From 0eb129a9beddbb86ae74d7106a8e60823206b8d5 Mon Sep 17 00:00:00 2001
From: king <18310653075@163.com>
Date: 星期四, 14 十二月 2023 11:29:15 +0800
Subject: [PATCH] 2023-12-14

---
 src/tabviews/custom/components/card/cardcellList/index.jsx |  361 ++++++++++++++++++++++++++++++++-------------------
 1 files changed, 227 insertions(+), 134 deletions(-)

diff --git a/src/tabviews/custom/components/card/cardcellList/index.jsx b/src/tabviews/custom/components/card/cardcellList/index.jsx
index 33e1622..16d6feb 100644
--- a/src/tabviews/custom/components/card/cardcellList/index.jsx
+++ b/src/tabviews/custom/components/card/cardcellList/index.jsx
@@ -4,9 +4,8 @@
 import { Col, Tooltip, notification, Typography, message } from 'antd'
 import moment from 'moment'
 
-// import Api from '@/api'
-import asyncComponent from './asyncButtonComponent'
-import asyncElementComponent from '@/utils/asyncComponent'
+import Api from '@/api'
+import asyncComponent from '@/utils/asyncComponent'
 import { getMark } from '@/utils/utils.js'
 import MkIcon from '@/components/mk-icon'
 import Encrypts from '@/components/encrypts'
@@ -25,9 +24,9 @@
 const FuncMegvii = asyncComponent(() => import('@/tabviews/zshare/actionList/funcMegvii'))
 const FuncZip = asyncComponent(() => import('@/tabviews/zshare/actionList/funczip'))
 const EditLine = asyncComponent(() => import('@/tabviews/zshare/actionList/editLine'))
-const BarCode = asyncElementComponent(() => import('@/components/barcode'))
-const QrCode = asyncElementComponent(() => import('@/components/qrcode'))
-const MkProgress = asyncElementComponent(() => import('@/components/mkProgress'))
+const BarCode = asyncComponent(() => import('@/components/barcode'))
+const QrCode = asyncComponent(() => import('@/components/qrcode'))
+const MkProgress = asyncComponent(() => import('@/components/mkProgress'))
 const Video = asyncComponent(() => import('@/components/video'))
 const MkPicture = asyncComponent(() => import('@/components/mkPicture'))
 const PicRadio = {
@@ -77,7 +76,7 @@
   }
 
   shouldComponentUpdate (nextProps, nextState) {
-    return !is(fromJS(this.props), fromJS(nextProps))
+    return !is(fromJS(this.props.data), fromJS(nextProps.data)) || (nextProps.syncData ? !is(fromJS(this.props.syncData), fromJS(nextProps.syncData)) : false)
   }
 
   /**
@@ -136,88 +135,98 @@
     }
 
     // positecgroup
-    // 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 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
-    //   }
-  
-    //   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
-    // }
-
-    let Id = ''
-
-    if (cards.subtype === 'propcard' && cardCell) {
-      Id = cardCell.setting.primaryId || ''
-    } else {
-      Id = data[cards.setting.primaryKey] || ''
-    }
-    
-    if (card.joint === 'true') {
-      let con = '?'
-
-      if (/\?/ig.test(url)) {
-        con = '&'
+    if (/^sso$/ig.test(url)) {
+      if (!data.LinkUrl1) {
+        notification.warning({
+          top: 92,
+          message: '閾炬帴鍦板潃涓嶅瓨鍦紒',
+          duration: 5
+        })
+        return
       }
 
-      url = url + `${con}id=${Id}&appkey=${window.GLOB.appkey}&userid=${sessionStorage.getItem('UserID')}&LoginUID=${sessionStorage.getItem('LoginUID') || ''}`
-    }
+      let _url = data.LinkUrl1
+      if (/index\.html/ig.test(_url)) {
+        _url = _url.replace(/index\.html.*/ig, '')
+      } else if (!/\/$/ig.test(_url)) {
+        _url = _url + '/'
+      }
 
