jingshuyong 11 месяцев назад
Родитель
Сommit
335c96ed03

+ 10 - 0
src/api/aps/index.js

@@ -122,3 +122,13 @@ export async function getFactoryarea(params) {
 }
 
 
+/**
+ * 修改处置状态
+ */
+ export async function updateDisposalStatus (data) {
+  const res = await request.post('/qms/qmsreturnrepairwork/updateDisposalStatus', data);
+  if (res.data.code == 0) {
+    return res.data.data;
+  }
+  return Promise.reject(new Error(res.data.message));
+}

+ 1 - 1
src/views/inspectionPlan/components/edit.vue

@@ -845,7 +845,7 @@
             weight
           });
         }
-        console.log('数据1221212121');
+        console.log('数据1221212121 list list',list);
         this.$refs.table12.setData(list);
       },
 

+ 106 - 73
src/views/inspectionPlan/components/new-edit.vue

@@ -603,6 +603,13 @@
               message: '请输入',
               trigger: 'blur'
             }
+          ],
+          packingUnit: [
+            {
+              required: true,
+              message: '请选择',
+              trigger: 'change'
+            }
           ]
         },
         isScheme: true,
@@ -781,76 +788,75 @@
     methods: {
       //
       calculate(list) {
-        if (list.length == 0) {
-          this.baseForm.sampleQuantity = 0;
-          this.baseForm.sampleWeight = 0;
-        }
+        // if (list.length == 0) {
+        //   this.baseForm.sampleQuantity = 0;
+        //   this.baseForm.sampleWeight = 0;
+        // }
         let sampleQuantity = 0; // 样品数量
         let sampleWeight = 0; // 样品重量
-        let sampleQualifiedNumber = 0; //  样品合格数
-        let sampleNoQualifiedNumber = 0; //  样品不合格数
+        // // let sampleQualifiedNumber = 0; //  样品合格数
+        // let sampleNoQualifiedNumber = 0; //  样品不合格数
         list.forEach((el) => {
           sampleQuantity += el.measureQuantity - 0;
           sampleWeight += el.weight - 0;
-          if (el.qualityResults != 2) {
-            sampleQualifiedNumber += el.measureQuantity - 0;
-          } else {
-            sampleNoQualifiedNumber += el.measureQuantity - 0;
-          }
+          // if (el.qualityResults != 2) {
+          //   sampleQualifiedNumber += el.measureQuantity - 0;
+          // } else {
+          //   sampleNoQualifiedNumber += el.measureQuantity - 0;
+          // }
         });
-        // 计算合格率和不合格率(百分比形式)
-        let sampleQualificationRate = ''; // 合格率
-        let sampleNoQualificationRate = ''; // 不合格率
-        if (sampleQualifiedNumber) {
-          sampleQualificationRate =
-            ((sampleQualifiedNumber / sampleQuantity) * 100).toFixed(2) || '';
-          sampleNoQualificationRate =
-            ((sampleNoQualifiedNumber / sampleQuantity) * 100).toFixed(2) || '';
-        }
-        if (sampleQualificationRate || sampleQualificationRate == '0.00') {
-          sampleQualificationRate = sampleQualificationRate + '%';
-        }
-        if (sampleNoQualificationRate || sampleNoQualificationRate == '0.00') {
-          sampleNoQualificationRate = sampleNoQualificationRate + '%';
-        }
-        let resultsTotal = this.baseForm.productNumber - sampleQuantity;
-        if (sampleQuantity == sampleQualifiedNumber) {
-          this.$set(this.baseForm, 'qualifiedNumber', resultsTotal);
-          this.$set(this.baseForm, 'unqualifiedNumber', 0);
-          this.$set(this.baseForm, 'qualificationRate', '100%');
-          // this.$set(this.baseForm, 'noQualificationRate', '0');
-          this.$set(this.baseForm, 'qualityResults', 1);
-        } else {
-          this.$set(this.baseForm, 'unqualifiedNumber', resultsTotal);
-          this.$set(this.baseForm, 'qualifiedNumber', 0);
-          this.$set(this.baseForm, 'qualificationRate', '0');
-          // this.$set(this.form, 'noQualificationRate', '100%');
-          this.$set(this.baseForm, 'qualityResults', 2);
-        }
-        // this.$set(this.form, 'resultsTotal', resultsTotal);
-        this.$set(
-          this.baseForm,
-          'sampleQualificationRate', // 样品合格率
-          sampleQualificationRate
-        );
-        this.$set(
-          this.baseForm,
-          'sampleNoQualificationRate', // 样品不合格率
-          sampleNoQualificationRate
-        );
-        this.$set(
-          this.baseForm,
-          'sampleNoQualifiedNumber', // 样品不合格数
-          sampleNoQualifiedNumber
-        );
-
-        this.$set(this.baseForm, 'sampleQuantity', sampleQuantity); // 样品数量
+         this.$set(this.baseForm, 'sampleQuantity', sampleQuantity); // 样品数量
         this.$set(this.baseForm, 'sampleWeight', sampleWeight); // 样品重量
-        this.$set(
-          this.baseForm,
-          'sampleQualifiedNumber',
-          sampleQualifiedNumber
-        ); // 样品合格数
+        // // 计算合格率和不合格率(百分比形式)
+        // let sampleQualificationRate = ''; // 合格率
+        // let sampleNoQualificationRate = ''; // 不合格率
+        // if (sampleQualifiedNumber) {
+        //   sampleQualificationRate =
+        //     ((sampleQualifiedNumber / sampleQuantity) * 100).toFixed(2) || '';
+        //   sampleNoQualificationRate =
+        //     ((sampleNoQualifiedNumber / sampleQuantity) * 100).toFixed(2) || '';
+        // }
+        // if (sampleQualificationRate || sampleQualificationRate == '0.00') {
+        //   sampleQualificationRate = sampleQualificationRate + '%';
+        // }
+        // if (sampleNoQualificationRate || sampleNoQualificationRate == '0.00') {
+        //   sampleNoQualificationRate = sampleNoQualificationRate + '%';
+        // }
+        // let resultsTotal = this.baseForm.productNumber - sampleQuantity;
+        // if (sampleQuantity == sampleQualifiedNumber) {
+        //   this.$set(this.baseForm, 'qualifiedNumber', resultsTotal);
+        //   this.$set(this.baseForm, 'unqualifiedNumber', 0);
+        //   this.$set(this.baseForm, 'qualificationRate', '100%');
+        //   // this.$set(this.baseForm, 'noQualificationRate', '0');
+        //   this.$set(this.baseForm, 'qualityResults', 1);
+        // } else {
+        //   this.$set(this.baseForm, 'unqualifiedNumber', resultsTotal);
+        //   this.$set(this.baseForm, 'qualifiedNumber', 0);
+        //   this.$set(this.baseForm, 'qualificationRate', '0');
+        //   // this.$set(this.form, 'noQualificationRate', '100%');
+        //   this.$set(this.baseForm, 'qualityResults', 2);
+        // }
+        // // this.$set(this.form, 'resultsTotal', resultsTotal);
+        // this.$set(
+        //   this.baseForm,
+        //   'sampleQualificationRate', // 样品合格率
+        //   sampleQualificationRate
+        // );
+        // this.$set(
+        //   this.baseForm,
+        //   'sampleNoQualificationRate', // 样品不合格率
+        //   sampleNoQualificationRate
+        // );
+        // this.$set(
+        //   this.baseForm,
+        //   'sampleNoQualifiedNumber', // 样品不合格数
+        //   sampleNoQualifiedNumber
+        // );
+        // this.$set(
+        //   this.baseForm,
+        //   'sampleQualifiedNumber',
+        //   sampleQualifiedNumber
+        // ); // 样品合格数
       },
       //成品检验类型,计划来源主数据,修改数量生成来源清单
       changeProductNumberModel(num) {
@@ -957,6 +963,7 @@
 
       //成品类型检验类型,计划来源库存台账, 生成来源清单
       changesStokledgerNumberModal(val, dimension, type) {
+        val.map((el) => (el.sourceId = el.id));
         console.log(val, dimension, '获取成品检验订单数据', type);
         // this.$refs.table12.setData([]);
         this.sourceList = [];
@@ -1186,7 +1193,6 @@
       },
 
       async getSourceList(id) {
-        console.log('执行 ---------------------');
         const listData = await getInventoryListByPlanId({
           planId: id,
           pageNum: 1,
@@ -1196,9 +1202,39 @@
           this.sourceList = [];
           return;
         }
-        let o = listData.list[0];
-        let listArr = [];
 
+        // let o = listData.list[0];
+        // let listArr = [];
+        // console.log(listData,'listData 会执行吗1234')
+        // if (o.measureUnit) {
+        //   listArr.push({
+        //     packageCellTotal: 1,
+        //     conversionUnit: o.measureUnit,
+        //     id: '111'
+        //   });
+        // }
+        // if (o.packingUnit) {
+        //   listArr.push({
+        //     packageCellTotal: o.measureQuantity - 0,
+        //     conversionUnit: o.packingUnit,
+        //     id: '222'
+        //   });
+        // }
+        // listData.list.map((el) => {
+        //   el.weightProportion = el.weight
+        //     ? (el.weight / el.measureQuantity).toFixed(4)
+        //     : 0;
+        //   el.weightProportion = el.weightProportion - 0;
+        // });
+        listData.list = this.proceSources(listData.list);
+        // this.packingSpecificationOption = listArr;
+        this.sourceList = listData.list;
+      },
+      // 处理来源清单数据
+      proceSources(arr) {
+        let list = arr;
+        let o = list[0];
+        let listArr = [];
         if (o.measureUnit) {
           listArr.push({
             packageCellTotal: 1,
@@ -1213,24 +1249,21 @@
             id: '222'
           });
         }
-        listData.list.map((el) => {
+        list.map((el) => {
           el.weightProportion = el.weight
             ? (el.weight / el.measureQuantity).toFixed(4)
             : 0;
           el.weightProportion = el.weightProportion - 0;
         });
         this.packingSpecificationOption = listArr;
-        this.sourceList = listData.list;
-        console.log(this.sourceList, '333333333333333333');
+        return list;
       },
-
       async getSampleList(id) {
         let res = await getSampleListByPlanId({
           planId: id,
           pageNum: this.samplePagination.currentPage,
           size: this.samplePagination.pageSize
         });
-        console.log(res.list, 'yyyyyyyyyyyyyy样品----------------------------');
 
         this.sampleList = res?.list || [];
         this.samplePagination.total = res.count;
@@ -1250,7 +1283,6 @@
           pageNum: this.schemePagination.currentPage,
           size: this.schemePagination.pageSize
         });
-        console.log(res.list, 'fffffffffffffff方案--------------------------');
         this.schemeList = res?.list || [];
         this.schemePagination.total = res.count;
       },
@@ -1336,7 +1368,7 @@
 
         console.log(res, '来料清单');
         if (res.length > 0) {
-          const _arr1 = res.map((m) => {
+          let _arr1 = res.map((m) => {
             m.sourceId = m.id;
             m.productCategoryId = productCategoryId;
             m.productCategoryName = productCategoryName;
@@ -1371,6 +1403,7 @@
           //处理样品清单
           console.log('处理来源清单数据');
           // await this.handleSampleList();
+          _arr1 = this.proceSources(_arr1);
           await this.updatePackingList(_arr1);
         } else {
           console.log('来料清单数据为空');

+ 58 - 40
src/views/unqualifiedProduct/unqualifiedList/components/factoryAdd.vue

@@ -414,7 +414,8 @@
     getFactoryList,
     // temporarilyUpdate,
     temporaryPlanSave,
-    getCode
+    getCode,
+    updateDisposalStatus
   } from '@/api/aps';
 
   export default {
@@ -447,6 +448,10 @@
       factoryData: {
         type: Array,
         default: () => []
+      },
+      orderType: {
+        type: Number,
+        default: 1
       }
     },
     computed: {
@@ -1035,47 +1040,60 @@
           let flag = this.parameterVerification();
           // 必填参数校验
           if (!flag) return;
-          if (!this.form.id) {
-            if (this.form.productInfoList.length) {
-              this.form.productInfoList.map((item, index) => {
-                delete item.selectionRowShow;
-                if (item.bomVersionList && item.bomVersionList.length) {
-                  item.bomCategoryName = item.bomVersionList[0].name;
-                  item.bomCategoryVersions = item.bomVersionList[0].versions;
-                  item.produceRoutingName = item.routingList[0].name;
-                }
-              });
-            }
-
-            this.form.timeDimensionPlanType = this.type;
-            await this.getPlanCode();
-            this.loading = true;
-
-            // console.log(this.form,'this.form 1+1 ')
-            // return
-            temporaryPlanSave(this.form)
-              .then((res) => {
-                this.$message.success('新增成功!');
-                // this.visible = false;
-                this.cancel();
-              })
-              .finally(() => {
-                this.loading = false;
-              });
-          } else {
-            this.loading = true;
-            temporaryPlanSave(this.form)
-              .then((res) => {
-                this.$message.success('修改成功!');
-                // this.visible = false;
-                this.initForm();
-                this.$emit('close', true);
-              })
-              .finally(() => {
-                this.loading = false;
-              });
+          // if (!this.form.id) {
+          if (this.form.productInfoList.length) {
+            this.form.productInfoList.map((item, index) => {
+              delete item.selectionRowShow;
+              if (item.bomVersionList && item.bomVersionList.length) {
+                item.bomCategoryName = item.bomVersionList[0].name;
+                item.bomCategoryVersions = item.bomVersionList[0].versions;
+                item.produceRoutingName = item.routingList[0].name;
+              }
+            });
           }
+
+          this.form.timeDimensionPlanType = this.type;
+          await this.getPlanCode();
+          this.loading = true;
+
+          // console.log(this.form,'this.form 1+1 ')
+          // return
+          temporaryPlanSave(this.form)
+            .then((res) => {
+              this.$message.success('新增成功!');
+              // this.visible = false;
+              this.updateDisposal();
+              this.cancel();
+            })
+            .finally(() => {
+              this.loading = false;
+            });
+          // } else {
+          //   this.loading = true;
+          //   temporaryPlanSave(this.form)
+          //     .then((res) => {
+          //       this.updateDisposal();
+          //       this.$message.success('修改成功!');
+          //       // this.visible = false;
+          //       this.initForm();
+          //       this.$emit('close', true);
+          //     })
+          //     .finally(() => {
+          //       this.loading = false;
+          //     });
+          // }
+        });
+      },
+      // 修改处置状态
+      async updateDisposal() {
+        let list = this.factoryData.map((el) => {
+          return {
+            id: el.id,
+            sampleId: el.sampleId,
+            type: this.orderType
+          };
         });
+        await updateDisposalStatus(list);
       },
       bomListVersionFn(produceType, categoryId) {
         return new Promise((resolve, reject) => {

+ 6 - 5
src/views/unqualifiedProduct/unqualifiedList/rework/index.vue

@@ -16,7 +16,7 @@
             type="primary"
             slot="reference"
             :disabled="selection.length == 0"
-            @click="addProductPlan"
+            @click="addProductPlan(1)"
             >转生产计划</el-button
           >
           <!-- <el-button
@@ -76,6 +76,7 @@
 
     <factory-add
       v-if="factoryVisable"
+      :orderType="orderType"
       ref="factoryAddRef"
       :factoryVisable.sync="factoryVisable"
       :factoryData="selection"
@@ -114,7 +115,8 @@
         releasParams: {
           teamId: '',
           id: ''
-        }
+        },
+        orderType: 1
       };
     },
     computed: {
@@ -352,9 +354,8 @@
           this.$refs.table.reload({ page: 1, where });
         });
       },
-      addProductPlan() {
-        console.log(this.selection);
-
+      addProductPlan(type) {
+        this.orderType = type;
         this.factoryVisable = true;
       }
     }