695593266@qq.com 1 год назад
Родитель
Сommit
353ac3b8df

+ 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));
+}

+ 18 - 1
src/api/classifyManage/itemInformation.js

@@ -35,7 +35,24 @@ export async function getDetails(id) {
   }
   return Promise.reject(new Error(res.data.message));
 }
-
+  // 根据物品ID获取包装维度
+  export async function getCategoryPackageDisposition(data) {
+  const res = await request.post(`/main/categoryPackageDisposition/list`,data);
+  if (res.data.code == 0) {
+    return res.data.data;
+  }
+  return Promise.reject(new Error(res.data.message));
+}
+  // getCategoryPackageDisposition: async (data) => {
+  //   const res = await request.post(
+  //     '/main/categoryPackageDisposition/list',
+  //     data
+  //   );
+  //   if (res.data.code == 0) {
+  //     return res.data.data;
+  //   }
+  //   return Promise.reject(new Error(res.data.message));
+  // },
 // 物品信息删除
 export async function removeItem(id) {
   const res = await request.get(`/main/category/remove/${id}`, {});

+ 1 - 0
src/api/inspectionPlan/index.js

@@ -160,6 +160,7 @@ export async function getBatchInfoData(params) {
 // 详情接口
 
 export async function getDetailInfo(id) {
+  console.log('请求没有 1111')
   const res = await request.get(`/main/category/info/${id}`);
   if (res.data.code == 0) {
     return res.data.data;

+ 0 - 1
src/components/addDoc/index.vue

@@ -53,7 +53,6 @@
     watch: {
       value: {
         handler(newVal) {
-          console.log(newVal, '=======');
           this.selectVal = newVal || [];
         },
         immediate: true

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

@@ -841,7 +841,7 @@
         const data = await getDetailInfo(val);
         this.categoryInfo = data.category;
         const qmsData = data.categoryQms;
-
+        console.log(qmsData,'qmsData qmsDataqmsData 3333')
         // *** 新增 批次号,来源单据 字段传递
         console.log(this.categoryInfo.measureType, 'getProductDetails');
         this.form.inspectionStandards = this.categoryInfo.measureType;

+ 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);
       },
 

+ 59 - 14
src/views/inspectionPlan/components/new-baseInfo.vue

@@ -289,10 +289,8 @@
         </el-col>
         <el-col :span="6">
           <el-form-item label="合格率:" prop="qualificationRate">
-            <el-input
-              v-model="form.qualificationRate"
-              :disabled="btnType == 'detail' || btnType == 'issued'"
-            />
+            <el-input v-model="form.qualificationRate" disabled />
+            <!--  :disabled="btnType == 'detail' || btnType == 'issued'" -->
           </el-form-item>
         </el-col>
         <el-col :span="6">
@@ -352,6 +350,56 @@
           </el-form-item>
         </el-col>
       </el-row>
+
+      <!-- <header-title title="样品信息">
+        <el-col :span="6">
+          <el-form-item label="样品类型:" prop="unqualifiedNumber">
+            <el-input type="number" v-model="form.unqualifiedNumber" disabled>
+              <template #append>{{ categoryInfo.measuringUnit }}</template>
+            </el-input>
+          </el-form-item>
+        </el-col>
+        <el-col :span="6">
+          <el-form-item label="样品数量:" prop="unqualifiedNumber">
+            <el-input type="number" v-model="form.unqualifiedNumber" disabled>
+              <template #append>{{ categoryInfo.measuringUnit }}</template>
+            </el-input>
+          </el-form-item>
+        </el-col>
+        <el-col :span="6">
+          <el-form-item label="合格品数量:" prop="qualifiedNumber">
+            <el-input type="number" v-model="form.qualifiedNumber" disabled>
+              <template #append>{{ categoryInfo.measuringUnit }}</template>
+            </el-input>
+          </el-form-item>
+        </el-col>
+        <el-col :span="6">
+          <el-form-item label="不合格品数量:" prop="unqualifiedNumber">
+            <el-input type="number" v-model="form.unqualifiedNumber" disabled>
+              <template #append>{{ categoryInfo.measuringUnit }}</template>
+            </el-input>
+          </el-form-item>
+        </el-col>
+        <el-col :span="6">
+          <el-form-item label="合格率:" prop="qualificationRate">
+            <el-input
+              v-model="form.qualificationRate"
+              :disabled="btnType == 'detail' || btnType == 'issued'"
+            />
+          </el-form-item>
+        </el-col>
+        <el-col :span="6">
+          <el-form-item label="总重量:" prop="totalWeight">
+            <el-input
+              type="number"
+              v-model="form.totalWeight"
+              :disabled="btnType == 'detail' || btnType == 'issued'"
+            >
+              <template #append>{{ categoryInfo.weightUnit }}</template>
+            </el-input>
+          </el-form-item>
+        </el-col>
+      </header-title> -->
     </div>
     <!-- 采购收货单 -->
     <warehousing ref="warehousingRef" @choose="handleChoose" />
@@ -630,7 +678,6 @@
         console.log(val, '主数据根据来源得到产品');
         if (!val) return;
 
-        console.log();
         this.form.productName = val.name; //名称
         this.form.productCode = val.code; //编码
         this.form.specification = val.specification; //规格
@@ -770,17 +817,15 @@
       ) {
         const data = await getDetailInfo(val);
         this.categoryInfo = data.category;
-        const qmsData = data.categoryQms;
-
+        const qmsData = data.categoryQms.find((item) => item.dataType == 1);
         // *** 新增 批次号,来源单据 字段传递
-        console.log(this.categoryInfo.measureType, 'getProductDetails');
         this.form.inspectionStandards = this.categoryInfo.measureType;
-
-        this.form.qualityMode = this.form.qualityMode
-          ? this.form.qualityMode
-          : qmsData.checkFormula
-          ? qmsData.checkFormula
-          : 1;
+        this.form.qualityMode = qmsData?.checkFormula ? qmsData.checkFormula : 1;
+        // this.form.qualityMode = this.form.qualityMode
+        //   ? this.form.qualityMode
+        //   : qmsData.checkFormula
+        //   ? qmsData.checkFormula
+        //   : 1;
         // this.form.qualityMode = qmsData.checkFormula || 1;
         // if (this.form.qualityMode) {
         //   this.changeQualityMode(this.form.qualityMode, 'Details');

+ 348 - 18
src/views/inspectionPlan/components/new-edit.vue

@@ -31,6 +31,64 @@
       @changesStokledgerNumberModal="changesStokledgerNumberModal"
       @getQualityTemplate="getQualityTemplate"
     ></base-info>
+    <header-title title="样品信息"></header-title>
+    <el-form label-width="110px">
+      <el-row>
+        <el-col :span="6">
+          <el-form-item label="样品合格数:">
+            <el-input
+              type="number"
+              :min="0"
+              disabled
+              v-model="baseForm.sampleQualifiedNumber"
+              placeholder=""
+            ></el-input>
+          </el-form-item>
+        </el-col>
+        <el-col :span="6">
+          <el-form-item label="样品不合格数:">
+            <el-input
+              type="number"
+              :min="0"
+              disabled
+              v-model="baseForm.sampleNoQualifiedNumber"
+              placeholder=""
+            ></el-input>
+          </el-form-item>
+        </el-col>
+        <el-col :span="6">
+          <el-form-item label="样品合格率:">
+            <el-input v-model="baseForm.sampleQualificationRate" disabled />
+          </el-form-item>
+        </el-col>
+        <el-col :span="6">
+          <el-form-item label="样品不合格率:">
+            <el-input v-model="baseForm.sampleNoQualificationRate" disabled />
+          </el-form-item>
+        </el-col>
+      </el-row>
+      <el-row>
+        <el-col :span="6">
+          <el-form-item label="样品类型:">
+            <el-input disabled :value="sampletypeVal(baseForm.conditionType)" />
+          </el-form-item>
+        </el-col>
+        <el-col :span="6">
+          <el-form-item label="样品数量:">
+            <el-input
+              type="number"
+              disabled
+              v-model="baseForm.sampleQuantity"
+            />
+          </el-form-item>
+        </el-col>
+        <el-col :span="6">
+          <el-form-item label="样品重量:">
+            <el-input type="number" disabled v-model="baseForm.sampleWeight" />
+          </el-form-item>
+        </el-col>
+      </el-row>
+    </el-form>
     <el-row>
       <header-title title="质检内容"></header-title>
       <el-tabs v-model="activeName" @tab-click="handleClick">
@@ -123,7 +181,7 @@
                       ></el-input>
                     </el-form-item>
                   </el-col>
-                  <el-col :span="24" v-if="conditionType == 1">
+                  <el-col :span="10" v-if="conditionType == 1">
                     <el-form-item prop="portion" label="数量" style="margin: 0">
                       <el-input
                         v-model="formData.portion"
@@ -133,6 +191,26 @@
                       ></el-input>
                     </el-form-item>
                   </el-col>
+                  <el-col :span="10" v-if="conditionType == 1">
+                    <el-form-item
+                      prop="packingUnit"
+                      label="单位"
+                      style="margin: 0"
+                    >
+                      <el-select
+                        v-model="formData.packingUnit"
+                        placeholder="请选择"
+                      >
+                        <el-option
+                          v-for="item in packingSpecificationOption"
+                          :key="item.id"
+                          :label="item.conversionUnit"
+                          :value="item.id"
+                        >
+                        </el-option>
+                      </el-select>
+                    </el-form-item>
+                  </el-col>
                   <el-col
                     :span="4"
                     style="text-align: right"
@@ -442,6 +520,8 @@
           { label: '批次号', prop: 'batchNo', align: 'center', width: 120 },
           { label: '发货条码', prop: 'barcodes', align: 'center' },
           { label: '包装编码', prop: 'packageNo', align: 'center' },
+          { label: '包装数量', prop: 'packingQuantity', align: 'center' },
+          { label: '包装单位', prop: 'packingUnit', align: 'center' },
           { label: '计量数量', prop: 'measureQuantity', align: 'center' },
           { label: '计量单位', prop: 'measureUnit', align: 'center' },
           { label: '物料代号', prop: 'materielDesignation', align: 'center' },
@@ -450,6 +530,7 @@
           // { prop: 'specification', label: '规格', align: 'center', width: 100, showOverflowTooltip: true },
           // { prop: 'brandNum', label: '牌号', align: 'center', width: 100, showOverflowTooltip: true },
           // { prop: 'modelType', label: '型号', align: 'center', width: 100, showOverflowTooltip: true },
+
           { label: '重量', prop: 'weight', align: 'center' },
           { label: '重量单位', prop: 'weightUnit', align: 'center' },
           { label: '仓库', prop: 'warehouseName', align: 'center' },
@@ -498,7 +579,8 @@
         formData: {
           number: 1,
           sampleUnit: '',
-          portion: null
+          portion: null,
+          packingUnit: ''
         },
         rules: {
           number: [
@@ -521,6 +603,13 @@
               message: '请输入',
               trigger: 'blur'
             }
+          ],
+          packingUnit: [
+            {
+              required: true,
+              message: '请选择',
+              trigger: 'change'
+            }
           ]
         },
         isScheme: true,
@@ -541,9 +630,21 @@
         isPackingList: true,
         isSchemeList: true,
         newSampleList: [],
-        kkconditionType: ''
+        kkconditionType: '',
+        packingSpecificationOption: [] // 包装规格下拉
       };
     },
+    watch: {
+      // 样品清单
+      sampleList: {
+        handler(newVal) {
+          // 计算重量跟数量
+          this.calculate(newVal);
+        },
+        deep: true,
+        immediate: true
+      }
+    },
     computed: {
       tableColumns() {
         let arr = [
@@ -642,7 +743,14 @@
         ];
         return arr;
       },
-
+      sampletypeVal() {
+        return (row) => {
+          if (row == 1) {
+            return '整样';
+          }
+          return '小样';
+        };
+      },
       //分页后的来源列表
       paginatedSourceList() {
         console.log('分页', this.sourceList);
@@ -678,6 +786,78 @@
 
     created() {},
     methods: {
+      //
+      calculate(list) {
+        // if (list.length == 0) {
+        //   this.baseForm.sampleQuantity = 0;
+        //   this.baseForm.sampleWeight = 0;
+        // }
+        let sampleQuantity = 0; // 样品数量
+        let sampleWeight = 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;
+          // }
+        });
+         this.$set(this.baseForm, 'sampleQuantity', sampleQuantity); // 样品数量
+        this.$set(this.baseForm, 'sampleWeight', sampleWeight); // 样品重量
+        // // 计算合格率和不合格率(百分比形式)
+        // 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) {
         // if (
@@ -783,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 = [];
@@ -1017,17 +1198,72 @@
           pageNum: 1,
           size: -1
         });
+        if (listData.list.length == 0) {
+          this.sourceList = [];
+          return;
+        }
+
+        // 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;
-        console.log(this.sourceList);
       },
