update 表单细节

This commit is contained in:
2021-06-09 16:36:37 +08:00
parent 760797ea56
commit fe1f2fb821
8 changed files with 55 additions and 47 deletions

View File

@@ -1,4 +1,5 @@
export default { export default {
houseTaskPage: ['/houseTask/page', 'post'], houseTaskPage: ['/houseTask/page', 'post'],
houseTaskEdit: ['/houseTask/edit', 'post'], houseTaskEdit: ['/houseTask/edit', 'post'],
houseTaskSubmit: ['/houseTask/submit', 'post']
} }

View File

@@ -150,6 +150,10 @@ const app = new Vue({
*/ */
siderCollapsed: false siderCollapsed: false
} }
},
transfer: {
} }
}, },
mounted() { mounted() {

View File

@@ -163,12 +163,15 @@ export default {
// await this.onLoadCodes(); // await this.onLoadCodes();
/** 将默认数据覆盖到form */ /** 将默认数据覆盖到form */
const record = this.param && this.param.record; const record = this.param && this.param.record;
const form = this.$_.cloneDeep(defaultForm);
if (record) { if (record) {
// this.$_.giveDeep(form, record); this.$_.giveDeep(form, record);
for (var key in defaultForm.houseInfo) {
for (var key in form.houseInfo) {
const fileValue = []; const fileValue = [];
const fileList = !!record.houseInfo[key] ? record.houseInfo[key].split(',') : []; const fileList =
!form.houseInfo[key] || form.houseInfo[key].length == 0 ? [] : form.houseInfo[key].split(',');
for (let i = 0; i < fileList.length; i++) { for (let i = 0; i < fileList.length; i++) {
const file = await PreviewFile(fileList[i]); const file = await PreviewFile(fileList[i]);
const base64 = await BlobToBase64(file); const base64 = await BlobToBase64(file);
@@ -180,10 +183,9 @@ export default {
status: 'done', status: 'done',
}); });
} }
defaultForm.houseInfo[key] = fileValue; form.houseInfo[key] = fileValue;
} }
} }
const form = this.$_.cloneDeep(defaultForm);
this.form = form; this.form = form;
} }
this.loading = false; this.loading = false;

View File

@@ -198,6 +198,7 @@
<a-col :span="8"> <a-col :span="8">
<a-form-model-item class="ant-row-flex" label="竣工日期" prop="houseInfo.completedDate"> <a-form-model-item class="ant-row-flex" label="竣工日期" prop="houseInfo.completedDate">
<a-date-picker <a-date-picker
@change="(date) => $root.transfer.completedYear = date.format('YYYY')"
class="w-100-p" class="w-100-p"
placeholder="请选择竣工日期" placeholder="请选择竣工日期"
v-model="form.houseInfo.completedDate" v-model="form.houseInfo.completedDate"
@@ -626,13 +627,6 @@ export default {
// 'form.houseInfo.coating'(value) { // 'form.houseInfo.coating'(value) {
// this.frame.onTogglePane(value, 'coating'); // this.frame.onTogglePane(value, 'coating');
// }, // },
'form.houseInfo.completedDate': {
handler(newVal, oldVal) {
this.$emit('completedDateChanged', newVal.constructor === String ? newVal.substr(0, 4) : newVal.format('YYYY'));
},
deep: true,
immediate: false,
},
}, },
created() { created() {
@@ -641,6 +635,8 @@ export default {
beforeDestroy() { beforeDestroy() {
if (this.map) this.map.destroy(); if (this.map) this.map.destroy();
//组件销毁时,删除竣工日期的全局监听
this.$delete(this.$root.transfer, 'completedYear');
}, },
methods: { methods: {
@@ -662,7 +658,11 @@ export default {
} }
this.form = form; this.form = form;
this.$set(
this.$root.transfer,
'completedYear',
!!this.form.houseInfo.completedDate ? this.form.houseInfo.completedDate.substr(0, 4) : ''
);
this.$nextTick(async () => { this.$nextTick(async () => {
await this.onMapInit(); await this.onMapInit();
if (this.form.houseCode.lng && this.form.houseCode.lat) { if (this.form.houseCode.lng && this.form.houseCode.lat) {

View File

@@ -13,7 +13,6 @@
:is="part.component" :is="part.component"
:key="index" :key="index"
:param="param" :param="param"
@completedDateChanged="completedDateChanged"
ref="forms" ref="forms"
v-if="part.component" v-if="part.component"
/> />
@@ -114,10 +113,6 @@ export default {
} }
}); });
}, },
completedDateChanged(value) {
console.log(value);
this.$emit('completedDateChanged', value);
},
}, },
}; };
</script> </script>

View File

