From 8f8dfc2652f11931a3ee953a434233fdf71149d2 Mon Sep 17 00:00:00 2001
From: wu <731351411@qq.com>
Date: 星期三, 12 六月 2024 09:32:13 +0800
Subject: [PATCH] 增加接口的返回是否成功,清理钢化文件
---
UI-Project/src/views/Returns/returns.vue | 137 +++++++++++++++++++++++++++++++++++++++------
1 files changed, 117 insertions(+), 20 deletions(-)
diff --git a/UI-Project/src/views/Returns/returns.vue b/UI-Project/src/views/Returns/returns.vue
index 86be983..2aadf11 100644
--- a/UI-Project/src/views/Returns/returns.vue
+++ b/UI-Project/src/views/Returns/returns.vue
@@ -13,7 +13,7 @@
const adda = ref(false)
const flake = ref(false)
const flakea = ref(false)
-import { WebSocketHost } from '@/utils/constants'
+import { WebSocketHost ,host} from '@/utils/constants'
import request from "@/utils/request"
const ida = ref(null);
import { initializeWebSocket, closeWebSocket } from '@/utils/WebSocketService';
@@ -25,6 +25,10 @@
const selectedValuea = ref('');
const selectedValueb = ref('');
const selectedValuec = ref('');
+const upstatus = ref('涓婄墖鏈烘墜鍔ㄧ姸鎬侊細'); // 鍋囪杩欎釜鐢ㄤ簬鏄剧ず鑷姩/鎵嬪姩鐘舵��
+const cuttingMachine = ref(''); // 鍋囪杩欎釜鐢ㄤ簬瀛樺偍鍚庣杩斿洖鐨勭姸鎬佸�硷紙0鎴�1锛�
+const cuttingMachineStatusColor = ref('#911005'); // 鐢ㄤ簬鍔ㄦ�佽缃甶鏍囩鐨勮儗鏅壊
+const inKageWord = ref(0); // 鐢ㄤ簬瀛樺偍瑕佷紶閫掔粰鎺ュ彛鐨刬nKageWord鍊�
const options = ref<any[]>([]); // 涓嬫媺閫夐」鍒楄〃
const selectOptions = ref<Array<any>>([]); // 涓嬫媺閫夐�夐」鏁扮粍
const selectOptionsa = ref<Array<any>>([]); // 涓嬫媺閫夐�夐」鏁扮粍
@@ -40,22 +44,28 @@
// 鏇存柊琛ㄦ牸鏁版嵁
console.log('鎴愬姛鑾峰彇琛ㄦ牸鏁版嵁:', response.data);
tableData.splice(0, tableData.length, ...response.data);
- window.localStorage.setItem('engineeringId', response.data[0].engineeringId)
- selectOptions.value = response.data.map(item => ({
- value: item.width, // 鍋囪杩欐槸浣犳兂瑕佷綔涓簐alue鐨勫睘鎬�
- label: item.width, // 鍋囪杩欐槸浣犳兂瑕佹樉绀虹殑label
+ // window.localStorage.setItem('engineeringId', response.data[0].engineeringId)
+ // 鑾峰彇鍞竴鍊�
+ const uniqueWidths = new Set(response.data.map(item => item.width));
+ const uniqueHeights = new Set(response.data.map(item => item.height));
+ const uniqueFilmsIds = new Set(response.data.map(item => item.filmsId));
+ const uniqueThicknesses = new Set(response.data.map(item => item.thickness));
+
+ selectOptions.value = Array.from(uniqueWidths).map(width => ({
+ value: width, // 鍋囪杩欐槸浣犳兂瑕佷綔涓簐alue鐨勫睘鎬�
+ label: width, // 鍋囪杩欐槸浣犳兂瑕佹樉绀虹殑label
}));
- selectOptionsa.value = response.data.map(item => ({
- value: item.height,
- label: item.height,
+ selectOptionsa.value = Array.from(uniqueHeights).map(height => ({
+ value: height,
+ label: height,
}));
- selectOptionsb.value = response.data.map(item => ({
- value: item.filmsId,
- label: item.filmsId,
+ selectOptionsb.value = Array.from(uniqueFilmsIds).map(filmsId => ({
+ value: filmsId,
+ label: filmsId,
}));
- selectOptionsc.value = response.data.map(item => ({
- value: item.thickness,
- label: item.thickness,
+ selectOptionsc.value = Array.from(uniqueThicknesses).map(thickness => ({
+ value: thickness,
+ label: thickness,
}));
} else {
ElMessage.error(response.msg);
@@ -92,7 +102,7 @@
const titleSelectJsona = ref({
processTypea: [],
})
-const socketUrl = `ws://10.153.19.150:88/api/loadGlass/api/talk/loadGlass`;
+const socketUrl = `ws://${WebSocketHost}:${host}/api/loadGlass/api/talk/loadGlass`;
// 瀹氫箟娑堟伅澶勭悊鍑芥暟锛屾洿鏂� receivedData 鍙橀噺
const handleMessage = (data) => {
// 鏇存柊 tableData 鐨勬暟鎹�
@@ -294,6 +304,7 @@
const response = await request.post('/loadGlass/up-patten-usage/selectUpPattenUsage', {
engineerId: selectedProjectNo.value,
})
+ window.localStorage.setItem('engineeringId', selectedProjectNo.value)
if (response.code == 200) {
// 缁戝畾鎴愬姛锛屽鐞嗛�昏緫
ElMessage.success(response.message);
@@ -303,6 +314,27 @@
selectedProjectNo.value = ''
markingMachineStatus.value = '#911005';
cuttingMachineStatus.value = '#911005';
+ const uniqueWidths = new Set(response.data.map(item => item.width));
+ const uniqueHeights = new Set(response.data.map(item => item.height));
+ const uniqueFilmsIds = new Set(response.data.map(item => item.filmsId));
+ const uniqueThicknesses = new Set(response.data.map(item => item.thickness));
+
+ selectOptions.value = Array.from(uniqueWidths).map(width => ({
+ value: width, // 鍋囪杩欐槸浣犳兂瑕佷綔涓簐alue鐨勫睘鎬�
+ label: width, // 鍋囪杩欐槸浣犳兂瑕佹樉绀虹殑label
+ }));
+ selectOptionsa.value = Array.from(uniqueHeights).map(height => ({
+ value: height,
+ label: height,
+ }));
+ selectOptionsb.value = Array.from(uniqueFilmsIds).map(filmsId => ({
+ value: filmsId,
+ label: filmsId,
+ }));
+ selectOptionsc.value = Array.from(uniqueThicknesses).map(thickness => ({
+ value: thickness,
+ label: thickness,
+ }));
} else {
// 璇锋眰澶辫触锛屾樉绀洪敊璇秷鎭�
ElMessage.error(response.msg);
@@ -462,6 +494,68 @@
const confirmCuttingMachine = () => {
cuttingMachineStatus.value = 'green';
};
+
+
+
+const wsUrl = `ws://${WebSocketHost}:${host}/api/loadGlass/api/talk/loadGlass`;
+const ws = new WebSocket(wsUrl);
+ws.onopen = () => {
+ console.log('WebSocket杩炴帴宸叉墦寮�');
+};
+
+// 鐩戝惉WebSocket鐨勯敊璇簨浠�
+ws.onerror = (error) => {
+ console.error('WebSocket鍙戠敓閿欒:', error);
+};
+
+// 鐩戝惉WebSocket鐨勫叧闂簨浠�
+ws.onclose = (event) => {
+ if (event.wasClean) {
+ console.log('WebSocket杩炴帴宸叉甯稿叧闂�');
+ } else {
+ console.error('WebSocket杩炴帴寮傚父鍏抽棴');
+ }
+};
+
+// 鐩戝惉WebSocket鐨勬秷鎭簨浠�
+ws.onmessage = (event) => {
+ try {
+ const data = JSON.parse(event.data); // 瑙f瀽娑堟伅涓篔SON
+
+ if (data && Array.isArray(data.InkageStatus) && data.InkageStatus.length > 0) {
+ const status = data.InkageStatus[0];
+ cuttingMachine.value = status;
+ upstatus.value = status === '1' ? '涓婄墖鏈鸿仈鏈虹姸鎬侊細' : '涓婄墖鏈烘墜鍔ㄧ姸鎬侊細';
+ cuttingMachineStatusColor.value = status === '1' ? 'green' : '#911005';
+ inKageWord.value = status === '1' ? 0 : 1;
+ } else {
+ // 澶勭悊閿欒鎯呭喌鎴栨棤鏁堟暟鎹�
+ console.error('鎺ユ敹鍒扮殑鏁版嵁鏃犳晥', data);
+ }
+ } catch (error) {
+ console.error('瑙f瀽WebSocket娑堟伅鏃跺彂鐢熼敊璇�', error);
+ }
+};
+const confirmCutting = async () => {
+ try {
+ const response = await request.post('/loadGlass/LoadGlass/updateMesInkageLoad',
+ inKageWord.value
+ );
+ if (response.code == 200) {
+ const status = response.data.status;
+ upstatus.value = status === '1' ? '涓婄墖鏈鸿仈鏈虹姸鎬侊細' : '涓婄墖鏈烘墜鍔ㄧ姸鎬侊細';
+ cuttingMachineStatusColor.value = status === '1' ? 'green' : '#911005';
+ // 鏄剧ず鎴愬姛娑堟伅
+ ElMessage.success(response.message);
+ } else {
+ ElMessage.error(response.message || '璇锋眰澶辫触');
+ }
+ } catch (error) {
+ // 澶勭悊閿欒
+ console.error('璇锋眰鏃跺彂鐢熼敊璇�', error);
+ ElMessage.error('璇锋眰鏃跺彂鐢熼敊璇�');
+ }
+};
</script>
<template>
@@ -469,16 +563,19 @@
<div id="dotClass">
<div>鎵撴爣鏈哄氨缁姸鎬侊細</div>
<i :style="{ marginTop: '2px', backgroundColor: markingMachineStatus, width: '18px', height: '18px', borderRadius: '50%', display: 'block' }"></i>
- <el-button @click="confirmMarkingMachine" style="margin-left: 30px;margin-top: -3px;">鎵嬪姩纭</el-button>
-
+ <el-button @click="confirmMarkingMachine" style="margin-left: 30px;margin-top: -3px;">纭</el-button>
<div style="margin-left: 70px;">鍒囧壊鏈哄氨缁姸鎬侊細</div>
<i :style="{ marginTop: '2px', backgroundColor: cuttingMachineStatus, width: '18px', height: '18px', borderRadius: '50%', display: 'block' }"></i>
- <el-button @click="confirmCuttingMachine" style="margin-left: 30px;margin-top: -3px;" >鎵嬪姩纭</el-button>
- </div>
+ <el-button @click="confirmCuttingMachine" style="margin-left: 30px;margin-top: -3px;" >纭</el-button>
+ <div style="margin-left: 70px;">{{ upstatus }} </div>
+ <i :style="{ marginTop: '2px', backgroundColor: cuttingMachineStatusColor, width: '18px', height: '18px', borderRadius: '50%', display: 'block' }"></i>
+ <el-button @click="confirmCutting" style="margin-left: 30px;margin-top: -3px;" >纭</el-button>
+
+ </div>
<el-button style="margin-top: 5px;margin-left: 15px;" id="searchButton" type="primary" @click="dialogFormVisible = true">閫夋嫨宸ョ▼</el-button>
<el-button style="margin-top: 5px;margin-left: 20px;" id="searchButton" type="primary" @click="handleBind">寮�濮嬩笂鐗�</el-button>
<el-button style="margin-top: 5px;margin-left: 20px;" id="searchButton" type="warning" @click="handleBinda">鏆傚仠</el-button>
- <el-button style="margin-top: 5px;margin-left: 20px;" id="searchButton" type="danger" @click="handleBindb">鍋滄浠诲姟</el-button>
+ <!-- <el-button style="margin-top: 5px;margin-left: 20px;" id="searchButton" type="danger" @click="handleBindb">鍋滄浠诲姟</el-button> -->
<el-card style="flex: 1;margin-left: 10px;margin-top: 15px;" v-loading="loading">
<div style="width: 98%; height: calc(100% - 35px); overflow-y: auto;">
--
Gitblit v1.8.0