king
2024-05-08 d08fba77101b83f211738c722403506cc7dab50b
src/tabviews/custom/components/table/edit-table/normalTable/index.jsx
@@ -727,7 +727,7 @@
  }
  render() {
    let { col, config, record, style, className, ...resProps } = this.props
    let { col, record, style, className, ...resProps } = this.props
    const { editing } = this.state
    if (!col) return (<td {...resProps} className={className} style={style}/>)
@@ -747,10 +747,14 @@
      if (col.editType === 'select' && col.options.length > 0) {
        content = col.map.get(content) || content
      } else if (col.editType === 'switch') {
        if (content === config.openVal) {
          content = config.openText
        } else if (content === config.closeVal) {
          content = config.closeText
        if (content === col.openVal) {
          content = col.openText
        } else if (content === col.closeVal) {
          content = col.closeText
        }
      } else if (col.editType === 'popSelect') {
        if (col.showField) {
          content = record[col.showField] || content
        }
      }
@@ -761,6 +765,10 @@
          content = `${content.substr(0, 4)}-${content.substr(5, 2)}-${content.substr(8, 2)} ${content.substr(11, 2)}:${content.substr(14, 2)}:${content.substr(17, 2)}`
        } else if (col.textFormat === 'encryption') {
          content = <span>{col.prefix || ''}<Encrypts value={content} />{col.postfix || ''}</span>
        }
        if (col.noValue === 'hide' && content < '1949-10-02') {
          content = ''
        }
        if (col.textFormat !== 'encryption') {
@@ -809,8 +817,13 @@
              <MkDatePicker config={col} lineId={record.$$uuid} defaultValue={_value || null} autoFocus={true} onChange={this.onColChange} onBlur={() => this.setState({editing: false})}/>
            </td>)
          } else if (col.editType === 'popSelect') {
            let showValue = ''
            if (col.showField) {
              showValue = record[col.showField] || ''
            }
            return (<td onClick={(e) => e.stopPropagation()} className="editing_table_cell">
              <MKPopSelect config={col} lineId={record.$$uuid} defaultValue={_value} BID={record.$$BID} autoFocus={true} onChange={this.onColChange} onBlur={() => this.setState({editing: false})}/>
              <MKPopSelect config={col} lineId={record.$$uuid} defaultValue={_value} showValue={showValue} BID={record.$$BID} autoFocus={true} onChange={this.onColChange} onBlur={() => this.setState({editing: false})}/>
            </td>)
          } else {
            return (<td onClick={(e) => e.stopPropagation()} className="editing_table_cell">
@@ -853,6 +866,7 @@
        }
  
        if (col.format === 'thdSeparator') {
          content = content + ''
          content = content.replace(/\d{1,3}(?=(\d{3})+(\.\d*)?$)/g, '$&,')
        }
  
@@ -996,7 +1010,7 @@
      }
      children = (
        <CardCellComponent data={record} cards={config} elements={col.elements}/>
        <CardCellComponent data={record} cards={col.config} elements={col.elements}/>
      )
    }
@@ -1027,7 +1041,7 @@
  }
  render() {
    let { col, config, record, style, className, ...resProps } = this.props
    let { col, record, style, className, ...resProps } = this.props
    if (!col) return (<td {...resProps} className={className} style={style}/>)
@@ -1056,8 +1070,13 @@
            <MkDatePicker config={col} lineId={record.$$uuid} defaultValue={_value || null} autoFocus={false} onChange={this.onColChange}/>
          )
        } else if (col.editType === 'popSelect') {
          let showValue = ''
          if (col.showField) {
            showValue = record[col.showField] || ''
          }
          children = (
            <MKPopSelect config={col} lineId={record.$$uuid} defaultValue={_value} BID={record.$$BID} autoFocus={false} onChange={this.onColChange}/>
            <MKPopSelect config={col} lineId={record.$$uuid} defaultValue={_value} showValue={showValue} BID={record.$$BID} autoFocus={false} onChange={this.onColChange}/>
          )
        } else {
          children = (
@@ -1073,10 +1092,14 @@
        if (col.editType === 'select' && col.options.length > 0) {
          content = col.map.get(content) || content
        } else if (col.editType === 'switch') {
          if (content === config.openVal) {
            content = config.openText
          } else if (content === config.closeVal) {
            content = config.closeText
          if (content === col.openVal) {
            content = col.openText
          } else if (content === col.closeVal) {
            content = col.closeText
          }
        } else if (col.editType === 'popSelect') {
          if (col.showField) {
            content = record[col.showField] || content
          }
        }
@@ -1087,6 +1110,10 @@
            content = `${content.substr(0, 4)}-${content.substr(5, 2)}-${content.substr(8, 2)} ${content.substr(11, 2)}:${content.substr(14, 2)}:${content.substr(17, 2)}`
          } else if (col.textFormat === 'encryption') {
            content = <span>{col.prefix || ''}<Encrypts value={content} />{col.postfix || ''}</span>
          }
          if (col.noValue === 'hide' && content < '1949-10-02') {
            content = ''
          }
          if (col.textFormat !== 'encryption') {
@@ -1164,6 +1191,7 @@
          }
    
          if (col.format === 'thdSeparator') {
            content = content + ''
            content = content.replace(/\d{1,3}(?=(\d{3})+(\.\d*)?$)/g, '$&,')
          }
    
@@ -1296,7 +1324,7 @@
      }
      children = (
        <CardCellComponent data={record} cards={config} elements={col.elements}/>
        <CardCellComponent data={record} cards={col.config} elements={col.elements}/>
      )
    }
