king
2024-06-21 2bccb9ec7bdefe23292a22bc153463cfa1479a49
src/views/tabledesign/index.jsx
@@ -4,15 +4,15 @@
import { is, fromJS } from 'immutable'
import moment from 'moment'
import HTML5Backend from 'react-dnd-html5-backend'
import { ConfigProvider, notification, Modal, Collapse, Card, Switch, Button, Typography } from 'antd'
import { notification, Modal, Collapse, Card, Switch, Button, Typography } from 'antd'
import { DoubleLeftOutlined, DoubleRightOutlined } from '@ant-design/icons'
import md5 from 'md5'
import Api from '@/api'
import Utils, { setGLOBFuncs } from '@/utils/utils.js'
import antdZhCN from 'antd/es/locale/zh_CN'
import { langs } from '@/store/options'
import MKEmitter from '@/utils/events.js'
import { getTables } from '@/utils/utils-custom.js'
import { getTables, getFuncsAndInters, getLangTrans } from '@/utils/utils-custom.js'
import SourceElement from '@/templates/zshare/dragsource'
import asyncComponent from '@/utils/asyncComponent'
import Source from './source'
@@ -23,7 +23,6 @@
const { Panel } = Collapse
const { confirm } = Modal
const { Paragraph } = Typography
const _locale = antdZhCN
const MenuForm = asyncComponent(() => import('./menuform'))
const PopView = asyncComponent(() => import('./popview'))
@@ -34,6 +33,7 @@
const BgController = asyncComponent(() => import('@/pc/bgcontroller'))
const StyleController = asyncComponent(() => import('@/menu/stylecontroller'))
const ReplaceField = asyncComponent(() => import('@/menu/replaceField'))
const Debug = asyncComponent(() => import('@/menu/debug'))
const Versions = asyncComponent(() => import('@/menu/versions'))
const Transfer = asyncComponent(() => import('@/menu/transfer'))
const Unattended = asyncComponent(() => import('@/templates/zshare/unattended'))
@@ -58,6 +58,7 @@
    comloading: false,
    settingshow: sessionStorage.getItem('settingshow') !== 'false',
    view: null,
    langName: '',
    popConfig: null
  }
@@ -92,6 +93,7 @@
        ParentId: param.ParentId || '',
        MenuName: param.MenuName || '',
        MenuNo: param.MenuNo || '',
        langName: sessionStorage.getItem('lang') !== 'zh-CN' && langs[sessionStorage.getItem('lang')] ? `(${langs[sessionStorage.getItem('lang')]})` : ''
      }, () => {
        this.getMenuParam()
      })
@@ -424,8 +426,8 @@
        window.GLOB.urlFields = config.urlFields || []
        this.setState({
          oriConfig: config,
          config: fromJS(config).toJS()
          oriConfig: config.components[0].isNew ? {} : fromJS(config).toJS(),
          config: config
        })
        window.GLOB.customMenu = config
      } else {
@@ -458,7 +460,7 @@
          let _s = 1
          tab.components[0].action.forEach(btn => {
            if (btn.hidden === 'true') return
            if (btn.hidden === 'true' || btn.permission === 'false') return
            buttons.push(`select '${btn.uuid}' as menuid, '${btn.label}' as menuname, '${_s * 10}' as Sort, '${tab.components[0].uuid}' as parentid, 60 as Type`)
            _s++
@@ -470,7 +472,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
                  buttons.push(`select '${cell.uuid}' as menuid, '${cell.label}' as menuname, '${_s * 10}' as Sort, '${tab.components[0].uuid}' as parentid, 60 as Type`)
                  _s++
                })
@@ -485,7 +487,7 @@
          tbs.push(...item.$tables)
        }
        item.action.forEach(btn => {
          if (btn.hidden === 'true') return
          if (btn.hidden === 'true' || btn.permission === 'false') return
          buttons.push(`select '${btn.uuid}' as menuid, '${btn.label}' as menuname, '${_sort * 10}' as Sort, '${config.uuid}' as parentid, 40 as Type`)
          _sort++
@@ -497,7 +499,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
                buttons.push(`select '${cell.uuid}' as menuid,  '${cell.label}' as menuname, '${_sort * 10}' as Sort, '${config.uuid}' as parentid, 40 as Type`)
                _sort++
              })
