表单验证补充完整返回

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