From 2bccb9ec7bdefe23292a22bc153463cfa1479a49 Mon Sep 17 00:00:00 2001
From: king <18310653075@163.com>
Date: 星期五, 21 六月 2024 16:25:42 +0800
Subject: [PATCH] 2024-06-21

---
 src/tabviews/zshare/actionList/printbutton/index.jsx |  416 ++++++++++++++++++++++++++++++++---------------------------
 1 files changed, 224 insertions(+), 192 deletions(-)

diff --git a/src/tabviews/zshare/actionList/printbutton/index.jsx b/src/tabviews/zshare/actionList/printbutton/index.jsx
index f89c377..6d2e96c 100644
--- a/src/tabviews/zshare/actionList/printbutton/index.jsx
+++ b/src/tabviews/zshare/actionList/printbutton/index.jsx
@@ -6,7 +6,6 @@
 
 import Api from '@/api'
 import Utils from '@/utils/utils.js'
-import options from '@/store/options.js'
 import asyncSpinComponent from '@/utils/asyncSpinComponent'
 import { updateForm } from '@/utils/utils-update.js'
 import MKEmitter from '@/utils/events.js'
@@ -38,7 +37,8 @@
     loading: false,
     disabled: false,
     hidden: false,
-    autoMatic: false
+    autoMatic: false,
+    dict: window.GLOB.dict
   }
 
   UNSAFE_componentWillMount () {
@@ -131,21 +131,20 @@
   /**
    * @description 瑙﹀彂鎸夐挳鎿嶄綔
    */
-  actionTrigger = (triggerId, record, type) => {
-    const { BID, btn, selectedData, setting } = this.props
-    const { loading, disabled } = this.state
+  actionTrigger = (triggerId, record, type, lid) => {
+    const { BID, btn, selectedData, setting, LID } = this.props
+    const { loading, disabled, dict } = this.state
 
     if (loading || disabled) return
     if (triggerId && btn.uuid !== triggerId) return
+    if (type === 'linkbtn' && !btn.$toolbtn && LID !== lid) return
 
     if (setting.supModule && !BID) {
       notification.warning({
         top: 92,
-        message: '闇�瑕佷笂绾т富閿�硷紒',
+        message: dict['sup_key_req'] || '闇�瑕佷笂绾т富閿�硷紒',
         duration: 5
       })
-      return
-    } else if (type === 'linkbtn' && !btn.$toolbtn && !is(fromJS(selectedData || []), fromJS(record))) {
       return
     }
 
@@ -158,7 +157,7 @@
       // 闇�瑕侀�夋嫨琛屾椂锛屾牎楠屾暟鎹�
       notification.warning({
         top: 92,
-        message: '璇烽�夋嫨琛岋紒',
+        message: dict['select_row'] || '璇烽�夋嫨琛岋紒',
         duration: 5
       })
       return
@@ -166,25 +165,7 @@
       // 闇�瑕侀�夋嫨鍗曡鏃讹紝鏍¢獙鏁版嵁
       notification.warning({
         top: 92,
-        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({
-        top: 92,
-        message: '璇峰畬鍠勬墦鍗伴獙璇佷俊鎭紒',
-        duration: 5
-      })
-      return
-    } else if (btn.intertype === 'system' && btn.verify.dataType === 'custom' && (!btn.verify.setting || btn.verify.columns.length === 0)) {
-      notification.warning({
-        top: 92,
-        message: '鑷畾涔夋墦鍗版暟鎹璁剧疆鏁版嵁婧愶紒',
+        message: dict['select_single_row'] || '璇烽�夋嫨鍗曡鏁版嵁锛�',
         duration: 5
       })
       return
@@ -209,7 +190,9 @@
     } else if (btn.execMode === 'prompt') {
       this.setState({ loading: true })
       confirm({
-        title: '纭畾瑕佹墽琛屽悧?',
+        title: dict['exec_sure'] || '纭畾瑕佹墽琛屽悧?',
+        okText: dict['ok'] || '纭畾',
+        cancelText: dict['cancel'] || '鍙栨秷',
         onOk() {
           _this.triggerPrint(data)
         },
@@ -275,6 +258,9 @@
 
             Object.keys(cell).forEach(key => {
               let _key = key.toLowerCase()
+
+              if (/^\$/.test(_key)) return
+              
               _cell[_key] = cell[key]
             })
 
@@ -410,7 +396,6 @@
             errorMsg = {
               ErrCode: 'N',
               message: _temp.error,
-              ErrMesg: _temp.error,
               status: false
             }
           } else {
@@ -511,7 +496,7 @@
       if (list.length === 0) {
         notification.warning({
           top: 92,
-          message: '鏈幏鍙栧埌鎵撳嵃鏁版嵁锛�',
+          message: window.GLOB.dict['no_data'] || '鏈幏鍙栧埌鎵撳嵃鏁版嵁锛�',
           duration: 5
         })
         return false
@@ -538,7 +523,7 @@
       if (!result.ConfigParam) {
         notification.warning({
           top: 92,
-          message: '鏈幏鍙栧埌鎵撳嵃妯℃澘淇℃伅锛�',
+          message: window.GLOB.dict['no_print_temp'] || '鏈幏鍙栧埌鎵撳嵃妯℃澘淇℃伅锛�',
           duration: 5
         })
         this.setState({ loading: false })
@@ -570,16 +555,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'
@@ -775,18 +772,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: window.GLOB.dict['func_error'] || '鑷畾涔夊嚱鏁版墽琛岄敊璇紒',
+        duration: 5
+      })
     }
   }
 
@@ -908,6 +898,14 @@
         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') || ''
+            }
+            if (btn.dataM === 'true') {
+              _param.dataM = sessionStorage.getItem('dataM') === 'true' ? 'Y' : ''
+            }
   
             return _param
           })
@@ -955,7 +953,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
     }
@@ -981,10 +979,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}
         `
       }
@@ -994,16 +997,33 @@
       _dataresource = ''
     }
 
+    let isDataM = sessionStorage.getItem('dataM') === 'true'
+    let custompage = /@pageSize@|@orderBy@|@mk_total/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') || ''}'`},
+      { reg: /@SessionUid@/ig, value: `'${localStorage.getItem('SessionUid') || ''}'`},
+      { reg: /@UserID@/ig, value: `'${sessionStorage.getItem('UserID') || ''}'`},
+      { reg: /@Appkey@/ig, value: `'${window.GLOB.appkey || ''}'`},
+      { reg: /@lang@/ig, value: `'${sessionStorage.getItem('lang')}'`},
+      { 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(/@\$/ig, '*/').replace(/@datam@/ig, '\'Y\'')
-      _customScript = _customScript.replace(/\$@/ig, '/*').replace(/@\$/ig, '*/').replace(/@datam@/ig, '\'Y\'')
-    } 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)
@@ -1033,7 +1053,7 @@
         _initvars.push(`@${_key}='${form.value}'`)
       }
 
