From d5d0d1c7a84b996b9bbcebfaf2c2c95f1a5a3678 Mon Sep 17 00:00:00 2001
From: zhoushihao <zsh19950802@163.com>
Date: 星期五, 11 十月 2024 08:39:15 +0800
Subject: [PATCH] Merge remote-tracking branch 'origin/master'

---
 UI-Project/src/views/UnLoadGlass/loadmachinerack.vue |  324 ++++++++++++++++++++++++++++++++++++++++++------------
 1 files changed, 252 insertions(+), 72 deletions(-)

diff --git a/UI-Project/src/views/UnLoadGlass/loadmachinerack.vue b/UI-Project/src/views/UnLoadGlass/loadmachinerack.vue
index a538d4b..5a918af 100644
--- a/UI-Project/src/views/UnLoadGlass/loadmachinerack.vue
+++ b/UI-Project/src/views/UnLoadGlass/loadmachinerack.vue
@@ -1,43 +1,86 @@
 <script setup>
-import { Search } from "@element-plus/icons-vue";
-import { reactive, onMounted, onBeforeUnmount, onUnmounted } from "vue";
+import { onBeforeUnmount, onMounted, onUnmounted, reactive, ref } from "vue";
 import { useRouter } from "vue-router"
-const router = useRouter()
 import { useI18n } from 'vue-i18n'
-const { t } = useI18n()
-let language = ref(localStorage.getItem('lang') || 'zh')
-import { ref } from 'vue'
-import { ElMessage, ElMessageBox } from 'element-plus'
+import { ElMessage } from 'element-plus'
+import request from "@/utils/request";
+import { closeWebSocket, initializeWebSocket } from '@/utils/WebSocketService';
+import { host, WebSocketHost } from '@/utils/constants'
+import PrintFlow from "@/views/UnLoadGlass/PrintFlow.vue";
 import Landingindication from "./Landingindication.vue";
 import Landingindicationtwo from "./Landingindicationtwo.vue";
-import request from "@/utils/request";
-import { initializeWebSocket, closeWebSocket } from '@/utils/WebSocketService';
-import { WebSocketHost, host } from '@/utils/constants'
-import PrintFlow from './PrintFlow.vue'
-import print from 'fromwe-print-nb'
+import PrintLabel from "@/views/UnLoadGlass/PrintCustomLabelSemi1.vue";
+
+const router = useRouter()
+const { t } = useI18n()
+let language = ref(localStorage.getItem('lang') || 'zh')
+const printLoading = ref(true)
+const fullFlowCard = ref('')
+const autoPrint = ref(false)
+const takeGlass = ref([])
+const scanGlass = ref([])
+
+
 const dialogFormVisiblea = ref(false)
 const dialogFormVisiblea2 = ref(false)
 const dialogFormVisibleaDownGlass = ref(false)
+const dialogFormVisibleaDownGlasss = ref(false)
 // 鏁版嵁
 const loading = ref(false);
 // 寮规鏄剧ず鎺у埗
 const dialogFormVisible = ref(false);
 // 琛ㄥ崟鏁版嵁
 const workstationId = ref('');
-const selectedProjectNoa = ref(null); // 褰撳墠閫変腑鐨勮鑹� 
+const workFlowCard = ref('');
+const selectedProjectNoa = ref(null); // 褰撳墠閫変腑鐨勮鑹�
 const flowCardId = ref('');
 const flowCardOptions = ref('[]');
 const tableData = reactive([]);
 const downGlass = ref([]);
-const timeRange = ref(["2022-01-01", "2025-01-01"])
+
 const selectValuesa = reactive({});
 const selectOptionsa = ref([]);
 const dialogTableVisible = ref(false)
+const dialogTableVisible1 = ref(false)
 const printFlowCardId = ref('')
