From d64a5b5aa83fe566f43216ac718b970fbb9c96f7 Mon Sep 17 00:00:00 2001
From: huang <1532065656@qq.com>
Date: 星期一, 30 十二月 2024 16:46:13 +0800
Subject: [PATCH] Merge branch 'master' of http://10.153.19.25:10105/r/ERP_override

---
 north-glass-erp/northglass-erp/src/components/pp/PrintRepairCustomLabel.vue |  185 ++++++++++++++++++++++++++++++++--------------
 1 files changed, 129 insertions(+), 56 deletions(-)

diff --git a/north-glass-erp/northglass-erp/src/components/pp/PrintRepairCustomLabel.vue b/north-glass-erp/northglass-erp/src/components/pp/PrintRepairCustomLabel.vue
index 552079d..637b8bf 100644
--- a/north-glass-erp/northglass-erp/src/components/pp/PrintRepairCustomLabel.vue
+++ b/north-glass-erp/northglass-erp/src/components/pp/PrintRepairCustomLabel.vue
@@ -7,6 +7,9 @@
 import {changeFilterEvent, filterChanged} from "@/hook"
 import {useI18n} from 'vue-i18n'
 import deepClone from "@/utils/deepClone";
+import companyInfo from "@/stores/sd/companyInfo";
+
+const company = companyInfo()
 //璇█鑾峰彇
 const {t} = useI18n()
 let router = useRouter()
@@ -15,7 +18,7 @@
 let titleList = ref([])
 let dataList = ref([])
 let list = ref([])
-let lastList=ref([])
+let lastList = ref([])
 
 let filterData = ref({})
 
@@ -27,30 +30,63 @@
   list:null,//鍕鹃�夌殑鏁版嵁
   faceOrientation:null,//鍐呭闈�
   type:null,//鏍囩妯℃澘
-  lableType:null//鏍囩绫诲瀷
+  lableType:null,//鏍囩绫诲瀷
+  titleList:null,//鏍囬
+  switch:null,//鍒ゆ柇鏄惁涓烘柊鎵撳嵃,
+  lastList:[],
+  detailType:null
 })
 
 const {currentRoute} = useRouter()
 const route = currentRoute.value
 let type = props.type
-let faceOrientation = props.faceOrientation
-let lableType = props.lableType
-data.value.printList = JSON.parse(props.list)
 
