|
@@ -36,6 +36,28 @@
|
|
|
</el-icon>
|
|
|
</el-tooltip>
|
|
|
</div>
|
|
|
+ <!-- 静电环状态样式 -->
|
|
|
+ <div class="staticBox">
|
|
|
+ <div :class="braceletState == 0 ? 'static type0' : 'static type1'">
|
|
|
+ <div class="titleText">静电手环状态:</div>
|
|
|
+ <div class="titleText state">
|
|
|
+ {{ braceletState == 0 ? "离线" : "在线" }}
|
|
|
+ </div>
|
|
|
+ </div>
|
|
|
+ <!-- <el-button
|
|
|
+ v-if="braceletState == 0"
|
|
|
+ type="primary"
|
|
|
+ class="staticBtn"
|
|
|
+ @click="submit(item, index)"
|
|
|
+ >重新检测</el-button
|
|
|
+ > -->
|
|
|
+ </div>
|
|
|
+ <div class="lightsBox">
|
|
|
+ <div><div class="titleText">电烙铁状态:</div></div>
|
|
|
+ <div class="light" :class="{ activeLight0: lightIndex == 0 }"></div>
|
|
|
+ <div class="light" :class="{ activeLight1: lightIndex == 1 }"></div>
|
|
|
+ <div class="light" :class="{ activeLight2: lightIndex == 2 }"></div>
|
|
|
+ </div>
|
|
|
</div>
|
|
|
</template>
|
|
|
|
|
@@ -51,7 +73,14 @@ const porps = defineProps({
|
|
|
});
|
|
|
//true关闭 false打开
|
|
|
const showStatus = ref(true);
|
|
|
+const lightIndex = ref(null);
|
|
|
+const setExcelVal = (row, col, value) => {
|
|
|
+ if (window.luckysheet) {
|
|
|
+ window.luckysheet.setCellValue(row, col, value);
|
|
|
+ }
|
|
|
+};
|
|
|
const messages = ref([]);
|
|
|
+const braceletState = ref(0);
|
|
|
//首次通知是否弹框
|
|
|
const firstNotice = ref(false);
|
|
|
const page = ref(1);
|
|
@@ -64,30 +93,58 @@ const submit = async (item, index) => {
|
|
|
}
|
|
|
};
|
|
|
//连接地址
|
|
|
-const ws = new WebSocket(
|
|
|
- `${import.meta.env.VITE_WEBSOCKET_URL}/websocket/${localStorage.getItem("token")}`
|
|
|
-);
|
|
|
-ws.onopen = () => {
|
|
|
- console.log("实时已连接");
|
|
|
-};
|
|
|
-ws.onmessage = (event) => {
|
|
|
- const receivedMessage = event.data;
|
|
|
- messages.value = JSON.parse(receivedMessage).content;
|
|
|
- if (firstNotice.value == false) {
|
|
|
- if (messages.value.length > 0) {
|
|
|
- showStatus.value = false;
|
|
|
- } else {
|
|
|
- showStatus.value = true;
|
|
|
+const ws = ref(null);
|
|
|
+const addWebSocket = () => {
|
|
|
+ ws.value = new WebSocket(
|
|
|
+ `${import.meta.env.VITE_WEBSOCKET_URL}/websocket/${localStorage.getItem("token")}`
|
|
|
+ );
|
|
|
+ ws.value.onopen = () => {};
|
|
|
+ ws.value.onmessage = (event) => {
|
|
|
+ const receivedMessage = event.data;
|
|
|
+ const type = JSON.parse(receivedMessage).msgType;
|
|
|
+ switch (type) {
|
|
|
+ //处理左侧弹框消息
|
|
|
+ case "1":
|
|
|
+ if (firstNotice.value == false) {
|
|
|
+ if (messages.value.length > 0) {
|
|
|
+ showStatus.value = false;
|
|
|
+ } else {
|
|
|
+ showStatus.value = true;
|
|
|
+ }
|
|
|
+ }
|
|
|
+ break;
|
|
|
+ //回填表格数据
|
|
|
+ case "2":
|
|
|
+ window.luckysheet.setVal(
|
|
|
+ JSON.parse(JSON.parse(receivedMessage).content)
|
|
|
+ );
|
|
|
+ break;
|
|
|
+ case "3":
|
|
|
+ braceletState.value = JSON.parse(receivedMessage).content;
|
|
|
+ break;
|
|
|
+
|
|
|
+ case "4":
|
|
|
+ lightIndex.value = JSON.parse(receivedMessage).content;
|
|
|
+ break;
|
|
|
}
|
|
|
- }
|
|
|
+ };
|
|
|
+ ws.value.onclose = () => {
|
|
|
+ if (ws.value.readyState == 3) {
|
|
|
+ addWebSocket();
|
|
|
+ }
|
|
|
+ };
|
|
|
};
|
|
|
+
|
|
|
const changePop = () => {
|
|
|
showStatus.value = !showStatus.value;
|
|
|
firstNotice.value = true;
|
|
|
};
|
|
|
-ws.onclose = () => {
|
|
|
- console.log("实时连接断开");
|
|
|
-};
|
|
|
+onMounted(() => {
|
|
|
+ addWebSocket();
|
|
|
+});
|
|
|
+onUnmounted(() => {
|
|
|
+ ws.value.onclose();
|
|
|
+});
|
|
|
</script>
|
|
|
<style scoped lang="scss">
|
|
|
.body {
|
|
@@ -174,4 +231,72 @@ ws.onclose = () => {
|
|
|
}
|
|
|
}
|
|
|
}
|
|
|
+.staticBox {
|
|
|
+ position: fixed;
|
|
|
+ top: 10px;
|
|
|
+ left: 10px;
|
|
|
+ display: flex;
|
|
|
+ align-items: center;
|
|
|
+ .static {
|
|
|
+ height: 60px;
|
|
|
+ background-color: white;
|
|
|
+ border-radius: 16px;
|
|
|
+ padding: 0 10px;
|
|
|
+ display: flex;
|
|
|
+ align-items: center;
|
|
|
+ }
|
|
|
+ .staticBtn {
|
|
|
+ font-size: 20px;
|
|
|
+ margin-left: 10px;
|
|
|
+ }
|
|
|
+}
|
|
|
+.activeLight0 {
|
|
|
+ box-shadow:
|
|
|
+ 0 0 15px yellow,
|
|
|
+ 0 0 25px yellow,
|
|
|
+ 0 0 35px rgb(169, 169, 89);
|
|
|
+ background-color: yellow !important;
|
|
|
+}
|
|
|
+.activeLight1 {
|
|
|
+ box-shadow:
|
|
|
+ 0 0 15px #00ff00,
|
|
|
+ 0 0 25px #98e998,
|
|
|
+ 0 0 35px #8ae88a;
|
|
|
+ background-color: greenyellow !important;
|
|
|
+}
|
|
|
+.activeLight2 {
|
|
|
+ box-shadow:
|
|
|
+ 0 0 15px #f44f54,
|
|
|
+ 0 0 25px #f44f54,
|
|
|
+ 0 0 35px #f44f54;
|
|
|
+ background-color: red !important;
|
|
|
+}
|
|
|
+.lightsBox {
|
|
|
+ position: fixed;
|
|
|
+ top: 10px;
|
|
|
+ right: 300px;
|
|
|
+ width: 300px;
|
|
|
+ height: 60px;
|
|
|
+ margin: 0 auto;
|
|
|
+ display: flex;
|
|
|
+ align-items: center;
|
|
|
+ justify-content: space-evenly;
|
|
|
+ .light {
|
|
|
+ background-color: grey;
|
|
|
+ height: 30px;
|
|
|
+ width: 30px;
|
|
|
+ border-radius: 15px;
|
|
|
+ }
|
|
|
+}
|
|
|
+.type1 {
|
|
|
+ .state {
|
|
|
+ color: green;
|
|
|
+ }
|
|
|
+}
|
|
|
+.type0 {
|
|
|
+ background-color: red !important;
|
|
|
+ .titleText {
|
|
|
+ color: white !important;
|
|
|
+ }
|
|
|
+}
|
|
|
</style>
|