From 5bd56f3ebf96aa9a71e4a452cd2402df59d17384 Mon Sep 17 00:00:00 2001
From: 严智鑫 <test>
Date: 星期四, 04 九月 2025 09:28:27 +0800
Subject: [PATCH] 1.全部页面增加线下数据查询 2.增加一键删除线下玻璃按钮
---
UI-Project/src/views/Marking/marking.vue | 132 +++++++++++++++++++++++++++++++++++--------
1 files changed, 106 insertions(+), 26 deletions(-)
diff --git a/UI-Project/src/views/Marking/marking.vue b/UI-Project/src/views/Marking/marking.vue
index c8b2702..de00271 100644
--- a/UI-Project/src/views/Marking/marking.vue
+++ b/UI-Project/src/views/Marking/marking.vue
@@ -6,6 +6,7 @@
import { useI18n } from 'vue-i18n'
import { WebSocketHost ,host} from '@/utils/constants'
import { initializeWebSocket, closeWebSocket } from '@/utils/WebSocketService';
+import {gridDateFormatter} from '@/stores/tool';
let language = ref(localStorage.getItem('lang') || 'zh')
const { t } = useI18n()
@@ -15,29 +16,94 @@
});
const loadData = ref([]);
const findMachine = ref([]);
-const machineId=11;//褰撳墠椤甸潰鐨勮澶嘔D
-//浣跨敤WebSocket鏂瑰紡灞曠ず鏁版嵁
-let socket = null;
-const socketUrl = `ws://${WebSocketHost}:${host}/api/deviceInteraction/api/talk/marking`;
-// 瀹氫箟娑堟伅澶勭悊鍑芥暟锛屾洿鏂� receivedData 鍙橀噺
-const handleMessage = (data) => {
- // 鏇存柊 tableData 鐨勬暟鎹�
- loadData.value = data.taskingList[0];
- findMachine.value = data.machine[0];
-};
-onUnmounted(() => {
- if (socket) {
- closeWebSocket(socket);
+const sendRecords = ref([]);
+const downLineTask = ref([]);
+
+const userInfo=JSON.parse(window.localStorage.getItem('userInfo'));
+const pageParams=userInfo.user.menus[0].pages[3].params;
+const pageParamsJson=JSON.parse(pageParams);
+const machineId = pageParamsJson.machineId;//褰撳墠椤甸潰鐨勮澶嘔D
+console.log(machineId);
+//const machineId=12;//褰撳墠椤甸潰鐨勮澶嘔D
+// 鏂板锛氬畾鏃朵换鍔D锛堢敤浜庢竻闄ゅ畾鏃跺櫒锛�
+const timerId = ref(null);
+/**
+ * 鍗曟鎺ュ彛璇锋眰鍑芥暟
+ * 浣滅敤锛氳皟鐢ㄥ悗绔帴鍙o紝鑾峰彇鏁版嵁鍚庝氦缁� handleMessage 澶勭悊
+ */
+const fetchMachineData = async () => {
+ try {
+ // 浠诲姟鏁版嵁
+ request.post("/deviceInteraction/tasking/findMachineTask",{
+ "id": machineId
+ }).then((res) => { // 鏇挎崲涓轰綘鐨凙PI绔偣
+ if (res.code === 200) {
+ // 鍋囪鍚庣杩斿洖鐨勬暟鎹牸寮忎笌 handleMessage 棰勬湡涓�鑷�
+ const responseData = res.data || {};
+ loadData.value =responseData;
+ }
+ });
+
+ // 璁惧鏁版嵁
+ request.post("/deviceInteraction/machine/findMachine",{
+ "id": machineId
+ }).then((res) => { // 鏇挎崲涓轰綘鐨凙PI绔偣
+ if (res.code === 200) {
+ // 鍋囪鍚庣杩斿洖鐨勬暟鎹牸寮忎笌 handleMessage 棰勬湡涓�鑷�
+ const responseData = res.data || {};
+ findMachine.value =responseData;
+ }
+ });
+
+ // 绾夸笅鏁版嵁
+ request.post("/deviceInteraction/tasking/selectGlassDownLine").then((res) => { // 鏇挎崲涓轰綘鐨凙PI绔偣
+ if (res.code === 200) {
+ // 鍋囪鍚庣杩斿洖鐨勬暟鎹牸寮忎笌 handleMessage 棰勬湡涓�鑷�
+ const responseData = res.data || {};
+ downLineTask.value =responseData;
+ }
+ });
+ } catch (err) {
+ console.error('瀹氭椂璇锋眰鍚庣鎺ュ彛澶辫触锛�', err);
}
-});
-onBeforeUnmount(() => {
- console.log("鍏抽棴浜�")
- closeWebSocket();
+};
+
+/**
+ * 鍚姩瀹氭椂鍣�
+ * @param {number} interval - 瀹氭椂闂撮殧锛堟绉掞紝榛樿500ms锛屼笌鍚庣浠诲姟棰戠巼瀵归綈锛�
+ */
+const startTimer = (interval = 500) => {
+ // 鍏堟竻闄ゅ凡鏈夊畾鏃跺櫒锛堥伩鍏嶉噸澶嶅垱寤猴級
+ if (timerId.value) clearInterval(timerId.value);
+ // 绔嬪嵆鎵ц涓�娆★紙閬垮厤棣栨绛夊緟闂撮殧锛�
+ fetchMachineData();
+ // 鍒涘缓鏂板畾鏃跺櫒
+ timerId.value = setInterval(() => {
+ fetchMachineData();
+ }, interval);
+};
+
+/**
+ * 娓呴櫎瀹氭椂鍣紙閬垮厤鍐呭瓨娉勬紡锛�
+ */
+const clearTimer = () => {
+ if (timerId.value) {
+ clearInterval(timerId.value);
+ timerId.value = null; // 閲嶇疆ID
+ }
+};
+
+// 缁勪欢鍗歌浇鏃舵竻闄ゅ畾鏃跺櫒锛堝叧閿細閬垮厤缁勪欢閿�姣佸悗瀹氭椂鍣ㄤ粛杩愯锛�
+onUnmounted(() => {
+ clearTimer();
});
onMounted(async () => {
- //浣跨敤WebSocket鏂瑰紡灞曠ず鏁版嵁
- socket = initializeWebSocket(socketUrl, handleMessage);// 鍒濆鍖� WebSocket锛屽苟浼犻�掓秷鎭鐞嗗嚱鏁�
+ startTimer(500); // 500ms 闂撮殧锛堝彲鏍规嵁涓氬姟璋冩暣锛屽1000ms锛�
+ // //浣跨敤WebSocket鏂瑰紡灞曠ず鏁版嵁
+ // socket = initializeWebSocket(socketUrl, handleMessage);// 鍒濆鍖� WebSocket锛屽苟浼犻�掓秷鎭鐞嗗嚱鏁�
+ // //浣跨敤WebSocket鏂瑰紡灞曠ず鏁版嵁
+ // socketDownLineTask = initializeWebSocket(socketDownLineTaskUrl, handleMessage2);// 鍒濆鍖� WebSocket锛屽苟浼犻�掓秷鎭鐞嗗嚱鏁�
});
//淇敼宸ヤ綔鐘舵�� 銆愬け璐�/姝e湪宸ヤ綔/瀹屽伐銆�
const workStatus = async(row,state) => {
@@ -194,25 +260,28 @@
<el-button :type="(findMachine['state']=='鏆傚仠'?'danger':'success')" id="ButtonMachineStatus"
@click="machineStatus((findMachine['state']=='鏆傚仠'?'寮�宸�':'鏆傚仠'))">
{{findMachine['state']=='寮�宸�'?$t('functionState.start'):$t('functionState.stop')}}</el-button>
- <el-button type="primary" id="ButtonTopLine" @click="topLine">{{$t('functionState.topLine')}}</el-button>
+<!-- <el-button type="primary" id="ButtonTopLine" @click="topLine">{{$t('functionState.topLine')}}</el-button>-->
<!-- <el-button type="primary" id="searchButton" @click="downLine('涓嬬嚎')">涓嬬嚎</el-button>
<el-button type="primary" id="searchButton" @click="workStatus('鐮存崯')">鐮存崯</el-button>
<el-button type="primary" id="searchButton" @click="workStatus('瀹屽伐')">瀹屽伐</el-button> -->
</div>
- <div id="main-body" style="min-height:240px;">
+ <div id="main-body">
<!-- 琛ㄦ牸鍐呭 -->
- <el-table :data="loadData" stripe
+ <el-table :data="loadData" stripe style="height:260px"
:header-cell-style="{ background: '#F2F3F5 ', color: '#1D2129', textAlign: 'center' }"
:cell-style="{ textAlign: 'center' }">
<!-- <el-table-column type="selection" min-width="30" /> -->
<el-table-column type="index" :label="$t('glassInfo.number')" min-width="30" />
+ <el-table-column prop="isMarking" :label="$t('glassInfo.isMarking')"/>
<el-table-column prop="batchNumber" :label="$t('glassInfo.batchNumber')"/>
<el-table-column prop="taskType" :label="$t('glassInfo.taskType')"/>
<el-table-column prop="glassId" :label="$t('glassInfo.glassId')"/>
+ <el-table-column prop="scanId" :label="$t('glassInfo.scanId')" />
<el-table-column prop="length" :label="$t('glassInfo.length')"/>
<el-table-column prop="width" :label="$t('glassInfo.width')"/>
<el-table-column prop="thickness" :label="$t('glassInfo.thickness')"/>
<el-table-column prop="workState" :label="$t('glassInfo.workState')"/>
+ <el-table-column prop="operationRecordTime" :formatter="gridDateFormatter" :label="$t('glassInfo.operationRecordTime')" width="180"/>
<el-table-column fixed="right" :label="$t('productStock.operate')" align="center" width="270">
<template #default="scope">
<el-button size="mini" link type="primary" plain @click="workStatus(scope.row, '閲嶅彂')" >{{$t('functionState.anew')}}</el-button>
@@ -224,11 +293,22 @@
</el-table>
</div>
- <div id="main-body"
- style="width: 100%; height: 460px;background-image: url(../../src/assets/鑷姩鎵撴爣鏈�.png) ;background-size: 100% 100%;">
- <!-- 鐢诲浘鍐呭 -->
- <div style="width: 100px; height: 100px; background-color: red; position: relative; top: 171px; left: 218px">
+ <div id="main-body" style="width: 100%; height: 460px;min-width: 1200px;">
+ <img style="width: 70%;min-width: 900px; height: 460px;float: left;" src="../../assets/鑷姩鎵撴爣鏈�.png">
+ <!-- <el-image style="width: 70%;min-width: 900px; height: 460px;float: left;" src="../../src/assets/鑷姩鎵撴爣鏈�.png"></el-image> -->
+ <!-- <div style="width: 70%;min-width: 900px; height: 460px;background-image: url('../../src/assets/鑷姩鎵撴爣鏈�.png') ;background-size: 100% 100%;float: left;">
+
+ </div> -->
+ <div style="width: 30%;min-width: 300px; height: 460px;float: left;padding: 20px;;">
+ <!-- <div style="text-align: center;height: 30px;line-height: 30px;font-size: 20px;padding: 20px;">鏁版嵁浜や簰璁板綍</div> -->
+ <el-table :data="sendRecords" stripe :header-cell-style="{ background: '#F2F3F5 ', color: '#1D2129', textAlign: 'center',height:'30px'}" :cell-style="{ textAlign: 'center' }">
+ <el-table-column prop="sendContent" :label="$t('glassInfo.sendContent')"/>
+ </el-table>
</div>
+ <div style="clear锛歜oth"></div>
+ <!-- 鐢诲浘鍐呭
+ <div style="width: 100px; height: 100px; background-color: red; position: relative; top: 171px; left: 218px">
+ </div>-->
</div>
</div>
</template>
--
Gitblit v1.8.0