king
2020-08-22 835b48025a582b1c19c4de128906aff6a5e63612
src/templates/subtableconfig/index.jsx
@@ -11,14 +11,13 @@
import zhCN from '@/locales/zh-CN/model.js'
import enUS from '@/locales/en-US/model.js'
import Utils from '@/utils/utils.js'
import { getSubMenuForm } from '@/templates/zshare/formconfig'
import asyncComponent from '@/utils/asyncComponent'
import SearchComponent from '@/templates/sharecomponent/searchcomponent'
import ActionComponent from '@/templates/sharecomponent/actioncomponent'
import ColumnComponent from '@/templates/sharecomponent/columncomponent'
import MenuForm from '@/templates/zshare/menuform'
import MenuForm from './menuform'
import EditComponent from '@/templates/zshare/editcomponent'
import SourceElement from '@/templates/zshare/dragsource'
import Source from './source'
@@ -52,9 +51,6 @@
    config: null,            // 页面配置
    visible: false,          // 搜索条件、按钮、显示列,模态框显示控制
    tableFields: [],         // 已选表字段集
    fields: null,            // 搜索条件及显示列,可选字段
    menuformlist: null,      // 基本信息表单字段
    formlist: null,          // 搜索条件、按钮、显示列表单字段
    menuloading: false,      // 菜单保存中
    menucloseloading: false, // 菜单关闭时,选择保存
    loading: false,          // 加载中,页面spin
