king
2023-10-24 c81296b147b3b6e578a241e21bae7bded4b5f6c6
2023-10-24
5个文件已修改
241 ■■■■■ 已修改文件
src/menu/components/table/normal-table/columns/index.jsx 2 ●●● 补丁 | 查看 | 原始文档 | blame | 历史
src/tabviews/custom/components/share/normalTable/index.jsx 81 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
src/tabviews/custom/components/table/edit-table/index.jsx 29 ●●●● 补丁 | 查看 | 原始文档 | blame | 历史
src/tabviews/custom/components/table/edit-table/normalTable/index.jsx 100 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
src/tabviews/custom/components/table/normal-table/index.jsx 29 ●●●● 补丁 | 查看 | 原始文档 | blame | 历史
src/menu/components/table/normal-table/columns/index.jsx
@@ -655,7 +655,7 @@
          <PlusOutlined style={{color: '#26C281'}} title="添加列" onClick={this.addColumns}/>
          <CopyOutlined title="复制显示列" onClick={this.copycolumn} />
          <MarkColumn columns={fields} type="line" marks={lineMarks} onSubmit={this.updateLineMarks} />
          <ColsControl config={config} onSubmit={this.props.updatecolumn}/>
          {appType !== 'mob' ? <ColsControl config={config} onSubmit={this.props.updatecolumn}/> : null}
          <FileSyncOutlined title="同步字段集" onClick={this.syncfield} />
          <DeleteOutlined title="清空显示列" onClick={this.clear}/>
        </div>
