king
2024-12-04 ca8a314835a4048b22af5f548b0529aaa9b9ab36
2024-12-04
10个文件已修改
429 ■■■■■ 已修改文件
src/menu/components/table/normal-table/options.jsx 61 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
src/tabviews/custom/components/share/normalTable/index.jsx 203 ●●●● 补丁 | 查看 | 原始文档 | blame | 历史
src/tabviews/custom/components/share/normalTable/index.scss 37 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
src/tabviews/custom/components/table/base-table/index.jsx 6 ●●●● 补丁 | 查看 | 原始文档 | blame | 历史
src/tabviews/custom/components/table/normal-table/index.jsx 96 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
src/tabviews/custom/index.jsx 10 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
src/tabviews/custom/popview/index.jsx 10 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
src/tabviews/zshare/actionList/printbutton/index.jsx 2 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
src/templates/zshare/verifycard/index.jsx 2 ●●● 补丁 | 查看 | 原始文档 | blame | 历史
src/utils/utils-custom.js 2 ●●● 补丁 | 查看 | 原始文档 | blame | 历史
src/menu/components/table/normal-table/options.jsx
@@ -389,6 +389,67 @@
      forbid: !!appType || isprint
    },
    {
      type: 'radio',
      field: 'tree',
      label: '结构树',
      initval: wrap.tree || 'false',
      tooltip: '使用结构树时,显示列首列请使用文本类型。',
      required: false,
      options: [
        {value: 'true', label: '启用'},
        {value: 'false', label: '禁用'},
      ],
      controlFields: [
        {field: 'valueField', values: ['true']},
        {field: 'parentField', values: ['true']},
        {field: 'mark', values: ['true']},
        {field: 'defOpen', values: ['true']},
      ],
      forbid: appType === 'mob' || isprint
    },
    {
      type: 'select',
      field: 'valueField',
      label: '值字段',
      initval: wrap.valueField || '',
      tooltip: '数据值字段,结构树中节点ID值,与上级字段配合组织数据的上下级关系。',
      required: true,
      options: columns,
      forbid: appType === 'mob' || isprint
    },
    {
      type: 'select',
      field: 'parentField',
      label: '上级字段',
      initval: wrap.parentField || '',
      tooltip: '上级字段,用于组织数据的上下级关系。',
      required: true,
      options: columns,
      forbid: appType === 'mob' || isprint
    },
    {
      type: 'text',
      field: 'mark',
      label: '顶级标识',
      initval: wrap.mark || '',
      tooltip: '上级字段值与顶级标识相同时,视为顶级节点。',
      required: false,
      forbid: appType === 'mob' || isprint
    },
    {
      type: 'radio',
      field: 'defOpen',
      label: '默认展开',
      initval: wrap.defOpen || '',
      required: false,
      options: [
        {value: '', label: '无'},
        {value: 'topline', label: '首行'},
        {value: 'all', label: '全部'},
      ],
      forbid: appType === 'mob' || isprint
    },
    {
      type: 'multiselect',
      field: 'blacklist',
      label: '黑名单',
src/tabviews/custom/components/share/normalTable/index.jsx
@@ -2,7 +2,8 @@
import PropTypes from 'prop-types'
import md5 from 'md5'
import { is, fromJS } from 'immutable'
import { Table, Typography, Col, Switch, message } from 'antd'
import { Table, Typography, Col, Switch, message, Pagination } from 'antd'
import { CaretRightOutlined, CaretDownOutlined } from '@ant-design/icons'
import asyncComponent from '@/utils/asyncComponent'
import { getMark } from '@/utils/utils.js'
@@ -152,7 +153,7 @@
  }
  render() {
    let { col, config, record, className, style, ...resProps } = this.props
    let { col, config, record, className, style, openChange, ...resProps } = this.props
    if (!col) return (<td {...resProps} className={className} style={style}/>)
@@ -209,6 +210,21 @@
      if (col.rowspan === 'true') {
        resProps.rowSpan = record['$$' + col.field]
      }
      if (col.$tree && record.$mk_floor) {
        className += ' mk-tree-td'
        if (record.$open) {
          content = <>
            <span className="mk-tree-node" style={{width: `calc(var(--tree-node-width) * ${record.$mk_floor})`}}><CaretRightOutlined onClick={(e) => openChange(e, record.$key)} /><CaretDownOutlined onClick={(e) => openChange(e, record.$key)}/></span>
            {content}
          </>
        } else {
          content = <>
            <span className="mk-tree-node" style={{width: `calc(var(--tree-node-width) * ${record.$mk_floor})`}}></span>
            {content}
          </>
        }
      }
      
      resProps.children = content
@@ -539,11 +555,12 @@
    orderfields: {},      // 排序id与field转换
    pageOptions: [],
    allColumns: null,
    reseting: false
    reseting: false,
    openkeys: []
  }
  UNSAFE_componentWillMount () {
    const { setting, columns, fields, colsCtrls } = this.props
    const { setting, columns, fields, colsCtrls, data } = this.props
    let radio = 5          // 虚化比例
    let _format = false    // 是否虚化处理
    let rowspans = []
@@ -594,6 +611,7 @@
                record,
                col: item,
                config: item.type === 'custom' ? {setting, columns: fields} : null,
                openChange: item.$tree ? this.openChange : null,
              })
            }
          }
