up. 注意需要修复层级下的取值问题

This commit is contained in:
u2nyakim 2025-08-28 16:03:37 +08:00
parent 6ae1d07062
commit 20586ad694
3 changed files with 29 additions and 4 deletions

View File

@ -89,7 +89,7 @@ export function strToBind(type: string, bindStr: string): any {
return {};
}
export function valueToStr(type: string, value: any) {
export function valueToStr(type: string, value: any):string {
switch (type) {
case 'json':
return value ? JSON.stringify(value) : "{}";
@ -109,7 +109,10 @@ export function valueToStr(type: string, value: any) {
case 'date_range':
case 'time_range':
case 'datetime_range':
if(value.length == 2 && value[0] && value[1]){
return value.join(",");
}
return "";
default:
return value === null ? "" : value;
}

View File

@ -10,6 +10,7 @@
<ele-card shadow="always" :header="config.title" v-bind="config.bind">
<config-form-list
:config-list="config.children"
:ref="setListRef"
v-if="config.children && config.children.length > 0"
/>
</ele-card>
@ -19,6 +20,7 @@
<el-collapse-item :title="config.title">
<config-form-list
:config-list="config.children"
:ref="setListRef"
v-if="config.children && config.children.length > 0"
/>
</el-collapse-item>
@ -35,6 +37,7 @@
>
<config-form-list
:config-list="tabPane.children"
:ref="setListRef"
v-if="tabPane.children && tabPane.children.length > 0"
/>
</el-tab-pane>
@ -66,10 +69,22 @@
import type { ComponentPublicInstance } from "vue";
interface ConfigFormListInstance {
getFormData: () => any; //
}
//
interface ConfigFormItemInstance {
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[]>([]);
@ -88,6 +103,13 @@
const [name, value] = item.getDataValue();
data[name] = value;
});
listRefs.value.map((item)=>{
let aa = item.getFormData();
for (const dataKey in aa) {
data[dataKey] = aa[dataKey]
}
});
return data;
};
//

View File

@ -112,7 +112,7 @@ const reload = () => {
}
return d;
});
console.log("lists->lists", lists);
// console.log("lists->lists", lists);
configList.value = toTree({
data: lists,
idField: 'id',
@ -157,7 +157,7 @@ const saveForm = () => {
console.log('所有组件数据:', allValues);
updateConfigData(allValues).then(()=>{
EleMessage.success("保存成功");
reload();
// reload();
})
}