king
2020-01-22 c54724b0590729c677057736bd2d04715dc0c3fb
src/components/sidemenu/editthdmenu/index.jsx
@@ -41,23 +41,24 @@
  state = {
    dict: (!localStorage.getItem('lang') || localStorage.getItem('lang') === 'zh-CN') ? zhCN : enUS,
    thawmenulist: null,    // 已冻结的二级菜单
    type: '',              // 操作类型,新建或编辑菜单
    tabview: '',           // 选择模板窗口(template)、基础表格配置(CommonTable)、表单(Modal)、子表(SubTable)
    editMenu: null,        // 编辑菜单
    editAction: null,      // 编辑按钮
    editTab: null,         // 编辑标签
    thawMvisible: false,   // 解除冻结模态框
    confirmLoading: false, // 提交中。。。
    selectTemp: '',        // 选择模板
    usedTemplates: null,   // 已使用模板列表
    tempSearchKey: '',     // 菜单名称过滤值
    loading: false,        // 编辑菜单或使用已使用模板时,获取配置信息
    preview: null,         // 图片预览url
    pretemplate: null,     // 预览模板
    btnParam: null,        // 编辑按钮的配置信息
    menulist: null,        // 编辑中的菜单
    sysTemplates: sysTemps // 系统模板
    thawmenulist: null,     // 已冻结的二级菜单
    type: '',               // 操作类型,新建或编辑菜单
    thawMvisible: false,    // 解除冻结模态框
    confirmLoading: false,  // 提交中。。。
    selectTemp: '',         // 选择模板
    usedTemplates: null,    // 已使用模板列表
    tempSearchKey: '',      // 菜单名称过滤值
    loading: false,         // 编辑菜单或使用已使用模板时,获取配置信息
    preview: null,          // 图片预览url
    pretemplate: null,      // 预览模板
    btnParam: null,         // 编辑按钮的配置信息
    menulist: null,         // 编辑中的菜单
    sysTemplates: sysTemps, // 系统模板
    tabview: '',            // 选择模板窗口(template)、基础表格配置(CommonTable)、表单(Modal)、子表(SubTable)
    editMenu: null,         // 编辑菜单
    editAction: null,       // 编辑按钮
    editTab: null,          // 编辑标签
    subConfig: null         // 子配置信息
  }
  /**
@@ -177,7 +178,19 @@
        })
        return
      }
      this.setState({tabview: 'template', type: 'add'})
      this.setState({
        tabview: 'template',
        editMenu: {
          MenuID: '',
          MenuName: '',
          MenuNo: '',
          type: '',
          PageParam: '',
          LongParam: '',
          isSubtable: '', // 是否为主子表
          ParentID: this.props.supMenu.MenuID
        }
      })
      document.getElementById('root').style.overflowY = 'hidden'
    } else if (type === 'thaw') {
      if (!is(fromJS(this.props.menulist), fromJS(this.state.menulist))) {
@@ -325,8 +338,13 @@
    })
  }
  /**
   * @description 使用模板
   * 1、使用系统模板时,使用系统配置
   * 2、使用已有菜单模板时,获取菜单配置信息,标记为user(复制菜单按钮)
   */
  useTemplate = (template, useType) => {
    const { type, editMenu } = this.state
    const { editMenu } = this.state
    new Promise(resolve => {
      if (useType === 'sys') {
@@ -375,41 +393,30 @@
        })
      }
    }).then(res => {
      if (!res) {
      if (!res) { // 错误时,重置状态
        this.setState({
          loading: false
        })
        return
      }
      // 选择模板:添加菜单时
      if (type === 'add') {
        this.setState({
          tabview: template.type,
          loading: false,
          editMenu: {
            MenuID: Utils.getuuid(),
            MenuName: '',
            MenuNo: '',
            id: this.props.menulist.length,
            src: '',
            text: '',
            type: template.type,
            PageParam: {OpenType: 'newtab', Template: template.type},
            LongParam: template.baseconfig,
            isSubtable: template.isSubtable, // 是否为主子表
            ParentID: this.props.supMenu.MenuID
          }
        })
      } else {
        let _PageParam = {OpenType: editMenu.PageParam.OpenType || 'newtab', Template: template.type}
        this.setState({
          loading: false,
          tabview: template.type,
          editMenu: {...editMenu, LongParam: template.baseconfig, PageParam: _PageParam, type: template.type}
        })
      // 选择模板:添加菜单时(不存在menuId)
      let _PageParam = {
        OpenType: editMenu.PageParam ? editMenu.PageParam.OpenType : 'newtab',
        Template: template.type
      }
      this.setState({
        loading: false,
        tabview: template.type,
        editMenu: {
          ...editMenu,
          type: template.type,
          PageParam: _PageParam,
          LongParam: template.baseconfig,
          isSubtable: template.isSubtable
        }
      })
      document.getElementById('root').style.overflowY = 'hidden'
    })
  }
@@ -444,8 +451,17 @@
    }
  }
  tabHandleConfig = () => {
  handleView = (param) => {
    this.setState({
      tabview: ''
    }, () => {
      if (param) {
        this.setState(param)
        document.getElementById('root').style.overflowY = 'hidden'
      } else {
        document.getElementById('root').style.overflowY = 'unset'
      }
    })
  }
  handleSubConfig = (item, originMenu, config, type) => {
@@ -636,12 +652,10 @@
        </div>}
        {this.state.tabview === 'CommonTable' &&
          <ComTableConfig
            type={this.state.type}
            menu={this.state.editMenu}
            supMenuList={this.props.supMenuList}
            handleConfig={this.handleConfig}
            reloadmenu={() => {this.props.reload()}}
            handleSubConfig={this.handleSubConfig}
            handleView={this.handleView}
          />
        }
        {this.state.tabview === 'Modal' &&
@@ -649,16 +663,16 @@
            menu={this.state.editMenu}
            editTab={this.state.editTab}
            editAction={this.state.editAction}
            btnParam={this.state.btnParam}
            handleConfig={this.handleConfig}
            subConfig={this.state.subConfig}
            handleView={this.handleView}
          />
        }
        {this.state.tabview === 'SubTable' &&
          <SubTable
            config={this.state.editTab}
            menu={this.state.editMenu}
            handleConfig={this.handleConfig}
            handleSubConfig={this.handleSubConfig}
            editTab={this.state.editTab}
            config={this.state.subConfig}
            handleView={this.handleView}
          />
        }
        {this.state.tabview === 'FormTab' &&