king
2019-12-16 c0930736f5b5955efecdac4c0ca85957d4f7b574
src/tabviews/commontable/index.jsx
@@ -162,7 +162,6 @@
    let deffers = []
    searchlist.forEach(item => {
      if (item.type !== 'select' && item.type !== 'link') return
      if (item.setAll === 'true') {
        item.options.unshift({
          key: Utils.getuuid(),
@@ -172,11 +171,15 @@
      }
      if (item.resourceType === '1' && item.dataSource) {
        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: item.valueField + ',' + item.valueText
          arr_field: arrfield
        }
        param.timestamp = moment().format('YYYY-MM-DD HH:mm:ss') + '.000'
@@ -231,35 +234,138 @@
  improveAction = () => {
    const { config } = this.state
    config.action.forEach(item => {
      if (item.OpenType !== 'pop' && item.OpenType !== 'tab' && item.OpenType !== 'blank') return
      Api.getSystemCacheConfig({
        func: 'sPC_Get_LongParam',
        MenuID: item.uuid
      }).then(res => {
        if (res.status) {
          let _LongParam = ''
          if (res.LongParam) {
            _LongParam = window.decodeURIComponent(window.atob(res.LongParam))
            try {
              _LongParam = JSON.parse(_LongParam)
            } catch (e) {
              _LongParam = ''
            }
          }
          this.setState({
            configMap: {...this.state.configMap, [item.uuid]: _LongParam}
    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)
          })
        } else {
        })
      })
      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: res.message,
            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
        })
      }
    })
  }
@@ -326,6 +432,7 @@
    this.setState({
      loading: true,
      pageIndex: 1,
      search: searches
    }, () => {
      this.loadmaindata()
@@ -353,15 +460,52 @@
    })
  }
  reloadtable = () => {
    this.refs.mainTable.resetTable()
    this.setState({
      loading: true,
      pageIndex: 1
    }, () => {
      this.loadmaindata()
    })
  }
  reloadview = () => {
    this.setState({
      loadingview: true,    // 页面加载中
      viewlost: false,      // 页面丢失:1、未获取到配置-页面丢失;2、页面未启用
      lostmsg: '',          // 页面丢失时的提示信息
      config: {},
      searchlist: null,
      actions: null,
      columns: null,
      arr_field: '',
      setting: null,
      data: null,
      total: 0,
      loading: false,
      pageIndex: 1,
      pageSize: 10,
      orderColumn: '',
      orderType: 'asc',
      search: '',
      configMap: {}
    }, () => {
      this.loadconfig()
    })
  }
  refreshbyaction = (btn, type) => {
    // 按钮操作后刷新表格,重置页码及选择项
    console.log(btn)
    console.log(type)
    this.refs.mainTable.resetTable()
    // this.loadmaindata(1, this.state.param.pageSize, this.state.param.orderColumn, this.state.param.orderType, this.state.param.search)
    // this.setState({
    //   loading: true
    // })
    if (btn.execSuccess === 'grid' && type === 'success') {
      this.reloadtable()
    } else if (btn.execError === 'grid' && type === 'error') {
      this.reloadview()
    } else if (btn.execSuccess === 'view' && type === 'success') {
      this.reloadtable()
    } else if (btn.execError === 'view' && type === 'error') {
      this.reloadview()
    }
  }
  gettableselected = () => {