ソースを参照

Merge branch 'cf_dev' of http://192.168.101.4:3000/jiaxiaoqiang/JG-CLIENT-TEMP into cf_dev

qinhb 6 ヶ月 前
コミット
809f66506a

+ 2 - 2
.env.development

@@ -11,9 +11,9 @@ VITE_APP_BASE_API = '/dev-api'
 VITE_APP_UPLOAD_URL = 'http://192.168.101.4:9000'
 
 # 开发接口地址
-VITE_APP_API_URL = 'http://192.168.101.4:7103'
+VITE_APP_API_URL = 'http://192.168.101.4:7203'
 # Websocket地址
-VITE_WEBSOCKET_URL = 'ws://192.168.101.4:7103'
+VITE_WEBSOCKET_URL = 'ws://192.168.101.4:7203'
 ``
 # 是否启用 Mock 服务
 VITE_MOCK_DEV_SERVER = false

+ 1 - 1
.env.production

@@ -9,4 +9,4 @@ VITE_APP_UPLOAD_URL = ''
 
 
 # Websocket地址
-VITE_WEBSOCKET_URL = 'ws://192.168.102.96:7103'
+VITE_WEBSOCKET_URL = 'ws://192.168.101.4:7203'

+ 1 - 1
.gitignore

@@ -3,7 +3,7 @@ docker/dist
 .DS_Store
 docker/dist
 dist-ssr
-dist
+docker/dist
 *.local
 .history
 

+ 1 - 1
public/version.json

@@ -1,3 +1,3 @@
 {
-  "version": "1.9"
+  "version": "2.0"
 }

+ 7 - 0
src/api/excel/index.ts

@@ -0,0 +1,7 @@
+import request from "@/utils/request";
+export function getExcelData() {
+  return request({
+    url: "/api/v1/ProcessFormData/startTest/309",
+    method: "get",
+  });
+}

+ 29 - 1
src/components/ExcelView/index.vue

@@ -24,6 +24,7 @@
             <span class="btn">导入</span>
           </template>-->
         </el-upload>
+        <span class="btn" v-if="option.set" @click="toHardware">开始测试</span>
       </div>
       <div class="info">当前操作表格:{{ inName == "" ? "-" : inName }}</div>
     </div>
@@ -46,6 +47,7 @@
 <script setup>
 import { onMounted, ref, watch } from "vue";
 import { exportExcel } from "./export";
+import { getExcelData } from "@/api/excel";
 import LuckyExcel from "luckyexcel";
 import resData from "./resetData";
 
@@ -61,6 +63,7 @@ const props = defineProps({
     default: () => ({
       //控制上部分展示
       opreaState: true,
+      set: false,
       in: true,
       out: true,
       print: true,
@@ -79,6 +82,14 @@ const props = defineProps({
     default: false,
   },
 });
+
+const toHardware = async () => {
+  const { data, code } = await getExcelData();
+  if (code == "200") {
+    ElMessage.success("硬件调取成功!");
+  }
+};
+
 //update:data : v-model表格data ,confirm : 获取此时表格data
 const emits = defineEmits(["update:data", "confirm"]);
 //新增默认表格data
@@ -238,6 +249,23 @@ const setVerification = () => {
     }
   }
 };
+const setVal = (obj) => {
+  Object.keys(obj).forEach((key) => {
+    let val = obj[key];
+    const { row, col } = getRowCol(key);
+    luckysheet.setCellValue(row, col, val);
+  });
+};
+const getRowCol = (str) => {
+  const [letterPart, numberPart] = str.match(/([A-Z]+)(\d+)/).slice(1);
+  let col = 0;
+  for (let i = 0; i < letterPart.length; i++) {
+    col = col * 26 + (letterPart.charCodeAt(i) - "A".charCodeAt(0));
+  }
+  const row = parseInt(numberPart, 10) - 1;
+  console.log(row, col);
+  return { row, col };
+};
 defineExpose({ confirm, reset, saveCellData, getData });
 onMounted(() => {
   if (props.data == null) {
@@ -259,6 +287,7 @@ watch(
       if (props.checkStatus == true && props.verifications.length > 0) {
         setVerification();
       }
+      window.luckysheet.setVal = setVal;
     });
   },
   { immediate: true }
@@ -282,7 +311,6 @@ watch(
     }
 
     .btn {
-      width: 80px;
       border-radius: 16px;
       height: 40px;
       font-size: 20px;

+ 143 - 18
src/components/RealTimeMsg/index.vue

@@ -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>

+ 2 - 2
src/layout/components/header.vue

@@ -13,8 +13,8 @@
       {{ routeMeta.title }}
     </div>
     <div v-else>
-      <div class="date">{{ date }}</div>
-      <div class="time">{{ time }}</div>
+      <!-- <div class="date">{{ date }}</div>
+      <div class="time">{{ time }}</div> -->
     </div>
     <div>
       <el-space>

+ 3 - 0
src/views/pro-steps/components/excel.vue

@@ -157,6 +157,9 @@ const useExcelHook = () => {
     } else {
       excelData.value = JSON.parse(row.writeData);
     }
+    if (row.formType == "5") {
+      excelOptions.value.set = true;
+    }
     excelOptions.value.inName = row.formName;
     excelViewStatus.value = true;
     setting.value = row.settings;