king
2023-04-24 295b93984fd94a11d0337637f76ff91b5a618215
src/views/menudesign/index.jsx
@@ -37,6 +37,7 @@
const PasteController = asyncComponent(() => import('@/menu/pastecontroller'))
const StyleController = asyncComponent(() => import('@/menu/stylecontroller'))
const ReplaceField = asyncComponent(() => import('@/menu/replaceField'))
const NormalCss = asyncComponent(() => import('@/menu/normalCss'))
const Versions = asyncComponent(() => import('@/menu/versions'))
const TableNodes = asyncComponent(() => import('@/menu/tablenodes'))
const SysInterface = asyncComponent(() => import('@/menu/sysinterface'))
@@ -64,7 +65,7 @@
    config: null,
    customComponents: [],
    comloading: false,
    settingshow: true,
    settingshow: sessionStorage.getItem('settingshow') !== 'false',
    eyeopen: false,
    view: '',
    popConfig: null,
@@ -84,7 +85,7 @@
      this.setState({
        MenuType: param.MenuType,
        MenuId: param.MenuId,
        MenuId: param.MenuId || param.MenuID,
        ParentId: param.ParentId || '',
        MenuName: param.MenuName || '',
        MenuNo: param.MenuNo || '',
@@ -165,6 +166,9 @@
        }
        let node = document.getElementById('save-modal-config')
        if (!node) {
          node = document.getElementById('save-pop-config')
        }
        if (!node) {
          node = document.getElementById('save-config')
        }
@@ -509,7 +513,7 @@
        })
      } else if (item.type === 'group') {
        item.components = this.collectTB(item.components, popBtns)
      } else if (item.type !== 'search') {
      } else {
        item.$tables = getTables(item, popBtns)
      }
