king
2022-09-06 b8e1395f02c929eaa96b949cf6027ee2a43856a6
src/tabviews/zshare/normalTable/index.jsx
@@ -2,11 +2,12 @@
import PropTypes from 'prop-types'
import md5 from 'md5'
import { is, fromJS } from 'immutable'
import { Table, Affix, Typography } from 'antd'
import { Table, Affix, Typography, Col } from 'antd'
import asyncComponent from '@/utils/asyncComponent'
import MKEmitter from '@/utils/events.js'
import MkIcon from '@/components/mk-icon'
import Encrypts from '@/components/encrypts'
import '@/assets/css/table.scss'
import './index.scss'
@@ -16,6 +17,13 @@
const PopupButton = asyncComponent(() => import('@/tabviews/zshare/actionList/popupbutton'))
const TabButton = asyncComponent(() => import('@/tabviews/zshare/actionList/tabbutton'))
const NewPageButton = asyncComponent(() => import('@/tabviews/zshare/actionList/newpagebutton'))
const Video = asyncComponent(() => import('@/components/video'))
const PicRadio = {
  '4:3': '75%', '3:2': '66.67%', '16:9': '56.25%', '2:1': '50%', '3:1': '33.33%', '4:1': '25%',
  '5:1': '20%', '6:1': '16.67%', '7:1': '14.29%', '8:1': '12.5%', '9:1': '11.11%',
  '10:1': '10%', '3:4': '133.33%', '2:3': '150%', '9:16': '177.78%'
}
class BodyRow extends React.Component {
  shouldComponentUpdate (nextProps) {
@@ -360,34 +368,20 @@
    } else if (item.linkurl) {
      let src = item.linkurl
      if (src.indexOf('paramsmain/') > -1) {
        try {
          let _url = item.linkurl.split('paramsmain/')[0] + 'paramsmain/'
          let _param = JSON.parse(window.decodeURIComponent(window.atob(item.linkurl.split('paramsmain/')[1])))
          _param.UserID = sessionStorage.getItem('UserID')
          _param.LoginUID = sessionStorage.getItem('LoginUID')
          _param.User_Name = sessionStorage.getItem('User_Name')
          _param.param = __param
          src = _url + window.btoa(window.encodeURIComponent(JSON.stringify(_param)))
        } catch (e) {
          console.warn('菜单参数解析错误!')
        }
      } else {
        let con = '?'
      let con = '?'
        if (/\?/ig.test(src)) {
          con = '&'
        }
        if (item.linkfields && item.linkfields.length > 0) {
          item.linkfields.forEach(field => {
            if (field.toLowerCase() === 'id') return
            con += `${field}=${record[field] || ''}&`
          })
        }
        src = src + `${con}id=${record.$$uuid}&appkey=${window.GLOB.appkey}&userid=${sessionStorage.getItem('UserID')}&LoginUID=${sessionStorage.getItem('LoginUID') || ''}`
      if (/\?/ig.test(src)) {
        con = '&'
      }
      if (item.linkfields && item.linkfields.length > 0) {
        item.linkfields.forEach(field => {
          if (field.toLowerCase() === 'id') return
          con += `${field}=${record[field] || ''}&`
        })
      }
      src = src + `${con}id=${record.$$uuid}&appkey=${window.GLOB.appkey}&userid=${sessionStorage.getItem('UserID')}&LoginUID=${sessionStorage.getItem('LoginUID') || ''}`
      window.open(src)
    }
@@ -467,9 +461,13 @@
          content = `${content.substr(0, 4)}-${content.substr(5, 2)}-${content.substr(8, 2)}`
        } else if (item.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 (item.textFormat === 'encryption') {
          content = <span>{item.prefix || ''}<Encrypts value={content} />{item.postfix || ''}</span>
        }
  
        content = (item.prefix || '') + content + (item.postfix || '')
        if (item.textFormat !== 'encryption') {
          content = (item.prefix || '') + content + (item.postfix || '')
        }
      }
      
