diff --git a/src/views/quality/base/qualityInspectionType/index.vue b/src/views/quality/base/qualityInspectionType/index.vue index c4097ee2..9bafb076 100644 --- a/src/views/quality/base/qualityInspectionType/index.vue +++ b/src/views/quality/base/qualityInspectionType/index.vue @@ -52,7 +52,14 @@ // } }, ], - [{ input: true, label: '检测类型编码', prop: 'code' }], + [ + { + input: true, + label: '检测类型编码', + prop: 'code', + url: '/base/quality-inspection-type/getCode', + }, + ], [{ input: true, label: '备注', prop: 'remark' }], ]" /> diff --git a/src/views/quality/components/dialogForm.vue b/src/views/quality/components/dialogForm.vue index 408c108c..000e1cf9 100644 --- a/src/views/quality/components/dialogForm.vue +++ b/src/views/quality/components/dialogForm.vue @@ -97,6 +97,9 @@ export default { get() { return this.dataForm; }, + set(val) { + console.log('set form', val); + }, }, }, mounted() { @@ -111,7 +114,11 @@ export default { resetFields(args) { return this.$refs.form.resetFields(args); }, - + // getCode + async getCode(url) { + const response = await this.$axios(url); + return response.data; + }, handleOptions() { // console.log("[dialogForm:handleOptions]") const promiseList = []; @@ -120,22 +127,33 @@ export default { if (opt.options) { this.optionListOf[opt.prop] = opt.options; } else if (opt.url) { - promiseList.push(async () => { - const response = await this.$axios(opt.url, { - method: opt.method ?? 'get', + // 如果是下拉框,或者新增模式下的输入框,才去请求 + if (opt.select || (opt.input && !this.form?.id)) { + promiseList.push(async () => { + const response = await this.$axios(opt.url, { + method: opt.method ?? 'get', + }); + console.log('[dialogForm:handleOptions:response]', response); + if (opt.select) { + // 处理下拉框选项 + const list = + 'list' in response.data + ? response.data.list + : response.data; + this.$set( + this.optionListOf, + opt.prop, + list.map((item) => ({ + label: item[opt.labelKey ?? 'name'], + value: item[opt.valueKey ?? 'id'], + })) + ); + } else if (opt.input) { + // 处理输入框数据 + this.form[opt.prop] = response.data; + } }); - console.log('[dialogForm:handleOptions:response]', response); - const list = - 'list' in response.data ? response.data.list : response.data; - this.$set( - this.optionListOf, - opt.prop, - list.map((item) => ({ - label: item[opt.labelKey ?? 'name'], - value: item[opt.valueKey ?? 'id'], - })) - ); - }); + } try { // this.formLoading = true; // console.log("[dialogForm:handleOptions:promiseList]", promiseList)