king
2020-12-31 eebe63a6727e6495321d1433ebd2779b5a36d45a
src/tabviews/custom/components/table/normal-table/index.jsx
@@ -9,15 +9,15 @@
import zhCN from '@/locales/zh-CN/main.js'
import enUS from '@/locales/en-US/main.js'
import UtilsDM from '@/utils/utils-datamanage.js'
import asyncSpinComponent from '@/utils/asyncSpinComponent'
import asyncComponent from '@/utils/asyncComponent'
import MKEmitter from '@/utils/events.js'
import MainSearch from '@/tabviews/zshare/topSearch'
import './index.scss'
// 通用组件
const MainAction = asyncSpinComponent(() => import('@/tabviews/zshare/actionList'))
const MainTable = asyncSpinComponent(() => import('@/tabviews/custom/components/share/normalTable'))
const MainSearch = asyncComponent(() => import('@/tabviews/zshare/topSearch'))
const MainAction = asyncComponent(() => import('@/tabviews/zshare/actionList'))
const MainTable = asyncComponent(() => import('@/tabviews/custom/components/share/normalTable'))
const NormalHeader = asyncComponent(() => import('@/tabviews/custom/components/share/normalheader'))
class NormalTable extends Component {
  static propTpyes = {
@@ -121,6 +121,7 @@
   * @param { String }  repage 表格是否重置页码
   */
  async loadmaindata (reset, repage) {
    const { mainSearch } = this.props
    const { setting, config, arr_field, search, orderBy, BID, pageIndex, pageSize } = this.state
    let requireFields = search.filter(item => item.required && (!item.value || item.value.length === 0))
@@ -146,12 +147,22 @@
      return
    }
    let searches = fromJS(search).toJS()
    if (mainSearch && mainSearch.length > 0) { // 主表搜索条件
      let keys = searches.map(item => item.key.toLowerCase())
      mainSearch.forEach(item => {
        if (!keys.includes(item.key.toLowerCase())) {
          searches.push(item)
        }
      })
    }
    this.setState({
      loading: true
    })
    let _orderBy = orderBy || setting.order
    let param = UtilsDM.getQueryDataParams(setting, arr_field, search, _orderBy, pageIndex, pageSize, BID, this.props.menuType)
    let param = UtilsDM.getQueryDataParams(setting, arr_field, searches, _orderBy, pageIndex, pageSize, BID, this.props.menuType)
    if (param.func === 'sPC_Get_TableData') {
      param.menuname = config.name || ''
@@ -189,14 +200,25 @@
   * @description 获取单行数据
   */ 
  async loadmainLinedata (id) {
    const { mainSearch } = this.props
    const { setting, config, arr_field, search, orderBy, BID, pageIndex, pageSize } = this.state
    let searches = fromJS(search).toJS()
    if (mainSearch && mainSearch.length > 0) { // 主表搜索条件
      let keys = searches.map(item => item.key.toLowerCase())
      mainSearch.forEach(item => {
        if (!keys.includes(item.key.toLowerCase())) {
          searches.push(item)
        }
      })
    }
    this.setState({
      loading: true
    })
    let _orderBy = orderBy || setting.order
    let param = UtilsDM.getQueryDataParams(setting, arr_field, search, _orderBy, pageIndex, pageSize, BID, this.props.menuType, id)
    let param = UtilsDM.getQueryDataParams(setting, arr_field, searches, _orderBy, pageIndex, pageSize, BID, this.props.menuType, id)
    if (param.func === 'sPC_Get_TableData') {
      param.menuname = config.name || ''
@@ -244,6 +266,7 @@
   * @description 获取合计字段值
   */
  getStatFieldsValue = () => {
    const { mainSearch } = this.props
    const { setting, config, search, BID, orderBy, statFields } = this.state
    if (setting.supModule && !BID) { // BID 不存在时,不做查询
@@ -260,8 +283,18 @@
      return
    }
    let searches = fromJS(search).toJS()
    if (mainSearch && mainSearch.length > 0) { // 主表搜索条件
      let keys = searches.map(item => item.key.toLowerCase())
      mainSearch.forEach(item => {
        if (!keys.includes(item.key.toLowerCase())) {
          searches.push(item)
        }
      })
    }
    let _orderBy = orderBy || setting.order
    let param = UtilsDM.getStatQueryDataParams(setting, statFields, search, _orderBy, BID, this.props.menuType)
    let param = UtilsDM.getStatQueryDataParams(setting, statFields, searches, _orderBy, BID, this.props.menuType)
    if (param.func === 'sPC_Get_TableData') {
      param.menuname = config.name || ''
@@ -438,7 +471,7 @@
      })
      this.setState({sync: false, data: _data})
    } else if (!is(fromJS(this.props.mainSearch), fromJS(nextProps.mainSearch))) {
    } else if (nextProps.mainSearch && !is(fromJS(this.props.mainSearch), fromJS(nextProps.mainSearch))) {
      if (config.setting.syncRefresh === 'true') {
        this.setState({}, () => {
          this.reloadtable()
@@ -472,28 +505,20 @@
    return (
      <div className="custom-normal-table">
        {searchlist && searchlist.length > 0 ?
          <MainSearch
            BID={BID}
            dict={this.state.dict}
            searchlist={searchlist}
            menuType={this.props.menuType}
            refreshdata={this.refreshbysearch}
          /> : null
        <NormalHeader config={config}/>
        {searchlist && searchlist.length ?
          <MainSearch BID={BID} searchlist={searchlist} menuType={this.props.menuType} refreshdata={this.refreshbysearch}/> : null
        }
        <div className="commontable-main-action">
          <MainAction
            BID={BID}
            setting={setting}
            actions={actions}
            dict={this.state.dict}
            BData={this.state.BData}
            columns={config.columns}
            selectedData={selectedData}
            refreshdata={this.refreshbyaction}
            getexceloutparam={this.getexceloutparam}
          />
        </div>
        <MainAction
          BID={BID}
          setting={setting}
          actions={actions}
          BData={this.state.BData}
          columns={config.columns}
          selectedData={selectedData}
          refreshdata={this.refreshbyaction}
          getexceloutparam={this.getexceloutparam}
        />
        <div className="main-table-box">
          <MainTable
            setting={setting}