dengrui 10 hónapja
szülő
commit
19654d457a

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

@@ -15,3 +15,24 @@ export function getAcquisitionData(data: any): Promise<ResData> {
     data,
   });
 }
+export function addAcquisitionData(data: any): Promise<ResData> {
+  return request({
+    url: `/api/v1/process/data/acquisition/add`,
+    method: "post",
+    data,
+  });
+}
+export function updateAcquisitionData(data: any): Promise<ResData> {
+  return request({
+    url: `/api/v1/process/data/acquisition/update`,
+    method: "post",
+    data,
+  });
+}
+export function delAcquisitionData(data: any): Promise<ResData> {
+  return request({
+    url: `/api/v1/process/data/acquisition/del`,
+    method: "post",
+    data,
+  });
+}

+ 263 - 13
src/views/pro-steps/components/screwdriver.vue

@@ -3,7 +3,7 @@
     <el-collapse>
       <el-collapse-item
         v-for="(item, index) in materialsData"
-        :key="index"
+        :key="index + item"
         :name="index"
       >
         <template #title>
@@ -22,7 +22,7 @@
             >新增数据</span
           >
         </template>
-        <el-table :data="tableData[index]" border>
+        <el-table :data="tableData[index]" border :key="tableKey">
           <!-- <el-table-column prop="deviceNo" label="设备编号">
             <template #default="scope" v-if="!item.updateStatus">
               {{ scope.row.deviceNo }}
@@ -48,10 +48,11 @@
             </template>
           </el-table-column> -->
           <el-table-column
-            v-for="str in configeObj()"
+            v-for="str in configeObj(materialsData[index].deviceType)"
             :key="str"
             :prop="str"
             :label="showLable(str)"
+            width="230px"
           >
             <template #default="{ row }">
               <div v-if="!row.updateStatus">
@@ -63,11 +64,11 @@
             </template>
           </el-table-column>
 
-          <el-table-column label="操作">
+          <el-table-column label="操作" min-width="150px" fixed="right">
             <template #default="scope">
               <span
                 class="opear"
-                v-if="scope.row.updateStatus"
+                v-if="scope.row.updateStatus || scope.row.addStatus"
                 @click="toSuccess(index, scope.$index)"
                 >完成</span
               >
@@ -76,11 +77,10 @@
               >
               <span
                 class="opear"
-                v-if="scope.row.updateStatus"
+                v-if="scope.row.updateStatus || scope.row.addStatus"
                 @click="toCancel(index, scope.$index)"
                 >取消</span
-              >
-              <span class="opear" v-else @click="toEdit(index, scope.$index)"
+              ><span class="opear" v-else @click="toEdit(index, scope.$index)"
                 >编辑</span
               >
             </template>
@@ -102,6 +102,9 @@
 import {
   getScrewdriverData,
   getAcquisitionData,
+  addAcquisitionData,
+  updateAcquisitionData,
+  delAcquisitionData,
 } from "@/api/prosteps/screwdriver";
 import { useProcessStore } from "@/store";
 import { useDictionaryStore } from "@/store";
@@ -117,32 +120,243 @@ const showLable = (key) => {
       return "CH6";
     case "DataTimes":
       return "采集时间";
+    case "DDLSD1":
+      return "拧紧的模式";
+    case "DDLSD2":
+      return "拧紧旋转方向";
+    case "DDLSD3":
+      return "目标扭力";
+    case "DDLSD4":
+      return "扭力保持时间";
+    case "DDLSD5":
+      return "浮高界定圈数";
+    case "DDLSD6":
+      return "滑牙界定圈数";
+    case "DDLSD7":
+      return "触发速度切换的扭力比值";
+    case "DDLSD8":
+      return "扭力补偿值";
+    case "DDLSD9":
+      return "开启浮高滑牙检测";
+    case "DDLSD10":
+      return "触发速度切换的扭力";
+    case "DDLSD11":
+      return "触发速度切换的速度比值";
+    case "DDLSD12":
+      return "扭力偏差上限";
+    case "DDLSD13":
+      return "扭力偏差下限";
+    case "DDLSD14":
+      return "扭力免检圈数";
+    case "DDLSD15":
+      return "拧松有效触发的扭力阀值";
+    case "DDLSD16":
+      return "拧松有效触发的保持时间";
+    case "DDLSD17":
+      return "自由旋转方向";
+    case "DDLSD18":
+      return "STEP-00拧紧圈数";
+    case "DDLSD19":
+      return "STEP-00拧紧速度";
+    case "DDLSD20":
+      return "STEP-01拧紧圈数";
+    case "DDLSD21":
+      return "STEP-01拧紧速度";
+    case "DDLSD22":
+      return "STEP-02拧紧圈数";
+    case "DDLSD23":
+      return "STEP-02拧紧速度";
+    case "DDLSD24":
+      return "STEP-03拧紧圈数";
+    case "DDLSD25":
+      return "STEP-03拧紧速度";
+    case "DDLSD26":
+      return "STEP-04拧紧圈数";
+    case "DDLSD27":
+      return "STEP-04拧紧速度";
+    case "DDLSD28":
+      return "STEP-00拧松圈数";
+    case "DDLSD29":
+      return "STEP-00拧松速度";
+    case "DDLSD30":
+      return "STEP-01拧松圈数";
+    case "DDLSD31":
+      return "STEP-01拧松速度";
+    case "DDLSD32":
+      return "STEP-02拧松圈数";
+    case "DDLSD33":
+      return "STEP-02拧松速度";
+    case "DDLSD34":
+      return "STEP-00自由圈数";
+    case "DDLSD35":
+      return "STEP-00自由速度";
     default:
       return key;
   }
 };
