king
2024-02-03 8acfcd6e349ef2d1b797a7483940a2f3f2dfcfe6
src/tabviews/custom/components/table/edit-table/normalTable/index.jsx
@@ -55,7 +55,7 @@
    this.node.blur()
    
    if (config.enter === '$noAct') return
    if (/\$noAct/.test(config.enter)) return
    if (/\$next/.test(config.enter)) {
      MKEmitter.emit('nextLine' + config.tableId, lineId, config.enter.replace('$next_', ''))
@@ -191,7 +191,7 @@
    this.props.onChange(values)
    if (config.enter === '$noAct') return
    if (/\$noAct/.test(config.enter)) return
    if (/\$next/.test(config.enter)) {
      MKEmitter.emit('nextLine' + config.tableId, lineId, config.enter.replace('$next_', ''))
@@ -283,9 +283,11 @@
    this.props.onChange(values, val)
    if (config.enter === '$noActX') return
    this.node.blur()
    
    if (config.enter === '$noAct') return
    if (/\$noAct/.test(config.enter)) return
    setTimeout(() => {
      if (/\$next/.test(config.enter)) {
@@ -308,7 +310,7 @@
    const { config, lineId } = this.props
    if (config.$ctrl) {
      MKEmitter.emit('colBlur' + config.tableId, lineId, config.uuid)
      MKEmitter.emit('colBlur' + config.tableId, lineId, config.uuid, true)
    }
    setTimeout(() => {
@@ -408,7 +410,7 @@
    this.node.blur()
    
    if (config.enter === '$noAct') return
    if (/\$noAct/.test(config.enter)) return
    if (/\$next/.test(config.enter)) {
      MKEmitter.emit('nextLine' + config.tableId, lineId, config.enter.replace('$next_', ''))
@@ -536,7 +538,7 @@
    this.node.blur()
    
    if (config.enter === '$noAct') return
    if (/\$noAct/.test(config.enter)) return
    setTimeout(() => {
      if (/\$next/.test(config.enter)) {
@@ -1345,6 +1347,7 @@
  timer = null
  focusId = ''
  blurId = ''
  colId = ''
  UNSAFE_componentWillMount () {
    const { setting, fields, columns, BID, colsCtrls } = this.props
@@ -1389,7 +1392,7 @@
              if (item.resourceType === '1') {
                let _option = Utils.getSelectQueryOptions(item)
  
                if (/@BID@/ig.test(_option.sql)) {
                if (/@BID@/ig.test(_option.sql) && setting.supModule) {
                  hasBid = true
                }
        
@@ -1470,6 +1473,10 @@
      pageOptions = pageOptions.sort((a, b) => a - b)
    }
    if (setting.maxPageSize) {
      pageOptions = pageOptions.filter(item => item <= setting.maxPageSize)
    }
    let allColumns = null
    if (colsCtrls) {
      allColumns = [..._columns]
@@ -1490,14 +1497,11 @@
      pageOptions,
      columns: _columns,
      tableId: setting.tableId,
      orderfields
      orderfields,
      deForms: hasBid ? deForms : null
    }, () => {
      if (deForms.length > 0) {
        if (hasBid && setting.supModule && !BID) {
          this.setState({ deForms })
        } else {
          this.improveActionForm(deForms, BID)
        }
      if (deForms.length > 0 && (!hasBid || BID)) {
        this.improveActionForm(deForms, BID)
      }
    })
  }
@@ -1552,7 +1556,11 @@
    MKEmitter.removeListener('changeRecord' + tableId, this.changeRecord)
  }
  colBlur = (lineId) => {
  colBlur = (lineId, colId, defer) => {
    if (defer && this.focusId === lineId && this.colId !== colId) {
      return
    }
    this.blurId = lineId
    this.focusId = ''
@@ -1565,8 +1573,9 @@
    }, 150)
  }
  colFocus = (lineId) => {
  colFocus = (lineId, colId) => {
    this.focusId = lineId
    this.colId = colId
  }
  checkLine = () => {
@@ -1708,9 +1717,11 @@
  }
  transferData = (data, type) => {
    const { edData } = this.state
    const { edData, tableId } = this.state
    if (type === 'line') {
    if (type === 'delete') {
    } else if (type === 'line') {
      let value = ''
      Object.keys(data).sort().forEach(key => {
        if (/^\$/.test(key)) return
@@ -1728,14 +1739,18 @@
      })
    }
    if (type !== 'line') {
      let index = edData.findIndex(item => !item.$origin && !item.$forbid)
    if (type === 'delete') {
      let _edData = this.state.edData.filter(item => item.$$uuid !== data)
      if (index > -1) {
        this.setState({visible: true, midData: data})
      } else {
        this.updateMutil(data)
      }
      this.setState({edData: _edData, reseting: true}, () => {
        this.setState({reseting: false})
        if (this.focusId) {
          setTimeout(() => {
            MKEmitter.emit('setFocus' + tableId, this.focusId, this.colId)
          }, 10)
        }
      })
    } else if (type === 'line') {
      let _edData = this.state.edData.map(item => {
        if (item.$$uuid === data.$$uuid) {
@@ -1747,7 +1762,21 @@
      this.setState({edData: _edData, reseting: true}, () => {
        this.setState({reseting: false})
        if (this.focusId) {
          setTimeout(() => {
            MKEmitter.emit('setFocus' + tableId, this.focusId, this.colId)
          }, 10)
        }
      })
    } else {
      let index = edData.findIndex(item => !item.$origin && !item.$forbid)
      if (index > -1) {
        this.setState({visible: true, midData: data})
      } else {
        this.updateMutil(data)
      }
    }
  }
@@ -1793,12 +1822,9 @@
  }
  improveActionForm = (deForms, BID) => {
    const { setting } = this.props
    let deffers = []
    let mainItems = []  // 云端或单点数据
    let localItems = [] // 本地数据
    let cache = setting.cache !== 'false'
    let debug = window.GLOB.debugger === true
    let _sql = `Declare @mk_departmentcode nvarchar(512),@mk_organization nvarchar(512),@mk_user_type nvarchar(20)  select @mk_departmentcode='${sessionStorage.getItem('departmentcode') || ''}',@mk_organization='${sessionStorage.getItem('organization') || ''}',@mk_user_type='${sessionStorage.getItem('mk_user_type') || ''}'\n`
    let _sso = _sql
@@ -1850,7 +1876,7 @@
      deffers.push(
        new Promise(resolve => {
          Api.getSystemCacheConfig(param, cache).then(res => {
          Api.getSystemCacheConfig(param, false).then(res => {
            if (!res.status) {
              notification.warning({
                top: 92,
@@ -1885,7 +1911,7 @@
      deffers.push(
        new Promise(resolve => {
          Api.getSystemCacheConfig(mainparam, cache).then(res => {
          Api.getSystemCacheConfig(mainparam, false).then(res => {
            if (!res.status) {
              notification.warning({
                top: 92,
@@ -2001,7 +2027,7 @@
      setTimeout(() => {
        this.plusLine(colId)
      }, 10)
    } else if (edData[index] && setting.commit !== 'change') {
    } else if (edData[index] && (setting.commit === 'all' || setting.commit === 'amend')) {
      setTimeout(() => {
        this.submit()
      }, 10)
@@ -2142,7 +2168,7 @@
  checkData = () => {
    const { setting } = this.props
    const { edData, forms, checkForms } = this.state
    const { edData, forms, checkForms, selectedRowKeys } = this.state
    let data = fromJS(edData).toJS()
@@ -2150,6 +2176,17 @@
    if (setting.commit === 'amend') {
      data = data.filter(item => !item.$origin)
    } else if (setting.commit === 'check') {
      data = data.filter(item => selectedRowKeys.includes(item.$$uuid))
      if (data.length === 0) {
        notification.warning({
          top: 92,
          message: '请选择需要提交的数据!',
          duration: 5
        })
        return null
      }
    }
    if (data.length === 0) {
@@ -2304,9 +2341,9 @@
      Api.genericInterface(param).then((res) => {
        if (res.status) {
          this.execSuccess(res)
          this.execSuccess(res, record)
        } else {
          this.execError(res)
          this.execError(res, record)
        }
      }, (error) => {
        if (error && error.ErrCode === 'LoginError') return
@@ -2323,9 +2360,9 @@
      Api.genericInterface(param).then((res) => {
        if (res.status) {
          this.execSuccess(res)
          this.execSuccess(res, record)
        } else {
          this.execError(res)
          this.execError(res, record)
        }
      }, (error) => {
        if (error && error.ErrCode === 'LoginError') return
@@ -2335,7 +2372,7 @@
    }
  }
  execSuccess = (res) => {
  execSuccess = (res, record) => {
    const { submit } = this.props
    const { edData } = this.state
@@ -2385,13 +2422,13 @@
    }
    if (submit.execSuccess !== 'never') {
      MKEmitter.emit('refreshByButtonResult', submit.$menuId, submit.execSuccess, submit)
      MKEmitter.emit('refreshByButtonResult', submit.$menuId, submit.execSuccess, submit, '', record ? [record] : null)
    }
    submit.syncComponentId && MKEmitter.emit('reloadData', submit.syncComponentId)
  }
  execError = (res) => {
  execError = (res, record) => {
    const { submit } = this.props
    if (res.ErrCode === 'E') {
@@ -2420,7 +2457,7 @@
    })
    if (submit.execError !== 'never') {
      MKEmitter.emit('refreshByButtonResult', submit.$menuId, submit.execError, submit)
      MKEmitter.emit('refreshByButtonResult', submit.$menuId, submit.execError, submit, '', record ? [record] : null)
    }
  }