@@ -582,6 +586,7 @@
    let popBtns = []
    config.components = this.collectTB(config.components, popBtns)
    config.version = 2.0
    if (popBtns.length === 0) {
      this.setState({
@@ -753,6 +758,35 @@
    return true
  }
  resetSyncQuery = (components) => {
    return components.map(item => {
      if (item.type === 'tabs') {
        item.subtabs.forEach(tab => {
          tab.components = this.resetSyncQuery(tab.components)
        })
      } else if (item.type === 'group') {
        item.components = this.resetSyncQuery(item.components)
      } else if (item.setting && item.setting.interType === 'system' && item.setting.sync === 'true') {
        let sql = ''
        if (item.setting.execute !== 'false' && item.setting.dataresource) {
          sql = item.setting.dataresource
        }
        item.scripts && item.scripts.forEach(script => {
          if (script.status === 'false') return
          sql += script.sql
        })
        if (sql.length > 8000) {
          item.setting.sync = 'false'
        }
      }
      return item
    })
  }
  submitConfig = () => {
    const { MenuType } = this.state
    let config = fromJS(this.state.config).toJS()
@@ -771,8 +805,18 @@
    })
    setTimeout(() => {
      if (config.enabled && this.verifyConfig()) {
      let _pass = this.verifyConfig(config)
      if (config.enabled && !_pass) {
        config.enabled = false
        config.force = true
      } else if (!config.enabled && config.force && _pass) {
        config.enabled = true
        delete config.force
      }
      if (config.cacheUseful !== 'true') {
        config.components = this.resetSyncQuery(config.components)
      }
      let tbs = []
@@ -843,7 +887,6 @@
      btnParam.LText = Utils.formatOptions(btnParam.LText)
      btnParam.timestamp = moment().format('YYYY-MM-DD HH:mm:ss')
      btnParam.secretkey = Utils.encrypt(btnParam.LText, btnParam.timestamp)
      new Promise(resolve => {
        if (MenuType === 'billPrint') { // 打印生成页面效果图
@@ -872,7 +915,7 @@
              } else {
                resolve(result)
              }
            })
            }, this.netError)
          })
        } else {
          resolve({status: true})
@@ -885,10 +928,7 @@
        if (!res || !res.status) return res
        if (MenuType !== 'billPrint') { // 基本信息改变时,通知菜单列表更新
          let ori = this.state.oriConfig
          if (config.MenuName !== ori.MenuName || config.MenuNo !== ori.MenuNo || config.parentId !== ori.parentId) {
            localStorage.setItem('menuUpdate', new Date().getTime())
          }
          localStorage.setItem('menuUpdate', new Date().getTime() + ',' + config.uuid)
        }
        config.open_edition = res.open_edition || ''
        this.setState({
@@ -908,7 +948,7 @@
          }
          return Api.getSystemConfig(_param)
        }
      }).then(res => { // 页面按钮关系保存
      }, this.netError).then(res => { // 页面按钮关系保存
        if (!res || !res.status) return res
        this.setState({
@@ -922,7 +962,7 @@
            status: true
          }
        }
      }).then(res => {
      }, this.netError).then(res => {
        this.setState({
          menuloading: false
        })
@@ -943,8 +983,21 @@
            duration: 5
          })
        }
      })
      }, this.netError)
    }, 300 + (+sessionStorage.getItem('mkDelay')))
  }
  netError = (error) => {
    this.setState({
      menuloading: false
    })
    if (!error) {
      notification.warning({
        top: 92,
        message: '保存失败,请检查网络是否正常。',
        duration: 5
      })
    }
  }
  getRoleFields = () => {
@@ -983,17 +1036,23 @@
  onEnabledChange = () => {
    const { config } = this.state
    if (!config || (!config.enabled && this.verifyConfig(true))) {
      return
    }
    let _config = {...config, enabled: !config.enabled}
    this.setState({
      config: {...config, enabled: !config.enabled}
    })
    delete _config.force
    if (!_config.enabled) {
      this.setState({
        config: _config
      })
    } else if (this.verifyConfig(_config)) {
      this.setState({
        config: _config
      })
    }
  }
  verifyConfig = (show) => {
    const { config, MenuType } = this.state
  verifyConfig = (config) => {
    const { MenuType } = this.state
    let error = ''
    let check = (components) => {
@@ -1021,7 +1080,7 @@
    check(config.components)
    if (show && error) {
    if (config.enabled && error) {
      notification.warning({
        top: 92,
        message: error,
@@ -1037,12 +1096,14 @@
        carousel: '轮播',
        tree: '树形列表',
        chart: '自定义图表',
        editor: '富文本',
        group: '分组'
        // editor: '富文本',
        group: '分组',
        iframe: 'iframe'
      }
      let subforbid = {
        editable: '可编辑表格',
        voucher: '凭证'
        voucher: '凭证',
        account: '账套'
      }
      config.components.forEach(item => {
@@ -1053,7 +1114,7 @@
        }
      })
      if (show && error) {
      if (config.enabled && error) {
        notification.warning({
          top: 92,
          message: error,
@@ -1062,7 +1123,7 @@
      }
    }
    return error
    return error === ''
  }
  // 更新配置信息
@@ -1102,6 +1163,7 @@
  changeSetting = () => {
    this.setState({settingshow: !this.state.settingshow})
    sessionStorage.setItem('settingshow', '' + !this.state.settingshow)
    setTimeout(() => {
      MKEmitter.emit('tabsChange', 'all')
@@ -1148,6 +1210,7 @@
                    {/* 表名添加 */}
                    {config ? <TableComponent config={config} updatetable={this.updateConfig}/> : null}
                    {config ? <Paragraph style={{padding: '15px 0px 0px 18px'}} copyable={{ text: MenuId }}>菜单ID</Paragraph> : null}
                    {config ? <NormalCss config={config} updateConfig={this.updateConfig}/> : null}
                  </Panel>
                  {/* 组件添加 */}
                  <Panel header="组件" key="component">
@@ -1175,7 +1238,7 @@
                    <PictureController/>
                    <StyleCombControlButton menu={config} />
                    <PasteController insert={this.insert} />
                    <Switch className="big" checkedChildren="启" unCheckedChildren="停" checked={config && config.enabled} onChange={this.onEnabledChange} />
                    {config ? <Switch className="big" checkedChildren="启" unCheckedChildren="停" checked={config.enabled} onChange={this.onEnabledChange} /> : null}
                    <Button type="primary" id="save-config" className={needUpdate ? 'update-tip' : ''} onClick={this.submitConfig} loading={menuloading}>保存</Button>
                    <Button type="default" onClick={this.closeView}>关闭</Button>
                  </div>