-
+      // 处理来源清单数据
+      proceSources(arr) {
+        let list = arr;
+        let o = list[0];
+        let listArr = [];
+        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'
+          });
+        }
+        list.map((el) => {
+          el.weightProportion = el.weight
+            ? (el.weight / el.measureQuantity).toFixed(4)
+            : 0;
+          el.weightProportion = el.weightProportion - 0;
+        });
+        this.packingSpecificationOption = listArr;
+        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;
@@ -1047,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;
       },
@@ -1133,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;
@@ -1168,6 +1403,7 @@
           //处理样品清单
           console.log('处理来源清单数据');
           // await this.handleSampleList();
+          _arr1 = this.proceSources(_arr1);
           await this.updatePackingList(_arr1);
         } else {
           console.log('来料清单数据为空');
@@ -1879,7 +2115,12 @@
       // },
 
       //从来源数组取样到目标数组
-      async getNewFullSampleList(sampleCount, sampleQuantity, sampleUnit) {
+      async getNewFullSampleList(
+        sampleCount,
+        sampleQuantity,
+        sampleUnit,
+        specifications
+      ) {
         console.log(
           '从来源数组取样到目标数组',
           sampleCount,
@@ -1958,6 +2199,21 @@
 
         console.log('样品清单', this.sampleList);
         console.log('样品清单List', result);
+        // 判断是不是取整样
+        if (
+          this.baseForm.conditionType == 1 &&
+          specifications &&
+          specifications.id
+        ) {
+          result.map((el) => {
+            el.measureQuantity =
+              el.measureQuantity * specifications.packageCellTotal;
+            el.weight = this.formatNumber(
+              el.measureQuantity,
+              el.weightProportion
+            );
+          });
+        }
         this.sampleList = result;
 
         this.samplePagination.total = result.length;
@@ -1967,6 +2223,25 @@
         this.changeSamUnit(sampleUnit);
       },
 
+      // 小数点数据判断
+      formatNumber(a, b, maxDecimals = 4) {
+        if (a == 0 || b == 0 || !a || !b) {
+          return 0;
+        }
+        // 计算乘积
+        const product = a * b;
+        // 转换为固定小数位数,然后转换为数字以去除末尾零
+        const rounded = Number(product.toFixed(maxDecimals));
+        // 转换为字符串检查是否需要显示小数部分
+        const str = rounded.toString();
+        // 如果包含小数点
+        if (str.indexOf('.') !== -1) {
+          // 移除末尾的零和小数点(如果后面没有数字了)
+          return str.replace(/\.?0+$/, '');
+        }
+        return str;
+      },
+
       //抽样确认按钮事件-样品列表右上角确认按钮
       handleSampleSubmit() {
         this.$refs.ruleForm.validate((valid) => {
@@ -2413,11 +2688,24 @@
           const sampleCount = Number(this.formData.portion);
           const measureQ = this.formData.number || 1;
           const unit = this.formData.sampleUnit;
+          let specifications = this.packingSpecificationOption.find(
+            (el) => el.id == this.formData.packingUnit
+          );
           // console.log(this.conditionType, this.baseForm.inspectionStandards);
           // console.log(this.isStandard1OrWeightSample())
           // console.log(this.isWeightStandardFullSample())
           try {
             if (this.isStandard1OrWeightSample()) {
+              // 新增校验 数量  取整样 ***
+              console.log(this.baseForm.conditionType,'33333333333')
+              if (this.conditionType == 1) {
+                let isFlag = this.validateSampleQuantity(
+                  sampleCount,
+                  specifications
+                );
+                if (!isFlag) return;
+              }
+              // ***
               //抽检计量整样小样或者抽检计重小样
               if (!this.validateMeasureQuantity(measureQ, unit, sampleCount))
                 return;
@@ -2425,19 +2713,20 @@
                 return; // 若计量单位为重量,还需验证总重量是否足够
               console.log('getNewFullSampleList');
               if (this.conditionType == '1' && this.baseForm.type == '3') {
-                await this.handleWeightFullSample(sampleCount);
+                await this.handleWeightFullSample(sampleCount, specifications);
               } else {
                 await this.getNewFullSampleList(
                   Math.ceil(sampleCount),
                   measureQ,
-                  unit
+                  unit,
+                  specifications
                 );
               }
             } else if (this.isWeightStandardFullSample()) {
-              console.log('handleWeightFullSample');
               //抽检取计重取整样
-              if (!this.validateSampleCount(sampleCount)) return;
-              await this.handleWeightFullSample(sampleCount);
+              if (!this.validateSampleCount(sampleCount, specifications))
+                return;
+              await this.handleWeightFullSample(sampleCount, specifications);
             }
             this.activeName = '2';
           } catch (error) {
@@ -2446,6 +2735,28 @@
           }
         });
       },
+      // 当计量类型 是数量的时候 取整样 校验
+      validateSampleQuantity(sampleCount, specifications) {
+        let packingUnit = this.selectedList[0].packingUnit.trim();
+        let totalS = 0;
+        let labelKey =
+          packingUnit == specifications.conversionUnit.trim()
+            ? 'packingQuantity'
+            : 'measureQuantity';
+        let labelName = labelKey == 'packingQuantity' ? '包装数量' : '计量数量';
+        totalS = this.selectedList.reduce(
+          (total, el) => total + el[labelKey],
+          0
+        );
+
+        if (sampleCount > totalS) {
+          this.$message.info(
+            `所填的条目数量不能超过所选${labelName}总和${totalS}`
+          );
+          return false;
+        }
+        return true;
+      },
       validateSelection() {
         if (!this.selectedList?.length) {
           this.$message.warning('请先选择样品!');
@@ -2537,7 +2848,7 @@
         return true;
       },
 
-      validateSampleCount(sampleCount) {
+      validateSampleCount(sampleCount, specifications) {
         // const invalidItem = this.selectedList.find(
         //   (item) => item.measureQuantity < sampleCount
         // );
@@ -2545,7 +2856,12 @@
         // const totalNumber = this.sourceList.reduce((acc, pro) => {
         //   return pro.measureQuantity ? acc + Number(pro.measureQuantity) : acc;
         // }, 0);
-
+        // 新增校验 ***
+        let isFlag = this.validateSampleQuantity(sampleCount, specifications);
+        if (!isFlag) {
+          return false;
+        }
+        // ***
         const chooseNumber = this.selectedList.reduce((acc, pro) => {
           return pro.measureQuantity ? acc + Number(pro.measureQuantity) : acc;
         }, 0);
@@ -2559,7 +2875,7 @@
         return true;
       },
 
-      async handleWeightFullSample(sampleCount) {
+      async handleWeightFullSample(sampleCount, specifications) {
         // console.log(sampleCount, 'sampleCount');
         // console.log(this.selectedList, 'this.selectedList');
         let currentNum = sampleCount - this.selectedList.length;
@@ -2627,6 +2943,20 @@
         // } else {
         //   await this.updatePackingList(list);
         // }
+        // 更改 从新计算 样品清单 取整样 数据
+        if (specifications && specifications.id) {
+          // let proportion = (obj.weight / obj.measureQuantity).toFixed(2);
+          console.log(list, 'dataList 这里是重量');
+          console.log(specifications, 'specifications ===');
+          list.map((el) => {
+            el.measureQuantity =
+              el.measureQuantity * specifications.packageCellTotal;
+            el.weight = this.formatNumber(
+              el.measureQuantity,
+              el.weightProportion
+            );
+          });
+        }
         await this.updatePackingList(list);
       },
       handDel(index) {

+ 57 - 36
src/views/inspectionWork/components/baseInfo.vue

@@ -70,6 +70,24 @@
         </el-form-item>
       </el-col>
       <el-col :span="6">
+        <el-form-item label="计量类型" prop="inspectionStandards">
+          <!-- 计量 计重 -->
+          <el-select
+            style="width: 100%"
+            v-model="form.inspectionStandards"
+            placeholder="请选择"
+            :disabled="true"
+          >
+            <el-option
+              v-for="item in inspectionStandardsList"
+              :label="item.label"
+              :value="item.value"
+              :key="item.value"
+            ></el-option>
+          </el-select>
+        </el-form-item>
+      </el-col>
+      <!-- <el-col :span="6">
         <el-form-item label="总数量:" prop="total">
           <el-input
             type="number"
@@ -78,7 +96,7 @@
             disabled
           />
         </el-form-item>
-      </el-col>
+      </el-col> -->
     </el-row>
     <!-- <div style="text-align: right; margin-bottom: 22px">
       <div @click="toggleExpand">
@@ -143,10 +161,11 @@
       <el-row>
         <el-col :span="6">
           <el-form-item label="合格数:" prop="qualifiedNumber">
+            <!--  :disabled="btnType == 'detail'" -->
             <el-input
               type="number"
               :min="0"
-              :disabled="btnType == 'detail'"
+              disabled
               @input="limitation('qualifiedNumber')"
               @blur="quantityCalculation"
               v-model="form.qualifiedNumber"
@@ -156,10 +175,11 @@
         </el-col>
         <el-col :span="6">
           <el-form-item label="不合格数:" prop="noQualifiedNumber">
+            <!--  :disabled="btnType == 'detail'" -->
             <el-input
               type="number"
               :min="0"
-              :disabled="btnType == 'detail'"
+              disabled
               @input="limitation('noQualifiedNumber')"
               @blur="quantityCalculation"
               v-model="form.noQualifiedNumber"
@@ -189,21 +209,13 @@
           </el-form-item>
         </el-col>
         <el-col :span="6">
-          <el-form-item label="计量类型" prop="inspectionStandards">
-            <!-- 计量 计重 -->
-            <el-select
-              style="width: 100%"
-              v-model="form.inspectionStandards"
-              placeholder="请选择"
-              :disabled="true"
-            >
-              <el-option
-                v-for="item in inspectionStandardsList"
-                :label="item.label"
-                :value="item.value"
-                :key="item.value"
-              ></el-option>
-            </el-select>
+          <el-form-item label="总数量:" prop="total">
+            <el-input
+              type="number"
+              v-model="form.total"
+              @input="inputTotal"
+              disabled
+            />
           </el-form-item>
         </el-col>
         <el-col :span="6">
@@ -215,7 +227,7 @@
               v-model="form.qualityMode"
               placeholder="请选择"
             >
-            <!-- :disabled="
+              <!-- :disabled="
                 parseInt(qualityType1) == 1 || parseInt(qualityType1) == 3
               " -->
               <el-option
@@ -272,11 +284,12 @@
         <el-col :span="6">
           <!-- <el-form-item label="质检结果:" prop="qualityResults" v-if="form.qualityMode == 2"> -->
           <el-form-item label="质检结果:" prop="qualityResults">
+            <!--    :disabled="btnType == 'detail'" -->
             <el-select
               v-model="form.qualityResults"
               placeholder="请选择"
               style="width: 100%"
-              :disabled="btnType == 'detail'"
+              disabled
             >
               <el-option label="合格" :value="1" />
               <el-option label="不合格" :value="2" />
@@ -325,6 +338,18 @@
           </el-form-item>
         </el-col> -->
 
+        <!--  总数量 减去 样品数量 *** -->
+        <!--   -->
+        <!-- <el-col :span="6">
+          <el-form-item label="质检结果数量:" prop="resultsTotal">
+            <el-input
+              type="number"
+              v-model="form.resultsTotal"
+              @input="inputTotal"
+              disabled
+            />
+          </el-form-item>
+        </el-col> -->
         <el-col :span="6">
           <el-form-item label="备注:" prop="remark">
             <el-input
@@ -471,17 +496,18 @@
       },
       // *** 计算合格数 不合格数
       quantityCalculation() {
-        let qualifiedNumber = this.form.qualifiedNumber - 0;
-        let noQualifiedNumber = this.form.noQualifiedNumber - 0;
-        let total = qualifiedNumber + noQualifiedNumber;
-        let passRate = ((qualifiedNumber / total) * 100).toFixed(2);
-        let failureRate = ((noQualifiedNumber / total) * 100).toFixed(2);
-        this.form.qualificationRate = passRate + '%';
-        this.form.noQualificationRate = failureRate + '%';
-        if (total != this.form.total) {
-          this.$message.warning('合格数加上不合格数需要等于总数量');
-          return false;
-        }
+        // let qualifiedNumber = this.form.qualifiedNumber - 0;
+        // let noQualifiedNumber = this.form.noQualifiedNumber - 0;
+        // let total = qualifiedNumber + noQualifiedNumber;
+        // let passRate = ((qualifiedNumber / total) * 100).toFixed(2);
+        // let failureRate = ((noQualifiedNumber / total) * 100).toFixed(2);
+        // this.form.qualificationRate = passRate + '%';
+        // this.form.noQualificationRate = failureRate + '%';
+        // if (total != this.form.total) {
+        //   this.$message.warning('合格数加上不合格数需要等于总数量');
+        //   return false;
+        // }
+        // return true;
         return true;
       },
 
@@ -503,8 +529,6 @@
             label: item[values[0]]
           };
         });
-
-        console.log(this.inspectionStandardsList, '2222222222222222');
       },
       async getQualityModeList(code) {
         let { data: res } = await getByCode(code);
@@ -601,7 +625,6 @@
       },
       handleChangeNumber(val) {
         this.form.sampleNumber = val;
-        console.log(val);
         this.$emit('changeNumber', val);
       },
 
@@ -619,11 +642,9 @@
       },
       //解决换检验方式的时候
       changeQualityMode(val) {
-        console.log(val, 'isInfoChangeModel');
         if (val) {
           this.$emit('changeModel', val);
         } else {
-          console.log('清空table2数据');
           this.$emit('table2');
         }
       }

+ 118 - 25
src/views/inspectionWork/components/newQualityContentTabs.vue

@@ -14,13 +14,13 @@
         @click="$emit('batch-quality')"
         >批量质检</el-button
       >
-      <el-button
+      <!-- <el-button
         type="primary"
         :loading="loading"
         v-if="type != 'detail'"
         @click="$emit('batch-dispose')"
         >批量处置</el-button
-      >
+      > -->
     </header-title>
 
     <el-tabs v-model="activeNameKK" @tab-click="handleClick">
@@ -95,7 +95,7 @@
                     ></el-input>
                   </el-form-item>
                 </el-col>
-                <el-col :span="20" v-if="conditionType == 1">
+                <el-col :span="10" v-if="conditionType == 1">
                   <el-form-item prop="portion" label="数量" style="margin: 0">
                     <el-input
                       v-model="formData.portion"
@@ -104,6 +104,26 @@
                     ></el-input>
                   </el-form-item>
                 </el-col>
+                <el-col :span="10" v-if="conditionType == 1">
+                  <el-form-item
+                    prop="packingUnit"
+                    label="单位"
+                    style="margin: 0"
+                  >
+                    <el-select
+                      v-model="formData.packingUnit"
+                      placeholder="请选择"
+                    >
+                      <el-option
+                        v-for="item in packingSpecificationOption"
+                        :key="item.id"
+                        :label="item.conversionUnit"
+                        :value="item.id"
+                      >
+                      </el-option>
+                    </el-select>
+                  </el-form-item>
+                </el-col>
                 <el-col
                   :span="4"
                   style="text-align: right"
@@ -304,12 +324,12 @@
               >
                 质检
               </el-link>
-              <el-link
+              <!-- <el-link
                 type="primary"
                 :underline="false"
                 @click="handleDispose(scope.$index, scope.row, 'dispose')"
                 >处置
-              </el-link>
+              </el-link> -->
             </template>
           </el-table-column>
         </el-table>
@@ -430,6 +450,10 @@
 
 <script>
   import inspectionTemplateDialog from '@/views/inspectionTemplate/components/inspectionTemplateDialog.vue';
+  import {
+    getDetails,
+    getCategoryPackageDisposition
+  } from '@/api/classifyManage/itemInformation';
   import {
     save,
     update,
@@ -447,7 +471,6 @@
     watch: {
       schemeList: {
         handler(newVal, oldVal) {
-          console.log('213123131');
           this.templateList = newVal;
           // console.log(newVal, 'schemeList');
         },
@@ -469,7 +492,11 @@
       form: Object,
       ids: String,
       activeName: String,
-      status: Boolean
+      status: Boolean,
+      productId: {
+        type: String,
+        default: ''
+      }
     },
     data() {
       return {
@@ -527,7 +554,7 @@
           { label: '批次号', prop: 'batchNo', align: 'center' },
           { label: '发货条码', prop: 'barcodes', align: 'center' },
           { label: '包装编码', prop: 'packageNo', align: 'center' },
-          // { label: '包装数量', prop: 'packingQuantity', align: 'center' },
+          { label: '包装数量', prop: 'packingQuantity', align: 'center' },
           { label: '包装单位', prop: 'packingUnit', align: 'center' },
           { label: '计量数量', prop: 'measureQuantity', align: 'center' },
           { label: '计量单位', prop: 'measureUnit', align: 'center' },
@@ -589,7 +616,8 @@
         formData: {
           number: 1,
           sampleUnit: '',
-          portion: null
+          portion: null,
+          packingUnit: ''
         },
         rules: {
           number: [
@@ -612,8 +640,16 @@
               message: '请输入',
               trigger: 'blur'
             }
+          ],
+          packingUnit: [
+            {
+              required: true,
+              message: '请选择',
+              trigger: 'change'
+            }
           ]
-        }
+        },
+        packingSpecificationOption: [] // 包装规格下拉
       };
     },
 
@@ -671,6 +707,12 @@
           },
           { label: '包装数量', prop: 'packingQuantity', align: 'center' },
           { label: '包装单位', prop: 'packingUnit', align: 'center' },
