king
2023-08-15 a94b0a4d15b26ecf8fe99f0a1c3e60d60b97766d
src/views/menudesign/index.jsx
@@ -10,7 +10,6 @@
import md5 from 'md5'
import Api from '@/api'
import options from '@/store/options.js'
import Utils, { setGLOBFuncs } from '@/utils/utils.js'
import antdZhCN from 'antd/es/locale/zh_CN'
import MKEmitter from '@/utils/events.js'
@@ -48,7 +47,6 @@
const StyleCombControlButton = asyncComponent(() => import('@/menu/stylecombcontrolbutton'))
const TableComponent = asyncComponent(() => import('@/templates/sharecomponent/tablecomponent'))
sessionStorage.setItem('isEditState', 'true')
sessionStorage.setItem('appType', '')          // 应用类型
document.body.className = ''
@@ -73,12 +71,27 @@
  }
  UNSAFE_componentWillMount() {
    if (sessionStorage.getItem('devError') === 'true') {
      sessionStorage.clear()
      window.history.replaceState(null, null, window.location.href.split('#')[0] + '#/login')
      window.location.reload()
      return
    }
    if (!sessionStorage.getItem('UserID')) {
      sessionStorage.removeItem('appType')
      this.props.history.replace('/login')
      return
    }
    sessionStorage.setItem('editMenuType', 'menu') // 编辑菜单类型
    window.GLOB.curDate = moment().format('YYYY-MM-DD')
    window.GLOB.UserComponentMap = new Map() // 缓存用户自定义组件
    window.GLOB.TabsMap = new Map()          // 缓存用户操作的标签页
    window.GLOB.urlFields = []               // url变量
    window.GLOB.customMenu = null            // 保存菜单信息
    window.GLOB.developing = true
    try {
      let param = JSON.parse(window.decodeURIComponent(window.atob(this.props.match.params.param)))
@@ -106,6 +119,8 @@
  }
  componentDidMount () {
    if (!sessionStorage.getItem('UserID')) return
    MKEmitter.addListener('changePopview', this.initPopview)
    MKEmitter.addListener('triggerMenuSave', this.triggerMenuSave)
    MKEmitter.addListener('updateCustomComponent', this.updateCustomComponent)
@@ -245,7 +260,7 @@
  
      param.open_key = Utils.encryptOpenKey(param.secretkey, param.timestamp) // 云端数据验证
  
      Api.getSystemConfig(param).then(res => {
      Api.getCloudConfig(param).then(res => {
        if (res.status) {
          let temps = res.data.map(temp => {
            return {
@@ -278,19 +293,19 @@
    }
    deffers = [new Promise(resolve => {
      setTimeout(() => {
        Api.getSystemConfig({...param, typecharone: 'image'}).then(res => {
        Api.getCloudConfig({...param, typecharone: 'image'}).then(res => {
          resolve(res.data)
        })
      }, 500)
    }), new Promise(resolve => {
      setTimeout(() => {
        Api.getSystemConfig({...param, typecharone: 'video'}).then(res => {
        Api.getCloudConfig({...param, typecharone: 'video'}).then(res => {
          resolve(res.data)
        })
      }, 1000)
    }), new Promise(resolve => {
      setTimeout(() => {
        Api.getSystemConfig({...param, typecharone: 'color'}).then(res => {
        Api.getCloudConfig({...param, typecharone: 'color'}).then(res => {
          resolve(res.data)
        })
      }, 1500)
@@ -304,7 +319,7 @@
  }
  updateCustomComponent = () => {
    Api.getSystemConfig({
    Api.getCloudConfig({
      func: 's_get_custom_components',
      typename: '',
      typecharone: ''
@@ -420,7 +435,7 @@
      MenuID: MenuId
    }
    Api.getSystemConfig(param).then(result => {
    Api.getCloudConfig(param).then(result => {
      if (result.status) {
        let config = null
@@ -633,6 +648,8 @@
        comloading: false,
        needUpdate: true
      })
      window.GLOB.customMenu = config
      return
    }
@@ -644,7 +661,7 @@
        }
    
        setTimeout(() => {
          Api.getSystemConfig(param).then(res => {
          Api.getCloudConfig(param).then(res => {
            let _config = null
            try {
              _config = res.LongParam ? JSON.parse(window.decodeURIComponent(window.atob(res.LongParam))) : null
@@ -711,6 +728,8 @@
      config.components = this.setPopView(config.components, parents, popbtns)
      this.setState({ delButtons: bts, config, comloading: false })
      window.GLOB.customMenu = config
    })
  }
@@ -798,7 +817,7 @@
  checkBase = () => {
    const { MenuType, config } = this.state
    if (MenuType === 'billPrint' && config.printPage === 'page' && !config.everyPCount) {
    if (MenuType === 'billPrint' && ((config.printPage === 'page' && !config.everyPCount) || (config.callback === 'true' && !config.callNo))) {
      return false
    } else if (MenuType === 'home' && (config.cacheUseful === 'true' && !config.cacheTime)) {
      return false
@@ -853,8 +872,6 @@
    this.setState({
      menuloading: true
    })
    window.GLOB.saving = true
    setTimeout(() => {
      let _pass = this.verifyConfig(config)
@@ -947,15 +964,15 @@
              Base64Img: canvas.toDataURL('image/png') // 获取生成的图片
            }
  
            if (options.cloudServiceApi) {
              param.rduri = options.cloudServiceApi
            if (window.GLOB.cloudServiceApi) {
              param.rduri = window.GLOB.cloudServiceApi
              param.userid = sessionStorage.getItem('CloudUserID') || ''
              param.LoginUID = sessionStorage.getItem('CloudLoginUID') || ''
            }
  
            Api.fileuploadbase64(param).then(result => {
              if (result.status) {
                Api.getSystemConfig({
                Api.getCloudConfig({
                  func: 's_PrintTemplateMSub',
                  ID: config.uuid,
                  Images: Utils.getcloudurl(result.Images),
@@ -975,7 +992,7 @@
      }).then(res => { // 页面保存
        if (!res || !res.status) return res
        return Api.getSystemConfig(param)
        return Api.getCloudConfig(param)
      }).then(res => { // 按钮删除
        if (!res || !res.status) return res
@@ -998,7 +1015,7 @@
            func: 'sPC_MainMenu_Del',
            MenuID: this.state.delButtons.join(',')
          }
          return Api.getSystemConfig(_param)
          return Api.getCloudConfig(_param)
        }
      }, this.netError).then(res => { // 页面按钮关系保存
        if (!res || !res.status) return res
@@ -1008,7 +1025,7 @@
        })
        if (MenuType !== 'billPrint') {
          return Api.getSystemConfig(btnParam)
          return Api.getCloudConfig(btnParam)
        } else {
          return {
            status: true
@@ -1019,8 +1036,6 @@
          menuloading: false
        })
        window.GLOB.saving = false
        if (!res) return
        if (res.status) {
@@ -1029,7 +1044,6 @@
            message: '保存成功',
            duration: 2
          })
          MKEmitter.emit('completeSave')
        } else {
          notification.warning({
            top: 92,
@@ -1037,6 +1051,7 @@
            duration: 5
          })
        }
        MKEmitter.emit('completeSave')
      }, this.netError)
    }, 300 + (+sessionStorage.getItem('mkDelay')))
  }
@@ -1046,8 +1061,6 @@
      menuloading: false
    })
    window.GLOB.saving = false
    if (!error) {
      notification.warning({
        top: 92,
@@ -1055,12 +1068,13 @@
        duration: 5
      })
    }
    MKEmitter.emit('completeSave')
  }
  getRoleFields = () => {
    if (sessionStorage.getItem('sysRoles')) return
    Api.getSystemConfig({func: 'sPC_Get_Roles_sModular'}).then(res => {
    Api.getCloudConfig({func: 'sPC_Get_Roles_sModular'}).then(res => {
      if (res.status) {
        let _permFuncField = []
        let _sysRoles = []