diff --git a/src/main/java/com/budwk/app/zhgh/welfare/controller/WelfareSelectionSituationController.java b/src/main/java/com/budwk/app/zhgh/welfare/controller/WelfareSelectionSituationController.java index 3477c72..d28047e 100644 --- a/src/main/java/com/budwk/app/zhgh/welfare/controller/WelfareSelectionSituationController.java +++ b/src/main/java/com/budwk/app/zhgh/welfare/controller/WelfareSelectionSituationController.java @@ -22,6 +22,7 @@ import io.swagger.annotations.Api; import io.swagger.annotations.ApiOperation; import lombok.extern.slf4j.Slf4j; import org.nutz.aop.interceptor.ioc.TransAop; +import org.nutz.dao.Chain; import org.nutz.dao.Cnd; import org.nutz.dao.Dao; import org.nutz.ioc.aop.Aop; @@ -77,15 +78,31 @@ public class WelfareSelectionSituationController { @ApiOperation("获取某个用户选择信息") public Result getUserSelection(String projectId, String userId) { List list = dao.query(WelfareUserSelection.class, Cnd.where(WelfareUserSelection::getWelfareId, "=", projectId).and(WelfareUserSelection::getSelectUserId, "=", userId)); + Sys_user user = dao.fetch(Sys_user.class, userId); + String welfareMobile = user == null ? null : user.getWelfareMobile(); + // 管理员代选详情返回被代选用户的当前福利电话。 + list.forEach(selection -> selection.setWelfareMobile(welfareMobile)); return Result.success(list); } + /** + * 管理员为指定用户提交福利选择。 + * + * @param selections 选择项数组,每项包含选项 ID、选择数量,以及按项目要求填写的地址或签名 + * @param projectId 福利项目 ID + * @param userId 被代选用户 ID + * @param welfareMobile 被代选用户福利电话,须为 11 位手机号码 + * @return Result;成功时返回“选择成功”,校验失败时返回对应错误信息 + */ @At @Aop(TransAop.READ_COMMITTED) @SLog(type = "welfare", tag = "选择福利", msg = "代选福利") @SaCheckPermission("welfare.selection.situation") - public Result confirmSelect(@Param("selections") WelfareUserSelection[] selections, String projectId, String userId) { + public Result confirmSelect(@Param("selections") WelfareUserSelection[] selections, String projectId, String userId, String welfareMobile) { + if (welfareMobile == null || !welfareMobile.matches("^1[3456789]\\d{9}$")) { + return Result.error("请输入正确的福利电话"); + } WelfareProject project = dao.fetch(WelfareProject.class, projectId); if (!AuthUtil.hasRoleOr(RoleConstant.SYSADMIN.name(), RoleConstant.SCHOOL_UNION_ADMIN.name())) { if(project.getChoiceTimeEnd().getTime() list = dao.query(WelfareUserSelection.class, Cnd.where(WelfareUserSelection::getWelfareId, "=", projectId).and(WelfareUserSelection::getSelectUserId, "=", SecurityUtil.getUserId())); + Sys_user user = dao.fetch(Sys_user.class, SecurityUtil.getUserId()); + String welfareMobile = user == null ? null : user.getWelfareMobile(); + // 选择记录返回当前福利电话,供 PC 与 H5 的选择详情统一回显。 + list.forEach(selection -> selection.setWelfareMobile(welfareMobile)); return Result.success(list); } + /** + * 获取当前用户的福利电话。 + * + * @return 字符串类型的福利电话;用户不存在或尚未维护时返回空值 + */ + @At + @SaCheckPermission("welfare.user.select") + @ApiOperation("获取当前用户福利电话") + public Result getWelfareMobile() { + Sys_user user = dao.fetch(Sys_user.class, SecurityUtil.getUserId()); + return Result.success().addData(user == null ? null : user.getWelfareMobile()); + } + } diff --git a/src/main/java/com/budwk/app/zhgh/welfare/model/WelfareUserSelection.java b/src/main/java/com/budwk/app/zhgh/welfare/model/WelfareUserSelection.java index 76c260a..7fa4c41 100644 --- a/src/main/java/com/budwk/app/zhgh/welfare/model/WelfareUserSelection.java +++ b/src/main/java/com/budwk/app/zhgh/welfare/model/WelfareUserSelection.java @@ -86,11 +86,17 @@ public class WelfareUserSelection extends BaseModel implements Serializable { @Default("0") private Boolean isSelectByAdmin; + @Deprecated @Column - @Comment("手机号") + @Comment("历史联系电话(福利选择流程不再使用)") @ColDefine(type = ColType.VARCHAR, width = 20) private String mobile; + /** + * 当前用户福利电话,仅用于福利选择查询结果回显,不映射选择记录表字段。 + */ + private String welfareMobile; + @Column @Comment("物流信息") @ColDefine(type = ColType.MYSQL_JSON) diff --git a/src/main/java/com/budwk/app/zhgh/welfare/service/impl/WelfareListServiceImpl.java b/src/main/java/com/budwk/app/zhgh/welfare/service/impl/WelfareListServiceImpl.java index 5925580..f3cae88 100644 --- a/src/main/java/com/budwk/app/zhgh/welfare/service/impl/WelfareListServiceImpl.java +++ b/src/main/java/com/budwk/app/zhgh/welfare/service/impl/WelfareListServiceImpl.java @@ -157,7 +157,7 @@ public class WelfareListServiceImpl extends BaseServiceImpl impleme SELECT u.loginname, u.username, - u.mobile, + u.welfareMobile, un.name unionname, it.name unitname, IF(LOCATE('undefined',wpus.receiveAddress)>0,NULL,wpus.receiveAddress) as receiveAddress, @@ -187,7 +187,7 @@ public class WelfareListServiceImpl extends BaseServiceImpl impleme List exportEntities = new ArrayList<>(); exportEntities.add(new ExcelExportEntity("工号", "loginname", 20)); exportEntities.add(new ExcelExportEntity("姓名", "username", 20)); - exportEntities.add(new ExcelExportEntity("电话号码", "mobile", 20)); + exportEntities.add(new ExcelExportEntity("福利电话", "welfareMobile", 20)); exportEntities.add(new ExcelExportEntity("所在分工会", "unionname", 30)); exportEntities.add(new ExcelExportEntity("所在单位", "unitname", 50)); exportEntities.add(new ExcelExportEntity("选择份数", "selectNum", 20)); @@ -703,6 +703,7 @@ public class WelfareListServiceImpl extends BaseServiceImpl impleme t2.loginname, t2.username, t2.sex, + t2.welfareMobile, DATE_FORMAT(t2.birthday, '%Y-%m-%d') AS birthday FROM `welfare_list` t1 @@ -765,7 +766,7 @@ public class WelfareListServiceImpl extends BaseServiceImpl impleme exportEntities.add(new ExcelExportEntity("工号", "loginname", 20)); exportEntities.add(new ExcelExportEntity("姓名", "username", 20)); exportEntities.add(new ExcelExportEntity("性别", "sex", 20)); - exportEntities.add(new ExcelExportEntity("联系电话", "mobile", 20)); + exportEntities.add(new ExcelExportEntity("福利电话", "welfareMobile", 20)); exportEntities.add(new ExcelExportEntity("身份证号", "idCard", 30)); exportEntities.add(new ExcelExportEntity("在职状态", "userState", 20)); exportEntities.add(new ExcelExportEntity("聘用方式", "preparedBy", 20)); diff --git a/src/main/java/com/budwk/app/zhgh/welfare/service/impl/WelfareSelectionSituationServiceImpl.java b/src/main/java/com/budwk/app/zhgh/welfare/service/impl/WelfareSelectionSituationServiceImpl.java index 3f4c711..adbc3ed 100644 --- a/src/main/java/com/budwk/app/zhgh/welfare/service/impl/WelfareSelectionSituationServiceImpl.java +++ b/src/main/java/com/budwk/app/zhgh/welfare/service/impl/WelfareSelectionSituationServiceImpl.java @@ -57,7 +57,6 @@ public class WelfareSelectionSituationServiceImpl extends BaseServiceImpl0,NULL,wpus.receiveAddress) as receiveAddress, GROUP_CONCAT(DISTINCT wpso.optionName ,'(',wpus.selectNum,'份)') optionName, wpus.courierNumber diff --git a/src/main/java/com/budwk/app/zhgh/welfare/service/impl/WelfareStatisticsServiceImpl.java b/src/main/java/com/budwk/app/zhgh/welfare/service/impl/WelfareStatisticsServiceImpl.java index 518125a..995d9bf 100644 --- a/src/main/java/com/budwk/app/zhgh/welfare/service/impl/WelfareStatisticsServiceImpl.java +++ b/src/main/java/com/budwk/app/zhgh/welfare/service/impl/WelfareStatisticsServiceImpl.java @@ -151,7 +151,7 @@ public class WelfareStatisticsServiceImpl extends BaseServiceImpl exportEntities = new ArrayList<>(); exportEntities.add(new ExcelExportEntity("工号", "loginName", 20)); exportEntities.add(new ExcelExportEntity("姓名", "userName", 20)); - exportEntities.add(new ExcelExportEntity("电话号码", "mobile", 20)); + exportEntities.add(new ExcelExportEntity("福利电话", "welfareMobile", 20)); exportEntities.add(new ExcelExportEntity("所在分工会", "welfareUnionName", 20)); exportEntities.add(new ExcelExportEntity("所在单位", "welfareUnitName", 20)); exportEntities.add(new ExcelExportEntity("选择方式", "selectByAdminName", 20)); @@ -396,7 +396,7 @@ public class WelfareStatisticsServiceImpl extends BaseServiceImpl
-
联系电话
-
{{ mergedSelections[0]?.mobile || '暂无' }}
+
福利电话
+
{{ mergedSelections[0]?.welfareMobile || '暂无' }}
diff --git a/src/main/resources/views/platform/zhgh/welfare/select/optionSelect.js b/src/main/resources/views/platform/zhgh/welfare/select/optionSelect.js index ed39d6a..16a9c00 100644 --- a/src/main/resources/views/platform/zhgh/welfare/select/optionSelect.js +++ b/src/main/resources/views/platform/zhgh/welfare/select/optionSelect.js @@ -135,14 +135,14 @@ const optionSelect = { append-to-body custom-class="welfare-confirm-dialog">
- +
联系信息
- + @@ -230,15 +230,15 @@ const optionSelect = { showOptionDetailDialog: false, // 选项详情弹窗 selectedOption: null, // 当前选中的选项 contactForm: { - mobile: "", // 联系电话, + welfareMobile: "", // 福利电话 receiveAddress: "" }, contactRules: { - mobile: [ - { required: true, message: "请输入联系电话", trigger: "blur" }, + welfareMobile: [ + { required: true, message: "请输入福利电话", trigger: "blur" }, { pattern: /^1[3456789]\d{9}$/, - message: "请输入正确的手机号码", + message: "请输入正确的福利电话", trigger: "blur" } ] @@ -325,7 +325,7 @@ const optionSelect = { this.selectedRadioId = null this.contactForm = { - mobile: "", + welfareMobile: "", receiveAddress: "" } @@ -376,18 +376,8 @@ const optionSelect = { this.userSelection = resp.data this.hasSubmittedBefore = this.userSelection.length > 0 - if (this.userSelection && this.userSelection.length > 0) { - this.contactForm.mobile = this.userSelection[0]?.mobile - } else { - if (this.isProxySelect) { - // 否则使用默认手机号 - $.post("/platform/welfare/selection/situation/getMobileByUserId", { userId: this.userId }).then((res) => { - if (res.code === 0) { - this.contactForm.mobile = res.data - } - }) - } - } + // 福利电话始终从用户资料回显,不再读取选择记录中的 mobile。 + this.getWelfareMobile() // 地址回显 if (this.projectInfo.provideMode === 3) { @@ -422,9 +412,22 @@ const optionSelect = { }) }, + // 获取本人或被代选用户的福利电话,返回值为字符串或空值。 + getWelfareMobile() { + const url = this.isProxySelect + ? "/platform/welfare/selection/situation/getWelfareMobileByUserId" + : "/platform/welfare/userSelect/getWelfareMobile" + const formData = this.isProxySelect ? { userId: this.userId } : {} + this.$axios.post(url, formData).then((res) => { + if (res.code === 0) { + this.$set(this.contactForm, "welfareMobile", res.data || "") + } + }) + }, + // 执行提交 doSubmit() { - // 验证手机号 + // 校验福利电话和按配送方式动态要求的收货地址。 this.$refs.contactForm.validate((valid) => { if (!valid) { return @@ -442,7 +445,6 @@ const optionSelect = { { selectOptionId: this.selectedRadioId, selectNum: 1, - mobile: this.contactForm.mobile, receiveAddress: this.contactForm.receiveAddress } ] @@ -453,7 +455,6 @@ const optionSelect = { selections = this.selectedOptions.map((option) => ({ selectOptionId: option.id, selectNum: option.selectNum, - mobile: this.contactForm.mobile, receiveAddress: this.contactForm.receiveAddress })) } @@ -461,6 +462,7 @@ const optionSelect = { let url = "/platform/welfare/userSelect/confirmSelect" const formData = { projectId: this.projectId, + welfareMobile: this.contactForm.welfareMobile, selections: JSON.stringify(selections) } if (this.isProxySelect) { @@ -471,8 +473,6 @@ const optionSelect = { this.$axios .post(url, formData) .then((res) => { - this.isSubmitting = false - if (res.code === 0) { this.showConfirmDialog = false this.$message.success("选择成功") @@ -482,8 +482,10 @@ const optionSelect = { } }) .catch(() => { + // 网络异常由全局请求处理器提示。 + }) + .finally(() => { this.isSubmitting = false - // this.$message.error("网络错误,请重试") }) }) }, diff --git a/src/main/resources/views/platform/zhgh/welfare/selectionSituation/index.html b/src/main/resources/views/platform/zhgh/welfare/selectionSituation/index.html index 0787981..fa19890 100644 --- a/src/main/resources/views/platform/zhgh/welfare/selectionSituation/index.html +++ b/src/main/resources/views/platform/zhgh/welfare/selectionSituation/index.html @@ -190,7 +190,7 @@ layout("/layouts/platform.html"){ { prop: "welfareUnitName", label: "所属单位", sortable: true }, { prop: "selectedOptions", label: "所选福利", sortable: true }, { prop: "selectByAdminName", label: "是否管理员代选", sortable: true }, - { prop: "welfareMobile", label: "福利号码", sortable: true } + { prop: "welfareMobile", label: "福利电话", sortable: true } ], optionSelectVisible: false, selectByAdminDialogVisible: false, diff --git a/src/main/resources/views/platform/zhgh/welfare/statistics/selectedUser.js b/src/main/resources/views/platform/zhgh/welfare/statistics/selectedUser.js index 306ad71..f79fced 100644 --- a/src/main/resources/views/platform/zhgh/welfare/statistics/selectedUser.js +++ b/src/main/resources/views/platform/zhgh/welfare/statistics/selectedUser.js @@ -65,7 +65,7 @@ const selectedUser = { { prop: "preparedBy", label: "聘用方式", width: 120, sortable: true }, { prop: "postDoctoralJoinDate", label: "进站时间", sortable: true }, { label: "单位", prop: "welfareUnitName" }, - { label: "手机号", prop: "mobile" }, + { label: "福利电话", prop: "welfareMobile" }, { label: "选择方式", prop: "selectByAdminName" }, { label: "所选福利", prop: "selectOptionName" } ] diff --git a/src/main/resources/views/platform/zhghh5/welfare/mine/selectView.js b/src/main/resources/views/platform/zhghh5/welfare/mine/selectView.js index fd63b80..9ce1615 100644 --- a/src/main/resources/views/platform/zhghh5/welfare/mine/selectView.js +++ b/src/main/resources/views/platform/zhghh5/welfare/mine/selectView.js @@ -53,8 +53,8 @@ const selectView = {
-
联系电话
-
{{ mergedSelections[0]?.mobile || '暂无' }}
+
福利电话
+
{{ mergedSelections[0]?.welfareMobile || '暂无' }}
收货地址
diff --git a/src/main/resources/views/platform/zhghh5/welfare/select/index.html b/src/main/resources/views/platform/zhghh5/welfare/select/index.html index d080e24..959228f 100644 --- a/src/main/resources/views/platform/zhghh5/welfare/select/index.html +++ b/src/main/resources/views/platform/zhghh5/welfare/select/index.html @@ -358,8 +358,8 @@ layout("/layouts/platform_h5.html"){ column-gap: 10px; } - /* 手机号输入样式 */ - .mobile-input-section { + /* 福利电话输入样式 */ + .welfare-mobile-input-section { margin-bottom: 20px; background: #fff; border-radius: 8px; @@ -367,17 +367,17 @@ layout("/layouts/platform_h5.html"){ border: 1px solid #ebeef5; } - .mobile-input-section .van-field { + .welfare-mobile-input-section .van-field { padding: 12px 16px; } - .mobile-input-section .van-field__label { + .welfare-mobile-input-section .van-field__label { width: 70px; color: var(--text-secondary); font-weight: 500; } - .mobile-input-section .van-field__control { + .welfare-mobile-input-section .van-field__control { color: var(--text-primary); } @@ -678,14 +678,14 @@ layout("/layouts/platform_h5.html"){
确认选择
- -
+ +
@@ -792,10 +792,10 @@ layout("/layouts/platform_h5.html"){ hasSubmittedBefore: false, // 是否之前提交过 showOptionDetailDialog: false, // 选项详情弹窗 selectedOption: null, // 当前选中的选项 - mobileError: false, // 手机号错误标记 + welfareMobileError: false, // 福利电话错误标记 formData: { userSign: "", // 用户签名 - mobile: "", // 手机号码 + welfareMobile: "", // 福利电话 address: "" // 收货地址 }, @@ -884,18 +884,13 @@ layout("/layouts/platform_h5.html"){ this.userSelection = resp.data this.hasSubmittedBefore = this.userSelection.length > 0 - // 如果有用户选择数据,从中获取手机号 - if (this.userSelection && this.userSelection.length > 0 && this.userSelection[0].mobile) { - this.formData.mobile = this.userSelection[0].mobile - - // 获取签名信息(如果有) + // 历史选择仅负责回显签名,福利电话始终从用户资料获取。 + if (this.userSelection && this.userSelection.length > 0) { if (this.userSelection[0].userSign) { - this.formData.userSign = this.userSelection[0].userSign + this.$set(this.formData, "userSign", this.userSelection[0].userSign) } - } else if (this.$store.user && this.$store.user.mobile) { - // 如果没有选择过,使用store中的默认手机号 - this.formData.mobile = this.$store.user.mobile } + this.getWelfareMobile() // 地址回显 if (this.projectInfo.provideMode === 3) { @@ -930,6 +925,15 @@ layout("/layouts/platform_h5.html"){ }) }, + // 获取当前用户福利电话,返回值为字符串或空值。 + getWelfareMobile() { + this.$axios.post("/platform/welfare/userSelect/getWelfareMobile", {}).then((res) => { + if (res.code === 0) { + this.$set(this.formData, "welfareMobile", res.data || "") + } + }) + }, + // 执行提交 doSubmit() { // 再次检查截止时间 @@ -941,8 +945,8 @@ layout("/layouts/platform_h5.html"){ return } - // 验证手机号 - if (!this.validateMobile()) { + // 验证福利电话 + if (!this.validateWelfareMobile()) { return } @@ -975,8 +979,7 @@ layout("/layouts/platform_h5.html"){ selections = [ { selectOptionId: this.selectedRadioId, - selectNum: 1, - mobile: this.formData.mobile + selectNum: 1 } ] } @@ -985,8 +988,7 @@ layout("/layouts/platform_h5.html"){ else { selections = this.selectedOptions.map((option) => ({ selectOptionId: option.id, - selectNum: option.selectNum, - mobile: this.formData.mobile + selectNum: option.selectNum })) } @@ -1007,12 +1009,10 @@ layout("/layouts/platform_h5.html"){ this.$axios .post("/platform/welfare/userSelect/confirmSelect", { projectId: this.projectId, + welfareMobile: this.formData.welfareMobile, selections: JSON.stringify(selections) }) .then((res) => { - loading.clear() - this.isSubmitting = false - if (res.code === 0) { this.$toast.success("选择成功") setTimeout(() => { @@ -1023,24 +1023,26 @@ layout("/layouts/platform_h5.html"){ } }) .catch(() => { + this.$toast.fail("网络错误,请重试") + }) + .finally(() => { loading.clear() this.isSubmitting = false - this.$toast.fail("网络错误,请重试") }) }, - // 验证手机号 - validateMobile() { - if (!this.formData.mobile) { - this.mobileError = true - this.$toast.fail("请输入手机号码") + // 验证福利电话必填且为有效的 11 位手机号码,返回布尔值。 + validateWelfareMobile() { + if (!this.formData.welfareMobile) { + this.welfareMobileError = true + this.$toast.fail("请输入福利电话") return false } const mobileReg = /^1[3456789]\d{9}$/ - if (!mobileReg.test(this.formData.mobile)) { - this.mobileError = true - this.$toast.fail("请输入正确的手机号码") + if (!mobileReg.test(this.formData.welfareMobile)) { + this.welfareMobileError = true + this.$toast.fail("请输入正确的福利电话") return false }