king
2020-12-23 e9640ccdc9fe57f91919e3f51462c780e44fadb0
src/views/menudesign/index.jsx
@@ -13,6 +13,7 @@
import enUS from '@/locales/en-US/mob.js'
import antdEnUS from 'antd/es/locale/en_US'
import antdZhCN from 'antd/es/locale/zh_CN'
import MKEmitter from '@/utils/events.js'
import asyncComponent from '@/utils/asyncComponent'
import { modifyCustomMenu } from '@/store/action'
@@ -32,10 +33,10 @@
const PaddingController = asyncComponent(() => import('@/menu/padcontroller'))
const StyleController = asyncComponent(() => import('@/menu/stylecontroller'))
const ModalController = asyncComponent(() => import('@/menu/modalconfig/controller'))
const PopviewController = asyncComponent(() => import('@/menu/popview/controller'))
const TableComponent = asyncComponent(() => import('@/templates/sharecomponent/tablecomponent'))
sessionStorage.setItem('isEditState', 'true')
sessionStorage.setItem('delButtons', JSON.stringify([]))
class MenuDesign extends Component {
  state = {
@@ -46,6 +47,7 @@
    MenuName: '',
    MenuNo: '',
    tableFields: [],
    delButtons: [],
    activeKey: 'basedata',
    menuloading: false,
    oriConfig: null,
@@ -79,6 +81,10 @@
    return !is(fromJS(this.state), fromJS(nextState))
  }
  componentDidMount () {
    MKEmitter.addListener('delButtons', this.delButtons)
  }
  /**
   * @description 组件销毁,清除state更新
   */
@@ -86,6 +92,11 @@
    this.setState = () => {
      return
    }
    MKEmitter.removeListener('delButtons', this.delButtons)
  }
  delButtons = (items) => {
    this.setState({delButtons: [...this.state.delButtons, ...items]})
  }
  closeView = () => {
@@ -149,7 +160,6 @@
              backgroundColor: '#ffffff', backgroundImage: '',
              paddingTop: '16px', paddingBottom: '80px', paddingLeft: '16px', paddingRight: '16px'
            },
            MenuType: MenuType
          }
          if (MenuType === 'billPrint') {
            config.style.paddingTop = '50px'
@@ -160,7 +170,6 @@
        } else {
          config.uuid = MenuId
          config.MenuID = MenuId
          config.MenuType = config.MenuType || MenuType
        }
        if (MenuType === 'billPrint') {
@@ -263,24 +272,24 @@
  }
  submitConfig = () => {
    const { openEdition } = this.state
    const { openEdition, MenuType, delButtons } = this.state
    let config = fromJS(this.state.config).toJS()
    if (config.MenuType === 'billPrint' && (!config.firstCount || !config.everyPCount)) {
    if (MenuType === 'billPrint' && (!config.firstCount || !config.everyPCount)) {
      notification.warning({
        top: 92,
        message: '请完善基本信息!',
        duration: 5
      })
      return
    } else if (config.MenuType === 'home' && (config.cacheUseful === 'true' && !config.cacheTime)) {
    } else if (MenuType === 'home' && (config.cacheUseful === 'true' && !config.cacheTime)) {
      notification.warning({
        top: 92,
        message: '请完善菜单基本信息!',
        duration: 5
      })
      return
    } else if (config.MenuType === 'custom' && (!config.MenuName || !config.MenuNo || !config.fstMenuId || !config.parentId || (config.cacheUseful === 'true' && !config.cacheTime))) {
    } else if (MenuType === 'custom' && (!config.MenuName || !config.MenuNo || !config.fstMenuId || !config.parentId || (config.cacheUseful === 'true' && !config.cacheTime))) {
      notification.warning({
        top: 92,
        message: '请完善菜单基本信息!',
@@ -333,7 +342,7 @@
      LText: []
    }
    if (config.MenuType !== 'billPrint') {
    if (MenuType !== 'billPrint') {
      btnParam.LText = this.getMenuMessage()
      btnParam.LText = btnParam.LText.join(' union all ')
      btnParam.LText = Utils.formatOptions(btnParam.LText)
@@ -347,7 +356,7 @@
      menuloading: true
    }, () => {
      new Promise(resolve => {
        if (config.MenuType === 'billPrint') {
        if (MenuType === 'billPrint') {
          html2canvas(document.getElementById('menu-shell-inner')).then(canvas => {
            let img = canvas.toDataURL('image/png') // 获取生成的图片
            Api.fileuploadbase64(img, 'cloud').then(result => {
@@ -392,7 +401,36 @@
      }).then(res => {
        if (!res) return
        return Api.getSystemConfig(param)
        if (delButtons.length === 0) {
          return {
            status: true
          }
        } else {
          let _param = {
            func: 'sPC_MainMenu_Del',
            MenuID: delButtons.join(',')
          }
          return Api.getSystemConfig(_param)
        }
      }).then(res => {
        if (!res) return
        if (res.status) {
          this.setState({
            delButtons: []
          })
          return Api.getSystemConfig(param)
        } else {
          this.setState({
            menuloading: false
          })
          notification.warning({
            top: 92,
            message: res.message,
            duration: 5
          })
          return false
        }
      }).then(res => {
        if (!res) return
@@ -495,7 +533,7 @@
  }
  verifyConfig = (show) => {
    const { config } = this.state
    const { config, MenuType } = this.state
    let error = ''
    config.components.forEach(item => {
@@ -507,7 +545,7 @@
          error = `组件《${item.name}》未设置数据源!`
        } else if (item.setting.interType === 'system' && item.setting.execute === 'false' && item.scripts.length === 0) {
          error = `组件《${item.name}》未设置数据源!`
        } else if (item.setting.interType && !item.setting.primaryKey && config.MenuType !== 'billPrint') {
        } else if (item.setting.interType && !item.setting.primaryKey && MenuType !== 'billPrint') {
          error = `组件《${item.name}》未设置主键!`
        }
      }
@@ -619,6 +657,7 @@
          </DndProvider>
          <StyleController />
          <ModalController />
          <PopviewController />
        </div>
      </ConfigProvider>
    )