diff --git a/src/components/base-dialog/addOrUpdate/index.vue b/src/components/base-dialog/addOrUpdate/index.vue index 67f79d7..844f645 100644 --- a/src/components/base-dialog/addOrUpdate/index.vue +++ b/src/components/base-dialog/addOrUpdate/index.vue @@ -259,6 +259,7 @@ export default { return opt.label ? opt.label : this.defaultNames[opt.name] } }, + getPlaceholder(n, c) { const opt = this.configs.fields[(n - 1) * COLUMN_PER_ROW + (c - 1)] if (opt) { @@ -266,6 +267,7 @@ export default { return opt.placeholder ? opt.placeholder : this.defaultPlaceholders[opt.name] } }, + getType(n, c) { const opt = this.configs.fields[(n - 1) * COLUMN_PER_ROW + (c - 1)] if (opt) { @@ -279,9 +281,25 @@ export default { return 'input' } }, - init() { + + init(id) { + this.dataForm.id = id || null this.visible = true + this.$nextTick(() => { + this.$refs['dataForm'].resetFields() + if (this.dataForm.id) { + this.$http({ + url: this.$http.adornUrl(`${this.infoUrl}/${this.dataForm.id}`), + method: 'get' + }).then(({ data: res }) => { + if (res && res.code === 0) { + this.dataForm = + } + }) + } + }) }, + handleClick(btn) { /** 提取url */ const urls = {} @@ -330,8 +348,11 @@ export default { // add more.. } }, + handleOperations() {}, + getDataList() {}, + handleClose() { if (this.isAdd || this.isUpdated) this.$emit('refreshDataList') this.visible = false diff --git a/src/views/modules/monitoring/product.vue b/src/views/modules/monitoring/product.vue index 3dfcf87..17da917 100644 --- a/src/views/modules/monitoring/product.vue +++ b/src/views/modules/monitoring/product.vue @@ -6,7 +6,7 @@ 查询 - 测试 + 测试 新增 @@ -102,6 +102,7 @@ const tableConfigs = [ const addOrUpdateConfigs = { type: 'dialog', // dialog | drawer | page + infoUrl: '/monitoring/product', fields: [ 'name', { @@ -214,14 +215,16 @@ export default { }, methods: { // - test() { + addOrEdit(id) { this.showbasedialog = true this.$nextTick(() => { - this.$refs.basedialog.init() + this.$refs.basedialog.init(id) }) }, // 获取数据列表 getDataList() { + // console.log("after dialog close: ", this.showbasedialog) + this.showbasedialog = false // 清理弹窗 this.dataListLoading = true this.$http({ url: this.$http.adornUrl('/monitoring/product/page'), @@ -268,7 +271,7 @@ export default { handleOperations({ type, data }) { switch (type) { case 'viewAttr': // <== 对照 tableConfig - return this.addOrUpdateHandle(data) + return this.addOrEdit(data) case 'delete': return this.deleteHandle(data) }