king
2020-08-22 835b48025a582b1c19c4de128906aff6a5e63612
src/templates/comtableconfig/index.jsx
@@ -11,14 +11,13 @@
import Utils from '@/utils/utils.js'
import zhCN from '@/locales/zh-CN/model.js'
import enUS from '@/locales/en-US/model.js'
import { getMainMenuForm } 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 SourceElement from '@/templates/zshare/dragsource'
import Source from './source'
import './index.scss'
@@ -46,8 +45,6 @@
    dict: localStorage.getItem('lang') !== 'en-US' ? zhCN : enUS,
    config: null,            // 页面配置
    tableFields: [],         // 表格显示列
    fields: null,            // 搜索条件及显示列,可选字段
    menuformlist: null,      // 基本信息表单字段
    formlist: null,          // 搜索条件、按钮、显示列表单字段
    menuloading: false,      // 菜单保存中
    menucloseloading: false, // 菜单关闭时,选择保存
@@ -101,6 +98,13 @@
        }
      })
    }
    // 页面配置中保留菜单信息,只用于数据传递
    _config.ParentId = menu.ParentId
    _config.fstMenuId = menu.fstMenuId
    _config.MenuName = menu.MenuName || ''
    _config.MenuNo = menu.MenuNo || ''
    _config.OpenType = menu.PageParam ? menu.PageParam.OpenType : ''
    if (!_config.version || _config.version < '1.0') {
      // 配置默认值,兼容
@@ -221,8 +225,7 @@
      activeKey: menu.activeKey || '0',
      optionLibs: optionLibs,
      originActions: _oriActions,
      originMenu: fromJS(menu).toJS(),
      menuformlist: getMainMenuForm(menu, _config)
      originMenu: fromJS(_config).toJS()
    })
  }
