king
2021-01-15 76a4300654a18d228838c3f27455dc8e7a8cd616
src/tabviews/subtable/index.jsx
@@ -35,7 +35,6 @@
    mainSearch: PropTypes.any,       // 主表搜索条件
    ContainerId: PropTypes.any,      // 三级菜单Container(html) ID
    handleTableId: PropTypes.func,   // 控制表格数据切换时,更新在主表中的id
    userConfig: PropTypes.any,       // 用户自定义设置
  }
  state = {
@@ -49,7 +48,7 @@
    columns: null,        // 显示列
    arr_field: '',        // 使用 sPC_Get_TableData 时的查询字段集
    setting: null,        // 页面全局设置:数据源、按钮及显示列固定、主键等
    data: null,           // 列表数据集
    data: [],             // 列表数据集
    selectedData: [],     // 已选表格数据
    total: 0,             // 总数
    loading: false,       // 列表数据加载中
@@ -92,7 +91,7 @@
   * @description 获取页面配置信息
   */
  async loadconfig () {
    const { permAction, permMenus, Tab, BID, userConfig } = this.props
    const { permAction, permMenus, Tab, BID } = this.props
    let param = {
      func: 'sPC_Get_LongParam',
@@ -176,28 +175,6 @@
      let chartId = config.charts[0] ? config.charts[0].uuid : ''
      if (userConfig) {
        config.action = config.action.map(item => {
          if (userConfig.action[item.uuid]) {
            delete userConfig.action[item.uuid].label
            item = {...item, ...userConfig.action[item.uuid]}
          }
          if (item.OpenType === 'funcbutton' && item.funcType === 'print' && item.verify && item.printer) {
            item.verify.defaultPrinter = item.printer.defaultPrinter || ''
            if (item.verify.printerTypeList && item.printer.printerList) {
              item.verify.printerTypeList = item.verify.printerTypeList.map(cell => {
                cell.printer = item.printer.printerList[cell.Value] || ''
                return cell
              })
            }
          }
          return item
        })
      }
      // 1、筛选字段集,2、过滤隐藏列及合并列中的字段uuid
      config.columns.forEach(col => {
        if (col.field) {
@@ -242,8 +219,10 @@
              subcols.push(colMap.get(sub))
            }
          })
          _col.subcols = subcols
          _columns.push(_col)
          if (subcols.length > 0) {
            _col.subcols = subcols
            _columns.push(_col)
          }
        } else {
          _columns.push(col)
        }
@@ -256,6 +235,20 @@
        item.logLabel = Tab.label + '-' + item.label // 用于sPC_TableData_InUpDe记录操作按钮
        item.$menuId = this.props.MenuID
        if (item.OpenType === 'funcbutton' && item.funcType === 'print' && item.verify) { // 打印机设置
          let _item = window.GLOB.UserCacheMap.get(Tab.uuid + item.uuid)
          if (_item) {
            item.verify.defaultPrinter = _item.printer || ''
            if (item.verify.printerTypeList && _item.printerList) {
              item.verify.printerTypeList = item.verify.printerTypeList.map(cell => {
                cell.printer = _item.printerList[cell.Value] || ''
                return cell
              })
            }
          }
        }
        if (item.position === 'toolbar') {
          _actions.push(item)
        } else if (item.position === 'grid') {
@@ -274,22 +267,6 @@
          valid = false
        }
      })
      // 添加用户显示列设置
      if (userConfig) {
        _columns = _columns.map(item => {
          if (userConfig.columns[item.uuid]) {
            delete userConfig.columns[item.uuid].label
            item = {...item, ...userConfig.columns[item.uuid]}
          }
          return item
        })
        _columns.sort((pre, next) => {
          return pre.sort - next.sort
        })
      }
      config.setting.tabType = 'sub'
      // 数据源信息预处理
@@ -428,6 +405,9 @@
            })
          }
          item.key = index
          item.$$uuid = item[setting.primaryKey] || ''
          item.$$BID = _BID || ''
          return item
        }),
        total: result.total,