      if (item.marks) {
@@ -556,13 +554,13 @@
      }
      if (content !== '') {
        let decimal = item.decimal || 0
        content = Math.round(content * item.round) / item.round
        if (item.format === 'percent') {
          content = content * 100
          decimal = decimal > 2 ? decimal - 2 : 0
        }
        content = content.toFixed(decimal)
        content = content.toFixed(item.decimal)
  
        if (item.format === 'thdSeparator') {
          content = content.replace(/\d{1,3}(?=(\d{3})+(\.\d*)?$)/g, '$&,')
@@ -641,6 +639,7 @@
      }
    } else if (item.type === 'picture') {
      let photos = ''
      let style = {borderRadius: '2px'}
      if (item.field && record.hasOwnProperty(item.field)) {
        photos = record[item.field] + ''
      }
@@ -650,19 +649,45 @@
        photos = photos.split(',').filter(Boolean)
      }
      let maxHeight = item.maxHeight || 128
      if (PicRadio[item.lenWidRadio]) {
        style.paddingTop = PicRadio[item.lenWidRadio]
      } else {
        style.paddingTop = '100%'
      }
      let scale = item.scale === 'true'
      return (
        <div className="picture-col">
          {photos && photos.map((url, i) => {
            if (item.scale === 'true') {
              return <img style={{maxHeight: maxHeight}} className="image-scale" onClick={(e) => {
          {photos.map((url, i) => (<Col key={i} span={item.span || 24}>
            <div
              className={'mk-picture' + (scale ? ' image-scale' : '')}
              onClick={(e) => {
                if (!scale) return
                e.stopPropagation()
                MKEmitter.emit('mkImageScale', url, photos)
              }} key={`${i}`} src={url} alt=""/>
            } else {
              return <img style={{maxHeight: maxHeight}} key={`${i}`} src={url} alt=""/>
            }
          })}
              }}
              style={{...style, backgroundImage: `url('${url}')`}}
            ></div>
          </Col>))}
        </div>
      )
    } else if (item.type === 'video') {
      let url = ''
      if (item.field && record.hasOwnProperty(item.field)) {
        url = record[item.field] + ''
      }
      if (!url) {
        return (
          <div className="video-wrap"></div>
        )
      }
      return (
        <div className="video-wrap">
          <Video card={item} value={url}/>
        </div>
      )
    } else if (item.type === 'textarea') {
@@ -806,13 +831,13 @@
          }
    
          if (content !== '') {
            let decimal = col.decimal || 0
            content = Math.round(content * col.round) / col.round
            if (col.format === 'percent') {
              content = content * 100
              decimal = decimal > 2 ? decimal - 2 : 0
            }
            content = content.toFixed(decimal)
            content = content.toFixed(col.decimal)
      
            if (col.format === 'thdSeparator') {
              content = content.replace(/\d{1,3}(?=(\d{3})+(\.\d*)?$)/g, '$&,')
@@ -855,7 +880,7 @@
          }
          photos.forEach(photo => {
            images.push({url: photo, align: col.Align, scale: col.scale === 'true', maxHeight: col.maxHeight || 128})
            images.push({url: photo, align: col.Align, scale: col.scale === 'true'})
          })
        } else if (col.type === 'text') {
          let content = record[col.field]
@@ -865,9 +890,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) {
@@ -990,12 +1019,12 @@
          <div className="content-fence-top" style={images[0] ? {textAlign: images[0].align} : null}>
            {images.map((_img, index) => {
              if (_img.scale) {
                return <img style={{maxHeight: _img.maxHeight}} className="image-scale" onClick={(e) => {
                return <img className="image-scale" onClick={(e) => {
                  e.stopPropagation()
                  MKEmitter.emit('mkImageScale', _img.url, images.map(g => g.url))
                }} key={`${index}`} src={_img.url} alt=""/>
              } else {
                return (<img style={{maxHeight: _img.maxHeight}} key={`${index}`} src={_img.url} alt=""/>)
                return (<img key={`${index}`} src={_img.url} alt=""/>)
              }
            })}
          </div>
@@ -1012,11 +1041,11 @@
          <div className="content-fence-left" style={images[0] ? {textAlign: images[0].align} : null}>
            {images.map((_img, index) => {
              if (_img.scale) {
                return <img style={{maxHeight: _img.maxHeight}} className="image-scale" onClick={() => {
                return <img className="image-scale" onClick={() => {
                  MKEmitter.emit('mkImageScale', _img.url, images.map(g => g.url))
                }} key={`${index}`} src={_img.url} alt=""/>
              } else {
                return (<img style={{maxHeight: _img.maxHeight}} key={`${index}`} src={_img.url} alt=""/>)
                return (<img key={`${index}`} src={_img.url} alt=""/>)
              }
            })}
          </div>