-const printLayer=ref('')
+const printLayer = ref('')
+const now = new Date();
+const timeRange = ref([])
+const browser = ref(false)
+
+const handleChange = async () => {
+  console.log("瑙﹀彂寮�鍏�")
+  try {
+    const body = {
+      flag: autoPrint.value, // 浣跨敤 ganghua.value 鑾峰彇褰撳墠寮�鍏崇殑鐘舵��
+    };
+
+    var url = "/unLoadGlass/downWorkStation/autoPrint?flag=" + autoPrint.value;
+    const response = await request.post(url)
+    if (response.code == 200) {
+      // 缁戝畾鎴愬姛锛屽鐞嗛�昏緫
+      ElMessage.success(response.message);
+      autoPrint.value = response.data
+    } else {
+      ElMessage.error(response.message);
+    }
+  } catch (error) {
+    // 澶勭悊閿欒
+    console.error(error);
+  }
+}
+const confirmBrowser = () => {
+  if (/chrome|chromium/i.test(navigator.userAgent) && !/edg/i.test(navigator.userAgent)) {
+    browser.value = true
+  } else if (/edg/i.test(navigator.userAgent)) {
+    browser.value = false
+  } else {
+    browser.value = false
+  }
+}
 
 const handleInputChangea = (value, rowId) => {
-  // 鏇存柊瀵瑰簲琛岀殑 select 鍊�  
+  // 鏇存柊瀵瑰簲琛岀殑 select 鍊�
   selectValuesa[rowId] = value;
 };
 // 鏂规硶
