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 {}; 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;
} }

View File

@ -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;
}; };
// //

View File

@ -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();
}) })
} }