+          // {
+          //   label: '包装规格',
+          //   prop: 'packingSpecification',
+          //   align: 'center',
+          //   width: 180
+          // },
           { label: '计量数量', prop: 'measureQuantity', align: 'center' },
           { label: '计量单位', prop: 'measureUnit', align: 'center' },
           { label: '物料代号', prop: 'materielDesignation', align: 'center' },
@@ -720,8 +762,6 @@
       },
       // 分页后的样品列表
       paginatedSampleList() {
-        console.log(this.sampleList);
-
         const { currentPage, pageSize } = this.samplePagination;
         const start = (currentPage - 1) * pageSize;
         const end = start + pageSize;
@@ -744,7 +784,6 @@
       let direction = this.$getDirection();
 
       direction.on('keyup', function (e, val) {
-        console.log(val);
         if (e.keyCode == 39) {
           direction.next();
         }
@@ -766,9 +805,69 @@
           pageNum: page,
           size: limit
         });
+        if (res.list.length == 0) {
+          return res;
+        }
+        // 包装数量的字段
+        // if (!this.productId) {
+        //   return res;
+        // }
+
+        // const result = await getCategoryPackageDisposition({
+        //   categoryIds: [this.productId]
+        // });
+
+        // let str = '';
+        // if (result.length) {
+        let o = res.list[0];
+        let listArr = [];
+        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'
+          });
+        }
+        // result.map((el, index) => {
+        //   // let Unit = el.conversionUnit.trim();
+
+        //   // if (Unit == o.packingUnit.trim() || Unit == o.measureUnit.trim()) {
+
+        //   //   listArr.push(el);
+        //   // }
+        //   if (index == 0) {
+        //     // el.packageCellTotal = el.packageCell - 0;
+        //     return;
+        //   }
+        //   if (index === result.length - 1) {
+        //     str = `${str}${el.packageCell}${el.packageUnit}/${el.conversionUnit}`;
+        //   } else {
+        //     str = `${str}${el.packageCell}${el.packageUnit}/${el.conversionUnit},`;
+        //   }
+        //   // if (index == 1) {
+        //   //   el.packageCellTotal = el.packageCell - 0;
+        //   //   return;
+        //   // }
+        //   // 计算乘法的规则
+        //   // el.packageCellTotal =
+        //   //   el.packageCell * result[index - 1].packageCellTotal;
+        // });
+        res.list.map((el) => {
+          el.weightProportion = el.weight
+            ? (el.weight / el.measureQuantity).toFixed(4)
+            : 0;
+          el.weightProportion = el.weightProportion - 0;
+        });
+        this.packingSpecificationOption = listArr;
         return res;
       },
