Переглянути джерело

QRCode组件对比接口处理

lph 1 рік тому
батько
коміт
9f9eb39762
1 змінених файлів з 46 додано та 11 видалено
  1. 46 11
      zkqy-ui/src/views/bussiness/dialogCompments/Mec/QRCode.vue

+ 46 - 11
zkqy-ui/src/views/bussiness/dialogCompments/Mec/QRCode.vue

@@ -21,8 +21,8 @@
           :class="{
             QRItem: true,
             active: index === selectIndex,
-            right: index === selectIndex && status == 1,
-            error: index === selectIndex && status == 2,
+            right: i.status == 1,
+            error: i.status == 2,
           }"
           @click="itemClickHandler(index)"
           v-for="(i, index) in QRList"
@@ -33,7 +33,7 @@
           <div class="description">
             <span class="title">{{ i.part_name }}</span>
             <div class="content">
-              {{ i.part_no }}
+              {{ i.description }}
             </div>
           </div>
         </div>
@@ -69,6 +69,7 @@ export default {
       QRList: [],
       selectIndex: "",
       status: 0, //对比结果 0:未对比 1:对比成功 2:对比失败
+      resultMap: {}, //保存比较结果
     };
   },
   computed: {
@@ -94,16 +95,41 @@ export default {
   },
   mounted() {},
   methods: {
-    sameHandler() {
+    async sameHandler() {
       if (!this.QRList[this.selectIndex]) {
         this.$message.error("请先选择一个二维码");
         return;
       }
-      this.status =
-        this.QRList[this.selectIndex].description ==
-        this.remark.replace(/\\/g, "")
-          ? 1
-          : 2;
+      let target = this.QRList[this.selectIndex];
+      let comparisonResult =
+        target.description == this.remark.replace(/\\/g, "") ? 1 : 2;
+      target.status = comparisonResult;
+      let payload = {};
+      payload.insertCommonEntityList = [
+        {
+          basicMap: {
+            tableName: "anti_error_material_log",
+          },
+          addListMap: [
+            {
+              materialId: target.id,
+              materialInfo: target.description,
+              realMaterialInfo: this.remark,
+              comparisonResult: comparisonResult == 1 ? "true" : "false",
+            },
+          ],
+        },
+      ];
+      try {
+        let res = await submitNodeForm(payload);
+        if (res.code === 200) {
+          this.$message.success("对比成功");
+        } else {
+          this.$message.error("网络异常,请稍后对比");
+        }
+      } catch (error) {
+        console.log(error);
+      }
     },
     // 二维码选中回调
     itemClickHandler(index) {
@@ -118,13 +144,16 @@ export default {
     getQRList(data) {
       if (data?.length) {
         this.QRList = data.map((item) => {
-          let { imageUrl, part_name, part_no, description } = item.resultMap;
+          let { id, imageUrl, part_name, part_no, description } =
+            item.resultMap;
           let { partNo, partName } = JSON.parse(description);
           return {
             imageUrl,
             part_name: partName,
             part_no: partNo,
             description,
+            id,
+            status: 0, //对比结果  0:未对比  1:对比成功  2:对比失败
           };
         });
       }
@@ -193,8 +222,14 @@ export default {
         flag: false,
         msg: "",
       };
+      if (!this.$refs.form) {
+        return {
+          flag: true,
+          data: {},
+        };
+      }
       try {
-        let valid = await this.$refs.form.validate();
+        let valid = await this.$refs.form?.validate();
         if (valid) {
           formData.flag = true;
           formData.data = this.form;