Bladeren bron

优化质检计划代码;

yijing 1 jaar geleden
bovenliggende
commit
62d1d28a21
2 gewijzigde bestanden met toevoegingen van 160 en 251 verwijderingen
  1. 3 20
      src/views/inspectionPlan/components/baseInfo.vue
  2. 157 231
      src/views/inspectionPlan/components/edit.vue

+ 3 - 20
src/views/inspectionPlan/components/baseInfo.vue

@@ -22,9 +22,6 @@
         </el-form-item>
       </el-col>
       <el-col :span="6">
-        <!--        <el-form-item label="检验标准:" prop="inspectionStandards">-->
-        <!--          <el-select v-model="form.inspectionStandards" placeholder="请选择" style="width: 100%" clearable></el-select>-->
-        <!--        </el-form-item>-->
         <el-form-item label="检验标准" prop="inspectionStandards">
           <!-- 计量 计重 -->
           <el-select style="width: 100%" v-model="form.inspectionStandards" placeholder="请选择">
@@ -275,17 +272,6 @@ export default {
       },
       immediate: false
     },
-    // 'form.autoOrder': {
-    //   handler(newVal) {
-    //     if (!newVal) {
-    //       this.form.groupId = '';
-    //       this.form.groupName = '';
-    //       this.form.executeId = '';
-    //       this.form.executeName = '';
-    //     }
-    //   },
-    //   immediate: false
-    // },
     'form.type': {
       handler(newVal) {
         if (!newVal) {
@@ -303,7 +289,6 @@ export default {
           this.form.qualificationRate = '';
           this.form.totalWeight = '';
           this.form.sampleNumber = '';
-          // this.form.sampleMeasureUnit = '';
           this.sourceList = [];
           this.$emit('resetTable');
         }
@@ -327,7 +312,6 @@ export default {
           this.form.qualificationRate = '';
           this.form.totalWeight = '';
           this.form.sampleNumber = '';
-          // this.form.sampleMeasureUnit = '';
           this.$emit('resetTable');
         }
       },
@@ -363,6 +347,7 @@ export default {
     toggleExpand() {
       this.isExpanded = !this.isExpanded;
     },
+    // 获取检验标准
     async getDictListIqoCode(code) {
       let { data: res } = await getByCode(code);
       this.inspectionStandardsList = res.map((item) => {
@@ -435,6 +420,7 @@ export default {
         this.$refs.equipmentRefs.open();
       }
     },
+    //根据类型获取计划来源下拉
     typeChange(val) {
       if (val == 1) {
         this.sourceList = [{ label: '采购收货单', value: '1' }];
@@ -450,10 +436,7 @@ export default {
     handleChoose(val) {
       if (!val) return;
       this.form.planSourceId = val.id;
-      // this.form.planReceiveId = val.receiveId;
-
       this.form.planSourceCode = val.receiveNo;
-      console.log(this.form.planSourceCode, 'this.form.planSourceCode')
       this.form.supplierName = val.supplierName;
       this.form.supplierMark = val.supplierMark;
       this.form.productName = val.productName;
@@ -483,7 +466,7 @@ export default {
       }
       this.getProductDetails(this.form.productId)
     },
-
+    //获取产品详情信息-来自主数据
     async getProductDetails(val) {
       const data = await getDetailInfo(val)
       this.categoryInfo = data.category

+ 157 - 231
src/views/inspectionPlan/components/edit.vue

@@ -4,7 +4,7 @@
     :close-on-press-escape="false" append-to-body width="80%" :maxable="true">
     <header-title title="基本信息"></header-title>
     <base-info ref="baseInfoRefs" v-if="baseForm" :form="baseForm" :btnType="btnType" @resetTable="resetTable"
-      @getList="getList" @changeModel="changeModel" @table2="table2" :packingLists="packingList"
+      @changeModel="changeModel" @getList="getList" @table2="table2" :packingLists="packingList"
       @getCategoryInfo="getCategoryInfo"></base-info>
     <el-row>
       <header-title title="质检内容"></header-title>
@@ -102,26 +102,6 @@
         下发
       </el-button>
     </template>
-
-
-    <!-- <ele-modal :visible.sync="takeAsampleVisible" title="选择取样信息" width="80vw" append-to-body @close="handleCancel"
-      :maxable="true">
-
-      <el-table ref="showSampleListTable" :data="selectedList" tooltip-effect="dark" :max-height="300" border
-        row-key="id" @selection-change="handleSelectionChange2">
-        <el-table-column type="selection" width="55" align="center" :reserve-selection="true"></el-table-column>
-        <el-table-column label="序号" type="index" width="50" align="center"></el-table-column>
-        <template v-for="column in tableColumns2">
-          <el-table-column :label="column.label" :prop="column.prop" :show-overflow-tooltip="true" :width="column.width"
-            :align="column.align">
-          </el-table-column>
-        </template>
-      </el-table>
-      <div style="width: 100%;text-align: right;margin-top: 12px;">
-        <el-button type="primary" @click="handleConfirm">确定</el-button>
-        <el-button @click="handleCancel">取消</el-button>
-      </div>
-    </ele-modal> -->
   </ele-modal>
 </template>
 
@@ -138,7 +118,7 @@ import {
   outInRecordsPage,
   getBatchInfoData
 } from '@/api/inspectionPlan/index.js';
-import { rules } from 'eslint-config-prettier';
+
 export default {
   components: {
     baseInfo
@@ -177,11 +157,8 @@ export default {
         sampleMeasureUnit: '',
         sampleProportion: '',
         supplierMark: '',
-        // planReceiveId: '',
-
         remark: '',
         accessory: [],
-
         conditionType: 1,
       };
     };
@@ -216,8 +193,6 @@ export default {
         { label: '计量单位', prop: 'measureUnit', align: 'center' },
         { label: '物料代号', prop: 'materielDesignation', align: 'center' },
         { label: '客户代号', prop: 'clientCode', align: 'center' },
-        // { label: '供应商名称', prop: 'supplierName', align: 'center', width: '120' },
-        // { label: '供应商代号', prop: 'supplierCode', align: 'center', width: '120' },
         { label: '刻码', prop: 'engrave', align: 'center' },
         { label: '重量', prop: 'weight', align: 'center' },
         { label: '重量单位', prop: 'weightUnit', align: 'center' },
@@ -257,9 +232,6 @@ export default {
       isCheck: false,
 
       rowIds: '',
-
-      takeAsampleVisible: false,
-      confirmSampleData: [],
       formData: {
         number: 1,
         sampleUnit: '',
@@ -394,16 +366,13 @@ export default {
   created() { },
   methods: {
     async datasource({ page, limit, where }) {
-
       const res = await getInventoryListByPlanId({ ...where, page, limit });
-
       if (res.list.length > 1) {
         this.isCheck = true
       } else {
         this.isCheck = false
       }
       this.packingList = res.list;
-
       return res.list;
     },
     // 切换质检内容
@@ -420,8 +389,10 @@ export default {
         const code = await getCode('qms_plan_code');
         this.baseForm.code = code;
         return;
+      } else {
+        await this.handleEditOrDetail(row);
       }
-      await this.handleEditOrDetail(row);
+
     },
     async handleEditOrDetail(row) {
       console.log('row====', row);
@@ -454,11 +425,9 @@ export default {
       // 如果是编辑或者详情,则查询物料清单、质检方案和样品列表
       if (row.id) {
         this.rowIds = row.id;
-
         //操作行点击时查询清单
         // await this.getInventoryList();
         await this.reload({ planId: row.id });
-
         //操作行点击时查询样品
         await this.getSampleList(row.id);
         //操作行点击时查询质检
@@ -496,12 +465,11 @@ export default {
       await this.getGoodsList(receiveNo, productCode, null, productCategoryId, productCategoryName, categoryid, batchNo, supplierName, supplierMark);
 
       //通过来源和产品 获取质检方案
-      this.getQualityTemplate(productCode);
+      await this.getQualityTemplate(productCode);
     },
     async getGoodsList(receiveNo, productCode, ids, productCategoryId, productCategoryName, categoryid, batchNo, supplierName, supplierMark) {
       this.$refs.table12.setData([])
 
-
       let res;
       const res1 = await outInRecordsPage({
         sourceBizNo: receiveNo,
@@ -517,7 +485,6 @@ export default {
           res = res1.list
           this.isCheck = true;
           console.log('this.isCheck=true', this.isCheck)
-
         } else {
           res = []
           this.$message.error('此数据已质检,无需再次质检!');
@@ -545,79 +512,63 @@ export default {
 
       console.log(res, '来料清单');
       if (res.length > 0) {
-        let _arr1 = [];
-        _arr1 = res.map((m) => {
+        const _arr1 = res.map((m) => {
           m.sourceId = m.id;
           m.productCategoryId = productCategoryId;
           m.productCategoryName = productCategoryName;
           delete m.id;
-          return {
-            ...m
-          };
+          return { ...m };
         });
         console.log(_arr1, '1234567890')
 
         this.packingList = _arr1;
         this.$refs.table12.setData(_arr1);//赋值
-
-
         const _arr2 = this.$refs.table12.getData();
+
         if (_arr2.length > 1) {
           this.baseForm.productNumber = _arr2.length;
         } else {
           this.baseForm.productNumber = _arr2[0].measureQuantity;
         }
         //处理样品清单
-        this.aaa();
+        await this.handleSampleList();
       } else {
         this.$refs.table12.setData([]);
       }
     },
-    //获取样品编码
-    async getSampleCode() {
-      return await getCode('sample_code');
-    },
-    async aaa() {
-      console.log('aaa')
+    async handleSampleList() {
       let packingList = this.$refs.table12.getData();
-
+      //全检时
       if (this.baseForm.qualityMode == 1) {
         this.sampleList = [];
-        console.log('是否拆包', this.baseForm.isUnpack)
+        console.log(this.baseForm.isUnpack, '---isUnpack---')
         if (this.baseForm.isUnpack != null && this.baseForm.isUnpack != undefined && this.baseForm.isUnpack != '') {
+          //拆包
           if (this.baseForm.isUnpack == 2) {
-            const num = Number(this.baseForm.productNumber || 0);
-            if (num) {
-              this.getUnpackSamList(packingList, num)
-            }
+            await this.handleUnpackCase(packingList);
           } else if (this.baseForm.isUnpack == 1) {
-            if (this.baseForm.qualityMode == 1) {
-              await this.updatePackingList(packingList);
-            } else {
-              this.sampleList = [];
-            }
+            await this.updatePackingList(packingList);
           }
         } else {
-          console.log('isCheck', this.isCheck)
           if (!this.isCheck) {
-            const num = Number(this.baseForm.productNumber || 0);
-            if (num) {
-              this.getUnpackSamList(packingList, num)
-            }
+            await this.handleUnpackCase(packingList);
           } else {
-            if (this.baseForm.qualityMode == 1) {
-
-              await this.updatePackingList(packingList);
-
-            } else {
-              this.sampleList = [];
-            }
+            await this.updatePackingList(packingList);
           }
         }
       } else {
         this.sampleList = [];
       }
-
+    },
+    async handleUnpackCase(packingList) {
+      const num = Number(this.baseForm.productNumber || 0);
+      if (num) {
+        await this.getUnpackSamList(packingList, num);
+      }
+    },
+    //获取样品编码
+    async getSampleCode() {
+      return await getCode('sample_code');
     },
     async updatePackingList(list) {
       for (let i = 0; i < list.length; i++) {
@@ -646,7 +597,7 @@ export default {
         }
       });
 
-      console.log(data, 'datadatadatadatadatadata', num)
+      console.log(data, '样品数据-条数', num)
       await this.updatePackingList(data);
 
     },
@@ -688,16 +639,12 @@ export default {
           this.schemePagination.total = this.schemeList.length;
         }
       });
-
-
     },
+    //来料列表表格选择事件
     handleSelectionChange(selection) {
-      console.log(selection, 'gouxuan')
-
+      console.log(selection, '勾选')
       this.selectedList = selection;
-
       this.formData.portion = selection.length;
-
       this.baseForm.sampleNumber = selection.length;
       //如果取小样
       if (this.conditionType == 2) {
@@ -706,35 +653,118 @@ export default {
         this.$set(this.baseForm, 'sampleMeasureUnit', data1[0]?.measureUnit);
       }
     },
+    //取样方式选择
+    handleSampleNumber(val) {
+      console.log(val, 'val');
+      this.conditionType = val;
+      //清空样品清单列表
+      this.sampleList = []
+      const dataS = this.$refs.table12.getData();
+      //取整样
+      if (val == 1) {
+        this.sampleList = dataS;
+        this.formData.portion = dataS.length;
+        this.$refs.table12.toggleAllSelection();
+        this.activeName = '2';
+        this.$message.success('取样成功!');
+      } else if (val == 2) {
+        this.formData.sampleUnit = dataS[0].measureUnit;
 
-    // 样品列表分页方法
-    handleSampleSizeChange(val) {
-      this.samplePagination.pageSize = val;
-      this.samplePagination.currentPage = 1;
-    },
-    handleSampleCurrentChange(val) {
-      this.samplePagination.currentPage = val;
+        this.$refs.table12.clearSelection();
+        //小样
+        if (this.selectedList.length == 0) {
+          this.$message.warning('请先选择样品!');
+        } else {
+          if (this.formData.number == null || this.formData.sampleUnit == '') {
+            this.$message.warning('请先选择取样的数量和单位!');
+          }
+        }
+      }
     },
 
-    // 质检方案分页方法
-    handleSchemeSizeChange(val) {
-      this.schemePagination.pageSize = val;
-      this.schemePagination.currentPage = 1;
-    },
-    handleSchemeCurrentChange(val) {
-      this.schemePagination.currentPage = val;
+    handleInputNumber(val) {
+      let packingList = this.$refs.table12.getData()
+
+      const maxValue = packingList.length > 1 ? packingList.length : packingList[0].measureQuantity;
+
+      if (val > maxValue) {
+        this.$message.warning('数量不能大于计量数量!');
+        this.formData.number = maxValue;
+        return;
+      }
     },
-    changeModel(val) {
-      this.baseForm.qualityMode = val;
-      this.baseForm.sampleNumber = ''
-      console.log(this.baseForm.productNumber, 'productNumberproductNumber数量')
-      if (this.baseForm.qualityMode == 1) {
-        this.aaa()
+    handleInput(val) {
+      if (val == 0 || val == '' || val == null) {
+        this.$refs.table12.clearSelection();
+        return
+      }
+      let packingList = this.$refs.table12.getData();
+      if (!packingList || packingList.length === 0) {
+        return;
+      }
+
+      const portion = Number(this.formData.portion);
+      if (this.isCheck) {
+        if (portion > packingList.length) {
+          this.$message.warning('取样数量不能大于来源清单数量!');
+          this.formData.portion = packingList.length;
+          return;
+        }
+        packingList.slice(0, this.formData.portion).forEach(row => {
+          this.$refs.table12.toggleRowSelection(row);
+        });
       } else {
-        this.sampleList = [];
+        const maxQuantity = Number(packingList[0].measureQuantity);
+        if (portion > maxQuantity) {
+          this.$message.warning('取样数量不能大于计量数量!');
+          this.formData.portion = maxQuantity;
+          return;
+        }
       }
     },
+    getCategoryInfo(val) {
+      this.isConsumable = val.isConsumable;
+    },
+    changeSamUnit(val) {
+      this.$refs.baseInfoRefs.getsampleMeasureUnit(val);
+    },
+    //抽样确认按钮事件-样品列表右上角确认按钮
+    handleSampleSubmit() {
+      this.$refs.ruleForm.validate((valid) => {
+        if (valid) {
+          this.sampleList = []
+          this.baseForm.sampleMeasureUnit = this.formData.sampleUnit
+
+          if (this.conditionType == 1) {
+            this.sampleList = this.selectedList
+          } else {
+            let measureQ = this.formData.number;
+            let unit = this.formData.sampleUnit;
+            let nums = Number(this.formData.portion);
+
+            console.log(measureQ, unit, nums, 'measureQ, unit, nums')
+            this.getNewSampleList(measureQ, unit, nums)
+          }
+          this.activeName = '2'
+        }
+      });
+    },
+    //更新计量数量、单位后重新生成样品列表数据
+    getNewSampleList(measureQ, unit, nums) {
+      this.sampleList = [];
+      if (!this.selectedList || this.selectedList.length == 0) {
+        this.$message.warning('请先选择样品!');
+        return;
+      }
 
+      this.sampleList = this.selectedList.map(oldItem => {
+        const newItem = JSON.parse(JSON.stringify(oldItem));
+        newItem.measureQuantity = measureQ;
+        newItem.measureUnit = unit;
+        return newItem;
+      });
+    },
+    //监听类型变化
     resetTable() {
       this.$nextTick(() => {
         this.table1();
@@ -781,6 +811,7 @@ export default {
 
         if (this.btnType == 'issued' && this.schemeList.length < 1) {
           this.$message.warning('质检方案不能为空!');
+          this.loading = false;
           return;
         }
         let URL =
@@ -798,7 +829,6 @@ export default {
             this.loading = false;
           });
       });
-      this.loading = false;
     },
     handleIssued() {
       if (this.sampleList.length == 0) {
@@ -826,6 +856,7 @@ export default {
 
         if (this.btnType == 'issued' && this.schemeList.length < 1) {
           this.$message.warning('质检方案不能为空!');
+          this.loading = false;
           return;
         }
 
@@ -840,139 +871,34 @@ export default {
             this.loading = false;
           });
       });
-      this.loading = false;
     },
-    handleSampleNumber(val) {
-      console.log(val, 'val')
-      this.conditionType = val;
-      //清空样品清单列表
-      this.sampleList = []
-      let dataS = this.$refs.table12.getData()
-      //取整样
-      if (val == 1) {
-        this.sampleList = dataS
-        this.formData.portion = dataS.length
-        this.$refs.table12.toggleAllSelection();
-        this.activeName = '2'
-        this.$message.success('取样成功!');
-      } else if (val == 2) {
-        this.formData.sampleUnit = dataS[0].measureUnit
-
-        this.$refs.table12.clearSelection();
-        //小样
-        if (this.selectedList.length == 0) {
-          this.$message.warning('请先选择样品!');
-        } else {
-          if (this.formData.number == null || this.formData.sampleUnit == '') {
-            this.$message.warning('请先选择取样的数量和单位!');
-          }
-        }
-      }
-    },
-    handleInputNumber(val) {
-      let packingList = this.$refs.table12.getData()
-
-      const maxValue = packingList.length > 1 ? packingList.length : packingList[0].measureQuantity;
-
-      if (val > maxValue) {
-        this.$message.warning('数量不能大于计量数量!');
-        this.formData.number = maxValue;
-        return;
-      }
-    },
-    handleInput(val) {
-      if (val == 0 || val == '' || val == null) {
-        this.$refs.table12.clearSelection();
-        return
-      }
-      let packingList = this.$refs.table12.getData();
-      if (!packingList || packingList.length === 0) {
-        return;
-      }
-
-      const portion = Number(this.formData.portion);
-      if (this.isCheck) {
-        if (portion > packingList.length) {
-          this.$message.warning('取样数量不能大于来源清单数量!');
-          this.formData.portion = packingList.length;
-          return;
-        }
-        packingList.slice(0, this.formData.portion).forEach(row => {
-          this.$refs.table12.toggleRowSelection(row);
-        });
-      } else {
-        const maxQuantity = Number(packingList[0].measureQuantity);
-        if (portion > maxQuantity) {
-          this.$message.warning('取样数量不能大于计量数量!');
-          this.formData.portion = maxQuantity;
-          return;
-        }
-      }
-    },
-
-    getCategoryInfo(val) {
-      this.isConsumable = val.isConsumable;
-    },
-    changeSamUnit(val) {
-      this.$refs.baseInfoRefs.getsampleMeasureUnit(val)
-    },
-    handleSampleSubmit() {
-      this.$refs.ruleForm.validate((valid) => {
-        if (valid) {
-          this.sampleList = []
-          this.baseForm.sampleMeasureUnit = this.formData.sampleUnit
-
-          if (this.conditionType == 1) {
-            this.sampleList = this.selectedList
-          } else {
-            let measureQ = this.formData.number;
-            let unit = this.formData.sampleUnit;
-            let nums = Number(this.formData.portion);
-
-            console.log(measureQ, unit, nums, 'measureQ, unit, nums')
-            this.getNewSampleList(measureQ, unit, nums)
-          }
-          this.activeName = '2'
-        }
-      });
-
-
+    // 样品列表分页方法
+    handleSampleSizeChange(val) {
+      this.samplePagination.pageSize = val;
+      this.samplePagination.currentPage = 1;
     },
-    getNewSampleList(measureQ, unit, nums) {
-      this.sampleList = [];
-      if (!this.selectedList || this.selectedList.length == 0) {
-        this.$message.warning('请先选择样品!');
-        return;
-      }
-
-      this.sampleList = this.selectedList.map(oldItem => {
-        const newItem = JSON.parse(JSON.stringify(oldItem));
-        newItem.measureQuantity = measureQ;
-        newItem.measureUnit = unit;
-        return newItem;
-      });
+    handleSampleCurrentChange(val) {
+      this.samplePagination.currentPage = val;
     },
-    handleCancel() {
-      this.takeAsampleVisible = false;
+    // 质检方案分页方法
+    handleSchemeSizeChange(val) {
+      this.schemePagination.pageSize = val;
+      this.schemePagination.currentPage = 1;
     },
-    handleSelectionChange2(selection) {
-      console.log(selection, '123')
-      this.confirmSampleData = selection;
+    handleSchemeCurrentChange(val) {
+      this.schemePagination.currentPage = val;
     },
-    handleConfirm() {
-
-      //赋值取样数量和取样单位
-      // this.baseForm.sampleNumber = this.sampleData[0].measureQuantity
-      // this.baseForm.sampleMeasureUnit = this.sampleData[0].measureUnit
-      if (this.confirmSampleData.length > 0) {
-        this.sampleList = this.confirmSampleData;
+    //检验方式改变时,重新获取样品列表
+    changeModel(val) {
+      this.baseForm.qualityMode = val;
+      this.baseForm.sampleNumber = '';
+      console.log(this.baseForm.productNumber, 'productNumberproductNumber数量')
+      if (this.baseForm.qualityMode == 1) {
+        this.handleSampleList();
       } else {
-        this.sampleList = this.selectedList;
+        this.sampleList = [];
       }
-      this.takeAsampleVisible = false;
-
     },
-
   }
 };
 </script>