组队
This commit is contained in:
+85
-3
@@ -1,24 +1,31 @@
|
||||
package com.budwk.app.module.activity.controller;
|
||||
|
||||
import cn.dev33.satoken.annotation.SaCheckPermission;
|
||||
import cn.hutool.core.util.StrUtil;
|
||||
import com.budwk.app.base.page.PageForm;
|
||||
import com.budwk.app.base.result.Result;
|
||||
import com.budwk.app.module.activity.models.ActGroup;
|
||||
import com.budwk.app.module.activity.models.ActUser;
|
||||
import com.budwk.app.module.activity.models.ActGroupUser;
|
||||
import com.budwk.app.module.activity.models.ActItemGroupScore;
|
||||
import com.budwk.app.module.activity.service.ActGroupService;
|
||||
import com.budwk.app.module.activity.service.ActUserService;
|
||||
import com.budwk.app.module.activity.vo.ActGroupVo;
|
||||
import com.budwk.app.module.activity.vo.ActUnGroupUserVo;
|
||||
import com.budwk.app.web.commons.slog.annotation.SLog;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.nutz.aop.interceptor.ioc.TransAop;
|
||||
import org.nutz.dao.Cnd;
|
||||
import org.nutz.dao.Dao;
|
||||
import org.nutz.dao.Sqls;
|
||||
import org.nutz.dao.sql.Sql;
|
||||
import org.nutz.dao.util.cri.SqlExpressionGroup;
|
||||
import org.nutz.ioc.aop.Aop;
|
||||
import org.nutz.ioc.loader.annotation.Inject;
|
||||
import org.nutz.ioc.loader.annotation.IocBean;
|
||||
import org.nutz.lang.util.NutMap;
|
||||
import org.nutz.mvc.annotation.At;
|
||||
import org.nutz.mvc.annotation.Ok;
|
||||
import org.nutz.mvc.annotation.Param;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
@@ -52,8 +59,37 @@ public class ActGroupController {
|
||||
|
||||
@At
|
||||
@SaCheckPermission("activity.group")
|
||||
public Result pageData(PageForm pageForm, String activityId){
|
||||
return null;
|
||||
public Result pageData(PageForm pageForm, String activityId, String groupName){
|
||||
Sql sql = Sqls.create("""
|
||||
SELECT
|
||||
ag.*,
|
||||
COUNT(agu.userId) AS groupNum,
|
||||
SUM(CASE WHEN u.sex = '男' THEN 1 ELSE 0 END) AS manNum,
|
||||
SUM(CASE WHEN u.sex = '女' THEN 1 ELSE 0 END) AS womanNum,
|
||||
MAX(CASE WHEN agu.isLeader = 1 THEN u.userName END) AS leaderName,
|
||||
MAX(CASE WHEN agu.isLeader = 1 THEN u.phone END) AS leaderPhone
|
||||
FROM
|
||||
act_group ag
|
||||
LEFT JOIN act_group_user agu ON agu.groupId = ag.id
|
||||
LEFT JOIN act_user u ON u.userId = agu.userId
|
||||
$condition
|
||||
""");
|
||||
Cnd cnd = Cnd.NEW();
|
||||
cnd.and("ag.activityId", "=", activityId);
|
||||
if (StrUtil.isNotBlank(pageForm.getSearchKeyword())) {
|
||||
SqlExpressionGroup seg = new SqlExpressionGroup();
|
||||
seg.orLike("u.userName", pageForm.getSearchKeyword());
|
||||
seg.orLike("u.phone", pageForm.getSearchKeyword());
|
||||
cnd.and(seg);
|
||||
}
|
||||
if (StrUtil.isNotBlank(groupName)) {
|
||||
cnd.and("ag,groupName", "like", "%" + groupName + "%");
|
||||
}
|
||||
cnd.asc("ag.sort");
|
||||
cnd.groupBy("ag.id");
|
||||
sql.setCondition(cnd);
|
||||
List<NutMap> nutMaps = actGroupService.listMap(sql);
|
||||
return Result.success().addData(nutMaps);
|
||||
}
|
||||
|
||||
|
||||
@@ -85,6 +121,27 @@ public class ActGroupController {
|
||||
}
|
||||
|
||||
|
||||
@At
|
||||
@Aop(TransAop.READ_COMMITTED)
|
||||
@SaCheckPermission("activity.group")
|
||||
@SLog(tag = "活动分组", msg = "删除分组")
|
||||
public Result doRemove(String id) {
|
||||
// 删除活动分组及分组的相关表格
|
||||
dao.clear(ActGroup.class, Cnd.where(ActGroup::getId, "=", id));
|
||||
dao.clear(ActGroupUser.class, Cnd.where(ActGroupUser::getGroupId, "=", id));
|
||||
dao.clear(ActItemGroupScore.class, Cnd.where(ActItemGroupScore::getGroupId, "=", id));
|
||||
return Result.success();
|
||||
}
|
||||
|
||||
|
||||
@At
|
||||
@SaCheckPermission("activity.group")
|
||||
public Result queryGroupList(String activityId){
|
||||
List<ActGroup> query = dao.query(ActGroup.class, Cnd.where(ActGroup::getActivityId, "=", activityId));
|
||||
return Result.success().addData(query);
|
||||
}
|
||||
|
||||
|
||||
@At
|
||||
@SaCheckPermission("activity.group")
|
||||
@SLog(tag = "活动分组", msg = "随机分组")
|
||||
@@ -93,4 +150,29 @@ public class ActGroupController {
|
||||
actGroupService.groupSetting(actGroupVo);
|
||||
return Result.success();
|
||||
}
|
||||
|
||||
|
||||
@At
|
||||
@SaCheckPermission("activity.group")
|
||||
public Result queryUnGroupUser(String activityId){
|
||||
Sql sql = Sqls.create("""
|
||||
SELECT
|
||||
u.*
|
||||
FROM
|
||||
act_un_group_user augu
|
||||
LEFT JOIN act_user u ON u.userId = augu.userId
|
||||
WHERE augu.activityId = @activityId
|
||||
""").setParam("activityId", activityId);
|
||||
List<NutMap> list = actUserService.listMap(sql);
|
||||
return Result.success(list);
|
||||
}
|
||||
|
||||
|
||||
@At
|
||||
@SaCheckPermission("activity.group")
|
||||
@SLog(tag = "活动分组", msg = "设置未分组人员")
|
||||
public Result unGroupUserSetting(ActUnGroupUserVo actUnGroupUserVo){
|
||||
actGroupService.unGroupUserSetting(actUnGroupUserVo);
|
||||
return Result.success();
|
||||
}
|
||||
}
|
||||
|
||||
@@ -3,6 +3,7 @@ package com.budwk.app.module.activity.service;
|
||||
import com.budwk.app.base.service.BaseService;
|
||||
import com.budwk.app.module.activity.models.ActGroup;
|
||||
import com.budwk.app.module.activity.vo.ActGroupVo;
|
||||
import com.budwk.app.module.activity.vo.ActUnGroupUserVo;
|
||||
|
||||
/**
|
||||
* @ClassName ActGroupService
|
||||
@@ -14,5 +15,15 @@ import com.budwk.app.module.activity.vo.ActGroupVo;
|
||||
public interface ActGroupService extends BaseService<ActGroup> {
|
||||
|
||||
|
||||
/**
|
||||
* 活动分组
|
||||
* @param groupVo
|
||||
*/
|
||||
void groupSetting(ActGroupVo groupVo);
|
||||
|
||||
/**
|
||||
* 设置未分组人员
|
||||
* @param unGroupUserVo
|
||||
*/
|
||||
void unGroupUserSetting(ActUnGroupUserVo unGroupUserVo);
|
||||
}
|
||||
|
||||
+96
-13
@@ -1,22 +1,19 @@
|
||||
package com.budwk.app.module.activity.service.impl;
|
||||
|
||||
import com.budwk.app.base.service.impl.BaseServiceImpl;
|
||||
import com.budwk.app.module.activity.models.ActGroup;
|
||||
import com.budwk.app.module.activity.models.ActGroupUser;
|
||||
import com.budwk.app.module.activity.models.ActUnGroupUser;
|
||||
import com.budwk.app.module.activity.models.ActUser;
|
||||
import com.budwk.app.module.activity.models.*;
|
||||
import com.budwk.app.module.activity.service.ActGroupService;
|
||||
import com.budwk.app.module.activity.vo.ActGroupVo;
|
||||
import com.budwk.app.module.activity.vo.ActUnGroupUserVo;
|
||||
import org.nutz.aop.interceptor.ioc.TransAop;
|
||||
import org.nutz.dao.Cnd;
|
||||
import org.nutz.dao.Dao;
|
||||
import org.nutz.dao.Sqls;
|
||||
import org.nutz.dao.sql.Sql;
|
||||
import org.nutz.ioc.aop.Aop;
|
||||
import org.nutz.ioc.loader.annotation.IocBean;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.Collections;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.*;
|
||||
import java.util.stream.Collectors;
|
||||
import java.util.stream.IntStream;
|
||||
|
||||
@@ -42,6 +39,7 @@ public class ActGroupServiceImpl extends BaseServiceImpl<ActGroup> implements Ac
|
||||
dao().clear(ActGroup.class, Cnd.where(ActGroup::getActivityId, "=", groupVo.getActivityId()));
|
||||
dao().clear(ActGroupUser.class, Cnd.where(ActGroupUser::getActivityId, "=", groupVo.getActivityId()));
|
||||
dao().clear(ActUnGroupUser.class, Cnd.where(ActUnGroupUser::getActivityId, "=", groupVo.getActivityId()));
|
||||
dao().clear(ActItemGroupScore.class, Cnd.where(ActItemGroupScore::getActivityId, "=", groupVo.getActivityId()));
|
||||
|
||||
// 查询报名了并且已经完成签到的人员
|
||||
List<ActUser> signUpUserList = dao().query(ActUser.class, Cnd.where(ActUser::getActivityId, "=", groupVo.getActivityId())
|
||||
@@ -52,7 +50,10 @@ public class ActGroupServiceImpl extends BaseServiceImpl<ActGroup> implements Ac
|
||||
|
||||
int result = Math.floorDiv(size, oneGroupLimitUserNum);
|
||||
// 初始化分组
|
||||
List<List<ActUser>> groups = Collections.nCopies(result, new ArrayList<>());
|
||||
List<List<ActUser>> groups = new ArrayList<>();
|
||||
for (int i = 0; i < result; i++) {
|
||||
groups.add(new ArrayList<>());
|
||||
}
|
||||
|
||||
// 分离男女用户
|
||||
Map<String, List<ActUser>> genderMap = signUpUserList.stream()
|
||||
@@ -90,7 +91,6 @@ public class ActGroupServiceImpl extends BaseServiceImpl<ActGroup> implements Ac
|
||||
}
|
||||
}
|
||||
|
||||
// 收集未分配的用户
|
||||
unassignedUsers.addAll(males.subList(maleIndex, males.size()));
|
||||
unassignedUsers.addAll(females.subList(femaleIndex, females.size()));
|
||||
|
||||
@@ -99,11 +99,12 @@ public class ActGroupServiceImpl extends BaseServiceImpl<ActGroup> implements Ac
|
||||
.mapToObj(index -> {
|
||||
ActGroup actGroup = new ActGroup();
|
||||
actGroup.setActivityId(groupVo.getActivityId());
|
||||
actGroup.setGroupName("第" + (index + 1) + "组");
|
||||
actGroup.setGroupName("第" + (index + 1) + "队");
|
||||
actGroup.setSort(index + 1);
|
||||
|
||||
List<ActGroupUser> userList = groups.get(index).stream().map(v -> {
|
||||
ActGroupUser user = new ActGroupUser();
|
||||
user.setUserId(v.getId());
|
||||
user.setUserId(v.getUserId());
|
||||
user.setActivityId(groupVo.getActivityId());
|
||||
return user;
|
||||
}).collect(Collectors.toList());
|
||||
@@ -113,10 +114,25 @@ public class ActGroupServiceImpl extends BaseServiceImpl<ActGroup> implements Ac
|
||||
}).toList();
|
||||
|
||||
|
||||
// 所有项目
|
||||
List<ActivityItem> actItemList = dao().query(ActivityItem.class, Cnd.where(ActivityItem::getActivityId, "=", groupVo.getActivityId()));
|
||||
// 往项目得分表里面插记录
|
||||
List<ActItemGroupScore> itemGroupScoreList = new ArrayList<>();
|
||||
|
||||
for (ActGroup group : groupList) {
|
||||
dao().insertWith(group, "groupUsers");
|
||||
}
|
||||
|
||||
// 构建小组项目得分表
|
||||
List<ActItemGroupScore> groupScoreList = actItemList.stream().map(item -> {
|
||||
ActItemGroupScore itemGroupScore = new ActItemGroupScore();
|
||||
itemGroupScore.setActivityId(groupVo.getActivityId());
|
||||
itemGroupScore.setItemId(item.getId());
|
||||
itemGroupScore.setGroupId(group.getId());
|
||||
return itemGroupScore;
|
||||
}).toList();
|
||||
itemGroupScoreList.addAll(groupScoreList);
|
||||
}
|
||||
dao().insert(itemGroupScoreList);
|
||||
|
||||
// 添加未能正确分组的人员
|
||||
List<ActUnGroupUser> userList = unassignedUsers.stream().map(v -> {
|
||||
@@ -127,4 +143,71 @@ public class ActGroupServiceImpl extends BaseServiceImpl<ActGroup> implements Ac
|
||||
}).toList();
|
||||
dao().insert(userList);
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
@Aop(TransAop.READ_COMMITTED)
|
||||
public void unGroupUserSetting(ActUnGroupUserVo unGroupUserVo) {
|
||||
// 查询还没有分组的人员
|
||||
List<ActUnGroupUser> query = dao().query(ActUnGroupUser.class, Cnd.where(ActUnGroupUser::getActivityId, "=", unGroupUserVo.getActivityId()));
|
||||
Set<Long> userIds = query.stream().map(ActUnGroupUser::getUserId).collect(Collectors.toSet());
|
||||
// 删除这些人员的分组信息
|
||||
dao().clear(ActGroupUser.class, Cnd.where(ActGroupUser::getActivityId, "=", unGroupUserVo.getActivityId()).and(ActGroupUser::getUserId, "in", userIds));
|
||||
|
||||
if (unGroupUserVo.getIsSeparateGroup() != null && unGroupUserVo.getIsSeparateGroup()) {
|
||||
// 构建分组用户
|
||||
List<ActGroupUser> userList = query.stream().map(v -> {
|
||||
ActGroupUser user = new ActGroupUser();
|
||||
user.setActivityId(unGroupUserVo.getActivityId());
|
||||
user.setUserId(v.getUserId());
|
||||
if (v.getUserId().equals(unGroupUserVo.getLeaderId())) {
|
||||
user.setIsLeader(true);
|
||||
}
|
||||
return user;
|
||||
}).toList();
|
||||
|
||||
// 查询出这个活动下最大的排序
|
||||
ActGroup sort = dao().fetch(ActGroup.class, Cnd.NEW().desc("sort"));
|
||||
|
||||
// 单独分组构建
|
||||
ActGroup actGroup = new ActGroup();
|
||||
actGroup.setActivityId(unGroupUserVo.getActivityId());
|
||||
actGroup.setGroupName(unGroupUserVo.getGroupName());
|
||||
actGroup.setSort(sort.getSort() + 1);
|
||||
actGroup.setGroupUsers(userList);
|
||||
dao().insertWith(actGroup, "groupUsers");
|
||||
|
||||
// 同时还要往小组得分记录表中查活动项目的数据
|
||||
List<ActivityItem> itemList = dao().query(ActivityItem.class, Cnd.where(ActivityItem::getActivityId, "=", unGroupUserVo.getActivityId()));
|
||||
// 构建小组项目得分表
|
||||
List<ActItemGroupScore> scoreList = itemList.stream().map(v -> {
|
||||
ActItemGroupScore itemGroupScore = new ActItemGroupScore();
|
||||
itemGroupScore.setActivityId(unGroupUserVo.getActivityId());
|
||||
itemGroupScore.setItemId(v.getId());
|
||||
itemGroupScore.setGroupId(actGroup.getId());
|
||||
return itemGroupScore;
|
||||
}).toList();
|
||||
dao().insert(scoreList);
|
||||
} else {
|
||||
// 不单独分组,分配到其他队伍
|
||||
List<ActGroupUser> unGroupUser = unGroupUserVo.getUnGroupUser();
|
||||
Map<Long, ActGroupUser> map = unGroupUser.stream().collect(Collectors.toMap(ActGroupUser::getUserId, v -> v));
|
||||
|
||||
List<ActGroupUser> userList = query.stream().map(v -> {
|
||||
// 要保证传递过来的数据中,不在数据表中存储的这些人员不插入
|
||||
ActGroupUser groupUser = map.get(v.getUserId());
|
||||
if (groupUser != null) {
|
||||
groupUser.setUserId(v.getUserId());
|
||||
groupUser.setActivityId(unGroupUserVo.getActivityId());
|
||||
groupUser.setGroupId(groupUser.getGroupId());
|
||||
return groupUser;
|
||||
} else {
|
||||
return null;
|
||||
}
|
||||
}).filter(Objects::nonNull).toList();
|
||||
dao().insert(userList);
|
||||
}
|
||||
// 分完之后,删除这个活动下的未分组人员
|
||||
dao().clear(ActUnGroupUser.class, Cnd.where(ActUnGroupUser::getActivityId, "=", unGroupUserVo.getActivityId()));
|
||||
}
|
||||
}
|
||||
|
||||
@@ -0,0 +1,32 @@
|
||||
package com.budwk.app.module.activity.vo;
|
||||
|
||||
import com.budwk.app.module.activity.models.ActGroupUser;
|
||||
import lombok.Data;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* @version 1.0
|
||||
* @Author zzr
|
||||
* @name:ActUnGroupUserVo
|
||||
* @Date 2025/4/30 15:01
|
||||
* @注释 :未分组人员
|
||||
*/
|
||||
@Data
|
||||
public class ActUnGroupUserVo {
|
||||
|
||||
// 活动id
|
||||
private Long activityId;
|
||||
|
||||
// 是否单独分组
|
||||
private Boolean isSeparateGroup;
|
||||
|
||||
// 分组名称
|
||||
private String groupName;
|
||||
|
||||
// 领队id
|
||||
private Long leaderId;
|
||||
|
||||
// 未分组人员
|
||||
private List<ActGroupUser> unGroupUser;
|
||||
}
|
||||
@@ -35,7 +35,6 @@ const GROUP_SETTING = {
|
||||
<el-form-item label="男用户限制人数" prop="manUserNum">
|
||||
<el-input-number style="width: 100%" v-model="form.manUserNum"
|
||||
placeholder="请输入男用户限制人数"></el-input-number>
|
||||
<span style="color: #bc2a25">设-1则标识不限制</span>
|
||||
</el-form-item>
|
||||
</el-col>
|
||||
<el-col :span="12">
|
||||
@@ -44,6 +43,7 @@ const GROUP_SETTING = {
|
||||
placeholder="请输入女用户限制人数"></el-input-number>
|
||||
</el-form-item>
|
||||
</el-col>
|
||||
<span style="color: #bc2a25;margin-left: 150px">设置-1,系统会将自动分配,尽可能的保持每队男女运动员数量一致</span>
|
||||
</el-row>
|
||||
</el-form>
|
||||
<span slot="footer" class="dialog-footer">
|
||||
@@ -92,6 +92,7 @@ const GROUP_SETTING = {
|
||||
this.groupingDialog = false
|
||||
this.$refs.formRef.resetFields()
|
||||
this.$message.success(resp.msg)
|
||||
this.$emit('success')
|
||||
} else {
|
||||
this.$message.error('操作失败')
|
||||
}
|
||||
|
||||
@@ -1,6 +1,17 @@
|
||||
<!--#
|
||||
layout("/layouts/platform_1.html"){
|
||||
#-->
|
||||
<style>
|
||||
.un_group_user_span {
|
||||
position: absolute;
|
||||
top: -6px; right: -6px;
|
||||
background-color: #bc2a25;
|
||||
color: white;
|
||||
border-radius: 50%;
|
||||
padding: 2px 6px;
|
||||
font-size: 12px;
|
||||
}
|
||||
</style>
|
||||
<div id="app">
|
||||
<el-card shadow="never">
|
||||
<div class="search">
|
||||
@@ -30,36 +41,125 @@ layout("/layouts/platform_1.html"){
|
||||
</el-select>
|
||||
</div>
|
||||
</div>
|
||||
<div class="search-item">
|
||||
<div class="search-item-label">队伍名称</div>
|
||||
<div class="search-item-option">
|
||||
<el-input v-model="pageForm.groupName" placeholder="请输入队伍名称"></el-input>
|
||||
</div>
|
||||
</div>
|
||||
<div class="search-item">
|
||||
<div class="search-item-label">运动员信息</div>
|
||||
<div class="search-item-option">
|
||||
<el-input v-model="pageForm.searchKeyword" placeholder="请输入运动员姓名、联系方式"></el-input>
|
||||
</div>
|
||||
</div>
|
||||
<div class="search-query">
|
||||
<el-button type="primary" icon="el-icon-search" @click="doSearch">搜索</el-button>
|
||||
</div>
|
||||
</div>
|
||||
</el-card>
|
||||
|
||||
<el-card shadow="never" class="mt-3">
|
||||
<el-row type="flex" class="mb-3" style="justify-content: flex-end">
|
||||
<el-button icon="el-icon-plus" type="primary" size="small" @click="openGrouping">开始分组</el-button>
|
||||
<el-row type="flex" style="justify-content: flex-start" class="mb-3">
|
||||
<el-button type="primary" size="small" @click="openGrouping">开始分组</el-button>
|
||||
<div v-if="unGroupUser && unGroupUser.length > 0" style="margin-left: 10px; display: inline-block;">
|
||||
<el-button type="warning" size="small" style="position: relative;" @click="doUnGroupUserSetting">
|
||||
未分组人员
|
||||
<span class="un_group_user_span">{{ unGroupUser.length }}</span>
|
||||
</el-button>
|
||||
</div>
|
||||
</el-row>
|
||||
<el-table v-loading="tableLoading" show-overflow-tooltip :data="tableData">
|
||||
<el-table-column label="序号" type="index" header-align="center" align="center" width="50"></el-table-column>
|
||||
<el-table-column label="队伍名称" prop="groupName"></el-table-column>
|
||||
<el-table-column label="队伍总人数" prop="groupNum"></el-table-column>
|
||||
<el-table-column label="男运动员人数" prop="manNum"></el-table-column>
|
||||
<el-table-column label="女运动员人数" prop="womanNum"></el-table-column>
|
||||
<el-table-column label="领队" prop="leaderName">
|
||||
<template #default="{row}">
|
||||
<el-tag v-if="row.leaderName">{{row.leaderName}}</el-tag>
|
||||
<el-tag v-else type="warning">未设置</el-tag>
|
||||
</template>
|
||||
</el-table-column>
|
||||
<el-table-column label="领队联系方式" prop="leaderPhone">
|
||||
<template #default="{row}">
|
||||
<el-tag v-if="row.leaderPhone">{{row.leaderPhone}}</el-tag>
|
||||
<el-tag v-else type="warning">未设置</el-tag>
|
||||
</template>
|
||||
</el-table-column>
|
||||
<el-table-column label="操作" fixed="right" width="250">
|
||||
<template #default="scope">
|
||||
<el-button type="primary" size="mini" @click="openView(scope.row)">查看</el-button>
|
||||
<el-button type="primary" size="mini" @click="openAdjustGroup(scope.row)">调整</el-button>
|
||||
<el-button type="danger" size="mini" @click="doRemove(scope.row)">删除</el-button>
|
||||
</template>
|
||||
</el-table-column>
|
||||
</el-table>
|
||||
</el-card>
|
||||
|
||||
<group-setting ref="groupSettingRef"></group-setting>
|
||||
<group-setting ref="groupSettingRef" @success="successGroup"></group-setting>
|
||||
|
||||
<un-group-user ref="unGroupUserRef" @success="successGroup"></un-group-user>
|
||||
</div>
|
||||
<script>
|
||||
<!--#include('groupSetting.js'){}#-->
|
||||
<!--#include('unGroupUser.js'){}#-->
|
||||
new Vue({
|
||||
el: "#app",
|
||||
mixins: [initTableMixins],
|
||||
components: {
|
||||
"group-setting": GROUP_SETTING
|
||||
"group-setting": GROUP_SETTING,
|
||||
"un-group-user": UN_GROUP_USER
|
||||
},
|
||||
data() {
|
||||
return {
|
||||
pageForm: {
|
||||
year: new Date().getFullYear() + ""
|
||||
},
|
||||
activityList: []
|
||||
activityList: [],
|
||||
unGroupUser: []
|
||||
}
|
||||
},
|
||||
methods: {
|
||||
openView(row){
|
||||
|
||||
},
|
||||
openAdjustGroup(row){
|
||||
|
||||
},
|
||||
async doRemove(row) {
|
||||
this.$confirm('此操作将会删除与该小队相关的所有信息,确定要删除吗?', '提示', {
|
||||
type: 'warning',
|
||||
confirmButtonText: '确定',
|
||||
cancelButtonText: '取消'
|
||||
}).then(async () => {
|
||||
const resp = await $.post('/platform/activity/group/doRemove', {
|
||||
id: row.id
|
||||
})
|
||||
if (resp.code === 0) {
|
||||
await this.pageData()
|
||||
this.$message.success(resp.msg)
|
||||
} else {
|
||||
this.$message.error(resp.msg)
|
||||
}
|
||||
})
|
||||
},
|
||||
// 处理没有分组的人员
|
||||
doUnGroupUserSetting(){
|
||||
if (!this.pageForm.activityId) {
|
||||
this.$message.error("请选择活动")
|
||||
return
|
||||
}
|
||||
const activity = this.activityList.find(v=>v.id === this.pageForm.activityId)
|
||||
this.$nextTick(() => {
|
||||
this.$refs.unGroupUserRef.onOpen({
|
||||
activityId: activity.id,
|
||||
activityName: activity.title,
|
||||
unGroupUser: this.unGroupUser
|
||||
})
|
||||
})
|
||||
},
|
||||
// 开始分组
|
||||
openGrouping(){
|
||||
if (!this.pageForm.activityId) {
|
||||
this.$message.error("请选择活动")
|
||||
@@ -67,6 +167,10 @@ layout("/layouts/platform_1.html"){
|
||||
}
|
||||
this.$refs.groupSettingRef.onOpen(this.pageForm.activityId)
|
||||
},
|
||||
async successGroup(){
|
||||
this.doSearch()
|
||||
await this.getUnGroupUser()
|
||||
},
|
||||
async getActivityList(){
|
||||
const resp = await $.post('/platform/activity/user/getActivityList', {
|
||||
year: this.pageForm.year
|
||||
@@ -77,7 +181,30 @@ layout("/layouts/platform_1.html"){
|
||||
} else {
|
||||
this.$set(this.pageForm, 'activityId', '')
|
||||
}
|
||||
// this.pageData()
|
||||
await this.pageData()
|
||||
await this.getUnGroupUser()
|
||||
},
|
||||
async getUnGroupUser(){
|
||||
const resp = await $.post('/platform/activity/group/queryUnGroupUser', {
|
||||
activityId: this.pageForm.activityId
|
||||
})
|
||||
if (resp.code === 0) {
|
||||
this.unGroupUser = resp.data
|
||||
} else {
|
||||
this.unGroupUser = []
|
||||
}
|
||||
},
|
||||
doSearch(){
|
||||
this.pageData()
|
||||
this.getUnGroupUser()
|
||||
},
|
||||
async pageData(){
|
||||
const resp = await $.post('/platform/activity/group/pageData', this.pageForm)
|
||||
if (resp.code === 0) {
|
||||
this.tableData = resp.data
|
||||
} else {
|
||||
this.$message.warning('查询失败')
|
||||
}
|
||||
}
|
||||
},
|
||||
created() {
|
||||
|
||||
@@ -0,0 +1,117 @@
|
||||
const UN_GROUP_USER = {
|
||||
template: /*language=HTML*/ `
|
||||
<el-dialog title="分配小队" :visible.sync="unGroupUserDialog" width="60%">
|
||||
<el-form :model="form" :rules="formRules" ref="formRef" label-width="100px" style="max-height: 600px;overflow-y: auto">
|
||||
<el-form-item label="活动名称" prop="activityName">
|
||||
<el-input v-model="form.activityName" readonly></el-input>
|
||||
</el-form-item>
|
||||
<el-form-item prop="isSeparateGroup">
|
||||
<template slot="label">
|
||||
<el-tooltip class="item" effect="dark" content="单独分组表示:未分组人员单独形成一个小队" placement="top-start">
|
||||
<span>单独分组</span>
|
||||
</el-tooltip>
|
||||
</template>
|
||||
<el-radio-group v-model="form.isSeparateGroup" size="small">
|
||||
<el-radio :label="true" border>是</el-radio>
|
||||
<el-radio :label="false" border>否</el-radio>
|
||||
</el-radio-group>
|
||||
</el-form-item>
|
||||
|
||||
<template v-if="form.isSeparateGroup">
|
||||
<el-form-item label="队伍名称" prop="groupName">
|
||||
<el-input v-model="form.groupName" placeholder="请输入队伍名称"></el-input>
|
||||
</el-form-item>
|
||||
<el-form-item label="选择领队" prop="leaderId">
|
||||
<el-select placeholder="请选择领队"
|
||||
style="width: 100%;"
|
||||
v-model="form.leaderId">
|
||||
<el-option :label="item.userName" :value="item.userId"
|
||||
v-for="item in form.unGroupUser"></el-option>
|
||||
</el-select>
|
||||
</el-form-item>
|
||||
</template>
|
||||
|
||||
<el-form-item label="未分组人员" prop="unGroupUser">
|
||||
<el-table :data="form.unGroupUser" border size="small" width="100%">
|
||||
<el-table-column v-if="form.isSeparateGroup === false" label="设置队伍" prop="groupId" fixed width="200">
|
||||
<template slot-scope="{row}">
|
||||
<el-select placeholder="请选择队伍"
|
||||
style="width: 100%;"
|
||||
v-model="row.groupId">
|
||||
<el-option :label="item.groupName" :value="item.id"
|
||||
v-for="item in groupList"></el-option>
|
||||
</el-select>
|
||||
</template>
|
||||
</el-table-column>
|
||||
<el-table-column label="姓名" prop="userName"></el-table-column>
|
||||
<el-table-column label="性别" prop="sex"></el-table-column>
|
||||
<el-table-column label="联系方式" prop="phone"></el-table-column>
|
||||
<el-table-column label="身份证件号" prop="idCard"></el-table-column>
|
||||
<el-table-column label="单位名称" prop="unitName"></el-table-column>
|
||||
<el-table-column label="职务" prop="position"></el-table-column>
|
||||
</el-table>
|
||||
</el-form-item>
|
||||
|
||||
</el-form>
|
||||
<div slot="footer" class="dialog-footer">
|
||||
<el-button @click="unGroupUserDialog = false">取 消</el-button>
|
||||
<el-button type="primary" @click="doUnGroupUserSetting">确 定</el-button>
|
||||
</div>
|
||||
</el-dialog>
|
||||
`,
|
||||
data(){
|
||||
return {
|
||||
unGroupUserDialog: false,
|
||||
form: {
|
||||
activityId: '',
|
||||
activityName: '',
|
||||
unGroupUser: []
|
||||
},
|
||||
formRules: {
|
||||
isSeparateGroup: [{ required: true, message: '请选择是否单独分组', trigger: ['blur', 'change'] }],
|
||||
groupName: [{ required: true, message: '请填写队伍名称', trigger: ['blur', 'change'] }],
|
||||
leaderId: [{ required: true, message: '请选择领队', trigger: ['blur', 'change'] }],
|
||||
},
|
||||
groupList: [],
|
||||
}
|
||||
},
|
||||
methods: {
|
||||
async onOpen(formData){
|
||||
this.form = {...formData}
|
||||
await this.getGroupList()
|
||||
this.unGroupUserDialog = true
|
||||
},
|
||||
async getGroupList(){
|
||||
const resp = await $.post('/platform/activity/group/queryGroupList', {
|
||||
activityId: this.form.activityId
|
||||
})
|
||||
if (resp.code === 0) {
|
||||
this.groupList = resp.data
|
||||
}
|
||||
},
|
||||
async doUnGroupUserSetting(){
|
||||
// 确定要提交吗?
|
||||
this.$refs.formRef.validate(async valid => {
|
||||
if (!valid) {
|
||||
return
|
||||
}
|
||||
this.$confirm('确定要提交吗?', '提示', {
|
||||
type: 'warning',
|
||||
confirmButtonText: '确定',
|
||||
cancelButtonText: '取消'
|
||||
}).then(async () => {
|
||||
const formData = JSON.parse(JSON.stringify(this.form))
|
||||
formData.unGroupUser = JSON.stringify(formData.unGroupUser)
|
||||
const resp = await $.post('/platform/activity/group/unGroupUserSetting', formData)
|
||||
if (resp.code === 0) {
|
||||
this.$message.success(resp.msg)
|
||||
this.unGroupUserDialog = false
|
||||
this.$emit('success')
|
||||
} else {
|
||||
this.$message.error(resp.msg)
|
||||
}
|
||||
})
|
||||
})
|
||||
},
|
||||
}
|
||||
}
|
||||
@@ -98,7 +98,7 @@ layout("/layouts/platform_1.html"){
|
||||
<!-- placeholder="请输入姓名"></el-input>-->
|
||||
</template>
|
||||
</el-table-column>
|
||||
<el-table-column label="性别" prop="name" width="200">
|
||||
<el-table-column label="性别" prop="sex" width="200">
|
||||
<template slot-scope="{row}">
|
||||
<el-radio-group v-model="row.sex">
|
||||
<el-radio label="男"></el-radio>
|
||||
|
||||
Reference in New Issue
Block a user