king
2024-08-25 ae170a9d58b4f91a225eada1dc83ed4a116b8d50
src/views/pcdesign/index.jsx
@@ -3,15 +3,14 @@
import { withRouter } from 'react-router'
import { is, fromJS } from 'immutable'
import HTML5Backend from 'react-dnd-html5-backend'
import { ConfigProvider, notification, Modal, Collapse, Switch, Button, message, Spin, Typography } from 'antd'
import { notification, Modal, Collapse, Switch, Button, message, Spin, Typography } from 'antd'
import { DoubleLeftOutlined, DoubleRightOutlined, HomeOutlined, LoginOutlined, ArrowLeftOutlined, EyeOutlined, EyeInvisibleOutlined } from '@ant-design/icons'
import moment from 'moment'
import md5 from 'md5'
import Api from '@/api'
import Utils, { setGLOBFuncs } from '@/utils/utils.js'
import { getTables, getFuncsAndInters } from '@/utils/utils-custom.js'
import antdZhCN from 'antd/es/locale/zh_CN'
import Utils from '@/utils/utils.js'
import { getTables, getFuncsAndInters, getLangTrans } from '@/utils/utils-custom.js'
import MKEmitter from '@/utils/events.js'
import MenuUtils from '@/utils/utils-custom.js'
import asyncComponent from '@/utils/asyncComponent'
@@ -69,7 +68,9 @@
    eyeopen: false,
    view: '',
    popConfig: null,
    needUpdate: false
    needUpdate: false,
    appLoginId: '',
    appHomeId: ''
  }
  UNSAFE_componentWillMount() {
@@ -100,17 +101,49 @@
    try {
      let param = JSON.parse(window.decodeURIComponent(window.atob(this.props.match.params.param)))
      if (param.lang) {
        sessionStorage.setItem('lang', param.lang)
      }
      if (param.type === 'app') {
        sessionStorage.setItem('appId', param.ID || '')
        sessionStorage.setItem('appName', param.remark || '')
        sessionStorage.setItem('lang', param.lang || 'zh-CN')
        sessionStorage.setItem('kei_no', param.kei_no || '')
        sessionStorage.setItem('sysBgColor', param.sysBgColor || '#ffffff')
        if (param.applangList) {
          sessionStorage.setItem('applangList', param.applangList)
        } else {
          sessionStorage.removeItem('applangList')
        }
        if (param.wxAppId) {
          sessionStorage.setItem('wxAppId', param.wxAppId)
        }
        this.getAppMessage(param.MenuID)
      } else if (param.type === 'view') {
        let appLoginId = ''
        let appHomeId = ''
        if (sessionStorage.getItem('appViewList')) {
          try {
            let appMenus = JSON.parse(sessionStorage.getItem('appViewList'))
            appMenus.forEach(item => {
              if (item.keys_type === 'login') {
                appLoginId = item.keys_id
              } else if (item.keys_type === 'index') {
                appHomeId = item.keys_id
              }
            })
          } catch (e) {
          }
        }
        this.setState({
          MenuId: param.MenuID
          MenuId: param.MenuID,
          appLoginId: appLoginId,
          appHomeId: appHomeId
        }, () => {
          this.getMenuParam(param)
        })
@@ -144,9 +177,13 @@
    MKEmitter.addListener('changeEditMenu', this.changeEditMenu)
    MKEmitter.addListener('triggerMenuSave', this.triggerMenuSave)
    if (sessionStorage.getItem('wxAppId')) {
      window.GLOB.WXAppID = sessionStorage.getItem('wxAppId')
    }
    setTimeout(() => {
      this.getRoleFields()
      setGLOBFuncs()
      // setGLOBFuncs()
    }, 1000)
    document.onkeydown = (event) => {
@@ -240,7 +277,8 @@
      MenuID: menu.MenuID,
      copyMenuId: menu.copyMenuId || '',
      clearMenu: menu.clearMenu !== 'false',
      type: 'view'
      type: 'view',
      lang: sessionStorage.getItem('lang')
    }
    // param.MenuNo = menu.MenuNo || ''
@@ -287,7 +325,7 @@
        let param = {
          func: 's_kei_link_keyids_addupt',
          BID: sessionStorage.getItem('appId'),
          exec_type: 'y',
          exec_type: 'x',
          LText: ''
        }
@@ -302,7 +340,7 @@
        param.LText = appViewList.map(item => `select '${item.keys_id}','${item.keys_type}','${item.kei_no}','${item.appkey}','${item.bid}','${sessionStorage.getItem('CloudUserID')}','${item.remark}'`)
        param.LText = param.LText.join(' union all ')
        param.LText = Utils.formatOptions(param.LText)
        param.LText = Utils.formatOptions(param.LText, 'x')
  
        param.timestamp = moment().format('YYYY-MM-DD HH:mm:ss')
        param.secretkey = Utils.encrypt('', param.timestamp)
@@ -316,12 +354,12 @@
            })
          } else {
            sessionStorage.setItem('appViewList', JSON.stringify(appViewList))
            this.props.history.replace('/pcdesign/' + window.btoa(window.encodeURIComponent(JSON.stringify({MenuID: homeId, type: 'view'}))))
            this.props.history.replace('/pcdesign/' + window.btoa(window.encodeURIComponent(JSON.stringify({MenuID: homeId, type: 'view', lang: sessionStorage.getItem('lang')}))))
          }
        })
      } else {
        sessionStorage.setItem('appViewList', JSON.stringify(appViewList))
        this.props.history.replace('/pcdesign/' + window.btoa(window.encodeURIComponent(JSON.stringify({MenuID: MenuID || homeId, type: 'view'}))))
        this.props.history.replace('/pcdesign/' + window.btoa(window.encodeURIComponent(JSON.stringify({MenuID: MenuID || homeId, type: 'view', lang: sessionStorage.getItem('lang')}))))
      }
    })
  }