@@ -72,14 +115,13 @@
 //纭
 const handleConfirm = async () => {
   try {
-    const firstPart = flowCardId.value.split('|')[0].trim(); // 
-    const twoPart = flowCardId.value.split('|')[1].trim(); // 
+    const firstPart = flowCardId.value.split('|')[0].trim(); //
+    const twoPart = flowCardId.value.split('|')[1].trim(); //
     const response = await request.post('unLoadGlass/downWorkStation/updateFlowCardId', {
       workstationId: workstationId.value,
       flowCardId: firstPart,
       layer: twoPart
     });
-    console.log(response)
     if (response.code == 200) {
       // 缁戝畾鎴愬姛锛屽鐞嗛�昏緫
       console.log('缁戝畾鎴愬姛');
@@ -105,6 +147,7 @@
 const handleBindRack2 = (row) => {
   workstationId.value = row.workstationId; // 鍋囪rackNumber鏄灦鍙峰瓧娈电殑灞炴�у悕
   dialogFormVisiblea2.value = true; // 鎵撳紑缁戝畾鏋跺瓙瀵硅瘽妗�
+  workFlowCard.value = row.flowCardId;
 };
 //娓呴櫎鍐呭
 const handleclear = async () => {
@@ -119,6 +162,9 @@
       console.log('娓呴櫎鎴愬姛');
       ElMessage.success(response.message);
       dialogFormVisiblea2.value = false;
+      if (fullFlowCard.value == workFlowCard.value) {
+        fullFlowCard.value = "";
+      }
     } else if (response.code === 500) {
       // 娓呴櫎澶辫触鐨勯�昏緫
       console.log('娓呴櫎澶辫触');
@@ -156,20 +202,64 @@
 const socketUrl = `ws://${WebSocketHost}:${host}/api/unLoadGlass/api/talk/unloadglass`;
 // 瀹氫箟娑堟伅澶勭悊鍑芥暟锛屾洿鏂� receivedData 鍙橀噺
 const handleMessage = (data) => {
+
   // 鏇存柊 tableData 鐨勬暟鎹�
   if (data.downGlassInfos != null) {
-    downGlass.value = data.downGlassInfos[0][1];
+    downGlass.value = data.downGlassInfos[0];
   }
   if (data.engineerIdList != null) {
     selectOptionsa.value = data.engineerIdList[0]
   }
+  if (data.autoPrint != null) {
+    autoPrint.value = data.autoPrint[0];
+  }
+  if (data.takeGlass != null) {
+      
+    takeGlass.value = data.takeGlass[0];
+      // takeGlass.value 鏄竴涓┖瀵硅薄
+      let width = takeGlass.value.width;
+      let height = takeGlass.value.height;
+      if (width < height) {
+        takeGlass.value.width = height;
+        takeGlass.value.height = width;
+      }
 
-  // tableData.splice(0, tableData.length, ...data.params[0]);
+
+  }
+  if (data.scanGlass != null) {
+    scanGlass.value = data.scanGlass[0];
+    let width = scanGlass.value.width;
+    let height = scanGlass.value.height;
+    if (width < height) {
+      scanGlass.value.width = height;
+      scanGlass.value.height = width;
+    }
+  }
+
+  //鑷姩鎵撳嵃
+  if (fullFlowCard.value == "" && autoPrint.value == true && browser.value == true) {
+    for (let i = 0; i < tableData.length; i++) {
+      if (tableData[i].totalQuantity != 0) {
+        if (tableData[i].totalQuantity == tableData[i].racksNumber + tableData[i].otherNumber && fullFlowCard.value != tableData[i].flowCardId) {
+          // printFlowCardId.value = tableData[i].flowCardId;
+          fullFlowCard.value = tableData[i].flowCardId;
+          open(tableData[i]);
+          break;
+        }
+      } else {
+        console.log("娌℃湁flowCardId")
+      }
+    }
+  }
+  if (data.params != null) {
+    tableData.splice(0, tableData.length, ...data.params[0]);
+  }
 
   //  console.log("鏇存柊鍚庢暟鎹�", data.params[0]);
 };
 // 鍒濆鍖� WebSocket锛屽苟浼犻�掓秷鎭鐞嗗嚱鏁�
 onMounted(() => {
+  confirmBrowser();//鑾峰彇娴忚鍣�
   fetchFlowCardId();
   fetchTableData(); // 鑾峰彇鏁版嵁
   socket = initializeWebSocket(socketUrl, handleMessage);
@@ -218,15 +308,14 @@
 
 // 鏌ヨ鏁版嵁
 const selectDownGlassData = async () => {
-  
-  const response = await request.post("/unLoadGlass/downGlassInfo/selectDownGlassInfo", {
+
+  const response = await request.post("/unLoadGlass/downGlassInfo/setDownGlassInfoRequest", {
     workStationId: selectValuesa[0],
     engineerId: selectValuesa[1],
     beginDate: timeRange.value[0],
     endDate: timeRange.value[1],
   })
   if (response.code === 200) {
-    sendDownGlass.value = response.data;
     ElMessage.success(response.message);
   } else {
     ElMessage.error(response.message);
@@ -235,15 +324,25 @@
 }
 
 
-const open=async(row)=>{
+const open = async (row) => {
 
-  printFlowCardId.value=row.flowCardId;
-  printLayer.value=row.layer
+  printFlowCardId.value = row.flowCardId;
+  printLayer.value = row.layer
   dialogTableVisible.value = true;
   setTimeout(() => {
-    printFlowCard(); // 鏇挎崲鎴愪綘瑕佹墽琛岀殑鍑芥暟鍚�
-    }, 1000);
-  ;
+    printFlowCard();
+    dialogTableVisible.value = false;
+  }, 2000);
+}
+const open1 = async (row) => {
+
+  printFlowCardId.value = row.flowCardId;
+  printLayer.value = row.layer
+  dialogTableVisible1.value = true;
+  setTimeout(() => {
+    printFlowCard1();
+    //dialogTableVisible1.value = false;
+  }, 1000);
 }
 
 const printFlowCard = () => {
@@ -257,20 +356,65 @@
   let content = doc.createElement("div");
   content.id = printId;
 
+  // alert(/Chrome/.test(userAgent) && !/Edge/.test(userAgent));
+
+  // 鏍峰紡鎺у埗涓庢墦鍗版棤鍏崇殑鍏冪礌闅愯棌
+  let style = doc.createElement("style");
+  console.log("style1:" + style.innerHTML)
+  style.innerHTML =
+    "body>#" +
+    printId +
+    "{display:none;}@media print{" +
+    "@page {" +
+    "    size: auto; " +
+    "    margin: 10mm 5mm 10mm 5mm; " +
+    "  }body>:not(#" +
+    printId +
+    "){display:none !important;}body>#" +
+    printId +
+    "{display:block;}#" +
+    printId +
+    "{display: block; padding: 0; margin: 0;  width: 100%;  position: absolute; top: 0; left: 0; height: 100vh;  box-sizing: border-box;}} ";
+
+  content.innerHTML = el.outerHTML;
+  // // console.log("el.outerHTML", el.outerHTML);
+  body.appendChild(style);
+
+  // 涓巗tyle鍏冪礌璁剧疆鐨勬牱寮忕浉閰嶅悎
+  // 鎶婃墦鍗板唴瀹圭殑鍏冪礌娣诲姞鍒癰ody(浣滀负body鐨勫瓙鍏冪礌锛屽彲鐢╞ody鐨勫瓙閫夋嫨鍣� '>' 鎺у埗鎵撳嵃鏍峰紡)
+  body.appendChild(content);
+  setTimeout(() => {
+    window.print();
+    body.removeChild(content);
+    body.removeChild(style);
+  }, 20);
+}
+
+const printFlowCard1 = () => {
+  // 闇�瑕佹墦鍗扮殑灞�閮ㄥ尯鍩熻祴浜�"print-wrap"鐨刬d
+  let el = document.getElementById("printFlowCard");
+  let doc = document;
+  let body = doc.body || doc.getElementsByTagName("body")[0];
+  let printId = "print-" + Date.now();
+
+  // 鍒涘缓鏃犲壇浣滅敤鐨勬墦鍗板鍣�(鍥犱笉纭畾椤甸潰鐨勬墦鍗板厓绱犳湁鏃犲叾瀹冩牱寮�)
+  let content = doc.createElement("div");
+  content.id = printId;
+
   // 鏍峰紡鎺у埗涓庢墦鍗版棤鍏崇殑鍏冪礌闅愯棌
   let style = doc.createElement("style");
   style.innerHTML =
-      "body>#" +
-      printId +
-      "{display:none}@media print{" +
-      "@page {" +
-      "    size: auto; " +
-      "    margin: 2mm 2mm 0mm 1mm; " +
-      "  }body>:not(#" +
-      printId +
-      "){display:none !important}body>#" +
-      printId +
-      "{display:block;padding-top:1px}}";
+    "body>#" +
+    printId +
+    "{display:none}@media print{" +
+    "@page {" +
+    "    size: auto; " +
+    "    margin: 2mm 2mm 2mm 2mm;  " +
+    "  }body>:not(#" +
+    printId +
+    "){display:none !important}body>#" +
+    printId +
+    "{display:block;padding-top:1px}}";
   //
   content.innerHTML = el.outerHTML;
   // // console.log("el.outerHTML", el.outerHTML);
@@ -287,6 +431,8 @@
 }
 
 
+
+
 // beforeUnmount(() => {
 //   closeWebSocket();
 // });
@@ -294,12 +440,18 @@
 </script>
 <template>
   <div>
-    <el-button style="margin-top: 5px;margin-left: 10px;" id="searchButton" type="primary"
-      @click="dialogFormVisibleaDownGlass = true">钀芥灦璇︽儏</el-button>
+    <el-button style="margin-top: 10px;margin-left: 10px;margin-bottom: 10px;" id="searchButton" type="primary"
+      @click="dialogFormVisibleaDownGlass = true">钀芥灦璇︽儏
+    </el-button>
+    <el-button style="margin-top: 10px;margin-left: 10px;margin-bottom: 10px;" id="searchButton" type="primary"
+      @click="dialogFormVisibleaDownGlasss = true">浜哄伐涓嬬墖
+    </el-button>
+    <el-switch style="margin-top: 10px;margin-left: 15px;margin-bottom: 10px;" v-model="autoPrint" class="mb-2"
+      :inactive-text="$t('鑷姩鎵撳嵃')" @change="handleChange" />
     <el-card style="flex: 1;" v-loading="loading">
       <el-card style="flex: 1;margin-left: 4px;margin-top: 1px;" v-loading="loading">
         <div style="width: 98%; height: calc(100% - 35px); overflow-y: auto;">
-          <el-table height="200px" ref="table" @selection-change="handleSelectionChange" :data="tableData"
+          <el-table height="350px" ref="table" @selection-change="handleSelectionChange" :data="tableData"
             :header-cell-style="{ background: '#F2F3F5 ', color: '#1D2129' }">
             <el-table-column prop="workstationId" align="center" :label="$t('reportWork.lowerbit')" min-width="80" />
             <el-table-column prop="workstationId" align="center" :label="$t('reportWork.shelfnumber')"
@@ -319,21 +471,22 @@
                 </el-tag>
               </template>
             </el-table-column>
-            <el-table-column fixed="right" :label="$t('reportWork.operate')" align="center" width="200">
+            <el-table-column fixed="right" :label="$t('reportWork.operate')" align="center" width="400">
               <template #default="scope">
                 <el-button size="mini" type="text" plain v-show="scope.row.enableState !== '宸插惎鐢�'"
-                  @click="handleBindRack(scope.row)">{{ $t('reportWork.bindingshelves') }}</el-button>
+                  @click="handleBindRack(scope.row)">{{ $t('reportWork.bindingshelves') }}
+                </el-button>
                 <el-button size="mini" type="text" plain @click="handleBindRack2(scope.row)">{{ $t('reportWork.clear')
                   }}</el-button>
-                  <el-button @click="open(scope.row)" :disabled="scope.row.flowCardId==null">鎵撳嵃</el-button>
+                <el-button @click="open(scope.row)" :disabled="scope.row.flowCardId == null">鎵撳嵃娴佺▼鍗�</el-button>
+                <el-button @click="open1(scope.row)" :disabled="scope.row.flowCardId == null">鎵撳嵃鏍囩</el-button>
               </template>
 
             </el-table-column>
           </el-table>
 
         </div>
-        <el-dialog v-model="dialogFormVisibleaDownGlass" top="2vh" width="97%"
-          :title="$t('searchOrder.cageinformation')">
+        <el-dialog v-model="dialogFormVisibleaDownGlass" top="2vh" width="97%" :title="$t('钀芥灦淇℃伅')">
           <el-select v-model="selectValuesa[0]" filterable :placeholder="$t('璇烽�夋嫨宸ヤ綅')" clearable>
             <el-option label="鍏ㄩ儴" value="0"></el-option>
             <el-option label="1" value="1"></el-option>
@@ -343,21 +496,22 @@
             <el-option label="5" value="5"></el-option>
             <el-option label="6" value="6"></el-option>
             <el-option label="7" value="7"></el-option>
-            <el-option label="8" value="8"></el-option>
-            <el-option label="9" value="9"></el-option>
-            <el-option label="10" value="10"></el-option>
           </el-select>
 
           <el-select v-model="selectValuesa[1]" filterable :placeholder="$t('basicData.plselectproject')" clearable
             @input="handleInputChangea($event, row.id)">
             <el-option v-for="item in selectOptionsa" :key="item" :label="item" :value="item" />
           </el-select>
-          <el-date-picker style="margin-left: 10px;" v-model="timeRange" type="daterange" format="YYYY/MM/DD"
-            value-format="YYYY-MM-DD" :start-placeholder="$t('reportmanage.starttime')"
-            :end-placeholder="$t('reportmanage.endtime')" :default-time="defaultTime" />
+
+          <span class="demonstration">鏃堕棿娈�</span>
+          <el-date-picker v-model="timeRange" type="datetimerange" range-separator="鑷�" start-placeholder="寮�濮嬫棩鏈�"
+            value-format="YYYY-MM-DD hh:mm:ss" end-placeholder="缁撴潫鏃ユ湡">
+          </el-date-picker>
+
           <el-button type="primary" style="margin-left: 10px;" @click="selectDownGlassData()">{{
-        $t('reportmanage.inquire')
-      }}</el-button>
+            $t('reportmanage.inquire')
+          }}
+          </el-button>
           <el-table height="200px" ref="table" @selection-change="handleSelectionChange" :data="downGlass"
             :header-cell-style="{ background: '#F2F3F5 ', color: '#1D2129' }">
             <el-table-column prop="workStationId" align="center" :label="$t('宸ヤ綅鍙�')" min-width="80" />
@@ -370,10 +524,43 @@
             <el-table-column prop="Filmsid" align="center" :label="$t('鑶滅郴')" min-width="120" />
             <el-table-column prop="thickness" align="center" label="鍘氬害" min-width="120" />
             <el-table-column prop="glassId" align="center" :label="$t('鐜荤拑id')" min-width="120" />
-
           </el-table>
         </el-dialog>
+        <el-dialog v-model="dialogFormVisibleaDownGlasss" top="2vh" width="97%" :title="$t('浜哄伐涓嬬墖淇℃伅')">
+          <div style="display:flex;justify-content: space-around;">
+            <el-card
+              style="display: flex; justify-content: center; align-items: center; width:800px; height: 800px;position: relative;">
+              <div
+                :style="{ width: takeGlass.width + 'px', height: takeGlass.height + 'px', backgroundColor: '#e1f3d8', transform: 'scale(' + 800 / (takeGlass.width > takeGlass.height ? takeGlass.width : takeGlass.height) + ')' }">
 
+              </div>
+              <div style="font-size: 50px; text-align: center;position: absolute;top:0px;left:170px;">
+                <div>浜哄伐涓嬬墖褰撳墠鐜荤拑淇℃伅</div>
+                <div>{{ takeGlass.flowCardId }}</div>
+                <div>{{ takeGlass.layer }}</div>
+                <div>{{ takeGlass.glassId }}</div>
+                <div>{{ takeGlass.width }}</div>
+                <div>{{ takeGlass.height }}</div>
+              </div>
+            </el-card>
+            <el-card
+              style="display: flex; justify-content: center; align-items: center; width: 800px; height: 800px;position: relative;">
+              <div
+                :style="{ width: scanGlass.width + 'px', height: scanGlass.height + 'px', backgroundColor: '#e1f3d8', transform: 'scale(' + 800 / (scanGlass.width > scanGlass.height ? scanGlass.width : scanGlass.height) + ')' }">
+
+              </div>
+              <div style="font-size: 50px; text-align: center;position: absolute;top:0px;left:200px;">
+                <div>鎵爜鏋綋鍓嶇幓鐠冧俊鎭�</div>
+                <div>{{ scanGlass.flowCardId }}</div>
+                <div>{{ scanGlass.layer }}</div>
+                <div>{{ scanGlass.glassId }}</div>
+                <div>{{ scanGlass.width }}</div>
+                <div>{{ scanGlass.height }}</div>
+
+              </div>
+            </el-card>
+          </div>
+        </el-dialog>
       </el-card>
       <!-- workstationId: '1',
     workstationId: '1005',
@@ -430,20 +617,13 @@
     </template>
   </el-dialog>
 
-  <el-dialog
-        id="sizePrintCalrd"
-        v-model="dialogTableVisible"
-        destroy-on-close
-        style="width: 75%;height:75% ">
-      <!-- <template #header="{ close, titleId, titleClass }">
-        <el-button  @click="printFlowCard" >鎵撳嵃</el-button>
-      </template> -->
-      <print-flow
-          id="child"
-          :printFlowCardId="printFlowCardId"
-          :printLayer="printLayer"
-          style="width: 100%;height: 100%"/>
-    </el-dialog>
+  <el-dialog id="sizePrintCalrd" v-model="dialogTableVisible" destroy-on-close>
+    <print-flow id="child" :printFlowCardId="printFlowCardId" :printLayer="printLayer"
+      style="width: 100%;height: 100%" />
+  </el-dialog>
+  <el-dialog id="sizePrintCalrd1" v-model="dialogTableVisible1" destroy-on-close>
+    <print-label id="printFlowCard" :printFlowCardId="printFlowCardId" :printLayer="printLayer" style="" />
+  </el-dialog>
 
 </template>
 <style scoped>

--
Gitblit v1.8.0