fix(dep): 配置了数据源内部方法无法收集到依赖

This commit is contained in:
roymondchen 2025-04-24 11:34:22 +08:00
parent fd7e737e8c
commit 0e911337b8

View File

@ -263,20 +263,32 @@ export const createDataSourceCondTarget = (ds: Pick<DataSourceSchema, 'id' | 'fi
isTarget: (key: string | number, value: any) => isDataSourceCondTarget(ds, key, value),
});
export const createDataSourceMethodTarget = (ds: Pick<DataSourceSchema, 'id' | 'methods'>, initialDeps: DepData = {}) =>
export const createDataSourceMethodTarget = (
ds: Pick<DataSourceSchema, 'id' | 'methods' | 'fields'>,
initialDeps: DepData = {},
) =>
new Target({
type: DepTargetType.DATA_SOURCE_METHOD,
id: ds.id,
initialDeps,
isTarget: (_key: string | number, value: any) => {
// 使用data-source-method-select 可以配置出来
if (!Array.isArray(value) || !ds?.methods) {
if (!Array.isArray(value)) {
return false;
}
const [dsId, methodName] = value;
if (!methodName || dsId !== ds.id || !ds.methods.find((field) => field.name === methodName)) {
if (!methodName || dsId !== ds.id) {
return false;
}
if (ds.methods?.find((method) => method.name === methodName)) {
return true;
}
// 配置的方法名称可能会是数据源类中定义的并不存在于methods中所以这里判断如果methodName如果是字段名称就表示配置的不是方法
if (ds.fields?.find((field) => field.name === methodName)) {
return false;
}