king
2023-01-17 cc1a76df575c18f0d0ee96e8658461efdce3a918
src/tabviews/custom/components/table/edit-table/normalTable/index.jsx
@@ -6,7 +6,6 @@
import moment from 'moment'
import Api from '@/api'
import options from '@/store/options.js'
import asyncComponent from '@/utils/asyncComponent'
import Utils, { getEditTableSql, getMark } from '@/utils/utils.js'
import MkIcon from '@/components/mk-icon'
@@ -14,7 +13,7 @@
import zhCN from '@/locales/zh-CN/main.js'
import enUS from '@/locales/en-US/main.js'
import CusSwitch from './cusSwitch'
import '@/assets/css/table.scss'
import Encrypts from '@/components/encrypts'
import './index.scss'
const { Paragraph } = Typography
@@ -301,9 +300,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 +316,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,15 +386,17 @@
      }
      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, '$&,')
@@ -405,10 +412,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>
        }
      }
@@ -477,10 +486,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>
        }
      }
@@ -495,7 +506,10 @@
        <CardCellComponent data={record} cards={config} elements={col.elements}/>
      )
    } else if (col.type === 'action') {
      style.padding = '0px 5px'
      style.padding = '0px'
      if (col.style) {
        style = {...style, ...col.style}
      }
      children = (
        <CardCellComponent data={record} cards={config} elements={col.elements}/>
      )
@@ -716,9 +730,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 +746,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,15 +775,17 @@
        }
        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, '$&,')
@@ -779,10 +801,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
@@ -836,10 +860,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>
        }
      }
@@ -868,7 +894,7 @@
  static propTpyes = {
    statFValue: PropTypes.any,       // 合计字段数据
    MenuID: PropTypes.string,        // 菜单Id
    setting: PropTypes.object,       // 表格全局设置:tableType(表格是否可选、单选、多选)、columnfixed(列固定)、actionfixed(按钮固定)
    setting: PropTypes.object,       // 表格全局设置:tableType(表格是否可选、单选、多选)、actionfixed(按钮固定)
    columns: PropTypes.array,        // 表格列
    lineMarks: PropTypes.any,        // 行标记
    fields: PropTypes.array,         // 组件字段集
@@ -913,6 +939,10 @@
      if (item.type === 'text' && item.editable === 'true' && item.editType === 'select' && item.resourceType === '1') {
        let _option = Utils.getSelectQueryOptions(item)
        if (window.GLOB.debugger === true || window.debugger === true) {
          console.info(_option.sql)
        }
        item.base_sql = window.btoa(window.encodeURIComponent(_option.sql))
        item.arr_field = _option.field
@@ -1083,11 +1113,6 @@
        localItems.push(`select '${item.uuid}' as obj_name,'${item.arr_field}' as arr_field,'${item.base_sql}' as LText`)
      }
    })
    if (options.sysType !== 'local') {
      localItems = [...localItems, ...mainItems]
      mainItems = []
    }
    // 本地请求
    let param = {
@@ -1178,16 +1203,24 @@
      if (item.resourceType === '1' && result[item.uuid] && result[item.uuid].length > 0) {
        let options = []
        let _map = new Map()
        let all = false
        result[item.uuid].forEach(cell => {
          let _cell = {key: Utils.getuuid()}
          _cell.value = cell[item.valueField]
          _cell.label = cell[item.valueText]
          if (!_cell.label && _cell.label !== 0) return
          if (!_cell.label && _cell.label !== 0) {
            if (!all) {
              _cell.label = '全部'
              all = true
            } else {
              return
            }
          }
          if (_map.has(_cell.value)) return
          _map.set(_cell.value, true)
          _map.set(_cell.value, 0)
          if (item.linkSubField) {
            item.linkSubField.forEach(m => {
@@ -1965,7 +1998,7 @@
          {!submit.hasAction && pickup ? <Button style={submit.style} onClick={() => setTimeout(() => {this.checkData()}, 10)} loading={loading} className="submit-table" type="link">提交</Button> : null}
          <Switch title="编辑" className="main-pickup" checkedChildren="开" unCheckedChildren="关" disabled={loading || this.props.loading} checked={pickup} onChange={this.pickupChange} />
        </div>
        <div className={`edit-custom-table ${pickup ? 'editable' : ''} ${setting.tableHeader || ''} ${setting.operType || ''} ${height ? 'fixed-height' : ''} ${setting.mode || ''}`} id={tableId}>
        <div className={`edit-custom-table ${pickup ? 'editable' : ''} ${setting.tableHeader || ''} ${setting.operType || ''} ${height ? 'fixed-height' : ''} ${setting.mode || ''} table-vertical-${setting.vertical || ''}`} id={tableId}>
          <Table
            rowKey="$$uuid"
            components={components}