695593266@qq.com před 1 rokem
rodič
revize
a2e71081c3

+ 8 - 2
src/views/produce/components/feeding/components/paramBom.vue

@@ -20,14 +20,20 @@
           </div>
           <div
             class="item ww40"
-            v-if="it.textType != 3 || (it.extInfo && it.extInfo.textType != 3)"
+            v-if="
+              (it.textType && it.textType != 3) ||
+              (it.extInfo && it.extInfo.textType != 3)
+            "
           >
             {{ it.defaultValue || it.extInfo.defaultValue }}
           </div>
 
           <div
             class="item ww40"
-            v-if="it.textType == 3 || (it.extInfo && it.extInfo.textType == 3)"
+            v-if="
+              (it.textType && it.textType == 3) ||
+              (it.extInfo && it.extInfo.textType == 3)
+            "
           >
             {{ it.minValue || it.extInfo.minValue }} -
             {{ it.maxValue || it.extInfo.maxValue }}

+ 8 - 0
src/views/produce/components/new_produceOrder.vue

@@ -289,6 +289,14 @@
             minWidth: 130,
             sortable: true
           },
+          {
+            prop: 'endTime',
+            label: '实际结束时间',
+            align: 'center',
+            showOverflowTooltip: true,
+            minWidth: 130,
+            sortable: true
+          },
 
           {
             prop: 'createTime',

+ 61 - 45
src/views/produce/components/workPlan/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">
@@ -214,10 +226,10 @@
               style="width: 100%"
               v-model="form.qualityMode"
               placeholder="请选择"
-              :disabled="
-                parseInt(qualityType1) == 1 || parseInt(qualityType1) == 3
-              "
             >
+              <!-- :disabled="
+                parseInt(qualityType1) == 1 || parseInt(qualityType1) == 3
+              " -->
               <el-option
                 v-for="item in qualityModeList"
                 :label="item.label"
@@ -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,22 +496,18 @@
       },
       // *** 计算合格数 不合格数
       quantityCalculation() {
-        let qualifiedNumber = this.form.qualifiedNumber - 0;
-        let noQualifiedNumber = this.form.noQualifiedNumber - 0;
-        let total = qualifiedNumber + noQualifiedNumber;
-        let passRate = ((qualifiedNumber / this.form.total) * 100).toFixed(2);
-        let failureRate = ((noQualifiedNumber / this.form.total) * 100).toFixed(
-          2
-        );
-
-        console.log(passRate, failureRate, '合格率');
-        console.log(total, '总数');
-        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;
       },
 
@@ -508,8 +529,6 @@
             label: item[values[0]]
           };
         });
