king
2024-06-21 2bccb9ec7bdefe23292a22bc153463cfa1479a49
src/tabviews/custom/components/table/edit-table/normalTable/index.jsx
@@ -1383,7 +1383,8 @@
    allColumns: null,
    checkForms: [],
    allForms: [],
    reseting: false
    reseting: false,
    dict: window.GLOB.dict
  }
  timer = null
@@ -1625,7 +1626,7 @@
  }
  checkLine = () => {
    const { edData, forms, checkForms } = this.state
    const { edData, forms, checkForms, dict } = this.state
    let data = edData.filter(item => item.$$uuid === this.blurId)[0]
@@ -1668,7 +1669,7 @@
      if (col.type === 'text') {
        let val = record[col.field] !== undefined ? (record[col.field] + '') : ''
        if (col.required === 'true' && !val) {
          err = `${col.label}不可为空`
          err = `${col.label}${dict['not_empty'] || '不可为空'}`
        } else if (col.datatype === 'datetime' && !val) {
          val = '1949-10-01'
        }
@@ -1677,27 +1678,27 @@
        let val = record[col.field]
        if (col.required === 'true' && !val) {
          err = `${col.label}不可为${col.noValue === 'hide' ? '空' : '0'}`
          err = `${col.label}${col.noValue === 'hide' ? (dict['not_empty'] || '不可为空') : dict['not_zero'] || '不可为0'}`
        } else if (col.noValue === 'hide' && !val) {
          if (col.clearField && checkForms.includes(col.clearField) && !record[col.clearField]) {
            err = `请填写 ${col.label} 或 ${col.clearName}`
            err = `${dict['input_tip'] || '请填写 '}${col.label} ${dict['or'] || '或'} ${col.clearName}`
          }
          val = 0
        } else if (!val && val !== 0) {
          err = `${col.label}不可为空`
          err = `${col.label}${dict['not_empty'] || '不可为空'}`
        } else {
          val = +val
          if (isNaN(val)) {
            err = `${col.label}数据格式错误`
            err = `${col.label} ${dict['data_format'] || '数据格式错误'}`
            return
          }
  
          val = +val.toFixed(col.decimal || 0)
          
          if (typeof(col.max) === 'number' && val > col.max) {
            err = `${col.label}不可大于${col.max}`
            err = `${col.label}${dict['max_limit'] || ' 不可大于 '}${col.max}`
          } else if (typeof(col.min) === 'number' && val < col.min) {
            err = `${col.label}不可小于${col.min}`
            err = `${col.label}${dict['less_limit'] || ' 不可小于 '}${col.min}`
          }
        }
@@ -2230,7 +2231,7 @@
  checkData = () => {
    const { setting } = this.props
    const { edData, forms, checkForms, selectedRowKeys } = this.state
    const { edData, forms, checkForms, selectedRowKeys, dict } = this.state
    let data = fromJS(edData).toJS()
@@ -2244,7 +2245,7 @@
      if (data.length === 0) {
        notification.warning({
          top: 92,
          message: '请选择需要提交的数据!',
          message: dict['select_row'] || '请选择需要提交的数据!',
          duration: 5
        })
        return null
@@ -2254,7 +2255,7 @@
    if (data.length === 0) {
      notification.warning({
        top: 92,
        message: '数据未修改,不可提交!',
        message: dict['un_modified'] || '数据未修改,不可提交!',
        duration: 5
      })
      return null
@@ -2288,7 +2289,7 @@
        if (col.type === 'text') {
          let val = item[col.field] !== undefined ? (item[col.field] + '') : ''
          if (col.required === 'true' && !val) {
            line.push(`${col.label}不可为空`)
            line.push(`${col.label}${dict['not_empty'] || '不可为空'}`)
          } else if (col.datatype === 'datetime' && !val) {
            val = '1949-10-01'
          }
@@ -2296,31 +2297,31 @@
        } else if (col.type === 'number') {
          let val = item[col.field]
          if (col.required === 'true' && !val) {
            err = `${col.label}不可为${col.noValue === 'hide' ? '空' : '0'}`
            err = `${col.label}${col.noValue === 'hide' ? (dict['not_empty'] || '不可为空') : dict['not_zero'] || '不可为0'}`
          } else if (col.noValue === 'hide' && !val) {
            if (col.clearField && checkForms.includes(col.clearField) && !item[col.clearField]) {
              let msg = `请填写 ${col.label} 或 ${col.clearName}`
              let msg = `${dict['input_tip'] || '请填写 '}${col.label} ${dict['or'] || '或'} ${col.clearName}`
              if (!line.includes(msg)) {
                line.push(msg)
              }
            }
            val = 0
          } else if (!val && val !== 0) {
            line.push(`${col.label}不可为空`)
            line.push(`${col.label}${dict['not_empty'] || '不可为空'}`)
            return
          } else {
            val = +val
            if (isNaN(val)) {
              line.push(`${col.label}数据格式错误`)
              line.push(`${col.label} ${dict['data_format'] || '数据格式错误'}`)
              return
            }
  
            val = +val.toFixed(col.decimal || 0)
            
            if (typeof(col.max) === 'number' && val > col.max) {
              line.push(`${col.label}不可大于${col.max}`)
              line.push(`${col.label}${dict['max_limit'] || ' 不可大于 '}${col.max}`)
            } else if (typeof(col.min) === 'number' && val < col.min) {
              line.push(`${col.label}不可小于${col.min}`)
              line.push(`${col.label}${dict['less_limit'] || ' 不可小于 '}${col.min}`)
            }
          }
@@ -2329,7 +2330,7 @@
      })
      if (line.length > 0) {
        err += `第${Index}行:` + line.join(',') + ';'
        err += (dict['line'] ? `${dict['line']} ${Index}:` : `第${Index}行:`) + line.join(',') + ';'
      }
      if (!item.$deleted) {
        Index++
@@ -2353,14 +2354,14 @@
  submit = (record) => {
    const { submit, BID, setting } = this.props
    const { forms } = this.state
    const { forms, dict } = this.state
    this.setState({visible: false, midData: null})
    if (setting.supModule && !BID) {
      notification.warning({
        top: 92,
        message: '需要上级主键值!',
        message: dict['sup_key_req'] || '需要上级主键值!',
        duration: 5
      })
@@ -2438,17 +2439,18 @@
  execSuccess = (res, record) => {
    const { submit } = this.props
    const { edData } = this.state
    const { edData, dict } = this.state
    if (res && res.ErrCode === 'S') { // 执行成功
      notification.success({
        top: 92,
        message: res.message || '执行成功',
        message: res.message || dict['exc_success'] || '执行成功',
        duration: submit.stime ? submit.stime : 2
      })
    } else if (res && res.ErrCode === 'Y') { // 执行成功
      Modal.success({
        title: res.message || '执行成功'
        title: res.message || dict['exc_success'] || '执行成功',
        okText: dict['got_it'] || '知道了'
      })
    } else if (res && res.ErrCode === '-1') { // 完成后不提示
@@ -2494,26 +2496,28 @@
  execError = (res, record) => {
    const { submit } = this.props
    const { dict } = this.state
    if (res.ErrCode === 'E') {
      Modal.error({
        title: res.message || '执行失败!',
        title: res.message || dict['exc_fail'] || '执行失败!',
        okText: dict['got_it'] || '知道了'
      })
    } else if (res.ErrCode === 'N') {
      notification.error({
        top: 92,
        message: res.message || '执行失败!',
        message: res.message || dict['exc_fail'] || '执行失败!',
        duration: submit.ntime ? submit.ntime : 10
      })
    } else if (res.ErrCode === 'F') {
      notification.error({
        className: 'notification-custom-error',
        top: 92,
        message: res.message || '执行失败!',
        message: res.message || dict['exc_fail'] || '执行失败!',
        duration: submit.ftime ? submit.ftime : 10
      })
    } else if (res.ErrCode === 'NM') {
      message.error(res.message || '执行失败!')
      message.error(res.message || dict['exc_fail'] || '执行失败!')
    }
    
    this.setState({
@@ -2627,7 +2631,7 @@
  render() {
    const { setting, lineMarks, submit } = this.props
    const { edData, columns, loading, pageOptions, selectedRowKeys, visible, midData, reseting } = this.state
    const { edData, columns, loading, pageOptions, selectedRowKeys, visible, midData, reseting, dict } = this.state
    if (reseting) return null
@@ -2658,7 +2662,7 @@
        pageSizeOptions: pageOptions,
        showSizeChanger: true,
        total: this.props.total || 0,
        showTotal: (total, range) => `${range[0]}-${range[1]} 共 ${total} 条`
        showTotal: (total, range) => `${range[0]}-${range[1]} ${dict['of'] || '共'} ${total} ${dict['items'] || '条'}`
      }
    }
@@ -2683,7 +2687,7 @@
    return (
      <>
        {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>
          <Button style={submit.style} onClick={() => setTimeout(() => {this.submit()}, 10)} loading={loading} className="submit-table" type="link">{dict['submit'] || '提交'}</Button>
        </div> : null}
        <div className={`edit-custom-table ${setting.tableHeader || ''} ${setting.parity === 'true' ? 'mk-parity' : ''} ${height ? 'fixed-table-height' : ''} ${setting.mode || ''} table-vertical-${setting.vertical || ''} mk-edit-${setting.editType || 'simple'}`} style={style}>
          <Table
@@ -2707,7 +2711,7 @@
            onChange={this.changeTable}
            pagination={_pagination}
          />
          {setting.hasSubmit && _data.length > 10 ? <Button style={submit.style} onClick={() => setTimeout(() => {this.submit()}, 10)} loading={loading} className="submit-footer-table" type="link">提交</Button> : null}
          {setting.hasSubmit && _data.length > 10 ? <Button style={submit.style} onClick={() => setTimeout(() => {this.submit()}, 10)} loading={loading} className="submit-footer-table" type="link">{dict['submit'] || '提交'}</Button> : null}
        </div>
        <Modal
          className="mk-user-confirm"
@@ -2716,13 +2720,13 @@
          maskClosable={false}
          closable={false}
          footer={[
            <Button key="cancel" onClick={() => { this.setState({ visible: false, midData: null }) }}>取消</Button>,
            <Button key="refresh" className="table-refresh" onClick={() => { midData && this.updateMutil(midData) }}>刷新表格</Button>,
            <Button key="confirm" type="primary" onClick={() => setTimeout(() => {this.submit()}, 10)}>提交数据</Button>
            <Button key="cancel" onClick={() => { this.setState({ visible: false, midData: null }) }}>{dict['cancel'] || '取消'}</Button>,
            <Button key="refresh" className="table-refresh" onClick={() => { midData && this.updateMutil(midData) }}>{dict['refresh'] || '刷新表格'}</Button>,
            <Button key="confirm" type="primary" onClick={() => setTimeout(() => {this.submit()}, 10)}>{dict['submit'] || '提交数据'}</Button>
          ]}
          destroyOnClose
        >
          <div><QuestionCircleOutlined />表格中有数据尚未提交</div>
          <div><QuestionCircleOutlined />{dict['data_not_sub'] || '表格中有数据尚未提交'}</div>
        </Modal>
      </>
    )