bug修改

This commit is contained in:
=
2025-10-10 08:59:32 +08:00
parent 761ade5916
commit dc55b0701d
25 changed files with 323 additions and 128 deletions
@@ -11,7 +11,7 @@
</dict-tag></van-cell>
<van-cell title="入学年份">{{ viewData.childrenYear }}</van-cell>
<van-cell title="身份证号">{{ viewData.childrenIdCard }}</van-cell>
<van-cell title="出生日期">{{ viewData.childrenBirthday }}</van-cell>
<van-cell title="出生日期">{{ formatDate(viewData.childrenBirthday) }}</van-cell>
<van-cell title="性别">{{ viewData.childrenSex }}</van-cell>
<van-cell title="国籍">{{ viewData.childrenCountry }}</van-cell>
<van-cell title="就读学校">{{ viewData.childrenCurrentSchool }}</van-cell>
@@ -50,6 +50,31 @@
this.visible = true
this.getInfo()
},
// 添加日期格式化方法
formatDate(date) {
if (!date) return '';
// 如果已经是 yyyy-MM-dd 格式,直接返回
if (typeof date === 'string' && /^\d{4}-\d{2}-\d{2}/.test(date)) {
// 如果包含时间,只取日期部分
if (date.length > 10) {
return date.substring(0, 10);
}
return date;
}
// 否则转换为 yyyy-MM-dd 格式
try {
const d = new Date(date);
if (isNaN(d.getTime())) {
return date;
}
const year = d.getFullYear();
const month = String(d.getMonth() + 1).padStart(2, '0');
const day = String(d.getDate()).padStart(2, '0');
return year + '-' + month + '-' + day;
} catch (e) {
return date;
}
},
// 关闭
onClose(){
this.visible = false
@@ -46,8 +46,13 @@ layout("/layouts/platform_h5.html"){
show-toolbar
></van-picker>
</van-popup>
<van-field label="身份证号" v-model="formData.childrenIdCard" placeholder="请输入身份证号"></van-field>
<van-field
label="身份证号"
v-model="formData.childrenIdCard"
placeholder="请输入身份证号"
:rules="formRules.childrenIdCard"
required
></van-field> <van-field
label="出生年月"
v-model="formData.childrenBirthday"
placeholder="请选择出生年月"
@@ -96,16 +101,25 @@ layout("/layouts/platform_h5.html"){
<van-field label="监护人1" v-model="formData.guardianUserName1" readonly placeholder="读取信息中心数据"></van-field>
<van-field label="工号" v-model="formData.guardianLoginName1" readonly placeholder="读取信息中心数据"></van-field>
<van-field label="手机号码" v-model="formData.guardianMobile1" readonly placeholder="读取信息中心数据"></van-field>
<van-field
label="手机号码"
v-model="formData.guardianMobile1"
readonly
placeholder="读取信息中心数据"
:rules="formRules.guardianMobile1"
></van-field>
<van-field label="所在单位" v-model="formData.guardianUnitName1" readonly placeholder="读取信息中心数据"></van-field>
<van-field
label="监护人2"
v-model="formData.guardianUserName2"
placeholder="请输入监护人姓名"
></van-field>
<van-field label="工号" v-model="formData.guardianLoginName2" placeholder="没有则不填" ></van-field>
<van-field label="手机号码" v-model="formData.guardianMobile2" placeholder="请输入手机号码"></van-field>
<van-field
label="手机号码"
v-model="formData.guardianMobile2"
placeholder="请输入手机号码"
></van-field>
<van-field label="所在单位" v-model="formData.guardianUnitName2" placeholder="请输入所在单位"></van-field>
<van-field
label="备注"
@@ -190,28 +204,41 @@ layout("/layouts/platform_h5.html"){
currentDate: new Date(), // 添加这一行
minDate: new Date(1900, 0, 1),
maxDate: new Date(),
formRules: {
childrenIdCard: [
{ pattern: /^[1-9]\d{5}(18|19|20)\d{2}((0[1-9])|(1[0-2]))(([0-2][1-9])|10|20|30|31)\d{3}[0-9Xx]$/, message: '请输入正确的身份证号码' }
],
guardianMobile1: [
{ pattern: /^1[3-9]\d{9}$/, message: '请输入正确的手机号码' }
],
}
}
},
methods: {
onSave() {
this.$dialog.confirm({
title: "提示",
message: "您确定保存吗?"
}).then(() => {
// 创建提交数据的副本
const submitData = {...this.formData};
// 如果有年级代码值,则使用代码值提交
if (this.formData.childrenGradeCode) {
submitData.childrenGrade = this.formData.childrenGradeCode;
}
this.$axios.post("/platform/childManage/write/save", { data: JSON.stringify(submitData) }).then(res => {
if (res.code === 0) {
this.$toast(res.msg)
this.$pjaxReplace('/platform/childManage/mine/h5')
// 先进行表单验证
this.$refs.formRef.validate().then(() => {
this.$dialog.confirm({
title: "提示",
message: "您确定保存吗?"
}).then(() => {
// 创建提交数据的副本
const submitData = {...this.formData};
// 如果有年级代码值,则使用代码值提交
if (this.formData.childrenGradeCode) {
submitData.childrenGrade = this.formData.childrenGradeCode;
}
this.$axios.post("/platform/childManage/write/save", { data: JSON.stringify(submitData) }).then(res => {
if (res.code === 0) {
this.$toast(res.msg)
this.$pjaxReplace('/platform/childManage/mine/h5')
}
})
})
})
}).catch(() => {
// 验证失败,Vant 会自动显示错误信息
});
},
onChildrenGradeConfirm(o) {
// 显示名称给用户看