king
2023-10-18 81d0d7721bb14a34b1eef99fd9506c3eda4bda99
src/tabviews/custom/components/table/edit-table/normalTable/index.jsx
@@ -4,6 +4,7 @@
import { Table, Typography, Modal, Input, InputNumber, Button, notification, message, Select } from 'antd'
import { EditOutlined, QuestionCircleOutlined } from '@ant-design/icons'
import moment from 'moment'
import md5 from 'md5'
import Api from '@/api'
import asyncComponent from '@/utils/asyncComponent'
@@ -308,6 +309,14 @@
          }
        } else if (mark.innerStyle) {
          content = <span style={mark.innerStyle}>{content}</span>
        } else if (mark.space) {
          content = <><span dangerouslySetInnerHTML={{__html: mark.space}}></span>{content}</>
        } else if (mark.point) {
          if (mark.position === 'front') {
            content = <>{mark.point}{content}</>
          } else {
            content = <>{content}{mark.point}</>
          }
        }
      }
@@ -396,6 +405,14 @@
          }
        } else if (mark.innerStyle) {
          content = <span style={mark.innerStyle}>{content}</span>
        } else if (mark.space) {
          content = <><span dangerouslySetInnerHTML={{__html: mark.space}}></span>{content}</>
        } else if (mark.point) {
          if (mark.position === 'front') {
            content = <>{mark.point}{content}</>
          } else {
            content = <>{content}{mark.point}</>
          }
        }
      }
@@ -440,9 +457,7 @@
          let func = new Function('data', col.formula)
          content = func([record])
        } catch (e) {
          if (window.GLOB.debugger === true) {
            console.warn(e)
          }
          console.warn(e)
          content = ''
        }
      } else {
@@ -456,10 +471,8 @@
            // eslint-disable-next-line
            content = eval(content)
          } catch (e) {
            if (window.GLOB.debugger === true) {
              console.info(content)
              console.warn(e)
            }
            console.info(content)
            console.warn(e)
            content = ''
          }
        }
@@ -497,6 +510,14 @@
          }
        } else if (mark.innerStyle) {
          content = <span style={mark.innerStyle}>{content}</span>
        } else if (mark.space) {
          content = <><span dangerouslySetInnerHTML={{__html: mark.space}}></span>{content}</>
        } else if (mark.point) {
          if (mark.position === 'front') {
            content = <>{mark.point}{content}</>
          } else {
            content = <>{content}{mark.point}</>
          }
        }
      }
@@ -749,6 +770,14 @@
            }
          } else if (mark.innerStyle) {
            content = <span style={mark.innerStyle}>{content}</span>
          } else if (mark.space) {
            content = <><span dangerouslySetInnerHTML={{__html: mark.space}}></span>{content}</>
          } else if (mark.point) {
            if (mark.position === 'front') {
              content = <>{mark.point}{content}</>
            } else {
              content = <>{content}{mark.point}</>
            }
          }
        }
@@ -816,6 +845,14 @@
            }
          } else if (mark.innerStyle) {
            content = <span style={mark.innerStyle}>{content}</span>
          } else if (mark.space) {
            content = <><span dangerouslySetInnerHTML={{__html: mark.space}}></span>{content}</>
          } else if (mark.point) {
            if (mark.position === 'front') {
              content = <>{mark.point}{content}</>
            } else {
              content = <>{content}{mark.point}</>
            }
          }
        }
@@ -849,9 +886,7 @@
          let func = new Function('data', col.formula)
          content = func([record])
        } catch (e) {
          if (window.GLOB.debugger === true) {
            console.warn(e)
          }
          console.warn(e)
          content = ''
        }
      } else {
@@ -865,10 +900,8 @@
            // eslint-disable-next-line
            content = eval(content)
          } catch (e) {
            if (window.GLOB.debugger === true) {
              console.info(content)
              console.warn(e)
            }
            console.info(content)
            console.warn(e)
            content = ''
          }
        }
@@ -906,6 +939,14 @@
          }
        } else if (mark.innerStyle) {
          content = <span style={mark.innerStyle}>{content}</span>
        } else if (mark.space) {
          content = <><span dangerouslySetInnerHTML={{__html: mark.space}}></span>{content}</>
        } else if (mark.point) {
          if (mark.position === 'front') {
            content = <>{mark.point}{content}</>
          } else {
            content = <>{content}{mark.point}</>
          }
        }
      }
@@ -947,6 +988,7 @@
    pageSize: 10,         // 每页数据条数
    columns: null,        // 显示列
    forms: [],
    signForms: [],
    orderfields: {},      // 排序id与field转换
    loading: false,
    pageOptions: [],
@@ -963,6 +1005,7 @@
    let deForms = []
    let _forms = {}
    let hasBid = false
    let signForms = []
    let getColumns = (cols) => {
      return cols.map(item => {
@@ -974,6 +1017,8 @@
        } else {
          if (item.editable === 'true') {
            _forms[item.field] = item
            signForms.push(item.field)
            if (item.ctrlField) {
              item.ctrlValue = item.ctrlValue.split(',')
@@ -1046,6 +1091,7 @@
    this.setState({
      forms,
      signForms,
      pageSize: setting.pageSize || 10,
      pageOptions,
      columns: _columns,
@@ -1108,10 +1154,28 @@
  }
  transferData = (menuid, data, type) => {
    const { MenuID } = this.props
    const { edData } = this.state
    const { MenuID, setting } = this.props
    const { edData, signForms } = this.state
    if (menuid !== MenuID) return
    if (setting.commit !== 'all' && setting.standard !== 'change') {
      if (type !== 'line') {
        data.forEach(item => {
          let value = ''
          signForms.forEach(field => {
            value += item[field]
          })
          item.$sign = md5(value)
        })
      } else {
        let value = ''
        signForms.forEach(field => {
          value += data[field]
        })
        data.$sign = md5(value)
      }
    }
    if (type !== 'line') {
      let index = edData.findIndex(item => !item.$origin && !item.$forbid)
@@ -1461,19 +1525,31 @@
  changeRecord = (id, record) => {
    const { setting } = this.props
    const { tableId } = this.state
    const { tableId, signForms } = this.state
    if (id !== tableId) return
    let lock = record.$lock
    if (!record.$sign) {
      record.$origin = false
      record.$lock = true
      delete record.$forbid
    } else {
      let value = ''
      signForms.forEach(field => {
        value += record[field]
      })
      if (record.$sign !== md5(value)) {
        record.$origin = false
        record.$lock = true
      } else {
        record.$origin = true
        record.$lock = false
      }
    }
    let _data = this.state.edData.map(item => {
      if (item.$$uuid === record.$$uuid) {
        record.$origin = false
        record.$lock = true
        delete record.$forbid
        return record
      } else {
        return item
@@ -1481,7 +1557,7 @@
    })
    this.setState({edData: _data}, () => {
      if (setting.tableType && setting.hasAction && !lock && this.state.selectedRowKeys.includes(record.$$uuid)) {
      if (setting.tableType && setting.hasAction && this.state.selectedRowKeys.includes(record.$$uuid)) {
        this.selectdata(this.state.selectedRowKeys)
      }
    })