@@ -489,6 +469,9 @@
          data = data.map(item => {
            if (item[setting.primaryKey] === _data[setting.primaryKey]) {
              _data.key = item.key
              _data.$$uuid = _data[setting.primaryKey] || ''
              _data.$$BID = BID || ''
              return _data
            } else {
              return item
@@ -642,31 +625,6 @@
  }
  /**
   * @description 按钮操作完成后(成功或失败),页面刷新,重置页码及选择项
   */
  refreshbyaction = (position, btn) => {
    const { Tab, SupMenuID, BID } = this.props
    if (position === 'grid' || position === 'view') {
      this.reloadtable(btn)
    } else if (position === 'maingrid' || position === 'mainline') {
      this.reloadtable(btn)
      if (Tab.supMenu === 'mainTable') {
        MKEmitter.emit('reloadData', SupMenuID, (BID || 'empty'))   // 主表重置
      } else if (Tab.supMenu) {
        MKEmitter.emit('reloadData', Tab.supMenu, (BID || 'empty')) // 主表重置
      } else if (!Tab.supMenu && Tab.level === 0) {
        MKEmitter.emit('reloadData', SupMenuID, (BID || 'empty'))   // 树形结构,0级标签
      }
    } else if (position === 'equaltab') {
      this.reloadtable(btn)
      if (Tab.equalTab && Tab.equalTab.length > 0) {
        MKEmitter.emit('reloadData', Tab.equalTab.join(',')) // 同级标签重置
      }
    }
  }
  /**
   * @description 导出Excel时,获取页面搜索排序等参数
   */
  getexceloutparam = (menuId, btnId) => {
@@ -720,7 +678,7 @@
    this.setState({chartId: uuid})
  }
  reloadData = (menuId, id) => {
  reloadData = (menuId, id) => { // Id存在时,刷新行
    const { MenuID } = this.props
    if (menuId.indexOf(MenuID) === -1) return
@@ -730,6 +688,38 @@
      this.reloadtable()
    } else {
      this.loadmainLinedata(id)
    }
  }
  /**
   * @description 按钮执行完成后页面刷新
   * @param {*} menuId     // 菜单Id
   * @param {*} position   // 刷新位置
   * @param {*} btn        // 执行的按钮
   */
  refreshByButtonResult = (menuId, position, btn) => {
    const { MenuID } = this.props
    if (MenuID !== menuId) return
    const { Tab, SupMenuID, BID } = this.props
    if (position === 'grid' || position === 'view') {
      this.reloadtable(btn)
    } else if (position === 'maingrid' || position === 'mainline') {
      this.reloadtable(btn)
      if (Tab.supMenu === 'mainTable') {
        MKEmitter.emit('reloadData', SupMenuID, (BID || 'empty'))   // 主表重置
      } else if (Tab.supMenu) {
        MKEmitter.emit('reloadData', Tab.supMenu, (BID || 'empty')) // 主表重置
      } else if (!Tab.supMenu && Tab.level === 0) {
        MKEmitter.emit('reloadData', SupMenuID, (BID || 'empty'))   // 树形结构,0级标签
      }
    } else if (position === 'equaltab') {
      this.reloadtable(btn)
      if (Tab.equalTab && Tab.equalTab.length > 0) {
        MKEmitter.emit('reloadData', Tab.equalTab.join(',')) // 同级标签重置
      }
    }
  }
@@ -745,6 +735,7 @@
  componentDidMount () {
    MKEmitter.addListener('reloadData', this.reloadData)
    MKEmitter.addListener('getexceloutparam', this.getexceloutparam)
    MKEmitter.addListener('refreshByButtonResult', this.refreshByButtonResult)
  }
  /**
@@ -756,6 +747,7 @@
    }
    MKEmitter.removeListener('reloadData', this.reloadData)
    MKEmitter.removeListener('getexceloutparam', this.getexceloutparam)
    MKEmitter.removeListener('refreshByButtonResult', this.refreshByButtonResult)
  }
  render() {
@@ -790,7 +782,6 @@
                      BData={this.props.BData}
                      MenuID={this.props.MenuID}
                      selectedData={selectedData}
                      refreshdata={this.refreshbyaction}
                      ContainerId={this.props.ContainerId}
                    />
                  </div>
@@ -804,18 +795,16 @@
                      setting={setting}
                      columns={columns}
                      pageSize={pageSize}
                      BID={this.props.BID}
                      dict={this.state.dict}
                      data={this.state.data}
                      BData={this.props.BData}
                      total={this.state.total}
                      MenuID={this.props.MenuID}
                      loading={this.state.loading}
                      refreshdata={this.refreshbytable}
                      statFValue={this.state.statFValue}
                      handleTableId={this.handleTableId}
                      ContainerId={this.props.ContainerId}
                      refreshbyaction={this.refreshbyaction}
                      refreshdata={this.refreshbytable}
                      handleTableId={this.handleTableId}
                      chgSelectData={this.changeSelectedData}
                    />
                  </div>
@@ -835,7 +824,6 @@
                    MenuID={this.props.MenuID}
                    loading={this.state.loading}
                    tableId={this.props.Tab.uuid}
                    refreshdata={this.refreshbyaction}
                    handleTableId={this.handleTableId}
                  />
                </Col>