update getCode逻辑

This commit is contained in:
lb 2023-08-03 15:03:59 +08:00
parent 1299ebd0c9
commit 7c665484a7
2 changed files with 42 additions and 17 deletions

View File

@ -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' }], [{ input: true, label: '备注', prop: 'remark' }],
]" /> ]" />
</base-dialog> </base-dialog>

View File

@ -97,6 +97,9 @@ export default {
get() { get() {
return this.dataForm; return this.dataForm;
}, },
set(val) {
console.log('set form', val);
},
}, },
}, },
mounted() { mounted() {
@ -111,7 +114,11 @@ export default {
resetFields(args) { resetFields(args) {
return this.$refs.form.resetFields(args); return this.$refs.form.resetFields(args);
}, },
// getCode
async getCode(url) {
const response = await this.$axios(url);
return response.data;
},
handleOptions() { handleOptions() {
// console.log("[dialogForm:handleOptions]") // console.log("[dialogForm:handleOptions]")
const promiseList = []; const promiseList = [];
@ -120,13 +127,19 @@ export default {
if (opt.options) { if (opt.options) {
this.optionListOf[opt.prop] = opt.options; this.optionListOf[opt.prop] = opt.options;
} else if (opt.url) { } else if (opt.url) {
//
if (opt.select || (opt.input && !this.form?.id)) {
promiseList.push(async () => { promiseList.push(async () => {
const response = await this.$axios(opt.url, { const response = await this.$axios(opt.url, {
method: opt.method ?? 'get', method: opt.method ?? 'get',
}); });
console.log('[dialogForm:handleOptions:response]', response); console.log('[dialogForm:handleOptions:response]', response);
if (opt.select) {
//
const list = const list =
'list' in response.data ? response.data.list : response.data; 'list' in response.data
? response.data.list
: response.data;
this.$set( this.$set(
this.optionListOf, this.optionListOf,
opt.prop, opt.prop,
@ -135,7 +148,12 @@ export default {
value: item[opt.valueKey ?? 'id'], value: item[opt.valueKey ?? 'id'],
})) }))
); );
} else if (opt.input) {
//
this.form[opt.prop] = response.data;
}
}); });
}
try { try {
// this.formLoading = true; // this.formLoading = true;
// console.log("[dialogForm:handleOptions:promiseList]", promiseList) // console.log("[dialogForm:handleOptions:promiseList]", promiseList)