Ben Lin
2024-07-03 46c3d28c5633baaddad0da441185310b9360a45b
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
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
/*
 * @Description: 产品工艺路线相关
 * @Author: Ben Lin
 * @version:
 * @Date: 2024-06-19 20:34:27
 * @LastEditors: Ben Lin
 * @LastEditTime: 2024-06-28 10:53:28
 */
 
import { Tag, Tooltip } from 'ant-design-vue';
import { ActionItem, BasicColumn } from '/@/components/Table';
import { useI18n } from '/@/hooks/web/useI18n';
import { h, unref } from 'vue';
import { GetEnum } from '/@/api/tigerapi/system';
import { useLocale } from '/@/locales/useLocale';
 
const { getLocale } = useLocale();
 
const { t } = useI18n();
 
function _default() {
  const ActionColumn: BasicColumn = {
    width: 80,
    title: '操作',
    dataIndex: 'action',
    slots: { customRender: 'action' },
    fixed: undefined,
  };
 
  /**
   * @description: 一些自定义方法
   * @return {*}
   */  
  const methods = {
    /**
     * @description: 获取新增按钮的行为,必需要有的方法
     * @return {*}
     */
    CreateAction: (fnName: string) => {
      return {
        action: 'drawer', //drawer(打开左侧抽屉框) | go(跳转到新的页面)
      };
    },
    /**
     * @description: 产品绑定工艺路线操作字段自定义按钮,必需要有的方法
     * @return {*}
     */
    ActionItem: (params: Recordable<any>, data, ...args): ActionItem[] => {
      return data;
    },
    /**
     * @description: 高级表单和详情页面返回主页面的url
     * @return {*}
     */    
    GetHomeUrl: () => {
      return `/BAS_LABEL_TEMP/LC/${encodeURI(JSON.stringify({ ID: 'BAS_LABEL_TEMP', colSlots: [], crudColSlots: [] }))}`;
    },
    GetBaseColumns: () => {
      return [
        {
          dataIndex: 'LABEL_ID',
          title: '标签模板ID',
          ifShow: false,
          sorter: true,
          resizable: true,
        },
        {
          dataIndex: 'VAR_NAME',
          title: '变量名称',
          ifShow: true,
          sorter: true,
          resizable: true,
          customRender: () => {},
        },
        {
          dataIndex: 'VAR_TYPE',
          title: '变量类型',
          ifShow: true,
          sorter: true,
          resizable: true,
          customRender: ({ record }) => {
            let color = '';
            let text = '';
            switch (record.VAR_TYPE) {
              case 0:
                text = '常量';
                color = 'green';
                break;
              case 1:
                text = '过程变量';
                color = 'orange';
                break;
              case 2:
                text = '日期变量';
                color = '#4f68b0';
                break;
              case 3:
                text = '自定义变量';
                color = '#bfbfbf';
                break;
            }
            return h(Tooltip, { title: text }, () => h(Tag, { color: color }, () => text));
          },
        },
        {
          dataIndex: 'VAR_VALUE',
          title: '变量值',
          ifShow: true,
          sorter: true,
          resizable: true,
        },
        {
          dataIndex: 'REMARK',
          title: '备注',
          ifShow: true,
          sorter: true,
          resizable: true,
        },
      ];
    },
    GetSearchForm: () => {
      return [
        {
          field: 'VAR_NAME',
          label: t('变量名'),
          colProps: { span: 8 },
          component: 'Input',
        },
      ];
    },
    GetCrudForm: () => {
      let isShow = false;
      return [
        {
          field: 'ID',
          label: '变量ID',
          component: 'Input',
          colProps: {
            span: 20,
          },
          show: false,
        },
        {
          field: 'LABEL_ID',
          label: '标签模板ID',
          component: 'Input',
          colProps: {
            span: 20,
          },
          show: false,
        },
        {
          field: 'VAR_NAME',
          label: '变量名',
          required: true,
          component: 'Input',
          isexist: 'Y',
          colProps: {
            span: 20,
          },
        },
        {
          field: 'VAR_TYPE',
          label: '变量类型',
          component: 'ApiSelect',
          colProps: {
            span: 20,
          },
          componentProps: {
            api: GetEnum,
            params: { name: 'BAS_LABEL_VAR+VAR_TYPEs' },
            resultField: 'Data',
            labelField: unref(getLocale) == 'zh_CN' ? 'Desc' : 'Name',
            valueField: 'Value',
            onChange: (e) => {
              if (e == 1) {
                isShow = true;
              } else {
                isShow = false;
              }
            },
          },
        },
        {
          field: 'VAR_VALUE',
          label: '变量值',
          required: true,
          component: 'Input',
          colProps: {
            span: 20,
          },
        },
        {
          field: 'BAS_LABEL_PV1PSelect_0', //按低代码配置的规则,实体名+序号+PSelect_0,序号用来区分多个的时候,PSelect_0这是个固定后缀
          label: '1',
          defaultValue: 'BAS_LABEL_PV',
          component: 'Input',
          colProps: { span: 4 },
          ifShow: ({ values }) => isShow,
          colSlot: 'BAS_LABEL_PV1add', //按低代码配置的规则,实体名+序号+add,序号用来区分多个的时候,add这是个固定后缀
        },
        {
          field: 'REMARK',
          label: '备注',
          component: 'Input',
          colProps: {
            span: 20,
          },
        },
      ];
    },
    KeyFieldValues: (val: string, id: string) => {
      return { LABEL_ID: id };
    },
  };
 
  return [methods, ActionColumn];
}
 
export default _default;