Selaa lähdekoodia

质检自定义组件的接口处理

lph 1 vuosi sitten
vanhempi
säilyke
808e68e296
1 muutettua tiedostoa jossa 144 lisäystä ja 2 poistoa
  1. 144 2
      zkqy-ui/src/views/bussiness/dialogCompments/GongYi/Inspect.vue

+ 144 - 2
zkqy-ui/src/views/bussiness/dialogCompments/GongYi/Inspect.vue

@@ -2,7 +2,8 @@
   <div class="form-wrap">
     <div class="cardwrap">
       <el-table :data="tableData" border>
-        <el-table-column prop="name" label="产品名称"> </el-table-column>
+        <el-table-column align="center" prop="productName" label="产品名称">
+        </el-table-column>
         <el-table-column label="物理指标" align="center">
           <el-table-column prop="intensity" label="强度" align="center">
             <template slot-scope="scope">
@@ -91,6 +92,16 @@
           clearable
         ></el-input>
       </div>
+      <div class="btn">
+        <el-button
+          class="mt10"
+          style="width: 100px; float: right"
+          type="primary"
+          size="default"
+          @click="record"
+          >{{ isEdit ? "确认修改" : "记录" }}</el-button
+        >
+      </div>
     </div>
   </div>
 </template>
@@ -98,6 +109,13 @@
 <script>
 import getNodeSequence from "@/utils/bpmn/getNodeSequence";
 import { xmlStr2XmlObj } from "@/utils/bpmn/xml";
+import { mapState } from "vuex";
+import { v4 as uuidv4 } from "uuid";
+import {
+  addQualityInspectionCertificate,
+  editQualityInspectionCertificate,
+} from "@/api/bussiness/bpmExcuteProcess";
+import moment from "moment";
 export default {
   name: "NodeShow",
   props: ["formData", "row"],
@@ -105,8 +123,13 @@ export default {
   data() {
     return {
       remark: "",
+      rowData: {},
+      isEdit: false,
+      inspectionListNo: "",
       tableData: [
         {
+          productName: "",
+          productNo: "",
           // 物理指标
           intensity: "", //强度
           elongation: "", //伸长率
@@ -132,6 +155,83 @@ export default {
       deep: true,
       handler(val) {
         console.log(val);
+        this.tableData = [];
+        this.isEdit = val.resultMap.inspectionList?.inspectionListNo
+          ? true
+          : false;
+        let list = val.resultMap?.productsList;
+        if (this.isEdit) {
+          //第二次修改
+          this.remark = val.resultMap.inspectionList.remark;
+          this.inspectionListNo = val.resultMap.inspectionList.inspectionListNo;
+          let listData = val.resultMap?.inspectionListInfoList;
+          this.tableData = listData.map((item) => {
+            let {
+              productName,
+              productNo,
+              intensity,
+              elongation,
+              titer,
+              oilContent,
+              crimpRate,
+              boilingWaterShrinkage,
+              fuzz,
+              coilWire,
+              arachnoidSilk,
+              takeShapeBadness,
+              oilFree,
+              chromaticAberrationWire,
+              filaments,
+            } = item;
+            return {
+              productName,
+              productNo,
+              intensity,
+              elongation,
+              titer,
+              oilContent,
+              crimpRate,
+              boilingWaterShrinkage,
+              fuzz,
+              coilWire,
+              arachnoidSilk,
+              takeShapeBadness,
+              oilFree,
+              chromaticAberrationWire,
+              filaments,
+            };
+          });
+        } else {
+          //第一次检验
+          this.tableData = list.map((item) => {
+            return {
+              productName: item.resultMap.productName,
+              productNo: item.resultMap.productNo,
+              // 物理指标
+              intensity: "", //强度
+              elongation: "", //伸长率
+              titer: "", //纤度
+              oilContent: "", //含油率
+              crimpRate: "", //卷缩率
+              boilingWaterShrinkage: "", //沸水收缩率
+              // 外观指标
+              fuzz: "", //毛丝
+              coilWire: "", //圈丝
+              arachnoidSilk: "", //蛛网丝
+              takeShapeBadness: "", //成型不良
+              oilFree: "", //无油
+              chromaticAberrationWire: "", //色差丝
+              filaments: "", //污丝
+            };
+          });
+        }
+      },
+    },
+    myRow: {
+      immediate: true,
+      deep: true,
+      handler(val) {
+        this.rowData = val;
       },
     },
   },
@@ -142,8 +242,50 @@ export default {
     myRow() {
       return this.row;
     },
+    ...mapState({
+      nickName: (state) => state.user.nickName,
+    }),
   },
   methods: {
+    // 记录质检结果
+    async record() {
+      let uuid = uuidv4();
+      let { bepTaskName, bepTaskKey, benTaskNodeKey } = this.rowData;
+      let payLoad = {
+        inspectionList: {
+          inspectionListNo: this.isEdit ? this.inspectionListNo : uuid, //检验单编号
+          saleNo: bepTaskName, // 销售单编号
+          taskProcessKey: bepTaskKey, //任务编码
+          taskNodeKey: benTaskNodeKey, //任务节点编码
+          inspectionTime: moment(new Date()).format("YYYY-MM-DD HH:mm:ss"), //检验时间
+          inspectionPersonnel: this.nickName, //检验人员
+          remark: this.remark, //备注
+        },
+        inspectionListInfo: [],
+      };
+      payLoad.inspectionListInfo = this.tableData.map((item) => {
+        return {
+          inspectionListNo: payLoad.inspectionList.inspectionListNo,
+          ...item,
+          taskProcessKey: bepTaskKey, //任务编码
+          taskNodeKey: benTaskNodeKey, //任务节点编码
+        };
+      });
+      try {
+        let apiFun = this.isEdit
+          ? editQualityInspectionCertificate
+          : addQualityInspectionCertificate;
+        let res = await apiFun(payLoad);
+        if (res.code == 200) {
+          let msg = this.isEdit ? "修改成功" : "添加成功";
+          this.$message.success(msg);
+        } else {
+          this.$message.error(res.msg);
+        }
+      } catch (error) {
+        console.log(error);
+      }
+    },
     async getFormData() {
       let formData = {
         flag: false,
@@ -152,7 +294,7 @@ export default {
 
       return {
         flag: true,
-        data: this.resFormData,
+        data: {},
       };
     },
   },