dengrui hace 8 meses
padre
commit
32d09feeee

+ 15 - 0
src/api/prosteps/screwdriver.ts

@@ -36,3 +36,18 @@ export function delAcquisitionData(data: any): Promise<ResData> {
     data,
   });
 }
+//获取电动螺丝刀列表
+export function getTaskList(data: any): Promise<ResData> {
+  return request({
+    url: `/api/v1/screwdriverTask/list`,
+    method: "post",
+    data,
+  });
+}
+export function startData(data: any): Promise<ResData> {
+  return request({
+    url: `/api/v1/process/data/acquisition/start`,
+    method: "post",
+    data,
+  });
+}

+ 16 - 1
src/components/RealTimeMsg/index.vue

@@ -115,7 +115,22 @@ const addWebSocket = () => {
         }
         break;
       case "8":
-        emitter.emit(EventsNames.GET_Screwdriver);
+        emitter.emit(
+          EventsNames.GETDATA_DDLSD,
+          JSON.parse(receivedMessage).content
+        );
+        break;
+      case "12":
+        emitter.emit(
+          EventsNames.GETDATA_YBKC,
+          JSON.parse(receivedMessage).content
+        );
+        break;
+      case "13":
+        emitter.emit(
+          EventsNames.GETDATA_GDC,
+          JSON.parse(receivedMessage).content
+        );
         break;
     }
   };

+ 0 - 1
src/router/modules/prepare.ts

