feat: plugin-approvals, notice config select (#1048)
Reviewed-on: daoyoucloud/tachybase#1048 Reviewed-by: sealday <zhanglin@daoyoucloud.com> Co-authored-by: bai.zixv <bai.zixv@foxmail.com> Co-committed-by: bai.zixv <bai.zixv@foxmail.com>
This commit is contained in:
parent
b90b40e71f
commit
fb54e11587
@ -87,7 +87,6 @@ function getCollectionFieldOptions(
|
|||||||
};
|
};
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
// XXX: 目前 AppendsTreeSelectV2 和 AppendsTreeSelect 都有特化逻辑, 需要整理出一个通用组件
|
// XXX: 目前 AppendsTreeSelectV2 和 AppendsTreeSelect 都有特化逻辑, 需要整理出一个通用组件
|
||||||
export const AppendsTreeSelectV2: React.FC<TreeSelectProps & AppendsTreeSelectPropsV2> = (props) => {
|
export const AppendsTreeSelectV2: React.FC<TreeSelectProps & AppendsTreeSelectPropsV2> = (props) => {
|
||||||
const {
|
const {
|
||||||
@ -159,16 +158,12 @@ export const AppendsTreeSelectV2: React.FC<TreeSelectProps & AppendsTreeSelectPr
|
|||||||
// NOTE: preload options in value
|
// NOTE: preload options in value
|
||||||
useEffect(() => {
|
useEffect(() => {
|
||||||
const arr = (props.multiple ? propsValue : propsValue ? [propsValue] : []) as string[];
|
const arr = (props.multiple ? propsValue : propsValue ? [propsValue] : []) as string[];
|
||||||
console.log('%c Line:160 🍑 arr', 'font-size:18px;color:#4fff4B;background:#f5ce50', arr);
|
|
||||||
if (!arr?.length || arr.every((v) => Boolean(optionsMap[v]))) {
|
if (!arr?.length || arr.every((v) => Boolean(optionsMap[v]))) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
const loaded = [];
|
const loaded = [];
|
||||||
|
|
||||||
arr.forEach((v) => {
|
arr.forEach((v) => {
|
||||||
if (typeof v !== 'string') {
|
|
||||||
v = v.value;
|
|
||||||
}
|
|
||||||
const paths = v.split('.');
|
const paths = v.split('.');
|
||||||
let option = optionsMap[paths[0]];
|
let option = optionsMap[paths[0]];
|
||||||
for (let i = 1; i < paths.length; i++) {
|
for (let i = 1; i < paths.length; i++) {
|
||||||
@ -196,9 +191,8 @@ export const AppendsTreeSelectV2: React.FC<TreeSelectProps & AppendsTreeSelectPr
|
|||||||
|
|
||||||
const handleChange = useCallback(
|
const handleChange = useCallback(
|
||||||
(next: DefaultOptionType[] | string) => {
|
(next: DefaultOptionType[] | string) => {
|
||||||
console.log('%c Line:193 🥔 next', 'font-size:18px;color:#42b983;background:#f5ce50', next);
|
|
||||||
if (!props.multiple) {
|
if (!props.multiple) {
|
||||||
onChange(next as string | Array<any>);
|
onChange(next as string);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -223,7 +217,7 @@ export const AppendsTreeSelectV2: React.FC<TreeSelectProps & AppendsTreeSelectPr
|
|||||||
}
|
}
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
onChange(next);
|
onChange(Array.from(valueSet));
|
||||||
},
|
},
|
||||||
[props.multiple, value, onChange, optionsMap],
|
[props.multiple, value, onChange, optionsMap],
|
||||||
);
|
);
|
||||||
@ -245,7 +239,6 @@ export const AppendsTreeSelectV2: React.FC<TreeSelectProps & AppendsTreeSelectPr
|
|||||||
);
|
);
|
||||||
|
|
||||||
const filteredValue = Array.isArray(value) ? value.filter((i) => i.value in optionsMap) : value;
|
const filteredValue = Array.isArray(value) ? value.filter((i) => i.value in optionsMap) : value;
|
||||||
console.log('%c Line:247 🥕 filteredValue', 'font-size:18px;color:#6ec1c2;background:#ea7e5c', filteredValue);
|
|
||||||
const valueKeys: string[] = props.multiple
|
const valueKeys: string[] = props.multiple
|
||||||
? (propsValue as string[])
|
? (propsValue as string[])
|
||||||
: propsValue != null
|
: propsValue != null
|
||||||
|
Loading…
Reference in New Issue
Block a user