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,22 +127,33 @@ 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) {
promiseList.push(async () => { //
const response = await this.$axios(opt.url, { if (opt.select || (opt.input && !this.form?.id)) {
method: opt.method ?? 'get', 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 { try {
// this.formLoading = true; // this.formLoading = true;
// console.log("[dialogForm:handleOptions:promiseList]", promiseList) // console.log("[dialogForm:handleOptions:promiseList]", promiseList)