-
-        console.log(this.inspectionStandardsList, '2222222222222222');
       },
       async getQualityModeList(code) {
         let { data: res } = await getByCode(code);
@@ -592,8 +611,8 @@
       // 人员选择
       changeExecutor(val) {
         if (val) {
-          this.form.executeId = val;
-          this.form.executeName = this.executorList.filter(
+          this.form.qualityId = val;
+          this.form.qualityName = this.executorList.filter(
             (item) => item.id === val
           )[0].name;
         }
@@ -606,7 +625,6 @@
       },
       handleChangeNumber(val) {
         this.form.sampleNumber = val;
-        console.log(val);
         this.$emit('changeNumber', val);
       },
 
@@ -624,11 +642,9 @@
       },
       //解决换检验方式的时候
       changeQualityMode(val) {
-        console.log(val, 'isInfoChangeModel');
         if (val) {
           this.$emit('changeModel', val);
         } else {
-          console.log('清空table2数据');
           this.$emit('table2');
         }
       }

+ 141 - 45
src/views/produce/components/workPlan/components/newQualityContentTabs.vue

@@ -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"
@@ -233,31 +253,12 @@
           <!-- *** fixed="right"  -->
           <el-table-column
             label="处置状态"
-            prop="disposalStatus"
+            prop="disposeType"
             align="center"
             :show-overflow-tooltip="true"
           >
             <template slot-scope="scope">
-              <span
-                v-if="scope.row.disposalStatus == 1 && form.qualityType == 2"
-                >返工</span
-              >
-              <span
-                v-if="scope.row.disposalStatus == 2 && form.qualityType == 2"
-                >返修</span
-              >
-              <span v-if="scope.row.disposalStatus == 3">报废</span>
-              <span
-                v-if="scope.row.disposalStatus == 4 && form.qualityType == 2"
-                >降级使用</span
-              >
-              <span
-                v-if="scope.row.disposalStatus == 5 && form.qualityType == 2"
-                >让步接收</span
-              >
-              <span v-if="scope.row.disposalStatus == 6">留样</span>
-              <span v-if="scope.row.disposalStatus == 7">消耗</span>
-              <span v-if="scope.row.disposalStatus == 8">回用</span>
+              <span>{{ disposeTypeList[scope.row.disposeType] }}</span>
             </template>
           </el-table-column>
           <!-- ***  fixed="right" -->
@@ -345,6 +346,7 @@
       <!--  -->
       <el-tab-pane label="质检方案" name="3">
         <el-button
+          v-if="type !== 'detail'"
           @click="addInspectionTemplate"
           type="primary"
           style="margin-top: 5px"
@@ -407,7 +409,12 @@
             </template>
           </el-table-column>
 
-          <el-table-column fixed="right" label="操作" width="80">
+          <el-table-column
+            fixed="right"
+            label="操作"
+            width="80"
+            v-if="type !== 'detail'"
+          >
             <template slot-scope="scope">
               <el-popconfirm
                 class="ele-action"
@@ -443,6 +450,10 @@
 
 <script>
   import inspectionTemplateDialog from './inspectionTemplateDialog.vue';
+  import {
+    getDetails,
+    getCategoryPackageDisposition
+  } from '@/api/classifyManage/itemInformation';
   import {
     save,
     update,
@@ -452,7 +463,7 @@
     queryQualityTempleContent,
     queryQualityInventory
   } from '@/api/inspectionWork';
-  import { getQualityTemplateByIds } from '@/api/produce/workPlan';
+  import { getQualityTemplateByIds } from '@/api/produce/workPlan.js';
   export default {
     components: {
       inspectionTemplateDialog
@@ -460,7 +471,6 @@
     watch: {
       schemeList: {
         handler(newVal, oldVal) {
-          console.log('213123131');
           this.templateList = newVal;
           // console.log(newVal, 'schemeList');
         },
@@ -482,10 +492,26 @@
       form: Object,
       ids: String,
       activeName: String,
-      status: Boolean
+      status: Boolean,
+      productId: {
+        type: String,
+        default: ''
+      }
     },
     data() {
       return {
+        disposeTypeList: {
+          1: '返工',
+          2: '返修',
+          3: '报废',
+          4: '降级使用',
+          5: '让步接收',
+          6: '留样',
+          7: '消耗',
+          8: '回用/归批',
+          9: '转试销',
+          10: '退货'
+        },
         templateList: [],
         planTemplateList: [],
         activeNameKK: '',
@@ -528,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' },
@@ -590,7 +616,8 @@
         formData: {
           number: 1,
           sampleUnit: '',
-          portion: null
+          portion: null,
+          packingUnit: ''
         },
         rules: {
           number: [
@@ -613,8 +640,16 @@
               message: '请输入',
               trigger: 'blur'
             }
+          ],
+          packingUnit: [
+            {
+              required: true,
+              message: '请选择',
+              trigger: 'change'
+            }
           ]
-        }
+        },
+        packingSpecificationOption: [] // 包装规格下拉
       };
     },
 
@@ -672,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' },
@@ -721,8 +762,6 @@
       },
       // 分页后的样品列表
       paginatedSampleList() {
-        console.log(this.sampleList);
-
         const { currentPage, pageSize } = this.samplePagination;
         const start = (currentPage - 1) * pageSize;
         const end = start + pageSize;
@@ -738,13 +777,13 @@
         // return this.schemeList?.slice(start, end);
       }
     },
+
     created() {
       this.activeNameKK = this.activeName;
       this.reload({ qualityWorkerId: this.ids });
       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) {
@@ -969,11 +1065,10 @@
         this.$emit('countQualityResults');
       },
       addInspectionTemplate() {
-        this.$refs.inspectionTemplateRef.open(2);
+        let type = this.form.qualityType || 1;
+        this.$refs.inspectionTemplateRef.open(type);
       },
       async inspectionTemplateSuccess(select) {
-        console.log(select);
-
         let data = await getQualityTemplateByIds({
           templateIds: select.map((item) => item.id)
         });
@@ -1007,11 +1102,12 @@
           );
         });
         this.$set(this.form, 'templateList', this.templateList);
+
         this.$emit('setSchemeList', this.templateList);
