king
2021-11-15 ded0a522a7747fb841719c13c8c35f13cf5cda4c
src/tabviews/custom/components/table/edit-table/normalTable/index.jsx
@@ -202,11 +202,13 @@
    const { value } = this.state
    this.setState({editing: false})
    if (col.enter === '$next') {
      MKEmitter.emit('nextLine', col, record.$Index)
    } else {
      MKEmitter.emit('tdFocus', col.enter + record.$Index)
    }
    setTimeout(() => {
      if (col.enter === '$next') {
        MKEmitter.emit('nextLine', col, record.$Index)
      } else {
        MKEmitter.emit('tdFocus', col.enter + record.$Index)
      }
    }, 50)
    if (value !== record[col.field]) {
      MKEmitter.emit('changeRecord', col.tableId, {...record, [col.field]: value})
@@ -368,6 +370,39 @@
          {content ? <Paragraph copyable ellipsis={{ rows: 3, expandable: true }}>{content}</Paragraph> : null }
        </div>
      )
    } else if (col.type === 'formula') {
      let content = col.formula
      Object.keys(record).forEach(key => {
        let reg = new RegExp('@' + key + '@', 'ig')
        content = content.replace(reg, record[key])
      })
      if (col.eval !== 'false') {
        try {
          // eslint-disable-next-line
          content = eval(content)
        } catch (e) {
          content = ''
        }
      }
      content = content === undefined ? '' : content
      if (content !== '') {
        content = `${col.prefix || ''}${content}${col.postfix || ''}`
        if (col.eval === 'false') {
          content = content.replace(/\n/ig, '<br/>').replace(/\s/ig, '&nbsp;')
          content = <span dangerouslySetInnerHTML={{__html: content}}></span>
        }
      }
      if (col.marks) {
        style = style || {}
        content = this.getMark(record, col.marks, style, content)
      }
      children = content
    } else if (col.type === 'custom') {
      style.padding = '0px'
      if (col.style) {
@@ -421,7 +456,8 @@
    pickup: false,        // 收起未选择项
    orderfields: {},      // 排序id与field转换
    loading: false,
    editable: 'false'
    editable: 'false',
    pageOptions: []
  }
  UNSAFE_componentWillMount () {
@@ -506,7 +542,17 @@
      document.getElementsByTagName('head')[0].appendChild(ele)
    }
    let size = (setting.pageSize || 10) + ''
    let pageOptions = ['10', '25', '50', '100', '500', '1000']
    if (!pageOptions.includes(size)) {
      pageOptions.push(size)
      pageOptions = pageOptions.sort((a, b) => a - b)
    }
    this.setState({
      pageSize: setting.pageSize || 10,
      pageOptions,
      data,
      columns: _columns,
      edColumns,
@@ -998,7 +1044,7 @@
  render() {
    const { setting, statFValue, lineMarks, submit } = this.props
    const { pickup, tableId, data, edData, columns, edColumns, loading } = this.state
    const { pickup, tableId, data, edData, columns, edColumns, loading, pageOptions } = this.state
    const components = {
      body: {
@@ -1022,7 +1068,7 @@
      _pagination = {
        current: this.state.pageIndex,
        pageSize: this.state.pageSize,
        pageSizeOptions: ['10', '25', '50', '100', '500', '1000'],
        pageSizeOptions: pageOptions,
        showSizeChanger: true,
        total: this.props.total || 0,
        showTotal: (total, range) => `${range[0]}-${range[1]} ${this.state.dict['main.pagination.of']} ${total} ${this.state.dict['main.pagination.items']}`