@@ -1357,7 +1385,6 @@
    let deForms = []
    let _forms = {}
    let hasBid = false
    let index = 0
    let checkForms = []
    let allForms = []
@@ -1370,25 +1397,12 @@
          cell.children = getColumns(item.subcols, sk || item.uuid)
        } else {
          if (item.editable === 'true') {
            item.$sort = index
            index++
            _forms[item.field] = item
            allForms.push({uuid: sk || item.uuid, field: item.field})
            checkForms.push(item.field)
            if (item.ctrlField) {
              item.ctrlValue = item.ctrlValue.split(',')
            }
            if (item.type === 'number' && item.clearField) {
              fields.forEach(cell => {
                if (cell.field === item.clearField) {
                  item.clearName = cell.label
                }
              })
            } else if (item.type === 'text' && item.editType === 'select') {
              item.map = new Map()
            if (item.type === 'text' && item.editType === 'select') {
              if (item.resourceType === '1') {
                let _option = Utils.getSelectQueryOptions(item)
  
@@ -1400,20 +1414,6 @@
                item.arr_field = _option.field
        
                deForms.push(item)
              } else {
                item.options.forEach(cell => {
                  item.map.set(cell.value, cell.label)
                })
              }
            } else if (item.type === 'text' && item.editType === 'date') {
              item.format = 'YYYY-MM-DD'
              if (item.precision === 'hour') {
                item.format = 'YYYY-MM-DD HH'
              } else if (item.precision === 'minute') {
                item.format = 'YYYY-MM-DD HH:mm'
              } else if (item.precision === 'second') {
                item.format = 'YYYY-MM-DD HH:mm:ss'
              }
            }
          }
@@ -1433,8 +1433,7 @@
            $key: item.uuid,
            onCell: record => ({
              record,
              col: item,
              config: item.type === 'custom' ? {setting, columns: fields} : null,
              col: item
            })
          }
        }
@@ -1511,11 +1510,44 @@
  }
  UNSAFE_componentWillReceiveProps(nextProps) {
    const { BID } = this.props
    const { BID, parCtrl } = this.props
    const { deForms } = this.state
    if (deForms && nextProps.BID !== BID) {
      this.improveActionForm(deForms, nextProps.BID)
    }
    if (parCtrl && !is(fromJS(this.props.columns), fromJS(nextProps.columns))) {
      let getColumns = (cols, sk) => {
        return cols.map(item => {
          let cell = null
          if (item.type === 'colspan') {
            cell = { title: item.label, align: item.Align, $key: item.uuid }
            cell.children = getColumns(item.subcols, sk || item.uuid)
          } else {
            cell = {
              align: item.Align,
              dataIndex: item.uuid,
              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,
              $key: item.uuid,
              onCell: record => ({
                record,
                col: item
              })
            }
          }
          return cell
        })
      }
      let _columns = getColumns(nextProps.columns)
      this.setState({
        columns: _columns
      })
    }
  }
@@ -1682,6 +1714,9 @@
        result = originVal === contrastVal
      } else if (item.match === '!=') {
        result = originVal !== contrastVal
      } else if (item.match === 'regexp') {
        let reg = new RegExp(item.contrastValue, 'ig')
        result = reg.test(originVal)
      } else {
        originVal = isNaN(originVal) ? originVal : +originVal
        contrastVal = isNaN(contrastVal) ? contrastVal : +contrastVal
@@ -1719,7 +1754,10 @@
  transferData = (data, type) => {
    const { edData, tableId } = this.state
    if (type === 'delete') {
    if (type === 'clear') {
      this.setState({edData: [], midData: []})
      return
    } else if (type === 'delete') {
    } else if (type === 'line') {
      let value = ''
@@ -2623,7 +2661,7 @@
        {setting.hasSubmit && edData.length > 0 ? <div className="edit-custom-table-btn-wrap" style={submit.wrapStyle}>
          <Button style={submit.style} onClick={() => setTimeout(() => {this.submit()}, 10)} loading={loading} className="submit-table" type="link">提交</Button>
        </div> : null}
        <div className={`edit-custom-table ${setting.tableHeader || ''} ${height ? 'fixed-height' : ''} ${setting.mode || ''} table-vertical-${setting.vertical || ''} mk-edit-${setting.editType || 'simple'}`} style={style}>
        <div className={`edit-custom-table ${setting.tableHeader || ''} ${setting.parity === 'true' ? 'mk-parity' : ''} ${height ? 'fixed-height' : ''} ${setting.mode || ''} table-vertical-${setting.vertical || ''} mk-edit-${setting.editType || 'simple'}`} style={style}>
          <Table
            rowKey="$$uuid"
            components={components}