From b980b063600af7bcfe16aa1145bcccffc3255eae Mon Sep 17 00:00:00 2001
From: wang <3597712270@qq.com>
Date: 星期三, 29 五月 2024 09:25:12 +0800
Subject: [PATCH] 上片机新增上片机联机状态、上片机手动状态,下拉选筛选
---
UI-Project/src/layout/MainErpView.vue | 59 ++++++++++----
UI-Project/src/views/Returns/returns.vue | 128 ++++++++++++++++++++++++++++----
2 files changed, 154 insertions(+), 33 deletions(-)
diff --git a/UI-Project/src/layout/MainErpView.vue b/UI-Project/src/layout/MainErpView.vue
index 91453ae..3bd4a05 100644
--- a/UI-Project/src/layout/MainErpView.vue
+++ b/UI-Project/src/layout/MainErpView.vue
@@ -13,24 +13,49 @@
const userStore = useUserInfoStore()
const user = userStore.user.userName
-// store.createWebSocket();
-function quit() {
- userStore.$patch({
- user: null,
- })
- // router.push('/login')
- let token = window.localStorage.getItem('userInfo')
-console.log(token);
- request.get("/loadGlass/sys/user/login").then((res) => {
- if (res.code === 200) {
- ElMessage.success(res.msg);
- console.log(res.data);
- } else {
- ElMessage.warning(res.msg);
- // router.push("/login");
- }
- });
+let userInfoStr = window.localStorage.getItem('userInfo')
+console.log(userInfoStr);
+// const userInfoStr = localStorage.getItem('userInfo');
+// let userInfo = userInfoStr.user.token;
+let token = userInfo; // 鎻愬彇 token
+// 閫�鍑虹櫥褰曟柟娉�
+const quit = async () => {
+ try {
+ const response = await request.get('/loadGlass/sys/user/logout', {
+ token: token,
+ user: null,
+ })
+ if (response.code === 200) {
+ // 鐧诲嚭鎴愬姛锛屾竻闄ゆ湰鍦板瓨鍌ㄧ殑 userInfo
+ localStorage.removeItem('userInfo');
+ // 鍙互鍦ㄨ繖閲岄噸缃簲鐢ㄧ姸鎬侊紝濡傚鑸埌鐧诲綍椤电瓑
+ console.log('鐧诲嚭鎴愬姛');
+ } else {
+ // 澶勭悊閿欒鎯呭喌
+ console.error('鐧诲嚭澶辫触', response);
+ }
}
+catch (error) {
+ // 澶勭悊閿欒
+ console.error(error);
+ }
+}
+// store.createWebSocket();
+// function quit() {
+// userStore.$patch({
+// user: null,
+// })
+// // router.push('/login')
+// request.get("/loadGlass/sys/user/login").then((res) => {
+// if (res.code === 200) {
+// ElMessage.success(res.msg);
+// console.log(res.data);
+// } else {
+// ElMessage.warning(res.msg);
+// // router.push("/login");
+// }
+// });
+// }
//鎻愬彇鑿滃崟妯″潡鍒楄〃
let menuList = $ref([])
diff --git a/UI-Project/src/views/Returns/returns.vue b/UI-Project/src/views/Returns/returns.vue
index 86be983..e179221 100644
--- a/UI-Project/src/views/Returns/returns.vue
+++ b/UI-Project/src/views/Returns/returns.vue
@@ -25,6 +25,10 @@
const selectedValuea = ref('');
const selectedValueb = ref('');
const selectedValuec = ref('');
+const upstatus = ref(''); // 鍋囪杩欎釜鐢ㄤ簬鏄剧ず鑷姩/鎵嬪姩鐘舵��
+const cuttingMachine = ref(''); // 鍋囪杩欎釜鐢ㄤ簬瀛樺偍鍚庣杩斿洖鐨勭姸鎬佸�硷紙0鎴�1锛�
+const cuttingMachineStatusColor = ref(''); // 鐢ㄤ簬鍔ㄦ�佽缃甶鏍囩鐨勮儗鏅壊
+const inKageWord = ref(0); // 鐢ㄤ簬瀛樺偍瑕佷紶閫掔粰鎺ュ彛鐨刬nKageWord鍊�
const options = ref<any[]>([]); // 涓嬫媺閫夐」鍒楄〃
const selectOptions = ref<Array<any>>([]); // 涓嬫媺閫夐�夐」鏁扮粍
const selectOptionsa = ref<Array<any>>([]); // 涓嬫媺閫夐�夐」鏁扮粍
@@ -41,21 +45,27 @@
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
+ // 鑾峰彇鍞竴鍊�
+ 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);
@@ -462,6 +472,89 @@
const confirmCuttingMachine = () => {
cuttingMachineStatus.value = 'green';
};
+
+
+
+const wsUrl = 'ws://10.153.19.150:88/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) => {
+ // 鍋囪鏈嶅姟鍣ㄥ彂閫佺殑鏄疛SON鏍煎紡鐨勫瓧绗︿覆
+ try {
+ const data = JSON.parse(event.data); // 瑙f瀽娑堟伅涓篔SON
+
+ // 鍋囪鏈嶅姟鍣ㄥ彂閫佺殑鏁版嵁缁撴瀯鏄� { InkageStatus: ["1"] }
+ 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' ? '#911005' : 'green';
+ 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' ? '#911005' : 'green';
+ // 鏄剧ず鎴愬姛娑堟伅
+ ElMessage.success(response.message);
+ } else {
+ ElMessage.error(response.message || '璇锋眰澶辫触');
+ }
+ } catch (error) {
+ // 澶勭悊閿欒
+ console.error('璇锋眰鏃跺彂鐢熼敊璇�', error);
+ ElMessage.error('璇锋眰鏃跺彂鐢熼敊璇�');
+ }
+};
+// const confirmCutting = async () => {
+// try {
+// const response = await request.post('/loadGlass/LoadGlass/updateMesInkageLoad', {
+// inKageWord: inKageWord.value
+// })
+// if (response.code == 200) {
+// inKageWord == '1' ? '涓婄墖鏈鸿仈鏈虹姸鎬侊細' : '涓婄墖鏈烘墜鍔ㄧ姸鎬侊細';
+// inKageWord.value == '1' ? '#911005' : 'green';
+// ElMessage.success(response.message);
+// } else {
+// // 璇锋眰澶辫触锛屾樉绀洪敊璇秷鎭�
+// ElMessage.error(response.msg);
+// }
+// }
+// catch (error) {
+// // 澶勭悊閿欒
+// console.error(error);
+// }
+// }
</script>
<template>
@@ -469,12 +562,15 @@
<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>
--
Gitblit v1.8.0