+
 const toEdit = (index, rowIndex) => {
   tableData.value[index][rowIndex].updateStatus = true;
 };
-
-const configeObj = () => {
-  return ["CH5Val", "CH6Val", "DataTimes"];
+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,
+  });
+  if (code == "200") {
+    ElMessage.success("操作成功!");
+    setAcquisitionDatas(no, index);
+  }
 };
-const addItem = (name, no, type, index) => {
+const toSuccess = (index, rowIndex) => {
+  if (tableData.value[index][rowIndex].addStatus == true) {
+    addInfo(index, rowIndex);
+  } else {
+    editInfo(index, rowIndex);
+  }
+};
+const addInfo = async (index, rowIndex) => {
+  const { code } = await addAcquisitionData({
+    ...tableData.value[index][rowIndex],
+    data: JSON.stringify(tableData.value[index][rowIndex].data),
+  });
+  if (code == "200") {
+    ElMessage.success("操作成功!");
+    tableData.value[index][rowIndex].addStatus = false;
+    tableData.value[index][rowIndex].updateStatus = false;
+  }
+};
+const editInfo = async (index, rowIndex) => {
+  const { code } = await updateAcquisitionData({
+    ...tableData.value[index][rowIndex],
+    data: JSON.stringify(tableData.value[index][rowIndex].data),
+  });
+  if (code == "200") {
+    ElMessage.success("操作成功!");
+    tableData.value[index][rowIndex].updateStatus = false;
+  }
+};
+const toCancel = (index, rowIndex) => {
+  if (tableData.value[index][rowIndex].addStatus == true) {
+    tableData.value[index].splice(rowIndex, 1);
+  } else {
+    tableData.value[index][rowIndex].updateStatus = false;
+    tableData.value[index][rowIndex].data = JSON.parse(
+      tableData.value[index][rowIndex].resdata
+    );
+  }
+};
+const configeObj = (type) => {
+  switch (type) {
+    //温湿度
+    case "WXDJC":
+      return ["CH5Val", "CH6Val", "DataTimes"];
+    //电动螺丝刀
+    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",
+      ];
+    default:
+      return ["a", "b", "c"];
+  }
+};
+const addItem = (no, name, type, index) => {
   let data = {};
   switch (type) {
     case "WXDJC":
       data = { CH5Val: "", CH6Val: "", DataTimes: "" };
       break;
+    case "DDLSD":
+      data = {
+        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: "",
+      };
+      break;
   }
   tableData.value[index].push({
     deviceNo: no,
     deviceName: name,
     deviceType: type,
     data: data,
+    operationId: store.odersData.operationId,
+    operationName: store.processInfo.operationName,
+    processId: store.scanInfo.id,
+    seqNo: store.scanInfo.seqNo,
+    workOrderCode: store.odersData.workOrderCode,
     index: tableData.value[index].length,
+    addStatus: true,
+    updateStatus: true,
   });
 };
+const tableKey = ref(false);
 const getData = async () => {
   const res = await getScrewdriverData();
   materialsData.value = res.data;
@@ -150,8 +364,15 @@ const getData = async () => {
     pageS.value.push({ ...page });
     getAcquisitionDatas(item.deviceNo, index);
   });
+  change();
+};
+const paginationChange = (index1) => {
+  materialsData.value.forEach((item, index) => {
+    if (index == index1) {
+      setAcquisitionDatas(item.deviceNo, index);
+    }
+  });
 };
-const paginationChange = (index) => {};
 const getAcquisitionDatas = async (No, index) => {
   const res = await getAcquisitionData({
     deviceNo: No,
@@ -162,12 +383,33 @@ const getAcquisitionDatas = async (No, index) => {
   });
   pageS.value[index].total = res.data.totalCount;
   res.data.records.forEach((item, index) => {
+    item.resdata = item.data;
     item.data = JSON.parse(item.data);
     item.updateStatus = false;
     item.index = index;
   });
   tableData.value.push(res.data.records);
 };
+const setAcquisitionDatas = async (No, index) => {
+  const res = await getAcquisitionData({
+    deviceNo: No,
+    operationId: store.odersData.operationId,
+    pageNo: pageS.value[index].pageNo,
+    pageSize: pageS.value[index].pageSize,
+    processId: store.scanInfo.id,
+  });
+  pageS.value[index].total = res.data.totalCount;
+  res.data.records.forEach((item, index) => {
+    item.resdata = item.data;
+    item.data = JSON.parse(item.data);
+    item.updateStatus = false;
+    item.index = index;
+  });
+  console.log(index, res.data.records);
+  tableData.value[index] = res.data.records;
+  console.log(tableData.value);
+  change();
+};
 const pageS = ref([]);
 const page = {
   pageSize: 10,
@@ -177,6 +419,14 @@ const page = {
 onMounted(async () => {
   await getData();
 });
+onActivated(() => {
+  change();
+});
+const change = () => {
+  setTimeout(() => {
+    tableKey.value = !tableKey.value;
+  }, 0);
+};
 </script>
 
 <style lang="scss" scoped>