diff --git a/src/components/base-dialog/addOrUpdate/index.vue b/src/components/base-dialog/addOrUpdate/index.vue index 20cb6a2..12e4770 100644 --- a/src/components/base-dialog/addOrUpdate/index.vue +++ b/src/components/base-dialog/addOrUpdate/index.vue @@ -150,9 +150,10 @@ export default { visible: false, isEdit: false, isDetail: false, - isUpdated: false, dataForm: {}, - dataFormRules: {} + dataFormRules: {}, + tempForm: [], // 临时保存自动生成的code,或其他数据 + shouldWait: null } }, computed: { @@ -162,6 +163,7 @@ export default { } }, mounted() { + console.log('mounted>..') /** 计算 defaultPlaceholders */ const prefix = '请输入' Object.entries(this.defaultNames).map(([key, value]) => { @@ -182,12 +184,14 @@ export default { this.$set(this.dataForm, [item.name], '') if (item.api) { /** 自动请求并填充 */ - this.$http({ + // or this.shouldWaitPool = [] + this.shouldWait = this.$http({ url: this.$http.adornUrl(item.api), method: 'POST' // 也可以改成动态决定 }).then(({ data: res }) => { if (res && res.code === 0) { - this.dataForm[item.name] = res.data // <=== 此处需要对接口 + // this.dataForm[item.name] = res.data // <=== 此处需要对接口 + this.tempForm.push({ name: item.name, data: res.data }) } }) } // end if (item.api) @@ -236,9 +240,6 @@ export default { this.$set(this.dataForm, 'id', null) }) }, - updated() { - this.isUpdated = true // 此时如果点击保存就会 emit(refreshDataList) - }, methods: { getLabel(n, c) { @@ -286,6 +287,16 @@ export default { this.dataForm = pick(res.data, dataFormKeys) } }) + } else { + /** 如果不是编辑,就填充自动生成的数据 */ + if (this.shouldWait) + this.shouldWait.then(() => { + if (this.tempForm.length) { + this.tempForm.forEach(item => { + this.dataForm[item.name] = item.data + }) + } + }) } }) }, @@ -351,7 +362,7 @@ export default { }, handleClose() { - if (this.isAdd || this.isUpdated) this.$emit('refreshDataList') + this.$emit('destory-dialog') this.visible = false } } diff --git a/src/views/modules/monitoring/equipmentGroup.vue b/src/views/modules/monitoring/equipmentGroup.vue index b9d63ac..a9e99ea 100644 --- a/src/views/modules/monitoring/equipmentGroup.vue +++ b/src/views/modules/monitoring/equipmentGroup.vue @@ -6,8 +6,7 @@ 查询 - 新增 - + 新增 - + - +