king
2019-12-03 343e35d61733028e884bc60963183983154ca093
src/templates/comtableconfig/index.jsx
@@ -10,6 +10,7 @@
import SearchForm from './searchform'
import ActionForm from './actionform'
import ColumnForm from './columnform'
import ColspanForm from './colspanform'
import SettingForm from './settingform'
import EditCard from './editcard'
import MenuForm from './menuform'
@@ -55,7 +56,8 @@
    closeVisible: false, // 关闭模态框
    tables: [], // 可用表名
    selectedTables: [], // 已选表名
    originMenu: null // 原始菜单
    originMenu: null, // 原始菜单
    originActions: null
  }
  /**
@@ -82,7 +84,13 @@
      _config = _LongParam
    }
    let _oriActions = _config.action
    if (_config.type === 'user' || _config.type === 'system') {
      _oriActions = []
    }
    this.setState({
      originActions: _oriActions,
      config: _config,
      operaType: _type,
      originMenu: JSON.parse(JSON.stringify({...menu})),
@@ -640,6 +648,7 @@
  }
  handleColumn = (card) => {
    if (card.type !== 'colspan') {
    this.setState({
      visible: true,
      formtemp: 'columns',
@@ -729,6 +738,13 @@
        }
      ]
    })
    } else {
      this.setState({
        visible: true,
        formtemp: 'columns',
        card: card
      })
    }
  }
  handleSubmit = () => {
@@ -783,23 +799,32 @@
    })
  }
  deleteElement = () => {
    let _config = this.state.config
    _config[this.state.formtemp] = _config[this.state.formtemp].filter(item => {
      if (item.uuid === this.state.card.uuid) {
  deleteElement = (element) => {
    let _this = this
    confirm({
      content: `确定删除<<${element.card.label}>>吗?`,
      okText: this.state.dict['header.confirm'],
      cancelText: this.state.dict['header.cancel'],
      onOk() {
        let _config = JSON.parse(JSON.stringify(_this.state.config))
        _config[element.type] = _config[element.type].filter(item => {
          if (item.uuid === element.card.uuid) {
        return false
      } else {
        return true
      }
    })
    this.setState({
        _this.setState({
      config: _config,
      [this.state.formtemp + 'loading']: true,
          [element.type + 'loading']: true,
      visible: false
    }, () => {
      this.setState({
        [this.state.formtemp + 'loading']: false
          _this.setState({
            [element.type + 'loading']: false
      })
        })
      },
      onCancel() {}
    })
  }
@@ -807,6 +832,9 @@
    this.props.handleConfig('template')
  }
  /**
   * @description 三级菜单保存
   */
  submitConfig = () => {
    const { menu } = this.props
    const { config, originMenu } = this.state
@@ -841,6 +869,9 @@
      let _config = {...config, tables: this.state.selectedTables}
      let _pageParam = {...menu.PageParam, OpenType: res.opentype}
      // 保存时删除配置类型,system 、user
      delete _config.type
      try {
        _LongParam = window.btoa(window.encodeURIComponent(JSON.stringify(_config)))
      } catch (e) {
@@ -852,7 +883,7 @@
        return
      }
      if (this.state.operaType === 'add') {
      if (this.state.operaType === 'add') { // 新建菜单
        let param = {
          func: 'sPC_TrdMenu_Add',
          ParentID: res.parentId,
@@ -897,7 +928,7 @@
            })
          }
        })
      } else {
      } else { // 修改菜单
        let param = {
          func: 'sPC_TrdMenu_Upt',
          ParentID: res.parentId,
@@ -953,6 +984,15 @@
        duration: 10
      })
    })
  }
  /**
   * @description 保存或修改菜单按钮
   */
  submitAction = () => {
    if (!is(fromJS(this.state.originActions), fromJS())) {
    }
  }
  cancelConfig = () => {
@@ -1461,6 +1501,7 @@
                    placeholder={this.state.dict['header.form.search.placeholder']}
                    handleList={this.handleList}
                    handleMenu={this.handleSearch}
                    deleteMenu={this.deleteElement}
                  /> : null
                }
              </div>
@@ -1473,6 +1514,7 @@
                    handleList={this.handleList}
                    handleMenu={this.handleAction}
                    copyElement={this.handleAction}
                    deleteMenu={this.deleteElement}
                  /> : null
                }
              </div>
@@ -1485,6 +1527,7 @@
                    placeholder={this.state.dict['header.form.column.placeholder']}
                    handleList={this.handleList}
                    handleMenu={this.handleColumn}
                    deleteMenu={this.deleteElement}
                  /> : null
                }
              </div>
@@ -1497,11 +1540,12 @@
          visible={this.state.visible}
          width={700}
          onCancel={() => { this.setState({ visible: false }) }}
          footer={[
            <Button key="delete" type="danger" onClick={this.deleteElement}>{this.state.dict['header.delete']}</Button>,
            <Button key="cancel" onClick={() => { this.setState({ visible: false }) }}>{this.state.dict['header.cancel']}</Button>,
            <Button key="confirm" type="primary" onClick={this.handleSubmit}>{this.state.dict['header.confirm']}</Button>
          ]}
          onOk={this.handleSubmit}
          // footer={[
          //   <Button key="delete" type="danger" onClick={this.deleteElement}>{this.state.dict['header.delete']}</Button>,
          //   <Button key="cancel" onClick={() => { this.setState({ visible: false }) }}>{this.state.dict['header.cancel']}</Button>,
          //   <Button key="confirm" type="primary" onClick={this.handleSubmit}>{this.state.dict['header.confirm']}</Button>
          // ]}
          destroyOnClose
        >
          {this.state.formtemp === 'search' ?
@@ -1520,7 +1564,7 @@
              wrappedComponentRef={(inst) => this.formRef = inst}
            /> : null
          }
          {this.state.formtemp === 'columns' ?
          {this.state.formtemp === 'columns' && this.state.card.type !== 'colspan' ?
            <ColumnForm
              dict={this.state.dict}
              card={this.state.card}
@@ -1528,6 +1572,14 @@
              wrappedComponentRef={(inst) => this.formRef = inst}
            /> : null
          }
          {this.state.formtemp === 'columns' && this.state.card.type === 'colspan' ?
            <ColspanForm
              dict={this.state.dict}
              card={this.state.card}
              columns={this.state.config.columns}
              wrappedComponentRef={(inst) => this.formRef = inst}
            /> : null
          }
        </Modal>
        {/* 根据字段名添加显示列及搜索条件 */}
        <Modal