This commit is contained in:
=
2026-08-19 16:58:43 +08:00
parent f6389f2b67
commit c6d0f5b7d4
3 changed files with 24 additions and 36 deletions
@@ -110,7 +110,9 @@ public class CadreTrainingMineController {
cnd.where().andLike(CadreTrainingAct::getName, pageForm.getSearchKeyword()); cnd.where().andLike(CadreTrainingAct::getName, pageForm.getSearchKeyword());
} }
cnd.desc("info.applyTime"); cnd.desc("info.applyTime");
cnd.and("info.userId", "=", SecurityUtil.getUserId()); // 本人报名和本人代他人报名的记录都应在“我的报名”中展示。
cnd.and(Cnd.exps("info.userId", "=", SecurityUtil.getUserId())
.or("info.applyUserId", "=", SecurityUtil.getUserId()));
sql.setCondition(cnd); sql.setCondition(cnd);
Pagination<NutMap> pagination = cadreTrainingSignUpService.listPageMap(pageForm.getPageNumber(), pageForm.getPageSize(), sql); Pagination<NutMap> pagination = cadreTrainingSignUpService.listPageMap(pageForm.getPageNumber(), pageForm.getPageSize(), sql);
return Result.success(pagination); return Result.success(pagination);
@@ -68,7 +68,8 @@ public class CadreTrainingSignUpController {
@ApiOperation("分页查询") @ApiOperation("分页查询")
public Result pageData(@Valid PageForm pageForm,Integer year, boolean isEnrolled) { public Result pageData(@Valid PageForm pageForm,Integer year, boolean isEnrolled) {
Sql sql = Sqls.create(""" Sql sql = Sqls.create("""
SELECT -- 同一活动存在多条代报名记录时,活动列表仅展示一次。
SELECT DISTINCT
info.*, info.*,
CASE WHEN cts.id IS NOT NULL THEN 1 ELSE 0 END AS isEnrolled CASE WHEN cts.id IS NOT NULL THEN 1 ELSE 0 END AS isEnrolled
FROM FROM
@@ -101,6 +102,9 @@ public class CadreTrainingSignUpController {
List<ProcessInstance> instances = new ArrayList<>(); List<ProcessInstance> instances = new ArrayList<>();
for (CadreTrainingSignUp signUp : cadreTrainingSignUps) { for (CadreTrainingSignUp signUp : cadreTrainingSignUps) {
// 代报名记录必须以当前登录人为报名操作人,供“已报名”和“我的报名”按操作人查询。
signUp.setApplyUserId(SecurityUtil.getUserId());
signUp.setApplyUserUserName(SecurityUtil.getUserUsername());
if (StrUtil.isBlank(signUp.getId())) { if (StrUtil.isBlank(signUp.getId())) {
signUp.setApplyTime(new Date()); signUp.setApplyTime(new Date());
} }
@@ -65,7 +65,7 @@ const signForm = {
</el-table-column> </el-table-column>
<el-table-column label="操作" width="100px"> <el-table-column label="操作" width="100px">
<template slot-scope="scope"> <template slot-scope="scope">
<el-button type="danger" size="mini" @click="removeTeamUser(scope.$index)">删除 <el-button v-if="!scope.row.id" type="danger" size="mini" @click="removeTeamUser(scope.$index)">删除
</el-button> </el-button>
</template> </template>
</el-table-column> </el-table-column>
@@ -74,7 +74,7 @@ const signForm = {
<el-row type="flex" justify="end" class="mt20"> <el-row type="flex" justify="end" class="mt20">
<el-button @click="dialogVisible = false">取消</el-button> <el-button @click="dialogVisible = false">取消</el-button>
<el-button type="primary" @click="onConfirm" :loading="submitLoading" <el-button type="primary" @click="onConfirm" :loading="submitLoading"
:disabled="teamUsers.length === 0 ">确认报名 :disabled="pendingTeamUsers.length === 0 ">确认报名
</el-button> </el-button>
</el-row> </el-row>
</el-dialog> </el-dialog>
@@ -88,7 +88,7 @@ const signForm = {
dialogVisible: false, dialogVisible: false,
viewData: {}, viewData: {},
id: null, id: null,
//表格用户(实际上只包含当前用户) // 表格同时展示已报名人员和本次新增人员
teamUsers: [], teamUsers: [],
quota: 0, // 报名名额限制 quota: 0, // 报名名额限制
signedUsers: [], // 已报名人员列表 signedUsers: [], // 已报名人员列表
@@ -97,6 +97,10 @@ const signForm = {
} }
}, },
computed: { computed: {
// 仅未保存的人员需要参与本次提交和名额校验。
pendingTeamUsers() {
return this.teamUsers.filter(user => !user.id)
},
remainingQuota() { remainingQuota() {
// 如果 quota 为 null 或 undefined,显示"不限" // 如果 quota 为 null 或 undefined,显示"不限"
if (this.quota == null || this.quota === 0) return "不限" if (this.quota == null || this.quota === 0) return "不限"
@@ -143,7 +147,7 @@ const signForm = {
this.$message.error("请勿重复添加") this.$message.error("请勿重复添加")
return return
} }
if (this.quota > 0 && (this.signedUsers.length + this.teamUsers.length) >= this.quota) { if (this.quota > 0 && (this.signedUsers.length + this.pendingTeamUsers.length) >= this.quota) {
this.$message.error("已达到报名人数上限") this.$message.error("已达到报名人数上限")
return return
} }
@@ -164,28 +168,12 @@ const signForm = {
if (signedResponse.code === 0) { if (signedResponse.code === 0) {
this.signedUsers = Array.isArray(signedResponse.data) ? signedResponse.data : [] this.signedUsers = Array.isArray(signedResponse.data) ? signedResponse.data : []
// 已报名人员必须回显,避免分工会主席无法查看已代报记录。
this.teamUsers = this.signedUsers.slice()
// 检查当前用户是否已报名 // 检查当前用户是否已报名
const currentUser = this.signedUsers.find(user => user.userId === this.$store.state.user.id) const currentUser = this.signedUsers.find(user => user.userId === this.$store.state.user.id)
this.isSignUp = !!currentUser this.isSignUp = !!currentUser
// 显示当前用户信息
if (currentUser) {
this.teamUsers = this.signedUsers;
} else {
// 如果当前用户未报名,显示当前用户信息用于报名
this.teamUsers = [{
userId: this.$store.state.user.id,
userName: this.$store.state.user.username,
loginName: this.$store.state.user.loginname,
unitId: this.$store.state.user?.unit?.id,
unitName: this.$store.state.user?.unit?.name,
unionId: this.$store.state.user?.union?.id,
unionName: this.$store.state.user?.union?.name,
sex: this.$store.state.user.sex,
mobile: this.$store.state.user.mobile,
remark: ''
}]
}
} }
} catch (error) { } catch (error) {
this.$message.error("获取用户数据失败") this.$message.error("获取用户数据失败")
@@ -215,20 +203,14 @@ const signForm = {
//提交报名 //提交报名
async onConfirm() { async onConfirm() {
// 检查是否已报名(仅当当前用户已报名时) // 检查是否有新增报名人员
if (this.isSignUp && this.teamUsers.some(user => user.userId === this.$store.state.user.id)) { if (this.pendingTeamUsers.length === 0) {
this.$message.warning("您已报名该活动!")
return
}
// 检查是否有报名人员
if (this.teamUsers.length === 0) {
this.$message.warning("请至少添加一名报名人员!") this.$message.warning("请至少添加一名报名人员!")
return return
} }
// 检查名额是否足够 // 检查名额是否足够
if (this.quota > 0 && (this.signedUsers.length + this.teamUsers.length) > this.quota) { if (this.quota > 0 && (this.signedUsers.length + this.pendingTeamUsers.length) > this.quota) {
// 添加空值检查 // 添加空值检查
const remaining = this.quota ? this.quota - this.signedUsers.length : 0; const remaining = this.quota ? this.quota - this.signedUsers.length : 0;
this.$message.warning('报名人数超过限额!当前还可报名' + remaining + '人'); this.$message.warning('报名人数超过限额!当前还可报名' + remaining + '人');
@@ -239,13 +221,13 @@ const signForm = {
try { try {
this.submitLoading = true; this.submitLoading = true;
this.$confirm('您确定要为' + this.teamUsers.length + '人报名吗?', "提示", { confirmButtonText: "确定", this.$confirm('您确定要为' + this.pendingTeamUsers.length + '人报名吗?', "提示", { confirmButtonText: "确定",
cancelButtonText: "取消", cancelButtonText: "取消",
type: "warning" type: "warning"
}).then(async () => { }).then(async () => {
try { try {
// 构造报名数据数组 // 构造报名数据数组
const signUpDataArray = this.teamUsers.map(user => { const signUpDataArray = this.pendingTeamUsers.map(user => {
return { return {
cadreTrainingActId: this.id, cadreTrainingActId: this.id,
userId: user.userId, userId: user.userId,