@@ -531,6 +533,18 @@
    if (!this.checkBase()) {
      return
    } else if (this.checklog()) {
      if (sessionStorage.getItem('langList') && !config.trans) {
      } else {
        notification.success({
          top: 92,
          message: '当前配置未修改,无需保存。',
          duration: 5
        })
        MKEmitter.emit('completeSave')
        return
      }
    }
    this.setState({
@@ -579,6 +593,10 @@
        config.tbkey = key
      }
      let interfaces = getFuncsAndInters(config)
      let urlFields = config.urlFields ? config.urlFields.join(',') : ''
      let langSql = getLangTrans(config)
      let param = {
        func: 'sPC_TrdMenu_AddUpt',
        FstID: config.fstMenuId || '',
@@ -589,19 +607,22 @@
        EasyCode: config.easyCode || '',
        Template: 'BaseTable',
        MenuName: config.MenuName || '',
        PageParam: JSON.stringify({Template: 'BaseTable', OpenType: config.OpenType || 'newtab', hidden: config.hidden || 'false'}),
        PageParam: JSON.stringify({Template: 'BaseTable', OpenType: config.OpenType || 'newtab', hidden: config.hidden || 'false', menuColor: config.menuColor || '', interfaces, urlFields}),
        open_edition: config.open_edition,
        LText: '',
        LTexttb: '',
        // LText: '',
        // LTexttb: '',
        debug_md5: key,
        debug_url: url,
        debug_list: window.btoa(tbs),
        LongParam: window.btoa(window.encodeURIComponent(JSON.stringify(config)))
      }
      param.LText = Utils.formatOptions(param.LText)
      if (langSql) {
        param.lang_translation = window.btoa(window.encodeURIComponent(langSql))
      }
      param.timestamp = moment().format('YYYY-MM-DD HH:mm:ss')
      param.secretkey = Utils.encrypt(param.LText, param.timestamp)
      param.secretkey = Utils.encrypt('', param.timestamp)
      let btnParam = {             // 添加菜单按钮
        func: 'sPC_Button_AddUpt',
@@ -609,14 +630,14 @@
        ParentID: config.uuid,
        MenuNo: config.MenuNo,
        Template: 'BaseTable',
        button_proc_edition: 'Y'
        button_proc_edition: 'Y',
        exec_type: 'x'
      }
      btnParam.LText = btns.join(' union all ')
      btnParam.LText = Utils.formatOptions(btnParam.LText)
      btnParam.LText = Utils.formatOptions(btnParam.LText, 'x')
      btnParam.timestamp = moment().format('YYYY-MM-DD HH:mm:ss')
      btnParam.secretkey = Utils.encrypt(btnParam.LText, btnParam.timestamp)
      btnParam.secretkey = Utils.encrypt('', btnParam.timestamp)
      new Promise(resolve => {
        Api.getCloudConfig(param).then(res => {
@@ -648,10 +669,10 @@
            duration: 2
          })
        } else {
          notification.warning({
            top: 92,
            message: res.message,
            duration: 5
          Modal.warning({
            width: 400,
            title: res.message,
            okText: '知道了'
          })
        }
        MKEmitter.emit('completeSave')
@@ -815,12 +836,34 @@
    sessionStorage.setItem('settingshow', '' + !this.state.settingshow)
  }
  checklog = () => {
    const { oriConfig, config } = this.state
    return is(fromJS(oriConfig), fromJS(config))
  }
  updateLogConfig = (config) => {
    config.fstMenuId = this.state.config.fstMenuId || config.fstMenuId || ''
    config.parentId = this.state.config.parentId || config.parentId || ''
    config.open_edition = this.state.config.open_edition || ''
    this.setState({
      config: null
    }, () => {
      this.setState({
        config: config
      })
    })
    window.GLOB.customMenu = config
  }
  render () {
    const { view, activeKey, comloading, MenuId, config, settingshow, ParentId, menuloading } = this.state
    const { view, activeKey, comloading, MenuId, config, settingshow, ParentId, menuloading, langName } = this.state
    return (
      <ConfigProvider locale={_locale}>
        <Header />
      <>
        <Header menuName={config ? config.MenuName + langName : ''}/>
        <DndProvider backend={HTML5Backend}>
        {view !== 'popview' ? <div className="pc-table-view">
            <div className="menu-body">
@@ -867,13 +910,19 @@
                </Collapse>
              </div>
              <div className={'menu-view' + (menuloading ? ' saving' : '')}>
                <Card title={
                  <div style={{paddingLeft: '15px'}}> {config && config.MenuName} </div>
                } bordered={false} extra={
                  <div>
                <Card bordered={false} extra={
                  <div className="mk-opeartion-list">
                    {/* <Dropdown overlay={
                      <div className="mk-button-dropdown-wrap">
                        <ReplaceField type="custom" config={config} updateConfig={this.resetConfig}/>
                      </div>
                    } trigger={['click']} placement="bottomCenter">
                      <Button className="mk-button-more">更多<DownOutlined/></Button>
                    </Dropdown> */}
                    {config ? <Debug config={config}/> : null}
                    {config ? <Transfer config={config}/> : null}
                    {config ? <Unattended config={config} updateConfig={this.updateConfig}/> : null}
                    <Versions MenuId={MenuId} open_edition={config ? config.open_edition : ''}/>
                    {config ? <Versions MenuId={MenuId} Template="BaseTable" checklog={this.checklog} updateConfig={this.updateLogConfig}/> : null}
                    <TableNodes config={config} />
                    <ReplaceField type="custom" config={config} updateConfig={this.resetConfig}/>
                    <PasteBaseTable type="page" insert={this.insert}/>
@@ -890,7 +939,7 @@
        </DndProvider>
        <StyleController />
        <ModalController />
      </ConfigProvider>
      </>
    )
  }
}