+        // this.schemeList = this.templateList;
         this.schemePagination.total = this.templateList.length;
       },
       handDel(index) {
-        console.log(index);
         this.templateList.splice(index, 1);
         this.sampleList.forEach((item, index) => {
           this.$set(

+ 301 - 115
src/views/produce/components/workPlan/edit.vue

@@ -38,8 +38,72 @@
           @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="dataWork.id"
@@ -48,6 +112,7 @@
           :scheme-list="schemeList"
           :loading="loading"
           :form="form"
+          :productId="productId"
           :status="statusType"
           @handleSelectionChange="handleSelectionChange1"
           @batch-quality="batchQuality"
@@ -113,7 +178,21 @@
       sampleDisposeDialog
     },
     mixins: [dictMixins],
-
+    computed: {
+      sampletypeVal() {
+        return (row) => {
+          if (row == 1) {
+            return '整样';
+          }
+          return '小样';
+        };
+      }
+    },
+    // p:{
+    //   sampletypeVal()=>{
+    //     return
+    //   }
+    // },
     data() {
       const defaultForm = function () {
         return {
@@ -185,17 +264,26 @@
         dataWork: {}
       };
     },
-    // watch: {
-    //   '$route.query.id': {
-    //     handler(id) {
-    //       if (id) {
-    //         this.getDetail();
-    //       } else {
-    //         this.form = { ...defaultForm() };
-    //       }
-    //     }
-    //   }
-    // },
+    watch: {
+      '$route.query.id': {
+        handler(id) {
+          if (id) {
+            this.getDetail();
+          } else {
+            this.form = { ...defaultForm() };
+          }
+        }
+      },
+      // 样品清单
+      sampleList: {
+        handler(newVal) {
+          // 计算重量跟数量
+          this.calculate(newVal);
+        },
+        deep: true,
+        immediate: true
+      }
+    },
 
     created() {
       // this.open();
@@ -204,10 +292,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(val, flag, '切换检验方式');
-
         this.$refs.tabsRef.tableSelClear();
         this.sampleList = [];
         this.$refs.tabsRef.tabsChange('1');
@@ -231,14 +385,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) {
@@ -247,8 +398,6 @@
                 delete item.id;
               });
 
-              console.log(oldItem, 'oldItem');
-              console.log(count, newMeasureQuantity, newWeight);
               delete oldItem.id;
 
               if (
@@ -270,7 +419,6 @@
                     )
                   });
                 }
-                console.log(ProductSampleList, 'ProductSampleList');
                 this.sampleList = ProductSampleList;
                 const pNum = ProductSampleList.reduce((sum, item) => {
                   return sum + Number(item.weight || 0);
@@ -288,7 +436,6 @@
                     )
                   });
                 }
-                console.log(ProductSampleList, 'ProductSampleList');
                 this.sampleList = ProductSampleList;
                 const pNum = ProductSampleList.reduce((sum, item) => {
                   return sum + Number(item.weight || 0);
@@ -305,18 +452,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) {
@@ -324,11 +466,7 @@
               }
               delete item.id;
             });
-
-            console.log(oldItem, 'oldItem');
-            console.log(count, newMeasureQuantity, newWeight);
             delete oldItem.id;
-
             if (
               oldItem.qualitySampleTemplateList == undefined ||
               oldItem.qualitySampleTemplateList == null ||
@@ -348,7 +486,6 @@
                   )
                 });
               }
-              console.log(ProductSampleList, 'ProductSampleList');
               this.sampleList = ProductSampleList;
               const pNum = ProductSampleList.reduce((sum, item) => {
                 return sum + Number(item.weight || 0);
@@ -366,7 +503,6 @@
                   )
                 });
               }