+let lableType = props.lableType
+let switchType = props.switch
+let detailType= props.detailType
+data.value.printList = JSON.parse(props.list)
 onMounted(() => {
+
       request.post(`/Replenish/getSelectPrintCustomLabel/${type}/${lableType}`, data.value).then((res) => {
         if (res.code == 200) {
-
           produceList.value = deepClone(res.data.title)
           list.value = deepClone(res.data.data)
           const data = produceList.value[0].value
           dataList = JSON.parse(`[${data}]`);
-          labelList = dataList[0]
+          const printElements = dataList[0].panels[0].printElements;
+          let a = []
+          printElements.forEach(element => {
+            if(element.options.field==='table'){
+              element.options.columns[0].forEach(elements => {
+                if(elements.field){
+                  a.push({
+                        title: elements.title,
+                        name: elements.field
+                      }
+                  )
+                }
+              })
+            }else{
+              a.push({
+                title: element.options.title,
+                name: element.options.field
+              })
+            }
+          })
+          labelList = a
           for (let i = 0; i < list.value.length; i++) {
-            let count= list.value[i].data.length
+            let count = list.value[i].data.length
             for (let j = 0; j < count; j++) {
-              for (let k = 0; k < list.value[i].data[j].quantity; k++){
-                lastList.value.push(list.value[i].data[j])
+              if (detailType==0){
+                for (let k = 0; k < list.value[i].data[j].quantity; k++) {
+                  props.lastList.push(list.value[i].data[j])
+                }
+
+              }
+              else {
+                for (let k = 0; k < list.value[i].data[j].quantity; k++) {
+                props.lastList.push(list.value[i].data[j])
+                }
               }
             }
           }
@@ -65,58 +101,93 @@
 )
 
 
-// 鎵撳嵃鏂规硶
-const printFlowCard = () => {
-  // 闇�瑕佹墦鍗扮殑灞�閮ㄥ尯鍩熻祴浜�"print-wrap"鐨刬d
-  let el = document.getElementById("print");
-  let doc = document;
-  let body = doc.body || doc.getElementsByTagName("body")[0];
-  let printId = "print-" + Date.now();
 
-  // 鍒涘缓鏃犲壇浣滅敤鐨勬墦鍗板鍣�(鍥犱笉纭畾椤甸潰鐨勬墦鍗板厓绱犳湁鏃犲叾瀹冩牱寮�)
-  let content = doc.createElement("div");
-  content.id = printId;
+//淇敼鐩稿悓浜у搧鍚嶇О鏍囩
+const updateProductName = (event, index,id) => {
+  // 鍒涘缓鏄犲皠瀵硅薄
+  const propertyMapping = {};
+  labelList.forEach(item => {
+    propertyMapping[item.name] = item.title;
+  });
+  // 杈撳叆鐨勫��
+  const newValue = event.target.innerText;
+  const parts = newValue.split('锛�');
+  const result = parts[1]; // 鑾峰彇鍐掑彿鍚庣殑閮ㄥ垎
+  // 鑾峰彇鏄犲皠涓墍鏈夌殑閿�
+  const keys = Object.keys(propertyMapping);
+  // 鏍规嵁 index 鑾峰彇瀵瑰簲鐨勫睘鎬у悕
+  const propertyName = keys[index];
+  // 濡傛灉鏄犲皠涓病鏈夎 index锛岀洿鎺ヨ繑鍥�
+  if (!propertyName) {
+    console.warn('Unsupported index:', index);
+    return;
+  }
 
-  // 鏍峰紡鎺у埗涓庢墦鍗版棤鍏崇殑鍏冪礌闅愯棌
-  let style = doc.createElement("style");
-  style.innerHTML =
-      "body>#" +
-      printId +
-      "{display:none}@media print{body>:not(#" +
-      printId +
-      "){display:none !important}body>#" +
-      printId +
-      "{display:block;padding-top:1px}}";
-  //
-  content.innerHTML = el.outerHTML;
-  body.appendChild(style);
+  // 閬嶅巻 lastList 骞舵洿鏂板搴旂殑灞炴��
+  props.lastList.forEach(obj => {
+    // 鑾峰彇鍓嶇紑鍜� orderId
+    const prefix = props.lastList[id].processId.substring(0, 11);
+    const orderId = obj.orderId;
+    const glassNumber=props.lastList[id].glassNumber
+    // 鏍规嵁 propertyName 鏇存柊灞炴��
+    if (propertyName === 'productAbbreviation' && prefix === obj.processId.substring(0, 11)) {
+      obj.productAbbreviation = result;
+    }
 
-  // 涓巗tyle鍏冪礌璁剧疆鐨勬牱寮忕浉閰嶅悎
-  // 鎶婃墦鍗板唴瀹圭殑鍏冪礌娣诲姞鍒癰ody(浣滀负body鐨勫瓙鍏冪礌锛屽彲鐢╞ody鐨勫瓙閫夋嫨鍣� '>' 鎺у埗鎵撳嵃鏍峰紡)
-  body.appendChild(content);
-  setTimeout(() => {
-    window.print();
-    body.removeChild(content);
-    body.removeChild(style);
-  }, 20);
+    if (propertyName === 'project' && orderId === obj.orderId) {
+      obj.project = result;
+    }
+    if (propertyName === 'productName' && prefix === obj.processId.substring(0, 11)){
+      obj.productName = result;
+    }
+    if (propertyName === 'customerName' && orderId === obj.orderId){
+      obj.customerName = result;
+    }
+    if (propertyName === 'orderId' && orderId === obj.orderId){
+      obj.orderId = result;
+    }
+    if (propertyName === 'glassNumber' && glassNumber === obj.glassNumber){
+      obj.glassNumber = result;
+    }
+    if (propertyName === 'width' && glassNumber === obj.glassNumber){
+      obj.width = result;
+    }
+    if (propertyName === 'height' && glassNumber === obj.glassNumber){
+      obj.height = result;
+    }
+    if (propertyName === 'custom1' && orderId === obj.orderId){
+      obj.custom1 = result;
+    }
+    if (propertyName === 'custom2' && orderId === obj.orderId){
+      obj.custom2 = result;
+    }
+    if (propertyName === 'custom3' && orderId === obj.orderId){
+      obj.custom3 = result;
+    }
+    if (propertyName === 'custom4' && orderId === obj.orderId){
+      obj.custom4 = result;
+    }
+    if (propertyName === 'custom5' && orderId === obj.orderId){
+      obj.custom5 = result;
+    }
+  });
 }
+
+
 </script>
 
 <template>
-  <div class="printFlowCard_finished" id="print">
-    <div v-for="(item1,id) in lastList"   class="entirety_finished">
-        <div class="row4">{{faceOrientation}}</div>
-        <div v-for="(item,id) in labelList"  class="contentRow">
-          <div class="row1" v-if="item1[item.name] != null && item1[item.name] !== ''">{{ item.title }}:</div>
-          <div class="row2" v-if="item1[item.name] != null && item1[item.name] !== ''">{{ item1[item.name] }}</div>
-
-        </div>
-        <div class="row3">
-          <label>W:{{ item1.width }}</label>
-          &nbsp;&nbsp;&nbsp;
-          <label>H:{{ item1.height }}</label>
-        </div>
-
+  <div id="print" :class="company.printLabel.className.custom.printFlowCardName()">
+    <div v-for="(item1,index) in props.lastList" :class="company.printLabel.className.custom.entiretyName()">
+      <div class="row4">{{ faceOrientation }}</div>
+      <div v-for="(item,id) in labelList" :class="company.printLabel.className.custom.contentRowName()">
+        <div v-if="item1[item.name] != null && item1[item.name] !== ''" class="row1"  contenteditable="true" @input="updateProductName($event, id,index)" v-text="item.title+'锛�'+item1[item.name]"></div>
+        <div v-else class="row1"  contenteditable="true" @input="updateProductName($event, id,index)" v-text="item.title+'锛�'"></div>
+        <!--          <div class="row2" style="width: 100%;"><input class="contentRow2" v-model="item1[item.name]"  @keyup="updataProductName()" style="border: none;"/></div>-->
+        <!--          <div v-if="item1[item.name] != null && item1[item.name] !== ''" class="row2" style="width: 100%;" contenteditable="true" @input="updateProductName($event, id)" v-text="item1[item.name]"></div>-->
+      </div>
+      <!--        <div v-html="company.printLabel.custom(item1)"></div>-->
+      <div v-if="(id + 1) % 2 === 0" class="pagebreak"></div>
     </div>
   </div>
 
@@ -220,7 +291,9 @@
 .entirety_finished{
   page-break-before: always;
 }
-
+  .pagebreak {
+    page-break-after: always;
+  }
 }
 
 </style>
\ No newline at end of file

--
Gitblit v1.8.0