king
2020-09-09 2652a3c1485dbbf3b003e13e5c5d1c0205e7c324
src/templates/comtableconfig/index.jsx
@@ -9,6 +9,7 @@
import Api from '@/api'
import Utils from '@/utils/utils.js'
import UtilsUpdate from '@/utils/utils-update.js'
import zhCN from '@/locales/zh-CN/model.js'
import enUS from '@/locales/en-US/model.js'
@@ -107,83 +108,8 @@
    _config.OpenType = menu.PageParam ? menu.PageParam.OpenType : ''
    _config.easyCode = _config.easyCode || ''
    if (!_config.version || _config.version < '1.0') {
      // 配置默认值,兼容
      _config.version = '1.0'
      _config.Template = 'CommonTable'
      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: fromJS(_config[groupId]).toJS()
          }
          delete _config[groupId]
          _tabgroups.push(_group)
        })
        _config.tabgroups = _tabgroups
      }
      // 兼容图表
      if (!_config.charts) {
        _config.expand = false
        _config.charts = [{
          uuid: Utils.getuuid(),
          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 (card.widthType === 'ratio' && card.avatar && card.avatar.widthType !== 'ratio') {
              card.avatar.widthType = 'ratio'
              card.avatar.width = 32
            }
          }
        })
      }
      // // 兼容接口类型
      // _config.action = _config.action.map(item => {
      //   if (item.intertype === 'inner' && !item.innerFunc) {
      //     item.intertype = 'system'
      //   }
      //   return item
      // })
    }
    // 版本兼容
    _config = UtilsUpdate.updateCommonTable(_config)
    
    let _oriActions = []
    if (_config.type === 'user') {