资产表单验证规则

master
xy 1 year ago
parent 3dcf5d265c
commit 7c8dd44c55

@ -13,6 +13,67 @@ export default {
render(h) { render(h) {
const _this = this; const _this = this;
let houseDialog = new CreateDialog(this, [ let houseDialog = new CreateDialog(this, [
{
show: true,
key: "bufuyuanyin",
label: "不符原因",
render: h("el-input", {
props: {
disabled: this.form.dengjimianji === this.form.shijimianji,
size: "small",
value: this.form["bufuyuanyin"],
},
on: {
input: e => {
this.$set(this.form,'bufuyuanyin',e)
}
}
}),
},
{
show: true,
key: "xianzhuang",
label: "现状",
render: h("div",[
h('el-select',{
props: {
size: 'small',
value: this.form.xianzhuang
},
style: {
width: '100%'
},
on: {
input: e => {
this.$set(this.form,'xianzhuang',e)
}
}
},this.formInfo?.find(i => i.field === 'xianzhuang')?._params?.map(i => h('el-option',{
props: {
label: i.key,
value: i.value
}
}))),
h('el-input',{
style: {
display: this.form.xianzhuang === '其他' ? 'block' : 'none',
'margin-top': '6px'
},
attrs: {
placeholder: "填写现状其他事项"
},
props: {
value: this.xianzhuangInput,
size: 'small',
},
on: {
input: e => {
this.$set(this,'xianzhuangInput',e)
}
}
})
])
},
{ {
show: true, show: true,
key: "guanliantudizhengquanzheng", key: "guanliantudizhengquanzheng",
@ -292,6 +353,7 @@ export default {
table_name: "lands", table_name: "lands",
keyword: "" keyword: ""
}, },
xianzhuangInput: "",
}; };
}, },
methods: { methods: {
@ -379,6 +441,9 @@ export default {
this.$refs["elForm"].validate((validate) => { this.$refs["elForm"].validate((validate) => {
if (validate) { if (validate) {
let copyForm = deepCopy(this.form); let copyForm = deepCopy(this.form);
if(copyForm.xianzhuang === '其他') {
copyForm.xianzhuang = this.xianzhuangInput
}
this.formInfo.forEach((info) => { this.formInfo.forEach((info) => {
if ( if (
info._relations?.link_relation === "newHasMany" || info._relations?.link_relation === "newHasMany" ||
@ -507,6 +572,21 @@ export default {
{ required: true, message: `请填写${i.name}` }, { required: true, message: `请填写${i.name}` },
]; ];
} }
if (i.field === 'bufuyuanyin') {
this.rules[i.field] = [
{ validator: (rule, value, callback) => {
if (this.form.dengjimianji === this.form.shijimianji) {
callback()
} else {
if (!value) {
callback(new Error('登记面积与实际面积不符,请填写不符原因'))
} else {
callback()
}
}
} },
];
}
if (i.edit_input === "files") { if (i.edit_input === "files") {
this.form[i.field] = []; this.form[i.field] = [];
} }

@ -12,6 +12,67 @@ export default {
}, },
render(h) { render(h) {
let dialog = new CreateDialog(this, [ let dialog = new CreateDialog(this, [
{
show: true,
key: "bufuyuanyin",
label: "不符原因",
render: h("el-input", {
props: {
disabled: this.form.dengjimianji === this.form.shijimianji,
size: "small",
value: this.form["bufuyuanyin"],
},
on: {
input: e => {
this.$set(this.form,'bufuyuanyin',e)
}
}
}),
},
{
show: true,
key: "xianzhuang",
label: "现状",
render: h("div",[
h('el-select',{
props: {
size: 'small',
value: this.form.xianzhuang
},
style: {
width: '100%'
},
on: {
input: e => {
this.$set(this.form,'xianzhuang',e)
}
}
},this.formInfo?.find(i => i.field === 'xianzhuang')?._params?.map(i => h('el-option',{
props: {
label: i.key,
value: i.value
}
}))),
h('el-input',{
style: {
display: this.form.xianzhuang === '其他' ? 'block' : 'none',
'margin-top': '6px'
},
attrs: {
placeholder: "填写现状其他事项"
},
props: {
value: this.xianzhuangInput,
size: 'small',
},
on: {
input: e => {
this.$set(this,'xianzhuangInput',e)
}
}
})
])
},
{ {
key: "fangchanzhuangtai", key: "fangchanzhuangtai",
label: "房产状态", label: "房产状态",
@ -156,6 +217,7 @@ export default {
file: {}, file: {},
pickHouseRow: null, pickHouseRow: null,
xianzhuangInput: ""
}; };
}, },
methods: { methods: {
@ -246,6 +308,9 @@ export default {
this.$refs["elForm"].validate((validate) => { this.$refs["elForm"].validate((validate) => {
if (validate) { if (validate) {
let copyForm = deepCopy(this.form); let copyForm = deepCopy(this.form);
if(copyForm.xianzhuang === '其他') {
copyForm.xianzhuang = this.xianzhuangInput
}
this.formInfo.forEach((info) => { this.formInfo.forEach((info) => {
if ( if (
info._relations?.link_relation === "newHasMany" || info._relations?.link_relation === "newHasMany" ||
@ -403,6 +468,21 @@ export default {
{ required: true, message: `请填写${i.name}` }, { required: true, message: `请填写${i.name}` },
]; ];
} }
if (i.field === 'bufuyuanyin') {
this.rules[i.field] = [
{ validator: (rule, value, callback) => {
if (this.form.dengjimianji === this.form.shijimianji) {
callback()
} else {
if (!value) {
callback(new Error('登记面积与实际面积不符,请填写不符原因'))
} else {
callback()
}
}
} },
];
}
if (i.edit_input === "files") { if (i.edit_input === "files") {
this.form[i.field] = []; this.form[i.field] = [];
} }

@ -825,7 +825,7 @@ export default {
table_name: item.hasOwnProperty('land_id') ? "houses" : "lands", table_name: item.hasOwnProperty('land_id') ? "houses" : "lands",
...item.ORIGINAL_DATA, ...item.ORIGINAL_DATA,
id: item.id, id: item.id,
xianzhuang: item._zichanshengyumianji == 0 ? 1 : 2, xianzhuang: '已处置/拆迁',///
shijimianji: item._zichanshengyumianji, shijimianji: item._zichanshengyumianji,
fenlei: 1 fenlei: 1
}))) })))

@ -411,7 +411,7 @@ export default {
value: "", value: "",
}, },
], ],
sort_name: 'xianzhuang', sort_name: 'fenlei',
sort_type: 'asc', sort_type: 'asc',
}, },
form: [], form: [],
@ -627,7 +627,7 @@ export default {
paramMap.set(i.select_item[key], key); paramMap.set(i.select_item[key], key);
}); });
return paramMap.get(row[i.field]?.toString()); return paramMap.get(row[i.field]?.toString()) || row[i.field];
}; };
} }
if (i._relations) { if (i._relations) {

@ -390,7 +390,7 @@ export default {
value: "", value: "",
}, },
], ],
sort_name: 'xianzhuang', sort_name: 'fenlei',
sort_type: 'asc' sort_type: 'asc'
}, },
form: [], form: [],
@ -603,7 +603,7 @@ export default {
paramMap.set(i.select_item[key], key); paramMap.set(i.select_item[key], key);
}); });
return paramMap.get(row[i.field]?.toString()); return paramMap.get(row[i.field]?.toString()) || row[i.field];
}; };
} }
if (i._relations) { if (i._relations) {

Loading…
Cancel
Save