king
2024-10-11 8e003c1a94d26cc4d477e7aa03593ccb4d7e6c61
src/views/mobdesign/index.jsx
@@ -9,9 +9,9 @@
import md5 from 'md5'
import Api from '@/api'
import Utils, { setGLOBFuncs } from '@/utils/utils.js'
import Utils from '@/utils/utils.js'
import MKEmitter from '@/utils/events.js'
import MenuUtils, { getTables, getFuncsAndInters, getLangTrans } from '@/utils/utils-custom.js'
import MenuUtils, { getTables, getFuncsAndInters, getOutMessage, getLangTrans, getAllSqls } from '@/utils/utils-custom.js'
import asyncComponent from '@/utils/asyncComponent'
import '@/assets/css/design.scss'
@@ -74,7 +74,9 @@
    viewType: 'menu',
    view: '',
    eyeopen: false,
    needUpdate: false
    needUpdate: false,
    appLoginId: '',
    appHomeId: ''
  }
  UNSAFE_componentWillMount() {
@@ -120,6 +122,10 @@
          sessionStorage.removeItem('applangList')
        }
        if (param.wxAppId) {
          sessionStorage.setItem('wxAppId', param.wxAppId)
        }
        this.getAppMessage(param.MenuID)
      } else if (param.type === 'view') {
        window.GLOB.winWidth = 420
@@ -135,10 +141,29 @@
          adapters = []
        }
        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({
          adapters,
          MenuId: param.MenuID,
          viewType: /^userbind/.test(param.MenuID) ? 'userbind' : 'menu'
          viewType: /^userbind/.test(param.MenuID) ? 'userbind' : 'menu',
          appLoginId: appLoginId,
          appHomeId: appHomeId
        }, () => {
          this.getMenuParam(param)
        })
