king
2019-12-18 977ce3d348f898d64ea240c8397b83d3e1cc5bb4
src/tabviews/commontable/index.jsx
@@ -141,7 +141,6 @@
        loading: true
      }, () => {
        this.improveSearch()
        this.improveAction()
        this.loadmaindata()
      })
    } else {
@@ -232,142 +231,6 @@
    })
  }
  improveAction = () => {
    const { config } = this.state
    let conAction = config.action.filter(item => (item.OpenType === 'pop' || item.OpenType === 'tab' || item.OpenType === 'blank'))
    if (conAction.length > 0) {
      let deffers = conAction.map(item => {
        return new Promise(resolve => {
          Api.getSystemCacheConfig({
            func: 'sPC_Get_LongParam',
            MenuID: item.uuid
          }).then(res => {
            res.uuid = item.uuid
            resolve(res)
          })
        })
      })
      let _action = {}
      let error = ''
      Promise.all(deffers).then(result => {
        result.forEach(res => {
          if (res.status) {
            let _LongParam = ''
            if (res.LongParam) {
              _LongParam = window.decodeURIComponent(window.atob(res.LongParam))
              try {
                _LongParam = JSON.parse(_LongParam)
              } catch (e) {
                _LongParam = ''
              }
            }
            if (_LongParam) {
              _action[res.uuid] = _LongParam
            }
          } else {
            error = res
          }
        })
        this.setState({
          configMap: {...this.state.configMap, ..._action}
        })
        if (error) {
          notification.warning({
            top: 92,
            message: error.message,
            duration: 10
          })
        } else {
          this.improveActionForm(Object.values(_action))
        }
      })
    }
  }
  improveActionForm = (actions) => {
    let subfields = []
    actions.forEach(item => {
      if (item.groups.length > 0) {
        item.groups.forEach(group => {
          group.sublist.forEach(field => {
            if ((field.type === 'select' || field.type === 'link') && field.resourceType === '1') {
              subfields.push(field)
            }
          })
        })
      } else {
        item.fields.forEach(field => {
          if ((field.type === 'select' || field.type === 'link') && field.resourceType === '1') {
            subfields.push(field)
          }
        })
      }
    })
    let deffers = subfields.map(item => {
      let arrfield = item.valueField + ',' + item.valueText
      if (item.type === 'link') {
        arrfield = arrfield + ',' + item.linkField
      }
      let param = {
        func: 'sPC_Get_SelectedList',
        LText: item.dataSourceSql,
        obj_name: 'data',
        arr_field: arrfield
      }
      param.timestamp = moment().format('YYYY-MM-DD HH:mm:ss') + '.000'
      param.secretkey = Utils.encrypt(param.LText, param.timestamp)
      console.log(item)
      return new Promise(resolve => {
        Api.getSystemCacheConfig(param).then(res => {
          res.search = item
          resolve(res)
        })
      })
    })
    let _field = {}
    let error = ''
    Promise.all(deffers).then(result => {
      result.forEach(res => {
        if (res.status) {
          let options = res.data.map(cell => {
            return {
              key: Utils.getuuid(),
              Value: cell[res.search.valueField],
              Text: cell[res.search.valueText]
            }
          })
          _field[res.search.uuid] = options
        } else {
          error = res
        }
      })
      this.setState({
        configMap: {...this.state.configMap, ..._field}
      })
      if (error) {
        notification.warning({
          top: 92,
          message: error.message,
          duration: 10
        })
      }
    })
  }
  async loadmaindata () {
    const { arr_field, pageIndex, pageSize, orderColumn, orderType, search, setting } = this.state
@@ -543,7 +406,6 @@
          <MainAction
            MenuID={this.props.MenuID}
            setting={setting}
            configMap={this.state.configMap}
            refreshdata={this.refreshbyaction}
            gettableselected={this.gettableselected}
            actions={actions}