From ed46c3e9a49e78f6e0782d6080d176a436eec4d1 Mon Sep 17 00:00:00 2001 From: Paidax Date: Thu, 19 Jun 2025 03:27:05 +0800 Subject: [PATCH] =?UTF-8?q?=E7=96=97=E4=BC=91=E5=85=BB?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../therapyRecuperation/baseManagement.html | 188 +----------------- .../mobile/therapyRecuperation/lineInfo.html | 4 +- .../theRapyRecuperation/signUp/base.js | 115 +++++++---- .../theRapyRecuperation/signUp/index.html | 63 ++++-- 4 files changed, 126 insertions(+), 244 deletions(-) diff --git a/src/main/resources/views/mobile/therapyRecuperation/baseManagement.html b/src/main/resources/views/mobile/therapyRecuperation/baseManagement.html index 0904e8a..8eda315 100644 --- a/src/main/resources/views/mobile/therapyRecuperation/baseManagement.html +++ b/src/main/resources/views/mobile/therapyRecuperation/baseManagement.html @@ -223,9 +223,6 @@ layout("/mobile/platform.html"){
- {{baseData.baseName}}
@@ -250,16 +247,9 @@ layout("/mobile/platform.html"){
- - 上下滑动翻页,单击查看图片,再单击返回
-
@@ -354,36 +344,6 @@ layout("/mobile/platform.html"){ - - - - - - - - - - - - - - - - - - @@ -499,7 +459,7 @@ layout("/mobile/platform.html"){ async openRead(){ const url = '/platform/theRapyRecuperation/baseManagement/showBaseApplyPdf?baseName=' + (this.formData.baseName ? this.formData.baseName : '') + '&specificTime=' + (this.formData.specificTime ? this.formData.specificTime : '') - + '&sign=' + (this.formData.sign ? this.configData.sign : '') + '&idCard=' + (this.formData.idCard ? this.formData.idCard : '') + + '&sign=' + (this.formData.sign ? this.formData.sign : '') + '&idCard=' + (this.formData.idCard ? this.formData.idCard : '') this.readVisible = true this.$nextTick(() => { @@ -525,43 +485,6 @@ layout("/mobile/platform.html"){ this.$set(this.formData, "specificTime", moment(date).format('YYYY年MM月DD日')) this.timeVisible = false }, - getAgeAndSex(item){ - try { - const value = item.idCard - const age = this.calculateAgeFromIdCard(value) - this.$set(item, "age", age) - - const sex = this.getGenderFromIdCard(value) - this.$set(item, "sex", sex) - } catch (error) { - console.log(error) - } - }, - roomCancel() { - if (!this.self) { - this.formData.companionList[this.active].bedInfo.bedType = '' - } - this.roomVisible = false - }, - roomConfirm(value, index) { - if (this.self) { - this.formData.bedInfo.bedType = value - } else { - this.formData.companionList[this.active].bedInfo.bedType = value - } - this.roomVisible = false - }, - bedConfirm(value, index) { - if (this.self) { - this.formData.bedInfo.bedNum = value - } else { - this.formData.companionList[this.active].bedInfo.bedNum = value - } - this.bedVisible = false - }, - validator(value) { - return value != null - }, async joinSubmit() { if (this.hasReadSafe === false) { this.$toast('请先阅读安全告知书') @@ -572,7 +495,7 @@ layout("/mobile/platform.html"){ return } if (!this.formData.sign) { - this.$toast.fail('请签字') + this.$toast('请签字') return } this.formData.editOther = this.editOther ? this.editOther : '' @@ -613,12 +536,6 @@ layout("/mobile/platform.html"){ // on cancel }) }, - addCompanion() { - this.formData.companionList.push({userName: '', loginName: '', sex: '', relation: '', bedInfo: {}}) - }, - delCompanion() { - this.formData.companionList.splice(this.active, 1) - }, async join() { const re = await $.post('/platform/theRapyRecuperation/line/enroll/validSignUpInfo', { enroll: JSON.stringify({ @@ -710,106 +627,7 @@ layout("/mobile/platform.html"){ }) this.minDate = new Date(res.data.minDate) this.maxDate = new Date(res.data.maxDate) - }, - calculateAgeFromIdCard(idCard) { - // 检查身份证号码是否合法 - if (!idCard) { - throw new Error("Invalid ID card format") - } - - let birthDateStr - let birthYear, birthMonth, birthDay - - // 处理18位身份证号码 - if (idCard.length === 18) { - birthDateStr = idCard.substring(6, 14) - birthYear = parseInt(birthDateStr.substring(0, 4), 10) - birthMonth = parseInt(birthDateStr.substring(4, 6), 10) - 1 // 月份从0开始 - birthDay = parseInt(birthDateStr.substring(6, 8), 10) - } - // 处理15位身份证号码 - else if (idCard.length === 15) { - birthDateStr = idCard.substring(6, 12) - birthYear = parseInt("19" + birthDateStr.substring(0, 2), 10) // 使用字符串拼接 - birthMonth = parseInt(birthDateStr.substring(2, 4), 10) - 1 // 月份从0开始 - birthDay = parseInt(birthDateStr.substring(4, 6), 10) - } else { - throw new Error("Invalid ID card format. Only 15 or 18 digits are supported.") - } - - // 获取当前日期 - const currentDate = new Date() - - // 计算年龄 - let age = currentDate.getFullYear() - birthYear - - // 如果当前日期还没过生日,则年龄减1 - if (currentDate.getMonth() < birthMonth || (currentDate.getMonth() === birthMonth && currentDate.getDate() < birthDay)) { - age -= 1 - } - - return age - }, - getGenderFromIdCard(idCard) { - // 检查身份证号码是否合法 - if (!idCard) { - throw new Error("Invalid ID card format") - } - - let genderDigit - - // 处理18位身份证号码 - if (idCard.length === 18) { - genderDigit = parseInt(idCard.charAt(16), 10) // 第17位 - } - // 处理15位身份证号码 - else if (idCard.length === 15) { - genderDigit = parseInt(idCard.charAt(14), 10) // 第15位 - } else { - throw new Error("Invalid ID card format. Only 15 or 18 digits are supported.") - } - - // 判断性别 - if (genderDigit % 2 === 0) { - return "女" - } else { - return "男" - } - }, - validateIdCard(idCard) { - if (!idCard) { - return false - } - - // 18位身份证号码校验 - if (idCard.length === 18) { - const idCardRegex = /^[1-9]\d{5}(18|19|20)?\d{2}((0[1-9])|(10|11|12))(([0|1|2][0-9])|10|20|30|31)\d{3}(\d|[Xx])$/ - if (!idCardRegex.test(idCard)) { - return false - } - - // 校验码计算 - const weights = [7, 9, 10, 5, 8, 4, 2, 1, 6, 3, 7, 9, 10, 5, 8, 4, 2] - const checksums = ["1", "0", "X", "9", "8", "7", "6", "5", "4", "3", "2"] - let sum = 0 - for (let i = 0; i < 17; i++) { - sum += idCard[i] * weights[i] - } - const checksum = checksums[sum % 11] - return checksum === idCard[17].toUpperCase() - } - - // 15位身份证号码校验 - else if (idCard.length === 15) { - const idCardRegex = /^[1-9]\d{5}\d{2}((0[1-9])|(10|11|12))(([0|1|2][0-9])|10|20|30|31)\d{3}$/ - return idCardRegex.test(idCard) - } - - // 外国人或其他情况 - else { - return false - } - }, + } }, async created() { // 修改其他线路标识 diff --git a/src/main/resources/views/mobile/therapyRecuperation/lineInfo.html b/src/main/resources/views/mobile/therapyRecuperation/lineInfo.html index ac8a47c..07b47f9 100644 --- a/src/main/resources/views/mobile/therapyRecuperation/lineInfo.html +++ b/src/main/resources/views/mobile/therapyRecuperation/lineInfo.html @@ -806,11 +806,11 @@ layout("/mobile/platform.html"){ url = '/platform/theRapyRecuperation/line/enroll/doSignUpForLine' } - const msg = this.editOther ? ('此操作会取消之前报名线路,并修改为【'+ this.formData.lineName +'】是否确认?') : '请确保信息填写无误,是否确认?' + const msg = this.editOther ? ('此操作会取消之前报名线路,并修改为【'+ this.formData.lineName +'】是否确认提交?') : '请确保信息填写无误,是否确认提交?' vant.Dialog.confirm({ title: '温馨提示', message: msg, - confirmButtonText: '确认', + confirmButtonText: '提交', cancelButtonText: '取消', }).then(async () => { this.showButton = false diff --git a/src/main/resources/views/platform/theRapyRecuperation/signUp/base.js b/src/main/resources/views/platform/theRapyRecuperation/signUp/base.js index 550983d..db7e22a 100644 --- a/src/main/resources/views/platform/theRapyRecuperation/signUp/base.js +++ b/src/main/resources/views/platform/theRapyRecuperation/signUp/base.js @@ -63,7 +63,7 @@ const BASE = { 《安全告知书》 - 查看 + 查看
@@ -73,7 +73,7 @@ const BASE = { 《定点自由行申请表》 - 查看 + 查看
@@ -123,9 +123,7 @@ const BASE = { data(){ return{ id: '', - index: '', enrollId: '', - fromUrlByMy: '', baseData: {}, formData: { userName: "", @@ -139,9 +137,49 @@ const BASE = { companionList: [], }, formRules: { - userName: [{required: false, message: "必填", trigger: ["change", "blur"]}], - loginName: [{required: false, message: "必填", trigger: ["change", "blur"]}], - specificTime: [{required: false, message: "必填", trigger: ["change", "blur"]}], + idCard: [ + { + required: true, + validator: (rule, value, callback) => { + if (/^[1-9]\d{5}(18|19|20)?\d{2}((0[1-9])|(10|11|12))(([0|1|2][0-9])|10|20|30|31)\d{3}(\d|[Xx])$/.test(value)) { + // 18位身份证号码格式正确 + callback(); + } else if (/^[1-9]\d{7}((0[1-9])|(10|11|12))(([0|1|2][0-9])|10|20|30|31)\d{3}$/.test(value)) { + // 15位身份证号码格式正确 + callback(); + } else if (/^[1-9]\d{5}(18|19|20)?\d{2}((0[1-9])|(10|11|12))(([0|1|2][0-9])|10|20|30|31)\d{3}$/.test(value)) { + // 外国人身份证号码格式正确(18位) + callback(); + } else if (/^[1-9]\d{7}((0[1-9])|(10|11|12))(([0|1|2][0-9])|10|20|30|31)\d{3}$/.test(value)) { + // 外国人身份证号码格式正确(15位) + callback(); + } else { + // 格式错误,返回错误信息 + callback(new Error("身份证号码格式错误")); + } + }, + trigger: ["change", "blur"] + } + ], + mobile: [ + { + required: true, + validator: (rule, value, callback) => { + if (/^[1][345789][0-9]{9}$/.test(value)) { + // 手机号格式正确 + callback(); + } else if (/^\d+-\d+$/.test(value) && value.length <= 16) { + // 座机号格式正确 + callback(); + } else { + // 格式错误,返回错误信息 + callback(new Error(value.includes('-') ? '座机号码格式错误' : '手机号码格式错误')); + } + }, + trigger: ["change", "blur"] + } + ], + specificTime: [{required: true, message: "必填", trigger: ["change", "blur"]}], }, // 出行日期相关 timeVisible: false, @@ -271,7 +309,7 @@ const BASE = { } }, async join(){ - if (this.fromUrlByMy !== 'editDo') { + if (!this.enrollId) { if (this.editOther) { this.$set(this.formData, 'baseName', this.baseData.baseName) this.$set(this.formData, 'takePartInLineId', null) @@ -291,9 +329,7 @@ const BASE = { } } } - if(this.index == 3) { - await this.getTimeArray() - } + await this.getTimeArray() }, joinSubmit(){ if (this.hasReadSafe === false) { @@ -311,43 +347,38 @@ const BASE = { this.formData.editOther = this.editOther ? this.editOther : '' const cloneData = clone(this.formData) - this.$confirm('请确保信息填写无误,是否确认提交?', '提示', { - confirmButtonText: '提交', - cancelButtonText: '取消', - type: 'warning' - }).then(async () => { - this.showButton = false - const loading = this.$loading({ - lock: true, - text: '数据提交中...', - spinner: 'el-icon-loading', - background: 'rgba(0, 0, 0, 0.7)' - }) - const resp = await $.post('/platform/theRapyRecuperation/line/enroll/doSignUpForBaseManagement', { - enroll: JSON.stringify(cloneData), - }) - loading.close() - if (resp.code === 0) { - this.$message.success('报名成功') - this.$emit('success') - // vant.Dialog.alert({ - // title: '提示', - // message: '报名成功', - // }).then(() => { - // location.replace('/platform/mobile/theRapyRecuperation/myRecuperation?index=' + this.index) - // }) - } else { - this.$message.warning(resp.msg) - this.showButton = true + this.$refs.formRef.validate(valid => { + if (valid) { + this.$confirm('请确保信息填写无误,是否确认提交?', '提示', { + confirmButtonText: '提交', + cancelButtonText: '取消', + type: 'warning' + }).then(async () => { + this.showButton = false + const loading = this.$loading({ + lock: true, + text: '数据提交中...', + spinner: 'el-icon-loading', + background: 'rgba(0, 0, 0, 0.7)' + }) + const resp = await $.post('/platform/theRapyRecuperation/line/enroll/doSignUpForBaseManagement', { + enroll: JSON.stringify(cloneData), + }) + loading.close() + if (resp.code === 0) { + this.$message.success('操作成功') + this.$emit('success') + } else { + this.$message.warning(resp.msg) + this.showButton = true + } + }) } }) - }, async initData(data){ this.id = data.id - this.index = data.index this.enrollId = data.enrollId - this.fromUrlByMy = data.fromUrlByMy this.editOther = data.editOther await this.getData() diff --git a/src/main/resources/views/platform/theRapyRecuperation/signUp/index.html b/src/main/resources/views/platform/theRapyRecuperation/signUp/index.html index 36282d9..eecf76e 100644 --- a/src/main/resources/views/platform/theRapyRecuperation/signUp/index.html +++ b/src/main/resources/views/platform/theRapyRecuperation/signUp/index.html @@ -351,16 +351,21 @@ layout("/layouts/platform.html"){ + + +