ソースを参照

测试数据模块

jiaxiaoqiang 6 ヶ月 前
コミット
20d2a2791b

+ 1 - 1
package.json

@@ -73,7 +73,7 @@
     "uuid": "^9.0.1",
     "vue": "^3.4.21",
     "vue-i18n": "9.9.1",
-    "vue-pdf-embed": "^2.0.2",
+    "vue-pdf-embed": "2.0.2",
     "vue-router": "^4.3.0",
     "vue3-pdfjs": "^0.1.6",
     "vue3-print-nb": "^0.1.4",

+ 34 - 0
src/api/prosteps/ceshishuju.ts

@@ -0,0 +1,34 @@
+import request from "@/utils/request";
+
+//获取当前列表
+export function dataArrayList(processId: string) {
+  return request({
+    url: `/api/v1/testData/get/${processId}`,
+    method: "get",
+  });
+}
+
+export function startCSSJTesting(processId: string) {
+  return request({
+    url: `/api/v1/testData/startTest/${processId}`,
+    method: "get",
+  });
+}
+
+export function deleteCSSJ(id: string) {
+  return request({
+    url: `/api/v1/testData/del`,
+    method: "post",
+    data: {
+      id: id,
+    },
+  });
+}
+
+export function addCSSJ(data: any) {
+  return request({
+    url: `/api/v1/testData/save`,
+    method: "post",
+    data: data,
+  });
+}

ファイルの差分が大きいため隠しています
+ 7 - 0
src/assets/icons/ceshishuju.svg


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

@@ -64,6 +64,7 @@
 <script setup>
 import { useDictionaryStore } from "@/store";
 import { readMessage } from "@/api/user";
