From 84aa4415e0702faf99a20efbedadd6ab36d7a962 Mon Sep 17 00:00:00 2001
From: king <18310653075@163.com>
Date: 星期二, 02 一月 2024 17:00:12 +0800
Subject: [PATCH] 2023-01-02

---
 src/menu/components/card/cardcellcomponent/dragaction/card.jsx |   10 +
 /dev/null                                                      |   27 ----
 src/tabviews/custom/components/card/cardcellList/index.jsx     |   10 +
 src/menu/components/share/actioncomponent/actionform/index.jsx |    6 
 src/tabviews/zshare/actionList/funczip/index.jsx               |   22 --
 src/tabviews/zshare/actionList/funczip/index.scss              |   26 ----
 src/tabviews/zshare/actionList/index.jsx                       |   10 +
 public/manifest.json                                           |    2 
 src/menu/components/share/actioncomponent/formconfig.jsx       |   35 +++++
 src/tabviews/zshare/actionList/exportPdf/index.scss            |    0 
 src/tabviews/zshare/actionList/exportPdf/index.jsx             |  183 ++++++++++++++++++++++++++++++
 11 files changed, 251 insertions(+), 80 deletions(-)

diff --git a/public/manifest.json b/public/manifest.json
index 63c5ebb..75ffd6a 100644
--- a/public/manifest.json
+++ b/public/manifest.json
@@ -6,5 +6,5 @@
   "display": "standalone",
   "theme_color": "#000000",
   "background_color": "#ffffff",
-  "mk_version": "20231201"
+  "mk_version": "20240102"
 }
diff --git a/src/menu/components/card/cardcellcomponent/dragaction/card.jsx b/src/menu/components/card/cardcellcomponent/dragaction/card.jsx
index 4cbb8a3..7e4b3aa 100644
--- a/src/menu/components/card/cardcellcomponent/dragaction/card.jsx
+++ b/src/menu/components/card/cardcellcomponent/dragaction/card.jsx
@@ -65,8 +65,14 @@
   }
   if (card.eleType === 'picture' && card.maxWidth) {
     _style.maxWidth = card.maxWidth
-    let left = _style.marginLeft && _style.marginLeft !== '0px' ? _style.marginLeft : 'auto'
-    let right = _style.marginRight && _style.marginRight !== '0px' ? _style.marginRight : 'auto'
+    let left = _style.marginLeft || 'auto'
+    let right = _style.marginRight || 'auto'
+
+    if (_style.marginLeft === '0px' && _style.marginRight === '0px') {
+      left = 'auto'
+      right = 'auto'
+    }
+
     _style.margin = (_style.marginTop || 0) + ' ' + right + ' ' + (_style.marginBottom || 0) + ' ' + left
     delete _style.marginLeft
     delete _style.marginRight
diff --git a/src/menu/components/share/actioncomponent/actionform/index.jsx b/src/menu/components/share/actioncomponent/actionform/index.jsx
index 63d4fe6..0c97afe 100644
--- a/src/menu/components/share/actioncomponent/actionform/index.jsx
+++ b/src/menu/components/share/actioncomponent/actionform/index.jsx
@@ -505,6 +505,8 @@
       } else if (_funcType === 'refund') {
         shows.push('Ot', 'execSuccess', 'execError', 'syncComponent', 'openmenu')
         reOptions.Ot = requireOptions.filter(op => ['requiredSgl'].includes(op.value))
+      // } else if (_funcType === 'expPdf') {
+      //   shows.push('exportType')
       }
     }
     
@@ -523,7 +525,7 @@
           shows.push('reason')
         }
       }
-    } else {
+    } else if (!(openType === 'funcbutton' && this.record.funcType === 'expPdf')) {
       if (openType !== 'excelOut') {
         reOptions.control = [
           { value: '', text: '鏃�' },
@@ -1083,6 +1085,8 @@
                 }
               })
             }