-      if (form.fieldlen && form.fieldlen > 2048) {
+      if (form.fieldlen && form.fieldlen > 4000) {
         form.fieldlen = 'max'
       }
 
@@ -1091,7 +1111,6 @@
         select ${_initvars.join(',')}
       `
     }
-
     
     if (_customScript) {
       _customScript = `${initsql}
@@ -1099,49 +1118,40 @@
       `
     }
 
-    _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 = ''
 
     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) {
       if (LText) {
         LText = `${LText}
+          ${_tailScript}
           aaa:
           if @ErrorCode!=''
             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,'${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}
@@ -1149,7 +1159,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'))
     }
@@ -1158,8 +1168,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)
@@ -1215,41 +1225,27 @@
       // 澶栭儴璇锋眰
       _outParam = JSON.parse(JSON.stringify(res))
 
-      if (window.GLOB.mkHS) {
-        if (btn.sysInterface === 'true' && options.cloudServiceApi) {
-          res.rduri = options.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
         }
       }
 
@@ -1261,7 +1257,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) {
@@ -1337,7 +1334,7 @@
     let imgs = []
 
     if (!res.ConfigParam) {
-      error = '鏈幏鍙栧埌鎵撳嵃妯℃澘淇℃伅锛�'
+      error = window.GLOB.dict['no_print_temp'] || '鏈幏鍙栧埌鎵撳嵃妯℃澘淇℃伅锛�'
     } else {
       try {
         configParam = JSON.parse(window.decodeURIComponent(window.atob(res.ConfigParam)))
@@ -1494,7 +1491,7 @@
     if (list.length === 0) {
       notification.warning({
         top: 92,
-        message: '鏈幏鍙栧埌鎵撳嵃鏁版嵁锛�',
+        message: window.GLOB.dict['no_data'] || '鏈幏鍙栧埌鎵撳嵃鏁版嵁锛�',
         duration: 5
       })
       this.setState({ loading: false })
@@ -1613,7 +1610,7 @@
     Api.postekPrint(param).then(res => {
       if (res.retval === '0') {
         if (params.length === 0) {
-          this.execSuccess({ ErrCode: 'S', message: '鎵撳嵃璇锋眰宸插彂鍑恒��', status: true })
+          this.execSuccess({ ErrCode: 'S', message: window.GLOB.dict['print_out'] || '鎵撳嵃璇锋眰宸插彂鍑恒��', status: true })
         } else {
           setTimeout(() => {
             this.loopRFIDPrint(params)
@@ -1631,6 +1628,8 @@
 
   execPrint = (list, template) => {
     const { btn } = this.props
+    const { dict } = this.state
+
     let _errors = []
 
     let defaultPrinter = btn.verify.defaultPrinter || 'lackprinter'
@@ -1731,13 +1730,13 @@
       if (btn.verify.emptyTip === 'false') {
         this.execSuccess({
           ErrCode: '-1',
-          message: '鏈幏鍙栧埌鎵撳嵃淇℃伅锛�',
+          message: dict['no_data'] || '鏈幏鍙栧埌鎵撳嵃淇℃伅锛�',
           status: true
         })
       } else {
         this.execError({
           ErrCode: 'N',
-          message: '鏈幏鍙栧埌鎵撳嵃淇℃伅锛�',
+          message: dict['no_data'] || '鏈幏鍙栧埌鎵撳嵃淇℃伅锛�',
           status: false
         })
       }
@@ -1751,7 +1750,7 @@
           lackerror.push(`鏁版嵁涓湭鑾峰彇鍒版ā鏉匡紙${err.title}锛�${err.lacks.join('銆�')} 瀛楁`)
         }
         if (err.emptys.length > 0) {
-          emptyerror.push(`鏁版嵁涓ā鏉匡紙${err.title}锛� ${err.emptys.join('銆�')} 瀛楁涓嶅彲涓虹┖`)
+          emptyerror.push(dict['not_empty'] ? `${err.title}: ${err.emptys.join('銆�')} ${dict['not_empty']}` : `鏁版嵁涓ā鏉匡紙${err.title}锛� ${err.emptys.join('銆�')} 瀛楁涓嶅彲涓虹┖`)
         }
       })
 
@@ -1772,26 +1771,35 @@
       return
     }
 
+    if (printerList.length === 0) {
+      this.execSuccess({
+        ErrCode: '-1',
+        message: dict['no_data'] || '鏈幏鍙栧埌鎵撳嵃淇℃伅锛�',
+        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: dict['print_out'] || '鎵撳嵃璇锋眰宸插彂鍑恒��',
+          status: true
+        })
       })
     }
 
     // 鎵撳紑Socket
     socket.onopen = () =>{
-      this.syncMessageSend(printerList)
-
-      this.execSuccess({
-        ErrCode: 'S',
-        message: '鎵撳嵃璇锋眰宸插彂鍑恒��',
-        status: true
+      this.syncMessageSend(printerList, () => {
+        this.execSuccess({
+          ErrCode: 'S',
+          message: dict['print_out'] || '鎵撳嵃璇锋眰宸插彂鍑恒��',
+          status: true
+        })
       })
     }
     // 鐩戝惉娑堟伅
@@ -1840,23 +1848,32 @@
     socket.onerror = () => {
       this.execError({
         ErrCode: 'N',
-        message: '鏃犳硶杩炴帴鍒�:' + btn.verify.linkUrl,
+        message: (dict['un_connect'] || '鏃犳硶杩炴帴鍒�') + ':' + btn.verify.linkUrl,
         status: false
       })
     }
   }
 
-  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瀵煎嚭锛屾垚鍔熷悗鍙栨秷瀵煎嚭鎸夐挳鍔犺浇涓姸鎬�
@@ -1867,17 +1884,18 @@
    */
   execSuccess = (res = {}) => {
     const { btn } = this.props
-    const { autoMatic, btnconfig } = this.state
+    const { autoMatic, btnconfig, dict } = this.state
 
     if ((res.ErrCode === 'S' || !res.ErrCode) || autoMatic) { // 鎵ц鎴愬姛
       notification.success({
         top: 92,
-        message: res.message || '鎵ц鎴愬姛锛�',
+        message: res.message || dict['exc_success'] || '鎵ц鎴愬姛锛�',
         duration: btn.verify && btn.verify.stime ? btn.verify.stime : 2
       })
     } else if (res.ErrCode === 'Y') { // 鎵ц鎴愬姛
       Modal.success({
-        title: res.message || '鎵ц鎴愬姛锛�'
+        title: res.message || dict['exc_success'] || '鎵ц鎴愬姛锛�',
+        okText: dict['got_it'] || '鐭ラ亾浜�'
       })
     } else if (res.ErrCode === '-1') { // 瀹屾垚鍚庝笉鎻愮ず
 
@@ -1916,7 +1934,7 @@
    */
   execError = (res) => {
     const { btn } = this.props
-    const { btnconfig, autoMatic } = this.state
+    const { btnconfig, autoMatic, dict } = this.state
 
     if (!['LoginError', 'C', '-2', 'E', 'N', 'F', 'NM'].includes(res.ErrCode)) {
       res.ErrCode = 'E'
@@ -1924,23 +1942,24 @@
 
     if (res.ErrCode === 'E' && !autoMatic) {
       Modal.error({
-        title: res.message || '鎵ц澶辫触锛�',
+        title: res.message || dict['exc_fail'] || '鎵ц澶辫触锛�',
+        okText: dict['got_it'] || '鐭ラ亾浜�'
       })
     } else if (res.ErrCode === 'N' || autoMatic) {
       notification.error({
         top: 92,
-        message: res.message || '鎵ц澶辫触锛�',
+        message: res.message || dict['exc_fail'] || '鎵ц澶辫触锛�',
         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 || '鎵ц澶辫触锛�',
+        message: res.message || dict['exc_fail'] || '鎵ц澶辫触锛�',
         duration: btn.verify && btn.verify.ftime ? btn.verify.ftime : 10
       })
     } else if (res.ErrCode === 'NM') {
-      message.error(res.message || '鎵ц澶辫触锛�')
+      message.error(res.message || dict['exc_fail'] || '鎵ц澶辫触锛�')
     }
     
     this.setState({
@@ -1953,6 +1972,8 @@
       return
     }
 
+    if (res.ErrCode === '-2') return
+
     if (btnconfig && btnconfig.setting && btnconfig.setting.errFocus) {
       MKEmitter.emit('mkFC', 'focus', btnconfig.setting.errFocus)
     }
@@ -1960,17 +1981,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) => {
@@ -2097,7 +2107,7 @@
   }
 
   modelconfirm = () => {
-    const { btnconfig, selines } = this.state
+    const { btnconfig, selines, dict } = this.state
     let _this = this
     let result = []
     let _data = {}
@@ -2170,7 +2180,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 || ''))
@@ -2214,7 +2250,9 @@
       this.execSubmit(selines, () => {}, result)
     } else {
       confirm({
-        title: '纭畾瑕佹墽琛屽悧?',
+        title: dict['exec_sure'] || '纭畾瑕佹墽琛屽悧?',
+        okText: dict['ok'] || '纭畾',
+        cancelText: dict['cancel'] || '鍙栨秷',
         onOk() {
           _this.triggerPrint(selines, result)
         },
@@ -2230,7 +2268,7 @@
    */
   getModels = () => {
     const { BID, btn } = this.props
-    const { btnconfig } = this.state
+    const { btnconfig, dict } = this.state
 
     if (!this.state.visible || !btnconfig || !btnconfig.setting) return null
 
@@ -2248,6 +2286,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}
@@ -2257,6 +2302,8 @@
         visible={this.state.visible}
         confirmLoading={this.state.confirmLoading}
         width={width}
+        okText={dict['ok'] || '纭畾'}
+        cancelText={dict['cancel'] || '鍙栨秷'}
         maskStyle={btnconfig.setting.moveable === 'true' ?  {backgroundColor: 'rgba(0, 0, 0, 0.15)'} : null}
         onOk={this.handleOk}
         onCancel={this.handleCancel}
@@ -2318,39 +2365,24 @@
     if (hidden) return null
 
     let label = ''
-    let icon = ''
-    let type = 'link'
-    let className = ''
 
-    if (btn.show === 'button') {
-      label = btn.label
-      icon = btn.icon || ''
-    } else if (btn.show === 'link') {
-      label = <span>{btn.label}{btn.icon ? <MkIcon style={{marginLeft: '8px'}} type={btn.icon}/> : ''}</span>
-      icon = ''
+    if (btn.show === 'link') {
+      label = <span>{btn.label}{btn.icon ? <MkIcon style={{marginLeft: '8px'}} type={btn.icon} /> : ''}</span>
     } else if (btn.show === 'icon') {
-      icon = btn.icon || ''
-    } else if (!btn.$toolbtn) {
-      icon = btn.icon || ''
-      label = btn.label
-      className = 'mk-btn mk-' + btn.class
+      label = !loading ? <MkIcon type={btn.icon} /> : null
     } else {
-      type = ''
-      icon = btn.icon || ''
-      label = btn.label
-      className = 'mk-btn mk-' + btn.class
+      label = <span>{!loading && btn.icon ? <MkIcon style={{marginRight: '8px'}} type={btn.icon} /> : ''}{btn.label}</span>
     }
 
     return <>
       <Button
-        type={type}
+        type="link"
         id={'button' + btn.uuid}
         title={disabled ? (btn.reason || '') : (btn.show === 'icon' ? btn.label : '')}
         loading={loading}
         disabled={disabled}
         style={btn.style || null}
-        icon={icon}
-        className={className}
+        className={btn.hover || ''}
         onClick={(e) => {e.stopPropagation(); this.actionTrigger()}}
       >{label}</Button>
       <span onClick={(e) => {e.stopPropagation()}}>{this.getModels()}</span>

--
Gitblit v1.8.0