king
2019-12-04 a5f99a5f0e2035851997221bc2430f8cfd1dc146
src/templates/comtableconfig/index.jsx
@@ -12,6 +12,7 @@
import ColumnForm from './columnform'
import ColspanForm from './colspanform'
import SettingForm from './settingform'
import GridBtnForm from './gridbtnform'
import EditCard from './editcard'
import MenuForm from './menuform'
import zhCN from '@/locales/zh-CN/comtable.js'
@@ -753,9 +754,24 @@
    }
  }
  handleGridBtn = () => {
    this.setState({
      visible: true,
      formtemp: 'gridbtn'
    })
  }
  /**
   * @description 搜索、按钮、显示列修改后提交保存
   * 1、搜索条件保存,当类型为下拉框且存在数据源时,将查询条件拼接为sql,并用base64转码
   * 2、按钮包括正常编辑和复制,复制时,按钮列末尾添加
   * 3、添加或编辑列,保存时,如按钮位置设置为表格,则修改操作列显示状态
   */
  handleSubmit = () => {
    let _config = JSON.parse(JSON.stringify(this.state.config))
    if (this.state.formtemp !== 'gridbtn') {
    this.formRef.handleConfirm().then(res => {
      let _config = this.state.config
      let isupdate = false
      if (res.type === 'search') {
@@ -793,16 +809,55 @@
        _config[res.type].push(res.values)
      }
        if (res.type === 'action') {
          let gridbtn = _config.action.filter(act => act.position === 'grid')
          let _display = false
          if (gridbtn.length > 0) {
            _display = true
          }
          if (_config.gridBtn) {
            _config.gridBtn.display = _display
          } else {
            _config.gridBtn = {
              display: _display,
              Align: 'center',
              IsSort: 'false',
              uuid: Utils.getuuid(),
              label: this.state.dict['header.form.column.action'],
              type: 'action',
              style: 'button',
              show: 'horizontal',
              Width: 120
            }
          }
        }
      this.setState({
        config: _config,
        [res.type + 'loading']: true,
          searchloading: true,
          actionloading: true,
          columnsloading: true,
        visible: false
      }, () => {
        this.setState({
          [res.type + 'loading']: false
            searchloading: false,
            actionloading: false,
            columnsloading: false
        })
      })
    })
    } else {
      this.formRef.handleConfirm().then(res => {
        _config.gridBtn = res
        this.setState({
          config: _config,
          visible: false
        })
      })
    }
  }
  deleteElement = (element) => {
@@ -1529,11 +1584,13 @@
                  <DragElement
                    list={this.state.config.columns}
                    setting={this.state.config.setting}
                    gridBtn={this.state.config.gridBtn}
                    type="columns"
                    placeholder={this.state.dict['header.form.column.placeholder']}
                    handleList={this.handleList}
                    handleMenu={this.handleColumn}
                    deleteMenu={this.deleteElement}
                    handleGridBtn={this.handleGridBtn}
                  /> : null
                }
              </div>
@@ -1547,11 +1604,6 @@
          width={700}
          onCancel={() => { this.setState({ visible: false }) }}
          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' ?
@@ -1586,6 +1638,13 @@
              wrappedComponentRef={(inst) => this.formRef = inst}
            /> : null
          }
          {this.state.formtemp === 'gridbtn' ?
            <GridBtnForm
              dict={this.state.dict}
              card={this.state.config.gridBtn}
              wrappedComponentRef={(inst) => this.formRef = inst}
            /> : null
          }
        </Modal>
        {/* 根据字段名添加显示列及搜索条件 */}
        <Modal