king
2025-01-16 325aa13d3b61d1c066f8fcab107003ef36713df3
src/tabviews/custom/components/card/cardcellList/index.jsx
@@ -4,7 +4,7 @@
import { Col, Tooltip, notification, Typography, message } from 'antd'
import moment from 'moment'
// import Api from '@/api'
import Api from '@/api'
import asyncComponent from '@/utils/asyncComponent'
import { getMark } from '@/utils/utils.js'
import MkIcon from '@/components/mk-icon'
@@ -110,7 +110,7 @@
        }
  
        if (card.field) {
          __param.$searchkey = card.field.toLowerCase()
          __param.$searchkey = card.field
          __param.$searchval = data[card.field] || ''
        }
      
@@ -162,71 +162,78 @@
    }
    // positecgroup
    // if (/^sso$/ig.test(url)) {
    //   if (!data.LinkUrl1) {
    //     notification.warning({
    //       top: 92,
    //       message: '链接地址不存在!',
    //       duration: 5
    //     })
    //     return
    //   }
    if (/^sso$/ig.test(url)) {
      if (!data.LinkUrl1) {
        notification.warning({
          top: 92,
          message: '链接地址不存在!',
          duration: 5
        })
        return
      }
    //   let _url = data.LinkUrl1
    //   if (/index\.html/ig.test(_url)) {
    //     _url = _url.replace(/index\.html.*/ig, '')
    //   } else if (!/\/$/ig.test(_url)) {
    //     _url = _url + '/'
    //   }
      let _url = data.LinkUrl1
      if (/index\.html/ig.test(_url)) {
        _url = _url.replace(/index\.html.*/ig, '')
      } else if (!/\/$/ig.test(_url)) {
        _url = _url + '/'
      }
    //   let key = (() => {
    //     let uuid = []
    //     let timestamp = new Date().getTime()
    //     let _options = '0123456789abcdefghigklmnopqrstuv'
    //     for (let i = 0; i < 19; i++) {
    //       uuid.push(_options.substr(Math.floor(Math.random() * 0x20), 1))
    //     }
    //     uuid = timestamp + uuid.join('')
    //     return uuid
    //   })()
      let key = (() => {
        let uuid = []
        let timestamp = new Date().getTime()
        let _options = '0123456789abcdefghigklmnopqrstuv'
        for (let i = 0; i < 19; i++) {
          uuid.push(_options.substr(Math.floor(Math.random() * 0x20), 1))
        }
        uuid = timestamp + uuid.join('')
        return uuid
      })()
    //   let _param = {
    //     func: 'webapi_scan_binding_key',
    //     binding_type: 'mk',
    //     scan_type: 'toggle',
    //     scan_appkey: data.scan_appkey || '',
    //     id: key
    //   }
      let _param = {
        func: 'webapi_scan_binding_key',
        binding_type: 'mk',
        scan_type: 'toggle',
        scan_appkey: data.scan_appkey || '',
        id: key
      }
  
    //   Api.getSystemConfig(_param).then(res => {
    //     if (!res.status) {
    //       notification.warning({
    //         top: 92,
    //         message: res.message,
    //         duration: 5
    //       })
    //     } else if (res.thd_party_appid && res.thd_party_member_id && res.thd_party_openid) {
    //       let href = _url + 'admin/index.html#/ssologin/' + window.btoa(window.encodeURIComponent(JSON.stringify({
    //         appid: res.thd_party_appid,
    //         memberId: res.thd_party_member_id,
    //         openid: res.thd_party_openid,
    //         key: key
    //       })))
    //       window.open(href)
    //     } else {
    //       notification.warning({
    //         top: 92,
    //         message: '信息缺失,请联系管理员!',
    //         duration: 5
    //       })
    //     }
    //   })
    //   return
    // }
      Api.getSystemConfig(_param).then(res => {
        if (!res.status) {
          notification.warning({
            top: 92,
            message: res.message,
            duration: 5
          })
        } else if (res.thd_party_appid && res.thd_party_member_id && res.thd_party_openid) {
          let href = _url + 'admin/index.html#/ssologin/' + window.btoa(window.encodeURIComponent(JSON.stringify({
            appid: res.thd_party_appid,
            memberId: res.thd_party_member_id,
            openid: res.thd_party_openid,
            key: key
          })))
          window.open(href)
        } else {
          notification.warning({
            top: 92,
            message: '信息缺失,请联系管理员!',
            duration: 5
          })
        }
      })
      return
    }
    
    if (/^http.+(.txt|.doc|.docx|.pdf|.xlsx|.xls|.zip|.rar|.ppt)$/i.test(url)) {
      let name = url.replace(/.+\//g, '').replace(/\.{1}[^.]*$/g, '')
    if (/^http.+(.txt|.doc|.docx|.pdf|.xlsx|.xls|.zip|.rar|.ppt)$/i.test(url) || card.linkType === 'download') {
      let name = ''
      if (card.datatype === 'static') {
        name = card.value || ''
      } else if (data.hasOwnProperty(card.field)) {
        name = data[card.field] + ''
      }
      name = name.replace(/\.{1}[^.]*$/g, '')
      name = name ? name + url.replace(/.+\./g, '.') : ''
      let d = document.createElement('a')
      d.href = url
      d.setAttribute('download', name)
@@ -257,6 +264,7 @@
        Object.keys(data).forEach(key => {
          if (/^\$/.test(key)) return
          if (key === 'children') return
          let reg = new RegExp('@' + key + '@', 'ig')
          url = url.replace(reg, data[key])
        })
@@ -554,6 +562,9 @@
          }
          if (card.format === 'percent') {
            val = val * 100
            if (!card.round) {
              val = +val.toFixed(2)
            }
          } else if (card.format === 'abs') {
            val = Math.abs(val)
          }
@@ -645,10 +656,21 @@
          }
        }
        let _style = {...card.style}
        if (card.marks) {
          let _s = {}
          getMark(card.marks, data, _s)
          if (_s.color) {
            _style.color = _s.color
          }
        }
        if (card.tipType === 'text') {
          contents.push(
            <div className={'ant-col ant-col-' + card.width} key={card.uuid} style={_style_} span={card.width}>
              <div style={card.style}>
              <div style={_style}>
                {val ? <Tooltip title={val}>
                  <div className={'ant-mk-text line' + (card.height || '')} style={{height: card.innerHeight}}>{icon}</div>
                </Tooltip> : <div className={'ant-mk-text line' + (card.height || '')} style={{height: card.innerHeight}}>{icon}</div>}
@@ -658,7 +680,7 @@
        } else {
          contents.push(
            <div className={'ant-col ant-col-' + card.width} key={card.uuid} style={_style_} span={card.width}>
              <div style={card.style}>
              <div style={_style}>
                {val ? <Tooltip title={val}>
                  <MkIcon className="ant-mk-icon" style={{height: card.innerHeight}} type={icon}/>
                </Tooltip> : <MkIcon className="ant-mk-icon" style={{height: card.innerHeight}} type={icon}/>}
@@ -713,6 +735,7 @@
          }
        } else {
          url = data[card.field] || ''
          url = url.replace(/@mywebsite@\//ig, window.GLOB.baseurl)
        }
  
        if (url === '' && card.noValue === 'hide') { // 空值隐藏
@@ -944,7 +967,7 @@
                // eslint-disable-next-line
                _val = eval(_val)
              } catch (e) {
                console.info(_val)
                window.mkInfo(_val)
                console.warn(e)
                _val = 0
              }
@@ -958,12 +981,49 @@
          val = ''
        } else if (data) {
          let _val = card.formula
          if (/@username@|@fullName@|@bid@/ig.test(_val)) {
            _val = _val.replace(/@username@/ig, sessionStorage.getItem('User_Name') || '').replace(/@fullName@/ig, sessionStorage.getItem('Full_Name') || '').replace(/@bid@/ig, data.$$BID || '')
          }
          let _data = {}
          Object.keys(data).forEach(key => {
            if (/^\$/.test(key)) return
            if (key === 'children') return
            if (/^1949-10-01/.test(data[key])) {
              _data[key.toLowerCase()] = ''
            } else if (/\d{4}-\d{2}-\d{2}\s00:00:00/.test(data[key])) {
              _data[key.toLowerCase()] = data[key].replace(/\s00:00:00/g, '')
            } else {
              _data[key.toLowerCase()] = data[key]
            }
          })
          _data.username = sessionStorage.getItem('User_Name') || ''
          _data.fullname = sessionStorage.getItem('Full_Name') || ''
          _data.bid = data.$$BID || ''
          if (card.eval === 'false' && card.noValue === 'hide') { // 空值隐藏
            if (card.$keys) {
              let empty = true
              card.$keys.forEach(key => {
                if (!_data.hasOwnProperty(key)) {
                  empty = false
                } else if (_data[key]) {
                  empty = false
                }
              })
              if (empty) return null
            }
            Object.keys(_data).forEach(key => {
              if (_data[key]) return
              _val = _val.replace(new RegExp('[^@]*@' + key + '@', 'ig'), '')
            })
            if (!_val) return null
          }
          Object.keys(_data).forEach(key => {
            let reg = new RegExp('@' + key + '@', 'ig')
            _val = _val.replace(reg, data[key])
            _val = _val.replace(reg, _data[key])
          })
          if (card.eval !== 'false') {
@@ -971,7 +1031,7 @@
              // eslint-disable-next-line
              _val = eval(_val)
            } catch (e) {
              console.info(_val)
              window.mkInfo(_val)
              console.warn(e)
              _val = ''
            }
@@ -992,7 +1052,7 @@
        if (val !== '') {
          if (val && typeof(val) === 'string') {
            if (!card.evalchars || card.evalchars.includes('enter')) {
              val = val.replace(/\n/ig, '<br/>')
              val = val.replace(/\\n|\n/ig, '<br/>')
            }
            if ((!card.evalchars || card.evalchars.includes('space')) && !/<(span|div|p|a|img)\s/g.test(val)) {
              val = val.replace(/\s/ig, '&nbsp;')
@@ -1235,6 +1295,7 @@
            name={name}
            BID={data.$$BID}
            LID={lid}
            columns={cards.columns}
            BData={data.$$BData || ''}
            disabled={_disabled}
            selectedData={_data}
@@ -1297,6 +1358,7 @@
              disabled={_disabled}
              LID={lid}
              btn={card}
              columns={cards.columns}
              selectedData={_data}
            />
          }