king
2022-09-08 0a72ad847aad17cf7dbffc239dec0d62c34a10d1
src/views/design/sidemenu/thdmenuplus/index.jsx
@@ -9,6 +9,7 @@
import MKEmitter from '@/utils/events.js'
import Utils from '@/utils/utils.js'
import Preview from './preview'
import MenuUtils from '@/utils/utils-custom.js'
import asyncComponent from '@/utils/asyncComponent'
import mainsubtable from '@/assets/img/mainsubtable.jpg'
@@ -69,6 +70,7 @@
        _templates.push({
          uuid: temp.MenuID,
          title: temp.MenuName,
          MenuNo: temp.MenuNo,
          type: temp.Template,
          url: illust[temp.Template],
          disabled: temp.disabled || false,
@@ -114,25 +116,6 @@
      preview: null
    })
  }
  // this.setState({
  //   tabview: 'template',
  //   editMenu: {
  //     MenuID: Utils.getuuid(),
  //     MenuName: '',
  //     MenuNo: '',
  //     type: '',
  //     PageParam: '',
  //     LongParam: '',
  //     isSubtable: '', // 是否为主子表
  //     ParentId: this.props.supMenu.MenuID,
  //     supMenuList: this.props.supMenuList,
  //     fstMenuId: this.props.mainMenu.MenuID,
  //     fstMenuList: this.props.menuTree,
  //     menuSort: (this.props.menulist.length + 1) * 10 // 新建菜单设置排序
  //   }
  // }, () => {
  //   document.getElementById('root').style.overflowY = 'hidden'
  // })
  useTemplate = (template) => {
    const { mainMenu, supMenu, menuTree } = this.props
@@ -174,7 +157,7 @@
        PageParam.url = values.url
      }
      if (sysMenu.copyId) {
      if (sysMenu.copyId && sysMenu.Template !== 'CustomPage') {
        PageParam.copyMenuId = sysMenu.copyId
      }
@@ -201,26 +184,92 @@
        loading: true
      })
      Api.getSystemConfig(param).then(response => {
        if (response.status) {
          this.setState({
            loading: false,
            addVisible: false,
            sysMenu: null
          })
      if (sysMenu.Template === 'CustomPage' && sysMenu.copyId) {
        this.copyMenu(param, sysMenu.copyId)
      } else {
        Api.getSystemConfig(param).then(response => {
          if (response.status) {
            this.setState({
              loading: false,
              addVisible: false,
              sysMenu: null
            })
            MKEmitter.emit('mkUpdateMenuList')
          } else {
            this.setState({
              loading: false
            })
            notification.warning({
              top: 92,
              message: response.message,
              duration: 5
            })
          }
        })
      }
    })
  }
          MKEmitter.emit('mkUpdateMenuList')
        } else {
          this.setState({
            loading: false
          })
          notification.warning({
            top: 92,
            message: response.message,
            duration: 5
          })
  copyMenu = (param, MenuId) => {
    Api.getSystemConfig({
      func: 'sPC_Get_LongParam',
      MenuID: MenuId
    }).then(result => {
      if (result.status) {
        let config = null
        try {
          config = result.LongParam ? JSON.parse(window.decodeURIComponent(window.atob(result.LongParam))) : null
        } catch (e) {
          console.warn('Parse Failure')
          config = null
        }
      })
        if (config) {
          config.uuid = param.MenuID
          config.MenuID = param.MenuID
          config.parentId = param.ParentID
          config.MenuName = param.MenuName
          config.MenuNo = param.MenuNo
          config.easyCode = ''
          config.components = MenuUtils.resetConfig(config.components)
          config.enabled = false
          param.LongParam = window.btoa(window.encodeURIComponent(JSON.stringify(config)))
        }
        Api.getSystemConfig(param).then(response => {
          if (response.status) {
            this.setState({
              loading: false,
              addVisible: false,
              sysMenu: null
            })
            MKEmitter.emit('mkUpdateMenuList')
            document.getElementById('root').style.overflowY = 'unset'
          } else {
            this.setState({
              loading: false
            })
            notification.warning({
              top: 92,
              message: response.message,
              duration: 5
            })
          }
        })
      } else {
        this.setState({
          confirmLoading: false
        })
        notification.warning({
          top: 92,
          message: result.message,
          duration: 5
        })
      }
    })
  }
@@ -263,21 +312,22 @@
              </Row>
              <Row>
                {this.state.usedTemplates.map((template, index) => {
                  if (!tempSearchKey || template.title.toLowerCase().indexOf(tempSearchKey.toLowerCase()) >= 0) {
                    return (
                      <Col key={template.type + index} className={template.disabled ? 'disabled' : ''} title={template.disTitle || ''} span={6}>
                        <Card
                          title={template.title}>
                          <img onClick={() => {this.previewPicture(template)}} src={template.url} alt=""/>
                          <div className="card-operation">
                            <Button type="primary" onClick={() => {this.useTemplate(template, 'user')}}>使用模板</Button>
                          </div>
                        </Card>
                      </Col>
                    )
                  } else {
                    return null
                  if (tempSearchKey) {
                    if ((template.title + template.MenuNo).toLowerCase().indexOf(tempSearchKey.toLowerCase()) === -1) {
                      return null
                    }
                  }
                  return (
                    <Col key={template.type + index} className={template.disabled ? 'disabled' : ''} title={template.disTitle || ''} span={6}>
                      <Card title={<div className="title-wrap"><div>{template.title}</div><div>{template.MenuNo}</div></div>}>
                        <img onClick={() => {this.previewPicture(template)}} src={template.url} alt=""/>
                        <div className="card-operation">
                          <Button type="primary" onClick={() => {this.useTemplate(template, 'user')}}>使用模板</Button>
                        </div>
                      </Card>
                    </Col>
                  )
                })}
              </Row>
            </TabPane>