@@ -314,27 +317,38 @@
   */
  submitConfig = () => {
    const { menu } = this.props
    const { originMenu, delActions, thawButtons, openEdition } = this.state
    const { delActions, thawButtons, openEdition } = this.state
    let config = fromJS(this.state.config).toJS()
    let _config = fromJS(this.state.config).toJS()
    this.menuformRef.handleConfirm().then(res => {
      if (config.isAdd) {
        config.search = config.search.filter(item => !item.origin)
        config.action = config.action.filter(item => !item.origin)
        config.columns = config.columns.filter(item => !item.origin)
        config.tabgroups[0].sublist = config.tabgroups[0].sublist.filter(item => !item.origin)
    // 基本信息验证
    if (!_config.fstMenuId || !_config.ParentId || !_config.MenuName || !_config.MenuNo) {
      notification.warning({
        top: 92,
        message: this.state.dict['model.menu.basemsg'],
        duration: 5
      })
      return
      }
      if (config.type === 'user') { // 使用已有菜单时,默认添加关联标签id
        config.action = config.action.map(item => {
    // 新建菜单,清除默认项
    if (_config.isAdd) {
      _config.search = _config.search.filter(item => !item.origin)
      _config.action = _config.action.filter(item => !item.origin)
      _config.columns = _config.columns.filter(item => !item.origin)
      _config.tabgroups[0].sublist = _config.tabgroups[0].sublist.filter(item => !item.origin)
    }
    // 使用已有菜单时,默认添加关联标签id
    if (_config.type === 'user') {
      _config.action = _config.action.map(item => {
          if (item.OpenType === 'popview' && !item.linkTab) {
            item.linkTab = Utils.getuuid()
          }
          return item
        })
    
        config.tabgroups.forEach(group => {
      _config.tabgroups.forEach(group => {
          group.sublist = group.sublist.map(tab => {
            if (!tab.linkTab) {
              tab.linkTab = Utils.getuuid()
@@ -343,10 +357,6 @@
          })
        })
      }
      let _LongParam = ''
      let _config = {...config, easyCode: res.easyCode}
      let _pageParam = {...menu.PageParam, OpenType: res.opentype}
      // 未设置数据源或标签不合法时,启用状态为false
      let vresult = this.verifyconfig(_config)
@@ -474,6 +484,8 @@
        delete _config.type
        delete _config.isAdd
  
      let _LongParam = ''
        try {
          _LongParam = window.btoa(window.encodeURIComponent(JSON.stringify(_config)))
        } catch (e) {
@@ -496,8 +508,8 @@
          func: 'sPC_Button_AddUpt',
          Type: 40,                  // 添加菜单下的按钮type为40,按钮下的按钮type为60
          ParentID: menu.MenuID,
          MenuNo: res.MenuNo,
          Template: menu.PageParam.Template || '',
        MenuNo: _config.MenuNo,
        Template: _config.Template || '',
          PageParam: '',
          LongParam: '',
          LText: []
@@ -555,15 +567,15 @@
        let param = {
          func: 'sPC_TrdMenu_AddUpt',
          FstID: res.fstMenuId,
          SndID: res.parentId,
          ParentID: res.parentId,
        FstID: _config.fstMenuId,
        SndID: _config.ParentId,
        ParentID: _config.ParentId,
          MenuID: menu.MenuID,
          MenuNo: res.MenuNo,
          EasyCode: res.easyCode,
          Template: menu.PageParam.Template || '',
          MenuName: res.MenuName,
          PageParam: JSON.stringify(_pageParam),
        MenuNo: _config.MenuNo,
        EasyCode: _config.easyCode,
        Template: _config.Template,
        MenuName: _config.MenuName,
        PageParam: JSON.stringify({...menu.PageParam, Template: _config.Template, OpenType: _config.OpenType}),
          LongParam: _LongParam,
          LText: _vals.func.map(item => `select '${menu.MenuID}' as MenuID,'${item.func}' as ProcName,'${item.label}' as MenuName`),
          LTexttb: _tables.map(item => `select '${menu.MenuID}' as MenuID,'${item}' as tbName`)
@@ -690,25 +702,10 @@
          Api.getSystemConfig(param).then(response => {
            if (response.status) {
              let _FMenu = originMenu.fstMenuList.filter(fstM => fstM.MenuID === res.fstMenuId)[0]
              let _supMenuList = []
              if (_FMenu) {
                _supMenuList = _FMenu.options
              }
              this.setState({
                config: _config,
                openEdition: response.open_edition || '',
                originMenu: {
                  ...originMenu,
                  LongParam: _config,
                  PageParam: _pageParam,
                  MenuName: res.MenuName,
                  MenuNo: res.MenuNo,
                  ParentID: res.parentId,
                  fstMenuId: res.fstMenuId,
                  supMenuList: _supMenuList
                }
              originMenu: fromJS(_config).toJS()
              })
              this.props.reloadmenu()
@@ -736,13 +733,6 @@
              })
            }
          })
        })
      })
    }, () => {
      notification.warning({
        top: 92,
        message: this.state.dict['model.menu.basemsg'],
        duration: 5
      })
    })
  }
@@ -889,7 +879,7 @@
                func: 'sPC_ButtonParam_AddUpt',
                ParentID: this.props.menu.MenuID,
                MenuID: action.curBtn.uuid,
                MenuNo: this.props.menu.MenuNo,
                MenuNo: config.MenuNo,
                Template: _temp,
                MenuName: action.curBtn.label,
                PageParam: JSON.stringify({Template: _temp}),
@@ -930,7 +920,6 @@
   * @description 点击返回时,判断配置保存状态
   */
  cancelConfig = () => {
    const { menu } = this.props
    const { config, originMenu } = this.state
    let _this = this
@@ -946,31 +935,13 @@
        onCancel() {}
      })
    } else {
      this.menuformRef.handleConfirm().then(res => {
        let _config = {...config, easyCode: res.easyCode}
        let _pageParam = {...menu.PageParam, OpenType: res.opentype}
        let _originMenu = {
          ...originMenu,
          LongParam: _config,
          PageParam: _pageParam,
          MenuName: res.MenuName,
          MenuNo: res.MenuNo,
          ParentID: res.parentId,
          fstMenuId: res.fstMenuId
        }
        if (!is(fromJS(originMenu), fromJS(_originMenu))) {
      if (!is(fromJS(originMenu), fromJS(config))) {
          this.setState({
            closeVisible: true
          })
        } else {
          this.props.handleView()
        }
      }, () => {
        this.setState({
          closeVisible: true
        })
      })
    }
  }
@@ -988,26 +959,35 @@
        duration: 5
      })
    } else {
      this.menuformRef.handleConfirm().then(res => {
        let _config = {...config, easyCode: res.easyCode}
        let _pageParam = {...menu.PageParam, OpenType: res.opentype}
        let _originMenu = {
          ...originMenu,
          LongParam: _config,
          PageParam: _pageParam,
          MenuName: res.MenuName,
          MenuNo: res.MenuNo,
          ParentID: res.parentId,
          fstMenuId: res.fstMenuId
      // 基本信息验证
      if (!config.fstMenuId || !config.ParentId || !config.MenuName || !config.MenuNo) {
        notification.warning({
          top: 92,
          message: this.state.dict['model.menu.basemsg'],
          duration: 5
        })
        return
        }
        if (!is(fromJS(originMenu), fromJS(_originMenu))) { // 菜单信息变化时,提示保存
      if (!is(fromJS(originMenu), fromJS(config))) { // 菜单信息变化时,提示保存
          notification.warning({
            top: 92,
            message: this.state.dict['header.menu.config.update'],
            duration: 5
          })
          return
      }
      let submenu = menu.fstMenuList.filter(item => item.MenuID === config.fstMenuId)[0]
      let _Menu = {
        ...menu,
        LongParam: config,
        PageParam: {...menu.PageParam, Template: config.Template, OpenType: config.OpenType},
        MenuName: config.MenuName,
        MenuNo: config.MenuNo,
        ParentId: config.ParentId,
        fstMenuId: config.fstMenuId,
        supMenuList: submenu ? submenu.options : []
        }
        // 菜单信息验证通过后,跳转子配置页面
@@ -1031,12 +1011,12 @@
          isbutton = false
        }
        _originMenu.activeKey = activeKey       // 保存当前打开页签
        _originMenu.open_edition = openEdition  // 更新版本号
      _Menu.activeKey = activeKey       // 保存当前打开页签
      _Menu.open_edition = openEdition  // 更新版本号
        let param = {
          optionLibs: optionLibs,
          editMenu: _originMenu,
        editMenu: _Menu,
          editTab: !isbutton ? item : '',
          tabConfig: null,
          editSubTab: null,
@@ -1050,7 +1030,7 @@
        
        // 当子表使用主页搜索条件时,将主页搜索向下传递
        if (param.editTab && param.editTab.searchPass === 'true') {
          param.editTab.mainsearch = fromJS(_config.search).toJS()
        param.editTab.mainsearch = fromJS(config.search).toJS()
        }
        this.setState({
@@ -1102,13 +1082,6 @@
              duration: 5
            })
          }
        })
      }, () => {
        notification.warning({
          top: 92,
          message: this.state.dict['header.menu.config.update'],
          duration: 5
        })
      })
    }
  }
