commit
This commit is contained in:
+57
-26
@@ -5,7 +5,6 @@ import cn.hutool.core.collection.CollUtil;
|
||||
import cn.hutool.core.lang.tree.Tree;
|
||||
import cn.hutool.core.lang.tree.TreeNode;
|
||||
import cn.hutool.core.lang.tree.TreeUtil;
|
||||
import cn.hutool.core.util.BooleanUtil;
|
||||
import cn.hutool.core.util.StrUtil;
|
||||
import com.budwk.app.base.annotation.SLog;
|
||||
import com.budwk.app.base.constant.RoleConstant;
|
||||
@@ -35,6 +34,7 @@ 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.Lang;
|
||||
import org.nutz.lang.util.NutMap;
|
||||
import org.nutz.mvc.annotation.At;
|
||||
import org.nutz.mvc.annotation.Ok;
|
||||
@@ -42,9 +42,11 @@ import org.nutz.mvc.annotation.POST;
|
||||
import org.nutz.mvc.annotation.Param;
|
||||
|
||||
import javax.validation.Valid;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Arrays;
|
||||
import java.util.List;
|
||||
import java.util.Optional;
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
@IocBean
|
||||
@At("/platform/teacherCongress/delegation")
|
||||
@@ -301,27 +303,55 @@ public class TeacherCongressDelegationController {
|
||||
throw new BaseException("参数错误");
|
||||
}
|
||||
|
||||
Record record = dao.fetch("sys_user_role", Cnd.where("tcSessionId", "=", sessionId).and("tcDelegationId", "=", delegationId).and("roleId", "=", role.getId()));
|
||||
String userId = Optional.ofNullable(record).map(r -> r.getString("userId")).orElse(null);
|
||||
|
||||
Sql sql = Sqls.create("""
|
||||
SELECT
|
||||
u.id as userId,
|
||||
u.loginname as loginName,
|
||||
u.username as userName,
|
||||
u.mobile,
|
||||
n.name as unitName
|
||||
FROM
|
||||
sys_user u
|
||||
LEFT JOIN sys_unit n on n.id = u.unitId
|
||||
WHERE
|
||||
u.id = @userId
|
||||
""");
|
||||
sql.setParam("userId", userId);
|
||||
sql.setCallback(Sqls.callback.map());
|
||||
dao.execute(sql);
|
||||
NutMap user = (NutMap) sql.getResult();
|
||||
return Result.success().addData(user);
|
||||
if (type.equals("TEACHER_CONGRESS_VICE_DELEGATION_HEAD")) {
|
||||
List<Record> recordList = dao.query("sys_user_role", Cnd.where("tcSessionId", "=", sessionId).and("tcDelegationId", "=", delegationId).and("roleId", "=", role.getId()));
|
||||
if (Lang.isEmpty(recordList)) {
|
||||
return Result.success(new ArrayList<>());
|
||||
}
|
||||
List<String> userIdList = recordList.stream().map(record -> record.getString("userId")).toList();
|
||||
String userIds = userIdList.stream()
|
||||
.map(s -> "'" + s + "'") // 给每个元素加上单引号
|
||||
.collect(Collectors.joining(",", "(", ")")); // 用逗号连接,并加上括号
|
||||
Sql sql = Sqls.create("""
|
||||
SELECT
|
||||
u.id as userId,
|
||||
u.loginname as loginName,
|
||||
u.username as userName,
|
||||
u.mobile,
|
||||
n.name as unitName
|
||||
FROM
|
||||
sys_user u
|
||||
LEFT JOIN sys_unit n on n.id = u.unitId
|
||||
WHERE
|
||||
u.id in %s
|
||||
""".formatted(userIds));
|
||||
List<NutMap> listMap = sysRoleService.listMap(sql);
|
||||
return Result.success(listMap);
|
||||
} else {
|
||||
Record record = dao.fetch("sys_user_role", Cnd.where("tcSessionId", "=", sessionId).and("tcDelegationId", "=", delegationId).and("roleId", "=", role.getId()));
|
||||
String userId = Optional.ofNullable(record).map(r -> r.getString("userId")).orElse(null);
|
||||
if (Lang.isEmpty(userId)) {
|
||||
return Result.success(new NutMap());
|
||||
}
|
||||
Sql sql = Sqls.create("""
|
||||
SELECT
|
||||
u.id as userId,
|
||||
u.loginname as loginName,
|
||||
u.username as userName,
|
||||
u.mobile,
|
||||
n.name as unitName
|
||||
FROM
|
||||
sys_user u
|
||||
LEFT JOIN sys_unit n on n.id = u.unitId
|
||||
WHERE
|
||||
u.id = @userId
|
||||
""");
|
||||
sql.setParam("userId", userId);
|
||||
sql.setCallback(Sqls.callback.map());
|
||||
dao.execute(sql);
|
||||
NutMap user = (NutMap) sql.getResult();
|
||||
return Result.success().addData(user);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -330,14 +360,14 @@ public class TeacherCongressDelegationController {
|
||||
* @param delegationId 代表团ID
|
||||
* @param sessionId 届次ID
|
||||
* @param userId 团长id
|
||||
* @param viceUserId 副团长id
|
||||
* @param viceUserIds 副团长id
|
||||
* @param contactUserId 联络人
|
||||
* @return
|
||||
*/
|
||||
@At
|
||||
@SaCheckPermission("tc.delegation")
|
||||
@Aop(TransAop.READ_COMMITTED)
|
||||
public Result insertHead(@Valid String delegationId, @Valid String sessionId, @Valid String userId, @Valid String viceUserId, String contactUserId) {
|
||||
public Result insertHead(@Valid String delegationId, @Valid String sessionId, @Valid String userId, @Valid @Param("viceUserIds") String[] viceUserIds, String contactUserId) {
|
||||
// 团长
|
||||
Sys_role role = sysRoleService.getByCode(RoleConstant.TEACHER_CONGRESS_DELEGATION_HEAD);
|
||||
dao.clear(Sys_user_role.class, Cnd.where(Sys_user_role::getTcDelegationId, "=", delegationId).and(Sys_user_role::getTcSessionId, "=", sessionId).and(Sys_user_role::getRoleId, "=", role.getId()));
|
||||
@@ -346,8 +376,9 @@ public class TeacherCongressDelegationController {
|
||||
// 副团长
|
||||
Sys_role role2 = sysRoleService.getByCode(RoleConstant.TEACHER_CONGRESS_VICE_DELEGATION_HEAD);
|
||||
dao.clear(Sys_user_role.class, Cnd.where(Sys_user_role::getTcDelegationId, "=", delegationId).and(Sys_user_role::getTcSessionId, "=", sessionId).and(Sys_user_role::getRoleId, "=", role2.getId()));
|
||||
dao.insert("sys_user_role", Chain.make("userId", viceUserId).add("roleId", role2.getId()).add("tcDelegationId", delegationId).add("tcSessionId", sessionId));
|
||||
|
||||
for (String viceUserId : viceUserIds) {
|
||||
dao.insert("sys_user_role", Chain.make("userId", viceUserId).add("roleId", role2.getId()).add("tcDelegationId", delegationId).add("tcSessionId", sessionId));
|
||||
}
|
||||
// 联络人
|
||||
Sys_role role3 = sysRoleService.getByCode(RoleConstant.TEACHER_CONGRESS_DELEGATION_CONTACT);
|
||||
dao.clear(Sys_user_role.class, Cnd.where(Sys_user_role::getTcDelegationId, "=", delegationId).and(Sys_user_role::getTcSessionId, "=", sessionId).and(Sys_user_role::getRoleId, "=", role3.getId()));
|
||||
|
||||
+69
-54
@@ -1,55 +1,56 @@
|
||||
const HEAD_FORM_TEMPLATE = {
|
||||
/*language=HTML*/
|
||||
template: `
|
||||
<el-dialog title="设置团长" :visible.sync="headDialogFormVisible" width="700px" :close-on-click-modal="false">
|
||||
<el-form :model="formData" ref="headFormRef" size="small" label-width="120px" :rules="formRules">
|
||||
<el-form-item prop="sessionId" label="教代会">
|
||||
<el-select v-model="formData.sessionId" disabled>
|
||||
<el-option v-for="item in sessionOptions" :label="item.fullName" :value="item.id" :key="item.id"></el-option>
|
||||
</el-select>
|
||||
</el-form-item>
|
||||
<el-form-item prop="userId" label="团长">
|
||||
<user-select v-model="formData.userId"
|
||||
v-if="headDialogFormVisible"
|
||||
api="/platform/teacherCongress/delegation/notHeadUser"
|
||||
:api_params="{sessionId:formData.sessionId,delegationId:formData.delegationId}"
|
||||
api_input_key_name="keyWord"
|
||||
:option_list="headOptions"
|
||||
option_value="userId"
|
||||
:option_label_func="(item)=>{return item.userName + item.loginName + '(' + item.unitName + ')'}"
|
||||
placeholder="请输入工号或者姓名"
|
||||
style="width: 100%"></user-select>
|
||||
</el-form-item>
|
||||
<el-form-item prop="viceUserId" label="副团长">
|
||||
<user-select v-model="formData.viceUserId"
|
||||
v-if="headDialogFormVisible"
|
||||
api="/platform/teacherCongress/delegation/notHeadUser"
|
||||
:api_params="{sessionId:formData.sessionId,delegationId:formData.delegationId}"
|
||||
api_input_key_name="keyWord"
|
||||
:option_list="viceHeadOptions"
|
||||
option_value="userId"
|
||||
:option_label_func="(item)=>{return item.userName + item.loginName + '(' + item.unitName + ')'}"
|
||||
placeholder="请输入工号或者姓名"
|
||||
style="width: 100%"></user-select>
|
||||
</el-form-item>
|
||||
<el-form-item prop="contactUserId" label="联络人">
|
||||
<user-select v-model="formData.contactUserId"
|
||||
v-if="headDialogFormVisible"
|
||||
api="/platform/teacherCongress/delegation/notHeadUser"
|
||||
:api_params="{sessionId:formData.sessionId,delegationId:formData.delegationId}"
|
||||
api_input_key_name="keyWord"
|
||||
:option_list="contactOptions"
|
||||
option_value="userId"
|
||||
:option_label_func="(item)=>{return item.userName + item.loginName + '(' + item.unitName + ')'}"
|
||||
placeholder="请输入工号或者姓名"
|
||||
style="width: 100%"></user-select>
|
||||
</el-form-item>
|
||||
</el-form>
|
||||
<div slot="footer" class="dialog-footer">
|
||||
<el-button @click="headDialogFormVisible = false">取 消</el-button>
|
||||
<el-button type="primary" @click="doSubmitHead">确 定</el-button>
|
||||
</div>
|
||||
</el-dialog>
|
||||
`,
|
||||
<el-dialog title="设置团长" :visible.sync="headDialogFormVisible" width="700px" :close-on-click-modal="false">
|
||||
<el-form :model="formData" ref="headFormRef" size="small" label-width="120px" :rules="formRules">
|
||||
<el-form-item prop="sessionId" label="教代会">
|
||||
<el-select v-model="formData.sessionId" disabled>
|
||||
<el-option v-for="item in sessionOptions" :label="item.fullName" :value="item.id"
|
||||
:key="item.id"></el-option>
|
||||
</el-select>
|
||||
</el-form-item>
|
||||
<el-form-item prop="userId" label="团长">
|
||||
<user-select v-model="formData.userId"
|
||||
v-if="headDialogFormVisible"
|
||||
api="/platform/teacherCongress/delegation/notHeadUser"
|
||||
:api_params="{sessionId:formData.sessionId,delegationId:formData.delegationId}"
|
||||
api_input_key_name="keyWord"
|
||||
:option_list="headOptions"
|
||||
option_value="userId"
|
||||
:option_label_func="(item)=>{return item.userName + item.loginName + '(' + item.unitName + ')'}"
|
||||
placeholder="请输入工号或者姓名"
|
||||
style="width: 100%"></user-select>
|
||||
</el-form-item>
|
||||
<el-form-item prop="viceUserId" label="副团长">
|
||||
<el-select v-model="formData.viceUserIds" multiple placeholder="请输入工号或者姓名"
|
||||
:remote-method="viceUserSelectUser" remote clearable filterable style="width: 100%">
|
||||
<el-option
|
||||
v-for="item in viceHeadOptions"
|
||||
:key="item.userId"
|
||||
:label="item.userName + item.loginName + '(' + item.unitName + ')'"
|
||||
:value="item.userId">
|
||||
</el-option>
|
||||
</el-select>
|
||||
</el-form-item>
|
||||
<el-form-item prop="contactUserId" label="联络人">
|
||||
<user-select v-model="formData.contactUserId"
|
||||
v-if="headDialogFormVisible"
|
||||
api="/platform/teacherCongress/delegation/notHeadUser"
|
||||
:api_params="{sessionId:formData.sessionId,delegationId:formData.delegationId}"
|
||||
api_input_key_name="keyWord"
|
||||
:option_list="contactOptions"
|
||||
option_value="userId"
|
||||
:option_label_func="(item)=>{return item.userName + item.loginName + '(' + item.unitName + ')'}"
|
||||
placeholder="请输入工号或者姓名"
|
||||
style="width: 100%"></user-select>
|
||||
</el-form-item>
|
||||
</el-form>
|
||||
<div slot="footer" class="dialog-footer">
|
||||
<el-button @click="headDialogFormVisible = false">取 消</el-button>
|
||||
<el-button type="primary" @click="doSubmitHead">确 定</el-button>
|
||||
</div>
|
||||
</el-dialog>
|
||||
`,
|
||||
data() {
|
||||
return {
|
||||
formData: {},
|
||||
@@ -64,12 +65,23 @@ const HEAD_FORM_TEMPLATE = {
|
||||
name: [{required: true, message: "必填", trigger: ["change", "blur"]}],
|
||||
code: [{required: true, message: "必填", trigger: ["change", "blur"]}],
|
||||
userId: [{required: true, message: "必填", trigger: ["change", "blur"]}],
|
||||
viceUserId: [{required: true, message: "必填", trigger: ["change", "blur"]}],
|
||||
// viceUserId: [{required: true, message: "必填", trigger: ["change", "blur"]}],
|
||||
// contactUserId: [{required: true, message: "必填", trigger: ["change", "blur"]}]
|
||||
}
|
||||
}
|
||||
},
|
||||
methods: {
|
||||
viceUserSelectUser(query) {
|
||||
if (query !== "") {
|
||||
$.get("/platform/teacherCongress/delegation/notHeadUser", {
|
||||
"keyWord": query,
|
||||
"sessionId": this.formData.sessionId,
|
||||
"delegationId": this.formData.delegationId
|
||||
}).then((res) => {
|
||||
this.viceHeadOptions = res.data
|
||||
})
|
||||
}
|
||||
},
|
||||
onOpen(delegationId, sessionId) {
|
||||
if (!delegationId || !sessionId) {
|
||||
return
|
||||
@@ -102,8 +114,9 @@ const HEAD_FORM_TEMPLATE = {
|
||||
}).then((res) => {
|
||||
if (res.code === 0) {
|
||||
if (res.data) {
|
||||
this.viceHeadOptions = [res.data]
|
||||
this.$set(this.formData, "viceUserId", res.data.userId)
|
||||
this.viceHeadOptions = res.data
|
||||
|
||||
this.$set(this.formData, "viceUserIds", res.data.map(v=>v.userId))
|
||||
}
|
||||
}
|
||||
})
|
||||
@@ -123,7 +136,9 @@ const HEAD_FORM_TEMPLATE = {
|
||||
doSubmitHead() {
|
||||
this.$refs.headFormRef.validate((valid) => {
|
||||
if (valid) {
|
||||
this.$axios.post("/platform/teacherCongress/delegation/insertHead", this.formData).then((res) => {
|
||||
let formData = clone(this.formData)
|
||||
if (formData.viceUserIds) formData.viceUserIds = JSON.stringify(formData.viceUserIds)
|
||||
this.$axios.post("/platform/teacherCongress/delegation/insertHead", formData).then((res) => {
|
||||
if (res.code === 0) {
|
||||
this.headDialogFormVisible = false
|
||||
this.$message.success(res.msg)
|
||||
|
||||
Reference in New Issue
Block a user