@@ -83,12 +79,12 @@
    let _config = null
    if (!config) {
      _config = JSON.parse(JSON.stringify(Source.baseConfig))
      _config = fromJS(Source.baseConfig).toJS()
      _config.uuid = editSubTab ? editSubTab.linkTab : editTab.linkTab
      _config.tabName = editSubTab ? editSubTab.label : editTab.label
      _config.isAdd = true
    } else {
      _config = JSON.parse(JSON.stringify(config))
      _config = fromJS(config).toJS()
      _config.search.forEach(item => {
        if (
@@ -114,7 +110,7 @@
        let uuid = Utils.getuuid()
        if (item.OpenType === 'pop') { // 含有子配置项的按钮
          _oriActions.push({
            prebtn: JSON.parse(JSON.stringify(item)),
            prebtn: fromJS(item).toJS(),
            curuuid: uuid,
            Template: 'Modal'
          })
@@ -185,8 +181,7 @@
      optionLibs: optionLibs,
      config: _config,
      activeKey: _activeKey || '0',
      originConfig: _config,
      menuformlist: getSubMenuForm(_config)
      originConfig: fromJS(_config).toJS(),
    })
  }
@@ -305,34 +300,40 @@
   * @description 标签页保存
   */
  submitConfig = () => {
    const { delActions, thawButtons, originConfig, openEdition } = this.state
    let config = JSON.parse(JSON.stringify(this.state.config))
    const { delActions, thawButtons, openEdition } = this.state
    let _config = fromJS(this.state.config).toJS()
    let copyreg = /\d{4}-\d{2}-\d{2}\s\d{2}:\d{2}:\d{2}$/ig
    this.menuformRef.handleConfirm().then(res => {
      if (copyreg.test(res.MenuNo) || copyreg.test(res.MenuName)) {
    // 基本信息验证
    if (!_config.tabName || !_config.tabNo) {
        notification.warning({
          top: 92,
          message: '请修改标签名称和标签参数,不可以时间格式 YYYY-MM-DD HH:mm:ss 结尾!',
        message: this.state.dict['model.menu.basemsg'],
          duration: 5
        })
        return
      }
      if (originConfig.isAdd) {
        if (config.search[0] && config.search[0].origin) {
          config.search = config.search.filter(item => !item.origin)
        }
        if (config.action[0] && config.action[0].origin) {
          config.action = config.action.filter(item => !item.origin)
        }
        if (config.columns[0] && config.columns[0].origin) {
          config.columns = config.columns.filter(item => !item.origin)
        }
    if (copyreg.test(_config.tabNo) || copyreg.test(_config.tabName)) {
      notification.warning({
        top: 92,
        message: '此标签为复制标签,请修改标签名称和标签参数,不可以时间格式 YYYY-MM-DD HH:mm:ss 结尾!',
        duration: 5
      })
      return
      }
      let _LongParam = ''
      let _config = {...config, tabName: res.MenuName, tabNo: res.MenuNo, Remark: res.Remark}
    if (_config.isAdd) {
      if (_config.search[0] && _config.search[0].origin) {
        _config.search = _config.search.filter(item => !item.origin)
      }
      if (_config.action[0] && _config.action[0].origin) {
        _config.action = _config.action.filter(item => !item.origin)
      }
      if (_config.columns[0] && _config.columns[0].origin) {
        _config.columns = _config.columns.filter(item => !item.origin)
      }
    }
      // 未设置数据源或主键时,启用状态为false
      let result = this.verifyconfig(_config)
@@ -442,6 +443,8 @@
        delete _config.type
        delete _config.isAdd
      let _LongParam = ''
        try {
          _LongParam = window.btoa(window.encodeURIComponent(JSON.stringify(_config)))
        } catch (e) {
@@ -462,7 +465,7 @@
          func: 'sPC_Button_AddUpt',
          Type: 40,
          ParentID: _config.uuid,
          MenuNo: res.MenuNo,
        MenuNo: _config.tabNo,
          Template: 'SubTable',
          PageParam: '',
          LongParam: '',
@@ -471,7 +474,7 @@
        let btntabs = []
        config.action.forEach((item, index) => {
      _config.action.forEach((item, index) => {
          if (item.OpenType === 'popview') {
            btntabs.push(`select '${item.uuid}' as MenuID ,'${item.linkTab}' as Tabid,'${item.label}' as TabName ,'${(index + 1) * 10}' as Sort`)
          }
@@ -496,10 +499,10 @@
        let param = {
          func: 'sPC_Tab_AddUpt',
          MenuID: _config.uuid,
          MenuNo: res.MenuNo,
        MenuNo: _config.tabNo,
          Template: 'SubTable',
          MenuName: res.MenuName,
          Remark: res.Remark,
        MenuName: _config.tabName,
        Remark: _config.Remark,
          Sort: 0,
          PageParam: JSON.stringify({Template: 'SubTable'}),
          LongParam: _LongParam
@@ -615,7 +618,7 @@
              this.setState({
                openEdition: response.open_edition || '',
                config: _config,
                originConfig: _config
              originConfig: fromJS(_config).toJS()
              }, () => {
                this.setState({
                  menuloading: false,
@@ -637,13 +640,7 @@
          })
        })
      })
    }, () => {
      notification.warning({
        top: 92,
        message: this.state.dict['model.menu.basemsg'],
        duration: 5
      })
    })
  }
  /**
@@ -792,21 +789,13 @@
        onCancel() {}
      })
    } else {
      this.menuformRef.handleConfirm().then(res => {
        let _config = {...config, tabName: res.MenuName, tabNo: res.MenuNo, Remark: res.Remark}
        if (!is(fromJS(originConfig), fromJS(_config))) {
      if (!is(fromJS(originConfig), fromJS(config))) {
          this.setState({
            closeVisible: true
          })
        } else {
          this.handleViewBack()
        }
      }, () => {
        this.setState({
          closeVisible: true
        })
      })
    }
  }
@@ -824,10 +813,7 @@
        duration: 5
      })
    } else {
      this.menuformRef.handleConfirm().then(res => {
        let _config = {...config, tabName: res.MenuName, tabNo: res.MenuNo, Remark: res.Remark}
        if (!is(fromJS(originConfig), fromJS(_config))) {
      if (!is(fromJS(originConfig), fromJS(config))) {
          notification.warning({
            top: 92,
            message: '菜单配置已修改,请保存!',
@@ -914,13 +900,6 @@
            }
          })
        }
      }, () => {
        notification.warning({
          top: 92,
          message: '菜单基本信息已修改,请保存!',
          duration: 5
        })
      })
    }
  }
@@ -1101,8 +1080,8 @@
                {/* 菜单信息 */}
                <MenuForm
                  dict={this.state.dict}
                  formlist={this.state.menuformlist}
                  wrappedComponentRef={(inst) => this.menuformRef = inst}
                  config={config}
                  updatemenu={this.updateconfig}
                />
                {/* 表名添加 */}
                <TableComponent
@@ -1190,7 +1169,6 @@
                config={config}
                mainsearch={!this.props.editSubTab && this.props.editTab.mainsearch ? this.props.editTab.mainsearch : ''}
                MenuID={config.uuid}
                menuformRef={this.menuformRef}
                permFuncField={this.props.permFuncField}
                updatesetting={this.updateconfig}
              />
@@ -1221,7 +1199,6 @@
                          menu={{MenuID: config.uuid, MenuName: config.tabName, MenuNo: config.tabNo, fstMenuList: this.props.menu.fstMenuList}}
                          config={config}
                          tabs={this.state.tabviews}
                          menuformRef={this.menuformRef}
                          pasteContent={this.state.pasteContent}
                          usefulFields={this.props.permFuncField}
                          setSubConfig={this.setSubConfig}