king
2022-03-24 26d0fa42ea8c63a87e8ef93d0915f75f46fb1f9c
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
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
import { fromJS } from 'immutable'
import MenuUtils from '@/utils/utils-custom.js'
 
/**
 * @description Wrap表单配置信息
 */
export default function (wrap, subtype, columns = [], id = '', supNodes = []) {
  let appType = sessionStorage.getItem('appType')
  let MenuType = ''
  let menu = fromJS(window.GLOB.customMenu).toJS()
 
  if (menu.parentId === 'BillPrintTemp') {
    MenuType = 'billPrint'
  }
  let modules = []
  if (subtype === 'propcard' || subtype === 'datacard') {
    modules = MenuUtils.getSupModules(menu.components, id) || []
  }
 
  let roleList = sessionStorage.getItem('sysRoles')
 
  if (roleList) {
    try {
      roleList = JSON.parse(roleList)
    } catch (e) {
      roleList = []
    }
  } else {
    roleList = []
  }
 
  const cardWrapForm = [
    {
      type: 'text',
      field: 'title',
      label: '标题',
      initval: wrap.title || '',
      required: false
    },
    {
      type: 'text',
      field: 'name',
      label: '组件名称',
      initval: wrap.name || '',
      tooltip: '用于组件间的区分。',
      required: true
    },
    {
      type: 'number',
      field: 'width',
      label: '宽度',
      initval: wrap.width || 24,
      tooltip: '栅格布局,每行等分为24列。',
      min: 1,
      max: 24,
      precision: 0,
      required: true
    },
    {
      type: 'radio',
      field: 'datatype',
      label: '数据来源',
      initval: wrap.datatype || 'dynamic',
      tooltip: '选择静态值,无需配置数据源。',
      required: false,
      options: [
        {value: 'dynamic', label: '动态', priKeyType: 'static'},
        {value: 'static', label: '静态', priKeyType: 'static'},
      ],
      linkFields: ['priKeyType'],
      controlFields: [
        {field: 'goback', values: ['dynamic']},
        {field: 'empty', values: ['dynamic']},
        {field: 'supModule', values: ['static']},
      ],
      forbid: subtype !== 'propcard'
    },
    {
      type: 'radio',
      field: 'pagestyle',
      label: '分页风格',
      initval: wrap.pagestyle || 'page',
      tooltip: '数据源选择分页时有效。注:滑动加载只有第一个有效',
      required: false,
      options: [
        {value: 'page', label: '页码'},
        {value: 'switch', label: '左右切换', forbid: appType === 'mob'},
        {value: 'slide', label: '滑动加载', forbid: appType !== 'mob'},
      ],
      forbid: !(subtype === 'datacard' || (subtype === 'tablecard' && appType === 'mob'))
    },
    {
      type: 'radio',
      field: 'cardType',
      label: '数据选择',
      initval: wrap.cardType || '',
      required: false,
      options: [
        {value: '', label: '不可选'},
        {value: 'radio', label: '单选'},
        {value: 'checkbox', label: '多选', disabled: subtype === 'propcard'},
      ],
      controlFields: [
        {field: 'checkAll', values: ['checkbox']},
        {field: 'selected', values: ['radio', 'checkbox']},
        {field: 'selStyle', values: ['radio', 'checkbox']},
        // {field: 'priKeyType', values: ['radio', 'checkbox']},
      ],
      forbid: subtype === 'tablecard'
    },
    {
      type: 'radio',
      field: 'priKeyType',
      label: '主键',
      initval: wrap.priKeyType || 'static',
      tooltip: '拼接值为动态主键与用户自定义的静态主键使用逗号拼接。',
      required: false,
      linkField: 'datatype',
      options: [
        {ParentID: 'static', value: 'static', label: '静态值'},
        {ParentID: 'dynamic', value: 'static', label: '静态值'},
        {ParentID: 'dynamic', value: 'dynamic', label: '动态值'},
        {ParentID: 'dynamic', value: 'joint', label: '拼接值'},
      ],
      forbid: subtype !== 'propcard'
    },
    {
      type: 'radio',
      field: 'selected',
      label: '首行选中',
      initval: wrap.selected || 'false',
      required: false,
      options: [
        {value: 'false', label: '无'},
        {value: 'init', label: '初始化'},
        {value: 'always', label: '数据加载'},
      ]
    },
    {
      type: 'select',
      field: 'selStyle',
      label: '选中风格',
      initval: wrap.selStyle || 'active',
      tooltip: '存在边框时,边框会使用系统色。',
      required: false,
      options: [
        {value: 'none', label: '无'},
        {value: 'active', label: '外阴影'},
        {value: 'backFont', label: '背景+文字'},
        {value: 'font', label: '文字'},
        ...(subtype === 'datacard' && appType === 'mob' ? [{value: 'check', label: '勾选'}] : [])
      ]
      // forbid: subtype !== 'propcard'
    },
    // {
    //   type: 'radio',
    //   field: 'checkAll',
    //   label: '全选',
    //   initval: wrap.checkAll || 'hidden',
    //   required: false,
    //   options: [
    //     {value: 'hidden', label: '隐藏'},
    //     {value: 'show', label: '显示'},
    //   ],
    //   forbid: subtype !== 'datacard' || appType !== 'mob'
    // },
    {
      type: 'radio',
      field: 'cardFloat',
      label: '对齐方式',
      initval: wrap.cardFloat || 'left',
      tooltip: '设置为居中对齐或右对齐,只在卡片为1行时有效。',
      required: false,
      options: [
        {value: 'left', label: '左对齐'},
        {value: 'center', label: '居中'},
        {value: 'right', label: '右对齐'},
      ],
      forbid: subtype === 'tablecard'
    },
    {
      type: 'radio',
      field: 'scale',
      label: '放大效果',
      initval: wrap.scale || 'false',
      tooltip: '鼠标悬浮于卡片上方时,卡片放大1.05倍。',
      required: false,
      options: [
        {value: 'false', label: '无'},
        {value: 'true', label: '有'},
      ],
      forbid: subtype === 'tablecard' || appType === 'mob'
    },
    {
      type: 'radio',
      field: 'printType',
      label: '组件类型',
      initval: wrap.printType || 'content',
      tooltip: '选择类型为《页眉/页脚》时,打印的每页里都会带有该组件。',
      required: false,
      options: [
        {value: 'content', label: '内容'},
        {value: 'headerOrfooter', label: '页眉/页脚'},
      ],
      forbid: subtype !== 'propcard' || MenuType !== 'billPrint'
    },
    {
      type: 'select',
      field: 'broadcast',
      label: '语音播报',
      initval: wrap.broadcast || '',
      tooltip: '语音播报在移动端app中有效。注:使用语音播报时,数据源不要使用同步查询,添加定时器时,可循环播报',
      required: false,
      options: columns,
      forbid: !columns || appType !== 'mob' || subtype !== 'propcard'
    },
    {
      type: 'radio',
      field: 'goback',
      label: '空值返回',
      initval: wrap.goback || 'false',
      tooltip: '当查询数据为空时,返回上一界面。',
      required: false,
      options: [
        {value: 'true', label: '是'},
        {value: 'false', label: '否'},
      ],
      forbid: subtype !== 'propcard' || appType !== 'mob'
    },
    {
      type: 'radio',
      field: 'empty',
      label: '空值隐藏',
      initval: wrap.empty || 'show',
      tooltip: '当查询数据为空时,隐藏该组件。',
      required: false,
      skip: true,
      options: [
        {value: 'show', label: '否'},
        {value: 'hidden', label: '是'},
      ],
    },
    {
      type: 'radio',
      field: 'supKey',
      label: '上级主键',
      initval: wrap.supKey || 'true',
      tooltip: '当设置上级组件时,上级主键值为空是否进行数据查询。',
      required: false,
      options: [
        {value: 'true', label: '验证'},
        {value: 'false', label: '忽略'},
      ],
      forbid: subtype !== 'datacard'
    },
    {
      type: 'cascader',
      field: 'supModule',
      label: '上级组件',
      initval: wrap.supModule || [],
      required: false,
      options: modules,
      allowClear: true,
      forbid: subtype !== 'propcard'
    },
    {
      type: 'select',
      field: 'controlField',
      label: '禁用字段',
      initval: wrap.controlField || '',
      tooltip: '用于控制行数据是否可选择。',
      required: false,
      allowClear: true,
      options: columns,
      controlFields: [
        {field: 'controlVal', notNull: true},
      ],
      forbid: subtype !== 'datacard'
    },
    {
      type: 'text',
      field: 'controlVal',
      label: '控制值',
      initval: wrap.controlVal || '',
      tooltip: '当字段值与控制值相等时,行数据会禁用,多个值用逗号分隔。',
      required: false,
      forbid: subtype !== 'datacard'
    },
    {
      type: 'radio',
      field: 'supType',
      label: '上级类型',
      initval: wrap.supType || 'single',
      tooltip: '上级组件为单一组件或多个组件。',
      required: false,
      forbid: subtype !== 'datacard' || appType === 'mob',
      options: [
        {value: 'single', label: '单组件'},
        {value: 'multi', label: '多组件'},
      ],
      controlFields: [
        {field: 'supNodes', values: ['multi']},
      ]
    },
    {
      type: 'multiselect',
      field: 'blacklist',
      label: '黑名单',
      initval: wrap.blacklist || [],
      required: false,
      options: roleList,
      forbid: !!appType
    },
    {
      type: 'table',
      field: 'supNodes',
      label: '上级组件',
      initval: supNodes,
      required: true,
      forbid: subtype !== 'datacard' || appType === 'mob',
      span: 24,
      columns: [
        {
          title: '序号',
          dataIndex: '$index',
          editable: false,
          required: false,
          width: '20%'
        },
        {
          title: '菜单',
          dataIndex: 'nodes',
          inputType: 'cascader',
          editable: true,
          required: true,
          extends: [{key: 'label', value: 'label'}],
          width: '50%',
          render: (text, record) => record.label,
          options: modules
        }
      ]
    }
  ]
 
  return cardWrapForm.map(item => {
    if (['pagestyle'].includes(item.field)) {
      item.options = item.options.filter(option => !option.forbid)
    }
 
    return item
  })