king
2020-11-13 8190d6e5ac14616d85e3992169ecef6d99d03b76
src/views/menudesign/index.jsx
@@ -90,7 +90,13 @@
  closeView = () => {
    const { oriConfig, config } = this.state
    if (!is(fromJS(oriConfig), fromJS(config))) {
    let _config = fromJS(config).toJS()
    delete _config.fstMenuList
    delete _config.permFuncField
    delete _config.sysRoles
    delete _config.tableFields
    if (!is(fromJS(oriConfig), fromJS(_config))) {
      confirm({
        title: '配置已修改,放弃保存吗?',
        content: '',
@@ -104,10 +110,87 @@
    }
  }
  getMenuParam = () => {
    const { MenuId, ParentId, MenuName, MenuNo, MenuType } = this.state
    let param = {
      func: 'sPC_Get_LongParam',
      MenuID: MenuId
    }
    Api.getSystemConfig(param).then(result => {
      if (result.status) {
        let config = null
        try {
          config = JSON.parse(window.decodeURIComponent(window.atob(result.LongParam)))
        } catch (e) {
          console.warn('Parse Failure')
          config = null
        }
        if (!config) {
          config = {
            version: 1.0,
            uuid: MenuId,
            MenuID: MenuId,
            parentId: ParentId,
            Template: 'CustomPage',
            easyCode: '',
            enabled: false,
            MenuName: MenuName,
            MenuNo: MenuNo,
            tables: [],
            components: [],
            style: {
              backgroundColor: '#ffffff', backgroundImage: '',
              paddingTop: '16px', paddingBottom: '80px', paddingLeft: '16px', paddingRight: '16px'
            },
            MenuType: MenuType
          }
          if (MenuType === 'billPrint') {
            config.style.paddingTop = '50px'
            config.style.paddingBottom = '50px'
            config.style.paddingLeft = '30px'
            config.style.paddingRight = '30px'
          }
        } else {
          config.uuid = MenuId
          config.MenuID = MenuId
          config.MenuType = config.MenuType || MenuType
        }
        if (MenuType === 'billPrint') {
          config.fstMenuId = 'BillPrintTemp'
          config.parentId = 'BillPrintTemp'
          config.MenuName = MenuName
          config.MenuNo = MenuNo
          config.firstCount = config.firstCount || 5
          config.everyPCount = config.everyPCount || 5
          config.lastCount = config.lastCount || ''
        }
        this.setState({
          oriConfig: config,
          config: fromJS(config).toJS(),
          openEdition: result.open_edition || '',
        })
        this.getRoleFields()
      } else {
        notification.warning({
          top: 92,
          message: result.message,
          duration: 5
        })
      }
    })
  }
  submitConfig = () => {
    const { config, openEdition } = this.state
    if (config.MenuType === 'billPrint' && (!config.MenuName || !config.MenuNo)) {
    if (config.MenuType === 'billPrint' && (!config.firstCount || !config.everyPCount)) {
      notification.warning({
        top: 92,
        message: '请完善基本信息!',
@@ -249,76 +332,6 @@
    })
  }
  getMenuParam = () => {
    const { MenuId, ParentId, MenuName, MenuNo, MenuType } = this.state
    let param = {
      func: 'sPC_Get_LongParam',
      MenuID: MenuId
    }
    Api.getSystemConfig(param).then(result => {
      if (result.status) {
        let config = null
        try {
          config = JSON.parse(window.decodeURIComponent(window.atob(result.LongParam)))
        } catch (e) {
          console.warn('Parse Failure')
          config = null
        }
        if (!config) {
          config = {
            version: 1.0,
            uuid: MenuId,
            MenuID: MenuId,
            parentId: ParentId,
            Template: 'CustomPage',
            easyCode: '',
            enabled: false,
            MenuName: MenuName,
            MenuNo: MenuNo,
            tables: [],
            components: [],
            style: {
              backgroundColor: '#ffffff', backgroundImage: '',
              paddingTop: '16px', paddingBottom: '80px', paddingLeft: '16px', paddingRight: '16px'
            },
            MenuType: MenuType
          }
        } else {
          config.uuid = MenuId
          config.MenuID = MenuId
          config.MenuType = config.MenuType || MenuType
        }
        if (MenuType === 'billPrint') {
          config.FstID = 'BillPrintTemp'
          config.SndID = 'BillPrintTemp'
          config.ParentID = 'BillPrintTemp'
          config.firstCount = config.firstCount || 5
          config.everyPCount = config.everyPCount || 5
          config.lastCount = config.lastCount || ''
        }
        this.setState({
          oriConfig: config,
          config: fromJS(config).toJS(),
          openEdition: result.open_edition || '',
        })
        this.getRoleFields()
      } else {
        notification.warning({
          top: 92,
          message: result.message,
          duration: 5
        })
      }
    })
  }
  getRoleFields = () => {
    Api.getSystemConfig({func: 'sPC_Get_Roles_sModular'}).then(res => {
      if (res.status) {
@@ -374,22 +387,6 @@
  verifyConfig = (show) => {
    const { config } = this.state
    let error = ''
    if (!config.MenuID) {
      notification.warning({
        top: 92,
        message: '请完善菜单基本信息!',
        duration: 5
      })
      return
    } else if (config.MenuType === 'custom' && (!config.MenuName || !config.MenuNo || !config.fstMenuId || !config.parentId)) {
      notification.warning({
        top: 92,
        message: '请完善菜单基本信息!',
        duration: 5
      })
      return
    }
    config.components.forEach(item => {
      if (error) return
@@ -453,7 +450,7 @@
    return (
      <ConfigProvider locale={_locale}>
        <div className="pc-menu-view" id="view">
          <Header view="design" closeView={this.closeView} />
          <Header />
          <DndProvider backend={HTML5Backend}>
            <div className="menu-body">
              <div className="menu-setting">
@@ -498,6 +495,7 @@
                  <div>
                    {config ? <Switch className="big" checkedChildren={dict['mob.enable']} unCheckedChildren={dict['mob.disable']} checked={config.enabled} onChange={this.onEnabledChange} /> : null}
                    <Button type="primary" onClick={this.submitConfig} loading={menuloading}>{dict['mob.save']}</Button>
                    <Button type="default" onClick={this.closeView}>{dict['mob.return']}</Button>
                  </div>
                } style={{ width: '100%' }}>
                  {config && config.components ? <MenuShell menu={config} handleList={this.updateConfig} /> : null}