create.config.ts
1.33 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
import { RouteLocationNormalizedLoaded } from 'vue-router';
import { RuleChainFieldsEnum, RuleChainFieldsNameEnum } from '../../../enum/formField/flow';
import { getRuleChains } from '/@/api/ruleDesigner';
import { FormSchema } from '/@/components/Form';
const fetch = async (params: Recordable, ruleChainId: string) => {
try {
const result = await getRuleChains(params);
const data = result.data
.map((item) => ({ label: item.name, value: item.id.id }))
.filter((item) => item.value !== ruleChainId);
return data;
} catch (err) {
console.error(err);
return [];
}
};
export const getFormSchemas = (route: RouteLocationNormalizedLoaded): FormSchema[] => {
const ruleChainId = (route.params as Record<'id', string>).id;
return [
{
field: RuleChainFieldsEnum.RULE_CHAIN_ID,
label: RuleChainFieldsNameEnum.RULE_CHAIN_ID,
component: 'ApiSearchSelect',
componentProps: () => {
return {
placeholder: '请选择规则链',
showSearch: true,
params: {
pageSize: 50,
page: 0,
type: 'CORE',
},
api: (params: Recordable) => fetch(params, ruleChainId),
searchApi: (params: Recordable) => fetch(params, ruleChainId),
getPopupContainer: () => document.body,
};
},
},
];
};