From 1bec8d69cf14bd88591eee5b0320c5c8f6c25a08 Mon Sep 17 00:00:00 2001
From: king <18310653075@163.com>
Date: 星期五, 08 三月 2024 21:19:31 +0800
Subject: [PATCH] Merge branch 'master' into positec

---
 src/views/printTemplate/index.jsx |   53 ++++++++++++++++++++++++++++++++++++++++++++++++++++-
 1 files changed, 52 insertions(+), 1 deletions(-)

diff --git a/src/views/printTemplate/index.jsx b/src/views/printTemplate/index.jsx
index 39c625f..dcb5d22 100644
--- a/src/views/printTemplate/index.jsx
+++ b/src/views/printTemplate/index.jsx
@@ -320,6 +320,9 @@
       if (keyCode === 46 && editItemId && editItemType !== 'Template') {
         this.deleteItem()
       }
+      if (e.ctrlKey && keyCode === 81 && editItemId && editItemType !== 'Template') {
+        this.copyItem()
+      }
     }
   }
 
@@ -706,6 +709,51 @@
     })
   }
 
+  copyItem = () => {
+    const { editItemId, config, fields } = this.state
+
+    let cell = config.elements.filter(item => item.uuid === editItemId)[0]
+
+    if (!cell) return
+
+    let item = {...cell}
+
+    item.left = item.left + parseInt(item.width / 4)
+    item.top = item.top + parseInt(item.height / 4)
+    item.uuid = Utils.getuuid()
+
+    if (item.left + item.width > config.width) {
+      item.left = config.width - item.width
+    }
+    if (item.top + item.height > config.height) {
+      item.top = config.height - item.height
+    }
+
+    let _config = fromJS(config).toJS()
+    
+    _config.elements.push(item)
+
+    let _formlist = []
+    if (item.type === 'text') {
+      _formlist = getTextForm(item, fields)
+    } else if (item.type === 'barcode') {
+      _formlist = getBarcodeForm(item, fields)
+    } else if (item.type === 'qrcode') {
+      _formlist = getQrcodeForm(item, fields)
+    } else if (item.type === 'image') {
+      _formlist = getImageForm(item, fields)
+    }
+
+    this.setState({
+      config: _config,
+      editItemId: item.uuid,
+      editItemType: item.type,
+      formlist: _formlist
+    }, () => {
+      this.resetview()
+    })
+  }
+
   deleteItem = () => {
     const _this = this
     const { editItemId, config } = this.state
@@ -896,7 +944,10 @@
     return (
       <div className="print-template">
         <DndProvider backend={HTML5Backend}>
-          <header className="print-header-container ant-menu-dark">妯℃澘鍒朵綔</header>
+          <header className="print-header-container ant-menu-dark">
+            妯℃澘鍒朵綔
+            <div>蹇嵎閿細Delete锛堝垹闄ゅ厓绱狅級銆乧trl + q锛堝鍒跺厓绱狅級</div>
+          </header>
           <aside className="tools">
             <Card className="tool-bar" title="宸ュ叿鏍�">
               {printItems.map((item, index) => {

--
Gitblit v1.8.0