Kaynağa Gözat

生产履历

dengrui 9 ay önce
ebeveyn
işleme
8ceca78200

+ 14 - 0
src/api/process/traceability.ts

@@ -82,3 +82,17 @@ export function excel(data: any) {
     data,
   });
 }
+export function collectData(data: any) {
+  return request({
+    url: "/api/v1/process/web/traceability/collect/page",
+    method: "post",
+    data,
+  });
+}
+export function tableDatas(data: any) {
+  return request({
+    url: "/api/v1/process/web/traceability/collectData/page",
+    method: "post",
+    data,
+  });
+}

+ 290 - 0
src/views/traceability/components/collect.vue

@@ -0,0 +1,290 @@
+<template>
+  <div class="collapseStyle" :height="tableHeight + 100">
+    <el-scrollbar
+      v-loading="loading"
+      style="border: 1px solid #ebeef5"
+      :height="tableHeight"
+    >
+      <el-collapse accordion v-model="activeNames">
+        <el-collapse-item
+          v-for="(item, index) in materialsData"
+          :key="item"
+          :title="item.operationName"
+          :name="index"
+        >
+          <el-collapse accordion>
+            <el-collapse-item
+              v-for="(device, deviceIndex) in item.children"
+              :key="deviceIndex"
+              :title="device.deviceName"
+              :name="device"
+              @click="getTableData(index, deviceIndex, device)"
+            >
+              <el-table :data="tableData[index][deviceIndex]" border>
+                <el-table-column
+                  v-for="str in configeObj(device.deviceType)"
+                  :key="str"
+                  :prop="str"
+                  :label="showLable(str)"
+                  width="230px"
+                >
+                  <template #default="{ row }">
+                    <div>
+                      {{ row.data[str] }}
+                    </div>
+                  </template>
+                </el-table-column>
+                <el-table-column
+                  prop="created"
+                  label="采集时间"
+                  width="230px"
+                />
+              </el-table>
+              <Pagination
+                v-model:limit="pageS[index][deviceIndex].pageSize"
+                v-model:page="pageS[index][deviceIndex].pageNo"
+                :total="pageS[index][deviceIndex].total"
+                @pagination="paginationChange(index, deviceIndex, device)"
+                position="right"
+              />
+            </el-collapse-item>
+          </el-collapse>
+        </el-collapse-item>
+      </el-collapse>
+      <Empty v-if="materialsData.length < 1" />
+    </el-scrollbar>
+    <Pagination
+      position="right"
+      :page="page"
+      :limit="limit"
+      :total="total"
+      @pagination="getPagination"
+    />
+  </div>
+</template>
+
+<script setup>
+import { useProcessStore } from "@/store";
+import { collectData, tableDatas } from "@/api/process/traceability";
+import { useDictionaryStore } from "@/store";
+const dictS = useDictionaryStore();
+const store = useProcessStore();
+const activeNames = ref([0]);
+const page = ref(1);
+const limit = ref(10);
+const total = ref(10);
+const materialsData = ref([]);
+const tableHeight = ref(null);
+const loading = ref(false);
+const tableData = ref([]);
+const pageS = ref([]);
+const configeObj = (type) => {
+  console.log(type, "222");
+  switch (type) {
+    //温湿度
+    case "WXDJC":
+      return ["CH5Val", "CH6Val", "DataTimes"];
+    case "YBKC":
+      return ["length"];
+    case "GDC":
+      return ["height"];
+    //电动螺丝刀
+    case "DDLSD":
+      return [
+        "taskNo",
+        "torquetarget",
+        "tightenTorqueMax",
+        "warning",
+        "tightenResult",
+        "totalCycles",
+      ];
+    default:
+      return ["数据1", "数据2", "数据3"];
+  }
+};
+const showLable = (key) => {
+  switch (key) {
+    case "CH5Val":
+      return "CH5";
+    case "CH6Val":
+      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":
+      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 pages = {
+  pageSize: 10,
+  pageNo: 1,
+  total: 0,
+};
+const getPagination = async () => {
+  loading.value = true;
+  try {
+    const { data } = await collectData({
+      pageNo: page.value,
+      pageSize: limit.value,
+      seqNo: store.useSeqNo,
+      workOrderCode: store.odersData.workOrderCode,
+    });
+    materialsData.value = data.records;
+    tableData.value = [];
+    pageS.value = [];
+    materialsData.value.forEach((item, index) => {
+      tableData.value.push([]);
+      pageS.value.push([]);
+      item.children.forEach((device, deviceIndex) => {
+        tableData.value[index].push([]);
+        pageS.value[index].push(pages);
+      });
+    });
+  } catch {
+  } finally {
+    loading.value = false;
+  }
+};
+//组件点击切换触发
+const paginationChange = async (index1, index2, device) => {
+  const { data } = await tableDatas({
+    pageNo: pageS.value[index1][index2].pageNo,
+    pageSize: pageS.value[index1][index2].pageSize,
+    deviceNo: device.deviceNo,
+    operationId: device.operationId,
+    seqNo: store.useSeqNo,
+    workOrderCode: store.odersData.workOrderCode,
+  });
+  data.records.forEach((item) => {
+    item.data = JSON.parse(item.data);
+  });
+  tableData.value[index1][index2] = data.records;
+  pageS.value[index1][index2].total = data.totalCount;
+  pageS.value[index1][index2].get = true;
+};
+
+const getTableData = async (index1, index2, device) => {
+  if (tableData.value[index1][index2].length < 1) {
+    const { data } = await tableDatas({
+      pageNo: pageS.value[index1][index2].pageNo,
+      pageSize: pageS.value[index1][index2].pageSize,
+      deviceNo: device.deviceNo,
+      operationId: device.operationId,
+      seqNo: store.useSeqNo,
+      workOrderCode: store.odersData.workOrderCode,
+    });
+    data.records.forEach((item) => {
+      item.data = JSON.parse(item.data);
+    });
+    tableData.value[index1][index2] = data.records;
+    pageS.value[index1][index2].total = data.totalCount;
+  }
+};
+//动态控制高度
+const setTableHeight = () => {
+  tableHeight.value =
+    Number(document.getElementById("tabBox").offsetHeight) - 110;
+};
+onMounted(async () => {
+  await getPagination();
+  setTableHeight();
+  window.addEventListener("resize", setTableHeight);
+});
+onUnmounted(() => {
+  window.removeEventListener("resize", setTableHeight);
+});
+</script>
+
+<style lang="scss" scoped>
+:deep(.el-dialog) {
+  margin: auto auto !important;
+}
+:deep(.el-overlay-dialog) {
+  display: flex;
+}
+</style>

+ 15 - 0
src/views/traceability/index.vue

@@ -230,6 +230,20 @@
               </template>
             </keep-alive>
           </el-tab-pane>
+          <el-tab-pane name="f9">
+            <template #label>
+              <el-badge
+                :type="activeName == 'f9' ? 'warning' : 'danger'"
+                :value="tabCountData.collect"
+                >数据采集
+              </el-badge>
+            </template>
+            <keep-alive>
+              <template v-if="activeName == 'f9'">
+                <Collect />
+              </template>
+            </keep-alive>
+          </el-tab-pane>
         </el-tabs>
       </div>
     </div>
@@ -250,6 +264,7 @@ const Equit = defineAsyncComponent(() => import("./components/equit.vue"));
 const Fault = defineAsyncComponent(() => import("./components/fault.vue"));
 const Media = defineAsyncComponent(() => import("./components/media.vue"));
 const Excel = defineAsyncComponent(() => import("./components/excel.vue"));
+const Collect = defineAsyncComponent(() => import("./components/collect.vue"));
 const store = useProcessStore();
 const activeName = ref("f1");
 const handleClick = () => {};