update 完成手动添加

This commit is contained in:
lb
2023-03-23 16:13:52 +08:00
parent b6a50cd1ef
commit 5917223e55
2 changed files with 79 additions and 24 deletions

View File

@@ -132,17 +132,31 @@ export default {
this.configs.form.rows.forEach((row) => {
row.forEach((col) => {
dataForm[col.prop] = col.default ?? null;
if (col.prop) dataForm[col.prop] = col.default ?? null;
if (col.fetchData)
col.fetchData().then(({ data: res }) => {
console.log("[DialogJustForm fetchData -->]", res.data.list);
if (res.code === 0 && res.data.list) {
this.$set(
col,
"options",
res.data.list.map((i) => ({ label: i.name, value: col.optionValue ? i[col.optionValue] : i.id }))
);
if (res.code === 0) {
if ("list" in res.data) {
this.$set(
col,
"options",
res.data.list.map((i) => ({
label: col.optionLabel ? i[col.optionLabel] : i.name,
value: col.optionValue ? i[col.optionValue] : i.id,
}))
);
} else if (Array.isArray(res.data)) {
this.$set(
col,
"options",
res.data.map((i) => ({
label: col.optionLabel ? i[col.optionLabel] : i.name,
value: col.optionValue ? i[col.optionValue] : i.id,
}))
);
}
// col.options = res.data.list;
} else {
col.options.splice(0);
@@ -374,7 +388,7 @@ export default {
/** 发送 */
return this.$http({
url: this.urls.base,
url: this.urls.formUrl ? this.urls.formUrl : this.urls.base,
method,
data: httpPayload,
})