king
2019-12-12 f22bb55c4ff50a8a63c795487b057c0cebdae649
src/templates/comtableconfig/index.jsx
@@ -929,26 +929,15 @@
          }
        }
  
        if (this.state.operaType === 'add') {
          _config[res.type] = _config[res.type].map(item => {
            if (item.uuid === res.values.uuid) {
              isupdate = true
              return res.values
            } else {
              return item
            }
          })
          _config[res.type] = _config[res.type].filter(item => !item.origin)
        } else {
          _config[res.type] = _config[res.type].map(item => {
            if (item.uuid === res.values.uuid) {
              isupdate = true
              return res.values
            } else {
              return item
            }
          })
        }
        _config[res.type] = _config[res.type].map(item => {
          if (item.uuid === res.values.uuid) {
            isupdate = true
            return res.values
          } else {
            return item
          }
        })
        _config[res.type] = _config[res.type].filter(item => !item.origin)
  
        if (!isupdate) { // 操作不是修改,添加元素至列表
          _config[res.type].push(res.values)
@@ -1005,6 +994,126 @@
    }
  }
  creatFunc = () => {
    // let _config = JSON.parse(JSON.stringify(this.state.config))
    this.formRef.handleConfirm().then(res => {
      let btn = res.values
      let LText = ''
      if (!btn.innerFunc) {
        notification.warning({
          top: 92,
          message: '请填写内部函数!',
          duration: 10
        })
        return
      }
      new Promise(resolve => {
        // 内部请求
        if (btn.OpenType === 'pop') {
          Api.getSystemConfig({
            func: 'sPC_Get_LongParam',
            MenuID: btn.uuid
          }).then(res => {
            let _LongParam = ''
            if (res.status && res.LongParam) {
              _LongParam = window.decodeURIComponent(window.atob(res.LongParam))
              try {
                _LongParam = JSON.parse(_LongParam)
              } catch (e) {
                _LongParam = ''
              }
            }
            if (_LongParam) {
              resolve(_LongParam)
            } else {
              resolve(false)
              notification.warning({
                top: 92,
                message: '弹窗(表单)按钮,请先配置表单信息!',
                duration: 10
              })
            }
          })
        } else {
          resolve(true)
        }
      }).then(res => {
        if (!res) return
        LText = Utils.formatOptions(Utils.getfunc())
        console.log(LText)
        return Api.getSystemConfig({
          func: 'sPC_Get_TVP',
          TVPName: btn.innerFunc
        })
      }).then(res => {
        console.log(res)
        if (res.status) {
          return true
        } else {
          notification.warning({
            top: 92,
            message: res.message,
            duration: 10
          })
          return false
        }
      }).then(res => {
        console.log(res)
      })
      // let isupdate = false
      // _config.action = _config.action.map(item => {
      //   if (item.uuid === res.values.uuid) {
      //     isupdate = true
      //     return res.values
      //   } else {
      //     return item
      //   }
      // })
      // _config.action = _config.action.filter(item => !item.origin)
      // if (!isupdate) { // 操作不是修改,添加元素至列表
      //   _config.action.push(res.values)
      // }
      // 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,
      //   actionloading: true
      // }, () => {
      //   this.setState({
      //     actionloading: false
      //   })
      // })
    })
  }
  deleteElement = (element) => {
    let _this = this
    confirm({
@@ -1045,30 +1154,32 @@
    const { config, originMenu } = this.state
    this.menuformRef.handleConfirm().then(res => {
      config.search = config.search.filter(item => !item.origin)
      if (config.search[0] && config.search[0].origin) {
        notification.warning({
          top: 92,
          message: '请设置搜索条件',
          duration: 10
        })
        return
      }
      if (config.action[0] && config.action[0].origin) {
        notification.warning({
          top: 92,
          message: '请设置按钮',
          duration: 10
        })
        return
      }
      if (config.columns[0] && config.columns[0].origin) {
        notification.warning({
          top: 92,
          message: '请设置显示列',
          duration: 10
        })
        return
      }
      config.action = config.action.filter(item => !item.origin)
      config.columns = config.columns.filter(item => !item.origin)
      // if (config.search[0] && config.search[0].origin) {
      //   notification.warning({
      //     top: 92,
      //     message: '请设置搜索条件',
      //     duration: 10
      //   })
      //   return
      // }
      // if (config.action[0] && config.action[0].origin) {
      //   notification.warning({
      //     top: 92,
      //     message: '请设置按钮',
      //     duration: 10
      //   })
      //   return
      // }
      // if (config.columns[0] && config.columns[0].origin) {
      //   notification.warning({
      //     top: 92,
      //     message: '请设置显示列',
      //     duration: 10
      //   })
      //   return
      // }
      let _LongParam = ''
      let _config = {...config, tables: this.state.selectedTables}
@@ -1833,6 +1944,12 @@
          width={700}
          onCancel={() => { this.setState({ visible: false }) }}
          onOk={this.handleSubmit}
          footer={[
            this.state.formtemp === 'action' ?
            <Button key="delete" className="mk-btn mk-purple" onClick={this.creatFunc} loading={this.state.confirmLoading}>{this.state.dict['header.delete']}</Button> : null,
            <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' ?