-    window.open(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 _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
+    }
+    
+    if (/^http.+(.txt|.doc|.docx|.pdf|.xlsx|.xls|.zip|.rar|.ppt)$/i.test(url)) {
+      let name = url.replace(/.+\//g, '').replace(/\.{1}[^.]*$/g, '')
+      let d = document.createElement('a')
+      d.href = url
+      d.setAttribute('download', name)
+      d.setAttribute('target', '_blank')
+      document.body.appendChild(d)
+      d.click()
+      d.remove()
+    } else {
+      if (card.joint === 'true') {
+        let Id = ''
+  
+        if (cards.subtype === 'propcard' && cardCell) {
+          Id = cardCell.setting.primaryId || ''
+        } else {
+          Id = data[cards.setting.primaryKey] || ''
+        }
+  
+        let con = '?'
+  
+        if (/\?/ig.test(url)) {
+          con = '&'
+        }
+  
+        url = url + `${con}id=${Id}&appkey=${window.GLOB.appkey}&userid=${sessionStorage.getItem('UserID')}&LoginUID=${sessionStorage.getItem('LoginUID') || ''}`
+      }
+  
+      window.open(url)
+    }
   }
 
   getColor = (marks) => {
@@ -266,6 +275,8 @@
 
       if (card.style && card.style.clear === 'left') {
         _style_ = {clear: 'left'}
+      } else if (card.style && card.style.clear === 'right') {
+        _style_ = {float: 'right'}
       }
 
       if (card.eleType === 'sequence') {
@@ -277,8 +288,7 @@
           _style.lineHeight = card.innerHeight + 'px'
   
           let mark = getMark(card.marks, data, _style)
-  
-          _style = mark.style
+
           className = mark.signType
         }
         contents.push(
@@ -294,38 +304,39 @@
   
         if (card.datatype === 'static') {
           val = card.value || ''
-          if (/@username@|@fullName@|@mk_city@|@bid@/ig.test(val)) {
-            let userName = sessionStorage.getItem('User_Name') || ''
-            let fullName = sessionStorage.getItem('Full_Name') || ''
-            let city = sessionStorage.getItem('city') || ''
-            let bid = data.$$BID || ''
-            val = val.replace(/@username@/ig, userName).replace(/@fullName@/ig, fullName).replace(/@mk_city@/ig, city).replace(/@bid@/ig, bid)
-          } else if (/@month@/ig.test(val)) {
-            val = val.replace(/@month@/ig, new Date().toLocaleString('en-US', { month: 'long' }))
-          } else if (/@week@/ig.test(val)) {
-            val = val.replace(/@week@/ig, (() => {
-              let day = new Date().getDay()
-              let weeks = ['鏄熸湡鏃�', '鏄熸湡涓�', '鏄熸湡浜�', '鏄熸湡涓�', '鏄熸湡鍥�', '鏄熸湡浜�', '鏄熸湡鍏�']
-              return weeks[day]
-            })())
-          } else if (/@day@/ig.test(val)) {
-            val = val.replace(/@day@/ig, (() => {
-              let day = new Date().getDate()
-              return day < 10 ? '0' + day : day
-            })())
+          if (/@.+@/g.test(val)) {
+            if (/@username@|@fullName@|@mk_city@|@appname@|@bid@/ig.test(val)) {
+              let userName = sessionStorage.getItem('User_Name') || ''
+              let fullName = sessionStorage.getItem('Full_Name') || ''
+              let city = sessionStorage.getItem('city') || ''
+              let appname = sessionStorage.getItem('appname') || ''
+              let bid = data.$$BID || ''
+              val = val.replace(/@username@/ig, userName).replace(/@fullName@/ig, fullName).replace(/@mk_city@/ig, city).replace(/@appname@/ig, appname).replace(/@bid@/ig, bid)
+            } else if (/@month@/ig.test(val)) {
+              val = val.replace(/@month@/ig, new Date().toLocaleString('en-US', { month: 'long' }))
+            } else if (/@week@/ig.test(val)) {
+              val = val.replace(/@week@/ig, (() => {
+                let day = new Date().getDay()
+                let weeks = ['鏄熸湡鏃�', '鏄熸湡涓�', '鏄熸湡浜�', '鏄熸湡涓�', '鏄熸湡鍥�', '鏄熸湡浜�', '鏄熸湡鍏�']
+                return weeks[day]
+              })())
+            } else if (/@day@/ig.test(val)) {
+              val = val.replace(/@day@/ig, (() => {
+                let day = new Date().getDate()
+                return day < 10 ? '0' + day : day
+              })())
+            }
           }
         } else if (data.hasOwnProperty(card.field)) {
-          val = data[card.field]
+          val = data[card.field] + ''
         }
   
-        if (!val && card.noValue === 'hide') { // 绌哄�奸殣钘�
-          return null
-        }
-  
-        if (val !== '' && card.format) {
+        if (val && card.format && card.format !== 'encryption') {
           let _val = null
   
-          if (card.format === 'calendar1') {
+          if (val < '1949-10-02') {
+            val = ''
+          } else if (card.format === 'calendar1') {
             _val = moment(val).calendar(null, {
               sameDay: '[浠婂ぉ] ahh:mm',
               nextDay: '[鏄庡ぉ] ahh:mm',
@@ -372,17 +383,43 @@
           } else {
             _val = moment(val).format(card.format)
           }
-          
-          // if (card.format === 'YYYY-MM-DD' && /^[1-9]\d{3}(-|\/)(0[1-9]|1[0-2])(-|\/)(0[1-9]|[1-2][0-9]|3[0-1])/.test(val)) {
-          //   val = `${val.substr(0, 4)}-${val.substr(5, 2)}-${val.substr(8, 2)}`
-          // }
+
           if (_val && _val !== 'Invalid date') {
             val = _val
           }
         }
+
+        if (!val && card.noValue === 'hide') { // 绌哄�奸殣钘�
+          return null
+        }
   
         if (val !== '') {
           let orival = val
+
+          if (card.linkType === 'download') {
+            let url = ''
+  
+            if (card.link === 'static') {
+              url = card.linkurl
+            } else {
+              url = data[card.linkurl]
+            }
+  
+            if (/^http.+(.txt|.doc|.docx|.pdf|.xlsx|.xls|.zip|.rar)$/i.test(url)) {
+              if (/pdf$/i.test(url)) {
+                val = <><img src="./media/pdf.png" className="file-image" alt=""/> {val}</>
+              } else if (/(.doc|.docx)$/i.test(url)) {
+                val = <><img src="./media/word.png" className="file-image" alt=""/> {val}</>
+              } else if (/(.xlsx|.xls)$/i.test(url)) {
+                val = <><img src="./media/excel.png" className="file-image" alt=""/> {val}</>
+              } else if (/(.zip|.rar)$/i.test(url)) {
+                val = <><img src="./media/rar.png" className="file-image" alt=""/> {val}</>
+              } else {
+                val = <><img src="./media/txt.png" className="file-image" alt=""/> {val}</>
+              }
+            }
+          }
+
           if (card.format === 'encryption') {
             val = <Encrypts value={val} />
           }
@@ -417,13 +454,19 @@
         if (card.marks) {
           let mark = getMark(card.marks, data, _style)
   
-          _style = mark.style
-  
           if (mark.icon) {
             if (mark.position === 'front') {
               val = <span><MkIcon style={mark.innerStyle} type={mark.icon} /> {val}</span>
             } else {
               val = <span>{val} <MkIcon style={mark.innerStyle} type={mark.icon} /></span>
+            }
+          } else if (mark.space) {
+            val = <><span style={{float: 'left'}} dangerouslySetInnerHTML={{__html: mark.space}}></span>{val}</>
+          } else if (mark.point) {
+            if (mark.position === 'front') {
+              val = <>{mark.point}{val}</>
+            } else {
+              val = <>{val}{mark.point}</>
             }
           }
           className = mark.signType
@@ -499,13 +542,19 @@
         if (card.marks) {
           let mark = getMark(card.marks, data, _style)
   
-          _style = mark.style
-  
           if (mark.icon) {
             if (mark.position === 'front') {
               val = <span><MkIcon style={mark.innerStyle} type={mark.icon} /> {val}</span>
             } else {
               val = <span>{val} <MkIcon style={mark.innerStyle} type={mark.icon} /></span>
+            }
+          } else if (mark.space) {
+            val = <><span style={{float: 'left'}} dangerouslySetInnerHTML={{__html: mark.space}}></span>{val}</>
+          } else if (mark.point) {
+            if (mark.position === 'front') {
+              val = <>{mark.point}{val}</>
+            } else {
+              val = <>{val}{mark.point}</>
             }
           }
           className = mark.signType
@@ -539,6 +588,16 @@
           val = data[card.tooltip]
         } else {
           val = card.tooltip
+        }
+
+        if (/\\n|\n/.test(val)) {
+          val = val.replace(/(\\n|\n)$/, '')
+        
+          if (val) {
+            val = val.split(/\\n|\n/)
+        
+            val = <div>{val.map((cell, i) => <div style={{marginBottom: 2}} key={i}>{cell}</div>)}</div>
+          }
         }
 
         if (card.tipType === 'text') {
@@ -630,6 +689,10 @@
   
         if (card.link) {
           _style.cursor = 'pointer'
+        }
+
+        if (_style.position === 'absolute') {
+          _style.width = '100%'
         }
   
         let scale = url && card.scale === 'true'
@@ -749,8 +812,24 @@
       } else if (card.eleType === 'formula') {
         let val = 0
         let _style = {...card.style}
+        
+        if (card.eval === 'func') {
+          let _data = []
+          if (card.$sync) {
+            _data = this.props.syncData
+          } else if (data && !data.$$empty) {
+            _data = [data]
+          }
 
-        if (card.$sync) {
+          try {
+            // eslint-disable-next-line
+            let func = new Function('data', card.formula)
+            val = func(_data)
+          } catch (e) {
+            console.warn(e)
+            val = ''
+          }
+        } else if (card.$sync) {
           if (card.eval === 'false') {
             val = ''
           }
@@ -765,10 +844,8 @@
                 // eslint-disable-next-line
                 _val = eval(_val)
               } catch (e) {
-                if (window.debugger) {
-                  console.info(_val)
-                  console.warn(e)
-                }
+                console.info(_val)
+                console.warn(e)
                 _val = 0
               }
             }
@@ -777,7 +854,7 @@
   
             val += _val
           })
-        } else if (data && data.$$empty) {
+        } else if (data && data.$$empty && /@.*@/.test(card.formula)) {
           val = ''
         } else if (data) {
           let _val = card.formula
@@ -791,10 +868,8 @@
               // eslint-disable-next-line
               _val = eval(_val)
             } catch (e) {
-              if (window.debugger) {
-                console.info(_val)
-                console.warn(e)
-              }
+              console.info(_val)
+              console.warn(e)
               _val = ''
             }
           }
@@ -804,6 +879,15 @@
 
         if (!val && card.noValue === 'hide') { // 绌哄�奸殣钘�
           return null
+        } else if (card.eval === 'func') {
+          contents.push(
+            <div className={'ant-col ant-col-' + card.width} key={card.uuid} style={_style_} span={card.width}>
+              <div style={_style}>
+                <div className={'ant-mk-text line' + (card.height || '')} style={{height: card.innerHeight}} dangerouslySetInnerHTML={{__html: val}}></div>
+              </div>
+            </div>
+          )
+          return
         }
 
         if (card.round && typeof(val) === 'number') {
@@ -836,13 +920,19 @@
         if (card.marks) {
           let mark = getMark(card.marks, data, _style)
   
-          _style = mark.style
-  
           if (mark.icon) {
             if (mark.position === 'front') {
               val = <span><MkIcon style={mark.innerStyle} type={mark.icon} /> {val}</span>
             } else {
               val = <span>{val} <MkIcon style={mark.innerStyle} type={mark.icon} /></span>
+            }
+          } else if (mark.space) {
+            val = <><span style={{float: 'left'}} dangerouslySetInnerHTML={{__html: mark.space}}></span>{val}</>
+          } else if (mark.point) {
+            if (mark.position === 'front') {
+              val = <>{mark.point}{val}</>
+            } else {
+              val = <>{val}{mark.point}</>
             }
           }
           className = mark.signType
@@ -907,6 +997,9 @@
   
         if (data.$$type === 'extendCard') {
           _data = data.$$selectedData || []
+          if (card.Ot === 'notRequired' && _data.length === 0) {
+            _data = [data]
+          }
         } else if (card.$sync) {
           _data = this.props.syncData || []
         } else if (data.$$empty) {

--
Gitblit v1.8.0