up. 注意需要修复层级下的取值问题
This commit is contained in:
parent
6ae1d07062
commit
20586ad694
@ -89,7 +89,7 @@ export function strToBind(type: string, bindStr: string): any {
|
|||||||
return {};
|
return {};
|
||||||
}
|
}
|
||||||
|
|
||||||
export function valueToStr(type: string, value: any) {
|
export function valueToStr(type: string, value: any):string {
|
||||||
switch (type) {
|
switch (type) {
|
||||||
case 'json':
|
case 'json':
|
||||||
return value ? JSON.stringify(value) : "{}";
|
return value ? JSON.stringify(value) : "{}";
|
||||||
@ -109,7 +109,10 @@ export function valueToStr(type: string, value: any) {
|
|||||||
case 'date_range':
|
case 'date_range':
|
||||||
case 'time_range':
|
case 'time_range':
|
||||||
case 'datetime_range':
|
case 'datetime_range':
|
||||||
return value.join(",");
|
if(value.length == 2 && value[0] && value[1]){
|
||||||
|
return value.join(",");
|
||||||
|
}
|
||||||
|
return "";
|
||||||
default:
|
default:
|
||||||
return value === null ? "" : value;
|
return value === null ? "" : value;
|
||||||
}
|
}
|
||||||
|
|||||||
@ -10,6 +10,7 @@
|
|||||||
<ele-card shadow="always" :header="config.title" v-bind="config.bind">
|
<ele-card shadow="always" :header="config.title" v-bind="config.bind">
|
||||||
<config-form-list
|
<config-form-list
|
||||||
:config-list="config.children"
|
:config-list="config.children"
|
||||||
|
:ref="setListRef"
|
||||||
v-if="config.children && config.children.length > 0"
|
v-if="config.children && config.children.length > 0"
|
||||||
/>
|
/>
|
||||||
</ele-card>
|
</ele-card>
|
||||||
@ -19,6 +20,7 @@
|
|||||||
<el-collapse-item :title="config.title">
|
<el-collapse-item :title="config.title">
|
||||||
<config-form-list
|
<config-form-list
|
||||||
:config-list="config.children"
|
:config-list="config.children"
|
||||||
|
:ref="setListRef"
|
||||||
v-if="config.children && config.children.length > 0"
|
v-if="config.children && config.children.length > 0"
|
||||||
/>
|
/>
|
||||||
</el-collapse-item>
|
</el-collapse-item>
|
||||||
@ -35,6 +37,7 @@
|
|||||||
>
|
>
|
||||||
<config-form-list
|
<config-form-list
|
||||||
:config-list="tabPane.children"
|
:config-list="tabPane.children"
|
||||||
|
:ref="setListRef"
|
||||||
v-if="tabPane.children && tabPane.children.length > 0"
|
v-if="tabPane.children && tabPane.children.length > 0"
|
||||||
/>
|
/>
|
||||||
</el-tab-pane>
|
</el-tab-pane>
|
||||||
@ -66,10 +69,22 @@
|
|||||||
import type { ComponentPublicInstance } from "vue";
|
import type { ComponentPublicInstance } from "vue";
|
||||||
|
|
||||||
|
|
||||||
|
interface ConfigFormListInstance {
|
||||||
|
getFormData: () => any; // 根据实际返回类型调整
|
||||||
|
}
|
||||||
// 定义组件引用类型
|
// 定义组件引用类型
|
||||||
interface ConfigFormItemInstance {
|
interface ConfigFormItemInstance {
|
||||||
getDataValue: () => any; // 根据实际返回类型调整
|
getDataValue: () => any; // 根据实际返回类型调整
|
||||||
}
|
}
|
||||||
|
// 存储所有组件引用的数组
|
||||||
|
const listRefs = ref<ConfigFormListInstance[]>([]);
|
||||||
|
// 收集组件引用的函数
|
||||||
|
const setListRef = (el: unknown) => {
|
||||||
|
const component = el as ComponentPublicInstance & ConfigFormListInstance;
|
||||||
|
if (component && component.getDataValue) {
|
||||||
|
listRefs.value.push(component);
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
// 存储所有组件引用的数组
|
// 存储所有组件引用的数组
|
||||||
const itemRefs = ref<ConfigFormItemInstance[]>([]);
|
const itemRefs = ref<ConfigFormItemInstance[]>([]);
|
||||||
@ -88,6 +103,13 @@
|
|||||||
const [name, value] = item.getDataValue();
|
const [name, value] = item.getDataValue();
|
||||||
data[name] = value;
|
data[name] = value;
|
||||||
});
|
});
|
||||||
|
listRefs.value.map((item)=>{
|
||||||
|
let aa = item.getFormData();
|
||||||
|
for (const dataKey in aa) {
|
||||||
|
data[dataKey] = aa[dataKey]
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
return data;
|
return data;
|
||||||
};
|
};
|
||||||
// 每次更新前清空引用数组
|
// 每次更新前清空引用数组
|
||||||
|
|||||||
@ -112,7 +112,7 @@ const reload = () => {
|
|||||||
}
|
}
|
||||||
return d;
|
return d;
|
||||||
});
|
});
|
||||||
console.log("lists->lists", lists);
|
// console.log("lists->lists", lists);
|
||||||
configList.value = toTree({
|
configList.value = toTree({
|
||||||
data: lists,
|
data: lists,
|
||||||
idField: 'id',
|
idField: 'id',
|
||||||
@ -157,7 +157,7 @@ const saveForm = () => {
|
|||||||
console.log('所有组件数据:', allValues);
|
console.log('所有组件数据:', allValues);
|
||||||
updateConfigData(allValues).then(()=>{
|
updateConfigData(allValues).then(()=>{
|
||||||
EleMessage.success("保存成功");
|
EleMessage.success("保存成功");
|
||||||
reload();
|
// reload();
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user