@@ -1301,6 +1274,7 @@
  }
  render () {
    const { menu } = this.props
    const { activeKey, config, chartview } = this.state
    const confActions = config.action.filter(_action => !_action.origin && ['pop', 'popview', 'blank', 'tab'].includes(_action.OpenType))
@@ -1320,9 +1294,10 @@
              <Panel forceRender={true} header={this.state.dict['header.menu.basedata']} key="0" id="main-basedata">
                {/* 菜单信息 */}
                <MenuForm
                  menu={menu}
                  config={config}
                  dict={this.state.dict}
                  formlist={this.state.menuformlist}
                  wrappedComponentRef={(inst) => this.menuformRef = inst}
                  updatemenu={this.updateconfig}
                />
                {/* 表名添加 */}
                <TableComponent
@@ -1429,12 +1404,11 @@
                type="main"
                config={config}
                MenuID={this.props.menu.MenuID}
                menuformRef={this.menuformRef}
                permFuncField={this.props.permFuncField}
                updatesetting={this.updateconfig}
              />
              <SearchComponent
                menu={{MenuID: this.props.menu.MenuID, MenuName: this.props.menu.MenuName}}
                menu={{MenuID: this.props.menu.MenuID, MenuName: config.MenuName}}
                config={config}
                pasteContent={this.state.pasteContent}
                sysRoles={this.props.sysRoles}
@@ -1457,10 +1431,9 @@
                        {config.charts.length > 1 && item.title ? <p className="chart-title">{item.title}</p> : null}
                        <ActionComponent
                          type="main"
                          menu={{ MenuID: this.props.menu.MenuID, MenuName: this.props.menu.MenuName, MenuNo: this.props.menu.MenuNo, fstMenuList: this.props.menu.fstMenuList }}
                          menu={{ MenuID: this.props.menu.MenuID, MenuName: config.MenuName, MenuNo: config.MenuNo, fstMenuList: this.props.menu.fstMenuList }}
                          config={config}
                          tabs={this.state.tabviews}
                          menuformRef={this.menuformRef}
                          pasteContent={this.state.pasteContent}
                          usefulFields={this.props.permFuncField}
                          setSubConfig={(_btn) => this.setSubConfig(_btn, 'button')}