+          } else if (values.OpenType === 'funcbutton' && values.funcType === 'expPdf') {
+            values.Ot = 'notRequired'
           }
           
           if (values.outerBlacklist) {
diff --git a/src/menu/components/share/actioncomponent/formconfig.jsx b/src/menu/components/share/actioncomponent/formconfig.jsx
index 00b31aa..be2b2cd 100644
--- a/src/menu/components/share/actioncomponent/formconfig.jsx
+++ b/src/menu/components/share/actioncomponent/formconfig.jsx
@@ -161,7 +161,7 @@
     { value: 'print', text: '鏍囩鎵撳嵃' },
     { value: 'refund', text: '閫�娆�' },
     { value: 'closetab', text: '鏍囩鍏抽棴' },
-    // { value: 'expPdf', text: '瀵煎嚭PDF' },
+    { value: 'expPdf', text: '瀵煎嚭PDF' },
     { value: 'megvii', text: '鏃疯闈㈡澘鏈�' },
     { value: 'filezip', text: '鏂囦欢鍘嬬缉鍖�' },
   ]
@@ -204,6 +204,7 @@
       { value: 'reAuth', text: '鍒囨崲绯荤粺锛堟竻绌虹紦瀛�-灏忕▼搴忥級' },
       { value: 'clearCache', text: '娓呯┖鏈湴閰嶇疆' },
       { value: 'copyurl', text: '澶嶅埗閾炬帴鍦板潃' },
+      { value: 'expPdf', text: '瀵煎嚭PDF' },
       { value: 'logout', text: '閫�鍑�' },
       { value: 'goBack', text: '杩斿洖' },
     ]
@@ -776,6 +777,21 @@
       forbid: type !== 'card',
       required: true
     },
+    // {
+    //   type: 'radio',
+    //   key: 'exportType',
+    //   label: '瀵煎嚭鏂瑰紡',
+    //   initVal: card.exportType || 'download',
+    //   tooltip: '',
+    //   required: true,
+    //   options: [{
+    //     value: 'download',
+    //     text: '涓嬭浇鏈湴'
+    //   }, {
+    //     value: 'link',
+    //     text: '鐢熸垚閾炬帴'
+    //   }]
+    // },
     {
       type: 'radio',
       key: 'show',
@@ -1444,7 +1460,7 @@
     { value: 'print', text: '鏍囩鎵撳嵃' },
     { value: 'refund', text: '閫�娆�' },
     { value: 'closetab', text: '鏍囩鍏抽棴' },
-    // { value: 'expPdf', text: '瀵煎嚭PDF' },
+    { value: 'expPdf', text: '瀵煎嚭PDF' },
     { value: 'megvii', text: '鏃疯闈㈡澘鏈�' },
     { value: 'filezip', text: '鏂囦欢鍘嬬缉鍖�' },
   ]
@@ -1900,6 +1916,21 @@
         text: '涓嶉噸缃�'
       }]
     },