-
       reload(where) {
         this.$nextTick(() => {
           if (this.$refs.sourceTable && this.$refs.sourceTable.reload)
@@ -777,7 +876,6 @@
       },
 
       tableSelClear() {
-        console.log('清空勾选');
         this.$refs.sourceTable.clearSelection();
       },
       handleSelectionChange(selection) {
@@ -803,8 +901,6 @@
       },
 
       handleSampleNumber(val) {
-        console.log('取样方式选择', this.form.isUnpack);
-        console.log(val, 'val');
         this.conditionType = val;
         this.form.sampleUnit = '';
         this.$emit('getConditionType', val);
@@ -838,7 +934,6 @@
         }
       },
       handleInput(val) {
-        debugger;
         if (val == 0 || val == '' || val == null) {
           this.$refs.sourceTable.clearSelection();
           return;
@@ -856,7 +951,6 @@
         const portion = Number(this.formData.portion);
         // 清空当前选中
         this.$refs.sourceTable.clearSelection();
-        debugger;
         if (this.form.conditionType == 2) {
           // 确保 portion 不超过数据列表长度
           const safePortion = Math.min(portion, packingList.length);
@@ -907,7 +1001,6 @@
         // }
       },
       changeSamUnit(val) {
-        console.log(val, 'dddd');
         this.$emit('changeSamUnit', val);
       },
       handleSampleSubmit() {
@@ -922,13 +1015,16 @@
               sampleUnit: this.formData.sampleUnit,
               portion: this.formData.portion
             };
-            this.$emit('handleSampleSubmit', params);
+            let specifications = this.packingSpecificationOption.find(
+              (el) => el.id == this.formData.packingUnit
+            );
+            console.log('执行这里没', params, '---');
+            this.$emit('handleSampleSubmit', params, specifications);
           }
         });
       },
 
       handleClick(tab) {
-        console.log(tab, 'tab');
         this.activeNameKK = tab.name;
       },
       tabsChange(val) {
@@ -972,8 +1068,6 @@
         this.$refs.inspectionTemplateRef.open(2);
       },
       async inspectionTemplateSuccess(select) {
-        console.log(select);
-
         let data = await getQualityTemplateByIds({
           templateIds: select.map((item) => item.id)
         });
@@ -1013,7 +1107,6 @@
         this.schemePagination.total = this.templateList.length;
       },
       handDel(index) {
-        console.log(index);
         this.templateList.splice(index, 1);
         this.sampleList.forEach((item, index) => {
           this.$set(

+ 4 - 3
src/views/inspectionWork/components/sampleListDialog.vue

@@ -127,7 +127,7 @@
           </template> -->
         </el-table-column>
       </template>
-      <el-table-column label="操作" align="center" width="80">
+      <!-- <el-table-column label="操作" align="center" width="80">
         <template slot-scope="scope">
           <el-link
             :underline="false"
@@ -137,7 +137,7 @@
             处置
           </el-link>
         </template>
-      </el-table-column>
+      </el-table-column> -->
     </el-table>
     <template v-slot:footer v-if="type == 'report'">
       <el-button @click="handleClose">取消</el-button>
@@ -242,7 +242,8 @@
               list[0].qualityResults;
           }
         }
-        this.tableData = list;
+        this.tableData = JSON.parse(JSON.stringify(list));
+        console.log( this.tableData,'33333333333333333');
 
         this.visible = true;
       },

+ 0 - 2
src/views/inspectionWork/components/toolButtom.vue

@@ -57,7 +57,6 @@
     watch: {
       value: {
         handler(newVal) {
-          console.log(newVal, '=======');
           this.selectVal = newVal || [];
         },
         immediate: true
@@ -66,7 +65,6 @@
     created() {},
     methods: {
       handleUpload() {
-        console.log(this.sList, '选择质检工具列表======');
         this.$refs.toolListRef.open(this.selectVal,this.type,this.sList);
       },
       getFiles(val = []) {

+ 258 - 77
src/views/inspectionWork/edit.vue

@@ -28,8 +28,65 @@
         @changeNumber="changeNumber"
         @changeInspectionStandardsModel="changeInspectionStandardsModel"
       ></base-info>
-
+      <header-title title="样品信息"></header-title>
+      <el-form label-width="110px">
+        <el-row>
+          <el-col :span="6">
+            <el-form-item label="样品合格数:" prop="sampleQualifiedNumber">
+              <el-input
+                type="number"
+                :min="0"
+                disabled
+                v-model="form.sampleQualifiedNumber"
+                placeholder=""
+              ></el-input>
+            </el-form-item>
+          </el-col>
+          <el-col :span="6">
+            <el-form-item label="样品不合格数:" prop="sampleNoQualifiedNumber">
+              <el-input
+                type="number"
+                :min="0"
+                disabled
+                v-model="form.sampleNoQualifiedNumber"
+                placeholder=""
+              ></el-input>
+            </el-form-item>
+          </el-col>
+          <el-col :span="6">
+            <el-form-item label="样品合格率:" prop="sampleQualificationRate">
+              <el-input v-model="form.sampleQualificationRate" disabled />
+            </el-form-item>
+          </el-col>
+          <el-col :span="6">
+            <el-form-item
+              label="样品不合格率:"
+              prop="sampleNoQualificationRate"
+            >
+              <el-input v-model="form.sampleNoQualificationRate" disabled />
+            </el-form-item>
+          </el-col>
+        </el-row>
+        <el-row>
+          <el-col :span="6">
+            <el-form-item label="样品类型:" prop="samplesType">
+              <el-input disabled :value="sampletypeVal(form.conditionType)" />
+            </el-form-item>
+          </el-col>
+          <el-col :span="6">
+            <el-form-item label="样品数量:" prop="sampleQuantity">
+              <el-input type="number" disabled v-model="form.sampleQuantity" />
+            </el-form-item>
+          </el-col>
+          <el-col :span="6">
+            <el-form-item label="样品重量:" prop="sampleWeight">
+              <el-input type="number" disabled v-model="form.sampleWeight" />
+            </el-form-item>
+          </el-col>
+        </el-row>
+      </el-form>
       <quality-content-tabs
+        v-if="form.id"
         ref="tabsRef"
         :type="type"
         :ids="this.$route.query.id"
@@ -38,6 +95,7 @@
         :scheme-list="schemeList"
         :loading="loading"
         :form="form"
+        :productId="productId"
         :status="statusType"
         @handleSelectionChange="handleSelectionChange1"
         @batch-quality="batchQuality"
@@ -102,7 +160,21 @@
       sampleDisposeDialog
     },
     mixins: [dictMixins],
-
+    computed: {
+      sampletypeVal() {
+        return (row) => {
+          if (row == 1) {
+            return '整样';
+          }
+          return '小样';
+        };
+      }
+    },
+    // p:{
+    //   sampletypeVal()=>{
+    //     return
+    //   }
+    // },
     data() {
       const defaultForm = function () {
         return {
@@ -181,6 +253,15 @@
             this.form = { ...defaultForm() };
           }
         }
+      },
+      // 样品清单
+      sampleList: {
+        handler(newVal) {
+          // 计算重量跟数量
+          this.calculate(newVal);
+        },
+        deep: true,
+        immediate: true
       }
     },
 
@@ -191,10 +272,76 @@
       }
     },
     methods: {
+      //
+      calculate(list) {
+        if (list.length == 0) {
+          this.form.sampleQuantity = 0;
+          this.form.sampleWeight = 0;
+        }
+        let sampleQuantity = 0; // 样品数量
+        let sampleWeight = 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;
+          }
+        });
+        // 计算合格率和不合格率(百分比形式)
+        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.form.total - sampleQuantity;
+        if (sampleQuantity == sampleQualifiedNumber) {
+          this.$set(this.form, 'qualifiedNumber', resultsTotal);
+          this.$set(this.form, 'noQualifiedNumber', 0);
+          this.$set(this.form, 'qualificationRate', '100%');
+          this.$set(this.form, 'noQualificationRate', '0');
+          this.$set(this.form, 'qualityResults', 1);
+        } else {
+          this.$set(this.form, 'noQualifiedNumber', resultsTotal);
+          this.$set(this.form, 'qualifiedNumber', 0);
+          this.$set(this.form, 'qualificationRate', '0');
+          this.$set(this.form, 'noQualificationRate', '100%');
+          this.$set(this.form, 'qualityResults', 2);
+        }
+        // this.$set(this.form, 'resultsTotal', resultsTotal);
+        this.$set(
+          this.form,
+          'sampleQualificationRate',
+          sampleQualificationRate
+        );
+        this.$set(
+          this.form,
+          'sampleNoQualificationRate',
+          sampleNoQualificationRate
+        );
+        this.$set(this.form, 'sampleQuantity', sampleQuantity);
+        this.$set(this.form, 'sampleWeight', sampleWeight);
+        this.$set(this.form, 'sampleQualifiedNumber', sampleQualifiedNumber);
+        this.$set(
+          this.form,
+          'sampleNoQualifiedNumber',
+          sampleNoQualifiedNumber
+        );
+      },
       //切换检验方式
       changeModel(val, flag) {
-        console.log('切换检验方式');
-
         this.$refs.tabsRef.tableSelClear();
         this.sampleList = [];
         this.$refs.tabsRef.tabsChange('1');
@@ -218,14 +365,11 @@
         if (this.qualityType == 2) {
           if (this.form.qualityMode != null) {
             const ProductSampleList = [];
-            console.log(list, 'list');
             for (const oldItem of list) {
               const count = oldItem.measureQuantity;
               const newMeasureQuantity = oldItem.measureQuantity / count;
               const newWeight = parseFloat((oldItem.weight / count).toFixed(2));
 
-              console.log(typeof oldItem.qualitySampleTemplateList, 'ssssss');
-
               // 遍历新数组设置 qualityResults 默认值
               this.schemeList.forEach((item) => {
                 if (typeof item === 'object' && item !== null) {
@@ -234,8 +378,6 @@
                 delete item.id;
               });
 
-              console.log(oldItem, 'oldItem');
-              console.log(count, newMeasureQuantity, newWeight);
               delete oldItem.id;
 
               if (
@@ -257,7 +399,6 @@
                     )
                   });
                 }
-                console.log(ProductSampleList, 'ProductSampleList');
                 this.sampleList = ProductSampleList;
                 const pNum = ProductSampleList.reduce((sum, item) => {
                   return sum + Number(item.weight || 0);
@@ -275,7 +416,6 @@
                     )
                   });
                 }
