king
2023-10-31 eee991f412fc8250ffe9ba8dd074fc4d0cf6eaa2
2023-10-31
3个文件已修改
72 ■■■■ 已修改文件
src/menu/components/table/edit-table/columns/editColumn/formconfig.jsx 10 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
src/menu/components/table/edit-table/columns/editColumn/index.jsx 2 ●●● 补丁 | 查看 | 原始文档 | blame | 历史
src/tabviews/custom/components/table/edit-table/normalTable/index.jsx 60 ●●●● 补丁 | 查看 | 原始文档 | blame | 历史
src/menu/components/table/edit-table/columns/editColumn/formconfig.jsx
@@ -593,6 +593,16 @@
      options: fields
    },
    {
      type: 'select',
      key: 'clearField',
      label: '清空字段',
      initVal: card.clearField || '',
      tooltip: '当前字段编辑时需要清空的字段。',
      allowClear: true,
      required: false,
      options: fields
    },
    {
      type: 'text',
      key: 'ctrlValue',
      label: '禁止值',
src/menu/components/table/edit-table/columns/editColumn/index.jsx
@@ -89,7 +89,7 @@
          _options.push('required', 'enter')
        }
      } else if (this.record.type === 'number') {
        _options.push('max', 'min', 'enter')
        _options.push('max', 'min', 'enter', 'clearField')
      }
    }
    if (this.record.type === 'formula' && this.record.eval === 'true') {
src/tabviews/custom/components/table/edit-table/normalTable/index.jsx
@@ -266,25 +266,33 @@
  }
  
  onChange = (val) => {
    const { col } = this.props
    const { col, record } = this.props
    
    let err = null
    if (col.type === 'number') {
      val = +val
      if (isNaN(val)) {
      if (col.noValue === 'hide' && val === null) {
        val = 0
      }
      if (typeof(col.max) === 'number' && val > col.max) {
        err = col.label + '最大为' + col.max
      } else if (typeof(col.min) === 'number' && val < col.min) {
        err = col.label + '最小为' + col.min
      } else {
        val = +val
        if (isNaN(val)) {
          val = 0
        }
        if (typeof(col.max) === 'number' && val > col.max) {
          err = col.label + '最大为' + col.max
        } else if (typeof(col.min) === 'number' && val < col.min) {
          err = col.label + '最小为' + col.min
        }
      }
    } else if (col.required === 'true' && !val) {
      err = '请填写' + col.label
    }
    
    this.setState({value: val, err})
    if (col.clearField && record[col.clearField]) {
      MKEmitter.emit('changeRecord', col.tableId, {...record, [col.clearField]: ''}, 'clear')
    }
  }
  onSwitchChange = (val, label) => {
@@ -680,7 +688,16 @@
class BodyAllCell extends React.Component {
  state = {
    err: null,
    value: ''
    value: '',
    resting: false
  }
  componentDidMount() {
    const { col } = this.props
    if (col && col.type === 'number' && col.clearField) {
      MKEmitter.addListener('resetCol', this.resetCol)
    }
  }
  shouldComponentUpdate (nextProps, nextState) {
@@ -711,6 +728,7 @@
    this.setState = () => {
      return
    }
    MKEmitter.removeListener('resetCol', this.resetCol)
  }
  enterPress = () => {
@@ -736,14 +754,29 @@
      }
    }, 50)
  }
  resetCol = (tableId, clearField, id) => {
    const { col, record } = this.props
    if (col.tableId === tableId && clearField === col.field && record.$$uuid === id) {
      this.setState({resting: true}, () => {
        this.setState({resting: false})
      })
    }
  }
  
  onChange = (val) => {
    const { col } = this.props
    const { col, record } = this.props
    if (col.noValue === 'hide' && val === null) {
      this.setState({value: 0})
    } else {
      this.setState({value: val})
    }
    if (col.clearField && record[col.clearField]) {
      MKEmitter.emit('changeRecord', col.tableId, {...record, [col.clearField]: ''}, 'clear')
      MKEmitter.emit('resetCol', col.tableId, col.clearField, record.$$uuid)
    }
  }
@@ -878,9 +911,10 @@
  render() {
    let { col, config, record, style, className, ...resProps } = this.props
    const { err } = this.state
    const { err, resting } = this.state
    if (!col) return (<td {...resProps} className={className} style={style}/>)
    if (resting) return null
    let disabled = false
    let editable = false
@@ -1824,7 +1858,7 @@
    }
  }
  changeRecord = (id, record) => {
  changeRecord = (id, record, type) => {
    const { setting } = this.props
    const { tableId, signForms } = this.state
@@ -1863,7 +1897,7 @@
      if (setting.tableType && setting.hasAction && this.state.selectedRowKeys.includes(record.$$uuid)) {
        this.selectdata(this.state.selectedRowKeys)
      }
      if (setting.commit === 'blur') {
      if (setting.commit === 'blur' && type !== 'clear') {
        this.submit(record)
      }
    })