From 8881f69f5d7127a4090184b3ea7c9cbf9574100e Mon Sep 17 00:00:00 2001
From: king <18310653075@163.com>
Date: 星期一, 18 三月 2024 18:01:51 +0800
Subject: [PATCH] 2024-03-18

---
 src/tabviews/zshare/actionList/newpagebutton/index.jsx |   84 +++++++++++++++++++++++++++++++++++------
 1 files changed, 71 insertions(+), 13 deletions(-)

diff --git a/src/tabviews/zshare/actionList/newpagebutton/index.jsx b/src/tabviews/zshare/actionList/newpagebutton/index.jsx
index 01d678e..7748e24 100644
--- a/src/tabviews/zshare/actionList/newpagebutton/index.jsx
+++ b/src/tabviews/zshare/actionList/newpagebutton/index.jsx
@@ -16,6 +16,7 @@
     btn: PropTypes.object,            // 鎸夐挳
     selectedData: PropTypes.any,      // 瀛愯〃涓�夋嫨鏁版嵁
     disabled: PropTypes.any,          // 琛屾寜閽鐢�
+    name: PropTypes.any
   }
 
   state = {
@@ -159,18 +160,75 @@
 
     if (btn.pageTemplate === 'billprint') {
       _name = '鍗曟嵁鎵撳嵃'
-      if (btn.Ot === 'required') {
-        data.forEach(item => {
-          let _id = item.$$uuid || ''
-          let url = '#/billprint/' + window.btoa(window.encodeURIComponent(JSON.stringify({ id: _id, tempId: btn.printTemp, pageId: btn.$MenuID || '', dataM: sessionStorage.getItem('dataM') })))
-          window.open(url)
-        })
-      } else if (btn.Ot === 'requiredOnce') {
-        Id = data.map(item => item.$$uuid).filter(Boolean).join(',')
+      if (btn.preHandle === 'true' && btn.pre_func) {
+        MKEmitter.emit('queryModuleParam', btn.$menuId, (res) => {
+          let searches = {}
+          res.search && res.search.forEach(item => {
+            searches[item.key] = item.value
+          })
 
-        window.open('#/billprint/' + window.btoa(window.encodeURIComponent(JSON.stringify({ id: Id, tempId: btn.printTemp, pageId: btn.$MenuID || '', dataM: sessionStorage.getItem('dataM') }))))
+          if (btn.Ot === 'requiredOnce') {
+            Id = data.map(item => item.$$uuid).filter(Boolean).join(',')
+          }
+
+          if (btn.Ot === 'required') {
+            data.forEach(item => {
+              let _param = { id: item.$$uuid || '', tempId: btn.printTemp, pageId: btn.$MenuID || '', dataM: sessionStorage.getItem('dataM')}
+              try {
+                // eslint-disable-next-line
+                let func = new Function('btn', 'searches', 'data', 'param', 'systemType', btn.pre_func)
+                _param = func(btn, searches, [item], _param, window.GLOB.systemType)
+              } catch (e) {
+                console.warn(e)
+              }
+
+              if (!_param) {
+                notification.warning({
+                  top: 92,
+                  message: '鏈幏鍙栧埌鎵撳嵃鍙傛暟锛岃嚜瀹氫箟鑴氭湰閿欒锛�',
+                  duration: 5
+                })
+                return
+              }
+              
+              window.open('#/billprint/' + window.btoa(window.encodeURIComponent(JSON.stringify(_param))))
+            })
+          } else {
+            let _param = { id: Id, tempId: btn.printTemp, pageId: btn.$MenuID || '', dataM: sessionStorage.getItem('dataM')}
+            try {
+              // eslint-disable-next-line
+              let func = new Function('btn', 'searches', 'data', 'param', 'systemType', btn.pre_func)
+              _param = func(btn, searches, data, _param, window.GLOB.systemType)
+            } catch (e) {
+              console.warn(e)
+            }
+
+            if (!_param) {
+              notification.warning({
+                top: 92,
+                message: '鏈幏鍙栧埌鎵撳嵃鍙傛暟锛岃嚜瀹氫箟鑴氭湰閿欒锛�',
+                duration: 5
+              })
+              return
+            }
+
+            window.open('#/billprint/' + window.btoa(window.encodeURIComponent(JSON.stringify(_param))))
+          }
+        })
       } else {
-        window.open('#/billprint/' + window.btoa(window.encodeURIComponent(JSON.stringify({ id: Id, tempId: btn.printTemp, pageId: btn.$MenuID || '', dataM: sessionStorage.getItem('dataM') }))))
+        if (btn.Ot === 'required') {
+          data.forEach(item => {
+            let _id = item.$$uuid || ''
+            let url = '#/billprint/' + window.btoa(window.encodeURIComponent(JSON.stringify({ id: _id, tempId: btn.printTemp, pageId: btn.$MenuID || '', dataM: sessionStorage.getItem('dataM') })))
+            window.open(url)
+          })
+        } else if (btn.Ot === 'requiredOnce') {
+          Id = data.map(item => item.$$uuid).filter(Boolean).join(',')
+  
+          window.open('#/billprint/' + window.btoa(window.encodeURIComponent(JSON.stringify({ id: Id, tempId: btn.printTemp, pageId: btn.$MenuID || '', dataM: sessionStorage.getItem('dataM') }))))
+        } else {
+          window.open('#/billprint/' + window.btoa(window.encodeURIComponent(JSON.stringify({ id: Id, tempId: btn.printTemp, pageId: btn.$MenuID || '', dataM: sessionStorage.getItem('dataM') }))))
+        }
       }
     } else if (btn.pageTemplate === 'billprintTemp') {
       let src = '#/menudesign/' + window.btoa(window.encodeURIComponent(JSON.stringify({ MenuType: 'billPrint', MenuId: Id, MenuNo: MenuNo, MenuName: name || '鎵撳嵃', Remark: Remark })))
@@ -250,7 +308,7 @@
   }
 
   render() {
-    const { btn } = this.props
+    const { btn, name } = this.props
     const { disabled, hidden } = this.state
 
     if (hidden) return null
@@ -261,10 +319,10 @@
     let className = ''
 
     if (btn.show === 'button') {
-      label = btn.label
+      label = name || btn.label
       icon = btn.icon || ''
     } else if (btn.show === 'link') {
-      label = <span>{btn.label}{btn.icon ? <MkIcon style={{marginLeft: '8px'}} type={btn.icon}/> : ''}</span>
+      label = <span>{name || btn.label}{btn.icon ? <MkIcon style={{marginLeft: '8px'}} type={btn.icon}/> : ''}</span>
       icon = ''
     } else if (btn.show === 'icon') {
       icon = btn.icon || ''

--
Gitblit v1.8.0