king
2021-03-05 e36eb1999794bd71e76482b92a0b0b20f49d0032
src/views/menudesign/index.jsx
@@ -8,6 +8,7 @@
import html2canvas from 'html2canvas'
import Api from '@/api'
import options from '@/store/options.js'
import Utils from '@/utils/utils.js'
import zhCN from '@/locales/zh-CN/mob.js'
import enUS from '@/locales/en-US/mob.js'
@@ -22,23 +23,24 @@
const { Panel } = Collapse
const { confirm } = Modal
const _locale = localStorage.getItem('lang') !== 'en-US' ? antdZhCN : antdEnUS
const _locale = sessionStorage.getItem('lang') !== 'en-US' ? antdZhCN : antdEnUS
const MenuForm = asyncComponent(() => import('./menuform'))
const HomeForm = asyncComponent(() => import('./homeform'))
const PrintMenuForm = asyncComponent(() => import('./printmenuform'))
const Header = asyncComponent(() => import('@/menu/header'))
const SourceWrap = asyncComponent(() => import('@/menu/modelsource'))
const MenuShell = asyncComponent(() => import('@/menu/menushell'))
const PrintMenuForm = asyncComponent(() => import('./printmenuform'))
const SourceWrap = asyncComponent(() => import('@/menu/modulesource'))
const PopviewController = asyncComponent(() => import('@/menu/popview'))
const BgController = asyncComponent(() => import('@/menu/bgcontroller'))
const PasteController = asyncComponent(() => import('@/menu/pastecontroller'))
const PaddingController = asyncComponent(() => import('@/menu/padcontroller'))
const StyleController = asyncComponent(() => import('@/menu/stylecontroller'))
// const PictureController = asyncComponent(() => import('@/menu/picturecontroller'))
const SysInterface = asyncComponent(() => import('@/menu/sysinterface'))
const PictureController = asyncComponent(() => import('@/menu/picturecontroller'))
const ModalController = asyncComponent(() => import('@/menu/modalconfig/controller'))
const StyleCombController = asyncComponent(() => import('@/menu/stylecombcontroller'))
const StyleCombControlButton = asyncComponent(() => import('@/menu/stylecombcontrolbutton'))
const ModalController = asyncComponent(() => import('@/menu/modalconfig/controller'))
const PopviewController = asyncComponent(() => import('@/menu/popview'))
const TableComponent = asyncComponent(() => import('@/templates/sharecomponent/tablecomponent'))
sessionStorage.setItem('isEditState', 'true')
@@ -48,20 +50,18 @@
class MenuDesign extends Component {
  state = {
    dict: localStorage.getItem('lang') !== 'en-US' ? zhCN : enUS,
    dict: sessionStorage.getItem('lang') !== 'en-US' ? zhCN : enUS,
    MenuType: '',
    MenuId: '',
    ParentId: '',
    MenuName: '',
    MenuNo: '',
    tableFields: [],
    delButtons: [],
    copyButtons: [],
    thawButtons: [],
    activeKey: 'basedata',
    menuloading: false,
    oriConfig: null,
    openEdition: '',
    config: null,
    popBtn: null,             // 弹窗标签页
    visible: false,
@@ -101,8 +101,10 @@
    MKEmitter.addListener('changePopview', this.initPopview)
    MKEmitter.addListener('submitComponentStyle', this.updateComponentStyle)
    MKEmitter.addListener('updateCustomComponent', this.updateCustomComponent)
    this.updateCustomComponent()
    // this.getAppPictures()
    setTimeout(() => {
      this.updateCustomComponent()
      this.getAppPictures()
    }, 1000)
  }
  /**
@@ -120,18 +122,31 @@
    MKEmitter.removeListener('updateCustomComponent', this.updateCustomComponent)
  }
  // getAppPictures = () => {
  //   Api.getSystemConfig({
  //     func: 's_url_db_adduptdel',
  //     id: '',
  //     PageIndex: 0, // 0 代表全部
  //     PageSize: 0,  // 0 代表全部
  //     typecharone: 'image',
  //     type: 'search'
  //   }).then(res => {
  getAppPictures = () => {
    Api.getSystemConfig({
      func: 's_url_db_adduptdel',
      PageIndex: 0,  // 0 代表全部
      PageSize: 0,   // 0 代表全部
      typecharone: 'image',
      type: 'search'
    }).then(res => {
      if (res.status) {
        sessionStorage.setItem('app_pictures', JSON.stringify(res.data || []))
      }
  //   })
  // }
      Api.getSystemConfig({
        func: 's_url_db_adduptdel',
        PageIndex: 0,  // 0 代表全部
        PageSize: 0,   // 0 代表全部
        typecharone: 'video',
        type: 'search'
      }).then(res => {
        if (res.status) {
          sessionStorage.setItem('app_videos', JSON.stringify(res.data || []))
        }
      })
    })
  }
  updateCustomComponent = () => {
    Api.getSystemConfig({
@@ -166,6 +181,7 @@
        })
      }
      this.setState({customComponents: coms})
      this.getRoleFields()
    })
  }
@@ -210,10 +226,7 @@
  initPopview = (card, btn) => {
    const { oriConfig, config } = this.state
    let _config = fromJS(config).toJS()
    delete _config.tableFields
    if (!is(fromJS(oriConfig), fromJS(_config))) {
    if (!is(fromJS(oriConfig), fromJS(config))) {
      notification.warning({
        top: 92,
        message: '配置已修改,请保存!',
@@ -222,7 +235,7 @@
      return
    }
    btn.config = _config
    btn.config = fromJS(config).toJS()
    btn.component = card
    sessionStorage.setItem('editMenuType', 'popview') // 编辑弹窗标签
@@ -246,10 +259,7 @@
      return
    }
    let _config = fromJS(config).toJS()
    delete _config.tableFields
    if (!is(fromJS(oriConfig), fromJS(_config))) {
    if (!is(fromJS(oriConfig), fromJS(config))) {
      confirm({
        title: '配置已修改,放弃保存吗?',
        content: '',
@@ -323,14 +333,14 @@
          config.lastCount = config.lastCount || ''
        }
        config.open_edition = result.open_edition || ''
        this.setState({
          oriConfig: config,
          config: fromJS(config).toJS(),
          openEdition: result.open_edition || '',
          config: fromJS(config).toJS()
        })
        this.props.modifyCustomMenu(config)
        this.getRoleFields()
      } else {
        notification.warning({
          top: 92,
@@ -441,7 +451,7 @@
  }
  submitConfig = () => {
    const { openEdition, MenuType, delButtons, copyButtons, thawButtons } = this.state
    const { MenuType, delButtons, copyButtons, thawButtons } = this.state
    let config = fromJS(this.state.config).toJS()
    if (MenuType === 'billPrint' && (!config.firstCount || !config.everyPCount)) {
@@ -478,21 +488,19 @@
        config.enabled = false
      }
      let _config = fromJS(config).toJS()
      delete _config.tableFields
      let param = {
        func: 'sPC_TrdMenu_AddUpt',
        FstID: _config.fstMenuId || '',
        SndID: _config.parentId,
        ParentID: _config.parentId,
        MenuID: _config.uuid,
        MenuNo: _config.MenuNo || '',
        EasyCode: _config.easyCode || '',
        FstID: config.fstMenuId || '',
        SndID: config.parentId,
        ParentID: config.parentId,
        MenuID: config.uuid,
        MenuNo: config.MenuNo || '',
        EasyCode: config.easyCode || '',
        Template: 'CustomPage',
        MenuName: _config.MenuName || '',
        PageParam: JSON.stringify({Template: 'CustomPage', OpenType: 'newtab'}),
        LongParam: window.btoa(window.encodeURIComponent(JSON.stringify(_config))),
        MenuName: config.MenuName || '',
        PageParam: JSON.stringify({Template: 'CustomPage', OpenType: config.OpenType || 'newtab'}),
        LongParam: window.btoa(window.encodeURIComponent(JSON.stringify(config))),
        open_edition: config.open_edition,
        LText: '',
        LTexttb: ''
      }
@@ -501,15 +509,11 @@
      param.timestamp = moment().format('YYYY-MM-DD HH:mm:ss')
      param.secretkey = Utils.encrypt(param.LText, param.timestamp)
      if (openEdition) { // 版本管理
        param.open_edition = openEdition
      }
      let btnParam = {             // 添加菜单按钮
        func: 'sPC_Button_AddUpt',
        Type: 40,                  // 添加菜单下的按钮type为40,按钮下的按钮type为60
        ParentID: _config.uuid,
        MenuNo: _config.MenuNo,
        ParentID: config.uuid,
        MenuNo: config.MenuNo,
        Template: 'CustomPage',
        PageParam: '',
        LongParam: '',
@@ -533,12 +537,21 @@
      new Promise(resolve => {
        if (MenuType === 'billPrint') { // 打印生成页面效果图
          html2canvas(document.getElementById('menu-shell-inner')).then(canvas => {
            let img = canvas.toDataURL('image/png') // 获取生成的图片
            Api.fileuploadbase64(img, 'cloud').then(result => {
            let param = {
              Base64Img: canvas.toDataURL('image/png') // 获取生成的图片
            }
            if (options.cloudServiceApi) {
              param.rduri = options.cloudServiceApi
              param.userid = sessionStorage.getItem('CloudUserID') || ''
              param.LoginUID = sessionStorage.getItem('CloudLoginUID') || ''
            }
            Api.fileuploadbase64(param).then(result => {
              if (result.status) {
                Api.getSystemConfig({
                  func: 's_PrintTemplateMSub',
                  ID: _config.uuid,
                  ID: config.uuid,
                  Images: Utils.getcloudurl(result.Images),
                  Remark: '',
                  temp_type: 'billprint',
@@ -620,9 +633,9 @@
        if (!res) return
        if (res.status) {
          config.open_edition = res.open_edition || ''
          this.setState({
            oriConfig: fromJS(_config).toJS(),
            openEdition: res.open_edition || ''
            oriConfig: fromJS(config).toJS()
          })
          if (btnParam.LText) {
@@ -694,7 +707,7 @@
                    let _param = {
                      func: 'sPC_ButtonParam_AddUpt',
                      ParentID: _config.uuid,
                      ParentID: config.uuid,
                      MenuID: item.uuid,
                      MenuNo: '',
                      Template: 'CustomPage',
@@ -794,7 +807,7 @@
  onEnabledChange = () => {
    const { config } = this.state
    if (!config.enabled && this.verifyConfig(true)) {
    if (!config || (!config.enabled && this.verifyConfig(true))) {
      return
    }
@@ -856,28 +869,12 @@
    this.props.modifyCustomMenu(config)
  }
  /**
   * @description 更新常用表信息,快捷添加后更新配置信息
   */
  updatetable = (config, fields) => {
    const { tableFields } = this.state
    config.tableFields = fields ? fields : tableFields
    this.setState({
      tableFields: fields ? fields : tableFields,
      config
    })
    this.props.modifyCustomMenu(config)
  }
  render () {
    const { activeKey, MenuType, popBtn, visible, dict, MenuId, config, ParentId, MenuName, MenuNo, menuloading, customComponents } = this.state
    return (
      <ConfigProvider locale={_locale}>
        <div className={'pc-menu-view ' + (MenuType || '')} id="view">
        <div className={'pc-menu-view ' + (MenuType || '')} id="mk-menu-design-view">
          <Header />
          {!popBtn && !visible ? <DndProvider backend={HTML5Backend}>
            <div className="menu-body">
@@ -906,7 +903,7 @@
                      updateConfig={this.updateConfig}
                    /> : null}
                    {/* 表名添加 */}
                    {config ? <TableComponent config={config} updatetable={this.updatetable}/> : null}
                    {config ? <TableComponent config={config} updatetable={this.updateConfig}/> : null}
                  </Panel>
                  {/* 组件添加 */}
                  <Panel header={dict['mob.component']} key="component">
@@ -928,10 +925,11 @@
                  <div> {config && config.MenuName} </div>
                } bordered={false} extra={
                  <div>
                    {/* <PictureController/> */}
                    <SysInterface config={config} updateConfig={this.updateConfig}/>
                    <PictureController/>
                    <StyleCombControlButton menu={config} />
                    <PasteController type="menu" Tab={null} insert={this.insert} />
                    {config ? <Switch className="big" checkedChildren={dict['mob.enable']} unCheckedChildren={dict['mob.disable']} checked={config.enabled} onChange={this.onEnabledChange} /> : null}
                    <Switch className="big" checkedChildren={dict['mob.enable']} unCheckedChildren={dict['mob.disable']} checked={config && config.enabled} onChange={this.onEnabledChange} />
                    <Button type="primary" onClick={this.submitConfig} loading={menuloading}>{dict['mob.save']}</Button>
                    <Button type="default" onClick={this.closeView}>{dict['mob.return']}</Button>
                  </div>