diff --git a/src/components/DialogForm/index.vue b/src/components/DialogForm/index.vue index 716f5a02..238d7823 100644 --- a/src/components/DialogForm/index.vue +++ b/src/components/DialogForm/index.vue @@ -53,7 +53,12 @@ :action="col.url" :on-success="handleUploadSuccess" v-bind="col.bind"> - 点击上传 + + 点击上传 +
{{ col.uploadTips || '只能上传jpg/png文件,大小不超过2MB' }}
@@ -157,7 +162,7 @@ export default { return response.data; }, async handleOptions(trigger = 'monuted') { - // console.log("[dialogForm:handleOptions]") + console.log("[dialogForm:handleOptions]") const promiseList = []; this.rows.forEach((cols) => { cols.forEach((opt) => { @@ -169,6 +174,32 @@ export default { if (opt.options) { this.$set(this.optionListOf, opt.prop, opt.options); } else if (opt.url) { + // 如果有 depends,则暂时先不获取,注册一个watcher + if (opt.depends) { + console.log("[handleOptions] setting watch") + this.$watch( + () => this.form[opt.depends], + (id) => { + console.log(opt.depends, 'changed') + // 清空原有选项 + this.form[opt.prop] = null; + // 获取新的选项 + this.$axios({ + url: `${opt.url}?id=${id}`, + }).then((res) => { + this.$set( + this.optionListOf, + opt.prop, + res.data.map((item) => ({ + label: item[opt.labelKey ?? 'name'], + value: item[opt.valueKey ?? 'id'], + })) + ); + }); + } + ); + return; + } // 如果是下拉框,或者新增模式下的输入框,才去请求 if (opt.select || (opt.input && !this.form?.id)) { promiseList.push(async () => { @@ -216,10 +247,16 @@ export default { if (!promiseList.length) this.formLoading = false; }, // 上传成功的特殊处理 - beforeUpload(){}, + beforeUpload() {}, // 上传前的验证规则可通过 bind 属性传入 handleUploadSuccess(response, file, fileList) { - console.log('[dialogForm:handleUploadSuccess]', response, file, fileList, this.form); + console.log( + '[dialogForm:handleUploadSuccess]', + response, + file, + fileList, + this.form + ); // 保存原始文件名 if ('fileNames' in this.form) this.form.fileNames.push(file.name); // 保存完整地址 diff --git a/src/views/base/equipmentBindSection/index.vue b/src/views/base/equipmentBindSection/index.vue index 3a54da54..cd653693 100644 --- a/src/views/base/equipmentBindSection/index.vue +++ b/src/views/base/equipmentBindSection/index.vue @@ -1,253 +1,357 @@ diff --git a/src/views/base/equipmentGroup/index.vue b/src/views/base/equipmentGroup/index.vue index 7c75e8f0..88763a0b 100644 --- a/src/views/base/equipmentGroup/index.vue +++ b/src/views/base/equipmentGroup/index.vue @@ -33,13 +33,12 @@ -