From a9b02f6862522b54d0824152017bf2acfec2af7b Mon Sep 17 00:00:00 2001
From: king <18310653075@163.com>
Date: 星期四, 21 三月 2024 10:29:50 +0800
Subject: [PATCH] 2024-03-21

---
 src/tabviews/zshare/actionList/printbutton/index.jsx |  212 ++++++++++++++++++++++++++++++++++-------------------
 1 files changed, 136 insertions(+), 76 deletions(-)

diff --git a/src/tabviews/zshare/actionList/printbutton/index.jsx b/src/tabviews/zshare/actionList/printbutton/index.jsx
index fdc3ac2..e16a32c 100644
--- a/src/tabviews/zshare/actionList/printbutton/index.jsx
+++ b/src/tabviews/zshare/actionList/printbutton/index.jsx
@@ -270,6 +270,9 @@
 
             Object.keys(cell).forEach(key => {
               let _key = key.toLowerCase()
+
+              if (/^\$/.test(_key)) return
+              
               _cell[_key] = cell[key]
             })
 
@@ -405,7 +408,6 @@
             errorMsg = {
               ErrCode: 'N',
               message: _temp.error,
-              ErrMesg: _temp.error,
               status: false
             }
           } else {
@@ -565,16 +567,28 @@
   execCustomPrint = (printlist, formdata) => {
     const { btn } = this.props
 
-    this.execSuccess({
-      ErrCode: '-1',
-      message: '',
-      status: true
-    })
+    let callback = null
+
+    if (/callback\(\)/.test(btn.verify.printFunc)) {
+      callback = () => {
+        this.execSuccess({
+          ErrCode: '-1',
+          message: '',
+          status: true
+        })
+      }
+    } else {
+      this.execSuccess({
+        ErrCode: '-1',
+        message: '',
+        status: true
+      })
+    }
 
     try {
       // eslint-disable-next-line
-      let func = new Function('data', 'form', 'printer', 'notification', 'Api', 'systemType', btn.verify.printFunc)
-      func(printlist, formdata, btn.verify, notification, Api, window.GLOB.systemType)
+      let func = new Function('data', 'form', 'printer', 'notification', 'Api', 'systemType', 'callback', btn.verify.printFunc)
+      func(printlist, formdata, btn.verify, notification, Api, window.GLOB.systemType, callback)
 
       // 鑷畾涔夋墦鍗扮ず渚�
       // let defaultPrinter = printer.defaultPrinter || 'lackprinter'
@@ -770,18 +784,11 @@
     } catch (e) {
       console.warn(e)
 
-      try {
-        // eslint-disable-next-line
-        let evalfunc = eval('(true && function (data, form, printer, notification, Api, systemType) {' + btn.verify.printFunc + '})')
-        evalfunc(printlist, formdata, btn.verify, notification, Api, window.GLOB.systemType)
-      } catch (error) {
-        console.warn(error)
-        notification.warning({
-          top: 92,
-          message: '鑷畾涔夊嚱鏁版墽琛岄敊璇紒',
-          duration: 5
-        })
-      }
+      notification.warning({
+        top: 92,
+        message: '鑷畾涔夊嚱鏁版墽琛岄敊璇紒',
+        duration: 5
+      })
     }
   }
 
@@ -903,6 +910,11 @@
         if (btn.intertype === 'inner') {
           params = params.map(_param => {
             _param.func = btn.innerFunc
+
+            if (btn.recordUser === 'true') {
+              _param.username = sessionStorage.getItem('User_Name') || ''
+              _param.fullname = sessionStorage.getItem('Full_Name') || ''
+            }
   
             return _param
           })
@@ -950,7 +962,7 @@
     let param = {
       func: 'sPC_Get_TableData',
       obj_name: 'data',
-      exec_type: 'y',
+      exec_type: window.GLOB.execType || 'y',
       arr_field: arrFields,
       default_sql: btn.verify.setting.defaultSql
     }
@@ -995,7 +1007,11 @@
     }
 
     let isDataM = sessionStorage.getItem('dataM') === 'true'
+    let custompage = /@pageSize@|@orderBy@/i.test(_dataresource + _customScript + _tailScript)
     let regoptions = [
+      { reg: /@orderBy@/ig, value: btn.verify.setting.order },
+      { reg: /@pageSize@/ig, value: '9999' },
+      { reg: /@pageIndex@/ig, value: '1'},
       { reg: /@ID@/ig, value: `'${ID}'`},
       { reg: /@BID@/ig, value: `'${BID || ''}'`},
       { reg: /@LoginUID@/ig, value: `'${sessionStorage.getItem('LoginUID') || ''}'`},
@@ -1045,7 +1061,7 @@
         _initvars.push(`@${_key}='${form.value}'`)
       }
 
-      if (form.fieldlen && form.fieldlen > 2048) {
+      if (form.fieldlen && form.fieldlen > 4000) {
         form.fieldlen = 'max'
       }
 
@@ -1113,7 +1129,11 @@
     let LText = ''
 
     if (_dataresource) {
-      LText = `/*system_query*/select ${arrFields} from (select ${arrFields} ,ROW_NUMBER() over(order by ${btn.verify.setting.order}) as rows from ${_dataresource}) tmptable order by tmptable.rows `
+      if (custompage) {
+        LText = `/*system_query*/select ${arrFields} from ${_dataresource} `
+      } else {
+        LText = `/*system_query*/select ${arrFields} from (select ${arrFields} ,ROW_NUMBER() over(order by ${btn.verify.setting.order}) as rows from ${_dataresource}) tmptable order by tmptable.rows `
+      }
     }
 
     if (_customScript) {
@@ -1156,8 +1176,8 @@
       param.menuname = btn.logLabel
     }
 
-    param.custom_script = Utils.formatOptions(_customScript)
-    param.LText = Utils.formatOptions(LText)
+    param.custom_script = Utils.formatOptions(_customScript, param.exec_type)
+    param.LText = Utils.formatOptions(LText, param.exec_type)
 
     param.timestamp = moment().format('YYYY-MM-DD HH:mm:ss')
     param.secretkey = Utils.encrypt('', param.timestamp)
@@ -1213,41 +1233,27 @@
       // 澶栭儴璇锋眰
       _outParam = JSON.parse(JSON.stringify(res))
 
-      if (window.GLOB.mkHS) {
-        if (btn.sysInterface === 'true' && window.GLOB.cloudServiceApi) {
-          res.rduri = window.GLOB.cloudServiceApi
-          res.userid = sessionStorage.getItem('CloudUserID') || ''
-          res.LoginUID = sessionStorage.getItem('CloudLoginUID') || ''
-        } else if (btn.sysInterface !== 'true') {
-          if (window.GLOB.systemType === 'production' && btn.proInterface) {
-            res.rduri = btn.proInterface
-          } else {
-            res.rduri = btn.interface
-          }
+      if (btn.sysInterface === 'true') {
+        if (window.GLOB.mainSystemApi) {
+          res.rduri = window.GLOB.mainSystemApi
         }
-      } else {
-        if (btn.sysInterface === 'true') {
-          if (window.GLOB.mainSystemApi) {
-            res.rduri = window.GLOB.mainSystemApi
-          }
-        } else if (btn.sysInterface === 'external') {
-          if (window.GLOB.systemType === 'production') {
-            res.$token = btn.exProInterface || ''
-          } else {
-            res.$token = btn.exInterface || ''
-          }
-          ver_token = true
+      } else if (btn.sysInterface === 'external') {
+        if (window.GLOB.systemType === 'production') {
+          res.$token = btn.exProInterface || ''
         } else {
-          if (window.GLOB.systemType === 'production' && btn.proInterface) {
-            res.rduri = btn.proInterface
-          } else {
-            res.rduri = btn.interface
-          }
+          res.$token = btn.exInterface || ''
+        }
+        ver_token = true
+      } else {
+        if (window.GLOB.systemType === 'production' && btn.proInterface) {
+          res.rduri = btn.proInterface
+        } else {
+          res.rduri = btn.interface
+        }
 
-          let host = window.GLOB.baseurl.replace(/http(s):\/\//, '')
-          if (res.rduri.indexOf(host) === -1 && /\/dostars/.test(res.rduri)) {
-            res.$login = true
-          }
+        let host = window.GLOB.baseurl.replace(/http(s):\/\//, '')
+        if (res.rduri.indexOf(host) === -1 && /\/dostars/.test(res.rduri)) {
+          res.$login = true
         }
       }
 
@@ -1259,7 +1265,8 @@
     }).then(response => {
       if (!response || response.ErrCode === 'LoginError') return
 
-      if (ver_token && response.ErrMesg === 'token_error') {
+      if (ver_token && response.ErrCode === 'token_error') {
+        response.ErrCode = 'E'
         this.execError(response)
         _resolve({next: false, list: []})
       } else if (btn.callbackFunc) {
@@ -1770,26 +1777,35 @@
       return
     }
 
+    if (printerList.length === 0) {
+      this.execSuccess({
+        ErrCode: '-1',
+        message: '鏈幏鍙栧埌鎵撳嵃淇℃伅锛�',
+        status: true
+      })
+      return
+    }
+
     if (!socket || socket.readyState !== 1 || socket.url !== 'ws://' + btn.verify.linkUrl) {
       socket = new WebSocket('ws://' + btn.verify.linkUrl)
     } else {
-      this.syncMessageSend(printerList)
-
-      this.execSuccess({
-        ErrCode: 'S',
-        message: '鎵撳嵃璇锋眰宸插彂鍑恒��',
-        status: true
+      this.syncMessageSend(printerList, () => {
+        this.execSuccess({
+          ErrCode: 'S',
+          message: '鎵撳嵃璇锋眰宸插彂鍑恒��',
+          status: true
+        })
       })
     }
 
     // 鎵撳紑Socket
     socket.onopen = () =>{
-      this.syncMessageSend(printerList)
-
-      this.execSuccess({
-        ErrCode: 'S',
-        message: '鎵撳嵃璇锋眰宸插彂鍑恒��',
-        status: true
+      this.syncMessageSend(printerList, () => {
+        this.execSuccess({
+          ErrCode: 'S',
+          message: '鎵撳嵃璇锋眰宸插彂鍑恒��',
+          status: true
+        })
       })
     }
     // 鐩戝惉娑堟伅
@@ -1844,17 +1860,26 @@
     }
   }
 
-  syncMessageSend = (list) => {
+  syncMessageSend = (list, callback) => {
     let param = list.shift()
 
-    if (socket && param) {
-      socket.send(JSON.stringify(param))
+    if (socket) {
+      try {
+        socket.send(JSON.stringify(param))
+      } catch(e) {
+        console.warn('鎵撳嵃璇锋眰鍙戦�佸け璐ワ紒')
+      }
     }
 
-    if (list && list.length > 0) {
-      setTimeout(() => {this.syncMessageSend(list)}, 3000)
+    if (list.length > 0) {
+      setTimeout(() => {
+        this.syncMessageSend(list, callback)
+      }, 3000)
+    } else {
+      callback()
     }
   }
+
   /**
    * @description 鎿嶄綔鎴愬姛鍚庡鐞�
    * 1銆乪xcel瀵煎嚭锛屾垚鍔熷悗鍙栨秷瀵煎嚭鎸夐挳鍔犺浇涓姸鎬�
@@ -1950,6 +1975,8 @@
       MKEmitter.emit('autoExecOver', btn.uuid, 'error')
       return
     }
+
+    if (res.ErrCode === '-2') return
 
     if (btnconfig && btnconfig.setting && btnconfig.setting.errFocus) {
       MKEmitter.emit('mkFC', 'focus', btnconfig.setting.errFocus)
@@ -2157,7 +2184,33 @@
         _item.value = _item.value.replace(/\t+|\v+/g, '')       // 鍘婚櫎鍒惰〃绗�
 
         if (item.interception !== 'false') {                    // 鍘婚櫎棣栧熬绌烘牸
-          _item.value = _item.value.replace(/(^\s*|\s*$)/g, '')
+          if (item.interception === 'func') {
+            try {
+              // eslint-disable-next-line
+              let func = new Function('value', 'data', item.func)
+              _item.value = func(_item.value, _data)
+              _item.value = _item.value !== undefined ? _item.value : ''
+            } catch (e) {
+              console.warn(e)
+              _item.value = ''
+            }
+          } else if (item.interception === 'charTure') {
+            let str = _item.value.replace(/(^\s*|\s*$)/g, '')
+            let result = ''
+            for (let i = 0 ; i < str.length; i++) {
+              let code = str.charCodeAt(i)
+              if (code >= 65281 && code <= 65373) {
+                result += String.fromCharCode(str.charCodeAt(i) - 65248)
+              } else if (code === 12288) {
+                result += String.fromCharCode(str.charCodeAt(i) - 12288 + 32)
+              } else {
+                result += str.charAt(i)
+              }
+            }
+            _item.value = result
+          } else {
+            _item.value = _item.value.replace(/(^\s*|\s*$)/g, '')
+          }
         }
         if (_item.type === 'text' && /@appkey@|@SessionUid@|@bid@/ig.test(_item.value)) { // 鐗规畩瀛楁鏇挎崲
           _item.value = _item.value.replace(/^(\s*)@appkey@(\s*)$/ig, window.GLOB.appkey).replace(/^(\s*)@SessionUid@(\s*)$/ig, (localStorage.getItem('SessionUid') || '')).replace(/^(\s*)@bid@(\s*)$/ig, (this.props.BID || ''))
@@ -2235,6 +2288,13 @@
       clickouter = true
     }
 
+    if (btnconfig.setting.icon) {
+      title = <>
+        <span className={'mk-modal-icon-' + btnconfig.setting.iconType} style={{background: btnconfig.setting.iconColor || 'unset', color: btnconfig.setting.iconColor || 'inherit'}}><MkIcon type={btnconfig.setting.icon}/></span>
+        {title}
+      </>
+    }
+
     return (
       <Modal
         title={title}

--
Gitblit v1.8.0