-                console.log(ProductSampleList, 'ProductSampleList');
                 this.sampleList = ProductSampleList;
                 const pNum = ProductSampleList.reduce((sum, item) => {
                   return sum + Number(item.weight || 0);
@@ -292,18 +432,13 @@
       // 创建计量数量为1的样品清单函数,用于计数类型的
       async createSampleList(list) {
         if (this.form.qualityMode != null) {
-          console.log('sssssjijdiajdia');
-
           this.$message('正在生成样品清单');
           const ProductSampleList = [];
-          console.log(list, 'list');
           for (const oldItem of list) {
             const count = oldItem.measureQuantity;
             const newMeasureQuantity = oldItem.measureQuantity / count;
             const newWeight = parseFloat((oldItem.weight / count).toFixed(2));
 
-            console.log(typeof oldItem.qualitySampleTemplateList, 'ssssss');
-
             // 遍历新数组设置 qualityResults 默认值
             this.schemeList.forEach((item) => {
               if (typeof item === 'object' && item !== null) {
@@ -311,11 +446,7 @@
               }
               delete item.id;
             });
-
-            console.log(oldItem, 'oldItem');
-            console.log(count, newMeasureQuantity, newWeight);
             delete oldItem.id;
-
             if (
               oldItem.qualitySampleTemplateList == undefined ||
               oldItem.qualitySampleTemplateList == null ||
@@ -335,7 +466,6 @@
                   )
                 });
               }
-              console.log(ProductSampleList, 'ProductSampleList');
               this.sampleList = ProductSampleList;
               const pNum = ProductSampleList.reduce((sum, item) => {
                 return sum + Number(item.weight || 0);
@@ -353,7 +483,6 @@
                   )
                 });
               }
