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.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);
Pagination<NutMap> pagination = cadreTrainingSignUpService.listPageMap(pageForm.getPageNumber(), pageForm.getPageSize(), sql);
return Result.success(pagination);
@@ -68,7 +68,8 @@ public class CadreTrainingSignUpController {
@ApiOperation("分页查询")
public Result pageData(@Valid PageForm pageForm,Integer year, boolean isEnrolled) {
Sql sql = Sqls.create("""
SELECT
-- 同一活动存在多条代报名记录时,活动列表仅展示一次。
SELECT DISTINCT
info.*,
CASE WHEN cts.id IS NOT NULL THEN 1 ELSE 0 END AS isEnrolled
FROM
@@ -101,6 +102,9 @@ public class CadreTrainingSignUpController {
List<ProcessInstance> instances = new ArrayList<>();
for (CadreTrainingSignUp signUp : cadreTrainingSignUps) {
// 代报名记录必须以当前登录人为报名操作人,供“已报名”和“我的报名”按操作人查询。
signUp.setApplyUserId(SecurityUtil.getUserId());
signUp.setApplyUserUserName(SecurityUtil.getUserUsername());
if (StrUtil.isBlank(signUp.getId())) {
signUp.setApplyTime(new Date());
}
@@ -65,7 +65,7 @@ const signForm = {
</el-table-column>
<el-table-column label="操作" width="100px">
<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>
</template>
</el-table-column>
@@ -74,7 +74,7 @@ const signForm = {
<el-row type="flex" justify="end" class="mt20">
<el-button @click="dialogVisible = false">取消</el-button>
<el-button type="primary" @click="onConfirm" :loading="submitLoading"
:disabled="teamUsers.length === 0 ">确认报名
:disabled="pendingTeamUsers.length === 0 ">确认报名
</el-button>
</el-row>
</el-dialog>
@@ -88,7 +88,7 @@ const signForm = {
dialogVisible: false,
viewData: {},
id: null,
//表格用户(实际上只包含当前用户)
// 表格同时展示已报名人员和本次新增人员
teamUsers: [],
quota: 0, // 报名名额限制
signedUsers: [], // 已报名人员列表
@@ -97,6 +97,10 @@ const signForm = {
}
},
computed: {
// 仅未保存的人员需要参与本次提交和名额校验。
pendingTeamUsers() {
return this.teamUsers.filter(user => !user.id)
},
remainingQuota() {
// 如果 quota 为 null 或 undefined,显示"不限"
if (this.quota == null || this.quota === 0) return "不限"
@@ -143,7 +147,7 @@ const signForm = {
this.$message.error("请勿重复添加")
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("已达到报名人数上限")
return
}
@@ -164,28 +168,12 @@ const signForm = {
if (signedResponse.code === 0) {
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)
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) {
this.$message.error("获取用户数据失败")
@@ -215,20 +203,14 @@ const signForm = {
//提交报名
async onConfirm() {
// 检查是否已报名(仅当当前用户已报名时)
if (this.isSignUp && this.teamUsers.some(user => user.userId === this.$store.state.user.id)) {
this.$message.warning("您已报名该活动!")
return
}
// 检查是否有报名人员
if (this.teamUsers.length === 0) {
// 检查是否有新增报名人员
if (this.pendingTeamUsers.length === 0) {
this.$message.warning("请至少添加一名报名人员!")
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;
this.$message.warning('报名人数超过限额!当前还可报名' + remaining + '人');
@@ -239,13 +221,13 @@ const signForm = {
try {
this.submitLoading = true;
this.$confirm('您确定要为' + this.teamUsers.length + '人报名吗?', "提示", { confirmButtonText: "确定",
this.$confirm('您确定要为' + this.pendingTeamUsers.length + '人报名吗?', "提示", { confirmButtonText: "确定",
cancelButtonText: "取消",
type: "warning"
}).then(async () => {
try {
// 构造报名数据数组
const signUpDataArray = this.teamUsers.map(user => {
const signUpDataArray = this.pendingTeamUsers.map(user => {
return {
cadreTrainingActId: this.id,
userId: user.userId,