+    // {
+    //   type: 'radio',
+    //   key: 'exportType',
+    //   label: '瀵煎嚭鏂瑰紡',
+    //   initVal: card.exportType || 'download',
+    //   tooltip: '',
+    //   required: true,
+    //   options: [{
+    //     value: 'download',
+    //     text: '涓嬭浇鏈湴'
+    //   }, {
+    //     value: 'link',
+    //     text: '鐢熸垚閾炬帴'
+    //   }]
+    // },
     {
       type: 'number',
       key: 'width',
diff --git a/src/tabviews/custom/components/card/cardcellList/index.jsx b/src/tabviews/custom/components/card/cardcellList/index.jsx
index 142622f..a958493 100644
--- a/src/tabviews/custom/components/card/cardcellList/index.jsx
+++ b/src/tabviews/custom/components/card/cardcellList/index.jsx
@@ -23,6 +23,7 @@
 const PrintButton = asyncComponent(() => import('@/tabviews/zshare/actionList/printbutton'))
 const FuncMegvii = asyncComponent(() => import('@/tabviews/zshare/actionList/funcMegvii'))
 const FuncZip = asyncComponent(() => import('@/tabviews/zshare/actionList/funczip'))
+const ExportPdf = asyncComponent(() => import('@/tabviews/zshare/actionList/exportPdf'))
 const EditLine = asyncComponent(() => import('@/tabviews/zshare/actionList/editLine'))
 const BarCode = asyncComponent(() => import('@/components/barcode'))
 const QrCode = asyncComponent(() => import('@/components/qrcode'))
@@ -656,10 +657,8 @@
         let url = ''
         if (card.maxWidth) {
           _style.maxWidth = card.maxWidth
-          if (_style.marginLeft === '0px') {
+          if (_style.marginLeft === '0px' && _style.marginRight === '0px') {
             delete _style.marginLeft
-          }
-          if (_style.marginRight === '0px') {
             delete _style.marginRight
           }
         }
@@ -1099,10 +1098,15 @@
             MkButton = <FuncZip
               btn={card}
               BID={data.$$BID}
+              BData={data.$$BData || ''}
               disabled={_disabled}
               setting={cards.setting}
               selectedData={_data}
             />
+          } else if (card.funcType === 'expPdf') {
+            MkButton = <ExportPdf
+              btn={card}
+            />
           } else if (card.funcType === 'addline' || card.funcType === 'delline') {
             MkButton = <EditLine
               btn={card}
diff --git a/src/tabviews/zshare/actionList/exportPdf/index.jsx b/src/tabviews/zshare/actionList/exportPdf/index.jsx
new file mode 100644
index 0000000..3887535
--- /dev/null
+++ b/src/tabviews/zshare/actionList/exportPdf/index.jsx
@@ -0,0 +1,183 @@
+import React, {Component} from 'react'
+import PropTypes from 'prop-types'
+import { is, fromJS } from 'immutable'
+import { Button } from 'antd'
+import html2Canvas from 'html2canvas'
+import moment from 'moment'
+import JsPDF from 'jspdf'
+
+import Api from '@/api'
+import MKEmitter from '@/utils/events.js'
+import MkIcon from '@/components/mk-icon'
+
+// import './index.scss'
+
+class ExportPDF extends Component {
+  static propTpyes = {
+    btn: PropTypes.object
+  }
+
+  state = {
+    loading: false,
+  }
+
+  componentDidMount () {
+    MKEmitter.addListener('triggerBtnId', this.actionTrigger)
+  }
+
+  shouldComponentUpdate (nextProps, nextState) {
+    return !is(fromJS(this.state), fromJS(nextState))
+  }
+
+  componentWillUnmount () {
+    this.setState = () => {
+      return
+    }
+    MKEmitter.removeListener('triggerBtnId', this.actionTrigger)
+  }
+
+  /**
+   * @description 瑙﹀彂鎸夐挳鎿嶄綔
+   */
+  actionTrigger = (triggerId) => {
+    const { btn } = this.props
+    const { loading } = this.state
+
+    if (loading) return
+    if (triggerId && btn.uuid !== triggerId) return
+
+    this.setState({
+      loading: true
+    }, () => {
+      this.getCanvas()
+    })
+  }
+
+  getCanvas = () => {
+    const { btn } = this.props
+
+    let wrap = document.getElementById('menu' + btn.$MenuID)
+
+    const opts = {
+      scale: 1.5,        // 缂╂斁姣斾緥锛屾彁楂樼敓鎴愬浘鐗囨竻鏅板害
+      useCORS: false,    // 鍏佽鍔犺浇璺ㄥ煙鐨勫浘鐗�
+      allowTaint: false, // 鍏佽鍥剧墖璺ㄥ煙锛屽拰 useCORS 浜岃�呬笉鍙叡鍚屼娇鐢�
+      tainttest: false,  // 妫�娴嬫瘡寮犲浘鐗囧凡缁忓姞杞藉畬鎴�
+      logging: false     // 鏃ュ織寮�鍏筹紝鍙戝竷鐨勬椂鍊欒寰楁敼鎴� false
+    }
+    
+    // eslint-disable-next-line
+    html2Canvas(wrap, opts).then(canvas => {
+      // const contentWidth = parseInt(canvas.style.width) * 2
+      // const contentHeight = parseInt(canvas.style.height) * 2
+      const contentWidth = canvas.width
+      const contentHeight = canvas.height
+      const pageHeight = (contentWidth / 592.28) * 841.89
+      let leftHeight = contentHeight
+
+      const imgWidth = 595.28
+      const imgHeight = (592.28 / contentWidth) * contentHeight
+      const pageData = canvas.toDataURL('image/jpeg', 1.0)
+      let position = 0
+
+      let title = btn.logLabel + moment().format('YYYYMMDDHHmmss')
+      const PDF = new JsPDF('', 'pt', 'a4')
+
+      if (leftHeight < pageHeight) {
+        PDF.addImage(pageData, 'JPEG', 10, 0, imgWidth - 20, imgHeight)
+      } else {
+        while (leftHeight > 0) {
+          PDF.addImage(pageData, 'JPEG', 10, position, imgWidth - 20, imgHeight)
+
+          leftHeight -= pageHeight
+          position -= 841.89
+
+          if (leftHeight > 0) {
+            PDF.addPage()
+          }
+        }
+      }
+      
+      PDF.save(title + '.pdf')
+
+      this.setState({
+        loading: false
+      })
+    })
+  }
+
+  getInnerData = (params) => {
+    let param = params.shift()
+
+    Api.genericInterface(param).then(res => {
+      if (res.status) {
+        this.downloadZipImage(res.data, this.props.btn.urlkey).then((res) => {
+          if (params.length === 0) {
+            if (res) {
+              this.execError({ErrCode: res})
+            } else {
+              this.execSuccess()
+            }
+          } else {
+            this.getInnerData(params)
+          }
+        }, (err) => {
+          if (params.length === 0) {
+            this.execError({ErrCode: err})
+          } else {
+            this.getInnerData(params)
+          }
+        })
+      } else {
+        this.execError(res)
+      }
+    })
+  }
+
+  render() {
+    const { btn } = this.props
+    const { loading } = this.state
+
+    let label = ''
+    let icon = ''
+    let type = 'link'
+    let className = ''
+    let style = {...btn.style}
+
+    if (loading) {
+      style.opacity = 0
+    }
+
+    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={btn.show === 'icon' ? btn.label : ''}
+        style={style}
+        icon={icon}
+        className={className}
+        onClick={(e) => {e.stopPropagation(); this.actionTrigger()}}
+      >{label}</Button>
+    )
+  }
+}
+
+export default ExportPDF
\ No newline at end of file
diff --git a/src/tabviews/zshare/actionList/exportPdf/index.scss b/src/tabviews/zshare/actionList/exportPdf/index.scss
new file mode 100644
index 0000000..e69de29
--- /dev/null
+++ b/src/tabviews/zshare/actionList/exportPdf/index.scss
diff --git a/src/tabviews/zshare/actionList/funczip/index.jsx b/src/tabviews/zshare/actionList/funczip/index.jsx
index cf511b5..e308d90 100644
--- a/src/tabviews/zshare/actionList/funczip/index.jsx
+++ b/src/tabviews/zshare/actionList/funczip/index.jsx
@@ -1,7 +1,7 @@
 import React, {Component} from 'react'
 import PropTypes from 'prop-types'
 import { is, fromJS } from 'immutable'
-import { Button, Modal, notification, message, Progress } from 'antd'
+import { Button, Modal, notification, message } from 'antd'
 import JSZip from 'jszip'
 import { saveAs } from 'file-saver'
 
@@ -10,7 +10,7 @@
 import MKEmitter from '@/utils/events.js'
 import MkIcon from '@/components/mk-icon'
 
-import './index.scss'
+// import './index.scss'
 
 class FuncZip extends Component {
   static propTpyes = {
@@ -21,10 +21,7 @@
   state = {
     loading: false,
     disabled: false,
-    loadingNumber: '',
-    loadingTotal: '',
     hidden: false,
-    visible: false
   }
 
   UNSAFE_componentWillMount () {
@@ -340,9 +337,7 @@
     const { btn } = this.props
 
     this.setState({
-      loading: false,
-      loadingNumber: '',
-      loadingTotal: ''
+      loading: false
     })
     
     if (btn.execSuccess !== 'never') {
@@ -361,9 +356,7 @@
     const { btn } = this.props
 
     this.setState({
-      loading: false,
-      loadingNumber: '',
-      loadingTotal: ''
+      loading: false
     })
 
     if (res.ErrCode === '01') {
@@ -411,7 +404,7 @@
 
   render() {
     const { btn } = this.props
-    const { loading, disabled, hidden, loadingNumber, loadingTotal } = this.state
+    const { loading, disabled, hidden } = this.state
 
     if (hidden) return null
 
@@ -439,10 +432,6 @@
       className = 'mk-btn mk-' + btn.class
     }
     
-    if (loadingNumber && !loadingTotal && btn.$toolbtn && (!btn.show || btn.show === 'button')) {
-      label = (loadingNumber && !loadingTotal ? `(${loadingNumber})` : '') + btn.label
-    }
-
     return (
       <>
         <Button
@@ -455,7 +444,6 @@
           className={className}
           onClick={(e) => {e.stopPropagation(); this.actionTrigger()}}
         >{label}</Button>
-        {loadingTotal ? <Progress className="mk-button-progress" percent={(loadingTotal - loadingNumber) / loadingTotal * 100} size="small" showInfo={false} /> : null}
       </>
     )
   }
diff --git a/src/tabviews/zshare/actionList/funczip/index.scss b/src/tabviews/zshare/actionList/funczip/index.scss
index 8eccbd6..e69de29 100644
--- a/src/tabviews/zshare/actionList/funczip/index.scss
+++ b/src/tabviews/zshare/actionList/funczip/index.scss
@@ -1,26 +0,0 @@
-.ip-list-modal {
-  .ip-item {
-    display: inline-block;
-    border: 1px solid #d9d9d9;
-    padding: 10px;
-    height: 100px;
-    width: calc(33% - 20px);
-    margin: 10px;
-    cursor: pointer;
-    .ip {
-      color: #000000;
-    }
-    .remark {
-      word-break: break-all;
-      text-overflow: ellipsis;
-      display: -webkit-box;
-      -webkit-box-orient: vertical;
-      -webkit-line-clamp: 2;
-      overflow: hidden;
-    }
-  }
-  .ip-item.active {
-    border-color: var(--mk-sys-color);
-    box-shadow: 0 0 2px var(--mk-sys-color);
-  }
-}
\ No newline at end of file
diff --git a/src/tabviews/zshare/actionList/funczip/mock.js b/src/tabviews/zshare/actionList/funczip/mock.js
deleted file mode 100644
index 669ad8e..0000000
--- a/src/tabviews/zshare/actionList/funczip/mock.js
+++ /dev/null
@@ -1,27 +0,0 @@
-export const mockdata = {
-  data: [
-    {
-      "recognition_type": "staff",
-      "id": "2226169",
-      "type": "persons",
-      "is_admin": "true",
-      "person_name": "king",
-      "card_number": "mk001",
-      "person_code": "2018",
-      "id_number": "130982193002054729",
-      "group_list": "1",
-      "face_data":""
-    },
-    {
-      "recognition_type": "staff",
-      "id": "3272487",
-      "is_admin": 'false',
-      "person_name": "jinfei",
-      "card_number": "mk002",
-      "person_code": "02",
-      "id_number": "",
-      "group_list": "1",
-      "face_data": ""
-    }
-  ]
-}
\ No newline at end of file
diff --git a/src/tabviews/zshare/actionList/index.jsx b/src/tabviews/zshare/actionList/index.jsx
index 4852e23..7d59c20 100644
--- a/src/tabviews/zshare/actionList/index.jsx
+++ b/src/tabviews/zshare/actionList/index.jsx
@@ -18,6 +18,7 @@
 const FuncMegvii = asyncComponent(() => import('./funcMegvii'))
 const FuncZip = asyncComponent(() => import('./funczip'))
 const EditLine = asyncComponent(() => import('./editLine'))
+const ExportPdf = asyncComponent(() => import('./exportPdf'))
 
 class ActionList extends Component {
   static propTpyes = {
@@ -180,14 +181,21 @@
           return (
             <FuncZip
               key={item.uuid}
-              show={item.show || 'actionList'}
               disabled={false}
               BID={BID}
               btn={item}
+              BData={BData}
               setting={setting}
               selectedData={selectedData}
             />
           )
+        } else if (item.funcType === 'expPdf') {
+          return (
+            <ExportPdf
+              key={item.uuid}
+              btn={item}
+            />
+          )
         } else if (item.funcType === 'addline' || item.funcType === 'delline') {
           return (
             <EditLine

--
Gitblit v1.8.0