king
2022-09-06 b8e1395f02c929eaa96b949cf6027ee2a43856a6
src/tabviews/custom/components/table/edit-table/normalTable/index.jsx
@@ -14,6 +14,7 @@
import zhCN from '@/locales/zh-CN/main.js'
import enUS from '@/locales/en-US/main.js'
import CusSwitch from './cusSwitch'
import Encrypts from '@/components/encrypts'
import '@/assets/css/table.scss'
import './index.scss'
@@ -301,9 +302,13 @@
          content = `${content.substr(0, 4)}-${content.substr(5, 2)}-${content.substr(8, 2)}`
        } else if (col.textFormat === 'YYYY-MM-DD HH:mm:ss' && /^[1-9]\d{3}(-|\/)(0[1-9]|1[0-2])(-|\/)(0[1-9]|[1-2][0-9]|3[0-1]).([0-1][0-9]|2[0-3]):[0-5][0-9]:[0-5][0-9]/.test(content)) {
          content = `${content.substr(0, 4)}-${content.substr(5, 2)}-${content.substr(8, 2)} ${content.substr(11, 2)}:${content.substr(14, 2)}:${content.substr(17, 2)}`
        } else if (col.textFormat === 'encryption') {
          content = <span>{col.prefix || ''}<Encrypts value={content} />{col.postfix || ''}</span>
        }
        content = (col.prefix || '') + content + (col.postfix || '')
        if (col.textFormat !== 'encryption') {
          content = (col.prefix || '') + content + (col.postfix || '')
        }
      }
      if (col.marks) {
@@ -313,10 +318,12 @@
        if (mark.icon) {
          if (mark.position === 'front') {
            content = <span><MkIcon style={{color: mark.color}} type={mark.icon} /> {content}</span>
            content = <span><MkIcon style={mark.innerStyle} type={mark.icon} /> {content}</span>
          } else {
            content = <span>{content} <MkIcon style={{color: mark.color}} type={mark.icon} /></span>
            content = <span>{content} <MkIcon style={mark.innerStyle} type={mark.icon} /></span>
          }
        } else if (mark.innerStyle) {
          content = <span style={mark.innerStyle}>{content}</span>
        }
      }
@@ -381,21 +388,23 @@
      }
      if (content !== '') {
        let decimal = col.decimal || 0
        if (col.round) {
          content = Math.round(content * col.round) / col.round
        }
        if (col.format === 'percent') {
          content = content * 100
          decimal = decimal > 2 ? decimal - 2 : 0
        } else if (col.format === 'abs') {
          content = Math.abs(content)
        }
        content = content.toFixed(decimal)
        if (col.round) {
          content = content.toFixed(col.decimal)
        }
  
        if (col.format === 'thdSeparator') {
          content = content.replace(/\d{1,3}(?=(\d{3})+(\.\d*)?$)/g, '$&,')
        }
  
        content = col.prefix + content + col.postfix
        content = (col.prefix || '') + content + (col.postfix || '')
      }
      if (col.marks) {
@@ -405,10 +414,12 @@
        if (mark.icon) {
          if (mark.position === 'front') {
            content = <span><MkIcon style={{color: mark.color}} type={mark.icon} /> {content}</span>
            content = <span><MkIcon style={mark.innerStyle} type={mark.icon} /> {content}</span>
          } else {
            content = <span>{content} <MkIcon style={{color: mark.color}} type={mark.icon} /></span>
            content = <span>{content} <MkIcon style={mark.innerStyle} type={mark.icon} /></span>
          }
        } else if (mark.innerStyle) {
          content = <span style={mark.innerStyle}>{content}</span>
        }
      }
@@ -435,7 +446,7 @@
      }
      if (content) {
        content = col.prefix + content + col.postfix
        content = (col.prefix || '') + content + (col.postfix || '')
      }
      children = (
@@ -477,10 +488,12 @@
        if (mark.icon) {
          if (mark.position === 'front') {
            content = <span><MkIcon style={{color: mark.color}} type={mark.icon} /> {content}</span>
            content = <span><MkIcon style={mark.innerStyle} type={mark.icon} /> {content}</span>
          } else {
            content = <span>{content} <MkIcon style={{color: mark.color}} type={mark.icon} /></span>
            content = <span>{content} <MkIcon style={mark.innerStyle} type={mark.icon} /></span>
          }
        } else if (mark.innerStyle) {
          content = <span style={mark.innerStyle}>{content}</span>
        }
      }
@@ -716,9 +729,13 @@
            content = `${content.substr(0, 4)}-${content.substr(5, 2)}-${content.substr(8, 2)}`
          } else if (col.textFormat === 'YYYY-MM-DD HH:mm:ss' && /^[1-9]\d{3}(-|\/)(0[1-9]|1[0-2])(-|\/)(0[1-9]|[1-2][0-9]|3[0-1]).([0-1][0-9]|2[0-3]):[0-5][0-9]:[0-5][0-9]/.test(content)) {
            content = `${content.substr(0, 4)}-${content.substr(5, 2)}-${content.substr(8, 2)} ${content.substr(11, 2)}:${content.substr(14, 2)}:${content.substr(17, 2)}`
          } else if (col.textFormat === 'encryption') {
            content = <span>{col.prefix || ''}<Encrypts value={content} />{col.postfix || ''}</span>
          }
          content = (col.prefix || '') + content + (col.postfix || '')
          if (col.textFormat !== 'encryption') {
            content = (col.prefix || '') + content + (col.postfix || '')
          }
        }
        if (col.marks) {
@@ -728,10 +745,12 @@
          if (mark.icon) {
            if (mark.position === 'front') {
              content = <span><MkIcon style={{color: mark.color}} type={mark.icon} /> {content}</span>
              content = <span><MkIcon style={mark.innerStyle} type={mark.icon} /> {content}</span>
            } else {
              content = <span>{content} <MkIcon style={{color: mark.color}} type={mark.icon} /></span>
              content = <span>{content} <MkIcon style={mark.innerStyle} type={mark.icon} /></span>
            }
          } else if (mark.innerStyle) {
            content = <span style={mark.innerStyle}>{content}</span>
          }
        }
        children = content
