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
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
| import { Base } from '@/libs/Base/Base'
| const request = Base.request
|
| /**
| * 获取字典
| * */
| export const getAlltype = (key: string) => {
| return request.get(`/api/v1/wmssuite/common/options/cache/all?key=${key}`)
| }
| /**
| * 获取动态表头
| */
| export const getColumnConfig = (key: string) => {
| return request.get(`/api/v1/wmssuite/dynamicproperty?key=${key}`)
| }
|
| export const getColumnConfigList = async (data: any) => {
| const dictionaryRes = await getAlltype(data)
| let dictionary = dictionaryRes.reduce((p: any, c: any) => {
| //转换一下后端因框架原因字典map和list不一致的情况
| p[c.key] = {
| ...c,
| key: c.key,
| dictionaryGroup: c.dictionaryGroup,
| dictionaryMap: {
| ...c.dictionaryGroup.reduce((pr: any, cr: any) => {
| const transformMap = {
| TRUE: 'true',
| True: 'true',
| FALSE: 'false',
| False: 'false',
| }
| const _key = transformMap[cr.value] || cr.value
| pr[_key] = cr.label
| return pr
| }, {}),
| },
| }
| return p
| }, {})
|
| /////////////
| const res = await getColumnConfig(data)
| let dynamicsColumn = res.columns.filter((item: any) => item.isShow) || []
|
| let dynamicsFilter = res.filters.map((i: any) => ({
| prop: i.propertyName,
| title: i.label,
| el: i.elementType,
| placeholder: i.placeholder,
| options: dictionary[i.optionKey]?.dictionaryGroup,
| filterable: true,
| urlConfig: {
| url: `/api/v1/wmssuite/common/options/filter`,
| params: {
| Key: i.optionKey,
| },
| },
| }))
|
| let dynamicsForm = res.forms.map((i: any) => ({
| prop: i.propertyName,
| label: i.label,
| el: i.elementType,
| placeholder: i.placeholder,
| rules: i.rules
| ? i.rules.map((item) => {
| const _obj = JSON.parse(item)
| if (_obj.pattern) {
| _obj.pattern = eval(_obj.pattern)
| }
| return _obj
| })
| : [],
| clearable: i.clearable,
| disabled: i.disabled,
| options: dictionary[i.optionKey]?.dictionaryGroup?.map((item: any) => ({
| ...item,
| value: String(item.value),
| })),
| type: 'datetime',
|
| urlConfig: {
| url: `/api/v1/wmssuite/common/options/filter`,
| params: {
| Key: i.optionKey,
| },
| optionString: true, //extend类扩展属性后端只传收字符串
| },
| }))
| return {
| dictionary,
| dynamicsColumn,
| dynamicsFilter,
| dynamicsForm,
| }
| }
|
|