From da64ab0923bf8817fc8599a6e37b953ce38f64c8 Mon Sep 17 00:00:00 2001
From: king <18310653075@163.com>
Date: 星期日, 27 八月 2023 18:37:36 +0800
Subject: [PATCH] 2023-08-27

---
 src/tabviews/zshare/actionList/printbutton/index.jsx |  168 ++++++++++++++++++++++++++------------------------------
 1 files changed, 78 insertions(+), 90 deletions(-)

diff --git a/src/tabviews/zshare/actionList/printbutton/index.jsx b/src/tabviews/zshare/actionList/printbutton/index.jsx
index 2bbfe85..db4fd6a 100644
--- a/src/tabviews/zshare/actionList/printbutton/index.jsx
+++ b/src/tabviews/zshare/actionList/printbutton/index.jsx
@@ -6,9 +6,6 @@
 
 import Api from '@/api'
 import Utils from '@/utils/utils.js'
-import options from '@/store/options.js'
-import zhCN from '@/locales/zh-CN/main.js'
-import enUS from '@/locales/en-US/main.js'
 import asyncSpinComponent from '@/utils/asyncSpinComponent'
 import { updateForm } from '@/utils/utils-update.js'
 import MKEmitter from '@/utils/events.js'
@@ -32,7 +29,6 @@
   }
 
   state = {
-    dict: sessionStorage.getItem('lang') !== 'en-US' ? zhCN : enUS,
     visible: false,
     formdata: null,
     selines: null,
@@ -161,7 +157,7 @@
       // 闇�瑕侀�夋嫨琛屾椂锛屾牎楠屾暟鎹�
       notification.warning({
         top: 92,
-        message: this.state.dict['main.action.confirm.selectline'],
+        message: '璇烽�夋嫨琛岋紒',
         duration: 5
       })
       return
@@ -169,13 +165,9 @@
       // 闇�瑕侀�夋嫨鍗曡鏃讹紝鏍¢獙鏁版嵁
       notification.warning({
         top: 92,
-        message: this.state.dict['main.action.confirm.selectSingleLine'],
+        message: '璇烽�夋嫨鍗曡鏁版嵁锛�',
         duration: 5
       })
-      return
-    } else if (!['requiredSgl', 'notRequired', 'requiredOnce', 'required'].includes(btn.Ot)) {
-      // 鏁版嵁閫夋嫨绫诲瀷鏍¢獙
-      this.actionSettingError()
       return
     } else if (!btn.verify || !btn.verify.printMode) {
       notification.warning({
@@ -212,7 +204,7 @@
     } else if (btn.execMode === 'prompt') {
       this.setState({ loading: true })
       confirm({
-        title: this.state.dict['main.action.confirm.tip'],
+        title: '纭畾瑕佹墽琛屽悧?',
         onOk() {
           _this.triggerPrint(data)
         },
@@ -533,7 +525,7 @@
 
       return Api.getSystemCacheConfig(param)
     }).then(result => {
-      if (!result) {
+      if (!result || result.ErrCode === 'LoginError') {
         this.setState({ loading: false })
         return
       }
@@ -576,7 +568,6 @@
     this.execSuccess({
       ErrCode: '-1',
       message: '',
-      ErrMesg: '',
       status: true
     })
 
@@ -912,6 +903,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
           })
@@ -985,10 +981,15 @@
 
     let _dataresource = btn.verify.setting.dataresource
     let _customScript = ''
-
+    let _tailScript = ''
     btn.verify.scripts && btn.verify.scripts.forEach(script => {
-      if (script.status !== 'false') {
+      if (script.status === 'false') return
+      if (script.position !== 'back') {
         _customScript += `
+        ${script.sql}
+        `
+      } else {
+        _tailScript += `
         ${script.sql}
         `
       }
@@ -998,18 +999,28 @@
       _dataresource = ''
     }
 
+    let isDataM = sessionStorage.getItem('dataM') === 'true'
+    let regoptions = [
+      { reg: /@ID@/ig, value: `'${ID}'`},
+      { reg: /@BID@/ig, value: `'${BID || ''}'`},
+      { reg: /@LoginUID@/ig, value: `'${sessionStorage.getItem('LoginUID') || ''}'`},
+      { reg: /@SessionUid@/ig, value: `'${localStorage.getItem('SessionUid') || ''}'`},
+      { reg: /@UserID@/ig, value: `'${sessionStorage.getItem('UserID') || ''}'`},
+      { reg: /@Appkey@/ig, value: `'${window.GLOB.appkey || ''}'`},
+      { reg: /@typename@/ig, value: `'admin'`},
+      { reg: /\$@/ig, value: isDataM ? '/*' : ''},
+      { reg: /@\$/ig, value: isDataM ? '*/' : ''},
+      { reg: /@datam@/ig, value: isDataM ? `'Y'` : `''`},
+    ]
+
+    regoptions.forEach(item => {
+      _dataresource = _dataresource.replace(item.reg, item.value)
+      _customScript = _customScript.replace(item.reg, item.value)
+      _tailScript = _tailScript.replace(item.reg, item.value)
+    })
+
     if (/\s/.test(_dataresource)) {
       _dataresource = '(' + _dataresource + ') tb'
-    }
-
-    if (sessionStorage.getItem('dataM') === 'true') { // 鏁版嵁鏉冮檺
-      _dataresource = _dataresource.replace(/\$@/ig, '/*').replace(/@datam@/ig, '\'Y\'')
-      _dataresource = _dataresource.replace(/@\$/ig, '*/')
-      _customScript = _customScript.replace(/\$@/ig, '/*').replace(/@datam@/ig, '\'Y\'')
-      _customScript = _customScript.replace(/@\$/ig, '*/')
-    } else {
-      _dataresource = _dataresource.replace(/@\$|\$@/ig, '').replace(/@datam@/ig, '\'\'')
-      _customScript = _customScript.replace(/@\$|\$@/ig, '').replace(/@datam@/ig, '\'\'')
     }
 
     let initsql = `declare @ErrorCode nvarchar(50),@retmsg nvarchar(4000),@UserName nvarchar(50),@FullName nvarchar(50),@RoleID nvarchar(512),@mk_departmentcode nvarchar(512),@mk_organization nvarchar(512),@mk_user_type nvarchar(20),@mk_nation nvarchar(50),@mk_province nvarchar(50),@mk_city nvarchar(50),@mk_district nvarchar(50),@mk_address nvarchar(100)
@@ -1097,36 +1108,12 @@
         select ${_initvars.join(',')}
       `
     }
-
     
     if (_customScript) {
       _customScript = `${initsql}
         ${_customScript}
       `
     }
-
-    _dataresource = _dataresource.replace(/@select\$|\$select@/ig, '')
-    _customScript = _customScript.replace(/@select\$|\$select@/ig, '')
-    _dataresource = _dataresource.replace(/\$sum@/ig, '/*')
-    _dataresource = _dataresource.replace(/@sum\$/ig, '*/')
-    _customScript = _customScript.replace(/\$sum@/ig, '/*')
-    _customScript = _customScript.replace(/@sum\$/ig, '*/')
-
-    _dataresource = _dataresource.replace(/@ID@/ig, `'${ID}'`)
-    _customScript = _customScript.replace(/@ID@/ig, `'${ID}'`)
-    _dataresource = _dataresource.replace(/@BID@/ig, `'${BID || ''}'`)
-    _customScript = _customScript.replace(/@BID@/ig, `'${BID || ''}'`)
-    _dataresource = _dataresource.replace(/@LoginUID@/ig, `'${sessionStorage.getItem('LoginUID') || ''}'`)
-    _customScript = _customScript.replace(/@LoginUID@/ig, `'${sessionStorage.getItem('LoginUID') || ''}'`)
-    _dataresource = _dataresource.replace(/@SessionUid@/ig, `'${localStorage.getItem('SessionUid') || ''}'`)
-    _customScript = _customScript.replace(/@SessionUid@/ig, `'${localStorage.getItem('SessionUid') || ''}'`)
-    _dataresource = _dataresource.replace(/@UserID@/ig, `'${sessionStorage.getItem('UserID') || ''}'`)
-    _customScript = _customScript.replace(/@UserID@/ig, `'${sessionStorage.getItem('UserID') || ''}'`)
-    _dataresource = _dataresource.replace(/@Appkey@/ig, `'${window.GLOB.appkey || ''}'`)
-    _customScript = _customScript.replace(/@Appkey@/ig, `'${window.GLOB.appkey || ''}'`)
-    _dataresource = _dataresource.replace(/@typename@/ig, `'admin'`)
-    _customScript = _customScript.replace(/@typename@/ig, `'admin'`)
-
 
     let LText = ''
 
@@ -1137,17 +1124,27 @@
     if (_customScript) {
       if (LText) {
         LText = `${LText}
+          ${_tailScript}
           aaa:
           if @ErrorCode!=''
-            insert into tmp_err_retmsg (ID, ErrorCode, retmsg, CreateUserID) select @time_id@,@ErrorCode, @retmsg,@UserID@ 
+            insert into tmp_err_retmsg (ID, ErrorCode, retmsg, CreateUserID) select @time_id@,@ErrorCode, @retmsg,'${sessionStorage.getItem('UserID') || ''}' 
         `
       } else {
         _customScript = `${_customScript}
+          ${_tailScript}
           aaa:
           if @ErrorCode!=''
-            insert into tmp_err_retmsg (ID, ErrorCode, retmsg, CreateUserID) select @time_id@,@ErrorCode, @retmsg,@UserID@ 
+            insert into tmp_err_retmsg (ID, ErrorCode, retmsg, CreateUserID) select @time_id@,@ErrorCode, @retmsg,'${sessionStorage.getItem('UserID') || ''}' 
         `
       }
+    } else if (_tailScript) {
+      LText = `${initsql}
+        ${LText}
+        ${_tailScript}
+        aaa:
+        if @ErrorCode!=''
+          insert into tmp_err_retmsg (ID, ErrorCode, retmsg, CreateUserID) select @time_id@,@ErrorCode, @retmsg,'${sessionStorage.getItem('UserID') || ''}' 
+      `
     } else {
       LText = `${initsql}
         ${LText}
@@ -1155,7 +1152,7 @@
     }
 
     // 娴嬭瘯绯荤粺鎵撳嵃鏌ヨ璇彞
-    if (window.GLOB.debugger === true || (window.debugger === true && options.sysType !== 'cloud')) {
+    if (window.GLOB.debugger === true) {
       _customScript && console.info(`${btn.logLabel ? `/*${btn.logLabel} 鑷畾涔夎剼鏈�*/\n` : ''}${LText ? '' : '/*涓嶆墽琛岄粯璁ql*/\n'}${_customScript}`)
       LText && console.info(`${btn.logLabel ? `/*${btn.logLabel} 鏁版嵁婧�*/\n` : ''}` + LText.replace(/\n\s{8}/ig, '\n'))
     }
@@ -1169,6 +1166,9 @@
 
     param.timestamp = moment().format('YYYY-MM-DD HH:mm:ss')
     param.secretkey = Utils.encrypt('', param.timestamp)
+
+    param.username = userName
+    param.fullname = fullName
 
     if (window.GLOB.probation) {
       param.s_debug_type = 'Y'
@@ -1219,8 +1219,8 @@
       _outParam = JSON.parse(JSON.stringify(res))
 
       if (window.GLOB.mkHS) {
-        if (btn.sysInterface === 'true' && options.cloudServiceApi) {
-          res.rduri = options.cloudServiceApi
+        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') {
@@ -1262,7 +1262,7 @@
 
       return Api.genericInterface(res)
     }).then(response => {
-      if (!response) return
+      if (!response || response.ErrCode === 'LoginError') return
 
       if (ver_token && response.ErrMesg === 'token_error') {
         this.execError(response)
@@ -1291,7 +1291,7 @@
         _resolve({next: false, list: []})
       }
     }).then(response => {
-      if (!response) return
+      if (!response || response.ErrCode === 'LoginError') return
 
       if (response.status) {
         _list.push(response)
@@ -1616,7 +1616,7 @@
     Api.postekPrint(param).then(res => {
       if (res.retval === '0') {
         if (params.length === 0) {
-          this.execSuccess({ ErrCode: 'S', message: '', ErrMesg: '鎵撳嵃璇锋眰宸插彂鍑恒��', status: true })
+          this.execSuccess({ ErrCode: 'S', message: '鎵撳嵃璇锋眰宸插彂鍑恒��', status: true })
         } else {
           setTimeout(() => {
             this.loopRFIDPrint(params)
@@ -1735,14 +1735,12 @@
         this.execSuccess({
           ErrCode: '-1',
           message: '鏈幏鍙栧埌鎵撳嵃淇℃伅锛�',
-          ErrMesg: '',
           status: true
         })
       } else {
         this.execError({
           ErrCode: 'N',
           message: '鏈幏鍙栧埌鎵撳嵃淇℃伅锛�',
-          ErrMesg: '',
           status: false
         })
       }
@@ -1772,7 +1770,6 @@
       this.execError({
         ErrCode: 'N',
         message: msg.join(' ; ') + ' !',
-        ErrMesg: '',
         status: false
       })
       return
@@ -1785,8 +1782,7 @@
 
       this.execSuccess({
         ErrCode: 'S',
-        message: '',
-        ErrMesg: '鎵撳嵃璇锋眰宸插彂鍑恒��',
+        message: '鎵撳嵃璇锋眰宸插彂鍑恒��',
         status: true
       })
     }
@@ -1797,8 +1793,7 @@
 
       this.execSuccess({
         ErrCode: 'S',
-        message: '',
-        ErrMesg: '鎵撳嵃璇锋眰宸插彂鍑恒��',
+        message: '鎵撳嵃璇锋眰宸插彂鍑恒��',
         status: true
       })
     }
@@ -1813,7 +1808,6 @@
           this.execError({
             ErrCode: 'N',
             message: event.data,
-            ErrMesg: '',
             status: false
           })
 
@@ -1833,8 +1827,7 @@
 
       //   this.execSuccess({
       //     ErrCode: 'S',
-      //     message: '',
-      //     ErrMesg: '鎵撳嵃璇锋眰宸插彂鍑恒��',
+      //     message: '鎵撳嵃璇锋眰宸插彂鍑恒��',
       //     status: true
       //   })
       // } else if (data && data.message && !data.status) {
@@ -1842,7 +1835,6 @@
         this.execError({
           ErrCode: 'N',
           message: data.message,
-          ErrMesg: '',
           status: false
         })
       }
@@ -1852,7 +1844,6 @@
       this.execError({
         ErrCode: 'N',
         message: '鏃犳硶杩炴帴鍒�:' + btn.verify.linkUrl,
-        ErrMesg: '',
         status: false
       })
     }
@@ -1877,19 +1868,19 @@
    * 4銆佹ā鎬佹鎵ц鎴愬姛鍚庢槸鍚﹀叧闂�
    * 5銆侀�氱煡涓诲垪琛ㄥ埛鏂�
    */
-  execSuccess = (res) => {
+  execSuccess = (res = {}) => {
     const { btn } = this.props
     const { autoMatic, btnconfig } = this.state
 
     if ((res.ErrCode === 'S' || !res.ErrCode) || autoMatic) { // 鎵ц鎴愬姛
       notification.success({
         top: 92,
-        message: res.ErrMesg || this.state.dict['main.action.confirm.success'],
+        message: res.message || '鎵ц鎴愬姛锛�',
         duration: btn.verify && btn.verify.stime ? btn.verify.stime : 2
       })
     } else if (res.ErrCode === 'Y') { // 鎵ц鎴愬姛
       Modal.success({
-        title: res.ErrMesg || this.state.dict['main.action.confirm.success']
+        title: res.message || '鎵ц鎴愬姛锛�'
       })
     } else if (res.ErrCode === '-1') { // 瀹屾垚鍚庝笉鎻愮ず
 
@@ -1914,6 +1905,10 @@
     if (btn.execSuccess !== 'never') {
       MKEmitter.emit('refreshByButtonResult', btn.$menuId, btn.execSuccess, btn, '', this.state.selines)
     }
+
+    if (btn.execSuccess === 'popclose' && btn.$tabId) { // 鏍囩鍏抽棴鍒锋柊
+      MKEmitter.emit('refreshPopButton', btn.$tabId)
+    }
   }
 
   /**
@@ -1926,25 +1921,29 @@
     const { btn } = this.props
     const { btnconfig, autoMatic } = this.state
 
+    if (!['LoginError', 'C', '-2', 'E', 'N', 'F', 'NM'].includes(res.ErrCode)) {
+      res.ErrCode = 'E'
+    }
+
     if (res.ErrCode === 'E' && !autoMatic) {
       Modal.error({
-        title: res.message || res.ErrMesg,
+        title: res.message || '鎵ц澶辫触锛�',
       })
     } else if (res.ErrCode === 'N' || autoMatic) {
       notification.error({
         top: 92,
-        message: res.message || res.ErrMesg,
+        message: res.message || '鎵ц澶辫触锛�',
         duration: btn.verify && btn.verify.ntime ? btn.verify.ntime : 10
       })
     } else if (res.ErrCode === 'F') {
       notification.error({
         className: 'notification-custom-error',
         top: 92,
-        message: res.message || res.ErrMesg,
+        message: res.message || '鎵ц澶辫触锛�',
         duration: btn.verify && btn.verify.ftime ? btn.verify.ftime : 10
       })
     } else if (res.ErrCode === 'NM') {
-      message.error(res.message || res.ErrMesg)
+      message.error(res.message || '鎵ц澶辫触锛�')
     }
     
     this.setState({
@@ -1964,17 +1963,6 @@
     if (btn.execError !== 'never') {
       MKEmitter.emit('refreshByButtonResult', btn.$menuId, btn.execError, btn, '', this.state.selines)
     }
-  }
-
-  /**
-   * @description 鎸夐挳閰嶇疆淇℃伅閿欒鎻愮ず
-   */
-  actionSettingError = () => {
-    notification.warning({
-      top: 92,
-      message: '鎸夐挳璁剧疆閿欒锛�',
-      duration: 5
-    })
   }
 
   handleModelConfig = (config) => {
@@ -2171,7 +2159,7 @@
         _item.fieldlen = item.decimal || 0
       } else if (['text', 'textarea', 'linkMain'].includes(_item.type)) {
         _item.value = _item.value + ''
-        _item.value = _item.value.replace(/\t*|\v*/g, '')       // 鍘婚櫎鍒惰〃绗�
+        _item.value = _item.value.replace(/\t+|\v+/g, '')       // 鍘婚櫎鍒惰〃绗�
 
         if (item.interception !== 'false') {                    // 鍘婚櫎棣栧熬绌烘牸
           _item.value = _item.value.replace(/(^\s*|\s*$)/g, '')
@@ -2218,7 +2206,7 @@
       this.execSubmit(selines, () => {}, result)
     } else {
       confirm({
-        title: this.state.dict['main.action.confirm.tip'],
+        title: '纭畾瑕佹墽琛屽悧?',
         onOk() {
           _this.triggerPrint(selines, result)
         },
@@ -2268,7 +2256,6 @@
       >
         <MutilForm
           BID={BID}
-          dict={this.state.dict}
           action={btnconfig}
           inputSubmit={this.handleOk}
           data={this.state.selines[0]}
@@ -2349,6 +2336,7 @@
     return <>
       <Button
         type={type}
+        id={'button' + btn.uuid}
         title={disabled ? (btn.reason || '') : (btn.show === 'icon' ? btn.label : '')}
         loading={loading}
         disabled={disabled}

--
Gitblit v1.8.0