@@ -877,7 +915,7 @@
          return
        } else if (item.type === 'card' || item.type === 'carousel' || item.type === 'timeline') {
          item.action && item.action.forEach(btn => {
            if (btn.hidden === 'true') return
            if (btn.hidden === 'true' || btn.permission === 'false') return
            m.children.push({
              key: btn.uuid,
@@ -886,7 +924,7 @@
          })
          item.subcards.forEach(card => {
            card.elements && card.elements.forEach(cell => {
              if (cell.eleType !== 'button' || cell.hidden === 'true') return
              if (cell.eleType !== 'button' || cell.hidden === 'true' || cell.permission === 'false') return
              m.children.push({
                key: cell.uuid,
@@ -895,7 +933,7 @@
            })
            card.backElements && card.backElements.forEach(cell => {
              if (cell.eleType !== 'button' || cell.hidden === 'true') return
              if (cell.eleType !== 'button' || cell.hidden === 'true' || cell.permission === 'false') return
              m.children.push({
                key: cell.uuid,
@@ -905,7 +943,7 @@
          })
        } else if (item.type === 'balcony') {
          item.elements && item.elements.forEach(cell => {
            if (cell.eleType !== 'button' || cell.hidden === 'true') return
            if (cell.eleType !== 'button' || cell.hidden === 'true' || cell.permission === 'false') return
            m.children.push({
              key: cell.uuid,
@@ -923,7 +961,7 @@
          }
        } else if (item.type === 'table') {
          item.action.forEach(btn => {
            if (btn.hidden === 'true') return
            if (btn.hidden === 'true' || btn.permission === 'false') return
            m.children.push({
              key: btn.uuid,
@@ -936,7 +974,7 @@
                loopCol(col.subcols)
              } else if (col.type === 'custom') {
                col.elements.forEach(cell => {
                  if (cell.eleType !== 'button' || cell.hidden === 'true') return
                  if (cell.eleType !== 'button' || cell.hidden === 'true' || cell.permission === 'false') return
                  m.children.push({
                    key: cell.uuid,
                    title: cell.label,
@@ -1140,6 +1178,18 @@
    if (!this.checkBase()) {
      return
    } else if (this.checklog()) {
      if (sessionStorage.getItem('applangList') && !config.trans) {
      } else {
        notification.success({
          top: 92,
          message: '当前配置未修改,无需保存。',
          duration: 5
        })
        MKEmitter.emit('completeSave')
        return
      }
    }
    this.setState({
@@ -1208,6 +1258,7 @@
      let interfaces = getFuncsAndInters(config)
      roleParam.interfaces = interfaces
      let langSql = getLangTrans(config)
      let param = {
        func: 'sPC_TrdMenu_AddUpt',
@@ -1224,12 +1275,16 @@
        PageParam: JSON.stringify({Template: 'webPage', interfaces}),
        menus_rolelist: window.btoa(window.encodeURIComponent(JSON.stringify(roleParam))),
        open_edition: config.open_edition,
        LText: '',
        LTexttb: '',
        // LText: '',
        // LTexttb: '',
        menus_used_list,
        debug_md5: key,
        debug_url: url,
        debug_list: window.btoa(tbs)
      }
      if (langSql) {
        param.lang_translation = window.btoa(window.encodeURIComponent(langSql))
      }
      param.timestamp = moment().format('YYYY-MM-DD HH:mm:ss')
@@ -1310,8 +1365,8 @@
              PageParam: JSON.stringify({Template: NavBar.type}),
              menus_rolelist: window.btoa(window.encodeURIComponent(JSON.stringify(roles))),
              open_edition: NavBar.open_edition,
              LText: '',
              LTexttb: ''
              // LText: '',
              // LTexttb: ''
            }
            _param.LongParam = window.btoa(window.encodeURIComponent(JSON.stringify(NavBar)))
@@ -1352,13 +1407,13 @@
                  let kparam = {
                    func: 's_kei_link_keyids_addupt',
                    BID: sessionStorage.getItem('appId'),
                    exec_type: 'y',
                    exec_type: 'x',
                    LText: ''
                  }
        
                  kparam.LText = _appViewList.map(item => `select '${item.keys_id}','${item.keys_type}','${item.kei_no}','${item.appkey}','${item.bid}','${sessionStorage.getItem('CloudUserID')}','${item.remark}'`)
                  kparam.LText = kparam.LText.join(' union all ')
                  kparam.LText = Utils.formatOptions(kparam.LText)
                  kparam.LText = Utils.formatOptions(kparam.LText, 'x')
            
                  kparam.timestamp = moment().format('YYYY-MM-DD HH:mm:ss')
                  kparam.secretkey = Utils.encrypt('', kparam.timestamp)
@@ -1550,12 +1605,6 @@
    this.setState({config})
    window.GLOB.customMenu = config
    notification.success({
      top: 92,
      message: '粘贴成功!',
      duration: 2
    })
  }
  setHomeView = () => {
@@ -1573,7 +1622,7 @@
    let param = {
      func: 's_kei_link_keyids_addupt',
      BID: sessionStorage.getItem('appId'),
      exec_type: 'y',
      exec_type: 'x',
      LText: ''
    }
@@ -1592,10 +1641,12 @@
    param.LText = appViewList.map(item => `select '${item.keys_id}','${item.keys_type}','${item.kei_no}','${item.appkey}','${item.bid}','${sessionStorage.getItem('CloudUserID')}','${item.remark}'`)
    param.LText = param.LText.join(' union all ')
    param.LText = Utils.formatOptions(param.LText)
    param.LText = Utils.formatOptions(param.LText, 'x')
    param.timestamp = moment().format('YYYY-MM-DD HH:mm:ss')
    param.secretkey = Utils.encrypt('', param.timestamp)
    const that = this
    confirm({
      title: '确定设置本页面为首页吗?',
@@ -1610,6 +1661,10 @@
            })
          } else {
            sessionStorage.setItem('appViewList', JSON.stringify(appViewList))
            that.setState({
              appHomeId: config.MenuID
            })
          }
        })
      },
@@ -1632,7 +1687,7 @@
    let param = {
      func: 's_kei_link_keyids_addupt',
      BID: sessionStorage.getItem('appId'),
      exec_type: 'y',
      exec_type: 'x',
      LText: ''
    }
@@ -1651,12 +1706,13 @@
    param.LText = appViewList.map(item => `select '${item.keys_id}','${item.keys_type}','${item.kei_no}','${item.appkey}','${item.bid}','${sessionStorage.getItem('CloudUserID')}','${item.remark}'`)
    param.LText = param.LText.join(' union all ')
    param.LText = Utils.formatOptions(param.LText)
    param.LText = Utils.formatOptions(param.LText, 'x')
    param.timestamp = moment().format('YYYY-MM-DD HH:mm:ss')
    param.secretkey = Utils.encrypt('', param.timestamp)
    let hasLogin = config.components.findIndex(item => item.type === 'login') > -1
    const that = this
    confirm({
      title: '确定设置本页面为登录页吗?',
@@ -1671,6 +1727,10 @@
            })
          } else {
            sessionStorage.setItem('appViewList', JSON.stringify(appViewList))
            that.setState({
              appLoginId: config.MenuID
            })
          }
        })
      },
@@ -1685,6 +1745,8 @@
  }
  updateLogConfig = (config) => {
    config.open_edition = this.state.config.open_edition || ''
    this.setState({
      config: null
    }, () => {
@@ -1697,10 +1759,10 @@
  }
  render () {
    const { view, loading, comloading, activeKey, settingshow, controlshow, MenuId, config, menuloading, eyeopen, needUpdate } = this.state
    const { view, loading, comloading, activeKey, settingshow, controlshow, MenuId, config, menuloading, eyeopen, needUpdate, appLoginId, appHomeId } = this.state
    return (
      <ConfigProvider locale={antdZhCN}>
      <>
        <DndProvider backend={HTML5Backend}>
          {view !== 'popview' ? <div className={'mk-pc-view '} id="mk-pc-design-view">
            {loading ? <Spin className="view-spin" size="large" /> : null}
@@ -1758,8 +1820,8 @@
                <PictureController/>
                <Quotecomponent config={config} updateConfig={this.updateConfig}/>
                <StyleCombControlButton menu={config} />
                <Button className="mk-border-green" onClick={this.setHomeView}><HomeOutlined /> 设为首页</Button>
                <Button className="mk-border-purple" onClick={this.setLoginView}><LoginOutlined/> 设为登录页</Button>
                <Button className="mk-border-green" disabled={MenuId === appHomeId} onClick={this.setHomeView}><HomeOutlined /> 设为首页</Button>
                <Button className="mk-border-purple" disabled={MenuId === appLoginId} onClick={this.setLoginView}><LoginOutlined/> 设为登录页</Button>
                <ReplaceField type="custom" config={config} updateConfig={this.resetConfig}/>
                <Transfer MenuID={MenuId} />
                {config ? <Versions MenuId={MenuId} Template="webPage" checklog={this.checklog} updateConfig={this.updateLogConfig}/> : null}
@@ -1777,7 +1839,7 @@
        <StyleController />
        <StyleCombController />
        <ModalController />
      </ConfigProvider>
      </>
    )
  }
}