king
2025-05-08 b6c698c8833836971184a0a9c2645a15f8174d37
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
/**
 * @description 升级表单信息
 * @param {Object}   config      表单配置信息
 * @return {Object}  config
 */
export function updateForm (config) {
  if (!config.version && config.groups) {
    config.version = '1.0'
    if (config.groups && config.groups.length > 0) {
      let fields = []
      config.groups.forEach(group => {
        if (group.sublist.length === 0) return
 
        if (!group.default) {
          fields.push({
            type: 'split',
            label: group.label,
            uuid: group.uuid,
            span: 24
          })
        }
 
        fields.push(...group.sublist)
      })
      config.fields = fields
    }
    delete config.groups
 
    let _col = config.setting.cols || '2'
 
    config.fields = config.fields.map(item => {
      item.labelwidth = 33.3
      if (_col === '1' || item.entireLine === 'true' || ['textarea','hint','checkcard','brafteditor'].includes(item.type)) {
        item.span = 24
        if (_col === '2') {
          item.labelwidth = 16.3
        } else if (_col === '3') {
          item.labelwidth = 10.5
        } else if (_col === '4') {
          item.labelwidth = 8.3
        }
      } else if (_col === '2') {
        item.span = 12
      } else if (_col === '3') {
        item.span = 8
      } else if (_col === '4') {
        item.span = 6
      }
      return item
    })
  }
 
  return config
}
 
/**
 * @description 升级主表信息
 * @param {Object}   config      页面配置信息
 * @return {Object}  config
 */
export function updateCommonTable (config) {
  if (!config.version || config.version < '1.0') {
    config.version = '1.0'
    // 兼容标签
    if (!config.tabgroups) {
      config.tabgroups = [{ uuid: 'tabs', sublist: [] }]
    } else if (typeof(config.tabgroups[0]) === 'string') {
      let _tabgroups = []
      config.tabgroups.forEach(groupId => {
        let _group = {
          uuid: groupId,
          sublist: config[groupId]
        }
 
        delete config[groupId]
 
        _tabgroups.push(_group)
      })
 
      config.tabgroups = _tabgroups
    }
 
    // 兼容图表
    if (!config.charts) {
      config.expand = true
      config.charts = [{ uuid: '$$normaltable', label: '', title: '', chartType: 'table', icon: 'table', Hide: 'false', blacklist: [] }]
    } else {
      config.charts.forEach(card => {
        if (card.chartType === 'card') {
          card.details = card.details.map(_cell => {
            _cell.fontSize = _cell.fontSize || 14
            if (!_cell.width) {
              _cell.width = 100
            } else if (_cell.width === 'helf') {
              _cell.width = 50
            } else if (_cell.width === 'third') {
              _cell.width = 33
            }
            if (!_cell.fontWeight && _cell.bold === 'true') {
              _cell.fontWeight = 'normal'
            }
            _cell.height = _cell.height || 1
 
            return _cell
          })
        }
      })
    }
  }
 
  if (config.version < '1.1') {
    config.version = '1.1'
    if (config.setting.interType === 'inner' && !config.setting.innerFunc) {
      config.setting.interType = 'system'
    }
    // 兼容接口类型
    config.action = config.action.map(item => {
      if (item.intertype === 'inner' && !item.innerFunc) {
        item.intertype = 'system'
      }
      return item
    })
  }
 
  if (config.version < '1.2') {
    config.version = '1.2'
    // 兼容功能按钮
    config.action = config.action.map(item => {
      if (item.execMode) {
        item.OpenType = 'funcbutton'
      } else if (item.OpenType === 'blank') {
        item.OpenType = 'tab'
      }
      return item
    })
  }
 
  if (config.version < '2.0') {
    config.version = '2.0'
    // 去除传统table中的标签,调整数据结构
    if (config.charts && config.charts.length === 1) {
      config.charts = null
    }
  }
 
  config.Template = 'CommonTable'
 
  return config
}
 
/**
 * @description 升级子表信息
 * @param {Object}   config      页面配置信息
 * @return {Object}  config
 */
export function updateSubTable (config) {
  if (!config.version || config.version < '1.0') {
    config.version = '1.0'
    // 兼容图表
    if (!config.charts) {
      config.expand = false
      config.charts = [{
        uuid: '$$normalsubtable',
        label: '',
        title: '',
        chartType: 'table',
        icon: 'table',
        Hide: 'false',
        blacklist: []
      }]
    } else {
      config.charts.forEach(card => {
        if (card.chartType === 'card') {
          card.details = card.details.map(_cell => {
            if (!_cell.fontSize) {
              _cell.fontSize = 14
            }
            if (!_cell.width) {
              _cell.width = 100
            } else if (_cell.width === 'helf') {
              _cell.width = 50
            } else if (_cell.width === 'third') {
              _cell.width = 33
            }
      
            if (_cell.bold === 'true') {
              _cell.fontWeight = 'normal'
            }
 
            if (!_cell.height) {
              _cell.height = 1
            }
 
            return _cell
          })
        }
      })
    }
  }
 
  if (config.version < '1.1') {
    config.version = '1.1'
    if (config.setting.interType === 'inner' && !config.setting.innerFunc) {
      config.setting.interType = 'system'
    }
    // 兼容接口类型
    config.action = config.action.map(item => {
      if (item.intertype === 'inner' && !item.innerFunc) {
        item.intertype = 'system'
      }
      return item
    })
  }
 
  if (config.version < '1.2') {
    config.version = '1.2'
    // 兼容功能按钮
    config.action = config.action.map(item => {
      if (item.execMode) {
        item.OpenType = 'funcbutton'
      } else if (item.OpenType === 'blank') {
        item.OpenType = 'tab'
      }
      return item
    })
  }
 
  if (config.version < '2.0') {
    config.version = '2.0'
    // 去除传统table中的标签,调整数据结构
    if (config.charts && config.charts.length === 1) {
      config.charts = null
    }
  }
  
  config.Template = 'SubTable'
 
  return config
}
 
/**
 * @description 升级弹窗子表信息
 * @param {Object}   config      页面配置信息
 * @return {Object}  config
 */
export function updateSubTabTable (config) {
  if (!config.version || config.version < '1.1') {
    config.version = '1.1'
    if (config.setting.interType === 'inner' && !config.setting.innerFunc) {
      config.setting.interType = 'system'
    }
    // 兼容接口类型
    config.action = config.action.map(item => {
      if (item.intertype === 'inner' && !item.innerFunc) {
        item.intertype = 'system'
      }
      return item
    })
  }
 
  if (config.version < '1.2') {
    config.version = '1.2'
    // 兼容功能按钮
    config.action = config.action.map(item => {
      if (item.execMode) {
        item.OpenType = 'funcbutton'
      } else if (item.OpenType === 'blank') {
        item.OpenType = 'tab'
      }
      return item
    })
  }
  
  config.Template = 'SubTable'
 
  return config
}