From 10b1d48b7f7655d80e1e431257f3af4e00d5ef2e Mon Sep 17 00:00:00 2001
From: wang <3597712270@qq.com>
Date: 星期四, 06 六月 2024 16:56:21 +0800
Subject: [PATCH] 掰片/识别页面样式,钢化前、钢化后接口
---
UI-Project/src/views/UnLoadGlass/loadmachinerack.vue | 217 +++++++++++++++--------------------------------------
1 files changed, 62 insertions(+), 155 deletions(-)
diff --git a/UI-Project/src/views/UnLoadGlass/loadmachinerack.vue b/UI-Project/src/views/UnLoadGlass/loadmachinerack.vue
index 91793a6..83f2eb6 100644
--- a/UI-Project/src/views/UnLoadGlass/loadmachinerack.vue
+++ b/UI-Project/src/views/UnLoadGlass/loadmachinerack.vue
@@ -1,6 +1,7 @@
<script setup>
import {Search} from "@element-plus/icons-vue";
-import {reactive, onMounted} from "vue";
+import {reactive, onMounted, onBeforeUnmount} from "vue";
+
import {useRouter} from "vue-router"
const router = useRouter()
@@ -9,76 +10,22 @@
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'
const dialogFormVisiblea = ref(false)
-
-
const dialogFormVisiblea2 = ref(false)
-
-
-
-
-
-let socket;
-
-
-const initWebSocket = (token) =>{ //鍒濆鍖杦e
-
-let viewname = "unloadglass";
-
-if (typeof WebSocket === "undefined") {
- console.log("鎮ㄧ殑娴忚鍣ㄤ笉鏀寔WebSocket");
-} else {
- let socketUrl = "ws://" + "localhost"+":88" + "/api/unLoadGlass/api/talk/" + viewname;
- if (socket != null) {
- socket.close();
- socket = null;
- }
-
- // 寮�鍚竴涓獁ebsocket鏈嶅姟
- socket = new WebSocket(socketUrl);
-
- // 鎵撳紑浜嬩欢
- socket.onopen = function () {
- console.log("websocket宸叉墦寮�");
- };
-
-
-
-socket.onmessage = (msg) => {
-if (!msg.data) {
-return; // 濡傛灉鏀跺埌绌烘暟鎹紝鍒欑洿鎺ヨ繑鍥烇紝涓嶆墽琛屽悗缁�昏緫
-}
-
-
-
- let obj = JSON.parse(msg.data);
-
-
- console.log('鏀跺埌娑堟伅锛�', obj.data);
-
- }
-
- }
- }
-
-
-
// 鏁版嵁
const loading = ref(false);
-
// 寮规鏄剧ず鎺у埗
-
const dialogFormVisible = ref(false);
-
// 琛ㄥ崟鏁版嵁
const workstationId = ref('');
const flowCardId = ref('');
const flowCardOptions = ref([]);
-
-
+const tableData = reactive([]);
// 鏂规硶
const handleSelectionChange = () => {
// 澶勭悊琛ㄦ牸琛岄�夋嫨浜嬩欢
@@ -86,15 +33,10 @@
const handleBindRack = (row) => {
workstationId.value = row.workstationId; // 鍋囪rackNumber鏄灦鍙峰瓧娈电殑灞炴�у悕
-
// 鍙戣捣鎺ュ彛璇锋眰鑾峰彇娴佺▼鍗″彿
fetchFlowCardId();
-
-
dialogFormVisiblea.value = true; // 鎵撳紑缁戝畾鏋跺瓙瀵硅瘽妗�
};
-
-
//鑾峰彇娴佺▼鍗″彿
const fetchFlowCardId = async () => {
@@ -102,8 +44,12 @@
const response = await request.get('unLoadGlass/downWorkStation/getflowCardId');
console.log(response)
if (response.code === 200) {
- flowCardOptions.value = response.data.map(item => ({ flowcard_id: item.flow_card_id }));
- } else {
+ flowCardOptions.value = response.data
+ .filter(item => item !== null)
+ .map(item => ({ flowcard_id: item.flow_card_Id }));
+ console.log(flowCardOptions.value);
+}
+ else {
ElMessage.error(response.msg);
}
} catch (error) {
@@ -122,7 +68,9 @@
if (response.code == 200) {
// 缁戝畾鎴愬姛锛屽鐞嗛�昏緫
console.log('缁戝畾鎴愬姛');
+
ElMessage.success(response.message);
+ updatePageData();
dialogFormVisiblea.value = false;
} else {
// 璇锋眰澶辫触锛屾樉绀洪敊璇秷鎭�
@@ -135,13 +83,16 @@
};
+const updatePageData = () => {
+ // 鍋囪浣犵殑椤甸潰涓婃湁涓�涓悕涓� tableData 鐨� Vue 缁勪欢
+ // 浣犲彲浠ョ洿鎺ユ洿鏂� tableData 鐨勬暟鎹�
+ fetchTableData()
+ // 浣跨敤 $forceUpdate() 寮哄埗鏇存柊缁勪欢
+
+};
const handleBindRack2 = (row) => {
workstationId.value = row.workstationId; // 鍋囪rackNumber鏄灦鍙峰瓧娈电殑灞炴�у悕
-
-
-
-
dialogFormVisiblea2.value = true; // 鎵撳紑缁戝畾鏋跺瓙瀵硅瘽妗�
};
//娓呴櫎鍐呭
@@ -173,9 +124,6 @@
};
-
-const tableData = reactive([]);
-
// 鍙戦�佽幏鍙栬〃鏍兼暟鎹殑璇锋眰
const fetchTableData = async () => {
try {
@@ -198,89 +146,36 @@
};
+const socketUrl = `ws://${WebSocketHost}:${host}/api/unLoadGlass/api/talk/unloadglass`;
+// 瀹氫箟娑堟伅澶勭悊鍑芥暟锛屾洿鏂� receivedData 鍙橀噺
+const handleMessage = (data) => {
+
+ // 鏇存柊 tableData 鐨勬暟鎹�
+
+ tableData.splice(0, tableData.length, ...data.params[0]);
+// console.log("鏇存柊鍚庢暟鎹�", data.params[0]);
+
+};
+
+// 鍒濆鍖� WebSocket锛屽苟浼犻�掓秷鎭鐞嗗嚱鏁�
+
+onMounted(() => {
+ fetchFlowCardId();
+ fetchTableData(); // 鑾峰彇鏁版嵁
+ initializeWebSocket(socketUrl, handleMessage);
+});
+
+onBeforeUnmount(() => {
+ console.log("鍏抽棴浜�")
+ closeWebSocket();
+});
+
+// beforeUnmount(() => {
+// closeWebSocket();
+// });
-initWebSocket();
-onMounted(fetchTableData);
-setInterval(fetchTableData, 2000)
-
-const open = () => {
- ElMessageBox.confirm(
- '鏄惁鍒犻櫎璇ユ潯淇℃伅?',
- '鎻愮ず',
- {
- confirmButtonText: '鏄�',
- cancelButtonText: '鍙栨秷',
- type: 'warning',
- }
- )
- .then(() => {
- ElMessage({
- type: 'success',
- message: '鍒犻櫎鎴愬姛锛�',
- })
- })
- .catch(() => {
- ElMessage({
- type: 'info',
- message: '鍒犻櫎澶辫触',
- })
- })
-}
-const getTableRow = (row,type) =>{
- switch (type) {
- case 'edit' :{
- //alert('鎴戞帴鏀跺埌瀛愮粍浠朵紶閫佺殑缂栬緫淇℃伅')
- router.push({path: '/main/returns/createReturns', query: { ReturnID: 'TH24010101' }})
- break
- }
- case 'delete':{
- alert('鎴戞帴鏀跺埌瀛愮粍浠朵紶閫佺殑鍒犻櫎淇℃伅')
- break
- }
- }
-}
-
-const gridOptions = reactive({
- border: "full",//琛ㄦ牸鍔犺竟妗�
- keepSource: true,//淇濇寔婧愭暟鎹�
- align: 'center',//鏂囧瓧灞呬腑
- stripe:true,//鏂戦┈绾�
- rowConfig: {isCurrent: true, isHover: true,height: 50},//榧犳爣绉诲姩鎴栭�夋嫨楂樹寒
- id: 'OrderList',
- showFooter: true,//鏄剧ず鑴�
- printConfig: {},
- importConfig: {},
- exportConfig: {},
- scrollY:{ enabled: true },//寮�鍚櫄鎷熸粴鍔�
- showOverflow:true,
- columnConfig: {
- resizable: true,
- useKey: true
- },
- filterConfig: { //绛涢�夐厤缃」
- remote: true
- },
- customConfig: {
- storage: true
- },
- editConfig: {
- trigger: 'click',
- mode: 'row',
- showStatus: true
- },
- data: [
- {
- 'id': '1',
- 'long': '5',
- 'wide': '1005',
- 'thick': '183.6',
- }
- ],
-})
-
-
-
+// setInterval(fetchTableData, 2000)
</script>
@@ -299,7 +194,19 @@
<el-table-column prop="racksnumber" align="center" label="宸茶惤鏋舵暟閲�" min-width="120" />
<el-table-column prop="work_state" align="center" label="鐘舵��" min-width="120" />
<el-table-column prop="deviceId" align="center" label="璁惧鍙�" min-width="120" />
- <el-table-column prop="enableState" align="center" label="鍚敤鐘舵��" min-width="120" />
+
+
+
+ <el-table-column
+ align="center"
+ label="鍚敤鐘舵��"
+ min-width="80"
+ prop="enableState"
+ >
+ <template #default="scope">
+ <el-tag type="success" >{{ scope.row.enableState==1?"鍚敤":"鏈惎鐢�" }}</el-tag>
+ </template>
+ </el-table-column>
<el-table-column fixed="right" label="鎿嶄綔" align="center" width="200">
<template #default="scope">
<el-button size="mini" type="text" plain v-show="scope.row.enableState !== '宸插惎鐢�' " @click="handleBindRack(scope.row)">缁戝畾鏋跺瓙</el-button>
@@ -390,7 +297,7 @@
}
#main-body{
margin-top: -20px;
- margin-left: 300px;
+ margin-left: 200px;
}
#main-bodya{
margin-top: -10px;
--
Gitblit v1.8.0