@@ -19,7 +19,11 @@
<a-row :gutter="16" type="flex"> <a-row :gutter="16" type="flex">
<a-col :span="24"> <a-col :span="24">
<a-form-model-item class="ant-row-flex" label="初始等级" prop="patrolInfo.initGrade"> <a-form-model-item class="ant-row-flex" label="初始等级" prop="patrolInfo.initGrade">
<a-radio-group button-style="solid" v-model="form.patrolInfo.initGrade"> <a-radio-group
:disabled="true"
button-style="solid"
v-model="form.patrolInfo.initGrade"
>
<a-radio-button <a-radio-button
:key="item.code" :key="item.code"
:value="+item.code" :value="+item.code"
@@ -66,7 +70,7 @@ const defaultForm = {
}; };
export default { export default {
props: ['param', 'completedYear'], props: ['param'],
data() { data() {
return { return {
@@ -98,13 +102,26 @@ export default {
}; };
}, },
watch: { watch: {
completedYear(value) { '$root.transfer.completedYear'(value) {
//初始等级无法手动更改由房屋详情的竣工日期决定2000年之后竣工的为一级1995年~1999年竣工的为二级1980年~1994年竣工的为三级早于1980年竣工的为四级。选择房屋竣工日期后初始等级会自动填充。
console.log('patrol-grade:' + value); console.log('patrol-grade:' + value);
var year = +value;
if (year > 1999) {
this.form.patrolInfo.initGrade = 1;
}
if (year > 1994 && year < 2000) {
this.form.patrolInfo.initGrade = 2;
}
if (year > 1979 && year < 1995) {
this.form.patrolInfo.initGrade = 3;
}
if (year < 1980) {
this.form.patrolInfo.initGrade = 4;
}
}, },
}, },
async created() { async created() {
this.onFillData(); this.onFillData();
console.log(this.param);
}, },
methods: { methods: {

View File

@@ -9,7 +9,6 @@
<section :id="`form-${index}-${id}`" :key="index"> <section :id="`form-${index}-${id}`" :key="index">
<h5 v-if="part.title">{{part.title}}</h5> <h5 v-if="part.title">{{part.title}}</h5>
<component <component
:completed-year="completedYear"
:frame="frame" :frame="frame"
:is="part.component" :is="part.component"
:key="index" :key="index"
@@ -44,7 +43,7 @@
<script> <script>
export default { export default {
props: ['id', 'param', 'frame', 'completedYear'], props: ['id', 'param', 'frame'],
data() { data() {
return { return {

View File

@@ -122,6 +122,11 @@ export default {
fileFieldArr: ['settlementTiltFiles', 'otherInfoFiles'], fileFieldArr: ['settlementTiltFiles', 'otherInfoFiles'],
}; };
}, },
async created() {
this.onFillData();
},
methods: { methods: {
/** /**
* 必要的方法 * 必要的方法
@@ -130,33 +135,19 @@ export default {
async onFillData() { async onFillData() {
this.loading = true; this.loading = true;
{ {
await this.onLoadCodes(); // await this.onLoadCodes();
/** 将默认数据覆盖到form */ /** 将默认数据覆盖到form */
const record = this.param && this.param.record; const record = this.param && this.param.record;
const form = this.$_.cloneDeep(defaultForm);
if (record) { if (record) {
// this.$_.giveDeep(form, record); this.$_.giveDeep(form, record);
// this.fileFieldArr.forEach((key) => {
// const fileValue = []; for (var key in form.patrolInfo) {
// const fileList = !!record.patrolInfo[key] ? record.patrolInfo[key].split(',') : [];
// for (let i = 0; i < fileList.length; i++) {
// const file = await PreviewFile(fileList[i]);
// const base64 = await BlobToBase64(file);
// fileValue.push({
// uid: fileList[i],
// response: fileList[i], // 用于和新上传的文件一同回传
// name: file.name,
// url: base64,
// status: 'done',
// });
// }
// defaultForm.patrolInfo[key] = fileValue;
// });
for (var key in defaultForm.patrolInfo) {
if (key.indexOf('Files') > -1) { if (key.indexOf('Files') > -1) {
const fileValue = []; const fileValue = [];
const fileList = !!record.patrolInfo[key] ? record.patrolInfo[key].split(',') : []; const fileList =
!form.patrolInfo[key] || form.patrolInfo[key].length == 0 ? [] : form.patrolInfo[key].split(',');
for (let i = 0; i < fileList.length; i++) { for (let i = 0; i < fileList.length; i++) {
const file = await PreviewFile(fileList[i]); const file = await PreviewFile(fileList[i]);
const base64 = await BlobToBase64(file); const base64 = await BlobToBase64(file);
@@ -168,11 +159,10 @@ export default {
status: 'done', status: 'done',
}); });
} }
defaultForm.patrolInfo[key] = fileValue; form.patrolInfo[key] = fileValue;
} }
} }
} }
const form = this.$_.cloneDeep(defaultForm);
this.form = form; this.form = form;
} }
this.loading = false; this.loading = false;