-              console.log(ProductSampleList, 'ProductSampleList');
               this.sampleList = ProductSampleList;
               const pNum = ProductSampleList.reduce((sum, item) => {
                 return sum + Number(item.weight || 0);
@@ -416,8 +552,6 @@
       // 切换检验方式为全检后生成样品
       changeGetSampleList(list) {
         this.$message('正在生成样品清单');
-        console.log(list);
-        console.log(this.form.total);
 
         // 计量类型1是数量,2是重量
         if (this.form.inspectionStandards == 1) {
@@ -452,7 +586,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) => {
@@ -554,24 +687,6 @@
             this.qualityTimeStart = this.getNowTime();
           }
         }
-        // this.type = this.$route.query.type;
-        // this.qualityType = this.$route.query.qualityType;
-
-        // this.title =
-        //   this.type == 'add' ? '新增' : this.type == 'edit' ? '报工' : '详情';
-
-        // if (this.type == 'add') {
-        //   const code = await getCode('quality_work_order_code');
-        //   this.form.code = code;
-        // } else {
-        //   if (
-        //     this.$route.query.qualityTimeStart != '' ||
-        //     this.$route.query.qualityTimeStart != null ||
-        //     this.$route.query.qualityTimeStart != undefined
-        //   ) {
-        //     this.qualityTimeStart = this.getNowTime();
-        //   }
-        // }
       },
       getNowTime() {
         const nowDate = this.getNowDate();
@@ -596,6 +711,7 @@
       async getDetail(id) {
         getById(id).then((res) => {
           this.form = res.data;
+          this.productId = res.data.productId || '';
           this.statusType = this.form.status == 1 ? true : false;
 
           this.isReportProcessProduce =
@@ -734,8 +850,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('请先选择样品!');
@@ -744,28 +859,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';
 
@@ -775,6 +896,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');
@@ -782,7 +925,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;
@@ -894,7 +1036,7 @@
 
       async queryQualitySamplContent() {
         const res = await queryQualitySamplContent({
-          qualityWorkerId: this.$route.query.id,
+          qualityWorkerId: this.dataWork.id,
           size: 1000
         });
         let addStatus = res.list.map((item) => {
@@ -914,30 +1056,27 @@
           this.addStatus = addStatus;
         } else {
           this.getProSamList(this.packingList);
-          if (this.form.qualityMode == 1) {
-            this.changeModel(this.form.qualityMode);
-          }
+          // if (this.form.qualityMode == 1) {
+          //   this.changeModel(this.form.qualityMode);
+          // }
         }
       },
       async queryQualityTempleContent() {
         const res = await queryQualityTempleContent({
-          qualityWorkerId: this.$route.query.id
+          qualityWorkerId: this.dataWork.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) {
@@ -951,8 +1090,6 @@
 
           delete this.form['qualityTimeEnd'];
 
-          console.log(this.sampleList);
-
           let params = {
             ...this.form,
             sampleList: this.sampleList,
@@ -961,7 +1098,6 @@
             // qualityInventoryList: this.$refs.tabsRef.$refs.sourceTable.getData()
             qualityInventoryList: this.inventoryList
           };
-          console.log(params, 'params ----');
 
           URL(params)
             .then((msg) => {
@@ -998,6 +1134,10 @@
         finishPageTab();
         this.$router.go(-1);
       },
+      setSchemeList(list) {
+        this.schemeList = list;
+      },
+
       handleDetail(index, row, type) {
         if (!this.sampleList[index] || !this.schemeList) {
           return;
@@ -1005,6 +1145,8 @@
         const selectedData = [];
         selectedData.push(this.sampleList[index]);
 
+        console.log(selectedData, 'selectedData');
+
         if (this.schemeList.length != 0) {
           this.sampleList.forEach((item) => {
             if (item.qualitySampleTemplateList.length == 0) {
@@ -1023,8 +1165,6 @@
         );
       },
       inputWeight(row, index) {
-        console.log(row, index, '输入重量');
-
         // 计算所有样本的总重量
         const pNum = this.sampleList.reduce((sum, item) => {
           return sum + Number(item.weight || 0);
@@ -1032,7 +1172,6 @@
         this.form.totalWeight = parseFloat(pNum.toFixed(2));
       },
       handleDispose(data) {
-        console.log(data);
         // return
         this.rowData = data;
         this.sampleDisposeVisble = true;
@@ -1090,8 +1229,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 = '';
           // }
@@ -1103,14 +1240,12 @@
             // qualityInventoryList: this.$refs.tabsRef.$refs.sourceTable.getData()
             qualityInventoryList: this.inventoryList
           };
-          console.log(params, 'params');
 
           exeReportWork(params)
             .then((msg) => {
               this.loading = false;
               this.$message.success(msg);
-              // this.cancel();
-              this.visible = false;
+              this.cancel();
               this.$emit('done');
             })
             .catch((e) => {
@@ -1120,9 +1255,6 @@
       },
       // 处理确认事件
       handleDisposeConfirm(data, index) {
-        console.log(data, index, '确认处置事件');
-        console.log(this.sampleList);
-
         if (index == undefined) {
           this.sampleList.forEach((obj) => {
             obj.disposeType = data.disposeType;
@@ -1137,13 +1269,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) {
@@ -1155,7 +1283,6 @@
         //     }
         //   }
         // }
-        console.log(list, 'listlistlistlist');
         list.forEach((item) => {
           if (item.qualitySampleTemplateList.length == 1) {
             if (
@@ -1195,20 +1322,25 @@
         if (index != null) {
           this.$set(this.sampleList, index, list[0]);
         } else {
-          this.$set(this.sampleList, null, list);
+          // this.$set(this.sampleList, null, list);
+          this.sampleList = list;
         }
         this.activeName = '2';
-        console.log(this.sampleList, '222表');
         // *** 选完批量质检调用
-        this.countQualityResults();
-      },
-
-      setSchemeList(list) {
-        this.schemeList = list;
-        console.log(this.schemeList, 'this.schemeList');
+        // this.countQualityResults();
       },
       // 批量质检
       batchQuality(index, row, type) {
+        // if (this.form.sampleList.qualitySampleTemplateList.length == 0) {
+        //   this.form.sampleList.forEach((item, index) => {
+        //     this.$set(
+        //       this.form.sampleList[index],
+        //       'qualitySampleTemplateList',
+        //       this.form.templateList
+        //     );
+        //   });
+        // }
+
         if (this.sampleList.length == 0) {
           this.$message.error('样品清单不能为空');
           return;
@@ -1221,6 +1353,7 @@
             }
           });
         }
+
         this.$refs.detailRef.openDia(
           null,
           null,
@@ -1289,7 +1422,12 @@
       },
 
       //从来源数组取样到目标数组
-      async getNewFullSampleList(sampleCount, sampleQuantity, sampleUnit) {
+      async getNewFullSampleList(
+        sampleCount,
+        sampleQuantity,
+        sampleUnit,
+        specifications
+      ) {
         const sourceArray = this.selectedList;
         // 检查单位是否匹配
         const isUnitMismatch =
@@ -1376,13 +1514,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) => {
@@ -1468,11 +1639,17 @@
         this.$emit('done');
       },
 
-      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(
@@ -1482,17 +1659,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
@@ -1537,7 +1711,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;
       },
@@ -1546,7 +1734,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
@@ -1560,7 +1747,6 @@
             ? acc + Number(pro.measureQuantity)
             : acc;
         }, 0);
-        console.log(noQualifiedNumber, 'noQualifiedNumber');
         let qualifiedNumber = sampleNumber - noQualifiedNumber; //不合格数
         let qualificationRate = (
           (qualifiedNumber / sampleNumber) *

+ 26 - 4
src/views/produce/components/workPlan/index.vue

@@ -66,10 +66,10 @@
           </template>
 
           <template v-slot:qualityType="{ row }">{{
-            getDictValue('质检计划类型', row.qualityType)
+            getQualityType(row.qualityType)
           }}</template>
           <template v-slot:qualityMode="{ row }">{{
-            getDictValue('取样类型', row.qualityMode)
+            getQualityMode(row.qualityMode)
           }}</template>
           <template v-slot:accessory="scope">
             <el-link
@@ -365,11 +365,13 @@
       };
     },
     created() {
-      this.requestDict('质检计划类型');
+      // this.requestDict('质检计划类型');
       this.requestDict('不良品处理类型');
-      this.requestDict('取样类型');
+      // this.requestDict('取样类型');
       this.getTnspectionPlanType();
       this.getQualityMethodCode();
+      // this.getQualityModeList('quality_method_code');
+      // this.getQualityTypeList('inspection_plan_type');
     },
     computed: {
       seekList() {
@@ -444,6 +446,14 @@
       //   });
       // },
 
+      // async getQualityModeList(code) {
+      //   const res = await getByCode(code);
+      // },
+
+      // async getQualityTypeList(code) {
+      //   const res = await getByCode(code);
+      // },
+
       async datasource({ page, limit }) {
         const res = await getList({
           produceSourceTaskId: this.dataWork.taskId,
@@ -545,6 +555,18 @@
           });
           this.qualityMode = list;
         }
+      },
+
+      getQualityType(num) {
+        const res = this.typeList.find((item) => item.value == num);
+
+        return res ? res.label : '';
+      },
+
+      getQualityMode(num) {
+        const res = this.qualityMode.find((item) => item.value == num);
+
+        return res ? res.label : '';
       }
     }
   };

+ 7 - 0
src/views/produceOrder/info.vue

@@ -174,6 +174,13 @@
         </div>
       </div>
 
+      <div class="item rx-sc">
+        <div class="rx ww25">
+          <div class="lable rx-cc">实际结束时间</div>
+          <div class="content">{{ workOrderInfo.endTime }}</div>
+        </div>
+      </div>
+
       <div class="item rx-sc">
         <div class="rx ww25">
           <div class="lable rx-cc">创建时间</div>

+ 2 - 2
vue.config.js

@@ -33,9 +33,9 @@ module.exports = {
       '/api': {
         // target: 'http://124.71.68.31:50001',
         // target: 'http://192.168.1.116:18086',
-        target: 'http://192.168.1.251:18086',
+        // target: 'http://192.168.1.251:18086',
         // target: 'http://192.168.1.103:18086',192.168.1.116
-        // target: 'http://192.168.1.125:18086',
+        target: 'http://192.168.1.125:18086',
         // target: 'http://192.168.1.116:18086',
         // target: 'http://192.168.1.144:18086',
         // target: 'http://192.168.1.30:18086',