@@ -18,7 +18,6 @@ export default {
   ],
   beforeEnter: (to, from, next) => {
     const store = useUserStore();
-    console.log(store.user.stationType);
     if (store.user.stationType == "5") {
       next();
     } else {

+ 6 - 1
src/utils/common.ts

@@ -9,7 +9,12 @@ enum EventsNames {
   PROCESS_STEPINDEX = "PROCESS_STEPINDEX",
   //通知procee界面重新加载数据
   PROCESS_REDER = "PROCESS_REDER",
-  GET_Screwdriver = "GET_Screwdriver",
+  //电动螺丝刀表格数据刷新
+  GETDATA_DDLSD = "GETDATA_DDLSD",
+  //游标卡尺
+  GETDATA_YBKC = "GETDATA_YBKC",
+  //高度尺
+  GETDATA_GDC = "GETDATA_GDC",
 }
 
 export { emitter, EventsNames };

+ 153 - 75
src/views/pro-steps/components/screwdriver.vue

@@ -5,6 +5,8 @@
         v-for="(item, index) in materialsData"
         :key="index + item"
         :name="index"
+        :disabled="item.deviceType == 'FJDJC'"
+        style="position: relative"
       >
         <template #title>
           {{
@@ -17,36 +19,53 @@
             @click.stop="
               addItem(item.deviceNo, item.deviceName, item.deviceType, index)
             "
+            v-if="item.deviceType != 'FJDJC'"
             class="opear"
             style="font-size: 18px; color: rgb(10, 89, 247); font-weight: 600"
             >新增数据</span
           >
+          <el-select
+            v-model="taskValue"
+            v-if="item.deviceType == 'DDLSD'"
+            placeholder="请选择任务"
+            size="large"
+            style="position: absolute; right: 200px; z-index: 2; width: 140px"
+          >
+            <el-option
+              v-for="item in options"
+              :key="item.value"
+              :label="item.label"
+              :value="item.value"
+            />
+          </el-select>
+          <el-button
+            class="ces"
+            type="primary"
+            style="position: absolute; right: 60px; z-index: 2"
+            v-if="item.deviceType != 'FJDJC'"
+            @click.stop="
+              startTest(item.deviceName, item.deviceNo, item.deviceType)
+            "
+            :disabled="item.deviceType == 'DDLSD' && !taskValue"
+            >开始检测</el-button
+          >
         </template>
-        <el-table :data="tableData[index]" border :key="tableKey">
-          <!-- <el-table-column prop="deviceNo" label="设备编号">
-            <template #default="scope" v-if="!item.updateStatus">
-              {{ scope.row.deviceNo }}
-            </template>
-            <template #default v-else>
-              <el-input v-model="tableData[index].deviceNo" />
-            </template>
-          </el-table-column>
-          <el-table-column prop="deviceName" label="设备名称">
-            <template #default="scope" v-if="!item.updateStatus">
-              {{ scope.row.deviceName }}
-            </template>
-            <template #default v-else>
-              <el-input v-model="tableData[index].deviceName" />
-            </template>
-          </el-table-column>
-          <el-table-column prop="created" label="采集时间">
-            <template #default="scope" v-if="!item.updateStatus">
-              {{ scope.row.created }}
-            </template>
-            <template #default v-else>
-              <el-input v-model="tableData[index].created" />
-            </template>
-          </el-table-column> -->
+        <!-- <el-table
+          :data="DDLSDTableData"
+          v-if="item.deviceType == 'DDLSD'"
+          border
+        >
+          <el-table-column prop="deviceNo" label="任务号" />
+          <el-table-column prop="deviceNo" label="圈数(r)" />
+          <el-table-column prop="deviceNo" label="扭力(mN.m)" />
+          <el-table-column prop="deviceNo" label="拧紧结果" />
+          <el-table-column prop="deviceNo" label="警报" />
+        </el-table> -->
+        <el-table
+          :data="tableData[index]"
+          v-if="item.deviceType != 'FJDJC'"
+          border
+        >
           <el-table-column
             v-for="str in configeObj(materialsData[index].deviceType)"
             :key="str"
@@ -63,7 +82,16 @@
               </div>
             </template>
           </el-table-column>
-
+          <el-table-column prop="created" label="采集时间" width="230px">
+            <template #default="{ row }">
+              <div v-if="!row.updateStatus">
+                {{ row.created }}
+              </div>
+              <div v-else>
+                <el-input v-model="tableData[index][row.index].created" />
+              </div>
+            </template>
+          </el-table-column>
           <el-table-column label="操作" min-width="150px" fixed="right">
             <template #default="scope">
               <span
@@ -87,6 +115,7 @@
           </el-table-column>
         </el-table>
         <Pagination
+          v-if="item.deviceType != 'FJDJC'"
           v-model:limit="pageS[index].pageSize"
           v-model:page="pageS[index].pageNo"
           :total="pageS[index].total"
@@ -105,13 +134,51 @@ import {
   addAcquisitionData,
   updateAcquisitionData,
   delAcquisitionData,
+  getTaskList,
+  startData,
 } from "@/api/prosteps/screwdriver";
 import { useProcessStore } from "@/store";
 import { useDictionaryStore } from "@/store";
+import { emitter, EventsNames } from "@/utils/common";
+import dayjs from "dayjs";
 const dictS = useDictionaryStore();
 const store = useProcessStore();
 const tableData = ref([]);
 const materialsData = ref([]);
+const router = useRouter();
+const taskValue = ref("");
+const toStartData = async (data) => {
+  const { code } = await startData(data);
+  if (code == "200") {
+    ElMessage.success("开始检测成功");
+  }
+};
+const getTask = async () => {
+  const { data } = await getTaskList({});
+  options.value = [];
+  data.forEach((item) => {
+    options.value.push({
+      value: item.id,
+      label: item.taskName,
+    });
+  });
+};
+const options = ref([]);
+
+const startTest = (a, b, c) => {
+  let obj = {
+    deviceName: a,
+    deviceNo: b,
+    deviceType: c,
+    operationId: store.scanInfo.operationId,
+    operationName: store.processInfo.operationName,
+    processId: store.scanInfo.id,
+    seqNo: store.useSeqNo,
+    workOrderCode: store.odersData.workOrderCode,
+    taskId: taskValue.value,
+  };
+  toStartData(obj);
+};
 const showLable = (key) => {
   switch (key) {
     case "CH5Val":
@@ -120,6 +187,22 @@ const showLable = (key) => {
       return "CH6";
     case "DataTimes":
       return "采集时间";
+    case "torquetarget":
+      return "当前任务目标扭力";
+    case "tightenTorqueMax":
+      return "拧紧过程中最大扭力值";
+    case "taskNo":
+      return "当前任务号";
+    case "warning":
+      return "警报";
+    case "tightenResult":
+      return "最终拧紧结果";
+    case "totalCycles":
+      return "总圈数";
+    case "length":
+      return "长度";
+    case "height":
+      return "高度";
     case "DDLSD1":
       return "拧紧的模式";
     case "DDLSD2":
@@ -199,7 +282,6 @@ const toEdit = (index, rowIndex) => {
   tableData.value[index][rowIndex].updateStatus = true;
 };
 const toDelete = async (index, rowIndex) => {
-  console.log(index, rowIndex);
   const no = tableData.value[index][rowIndex].deviceNo;
   const { code } = await delAcquisitionData({
     id: tableData.value[index][rowIndex].id,
@@ -252,47 +334,22 @@ const configeObj = (type) => {
     //温湿度
     case "WXDJC":
       return ["CH5Val", "CH6Val", "DataTimes"];
+    case "YBKC":
+      return ["length"];
+    case "GDC":
+      return ["height"];
     //电动螺丝刀
     case "DDLSD":
       return [
-        "DDLSD1",
-        "DDLSD2",
-        "DDLSD3",
-        "DDLSD4",
-        "DDLSD5",
-        "DDLSD6",
-        "DDLSD7",
-        "DDLSD8",
-        "DDLSD9",
-        "DDLSD10",
-        "DDLSD11",
-        "DDLSD12",
-        "DDLSD13",
-        "DDLSD14",
-        "DDLSD15",
-        "DDLSD16",
-        "DDLSD17",
-        "DDLSD18",
-        "DDLSD19",
-        "DDLSD20",
-        "DDLSD21",
-        "DDLSD22",
-        "DDLSD23",
-        "DDLSD24",
-        "DDLSD25",
-        "DDLSD26",
-        "DDLSD27",
-        "DDLSD28",
-        "DDLSD29",
-        "DDLSD30",
-        "DDLSD31",
-        "DDLSD32",
-        "DDLSD33",
-        "DDLSD34",
-        "DDLSD35",
+        "taskNo",
+        "torquetarget",
+        "tightenTorqueMax",
+        "warning",
+        "tightenResult",
+        "totalCycles",
       ];
     default:
-      return ["a", "b", "c"];
+      return ["数据1", "数据2", "数据3"];
   }
 };
 const addItem = (no, name, type, index) => {
@@ -301,6 +358,12 @@ const addItem = (no, name, type, index) => {
     case "WXDJC":
       data = { CH5Val: "", CH6Val: "", DataTimes: "" };
       break;
+    case "YBCK":
+      data = { CH5Val: "", CH6Val: "", DataTimes: "" };
+      break;
+    case "GDC":
+      data = { CH5Val: "", CH6Val: "", DataTimes: "" };
+      break;
     case "DDLSD":
       data = {
         DDLSD1: "",
@@ -364,7 +427,6 @@ const getData = async () => {
     pageS.value.push({ ...page });
     getAcquisitionDatas(item.deviceNo, index);
   });
-  change();
 };
 const paginationChange = (index1) => {
   materialsData.value.forEach((item, index) => {
@@ -388,7 +450,7 @@ const getAcquisitionDatas = async (No, index) => {
     item.updateStatus = false;
     item.index = index;
   });
-  tableData.value.push(res.data.records);
+  tableData.value[index] = res.data.records;
 };
 const setAcquisitionDatas = async (No, index) => {
   const res = await getAcquisitionData({
@@ -405,11 +467,9 @@ const setAcquisitionDatas = async (No, index) => {
     item.updateStatus = false;
     item.index = index;
   });
-  console.log(index, res.data.records);
   tableData.value[index] = res.data.records;
-  console.log(tableData.value);
-  change();
 };
+const DDLSDTableData = ref([]);
 const pageS = ref([]);
 const page = {
   pageSize: 10,
@@ -418,18 +478,36 @@ const page = {
 };
 onMounted(async () => {
   await getData();
+  getTask();
 });
-onActivated(() => {
-  change();
+emitter.on(EventsNames.GETDATA_DDLSD, (name) => {
+  materialsData.value.forEach((item, index) => {
+    if (item.deviceType == "DDLSD" && item.deviceNo == name) {
+      setAcquisitionDatas(item.deviceNo, index);
+    }
+  });
+});
+emitter.on(EventsNames.GETDATA_YBKC, (name) => {
+  materialsData.value.forEach((item, index) => {
+    if (item.deviceType == "YBKC" && item.deviceNo == name) {
+      setAcquisitionDatas(item.deviceNo, index);
+    }
+  });
+});
+emitter.on(EventsNames.GETDATA_GDC, (name) => {
+  materialsData.value.forEach((item, index) => {
+    if (item.deviceType == "GDC" && item.deviceNo == name) {
+      setAcquisitionDatas(item.deviceNo, index);
+    }
+  });
 });
-const change = () => {
-  setTimeout(() => {
-    tableKey.value = !tableKey.value;
-  }, 0);
-};
 </script>
 
 <style lang="scss" scoped>
+.ces {
+  font-size: 18px;
+  height: 40px;
+}
 .containerBox {
   background-color: white;
   padding: 20px;