@@ -653,6 +671,10 @@
      _columns = this.getCurColumns(_columns, this.props.allSearch)
    }
    if (setting.$tree) {
      this.resetOpenKeys(data)
    }
    this.setState({
      pageSize: setting.pageSize || 10,
      pageOptions,
@@ -669,7 +691,7 @@
  }
  UNSAFE_componentWillReceiveProps(nextProps) {
    const { allSearch, parCtrl } = this.props
    const { allSearch, parCtrl, setting, data } = this.props
    const { allColumns } = this.state
    if (allSearch && !is(fromJS(allSearch), fromJS(nextProps.allSearch))) {
@@ -698,6 +720,7 @@
                record,
                col: item,
                config: item.type === 'custom' ? {setting: this.props.setting, columns: this.props.fields} : null,
                openChange: item.$tree ? this.openChange : null,
              })
            }
          }
@@ -709,6 +732,10 @@
      this.setState({
        columns: getColumns(nextProps.columns)
      })
    }
    if (setting.$tree && !is(fromJS(data), fromJS(nextProps.data))) {
      this.resetOpenKeys(nextProps.data)
    }
  }
@@ -738,6 +765,83 @@
    MKEmitter.removeListener('autoQueryData', this.autoQueryData)
    MKEmitter.removeListener('autoSelectData', this.autoSelectData)
    MKEmitter.removeListener('mkCheckTopLine', this.mkCheckTopLine)
  }
  resetOpenKeys = (data) => {
    const { setting } = this.props
    if (!data || data.length === 0 || !setting.defOpen) {
      this.setState({openkeys: []})
    } else if (setting.defOpen === 'topline') {
      let keys = []
      if (data[0].$open) {
        keys = [data[0].$key]
        data.forEach(item => {
          if (item.$pkeys && item.$pkeys.length > 1 && item.$pkeys.includes(data[0].$key)) {
            keys.push(...item.$pkeys)
          }
        })
        keys = Array.from(new Set(keys))
      }
      this.setState({openkeys: keys})
    } else {
      this.setState({openkeys: data.filter(item => !!item.$open).map(item => item.$key)})
    }
  }
  openChange = (e, key) => {
    const { setting, MenuID, data } = this.props
    const { openkeys, selectedRowKeys } = this.state
    e.stopPropagation()
    let _openkeys = []
    if (openkeys.includes(key)) {
      _openkeys = openkeys.filter(k => k !== key)
    } else {
      _openkeys = [...openkeys, key]
    }
    if (!setting.tableType || _openkeys.length > openkeys.length) {
      this.setState({openkeys: _openkeys})
      return
    }
    let newkeys = fromJS(selectedRowKeys).toJS()
    newkeys = newkeys.filter(k => {
      if (!data[k]) return false
      if (!data[k].$pkeys) return true
      return data[k].$pkeys.every(key => _openkeys.includes(key))
    })
    if (newkeys.length === selectedRowKeys.length) {
      this.setState({openkeys: _openkeys})
      return
    }
    let _index = ''
    if (newkeys.length > 0) {
      _index = newkeys.slice(-1)[0]
    }
    this.changedata(_index)
    this.setState({ openkeys: _openkeys, selectedRowKeys: newkeys, activeIndex: _index !== '' ? _index : null })
    let selects = data.filter((item, _index) => newkeys.includes(_index))
    this.props.chgSelectData(selects)
    if (setting.$hasSyncModule) {
      MKEmitter.emit('syncBalconyData', MenuID, selects, false)
    }
  }
  getCurColumns = (columns, allSearch) => {
@@ -974,21 +1078,44 @@
  }
  changeTable = (pagination, filters, sorter) => {
    const { orderfields } = this.state
    this.setState({
      pageIndex: pagination.current,
      pageSize: pagination.pageSize,
      selectedRowKeys: [],
      activeIndex: null,
      pickup: false
    })
    const { setting } = this.props
    const { orderfields, pageSize } = this.state
    if (orderfields) {
      sorter.field = orderfields[sorter.field] || ''
    }
    this.props.refreshdata(pagination, filters, sorter)
    if (setting.$tree) {
      this.setState({
        pageIndex: 1,
        selectedRowKeys: [],
        activeIndex: null,
        pickup: false
      })
      this.props.refreshdata({current: 1, pageSize: pageSize}, sorter)
    } else {
      this.setState({
        pageIndex: pagination.current,
        pageSize: pagination.pageSize,
        selectedRowKeys: [],
        activeIndex: null,
        pickup: false
      })
      this.props.refreshdata(pagination, sorter)
    }
  }
  onPaginationChange = (current, pageSize) => {
    this.setState({
      pageIndex: current,
      pageSize: pageSize,
      selectedRowKeys: [],
      activeIndex: null
    })
    this.props.refreshdata({current: current, pageSize: pageSize, fixed: true}, {})
  }
  changedata = (index) => {
@@ -1125,7 +1252,7 @@
  render() {
    const { setting, statFValue, lineMarks, data } = this.props
    const { selectedRowKeys, activeIndex, pickup, pageOptions, columns, reseting } = this.state
    const { selectedRowKeys, activeIndex, pickup, pageOptions, columns, reseting, openkeys } = this.state
    if (reseting) return null
@@ -1152,14 +1279,16 @@
    // 数据收起时,过滤已选数据
    let _data = data || []
    if (pickup) {
      _data = _data.filter((item, index) => selectedRowKeys.includes(index))
    if (!setting.$tree) {
      if (pickup) {
        _data = _data.filter((item, index) => selectedRowKeys.includes(index))
      }
      _data = this.handleRowspan(_data)
    }
    _data = this.handleRowspan(_data)
    
    let _pagination = false
    if (setting.laypage !== 'false' && setting.laypage !== false) {
    if (setting.laypage && !setting.$tree) {
      _pagination = {
        current: this.state.pageIndex,
        pageSize: this.state.pageSize,
@@ -1210,7 +1339,7 @@
    return (
      <div className={`normal-custom-table ${setting.tableHeader || ''} ${setting.parity === 'true' ? 'mk-parity' : ''} ${height ? 'fixed-table-height' : ''} ${setting.mode || ''} table-vertical-${setting.vertical || 'middle'} table-col-${columns.length} ${fixed} ${setting.empSign === 'hidden' ? 'mk-empty-hide' : ''}`} style={style}>
        {(setting.tableType === 'radio' || setting.tableType === 'checkbox') && data && data.length > 0 ?
        {(setting.tableType === 'radio' || setting.tableType === 'checkbox') && data && data.length > 0 && !setting.$tree ?
          <Switch title="收起" className="main-pickup" checkedChildren={window.GLOB.dict['open'] || '开'} unCheckedChildren={window.GLOB.dict['shut'] || '关'} checked={pickup} onChange={this.pickupChange} /> : null
        }
        <Table
@@ -1223,11 +1352,26 @@
          loading={loading}
          scroll={{ x: '100%', y: height }}
          onRow={(record, index) => {
            let className = ''
            if (index === activeIndex) {
              className = ' mk-row-active '
            }
            if (setting.$tree) {
              if (record.$open && openkeys.includes(record.$key)) {
                className += ' mk-tree-open '
              }
              if (record.$pkeys && !record.$pkeys.every(key => openkeys.includes(key))) {
                className += ' mk-tree-hide '
              }
            }
            return {
              lineMarks: setting.tableMode !== 'fast' ? lineMarks : null,
              lineMarks: lineMarks,
              data: record,
              title: setting.tipField ? record[setting.tipField] : '',
              className: index === activeIndex ? ' mk-row-active ' : '',
              className: className,
              onClick: () => {this.changeRow(record, index)},
              onDoubleClick: () => {this.doubleClickLine(record)}
            }
@@ -1235,6 +1379,17 @@
          onChange={this.changeTable}
          pagination={_pagination}
        />
        {setting.laypage && setting.$tree ? <Pagination
          showSizeChanger
          className="mk-tree-pagination"
          onChange={this.onPaginationChange}
          onShowSizeChange={this.onPaginationChange}
          current={this.state.pageIndex}
          pageSize={this.state.pageSize}
          pageSizeOptions={pageOptions}
          total={this.props.total || 0}
          showTotal={(total, range) => `${range[0]}-${range[1]} ${window.GLOB.dict['of'] || '共'} ${total} ${window.GLOB.dict['items'] || '条'}`}
        /> : null}
        {_footer ? <div className={'normal-table-footer ' + (_pagination ? 'pagination' : '')}>{_footer}</div> : null}
      </div>
    )
src/tabviews/custom/components/share/normalTable/index.scss
@@ -200,6 +200,43 @@
  table tbody tr {
    color: var(--mk-table-color);
  }
  .mk-tree-node {
    display: inline-block;
    text-align: right;
    --tree-node-width: 18px;
    .anticon-caret-right, .anticon-caret-down {
      cursor: pointer;
      padding-right: 3px;
    }
    .anticon-caret-down {
      display: none;
    }
  }
  .mk-tree-open {
    .mk-tree-node {
      .anticon-caret-right {
        display: none;
      }
      .anticon-caret-down {
        display: inline-block;
      }
    }
  }
  .mk-tree-hide {
    display: none;
  }
  .mk-tree-td {
    overflow: hidden;
    word-break: break-word;
    white-space: nowrap;
    text-overflow: ellipsis;
  }
  .mk-tree-pagination {
    float: right;
    margin: 16px 0;
  }
}
.normal-custom-table.mk-parity {
  .ant-table-tbody tr:nth-child(even) {
src/tabviews/custom/components/table/base-table/index.jsx
@@ -73,6 +73,10 @@
      _config.setting.onload = 'false'
    }
    if (setting.tableMode === 'fast') {
      _config.lineMarks = null
    }
    _config.style = _config.style || {}
    this.setState({
@@ -454,7 +458,7 @@
  /**
   * @description 表格条件改变时重置数据(分页或排序)
   */
  refreshbytable = (pagination, filters, sorter) => {
  refreshbytable = (pagination, sorter) => {
    if (!sorter) { // 无人值守
      this.setState({
        pageIndex: pagination.pageIndex
src/tabviews/custom/components/table/normal-table/index.jsx
@@ -153,6 +153,10 @@
      _config.colsCtrls = null
    }
    if (setting.$tree && _config.cols[0]) {
      _config.cols[0].$tree = true
    }
    let columns = _config.cols
    if (_config.hasExtend) {
      columns = this.getCols(_config.cols, BData, _config.setting.extendTime)
@@ -610,6 +614,10 @@
        return item
      })
      if (setting.$tree && data.length) {
        data = this.getTree(data)
      }
      let total = result.total || 0
      if (config.setting.custompage && data.length) {
        total = data[data.length - 1].mk_total || 0
@@ -665,6 +673,90 @@
      
      UtilsDM.queryFail(result)
    }
  }
  getTree = (data) => {
    const { setting } = this.state
    let options = []
    let pnodes = []
    let _data = []
    data.forEach(item => {
      let pval = item[setting.parentField] + ''
      let val = item[setting.valueField] + ''
      if (pval === setting.mark) {
        pnodes.push({
          ...item,
          $mk_floor: 1,
          $key: val,
          $pid: ''
        })
      } else if (pval) {
        options.push({
          ...item,
          $mk_floor: 0,
          $key: val,
          $pid: pval
        })
      }
    })
    let get_tree = (parents) => {
      parents.forEach(parent => {
        parent.children = []
        options = options.filter(option => {
          if (option.$pid === parent.$key) {
            option.$mk_floor = parent.$mk_floor + 1
            option.$pkeys = parent.$pkeys ? [...parent.$pkeys, parent.$key] : [parent.$key]
            parent.children.push(option)
            return false
          }
          return true
        })
        if (parent.children.length === 0) {
          parent.children = null
        } else {
          parent.$open = true
          parent.children = get_tree(parent.children)
        }
      })
      return parents
    }
    let tree = get_tree(pnodes)
    let get_data = (parents) => {
      parents.forEach(parent => {
        let children = parent.children
        delete parent.children
        _data.push(parent)
        if (children) {
          get_data(children)
        }
      })
    }
    get_data(tree)
    if (options.length) {
      _data.push(...options)
    }
    _data = _data.map((item, index) => {
      item.key = index
      return item
    })
    return _data
  }
  /**
@@ -825,7 +917,7 @@
  /**
   * @description 表格条件改变时重置数据(分页或排序)
   */
  refreshbytable = (pagination, filters, sorter) => {
  refreshbytable = (pagination, sorter) => {
    if (sorter.order) {
      let _chg = {
        ascend: 'asc',
@@ -837,7 +929,7 @@
    this.setState({
      pageIndex: pagination.current,
      pageSize: pagination.pageSize,
      orderBy: (sorter.field && sorter.order) ? `${sorter.field} ${sorter.order}` : ''
      orderBy: (sorter.field && sorter.order) ? `${sorter.field} ${sorter.order}` : (pagination.fixed ? this.state.orderBy : '')
    }, () => {
      this.loadData()
    })
src/tabviews/custom/index.jsx
@@ -702,6 +702,12 @@
          item.colsCtrls = null
        }
        if (item.wrap.tree === 'true') {
          item.setting.sync = 'false'
          item.$cache = false
          item.setting.$tree = true
        }
        if (item.subtype === 'editable') {
          item.submit.logLabel = item.$menuname + '-提交'
          item.submit.$menuId = item.uuid
@@ -922,6 +928,10 @@
          item.setting.custompage = /@pageSize@|@orderBy@|@mk_total/i.test(item.setting.dataresource + item.setting.customScript)
          if (item.setting.$tree) {
            item.setting.custompage = true
          }
          if (!item.setting.execute || item.setting.custompage) {
            item.forbidLine = true
          }
src/tabviews/custom/popview/index.jsx
@@ -420,6 +420,12 @@
          item.colsCtrls = null
        }
        if (item.wrap.tree === 'true') {
          item.setting.sync = 'false'
          item.$cache = false
          item.setting.$tree = true
        }
        if (item.subtype === 'editable') {
          item.submit.logLabel = item.$menuname + '-提交'
          item.submit.$menuId = item.uuid
@@ -618,6 +624,10 @@
          item.setting.custompage = /@pageSize@|@orderBy@|@mk_total/i.test(item.setting.dataresource + item.setting.customScript)
          if (item.setting.$tree) {
            item.setting.custompage = true
          }
          if (!item.setting.execute || item.setting.custompage) {
            item.forbidLine = true
          }
src/tabviews/zshare/actionList/printbutton/index.jsx
@@ -180,6 +180,7 @@
      let modal = this.state.btnconfig
      if (!modal && btn.modal) {
        modal = this.handleModelConfig(btn.modal)
        modal.uuid = btn.uuid
      }
      this.setState({
@@ -2129,6 +2130,7 @@
        } else {
          _LongParam = updateForm(_LongParam)
          _LongParam = this.handleModelConfig(_LongParam)
          _LongParam.uuid = btn.uuid
          this.setState({
            btnconfig: _LongParam
src/templates/zshare/verifycard/index.jsx
@@ -1928,7 +1928,7 @@
      _sql = _insertsql
    } else if (_actionType === 'update' || _actionType === 'audit') {
      _sql = _updatesql
    } else if (_actionType === 'LogicDelete') { // 逻辑删除
    } else if (_actionType === 'LogicDelete' || _actionType === 'custom') { // 逻辑删除
      let _ID = '=@ID@'
      if (btn.Ot === 'requiredOnce') {
        _ID = ' in (select ID from  dbo.SplitComma(@ID@))'
src/utils/utils-custom.js
@@ -4890,7 +4890,7 @@
    let DateCount = ''
    if (_dataresource) {
      /*system_query*/
      if (/@pageSize@|@orderBy@|@mk_total/i.test(testSql)) {
      if (/@pageSize@|@orderBy@|@mk_total/i.test(testSql) || (item.wrap && item.wrap.tree === 'true')) {
        LText = `select ${arr_field} from ${_dataresource} ${_search} `
      } else if (item.setting.laypage === 'true' && item.setting.order) {
        LText = `select top @pageSize@ ${arr_field} from (select ${arr_field} ,ROW_NUMBER() over(order by @orderBy@) as rows from ${_dataresource} ${_search}) tmptable where rows > @pageSize@ * (@pageIndex@ - 1) order by tmptable.rows `