@@ -171,9 +196,14 @@
    MKEmitter.addListener('changePopview', this.initPopview)
    MKEmitter.addListener('triggerMenuSave', this.submitConfig)
    MKEmitter.addListener('changeEditMenu', this.changeEditMenu)
    if (sessionStorage.getItem('wxAppId')) {
      window.GLOB.WXAppID = sessionStorage.getItem('wxAppId')
    }
    setTimeout(() => {
      this.getRoleFields()
      setGLOBFuncs()
      // setGLOBFuncs()
    }, 1000)
    document.onkeydown = (event) => {
@@ -1295,6 +1325,7 @@
    let traversal = (components) => {
      return components.map(item => {
        item.miniStyle = ''
        if (item.style) {
          item.miniStyle = this.transferStyle(item.style)
        }
@@ -1310,12 +1341,18 @@
        }
        if (item.type === 'tabs') {
          if (item.setting.backgroundColor) {
            item.miniStyle += `--tabs-header-background: ${item.setting.backgroundColor};`
          }
          item.subtabs.forEach(tab => {
            tab.components = traversal(tab.components)
          })
        } else if (item.type === 'group') {
          item.components = traversal(item.components)
        } else if (['card', 'carousel', 'timeline'].includes(item.type)) {
          if (item.wrap.display === 'hidden') {
            item.miniStyle += 'display:none;'
          }
          item.subcards.forEach(card => {
            card.miniStyle = this.transferStyle(card.style)
            card.elements = card.elements.map(cell => {
@@ -1416,8 +1453,10 @@
      })
      return
    } else if (this.checklog()) {
      if (sessionStorage.getItem('applangList') && !config.trans) {
      if ((sessionStorage.getItem('applangList') && !config.trans) || (adapters.includes('wxmini') && !config.hasOwnProperty('miniStyle'))) {
      } else if (config.enabled && !config.allSqls) {
      } else {
        notification.success({
          top: 92,
@@ -1442,6 +1481,52 @@
      } else if (!config.enabled && config.force && _pass) {
        config.enabled = true
        delete config.force
      }
      let long_data = ''
      if (config.enabled) {
        let sqls = getAllSqls(config)
        let _t = moment().format('YYYYMMDDHHmmss')
        let getguid = () => {
          let uuid = ''
          for (let i = 0; i < 18; i++) {
            uuid += String.fromCharCode(Math.floor(Math.random() * 26) + 65)
          }
          uuid = uuid.replace(/minke/ig, 'MNKIE')
          return uuid
        }
        long_data = []
        let oriIds = {}
        if (config.allSqls) {
          config.allSqls.forEach(item => {
            if (!item.md5) return
            oriIds[item.uuid + item.md5] = item.v_id
          })
        }
        config.allSqls = sqls.map(item => {
          let v_id = _t + getguid()
          if (oriIds[item.uuid + item.md5]) {
            v_id = oriIds[item.uuid + item.md5]
          }
          long_data.push(`${md5(window.GLOB.appkey + v_id)},${item.uuid},${v_id},${window.btoa(window.encodeURIComponent(item.LText))}`)
          return {
            uuid: item.uuid,
            v_id: v_id,
            type: item.type,
            reps: item.reps,
            md5: item.md5 || '',
            luser: item.luser === true
          }
        })
        long_data = long_data.join(';')
      } else {
        delete config.allSqls
      }
      if (config.cacheUseful !== 'true') {
@@ -1486,7 +1571,7 @@
          typename: sessionStorage.getItem('typename') || '',
          adapter: sessionStorage.getItem('adapter') || '',
          sysBgColor: sessionStorage.getItem('sysBgColor') || '',
          MenuName: config.MenuName || '',
          MenuName: config.MenuName || ''
        }
        url = window.btoa(window.encodeURIComponent(JSON.stringify(urlparam)))
@@ -1497,6 +1582,9 @@
        roleParam.pass = true
      }
      delete config.miniTitle
      delete config.miniReloadUp
      config.components.forEach(item => {
        if (item.type === 'login') {
          roleParam.login = true
@@ -1504,6 +1592,13 @@
          config.loginview = true
        } else if (item.type === 'navbar') {
          config.tabview = true
        } else if (item.type === 'topbar' && adapters.includes('wxmini')) {
          if (item.wrap.minishow !== 'true') {
            config.miniTitle = item.wrap.title || ''
          }
          if (item.wrap.reload === 'true') {
            config.miniReloadUp = true
          }
        }
      })
@@ -1529,7 +1624,10 @@
      menus_used_list = window.btoa(window.encodeURIComponent(menus_used_list || 'del'))
      let interfaces = getFuncsAndInters(config)
      let msg = getOutMessage(config)
      roleParam.interfaces = interfaces
      roleParam.msg = msg
      roleParam.backend = 'level1'
      let langSql = getLangTrans(config)
      let param = {
@@ -1544,9 +1642,10 @@
        TypeCharOne: sessionStorage.getItem('kei_no'),
        Typename: sessionStorage.getItem('typename'),
        MenuName: config.MenuName || '',
        PageParam: JSON.stringify({Template: 'webPage', interfaces}),
        PageParam: JSON.stringify({Template: 'webPage', interfaces, msg}),
        open_edition: config.open_edition,
        menus_rolelist: window.btoa(window.encodeURIComponent(JSON.stringify(roleParam))),
        long_data: long_data,
        // LText: '',
        // LTexttb: '',
        menus_used_list,
@@ -1933,6 +2032,8 @@
    param.timestamp = moment().format('YYYY-MM-DD HH:mm:ss')
    param.secretkey = Utils.encrypt('', param.timestamp)
    const that = this
    confirm({
      title: '确定设置本页面为首页吗?',
      content: '',
@@ -1946,6 +2047,10 @@
            })
          } else {
            sessionStorage.setItem('appViewList', JSON.stringify(appViewList))
            that.setState({
              appHomeId: config.MenuID
            })
          }
        })
      },
@@ -1993,6 +2098,7 @@
    param.secretkey = Utils.encrypt('', param.timestamp)
    let hasLogin = config.components.findIndex(item => item.type === 'login') > -1
    const that = this
    confirm({
      title: '确定设置本页面为登录页吗?',
@@ -2007,6 +2113,10 @@
            })
          } else {
            sessionStorage.setItem('appViewList', JSON.stringify(appViewList))
            that.setState({
              appLoginId: config.MenuID
            })
          }
        })
      },
@@ -2071,7 +2181,7 @@
  render () {
    const { view, viewType, comloading, loading, settingshow, controlshow, activeKey, MenuId, config, menuloading, adapters, eyeopen, needUpdate } = this.state
    const { view, viewType, comloading, loading, settingshow, controlshow, activeKey, MenuId, config, menuloading, adapters, eyeopen, needUpdate, appLoginId, appHomeId } = this.state
    return (
      <div className={'mk-mob-view ' + viewType} id="mk-mob-design-view">
@@ -2126,7 +2236,7 @@
              {!controlshow ? <DoubleLeftOutlined onClick={() => {this.setState({controlshow: true})}}/> : null}
            </div>
            <div className="wrap">
              <Button type="primary" className={needUpdate ? 'update-tip' : ''} onClick={this.submitConfig} id="save-config" loading={menuloading}>保存</Button>
              <Button type="primary" className={needUpdate ? 'update-tip' : ''} disabled={!config} onClick={this.submitConfig} id="save-config" loading={menuloading}>保存</Button>
              {config ? <Switch className="big" checkedChildren="启" unCheckedChildren="停" checked={config.enabled} onChange={this.onEnabledChange} /> : null}
              <ArrowLeftOutlined title="后退" className="back-view" onClick={this.backView}/>
              {config ? <Debug config={config}/> : null}
@@ -2139,8 +2249,8 @@
              <PictureController/>
              <Quotecomponent config={config} updateConfig={this.updateConfig}/>
              <StyleCombControlButton menu={config} />
              <Button className="mk-border-green set-home" onClick={this.setHomeView}><HomeOutlined /> 设为首页</Button>
              <Button className="mk-border-purple set-login" onClick={this.setLoginView}><LoginOutlined /> 设为登录页</Button>
              <Button className="mk-border-green set-home" 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}