king
2020-08-22 835b48025a582b1c19c4de128906aff6a5e63612
src/templates/calendarconfig/index.jsx
@@ -11,12 +11,11 @@
import zhCN from '@/locales/zh-CN/model.js'
import enUS from '@/locales/en-US/model.js'
import Utils from '@/utils/utils.js'
import { getMainMenuForm } from '@/templates/zshare/formconfig'
import asyncComponent from '@/utils/asyncComponent'
import SearchComponent from '@/templates/sharecomponent/searchcomponent'
import MenuForm from '@/templates/zshare/menuform'
import MenuForm from '@/templates/comtableconfig/menuform'
// import EditComponent from '@/templates/zshare/editcomponent'
import SourceElement from '@/templates/zshare/dragsource'
import Source from './source'
@@ -46,7 +45,6 @@
    visible: false,          // 搜索条件、按钮、显示列,模态框显示控制
    tableFields: [],         // 已选表字段集
    fields: null,            // 搜索条件及显示列,可选字段
    menuformlist: null,      // 基本信息表单字段
    formlist: null,          // 搜索条件、按钮、显示列表单字段
    menuloading: false,      // 菜单保存中
    menucloseloading: false, // 菜单关闭时,选择保存
@@ -99,13 +97,19 @@
      }
    }
    // 页面配置中保留菜单信息,只用于数据传递
    _config.ParentId = menu.ParentId
    _config.fstMenuId = menu.fstMenuId
    _config.MenuName = menu.MenuName || ''
    _config.MenuNo = menu.MenuNo || ''
    _config.OpenType = menu.PageParam ? menu.PageParam.OpenType : ''
    this.setState({
      openEdition: menu.open_edition || '',
      optionLibs: optionLibs,
      activeKey: menu.activeKey || '0',
      config: _config,
      originMenu: fromJS(menu).toJS(),
      menuformlist: getMainMenuForm(menu, _config),
      originMenu: fromJS(_config).toJS(),
      mockdata: this.getMockData(moment().format('YYYY'))
    })
  }
@@ -267,24 +271,29 @@
   */
  submitConfig = () => {
    const { menu } = this.props
    const { originMenu, openEdition } = this.state
    const { 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)
    // 基本信息验证
    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
        if (config.tab && !config.tab.linkTab) {
          config.tab.linkTab = Utils.getuuid()
        }
    if (_config.isAdd) {
      _config.search = _config.search.filter(item => !item.origin)
      }
      let _LongParam = ''
      let _config = {...config, easyCode: res.easyCode}
      let _pageParam = {...menu.PageParam, OpenType: res.opentype}
    if (_config.type === 'user') { // 使用已有菜单时,默认添加关联标签id
      if (_config.tab && !_config.tab.linkTab) {
        _config.tab.linkTab = Utils.getuuid()
      }
    }
      // 未设置数据源或标签不合法时,启用状态为false
      let vresult = this.verifyconfig(_config)
@@ -358,6 +367,8 @@
        delete _config.type
        delete _config.isAdd
  
      let _LongParam = ''
        try {
          _LongParam = window.btoa(window.encodeURIComponent(JSON.stringify(_config)))
        } catch (e) {
@@ -392,15 +403,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`)
@@ -426,25 +437,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()
@@ -500,19 +496,10 @@
          }
        })
      })
    }, () => {
      notification.warning({
        top: 92,
        message: this.state.dict['model.menu.basemsg'],
        duration: 5
      })
    })
  }
  cancelConfig = () => {
    const { menu } = this.props
    const { config, originMenu } = this.state
    let _this = this
    if (config.isAdd) {
@@ -526,31 +513,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
        })
      })
    }
  }
@@ -568,20 +537,17 @@
        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'],
@@ -590,13 +556,25 @@
          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 : []
      }
        // 菜单信息验证通过后,跳转子配置页面
        _originMenu.activeKey = activeKey       // 保存当前打开页签
        _originMenu.open_edition = openEdition  // 更新版本号
      _Menu.activeKey = activeKey       // 保存当前打开页签
      _Menu.open_edition = openEdition  // 更新版本号
        let param = {
          optionLibs: optionLibs,
          editMenu: _originMenu,
        editMenu: _Menu,
          editTab: fromJS(config.tab).toJS(),
          tabConfig: null,
          editSubTab: null,
@@ -610,7 +588,7 @@
        
        // 当子表使用主页搜索条件时,将主页搜索向下传递
        if (param.editTab && param.editTab.searchPass === 'true') {
          param.editTab.mainsearch = fromJS(_config.search).toJS()
        param.editTab.mainsearch = fromJS(config.search).toJS()
        }
        this.setState({
@@ -655,13 +633,6 @@
            })
          }
        })
      }, () => {
        notification.warning({
          top: 92,
          message: this.state.dict['header.menu.config.update'],
          duration: 5
        })
      })
    }
  }
@@ -692,15 +663,11 @@
   * @description 校验配置信息的合法性
   */
  verifyconfig = (config) => {
    // let hasKey = false
    let cols = []
    config.columns.forEach(col => {
      if (col.field) {
        cols.push(col.field)
      }
      // if (config.setting.primaryKey === col.field) {
      //   hasKey = true
      // }
    })
    let calvaild = true
@@ -716,10 +683,6 @@
    if (config.setting.interType === 'inner' && !config.setting.innerFunc && config.setting.default !== 'false' && !config.setting.dataresource) {
      return '菜单尚未设置数据源,不可启用!'
    // } else if (!config.setting.primaryKey) {
    //   return '菜单尚未设置主键,不可启用!'
    // } else if (!hasKey) {
    //   return '显示列中不存在主键字段,不可启用!'
    } else if (!calvaild) {
      return '日历关联字段未设置,不可启用!'
    } else {
@@ -787,6 +750,7 @@
  }
  render () {
    const { menu } = this.props
    const { activeKey, config, tabviews, mockdata } = this.state
    return (
@@ -799,9 +763,10 @@
              <Panel forceRender={true} header={'标签基本信息'} key="0" id="subtable-basedata">
                {/* 菜单信息 */}
                <MenuForm
                  menu={menu}
                  config={config}
                  dict={this.state.dict}
                  formlist={this.state.menuformlist}
                  wrappedComponentRef={(inst) => this.menuformRef = inst}
                  updatemenu={this.updateconfig}
                />
                {/* 表名添加 */}
                <TableComponent
@@ -842,14 +807,13 @@
            } style={{ width: '100%' }}>
              <SettingComponent
                config={config}
                MenuID={config.uuid}
                menuformRef={this.menuformRef}
                MenuID={menu.MenuID}
                tableFields={this.state.tableFields}
                permFuncField={this.props.permFuncField}
                updateConfig={this.updateconfig}
              />
              <SearchComponent
                menu={{MenuID: config.uuid, MenuName: config.tabName}}
                menu={{MenuID: menu.MenuID, MenuName: config.MenuName}}
                config={config}
                pasteContent={this.state.pasteContent}
                sysRoles={this.props.sysRoles}