From 8d66ff34fae5b048a6b7923cc75d34f13a08be9d Mon Sep 17 00:00:00 2001
From: king <18310653075@163.com>
Date: 星期二, 02 八月 2022 11:42:43 +0800
Subject: [PATCH] Merge branch 'develop'

---
 src/tabviews/zshare/actionList/printbutton/index.jsx |  221 +++++++++++++++++++++++++++++++------------------------
 1 files changed, 125 insertions(+), 96 deletions(-)

diff --git a/src/tabviews/zshare/actionList/printbutton/index.jsx b/src/tabviews/zshare/actionList/printbutton/index.jsx
index 6c14dd2..ff0cd12 100644
--- a/src/tabviews/zshare/actionList/printbutton/index.jsx
+++ b/src/tabviews/zshare/actionList/printbutton/index.jsx
@@ -1,7 +1,6 @@
 import React, {Component} from 'react'
 import PropTypes from 'prop-types'
 import moment from 'moment'
-import {connect} from 'react-redux'
 import { is, fromJS } from 'immutable'
 import { Button, Modal, notification, message } from 'antd'
 
@@ -22,7 +21,6 @@
 
 class PrintButton extends Component {
   static propTpyes = {
-    show: PropTypes.any,              // 鎸夐挳鏄剧ず鏍峰紡鎺у埗
     BID: PropTypes.string,            // 涓昏〃ID
     BData: PropTypes.any,             // 涓昏〃鏁版嵁
     selectedData: PropTypes.any,      // 瀛愯〃涓�夋嫨鏁版嵁
@@ -32,7 +30,6 @@
     setting: PropTypes.any,           // 椤甸潰閫氱敤璁剧疆
     ContainerId: PropTypes.any,       // tab椤甸潰ID锛岀敤浜庡脊绐楁帶鍒�
     disabled: PropTypes.any,          // 琛屾寜閽鐢�
-    lineId: PropTypes.any,            // 琛岀储寮�+涓婚敭鍊硷紝鐢ㄤ簬琛屾寜閽弻鍑�
   }
 
   state = {
@@ -44,7 +41,6 @@
     loading: false,
     disabled: false,
     hidden: false,
-    loadingNumber: '',
     autoMatic: false
   }
 
@@ -150,12 +146,7 @@
     const { loading, disabled } = this.state
 
     if (loading || disabled) return
-    if (triggerId) {
-      if (btn.uuid !== triggerId) return
-      if (this.props.lineId && record && record[0] && this.props.lineId !== record[0].$$key) {
-        return
-      }
-    }
+    if (triggerId && btn.uuid !== triggerId) return
 
     if (((Tab && Tab.supMenu) || setting.supModule) && !BID) {
       notification.warning({
@@ -164,10 +155,8 @@
         duration: 5
       })
       return
-    } else if (type === 'linkbtn' && selectedData && selectedData.length === 1) {
-      if (record[0].$Index !== selectedData[0].$Index) {
-        return
-      }
+    } else if (type === 'linkbtn' && !btn.$toolbtn && !is(fromJS(selectedData || []), fromJS(record))) {
+      return
     }
 
     this.setState({autoMatic: type === 'autoMatic'})
@@ -250,38 +239,77 @@
   triggerPrint = (data, formlist = []) => {
     const { btn } = this.props
     let formdata = {}
+    let baseCount = 1
+    let baseType = ''
+    let baseTemp = btn.verify.Template || ''
     
     formlist.forEach(_data => {
       formdata[_data.key] = _data.value
+
+      if (!_data.value) return
+
+      if (_data.key.toLowerCase() === 'printcount') {
+        baseCount = +_data.value
+      } else if (_data.key.toLowerCase() === 'printtype') {
+        baseType = _data.value
+      } else if (_data.key.toLowerCase() === 'templateid') {
+        baseTemp = _data.value
+      }
     })
 
     let printlist = []
     let templates = []
-    let printCount = +(formdata.printCount || formdata.PrintCount || formdata.printcount || formdata.Printcount || 1)
 
-    if (isNaN(printCount) || printCount < 1) {
-      printCount = 1
+    if (isNaN(baseCount) || baseCount < 1) {
+      baseCount = 1
     }
 
     new Promise(resolve => {
       if (btn.intertype === 'system') { // 浣跨敤绯荤粺鏃讹紝鐩存帴浠庤〃鏍兼垨琛ㄥ崟涓�夊彇鏁版嵁
-        let printcell = {}
-
-        printcell.printType = formdata.printType || formdata.PrintType || formdata.printtype || formdata.Printtype || ''
-        printcell.printCount = printCount
-        printcell.templateID = btn.verify.Template || ''
-
         if (btn.Ot === 'notRequired') {
+          let printcell = {}
+  
+          printcell.printType = baseType
+          printcell.printCount = baseCount
+          printcell.templateID = baseTemp
           printcell.data = [formdata]
+
+          templates.push(printcell.templateID)
+
+          printlist.push(printcell)
         } else {
-          printcell.data = data.map(cell => {
-            return {...cell, ...formdata}
+          data.forEach(cell => {
+            let _cell = {...cell, ...formdata}
+            
+            let printcell = {data: [_cell]}
+  
+            printcell.templateID = baseTemp
+            printcell.printType = baseType
+            printcell.printCount = 0
+
+            Object.keys(_cell).forEach(key => {
+              if (!_cell[key]) return
+
+              let _key = key.toLowerCase()
+
+              if (_key === 'templateid') {
+                printcell.templateID = _cell[key]
+              } else if (_key === 'printtype') {
+                printcell.printType = _cell[key]
+              } else if (_key === 'printcount') {
+                printcell.printCount = +_cell[key]
+              }
+            })
+
+            if (isNaN(printcell.printCount) || printcell.printCount < 1) {
+              printcell.printCount = baseCount
+            }
+
+            templates.push(printcell.templateID)
+
+            printlist.push(printcell)
           })
         }
-
-        templates.push(printcell.templateID)
-
-        printlist.push(printcell)
 
         resolve(true)
       } else {
@@ -291,16 +319,31 @@
               // 绯荤粺鎵撳嵃鏁版嵁锛屾牎楠宒ata瀛楁
               if (btn.verify.printMode !== 'custom' && (!cell.data || cell.data.length === 0)) return
 
-              cell.templateID = cell.templateID || cell.TemplateID || cell.Templateid || cell.templateid || btn.verify.Template
-              cell.printType = cell.printType || cell.PrintType || cell.printtype || cell.Printtype || formdata.printType || formdata.PrintType || formdata.printtype || formdata.Printtype || ''
+              let templateID = baseTemp
+              let printType = baseType
+              let printCount = 0
 
-              let _printCount = +(cell.printCount || cell.PrintCount || cell.printcount || cell.Printcount || 0)
+              Object.keys(cell).forEach(key => {
+                if (!cell[key]) return
 
-              if (isNaN(_printCount) || _printCount < 1) {
-                _printCount = printCount
+                let _key = key.toLowerCase()
+
+                if (_key === 'templateid') {
+                  templateID = cell[key]
+                } else if (_key === 'printtype') {
+                  printType = cell[key]
+                } else if (_key === 'printcount') {
+                  printCount = +cell[key]
+                }
+              })
+
+              cell.templateID = templateID
+              cell.printType = printType
+              cell.printCount = printCount
+
+              if (isNaN(cell.printCount) || cell.printCount < 1) {
+                cell.printCount = baseCount
               }
-              
-              cell.printCount = _printCount
 
               templates.push(cell.templateID)
 
@@ -772,7 +815,7 @@
       // 澶栭儴璇锋眰
       _outParam = JSON.parse(JSON.stringify(res))
 
-      if (this.props.menuType === 'HS') {
+      if (window.GLOB.mkHS) {
         if (btn.sysInterface === 'true' && options.cloudServiceApi) {
           res.rduri = options.cloudServiceApi
         } else if (btn.sysInterface !== 'true') {
@@ -887,7 +930,8 @@
       if (!configParam) {
         error = '鎵撳嵃妯℃澘瑙f瀽閿欒锛�'
       } else {
-        let control = configParam.elements.map(element => {
+        let control = []
+        configParam.elements.forEach(element => {
           let _field = element.field
 
           if (_field === 'other_field') {
@@ -923,11 +967,12 @@
             item.Trimming = ''
             if (!item.Width) {
               item.Width = item.BorderSize
-              item.Left = item.Left - item.Width
+              item.Left = item.Left - item.Width + 0.1
             } else if (!item.Height) {
               item.Height = item.BorderSize
-              item.Top = item.Top - item.Height
+              item.Top = item.Top - item.Height + 0.1
             }
+            item.BackColor = element.borderColor
             item.BorderSize = 0
           } else if (item.Type === 'image') {
             item.ImageWidth = element.imgWidth
@@ -967,7 +1012,7 @@
             }
           }
 
-          return item
+          control.push(item)
         })
 
         _configparam = {
@@ -1563,7 +1608,7 @@
 
     if (!this.state.visible || !btnconfig || !btnconfig.setting) return null
 
-    let title = btnconfig.setting.title
+    let title = btn.label
     let width = btnconfig.setting.width > 100 ? btnconfig.setting.width : btnconfig.setting.width + 'vw'
     let clickouter = false
     let container = document.body
@@ -1595,7 +1640,6 @@
         <MutilForm
           BID={BID}
           dict={this.state.dict}
-          menuType={this.props.menuType}
           action={btnconfig}
           inputSubmit={this.handleOk}
           data={this.state.selines[0]}
@@ -1607,64 +1651,49 @@
   }
 
   render() {
-    const { btn, show } = this.props
-    const { loadingNumber, loading, disabled, hidden } = this.state
+    const { btn } = this.props
+    const { loading, disabled, hidden } = this.state
 
     if (hidden) return null
 
-    if (show === 'actionList') {
-      return <div style={{display: 'inline-block'}} onClick={(e) => e.stopPropagation()}>
-        <Button
-          icon={btn.icon}
-          loading={loading}
-          disabled={disabled}
-          title={disabled ? (btn.reason || '') : ''}
-          className={'mk-btn mk-' + btn.class}
-          onClick={() => {this.actionTrigger()}}
-        >{loadingNumber ? `(${loadingNumber})` : '' + btn.label}</Button>
-        {this.getModels()}
-      </div>
-    } else { // icon銆乼ext銆� all 鍗$墖
-      let label = ''
-      let icon = ''
+    let label = ''
+    let icon = ''
+    let type = 'link'
+    let className = ''
 
-      if (show === 'button') {
-        label = btn.label
-        icon = btn.icon || ''
-      } else if (show === 'link') {
-        label = <span>{btn.label}{btn.icon ? <MkIcon style={{marginLeft: '8px'}} type={btn.icon}/> : ''}</span>
-        icon = ''
-      } else if (show === 'icon') {
-        icon = btn.icon || ''
-      // } else if (show === 'text') {
-      } else {
-        label = btn.label
-      }
-
-      return <div style={{display: 'inline-block'}} onClick={(e) => e.stopPropagation()}>
-        <Button
-          type="link"
-          title={disabled ? (btn.reason || '') : (show === 'icon' ? btn.label : '')}
-          loading={loading}
-          disabled={disabled}
-          style={btn.style}
-          icon={icon}
-          onClick={() => {this.actionTrigger()}}
-        >{label}</Button>
-        {this.getModels()}
-      </div>
+    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 = ''
+    } else if (btn.show === 'icon') {
+      icon = btn.icon || ''
+    } else if (!btn.$toolbtn) {
+      icon = btn.icon || ''
+      label = btn.label
+      className = 'mk-btn mk-' + btn.class
+    } else {
+      type = ''
+      icon = btn.icon || ''
+      label = btn.label
+      className = 'mk-btn mk-' + btn.class
     }
+
+    return <>
+      <Button
+        type={type}
+        title={disabled ? (btn.reason || '') : (btn.show === 'icon' ? btn.label : '')}
+        loading={loading}
+        disabled={disabled}
+        style={btn.style || null}
+        icon={icon}
+        className={className}
+        onClick={(e) => {e.stopPropagation(); this.actionTrigger()}}
+      >{label}</Button>
+      <span onClick={(e) => {e.stopPropagation()}}>{this.getModels()}</span>
+    </>
   }
 }
 
-const mapStateToProps = (state) => {
-  return {
-    menuType: state.editLevel
-  }
-}
-
-const mapDispatchToProps = () => {
-  return {}
-}
-
-export default connect(mapStateToProps, mapDispatchToProps)(PrintButton)
\ No newline at end of file
+export default PrintButton
\ No newline at end of file

--
Gitblit v1.8.0