king
2021-03-05 e36eb1999794bd71e76482b92a0b0b20f49d0032
src/templates/comtableconfig/index.jsx
@@ -9,7 +9,7 @@
import Api from '@/api'
import Utils from '@/utils/utils.js'
import UtilsUpdate from '@/utils/utils-update.js'
import { updateCommonTable } from '@/utils/utils-update.js'
import zhCN from '@/locales/zh-CN/model.js'
import enUS from '@/locales/en-US/model.js'
@@ -42,9 +42,8 @@
  }
  state = {
    dict: localStorage.getItem('lang') !== 'en-US' ? zhCN : enUS,
    dict: sessionStorage.getItem('lang') !== 'en-US' ? zhCN : enUS,
    config: null,            // 页面配置
    tableFields: [],         // 已选的常用表
    formlist: null,          // 搜索条件、按钮、显示列表单字段
    menuloading: false,      // 菜单保存中
    menucloseloading: false, // 菜单关闭时,选择保存
@@ -90,7 +89,7 @@
    _config.easyCode = _config.easyCode || ''
    // 版本兼容
    _config = UtilsUpdate.updateCommonTable(_config)
    _config = updateCommonTable(_config)
    
    let _oriActions = []
    if (_config.type === 'user') {
@@ -101,17 +100,17 @@
          item.linkTab = ''
        }
        if (item.OpenType === 'pop') { // 含有子配置项的按钮(表单)
        if (item.OpenType === 'pop' || item.execMode === 'pop') { // 含有子配置项的按钮(表单)
          _oriActions.push({
            prebtn: fromJS(item).toJS(),
            curuuid: uuid,
            Template: 'Modal'
          })
        } else if (item.OpenType === 'tab' || item.OpenType === 'blank') { // 含有子配置项的按钮(标签后当前页打开)
        } else if (item.OpenType === 'tab' && item.tabTemplate === 'FormTab') { // 含有子配置项的按钮(标签页打开)
          _oriActions.push({
            prebtn: fromJS(item).toJS(),
            curuuid: uuid,
            Template: item.tabTemplate
            Template: 'FormTab'
          })
        }
@@ -616,6 +615,8 @@
        let curBtn = config.action.filter(cell => item.curuuid === cell.uuid)[0] // 查看初始化按钮是否存在
        if (!curBtn) return
        if (curBtn.OpenType !== item.prebtn.OpenType) return
        if (curBtn.OpenType === 'tab' && curBtn.tabTemplate !== 'FormTab') return
        if (curBtn.OpenType === 'funcbutton' && curBtn.execMode !== 'pop') return
        oriActions.push({
          prebtn: item.prebtn,
@@ -775,16 +776,6 @@
        duration: 5
      })
    } else {
      // 基本信息验证
      if (!config.fstMenuId || !config.ParentId || !config.MenuName || !config.MenuNo) {
        notification.warning({
          top: 92,
          message: this.state.dict['model.menu.basemsg'],
          duration: 5
        })
        this.setState({activeKey: '0'})
        return
      }
      if (!is(fromJS(originMenu), fromJS(config))) { // 菜单信息变化时,提示保存
        notification.warning({
          top: 92,
@@ -794,7 +785,7 @@
        return
      }
      let submenu = menu.fstMenuList.filter(item => item.MenuID === config.fstMenuId)[0]
      let submenu = menu.fstMenuList.filter(_menu => _menu.MenuID === config.fstMenuId)[0]
      let _Menu = {
        ...menu,
@@ -813,17 +804,17 @@
      let isbutton = true
      let _btnTab = null
      
      if (type === 'button' && item.OpenType === 'pop') {
        _view = 'Modal'             // 表单页面
      } else if (type === 'button' && (item.OpenType === 'tab' || item.OpenType === 'blank')) {
        _view = item.tabTemplate    // 新标签页模板
      if (type === 'button' && (item.OpenType === 'pop' || item.execMode === 'pop')) {
        _view = 'Modal'      // 表单页面
      } else if (type === 'button' && item.OpenType === 'tab') {
        _view = 'FormTab'    // 表单标签页模板
        _btnTab = item
      } else if (type === 'button' && item.OpenType === 'popview') {
        _view = item.tabType        // 新弹窗标签模板
        _view = 'SubTable'   // 新弹窗标签模板 tabType 属性已去除
        uuid = item.linkTab
        isbutton = false
      } else if (type === 'tab') {
        _view = item.type           // 标签模板
        _view = 'SubTable'   // 标签模板
        uuid = item.linkTab
        isbutton = false
      }
@@ -1000,8 +991,12 @@
      }
    })
    if (config.setting.interType === 'system' && config.setting.default !== 'false' && !config.setting.dataresource) {
      return '菜单尚未设置数据源,不可启用!'
    if ((config.setting.interType === 'system' || config.setting.requestMode === 'system') && config.setting.default === 'false' && config.setting.scripts && config.setting.scripts.filter(item => item.status !== 'false').length === 0) {
      return '数据源中不执行默认sql,且未添加自定义脚本,不可启用!'
    } else if (config.setting.interType === 'custom' && config.setting.procMode !== 'inner' && config.setting.preScripts && config.setting.preScripts.filter(item => item.status !== 'false').length === 0) {
      return '数据源未设置前置脚本,不可启用!'
    } else if (config.setting.interType === 'custom' && config.setting.callbackType === 'script' && config.setting.cbScripts && config.setting.cbScripts.filter(item => item.status !== 'false').length === 0) {
      return '数据源未设置回调脚本,不可启用!'
    } else if (!config.setting.primaryKey) {
      return '菜单尚未设置主键,不可启用!'
    } else if (config.columns.length === 0) {
@@ -1078,28 +1073,6 @@
  }
  
  /**
   * @description 更新常用表信息,快捷添加后更新配置信息
   */
  updatetable = (config, fields) => {
    const { tableFields } = this.state
    this.setState({
      config: config,
      tableFields: fields ? fields : tableFields
    })
  }
  /**
   * @description 更新标签配置信息
   */
  updatetabs = (config) => {
    this.setState({
      config: config
    })
  }
  /**
   * @description 更新配置信息
   */
  updateconfig = (config) => {
@@ -1112,7 +1085,7 @@
    const { menu } = this.props
    const { activeKey, config, chartview } = this.state
    const confActions = config.action.filter(_action => !_action.origin && (['pop', 'popview', 'blank'].includes(_action.OpenType) || (_action.OpenType === 'tab' && _action.tabTemplate === 'FormTab')))
    const confActions = config.action.filter(_action => !_action.origin && (['pop', 'popview'].includes(_action.OpenType) || (_action.OpenType === 'tab' && _action.tabTemplate === 'FormTab') || (_action.OpenType === 'funcbutton' && _action.execMode === 'pop')))
    let configTabs = []
    config.tabgroups.forEach(group => {
@@ -1138,7 +1111,7 @@
                <TableComponent
                  config={config}
                  containerId="main-basedata"
                  updatetable={this.updatetable}
                  updatetable={this.updateconfig}
                />
              </Panel>
              {/* 搜索条件添加 */}
@@ -1149,7 +1122,6 @@
                <FieldsComponent
                  config={config}
                  type="search"
                  tableFields={this.state.tableFields}
                  updatefield={this.updateconfig}
                />
              </Panel>
@@ -1189,7 +1161,6 @@
                <FieldsComponent
                  config={config}
                  type="columns"
                  tableFields={this.state.tableFields}
                  updatefield={this.updateconfig}
                />
              </Panel>
@@ -1300,7 +1271,7 @@
                config={config}
                tabs={this.state.tabviews}
                setSubConfig={(item) => this.setSubConfig(item, 'tab')}
                updatetabs={this.updatetabs}
                updatetabs={this.updateconfig}
              />
            </Card>
          </div>