king
2023-02-10 253fbcbdd06f6354e857a8e1e47ddf116459df42
src/templates/comtableconfig/updatetable/index.jsx
@@ -77,24 +77,22 @@
      style: { backgroundColor: '#ffffff', paddingTop: '16px', paddingBottom: '80px', paddingLeft: '16px', paddingRight: '16px'},
    }
    let uuids = {}
    let formActions = []
    let popActions = []
    let errors = []
    let mainTb = {name: '主表', uuid: Utils.getuuid(), useMSearch: 'false'}
    let mainTb = {name: '主表', uuid: Utils.getuuid(), useMSearch: 'false', isMain: true}
    let oldtabs = {
      mainTable: mainTb.uuid
    }
    let tbl = this.getTable(config, mainTb, uuids, errors, formActions, popActions, oldtabs)
    let tbl = this.getTable(config, mainTb, errors, formActions, popActions, oldtabs)
    if (config.autoMatic && config.autoMatic.enable === 'true' && uuids[config.autoMatic.action]) {
      _config.autoMatic = {...config.autoMatic}
      _config.autoMatic.action = uuids[config.autoMatic.action]
      if (tbl.action.filter(item => item.uuid === _config.autoMatic.action && (['pop', 'prompt', 'exec'].includes(item.OpenType) || (item.OpenType === 'funcbutton' && item.funcType === 'print'))).length === 0) {
    if (config.autoMatic && config.autoMatic.enable === 'true') {
      if (tbl.action.filter(item => item.uuid === config.autoMatic.action && (['pop', 'prompt', 'exec'].includes(item.OpenType) || (item.OpenType === 'funcbutton' && item.funcType === 'print'))).length === 0) {
        _config.autoMatic = {enable: 'false'}
      } else {
        _config.autoMatic = {...config.autoMatic}
      }
    } else {
      _config.autoMatic = {enable: 'false'}
@@ -185,7 +183,7 @@
        _config.components = _config.components.map(item => {
          if (item.type === 'tabs') {
            item.subtabs = item.subtabs.map(tab => {
              tab.components[0] = this.getTable(menus[tab.components[0].linkTab], tab.components[0], uuids, errors, formActions, popActions, oldtabs)
              tab.components[0] = this.getTable(menus[tab.components[0].linkTab], tab.components[0], errors, formActions, popActions, oldtabs)
              return tab
            })
@@ -262,7 +260,7 @@
                      MenuName: btn.label,
                      tables: _config.tables || [],
                      Template: 'BaseTable',
                      components: [this.getTable(menus[btn.uuid], mainTb, {}, errors, formActions)],
                      components: [this.getTable(menus[btn.uuid], mainTb, errors, formActions)],
                      viewType: 'popview',
                      style: { backgroundColor: '#ffffff', backgroundImage: '', paddingTop: '16px', paddingBottom: '40px', paddingLeft: '16px', paddingRight: '16px' }
                    }
@@ -286,7 +284,7 @@
                        MenuName: btn.label,
                        tables: _config.tables || [],
                        Template: 'BaseTable',
                        components: [this.getTable(menus[btn.uuid], mainTb, {}, errors, formActions)],
                        components: [this.getTable(menus[btn.uuid], mainTb, errors, formActions)],
                        viewType: 'popview',
                        style: { backgroundColor: '#ffffff', backgroundImage: '', paddingTop: '16px', paddingBottom: '40px', paddingLeft: '16px', paddingRight: '16px' }
                      }
@@ -311,7 +309,7 @@
                    MenuName: btn.label,
                    tables: _config.tables || [],
                    Template: 'BaseTable',
                    components: [this.getTable(menus[btn.uuid], mainTb, {}, errors, formActions)],
                    components: [this.getTable(menus[btn.uuid], mainTb, errors, formActions)],
                    viewType: 'popview',
                    style: { backgroundColor: '#ffffff', backgroundImage: '', paddingTop: '16px', paddingBottom: '40px', paddingLeft: '16px', paddingRight: '16px' }
                  }
@@ -335,7 +333,7 @@
                      MenuName: btn.label,
                      tables: _config.tables || [],
                      Template: 'BaseTable',
                      components: [this.getTable(menus[btn.uuid], mainTb, {}, errors, formActions)],
                      components: [this.getTable(menus[btn.uuid], mainTb, errors, formActions)],
                      viewType: 'popview',
                      style: { backgroundColor: '#ffffff', backgroundImage: '', paddingTop: '16px', paddingBottom: '40px', paddingLeft: '16px', paddingRight: '16px' }
                    }
@@ -682,6 +680,8 @@
    param.timestamp = moment().format('YYYY-MM-DD HH:mm:ss')
    param.secretkey = Utils.encrypt(param.LText, param.timestamp)
    let save = false
    new Promise(resolve => {
      Api.getSystemConfig(param).then(res => {
        resolve(res)
@@ -689,10 +689,14 @@
    }).then(res => { // 删除原菜单
      if (!res || !res.status) return res
      save = true
      localStorage.setItem('menuUpdate', new Date().getTime() + ',' + config.uuid)
      if (this.delButtons.length === 0) return res
      return Api.getSystemConfig({
        func: 'sPC_MainMenu_Del',
        up_type: 'Y',
        MenuID: this.delButtons.join(',')
      })
    }).then(res => {
@@ -701,34 +705,36 @@
      _resolve()
      if (res.status) {
        localStorage.setItem('menuUpdate', new Date().getTime())
        notification.success({
          top: 92,
          message: '升级成功',
          duration: 2
        })
        delete urlparam.type
        delete urlparam.MenuType
        let _param = window.btoa(window.encodeURIComponent(JSON.stringify(urlparam)))
        setTimeout(() => {
          window.history.replaceState(null, null, window.location.href.split('#')[0] + `#/tabledesign/${_param}`)
          window.location.reload()
        }, 2000)
        window.history.replaceState(null, null, window.location.href.split('#')[0] + `#/tabledesign/${_param}`)
        window.location.reload()
      } else {
        notification.warning({
          top: 92,
          message: res.message,
          duration: 5
        Modal.warning({
          title: res.message,
          okText: '知道了',
          onOk: () => {
            if (save) {
              delete urlparam.type
              delete urlparam.MenuType
              let _param = window.btoa(window.encodeURIComponent(JSON.stringify(urlparam)))
              window.history.replaceState(null, null, window.location.href.split('#')[0] + `#/tabledesign/${_param}`)
              window.location.reload()
            } else {
              window.location.reload()
            }
          }
        })
      }
    })
  }
  getTable = (config, newCon, uuids, errors, formActions, popActions, oldtabs) => {
  getTable = (config, newCon, errors, formActions, popActions, oldtabs) => {
    let _card = {
      uuid: newCon.uuid,
      type: 'table',
@@ -807,6 +813,7 @@
          if (m.signType === 'line') {
            lineMarks.push({
              $index: lineMarks.length + 1,
              uuid: Utils.getuuid(),
              field: field,
              color: color,
              contrastValue: m.contrastValue || '',
@@ -816,6 +823,7 @@
          } else {
            _col.marks.push({
              $index: _col.marks.length + 1,
              uuid: Utils.getuuid(),
              field: field,
              color: color,
              contrastValue: m.contrastValue || '',
@@ -883,10 +891,12 @@
                datatype: 'dynamic',
                eleType: _cols[sub].type !== 'number' ? 'text' : 'number',
                field: sub,
                height: 1,
                innerHeight: 21,
                height: '',
                innerHeight: 'auto',
                marks: _cols[sub].marks || null,
                noValue: 'show',
                prefix: _cols[sub].prefix || '',
                postfix: _cols[sub].postfix || '',
                style: {},
                width: 24,
                uuid: Utils.getuuid()
@@ -961,13 +971,23 @@
    let colbtns = []
    let colors = { primary: '#1890ff', yellow: '#c49f47', orange: 'orange', danger: '#ff4d4f', green: '#26C281', dgreen: '#32c5d2', purple: '#8E44AD', cyan: '#13c2c2', gray: '#666666', default: 'rgba(0, 0, 0, 0.65)' }
    let uuids = {}
    config.action.forEach(btn => {
      let _c = btn.class ? btn.class.replace('border-', '') : ''
      let color = colors[_c] || '#1890ff'
      let _btn = fromJS(btn).toJS()
      _btn.uuid = Utils.getuuid()
      // _btn.uuid = Utils.getuuid()
      delete _btn.position
      delete _btn.linkTab
      if (_btn.intertype === 'inner' && !_btn.innerFunc) {
        _btn.intertype = 'system'
      }
      if (_btn.funcType === 'print' && _btn.execMode) {
        _btn.OpenType = 'funcbutton'
      } else if (_btn.OpenType === 'blank') {
        _btn.OpenType = 'tab'
      }
      this.delButtons.push(btn.uuid)
@@ -1001,22 +1021,22 @@
        _btn.popClose = 'mainline'
      }
      uuids[btn.uuid] = _btn.uuid
      if (btn.OpenType === 'pop' || (btn.OpenType === 'funcbutton' && btn.funcType === 'print' && btn.execMode === 'pop')) {
      if (_btn.OpenType === 'pop' || (_btn.OpenType === 'funcbutton' && _btn.funcType === 'print' && _btn.execMode === 'pop')) {
        formActions.push({origin: btn.uuid, uuid: _btn.uuid, name: newCon.name, label: btn.label})
      } else if (btn.OpenType === 'popview') {
      } else if (_btn.OpenType === 'popview') {
        if (!popActions) return
        popActions.push({origin: btn.uuid, linkTab: btn.linkTab || '', uuid: _btn.uuid, name: newCon.name, label: btn.label})
      } else if (btn.OpenType === 'tab') {
      } else if (_btn.OpenType === 'tab') {
        if (btn.tabTemplate === 'FormTab' || !btn.linkmenu || btn.linkmenu.length !== 3) {
          errors.push(newCon.name + '中按钮《' + btn.label + '》不在支持')
          return
        }
      }
      uuids[btn.uuid] = true
      if (_btn.tabType === 'CommonTable' || _btn.tabType === 'SubTable') {
        _btn.tabType = 'BaseTable'
@@ -1059,8 +1079,14 @@
    _card.scripts = config.setting.scripts || []
    sets.forEach(n => {
      if (n === 'interType' && !['system', 'inner', 'outer'].includes(config.setting.interType)) {
        _card.setting.interType = 'system'
      if (n === 'interType') {
        if (!['system', 'inner', 'outer'].includes(config.setting.interType)) {
          _card.setting.interType = 'system'
        } else if (config.setting.interType === 'inner' && !config.setting.innerFunc) {
          _card.setting.interType = 'system'
        } else {
          _card.setting.interType = config.setting.interType
        }
      } else if (typeof(n) === 'string') {
        _card.setting[n] = config.setting[n] || ''
      } else {
@@ -1075,9 +1101,8 @@
      }
    })
    if (config.setting.doubleClick && uuids[config.setting.doubleClick]) {
      _card.wrap.doubleClick = uuids[config.setting.doubleClick]
    } else {
    _card.wrap.doubleClick = config.setting.doubleClick || ''
    if (_card.wrap.doubleClick && !uuids[_card.wrap.doubleClick]) {
      _card.wrap.doubleClick = ''
    }