king
2023-11-03 eb0482b3fc2e91a626baa6ac73e75e0b0038f552
src/templates/sharecomponent/actioncomponent/verifyexcelin/index.jsx
@@ -388,48 +388,100 @@
    const { verify } = this.state
    let _columns = JSON.parse(JSON.stringify(verify.columns))
    let _names = {}
    let _cols = _columns.map(item => {
      let key = item.Column.toLowerCase()
      _names[key] = item.Text
    let _cols = _columns.map(col => col.Column)
      return key
    })
    let names = {$up: false}
    columns.forEach(col => {
      if (col.field && !_cols.includes(col.field)) {
        let _type = 'Nvarchar(50)'
        let _limit = '50'
        if (col.type === 'number' && !col.decimal) {
          _type = 'Int'
          _limit = ''
        } else if (col.type === 'number') {
          _type = 'Decimal(18,' + col.decimal + ')'
          _limit = col.decimal
      if (!col.field) return
      let key = col.field.toLowerCase()
      if (_cols.includes(key)) {
        if (_names[key] !== col.label) {
          names.$up = true
          names[key] = col.label
        }
        let _cell = {
          uuid: col.uuid,
          Column: col.field,
          Text: col.label,
          type: _type,
          limit: _limit,
          import: 'true',
          required: 'true'
        }
        if (_type !== 'Nvarchar(50)') {
          _cell.min = 0
          _cell.max = 999999
        }
        _columns.push(_cell)
        return
      }
      let _type = 'Nvarchar(50)'
      let _limit = '50'
      if (col.type === 'number' && !col.decimal) {
        _type = 'Int'
        _limit = ''
      } else if (col.type === 'number') {
        _type = 'Decimal(18,' + col.decimal + ')'
        _limit = col.decimal
      }
      let _cell = {
        uuid: col.uuid,
        Column: col.field,
        Text: col.label,
        type: _type,
        limit: _limit,
        import: 'true',
        required: 'true'
      }
      if (_type !== 'Nvarchar(50)') {
        _cell.min = 0
        _cell.max = 999999
      }
      _columns.push(_cell)
    })
    this.setState({
      verify: {
        ...verify,
        columns: _columns
      }
    }, () => {
      this.resetUniqueColumns()
    })
    if (names.$up) {
      const that = this
      confirm({
        content: '部分字段名称与显示列不一致,是否更新?',
        onOk() {
          _columns = _columns.map(item => {
            let key = item.Column.toLowerCase()
            if (names[key]) {
              item.Text = names[key]
            }
            return item
          })
          that.setState({
            verify: {
              ...verify,
              columns: _columns
            }
          }, () => {
            that.resetUniqueColumns()
          })
        },
        onCancel() {
          that.setState({
            verify: {
              ...verify,
              columns: _columns
            }
          }, () => {
            that.resetUniqueColumns()
          })
        }
      })
    } else {
      this.setState({
        verify: {
          ...verify,
          columns: _columns
        }
      }, () => {
        this.resetUniqueColumns()
      })
    }
  }
  clearField = () => {
@@ -478,7 +530,6 @@
  changeColumns = (columns) => {
    const { verify } = this.state
    let reset = false
    columns = columns.map(col => {
      col.type = col.type || 'Nvarchar(50)'
      if (col.type === 'text' || col.type === 'image') {
@@ -487,19 +538,18 @@
        col.type = 'Decimal(18,2)'
      }
      if (col.import === 'init') {
        col.required = 'false'
        col.min = ''
        col.max = ''
      }
      if (/^Nvarchar/ig.test(col.type)) {
        col.limit = col.type.match(/\d+/) ? col.type.match(/\d+/)[0] : '20000'
      } else if (/^Decimal/ig.test(col.type)) {
        col.limit = col.type.match(/\d+/ig)[1]
        if (col.required === 'false') {
          reset = true
        }
        col.required = 'true'
      } else if (/^int/ig.test(col.type)) {
        if (col.required === 'false') {
          reset = true
        }
        col.required = 'true'
      } else {
        col.limit = ''
      }
@@ -509,10 +559,6 @@
      return col
    })
    if (reset) {
      message.warning('数值类型均为必填。')
    }
    this.setState({verify: {...verify, columns}}, () => {
      this.resetUniqueColumns()