-              console.log(ProductSampleList, 'ProductSampleList');
               this.sampleList = ProductSampleList;
               const pNum = ProductSampleList.reduce((sum, item) => {
                 return sum + Number(item.weight || 0);
@@ -403,8 +532,6 @@
       // 切换检验方式为全检后生成样品
       changeGetSampleList(list) {
         this.$message('正在生成样品清单');
-        console.log(list);
-        console.log(this.form.total);
 
         // 计量类型1是数量,2是重量
         if (this.form.inspectionStandards == 1) {
@@ -439,7 +566,6 @@
             const count = oldItem.measureQuantity;
             const newMeasureQuantity = oldItem.measureQuantity / count;
             const newWeight = parseFloat((oldItem.weight / count).toFixed(2));
-            console.log(count, newMeasureQuantity, newWeight);
             delete oldItem.id;
             // 遍历新数组设置 qualityResults 默认值
             this.schemeList.forEach((item) => {
@@ -562,6 +688,7 @@
       async getDetail() {
         getById(this.$route.query.id).then((res) => {
           this.form = res.data;
+          this.productId = res.data.productId || '';
           this.statusType = this.form.status == 1 ? true : false;
 
           this.isReportProcessProduce =
@@ -700,8 +827,7 @@
           console.log(data, 'datadatadatadataxiaoyang');
         }
       },
-      async handleSampleSubmit(data) {
-        console.log(data, 'data123确认');
+      async handleSampleSubmit(data, specifications) {
         this.sampleList = [];
         if (!this.selectedList || this.selectedList.length == 0) {
           this.$message.warning('请先选择样品!');
@@ -710,28 +836,34 @@
         const measureQ = data.measureQ || 1;
         const unit = data.sampleUnit;
         const sampleCount = Number(data.portion);
-        console.log(measureQ, '计量数量');
-        console.log(unit, '所选单位');
-        console.log(sampleCount, '数量');
         try {
           if (this.isStandard1OrWeightSample()) {
+            // 新增校验 数量  取整样 ***
+            if (this.form.conditionType == 1) {
+              let isFlag = this.validateSampleQuantity(
+                sampleCount,
+                specifications
+              );
+              if (!isFlag) return;
+            }
+            // ***
             //抽检计量整样小样或者抽检计重小样
             if (!this.validateMeasureQuantity(measureQ, unit, sampleCount))
               return; //取样数量验证
             if (unit === 'KG' && !this.validateWeight(measureQ, sampleCount))
               return; // 若计量单位为重量,还需验证总重量是否足够
-            console.log(1111111111111);
-
             await this.getNewFullSampleList(
               Math.ceil(sampleCount),
               measureQ,
-              unit
+              unit,
+              specifications
             );
+            // 这里是取整样 非数量
           } else if (this.isWeightStandardFullSample()) {
+            console.log('这里是取整样 吗');
             //抽检取计重取整样
-            if (!this.validateSampleCount(sampleCount)) return;
-            console.log(222222222222222222);
-            await this.handleWeightFullSample(sampleCount);
+            if (!this.validateSampleCount(sampleCount, specifications)) return;
+            await this.handleWeightFullSample(sampleCount, specifications);
           }
           this.activeName = '2';
 
@@ -741,6 +873,28 @@
           this.$message.error('取样处理失败');
         }
       },
+      // 当计量类型 是数量的时候 取整样 校验
+      validateSampleQuantity(sampleCount, specifications) {
+        let packingUnit = this.selectedList[0].packingUnit.trim();
+        let totalS = 0;
+        let labelKey =
+          packingUnit == specifications.conversionUnit.trim()
+            ? 'packingQuantity'
+            : 'measureQuantity';
+        let labelName = labelKey == 'packingQuantity' ? '包装数量' : '计量数量';
+        totalS = this.selectedList.reduce(
+          (total, el) => total + el[labelKey],
+          0
+        );
+
+        if (sampleCount > totalS) {
+          this.$message.info(
+            `所填的条目数量不能超过所选${labelName}总和${totalS}`
+          );
+          return false;
+        }
+        return true;
+      },
       //获取样品编码
       async getSampleCode() {
         return await getCode('sample_code');
@@ -748,7 +902,6 @@
       async getNewSampleList(measureQ, unit, nums) {
         this.sampleList = [];
 
-        console.log(this.selectedList, 'this.selectedList');
         if (!this.selectedList || this.selectedList.length == 0) {
           this.$message.warning('请先选择来源清单!');
           return;
@@ -875,7 +1028,6 @@
             ...item
           };
         });
-        console.log(addStatus, '样品清单12123123');
         if (addStatus.length > 0) {
           this.sampleList = addStatus;
           this.addStatus = addStatus;
@@ -887,21 +1039,18 @@
         const res = await queryQualityTempleContent({
           qualityWorkerId: this.$route.query.id
         });
-        console.log(res, '质检方案');
         this.schemeList = res.list;
       },
       // 取样
       getConditionType(val) {
-        console.log(val, '------取样的回调');
-
         this.form.conditionType = val;
       },
 
       /* 保存编辑 */
       save() {
         // *** 新增判断
-        let flag = this.$refs.baseInfoRefs.quantityCalculation();
-        if (!flag) return;
+        // let flag = this.$refs.baseInfoRefs.quantityCalculation();
+        // if (!flag) return;
         // ***
         this.$refs.baseInfoRefs.$refs.form1.validate((valid) => {
           if (!valid) {
@@ -915,8 +1064,6 @@
 
           delete this.form['qualityTimeEnd'];
 
-          console.log(this.sampleList);
-
           let params = {
             ...this.form,
             sampleList: this.sampleList,
@@ -925,7 +1072,6 @@
             // qualityInventoryList: this.$refs.tabsRef.$refs.sourceTable.getData()
             qualityInventoryList: this.inventoryList
           };
-          console.log(params, 'params ----');
 
           URL(params)
             .then((msg) => {
@@ -964,7 +1110,6 @@
       },
       setSchemeList(list) {
         this.schemeList = list;
-        console.log(this.schemeList, 'this.schemeList');
       },
 
       handleDetail(index, row, type) {
@@ -994,8 +1139,6 @@
         );
       },
       inputWeight(row, index) {
-        console.log(row, index, '输入重量');
-
         // 计算所有样本的总重量
         const pNum = this.sampleList.reduce((sum, item) => {
           return sum + Number(item.weight || 0);
@@ -1003,7 +1146,6 @@
         this.form.totalWeight = parseFloat(pNum.toFixed(2));
       },
       handleDispose(data) {
-        console.log(data);
         // return
         this.rowData = data;
         this.sampleDisposeVisble = true;
@@ -1061,8 +1203,6 @@
           this.form.qualityTimeEnd = this.getNowTime();
           this.form.qualityTimeStart = this.qualityTimeStart;
 
-          console.log(this.form.qualityTimeStart, this.form.qualityTimeEnd);
-
           // if (this.form.qualityMode == 1) {
           //   this.form.qualityResults = '';
           // }
@@ -1074,7 +1214,6 @@
             // qualityInventoryList: this.$refs.tabsRef.$refs.sourceTable.getData()
             qualityInventoryList: this.inventoryList
           };
-          console.log(params, 'params');
 
           exeReportWork(params)
             .then((msg) => {
@@ -1090,9 +1229,6 @@
       },
       // 处理确认事件
       handleDisposeConfirm(data, index) {
-        console.log(data, index, '确认处置事件');
-        console.log(this.sampleList);
-
         if (index == undefined) {
           this.sampleList.forEach((obj) => {
             obj.disposeType = data.disposeType;
@@ -1107,13 +1243,9 @@
         } else {
           this.$set(this.sampleList, index, data);
         }
-
-        console.log(this.sampleList);
       },
       //确认质检
       handleConfirm(list, index) {
-        console.log(list);
-
         // 检查有效性
         // for (const item of list) {
         //   for (const child of item.qualitySampleTemplateList) {
@@ -1125,7 +1257,6 @@
         //     }
         //   }
         // }
-        console.log(list, 'listlistlistlist');
         list.forEach((item) => {
           if (item.qualitySampleTemplateList.length == 1) {
             if (
@@ -1168,14 +1299,11 @@
           this.$set(this.sampleList, null, list);
         }
         this.activeName = '2';
-        console.log(this.sampleList, '222表');
         // *** 选完批量质检调用
-        this.countQualityResults();
+        // this.countQualityResults();
       },
       // 批量质检
       batchQuality(index, row, type) {
-        console.log(this.form.templateList, 'this.form.templateList');
-
         // if (this.form.sampleList.qualitySampleTemplateList.length == 0) {
         //   this.form.sampleList.forEach((item, index) => {
         //     this.$set(
@@ -1267,7 +1395,12 @@
       },
 
       //从来源数组取样到目标数组
-      async getNewFullSampleList(sampleCount, sampleQuantity, sampleUnit) {
+      async getNewFullSampleList(
+        sampleCount,
+        sampleQuantity,
+        sampleUnit,
+        specifications
+      ) {
         const sourceArray = this.selectedList;
         // 检查单位是否匹配
         const isUnitMismatch =
@@ -1354,13 +1487,46 @@
             break;
           }
         }
+
+        // 判断是不是取整样
+        if (
+          this.form.conditionType == 1 &&
+          specifications &&
+          specifications.id
+        ) {
+          result.map((el) => {
+            el.measureQuantity =
+              el.measureQuantity * specifications.packageCellTotal;
+            el.weight = this.formatNumber(
+              el.measureQuantity,
+              el.weightProportion
+            );
+          });
+        }
         this.sampleList = result;
         if (this.sampleList.length > sampleCount) {
           this.sampleList = this.sampleList.splice(0, sampleCount);
         }
-
         this.form.sampleNumber = this.sampleList.length;
       },
+      // 小数点数据判断
+      formatNumber(a, b, maxDecimals = 4) {
+        if (a == 0 || b == 0 || !a || !b) {
+          return 0;
+        }
+        // 计算乘积
+        const product = a * b;
+        // 转换为固定小数位数,然后转换为数字以去除末尾零
+        const rounded = Number(product.toFixed(maxDecimals));
+        // 转换为字符串检查是否需要显示小数部分
+        const str = rounded.toString();
+        // 如果包含小数点
+        if (str.indexOf('.') !== -1) {
+          // 移除末尾的零和小数点(如果后面没有数字了)
+          return str.replace(/\.?0+$/, '');
+        }
+        return str;
+      },
       validateWeight(measureQ, sampleCount) {
         let totalMaxPossible = 0;
         this.selectedList.forEach((item) => {
@@ -1441,11 +1607,17 @@
         );
       },
 
-      validateSampleCount(sampleCount) {
+      // 抽检取整样 校验
+      validateSampleCount(sampleCount, specifications) {
+        // 新增校验 ***
+        let isFlag = this.validateSampleQuantity(sampleCount, specifications);
+        if (!isFlag) {
+          return false;
+        }
+        // ***
         const chooseNumber = this.selectedList.reduce((acc, pro) => {
           return pro.measureQuantity ? acc + Number(pro.measureQuantity) : acc;
         }, 0);
-
         const invalidItem = chooseNumber < sampleCount;
         // console.log(this.selectedList, 'this.selectedList');
         // const invalidItem = this.selectedList.find(
@@ -1455,17 +1627,14 @@
           this.$message.info('所选的条目计量数量小于取样计量数量');
           return false;
         }
+        // ***
         return true;
       },
 
-      async handleWeightFullSample(sampleCount) {
-        console.log(sampleCount);
-
+      async handleWeightFullSample(sampleCount, specifications) {
         const dataList = [];
         let currentNum = sampleCount - this.selectedList.length;
         let currentNum1 = sampleCount;
-        console.log(this.selectedList);
-
         for (const item of this.selectedList) {
           const qualitySampleTemplateList = item.qualitySampleTemplateList
             ?.length
@@ -1510,7 +1679,21 @@
             }
           });
         }
-
+        // 更改 从新计算 样品清单 取整样 数据
+        if (specifications && specifications.id) {
+          // let proportion = (obj.weight / obj.measureQuantity).toFixed(2);
+          console.log(dataList, 'dataList 这里是重量');
+          console.log(specifications, 'specifications ===');
+          dataList.map((el) => {
+            el.measureQuantity =
+              el.measureQuantity * specifications.packageCellTotal;
+            el.weight = this.formatNumber(
+              el.measureQuantity,
+              el.weightProportion
+            );
+          });
+        }
+        // 更改
         this.sampleList = dataList;
         this.sampleNumber = this.sampleList.length;
       },
@@ -1519,7 +1702,6 @@
       countQualityResults() {
         let sampleList = this.sampleList; //样品清单
         let sampleNumber = this.form.total; //样品总数
-        console.log(sampleList, sampleNumber, '=====');
         // let qualifiedNumber = sampleList.filter(item => item.qualityResults == 1 || item.qualityResults == 3).length;
         // let noQualifiedNumber = sampleList.filter(
         //   (item) => item.qualityResults == 2
@@ -1533,7 +1715,6 @@
             ? acc + Number(pro.measureQuantity)
             : acc;
         }, 0);
-        console.log(noQualifiedNumber, 'noQualifiedNumber');
         let qualifiedNumber = sampleNumber - noQualifiedNumber; //不合格数
         let qualificationRate = (
           (qualifiedNumber / sampleNumber) *

+ 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;
       }
     }