1
0
mirror of synced 2026-04-03 14:38:37 +08:00

feat(editor, core): 支持直接绑定整个数据源对象

This commit is contained in:
roymondchen
2023-06-28 16:39:47 +08:00
parent 649720079a
commit 74c9deaa29
11 changed files with 185 additions and 30 deletions

View File

@@ -82,13 +82,17 @@ const equalValue = (value: any, v: any): boolean => {
};
const mapOptions = (data: any[]) => {
const { option } = props.config;
const { text } = option;
const { value } = option;
const {
option = {
text: 'text',
value: 'value',
},
} = props.config;
const { text = 'text', value = 'value' } = option;
return data.map((item) => ({
text: typeof text === 'function' ? text(item) : item[text || 'text'],
value: typeof value === 'function' ? value(item) : item[value || 'value'],
text: typeof text === 'function' ? text(item) : item[text],
value: typeof value === 'function' ? value(item) : item[value],
}));
};
@@ -103,8 +107,10 @@ const getOptions = async () => {
let items: SelectOption[] | SelectGroupOption[] = [];
const { config } = props;
const { option } = config;
const { option } = props.config;
if (!option) return [];
const { root = '', totalKey = 'total' } = option;
let { body = {}, url } = option;
@@ -224,8 +230,10 @@ const getInitLocalOption = async () => {
const getInitOption = async () => {
if (!props.model) return [];
const { config } = props;
const { option } = config;
const { option } = props.config;
if (!option) return [];
const { root = '', initRoot = '' } = option;
let { initBody = {} } = option;