src/tabviews/custom/components/share/normalTable/index.jsx
@@ -442,7 +442,9 @@
    loading: PropTypes.bool,         // 表格加载中
    refreshdata: PropTypes.func,     // 表格中排序列、页码的变化时刷新
    chgSelectData: PropTypes.func,   // 数据切换
    autoMatic: PropTypes.any
    autoMatic: PropTypes.any,
    allSearch: PropTypes.any,
    colsCtrls: PropTypes.any
  }
  state = {
@@ -455,11 +457,13 @@
    rowspans: null,       // 行合并字段信息
    pickup: false,        // 收起未选择项
    orderfields: {},      // 排序id与field转换
    pageOptions: []
    pageOptions: [],
    allColumns: null,
    reseting: false
  }
  UNSAFE_componentWillMount () {
    const { setting, fields, columns } = this.props
    const { setting, columns, fields, colsCtrls } = this.props
    let radio = 5          // 虚化比例
    let _format = false    // 是否虚化处理
    let rowspans = []
@@ -483,7 +487,7 @@
          let cell = null
    
          if (item.type === 'colspan') {
            cell = { title: item.label, align: item.Align }
            cell = { title: item.label, align: item.Align, $key: item.uuid }
            cell.children = getColumns(item.subcols)
          } else {
            if (item.rowspan === 'true') {
@@ -507,6 +511,7 @@
            }
  
            cell = {
              $key: item.uuid,
              align: item.Align,
              dataIndex: item.uuid,
              title: item.label,
@@ -532,6 +537,7 @@
        fields.push(item.field)
        _columns.push({
          $key: item.uuid,
          align: item.Align,
          dataIndex: item.field,
          title: item.label,
@@ -564,9 +570,17 @@
      pageOptions = pageOptions.sort((a, b) => a - b)
    }
    let allColumns = null
    if (colsCtrls) {
      rowspans = null
      allColumns = [..._columns]
      _columns = this.getCurColumns(_columns, this.props.allSearch)
    }
    this.setState({
      pageSize: setting.pageSize || 10,
      pageOptions,
      allColumns,
      columns: _columns,
      rowspans,
      tableId,
@@ -582,6 +596,20 @@
  shouldComponentUpdate (nextProps, nextState) {
    return !is(fromJS(this.props), fromJS(nextProps)) || !is(fromJS(this.state), fromJS(nextState))
  }
  UNSAFE_componentWillReceiveProps(nextProps) {
    const { allSearch } = this.props
    const { allColumns } = this.state
    if (allSearch && !is(fromJS(allSearch), fromJS(nextProps.allSearch))) {
      this.setState({
        reseting: true,
        columns: this.getCurColumns(allColumns, nextProps.allSearch)
      }, () => {
        this.setState({reseting: false})
      })
    }
  }
  componentDidMount () {
@@ -610,6 +638,47 @@
    MKEmitter.removeListener('autoQueryData', this.autoQueryData)
    MKEmitter.removeListener('autoSelectData', this.autoSelectData)
    MKEmitter.removeListener('mkCheckTopLine', this.mkCheckTopLine)
  }
  getCurColumns = (columns, allSearch) => {
    const { colsCtrls } = this.props
    let values = {}
    allSearch.forEach(item => {
      values[item.key] = item.value
    })
    let cols = null
    colsCtrls.some(item => {
      let originVal = item.field.map(f => values[f] || '').join('')
      let contrastVal = item.contrastValue
      let result = false
      if (item.match === '=') {
        result = originVal === contrastVal
      } else if (item.match === '!=') {
        result = originVal !== contrastVal
      } else {
        originVal = isNaN(originVal) ? originVal : +originVal
        contrastVal = isNaN(contrastVal) ? contrastVal : +contrastVal
        if (item.match === '>') {
          result = originVal > contrastVal
        } else if (item.match === '<') {
          result = originVal < contrastVal
        }
      }
      if (!result) return false
      cols = item.cols
      return true
    })
    if (cols) {
      return columns.filter(col => cols.includes(col.$key))
    }
    return columns
  }
  autoSelectData = (id, index) => {
@@ -1004,7 +1073,9 @@
  render() {
    const { setting, statFValue, lineMarks, data } = this.props
    const { selectedRowKeys, activeIndex, pickup, tableId, pageOptions, columns } = this.state
    const { selectedRowKeys, activeIndex, pickup, tableId, pageOptions, columns, reseting } = this.state
    if (reseting) return null
    // 设置表格选择属性:单选、多选、不可选
    let rowSelection = null
src/tabviews/custom/components/table/edit-table/index.jsx
@@ -35,7 +35,8 @@
    pageIndex: 1,         // 页码
    pageSize: 10,         // 每页数据条数
    orderBy: '',          // 排序
    search: ''            // 搜索条件数组,使用时需分场景处理
    search: '',           // 搜索条件数组,使用时需分场景处理
    allSearch: null
  }
  /**
@@ -163,6 +164,18 @@
      _config.lineMarks = null
    }
    let allSearch = null
    if (_config.colsCtrls && _config.colsCtrls.length > 0) {
      allSearch = [{key: 'BID', value: BID || ''}]
      allSearch.push(..._config.$searches)
      if (_config.setting.useMSearch) {
        let mainSearch = window.GLOB.SearchBox.get(_config.$searchId) || []
        allSearch.push(...mainSearch)
      }
    } else {
      _config.colsCtrls = null
    }
    this.setState({
      pageSize: setting.pageSize || 10,
      BID: BID || '',
@@ -172,7 +185,8 @@
      setting: setting,
      actions: _config.action,
      columns: _columns,
      search: _config.$searches
      search: _config.$searches,
      allSearch
    }, () => {
      if (_config.setting.onload === 'true') {
        setTimeout(() => {
@@ -255,9 +269,16 @@
        total = data[data.length - 1].mk_total || 0
      }
      let allSearch = null
      if (config.colsCtrls) {
        allSearch = [{key: 'BID', value: BID || ''}]
        allSearch.push(...searches)
      }
      this.setState({
        data: data,
        selectedData: [],
        allSearch: allSearch,
        total: total,
        loading: false
      })
@@ -585,7 +606,7 @@
  }
  render() {
    const { BID, setting, actions, config, columns, BData, data, selectedData } = this.state
    const { BID, setting, actions, config, columns, BData, data, selectedData, allSearch } = this.state
    let style = {...config.style}
    if (config.wrap.empty === 'hidden' && data.length === 0) {
@@ -611,9 +632,11 @@
          setting={setting}
          columns={columns}
          MenuID={config.uuid}
          allSearch={allSearch}
          submit={config.submit}
          fields={config.columns}
          total={this.state.total}
          colsCtrls={config.colsCtrls}
          lineMarks={config.lineMarks}
          loading={this.state.loading}
          refreshdata={this.refreshbytable}
src/tabviews/custom/components/table/edit-table/normalTable/index.jsx
@@ -1128,6 +1128,8 @@
    loading: PropTypes.bool,         // 表格加载中
    refreshdata: PropTypes.func,     // 表格中排序列、页码的变化时刷新
    chgSelectData: PropTypes.func,
    allSearch: PropTypes.any,
    colsCtrls: PropTypes.any
  }
  state = {
@@ -1144,11 +1146,13 @@
    pageOptions: [],
    deForms: null,
    visible: false,
    midData: null
    midData: null,
    allColumns: null,
    reseting: false
  }
  UNSAFE_componentWillMount () {
    const { setting, fields, columns, BID } = this.props
    const { setting, fields, columns, BID, colsCtrls } = this.props
    let orderfields = {}
    let _columns = []
@@ -1162,7 +1166,7 @@
        let cell = null
  
        if (item.type === 'colspan') {
          cell = { title: item.label, align: item.Align }
          cell = { title: item.label, align: item.Align, $key: item.uuid }
          cell.children = getColumns(item.subcols)
        } else {
          if (item.editable === 'true') {
@@ -1217,7 +1221,8 @@
            title: item.editable === 'true' ? <span>{item.label}<EditOutlined className="system-color mk-edit-sign"/></span> : item.label,
            sorter: (item.field || item.sortField) && item.IsSort === 'true',
            width: item.Width || 120,
            $type: item.type,
            // $type: item.type,
            $key: item.uuid,
            onCell: record => ({
              record,
              col: item,
@@ -1257,9 +1262,16 @@
      pageOptions = pageOptions.sort((a, b) => a - b)
    }
    let allColumns = null
    if (colsCtrls) {
      allColumns = [..._columns]
      _columns = this.getCurColumns(_columns, this.props.allSearch)
    }
    this.setState({
      forms,
      signForms,
      allColumns,
      pageSize: setting.pageSize || 10,
      pageOptions,
      columns: _columns,
@@ -1321,6 +1333,47 @@
    MKEmitter.removeListener('changeRecord', this.changeRecord)
  }
  getCurColumns = (columns, allSearch) => {
    const { colsCtrls } = this.props
    let values = {}
    allSearch.forEach(item => {
      values[item.key] = item.value
    })
    let cols = null
    colsCtrls.some(item => {
      let originVal = item.field.map(f => values[f] || '').join('')
      let contrastVal = item.contrastValue
      let result = false
      if (item.match === '=') {
        result = originVal === contrastVal
      } else if (item.match === '!=') {
        result = originVal !== contrastVal
      } else {
        originVal = isNaN(originVal) ? originVal : +originVal
        contrastVal = isNaN(contrastVal) ? contrastVal : +contrastVal
        if (item.match === '>') {
          result = originVal > contrastVal
        } else if (item.match === '<') {
          result = originVal < contrastVal
        }
      }
      if (!result) return false
      cols = item.cols
      return true
    })
    if (cols) {
      return columns.filter(col => cols.includes(col.$key))
    }
    return columns
  }
  transferData = (menuid, data, type) => {
    const { MenuID, setting } = this.props
    const { edData, signForms } = this.state
@@ -1367,7 +1420,24 @@
  }
  updateMutil = (data) => {
    const { setting } = this.props
    const { setting, colsCtrls, allSearch } = this.props
    const { allColumns } = this.state
    if (colsCtrls) {
      this.setState({
        columns: this.getCurColumns(allColumns, allSearch),
        reseting: true,
        edData: data,
        visible: false,
        midData: null
      }, () => {
        this.setState({
          reseting: false
        })
      })
      return
    }
    if (setting.editType === 'multi' && data.length > 0) {
      this.setState({edData: []}, () => {
@@ -1561,7 +1631,21 @@
      return item
    })
    this.setState({columns: [], edData: []}, () => {
    let _cols = this.state.allColumns
    if (_cols) {
      _cols = _cols.map(item => {
        if (reCols[item.dataIndex]) {
          item.onCell = record => ({
            record,
            col: reCols[item.dataIndex]
          })
        }
        return item
      })
    }
    this.setState({columns: [], edData: [], allColumns: _cols}, () => {
      this.setState({columns: _edColumns, edData: edData})
    })
  }
@@ -2144,7 +2228,9 @@
  render() {
    const { setting, lineMarks, submit } = this.props
    const { tableId, edData, columns, loading, pageOptions, selectedRowKeys, visible, midData } = this.state
    const { tableId, edData, columns, loading, pageOptions, selectedRowKeys, visible, midData, reseting } = this.state
    if (reseting) return null
    const components = {
      body: {
src/tabviews/custom/components/table/normal-table/index.jsx
@@ -38,7 +38,8 @@
    pageSize: 10,         // 每页数据条数
    orderBy: '',          // 排序
    search: '',           // 搜索条件数组,使用时需分场景处理
    statFValue: []        // 合计值
    statFValue: [],       // 合计值
    allSearch: null
  }
  loaded = false
@@ -138,6 +139,18 @@
    _config.style = _config.style || {}
    let allSearch = null
    if (_config.colsCtrls && _config.colsCtrls.length > 0) {
      allSearch = [{key: 'BID', value: BID || ''}]
      allSearch.push(..._config.$searches)
      if (_config.setting.useMSearch) {
        let mainSearch = window.GLOB.SearchBox.get(_config.$searchId) || []
        allSearch.push(...mainSearch)
      }
    } else {
      _config.colsCtrls = null
    }
    this.setState({
      pageSize: setting.pageSize || 10,
      BID: BID || '',
@@ -148,7 +161,8 @@
      setting: setting,
      actions: _config.action,
      columns: _config.cols,
      search: _config.$searches
      search: _config.$searches,
      allSearch
    })
  }
@@ -467,9 +481,16 @@
        total = data[data.length - 1].mk_total || 0
      }
      let allSearch = null
      if (config.colsCtrls) {
        allSearch = [{key: 'BID', value: BID || ''}]
        allSearch.push(...searches)
      }
      this.setState({
        data: data,
        selectedData: [],
        allSearch: allSearch,
        total: total,
        loading: false
      })
@@ -801,7 +822,7 @@
  }
  render() {
    const { BID, setting, actions, config, columns, selectedData, BData, data } = this.state
    const { BID, setting, actions, config, columns, selectedData, BData, data, allSearch } = this.state
    let style = {...config.style}
    if (config.wrap.empty === 'hidden' && (!data || data.length === 0)) {
@@ -825,9 +846,11 @@
          setting={setting}
          columns={columns}
          MenuID={config.uuid}
          allSearch={allSearch}
          data={this.state.data}
          fields={config.columns}
          total={this.state.total}
          colsCtrls={config.colsCtrls}
          lineMarks={config.lineMarks}
          loading={this.state.loading}
          refreshdata={this.refreshbytable}