表单验证补充完整返回

This commit is contained in:
aixianling
2024-07-09 10:19:09 +08:00
parent dc1eacdc7f
commit bad99f9383

View File

@@ -5,7 +5,7 @@
<ai-title title="添加档案" isShowBack isShowBottomBorder @onBackClick="cancel(false)"></ai-title> <ai-title title="添加档案" isShowBack isShowBottomBorder @onBackClick="cancel(false)"></ai-title>
</template> </template>
<template slot="content"> <template slot="content">
<el-form class="content-right" :model="form" ref="ruleForm" :rules="rules" label-width="130px" <el-form class="content-right" :model="form" ref="form" :rules="rules" label-width="130px"
label-position="right" size="small"> label-position="right" size="small">
<ai-card title="基本信息"> <ai-card title="基本信息">
@@ -163,13 +163,13 @@ export default {
phone: '', phone: '',
birthday: '', birthday: '',
age: '', age: '',
fileUrl:[], fileUrl: [],
girdInfoList: [] girdInfoList: []
}, },
currCheckedKeys: [], currCheckedKeys: [],
dialog: false, dialog: false,
treeList: [], treeList: [],
treeArray:[], treeArray: [],
treeObj: { treeObj: {
checkedKeys: [], checkedKeys: [],
}, },
@@ -181,8 +181,8 @@ export default {
} }
}, },
computed:{ computed: {
rules(){ rules() {
const IdNumberPass = (rule, value, callback) => { const IdNumberPass = (rule, value, callback) => {
if (value) { if (value) {
if (ID.check(value)) { if (ID.check(value)) {
@@ -191,6 +191,7 @@ export default {
callback(new Error("身份证号格式错误")); callback(new Error("身份证号格式错误"));
} }
} }
callback()
// else { // else {
// callback(new Error("请输入身份证号")); // callback(new Error("请输入身份证号"));
// } // }
@@ -263,11 +264,11 @@ export default {
} }
}) })
if (code === 0) { if (code === 0) {
this.form = {...data,girdInfoList:[]} this.form = {...data, girdInfoList: []}
this.form.fileUrl = [{ this.form.fileUrl = [{
url: data.fileUrl url: data.fileUrl
}] }]
const target = this.treeArray?.find(v=>v.girdCode === data.girdCode) const target = this.treeArray?.find(v => v.girdCode === data.girdCode)
this.currCheckedKeys = [target.id] this.currCheckedKeys = [target.id]
} }
} catch (e) { } catch (e) {
@@ -287,14 +288,14 @@ export default {
this.dialog = false; this.dialog = false;
}, },
handleCheckChange(data, checked){ handleCheckChange(data, checked) {
if (checked) { if (checked) {
this.$refs.treeRef.setCheckedKeys([data.id]) this.$refs.treeRef.setCheckedKeys([data.id])
} }
}, },
onCheckChange(e) { onCheckChange(e) {
if(e.children && e.children.length>0){ if (e.children && e.children.length > 0) {
this.$refs.treeRef.setCheckedKeys([]); this.$refs.treeRef.setCheckedKeys([]);
} }
}, },
@@ -302,10 +303,10 @@ export default {
async addOrUpdate() { async addOrUpdate() {
try { try {
const {code} = await this.instance.post(`/app/appshoparchives/addOrUpdate`,{ const {code} = await this.instance.post(`/app/appshoparchives/addOrUpdate`, {
...this.form, ...this.form,
fileId:this.form.fileUrl[0]?.id, fileId: this.form.fileUrl[0]?.id,
fileUrl:this.form.fileUrl[0]?.path, fileUrl: this.form.fileUrl[0]?.path,
}) })
if (code === 0) { if (code === 0) {
this.$message.success('保存成功'); this.$message.success('保存成功');
@@ -317,13 +318,8 @@ export default {
}, },
handleSave() { handleSave() {
this.$refs['ruleForm'].validate(valid => { this.$refs.form.validate().then(() => this.addOrUpdate())
if (valid) {
this.addOrUpdate()
}
})
}, },
cancel() { cancel() {
this.$emit('change', { this.$emit('change', {
type: 'List', type: 'List',