+import { emitter, EventsNames } from "@/utils/common.ts";
 const dictS = useDictionaryStore();
 const porps = defineProps({
   modelValue: {
@@ -115,7 +116,11 @@ const addWebSocket = () => {
         break;
       //回填表格数据
       case "2":
-        window.luckysheet.setVal(
+        // window.luckysheet.setVal(
+        //   JSON.parse(JSON.parse(receivedMessage).content)
+        // );
+        emitter.emit(
+          EventsNames.TEST_DATA,
           JSON.parse(JSON.parse(receivedMessage).content)
         );
         break;

+ 10 - 0
src/router/modules/process.ts

@@ -112,6 +112,16 @@ export default {
             keepAlive: true,
           },
         },
+        {
+          path: "ceshishuju",
+          component: () =>
+            import("@/views/pro-steps/components/ceshishuju.vue"),
+          name: "Ceshishuju",
+          meta: {
+            back: true,
+            keepAlive: true,
+          },
+        },
       ],
     },
     {

+ 2 - 0
src/utils/common.ts

@@ -9,6 +9,8 @@ enum EventsNames {
   PROCESS_STEPINDEX = "PROCESS_STEPINDEX",
   //通知procee界面重新加载数据
   PROCESS_REDER = "PROCESS_REDER",
+  //   测试数据开始测试之后的事件
+  TEST_DATA = "TEST_DATA",
 }
 
 export { emitter, EventsNames };

+ 193 - 0
src/views/pro-steps/components/ceshishuju.vue

@@ -0,0 +1,193 @@
+<template>
+  <div>
+    <div class="csTitle-header">
+      <el-button type="primary" @click="startTesting">开始测试</el-button>
+      <span>产品编码: {{ csObj?.materialName }}</span>
+      <span>产品名称: {{ csObj?.materialCode }}</span>
+      <span>测试人员: {{ csObj?.creator }}</span>
+      <span>测试时间: {{ csObj?.created }}</span>
+    </div>
+
+    <el-table :data="tableData" class="tableView-cssj">
+      <el-table-column fixed prop="proName" label="测试项目" align="center" />
+      <el-table-column fixed prop="name" label="测试名称" align="center" />
+      <el-table-column fixed prop="value" label="测试值" align="center" />
+      <el-table-column prop="flag" align="center" label="是否合格">
+        <template #default="scope">
+          <span
+            :class="{
+              'red-text': scope.row.flag == 0,
+              'green-text': scope.row.writeData == 1,
+            }"
+          >
+            {{ scope.row.flag == 1 ? "合格" : "不合格" }}
+          </span>
+        </template>
+      </el-table-column>
+
+      <!--      <el-table-column label="操作" fixed="right" width="200">-->
+      <!--        <template #default="scope">-->
+      <!--                    <el-button-->
+      <!--                      link-->
+      <!--                      class="btnText"-->
+      <!--                      type="primary"-->
+      <!--                      @click="handleEdit(scope.row)"-->
+      <!--                    >-->
+      <!--                      编辑-->
+      <!--                    </el-button>-->
+
+      <!--                    <el-popconfirm-->
+      <!--                      :visible="scope.row.dialogVisible"-->
+      <!--                      title="您确认删除吗?(此操作不可逆)"-->
+      <!--                      width="300"-->
+      <!--                      @cancel="scope.row.dialogVisible = false"-->
+      <!--                      @confirm="handleDelete(scope.row)"-->
+      <!--                    >-->
+      <!--                      <el-button> 取消 </el-button>-->
+      <!--                      <el-button type="primary"> 确认 </el-button>-->
+      <!--                      <template #reference>-->
+      <!--                        <el-button-->
+      <!--                          link-->
+      <!--                          class="btnText"-->
+      <!--                          type="primary"-->
+      <!--                          @click="scope.row.dialogVisible = true"-->
+      <!--                          >删除</el-button-->
+      <!--                        >-->
+      <!--                      </template>-->
+      <!--                    </el-popconfirm>-->
+      <!--        </template>-->
+      <!--      </el-table-column>-->
+    </el-table>
+
+    <el-dialog title="编辑测试项" v-model="dialogVisible">
+      <el-form ref="form" :model="editRow" label-width="100px">
+        <el-form-item label="测试项目">
+          <el-input v-model="editRow.proName" />
+        </el-form-item>
+        <el-form-item label="测试名称">
+          <el-input v-model="editRow.name" />
+        </el-form-item>
+        <el-form-item label="测试值">
+          <el-input v-model="editRow.value" />
+        </el-form-item>
+        <el-form-item label="是否合格">
+          <el-radio v-model="editRow.flag" :label="1">合格</el-radio>
+          <el-radio v-model="editRow.flag" :label="0">不合格</el-radio>
+        </el-form-item>
+      </el-form>
+      <template #footer>
+        <el-button @click="handleDialogCancel">取 消</el-button>
+        <el-button type="primary" @click="handleDialogConfirm">确 定</el-button>
+      </template>
+    </el-dialog>
+  </div>
+</template>
+
+<script setup lang="ts">
+import {
+  addCSSJ,
+  dataArrayList,
+  deleteCSSJ,
+  startCSSJTesting,
+} from "@/api/prosteps/ceshishuju";
+import { useProcessStore } from "@/store";
+import { emitter, EventsNames } from "@/utils/common";
+
+const store = useProcessStore();
+
+const csObj = ref<any>(null);
+
+const tableData = ref<any[]>([]);
+
+const getList = () => {
+  dataArrayList(store.scanInfo.id).then((res: any) => {
+    csObj.value = res.data;
+    tableData.value = JSON.parse(res.data.testData);
+    console.log(tableData.value, "返回的列表数据");
+  });
+};
+
+onMounted(() => {
+  getList();
+});
+
+const startTesting = () => {
+  startCSSJTesting(store.scanInfo.id).then(() => {
+    if (!emitter.all.has(EventsNames.TEST_DATA)) {
+      emitter.on(EventsNames.TEST_DATA, (mesaage: any) => {
+        console.log("测试数据获取成功");
+        getList();
+      });
+    }
+  });
+};
+
+onUnmounted(() => {
+  if (emitter.all.has(EventsNames.TEST_DATA)) {
+    emitter.off(EventsNames.TEST_DATA);
+    emitter.all.delete(EventsNames.TEST_DATA);
+  }
+});
+
+const handleDelete = (row: any) => {
+  deleteCSSJ(csObj.value.id).then(() => {
+    getList();
+  });
+};
+
+// 编辑相关代码
+const dialogVisible = ref(false);
+const editRow = ref<any>(null);
+const handleEdit = (row: any) => {
+  editRow.value = row;
+  dialogVisible.value = true;
+};
+const handleDialogConfirm = () => {
+  dialogVisible.value = false;
+
+  let p = {
+    materialCode: csObj.value.materialCode,
+    materialName: csObj.value.materialName,
+    processId: store.scanInfo.id,
+    testData: [JSON.stringify(editRow.value)],
+    workOrderId: csObj.value.workOrderId,
+  };
+  addCSSJ(p).then(() => {
+    getList();
+  });
+};
+const handleDialogCancel = () => {
+  dialogVisible.value = false;
+};
+</script>
+
+<style scoped lang="scss">
+.csTitle-header {
+  display: flex;
+  justify-content: space-between;
+
+  font-size: 18px;
+  font-weight: bold;
+}
+
+.tableView-cssj {
+  width: 100%;
+  height: calc(100vh - 300px);
+  padding: 20px 0px;
+  border-radius: 16px;
+  margin-top: 10px;
+}
+.btn {
+  width: 180px;
+  border-radius: 16px;
+  height: 40px;
+  font-size: 16px;
+  margin: 10px 0;
+}
+.red-text {
+  color: red;
+}
+.green-text {
+  color: green;
+}
+</style>

+ 6 - 0
src/views/pro-steps/index.vue

@@ -153,6 +153,12 @@ const defaultComponents = [
     path: "execl",
     name: "Excel",
   },
+  {
+    compentName: "测试数据",
+    iconName: "ceshishuju",
+    path: "ceshishuju",
+    name: "Ceshishuju",
+  },
 ];
 //当前路由在setpComponents中的index
 const selectIndex = ref(0);