@@ -755,21 +774,23 @@
        }
        if (content !== '') {
          let decimal = col.decimal || 0
          if (col.round) {
            content = Math.round(content * col.round) / col.round
          }
          if (col.format === 'percent') {
            content = content * 100
            decimal = decimal > 2 ? decimal - 2 : 0
          } else if (col.format === 'abs') {
            content = Math.abs(content)
          }
          content = content.toFixed(decimal)
          if (col.round) {
            content = content.toFixed(col.decimal)
          }
    
          if (col.format === 'thdSeparator') {
            content = content.replace(/\d{1,3}(?=(\d{3})+(\.\d*)?$)/g, '$&,')
          }
    
          content = col.prefix + content + col.postfix
          content = (col.prefix || '') + content + (col.postfix || '')
        }
        if (col.marks) {
@@ -779,10 +800,12 @@
          if (mark.icon) {
            if (mark.position === 'front') {
              content = <span><MkIcon style={{color: mark.color}} type={mark.icon} /> {content}</span>
              content = <span><MkIcon style={mark.innerStyle} type={mark.icon} /> {content}</span>
            } else {
              content = <span>{content} <MkIcon style={{color: mark.color}} type={mark.icon} /></span>
              content = <span>{content} <MkIcon style={mark.innerStyle} type={mark.icon} /></span>
            }
          } else if (mark.innerStyle) {
            content = <span style={mark.innerStyle}>{content}</span>
          }
        }
        children = content
@@ -794,7 +817,7 @@
      }
      if (content) {
        content = col.prefix + content + col.postfix
        content = (col.prefix || '') + content + (col.postfix || '')
      }
      children = (
@@ -836,10 +859,12 @@
        if (mark.icon) {
          if (mark.position === 'front') {
            content = <span><MkIcon style={{color: mark.color}} type={mark.icon} /> {content}</span>
            content = <span><MkIcon style={mark.innerStyle} type={mark.icon} /> {content}</span>
          } else {
            content = <span>{content} <MkIcon style={{color: mark.color}} type={mark.icon} /></span>
            content = <span>{content} <MkIcon style={mark.innerStyle} type={mark.icon} /></span>
          }
        } else if (mark.innerStyle) {
          content = <span style={mark.innerStyle}>{content}</span>
        }
      }
@@ -963,12 +988,12 @@
      })
    }
    if (setting.borderColor) { // 边框颜色
      let style = `#${setting.tableId} table, #${setting.tableId} tr, #${setting.tableId} th, #${setting.tableId} td {border-color: ${setting.borderColor}}`
      let ele = document.createElement('style')
      ele.innerHTML = style
      document.getElementsByTagName('head')[0].appendChild(ele)
    }
    // if (setting.borderColor) { // 边框颜色
    //   let style = `#${setting.tableId} table, #${setting.tableId} tr, #${setting.tableId} th, #${setting.tableId} td {border-color: ${setting.borderColor}}`
    //   let ele = document.createElement('style')
    //   ele.innerHTML = style
    //   document.getElementsByTagName('head')[0].appendChild(ele)
    // }
    let size = (setting.pageSize || 10) + ''
    let pageOptions = ['10', '25', '50', '100', '500', '1000']
@@ -991,6 +1016,12 @@
      if (deForms.length > 0) {
        this.improveActionForm(deForms)
      }
      const element = document.getElementById(setting.tableId)
      element && element.style.setProperty('--mk-table-border-color', setting.borderColor || '#e8e8e8')
      element && element.style.setProperty('--mk-table-color', setting.color || 'rgba(0, 0, 0, 0.65)')
      element && element.style.setProperty('--mk-table-font-size', setting.fontSize || '14px')
      element && element.style.setProperty('--mk-table-font-weight', setting.fontWeight || 'normal')
    })
  }
@@ -1181,7 +1212,7 @@
          if (!_cell.label && _cell.label !== 0) return
          if (_map.has(_cell.value)) return
          _map.set(_cell.value, true)
          _map.set(_cell.value, 0)
          if (item.linkSubField) {
            item.linkSubField.forEach(m => {
@@ -1238,6 +1269,10 @@
    } else if (setting.addable === 'true') {
      setTimeout(() => {
        this.plusLine()
      }, 10)
    } else if (edData[index]) {
      setTimeout(() => {
        this.subLine(col, edData[index])
      }, 10)
    }
  }
@@ -1959,7 +1994,7 @@
          <Table
            rowKey="$$uuid"
            components={components}
            style={setting.style}
            // style={setting.style}
            size={setting.size || 'middle'}
            bordered={setting.bordered !== 'false'}
            rowSelection={rowSelection}