Procházet zdrojové kódy

修改质检计划bug和合格率的bug

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

+ 126 - 7
src/views/inspectionPlan/components/edit.vue

@@ -34,7 +34,6 @@
 
       <el-tabs v-model="activeName" @tab-click="handleClick">
         <el-tab-pane label="来源清单" name="1">
-          <!-- 来料列表表格 -->
           <ele-pro-table
             ref="table12"
             :columns="tableColumns"
@@ -148,6 +147,120 @@
               </el-row>
             </template>
           </ele-pro-table>
+          <!-- 来料列表表格 -->
+          <!-- <ele-pro-table
+            ref="table12"
+            :columns="tableColumns"
+            :datasource="datasource"
+            :needPage="
+              btnType == 'add' ||
+              (btnType == 'edit' && !isFormNumber && !isOrder)
+                ? false
+                : true
+            "
+            @selection-change="handleSelectionChange"
+          >
+            <template
+              v-slot:toolbar
+              v-if="this.baseForm.qualityMode == 2 && btnType != 'detail'"
+            >
+              <el-dropdown trigger="click" @command="handleSampleNumber">
+                <el-link type="primary" icon="el-icon-plus">取样</el-link>
+                <el-dropdown-menu slot="dropdown">
+                  <el-dropdown-item command="1">取整样</el-dropdown-item>
+                  <el-dropdown-item command="2">取小样</el-dropdown-item>
+                </el-dropdown-menu>
+              </el-dropdown>
+            </template>
+            <template v-slot:toolkit v-if="this.baseForm.qualityMode == 2">
+              <el-row>
+                <el-form
+                  ref="ruleForm"
+                  :model="formData"
+                  label-width="60px"
+                  size="mini"
+                  :rules="rules"
+                  class="flex"
+                  :show-message="false"
+                >
+                  <el-col :span="6" v-if="conditionType == 2">
+                    <el-form-item
+                      prop="number"
+                      label-width="0"
+                      style="margin-bottom: 0"
+                    >
+                      <el-input
+                        v-model="formData.number"
+                        placeholder="请输入"
+                        size="mini"
+                      ></el-input>
+                    </el-form-item>
+                  </el-col>
+                  <el-col :span="6" v-if="conditionType == 2">
+                    <el-form-item
+                      prop="sampleUnit"
+                      label-width="0"
+                      style="margin: 0"
+                    >
+                      <DictSelection
+                        dictName="计量单位"
+                        clearable
+                        v-model="formData.sampleUnit"
+                        size="mini"
+                        @change="changeSamUnit"
+                      ></DictSelection>
+                    </el-form-item>
+                  </el-col>
+                  <el-col :span="8" v-if="conditionType == 2">
+                    <el-form-item prop="portion" label="数量" style="margin: 0">
+                      <el-input
+                        v-model="formData.portion"
+                        placeholder="请输入"
+                        size="mini"
+                        clearable
+                      ></el-input>
+                    </el-form-item>
+                  </el-col>
+                  <el-col :span="24" v-if="conditionType == 1">
+                    <el-form-item prop="portion" label="数量" style="margin: 0">
+                      <el-input
+                        v-model="formData.portion"
+                        placeholder="请输入"
+                        size="mini"
+                        clearable
+                      ></el-input>
+                    </el-form-item>
+                  </el-col>
+                  <el-col
+                    :span="4"
+                    style="text-align: right"
+                    v-if="conditionType == 1"
+                  >
+                    <el-button
+                      type="primary"
+                      size="mini"
+                      @click="handleExtractFull"
+                      style="margin-right: 12px"
+                      >确认</el-button
+                    >
+                  </el-col>
+                  <el-col
+                    :span="4"
+                    style="text-align: right"
+                    v-if="conditionType == 2"
+                  >
+                    <el-button
+                      type="primary"
+                      size="mini"
+                      @click="handleExtractFull"
+                      style="margin-right: 12px"
+                      >确认</el-button
+                    >
+                  </el-col>
+                </el-form>
+              </el-row>
+            </template>
+          </ele-pro-table> -->
         </el-tab-pane>
         <el-tab-pane label="样品清单" name="2">
           <el-table
@@ -597,7 +710,6 @@
         const { currentPage, pageSize } = this.samplePagination;
         const start = (currentPage - 1) * pageSize;
         const end = start + pageSize;
-        console.log('fafafaf');
         return this.sampleList.slice(start, end);
       },
       // 分页后的质检方案列表
@@ -740,8 +852,15 @@
       //获取基本信息中计量方式
       getInspectionStandards(data) {
         console.log(data, 'data');
+        console.log(this.baseForm.type, 'type');
+        console.log(this.baseForm.planSource, 'planSource');
         this.baseForm.inspectionStandards = data;
         console.log(1313322);
+        if (this.baseForm.type == '3' && this.baseForm.planSource == '6') {
+          // this.isOrder = false;
+          console.log('...........');
+          this.handleSampleList();
+        }
         if (this.btnType == 'edit' && !this.isOnce) {
           this.isOrder = false;
           console.log('98989898');
@@ -822,11 +941,11 @@
             if (this.baseForm.type) {
               this.$refs.baseInfoRefs.typeChange(this.baseForm.type);
             }
-            // if (this.baseForm.productId) {
-            //   this.$refs.baseInfoRefs.getProductDetails(
-            //     this.baseForm.productId
-            //   );
-            // }
+            if (this.baseForm.productId) {
+              this.$refs.baseInfoRefs.getProductDetails(
+                this.baseForm.productId
+              );
+            }
           }
         });
 

+ 896 - 0
src/views/inspectionPlan/components/new-baseInfo.vue

@@ -0,0 +1,896 @@
+<template>
+  <el-form ref="form1" :model="form" :rules="rules" label-width="120px">
+    <el-row>
+      <el-col :span="6">
+        <el-form-item label="类型:" prop="type">
+          <DictSelection
+            dictName="质检计划类型"
+            v-model="form.type"
+            clearable
+            @change="typeChange"
+            :disabled="btnType == 'detail' || btnType == 'issued'"
+          ></DictSelection>
+        </el-form-item>
+      </el-col>
+      <el-col :span="6">
+        <el-form-item label="计划来源:" prop="planSource">
+          <el-select
+            v-model="form.planSource"
+            placeholder="请选择"
+            style="width: 100%"
+            clearable
+            @change="planSourceChange"
+            :disabled="btnType == 'detail' || btnType == 'issued'"
+          >
+            <el-option
+              :label="item.label"
+              v-for="item in sourceList"
+              :key="item.value"
+              :value="item.value"
+            />
+          </el-select>
+        </el-form-item>
+      </el-col>
+      <!-- <el-col :span="6">
+        <el-form-item label="名称:" prop="name">
+          <el-input clearable v-model="form.name" placeholder="请输入"
+            :disabled="btnType == 'detail' || btnType == 'issued'" />
+        </el-form-item>
+      </el-col>-->
+      <el-col :span="6">
+        <el-form-item label="检验方式:" prop="qualityMode">
+          <DictSelection
+            dictName="取样类型"
+            v-model="form.qualityMode"
+            clearable
+            @change="changeQualityMode"
+            :disabled="btnType == 'detail' || btnType == 'issued'"
+          ></DictSelection>
+        </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="请选择"
+            @change="changeInspectionType"
+            :disabled="
+              btnType == 'detail' ||
+              btnType == 'issued' ||
+              btnType == 'add' ||
+              btnType == 'edit'
+            "
+          >
+            <el-option
+              v-for="item in inspectionStandardsList"
+              :label="item.label"
+              :value="item.value"
+              :key="item.value"
+            ></el-option>
+          </el-select>
+
+          <!-- <el-input
+            clearable
+            v-model="form.inspectionStandards"
+            placeholder="请输入"
+            :disabled="
+              btnType == 'detail' ||
+              btnType == 'issued' ||
+              btnType == 'add' ||
+              btnType == 'edit'
+            "
+          /> -->
+        </el-form-item>
+      </el-col>
+    </el-row>
+    <el-row>
+      <el-col :span="6">
+        <el-form-item label="编码:" prop="code">
+          <el-input
+            clearable
+            v-model="form.code"
+            placeholder="请输入"
+            disabled
+          />
+        </el-form-item>
+      </el-col>
+      <el-col :span="6">
+        <el-form-item label="名称:" prop="name">
+          <el-input
+            clearable
+            v-model="form.name"
+            placeholder="请输入"
+            :disabled="btnType == 'detail' || btnType == 'issued'"
+          />
+        </el-form-item>
+      </el-col>
+      <!-- <el-col :span="6">
+        <el-form-item label="自动派单:" prop="autoOrder">
+          <el-select v-model="form.autoOrder" placeholder="请选择" style="width: 100%"
+            :disabled="btnType == 'detail' || btnType == 'issued'" clearable>
+            <el-option label="是" :value="1" />
+            <el-option label="否" :value="0" />
+          </el-select>
+        </el-form-item>
+      </el-col>-->
+      <el-col :span="6">
+        <el-form-item label="执行部门:" prop="groupId">
+          <deptSelect
+            :disabled="btnType == 'detail'"
+            v-model="form.groupId"
+            @changeGroup="searchDeptNodeClick"
+          />
+        </el-form-item>
+      </el-col>
+      <el-col :span="6">
+        <el-form-item label="执行人员:" prop="executeId">
+          <el-select
+            :disabled="btnType == 'detail'"
+            v-model="form.executeId"
+            @change="changeExecutor"
+            filterable
+            style="width: 100%"
+          >
+            <el-option
+              v-for="item in executorList"
+              :key="item.id"
+              :value="item.id"
+              :label="item.name"
+            ></el-option>
+          </el-select>
+        </el-form-item>
+      </el-col>
+    </el-row>
+    <div style="text-align: right; margin-bottom: 22px">
+      <div @click="toggleExpand">
+        <div v-if="isExpanded"> <i class="el-icon-arrow-up"></i>收起 </div>
+        <div v-if="!isExpanded">
+          <i class="el-icon-arrow-down"></i>展开更多
+        </div>
+      </div>
+    </div>
+    <div v-if="isExpanded">
+      <el-row>
+        <el-col :span="6">
+          <el-form-item label="自动派单:" prop="autoOrder">
+            <el-select
+              v-model="form.autoOrder"
+              placeholder="请选择"
+              style="width: 100%"
+              :disabled="btnType == 'detail' || btnType == 'issued'"
+              clearable
+            >
+              <el-option label="是" :value="1" />
+              <el-option label="否" :value="0" />
+            </el-select>
+          </el-form-item>
+        </el-col>
+        <el-col :span="6">
+          <el-form-item label="开始时间:" prop="planStartTime">
+            <el-date-picker
+              :disabled="btnType == 'detail'"
+              class="w100"
+              v-model="form.planStartTime"
+              type="date"
+              value-format="yyyy-MM-dd"
+              placeholder="请输入"
+            ></el-date-picker>
+          </el-form-item>
+        </el-col>
+        <el-col :span="6">
+          <el-form-item label="结束时间:" prop="planEndTime">
+            <el-date-picker
+              :disabled="btnType == 'detail'"
+              class="w100"
+              v-model="form.planEndTime"
+              type="date"
+              value-format="yyyy-MM-dd"
+              placeholder="请输入"
+            ></el-date-picker>
+          </el-form-item>
+        </el-col>
+        <!-- <el-col :span="6">
+          <el-form-item label="类型:" prop="type">
+            <DictSelection dictName="质检计划类型" v-model="form.type" clearable @change="typeChange"
+              :disabled="btnType == 'detail' || btnType == 'issued'"></DictSelection>
+          </el-form-item>
+        </el-col>-->
+        <!-- <el-col :span="6">
+          <el-form-item label="计划来源:" prop="planSource">
+            <el-select v-model="form.planSource" placeholder="请选择" style="width: 100%" clearable
+              @change="planSourceChange" :disabled="btnType == 'detail' || btnType == 'issued'">
+              <el-option :label="item.label" v-for="item in sourceList" :key="item.value" :value="item.value" />
+            </el-select>
+          </el-form-item>
+        </el-col>-->
+        <el-col :span="6">
+          <el-form-item label="来源编码:" prop="planSourceCode">
+            <el-input v-model="form.planSourceCode" disabled />
+          </el-form-item>
+        </el-col>
+      </el-row>
+      <el-row>
+        <el-col :span="6">
+          <el-form-item label="名称:" prop="productName">
+            <el-input v-model="form.productName" disabled />
+          </el-form-item>
+        </el-col>
+        <el-col :span="6">
+          <el-form-item label="编码:" prop="productCode">
+            <el-input v-model="form.productCode" disabled />
+          </el-form-item>
+        </el-col>
+        <el-col :span="6">
+          <el-form-item label="批次号:" prop="batchNo">
+            <el-input v-model="form.batchNo" disabled />
+          </el-form-item>
+        </el-col>
+        <el-col :span="6">
+          <el-form-item label="规格:" prop="specification">
+            <el-input v-model="form.specification" disabled />
+          </el-form-item>
+        </el-col>
+      </el-row>
+      <el-row>
+        <el-col :span="6">
+          <el-form-item label="型号:" prop="modelType">
+            <el-input v-model="form.modelType" disabled />
+          </el-form-item>
+        </el-col>
+        <el-col :span="6">
+          <el-form-item label="牌号:" prop="brandNo">
+            <el-input v-model="form.brandNo" disabled />
+          </el-form-item>
+        </el-col>
+        <el-col :span="6">
+          <el-form-item label="数量:" prop="productNumber">
+            <el-input
+              type="number"
+              v-model="form.productNumber"
+              :disabled="quantityShow ? false : true"
+              @input="changeProductNumber"
+              @change="changeProductNumber"
+            >
+              <!-- *** 之前只有主数据的显示 现在主数据 + 生产检验类型的都显示-->
+              <!--  :disabled="form.planSource == '5' ? false : true" -->
+              <template #append>{{
+                form.dimension == 3
+                  ? form.packingUnit
+                  : form.dimension == 2
+                  ? form.measureUnit
+                  : categoryInfo.measuringUnit
+              }}</template>
+            </el-input>
+          </el-form-item>
+        </el-col>
+        <el-col :span="6">
+          <el-form-item label="工序:" prop="produceTaskName">
+            <el-input v-model="form.produceTaskName" disabled />
+          </el-form-item>
+        </el-col>
+      </el-row>
+      <el-row>
+        <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>
+      </el-row>
+      <el-row>
+        <!-- <el-col :span="6" v-if="form.qualityMode == 2">
+          <el-form-item label="取样数量:" prop="sampleNumber" :rules="{
+            required: form.qualityMode == 2 ? true : false,
+            message: '请输入取样数量',
+            trigger: 'blur'
+          }">
+            <div style="display: flex;align-items: center;justify-content: space-between;">
+              <el-input type="number" v-model="form.sampleNumber" disabled style="width: calc(100% - 90px)">
+              </el-input>
+              <DictSelection dictName="计量单位" clearable v-model="form.sampleMeasureUnit" disabled size="mini"
+                style="width: 90px;margin-left: 12px;">
+              </DictSelection>
+            </div>
+          </el-form-item>
+        </el-col>-->
+        <el-col :span="6">
+          <el-form-item label="抽样比例:" prop="sampleProportion">
+            <el-input
+              v-model="form.sampleProportion"
+              :disabled="btnType == 'detail' || btnType == 'issued'"
+            >
+              <template #append>%</template>
+            </el-input>
+          </el-form-item>
+        </el-col>
+        <el-col :span="6">
+          <el-form-item label="备注:" prop="remark">
+            <el-input
+              type="textarea"
+              v-model="form.remark"
+              placeholder="请输入"
+              :disabled="btnType == 'detail' || btnType == 'issued'"
+            />
+          </el-form-item>
+        </el-col>
+        <el-col :span="6">
+          <el-form-item label="附件:" prop="accessory">
+            <fileUpload
+              v-model="form.accessory"
+              :type="btnType == 'detail' ? 'view' : ''"
+            />
+          </el-form-item>
+        </el-col>
+      </el-row>
+    </div>
+
+    <warehousing ref="warehousingRef" @choose="handleChoose" />
+    <productionPlan ref="productionPlanRef" @choose="handleChoose" />
+    <workOrder ref="workOrderRef" @choose="handleChoose" />
+    <produceOrder ref="produceOrderRef" @choose="handleChoose" />
+    <EquipmentDialog
+      ref="equipmentRefs"
+      @choose="handleMainChoose"
+      :type="2"
+      :treeIds="['9']"
+    />
+    <stokledger ref="stokledgerRef" @choose="handleStokledgerChoose" />
+  </el-form>
+</template>
+<script>
+  import deptSelect from '@/components/CommomSelect/dept-select.vue';
+  import fileUpload from '@/components/addDoc/index.vue';
+
+  import warehousing from './warehousing';
+  import productionPlan from './productionPlan';
+  import workOrder from './workOrder';
+  import produceOrder from './produceOrder';
+  import EquipmentDialog from './equipmentDialog';
+  import stokledger from './stokledger';
+
+  //接口
+  import { getUserPage } from '@/api/system/organization';
+  import { getByCode } from '@/api/system/dictionary-data';
+  import { rules } from 'eslint-config-prettier';
+
+  import { getDetailInfo } from '@/api/inspectionPlan/index.js';
+
+  export default {
+    components: {
+      EquipmentDialog,
+      produceOrder,
+      workOrder,
+      productionPlan,
+      warehousing,
+      deptSelect,
+      fileUpload,
+      stokledger
+    },
+    props: {
+      form: {
+        type: Object,
+        default: () => {}
+      },
+      btnType: {
+        type: String,
+        default: ''
+      },
+      packingLists: {
+        type: Array,
+        default: () => []
+      },
+      isChangeNumber: {
+        type: Boolean,
+        default: true
+      },
+      isChangeType: {
+        type: Boolean,
+        default: true
+      }
+    },
+
+    computed: {
+      quantityShow() {
+        if (this.btnType == 'detail') {
+          return false;
+        }
+        let flag =
+          this.form.planSource == '5' ||
+          this.form.planSource == '2' ||
+          this.form.planSource == '3' ||
+          this.form.planSource == '4';
+        return flag;
+      }
+    },
+    watch: {
+      // 'form.productNumber': {
+      //   handler(newVal) {
+      //     // if (this.form.productNumber) {
+      //     //   this.isInforChangeNumber = false;
+      //     // }
+      //     // 现在生产检验所有的类型也用这个
+      //     // if (newVal && this.form.planSource == '5') { //主数据来源才生效
+      //     // if (newVal && this.quantityShow && !this.isInforChangeNumber) {
+      //     //   this.$emit('changeProductNumberModel', newVal);
+      //     //   this.form.totalWeight = this.categoryInfo.netWeight * newVal || 0;
+      //     // } else {
+      //     //   console.log('清空样品清单1');
+      //     //   this.isInforChangeNumber = true;
+      //     //   this.$emit('table2');
+      //     // }
+      //     console.log(this.btnType);
+      //     if (newVal && this.quantityShow && !this.isInforChangeNumber) {
+      //       this.$emit('changeProductNumberModel', newVal);
+      //       this.form.totalWeight = this.categoryInfo.netWeight * newVal || 0;
+      //     } else {
+      //       console.log('清空样品清单1');
+      //       this.isInforChangeNumber = true;
+      //       this.$emit('table2');
+      //     }
+      //   },
+      //   // immediate: false
+      //   immediate: true
+      // },
+      // 'form.qualityMode': {
+      //   handler(newVal) {
+      //     console.log(321321);
+      //     console.log(this.form.qualityMode);
+      //     // if (newVal && !this.isInfoChangeModel) {
+      //     //   this.$emit('changeModel', newVal);
+      //     //   console.log(45464646464);
+      //     // } else {
+      //     //   console.log('清空样品清单2');
+      //     //   this.isInfoChangeModel = true;
+      //     //   this.$emit('table2');
+      //     // }
+      //     // if (this.form.qualityMode) {
+      //     //   this.isInfoChangeModel = false;
+      //     // }
+      //     console.log(this.btnType, this.isInfoChangeModel, '=====>');
+      //     if (newVal && !this.isInfoChangeModel) {
+      //       console.log(
+      //         this.btnType,
+      //         this.isInfoChangeModel,
+      //         '--------------->'
+      //       );
+      //       this.$emit('changeModel', newVal);
+      //       console.log(45464646464);
+      //     } else {
+      //       console.log('清空样品清单2');
+      //       this.isInfoChangeModel = true;
+      //       this.$emit('table2');
+      //     }
+      //   },
+      //   // immediate: false
+      //   immediate: true
+      // },
+      // 'form.inspectionStandards': {
+      //   handler(newVal) {
+      //     // if (this.form.inspectionStandards) {
+      //     //   this.isInfoChangeType = false;
+      //     // }
+      //     // console.log(this.btnType);
+      //     // if (newVal && !this.isInfoChangeType) {
+      //     //   this.$emit('getInspectionStandards', newVal);
+      //     // } else {
+      //     //   this.isInfoChangeType = true;
+      //     //   console.log('清空样品清单3');
+      //     //   this.$emit('table2');
+      //     // }
+      //     console.log(this.btnType);
+      //     // console.log(465413);
+      //     if (newVal) {
+      //       console.log('=====<><><><><');
+      //       this.$emit('getInspectionStandards', newVal);
+      //     } else {
+      //       this.isInfoChangeType = true;
+      //       console.log('清空样品清单3');
+      //       this.$emit('table2');
+      //     }
+      //   },
+      //   // immediate: false
+      //   immediate: true
+      // },
+      'form.type': {
+        handler(newVal) {
+          if (!newVal) {
+            this.form.planSource = '';
+            this.form.planSourceCode = '';
+            this.form.productName = '';
+            this.form.productCode = '';
+            this.form.batchNo = '';
+            this.form.specification = '';
+            this.form.modelType = '';
+            this.form.brandNo = '';
+            this.form.productNumber = '';
+            this.form.qualifiedNumber = '';
+            this.form.unqualifiedNumber = '';
+            this.form.qualificationRate = '';
+            this.form.totalWeight = '';
+            this.form.sampleNumber = '';
+            this.sourceList = [];
+            this.$emit('resetTable');
+          }
+        },
+        immediate: false
+      },
+      'form.planSource': {
+        handler(newVal) {
+          if (!newVal) {
+            this.form.planSource = '';
+            this.form.planSourceCode = '';
+            this.form.productName = '';
+            this.form.productCode = '';
+            this.form.batchNo = '';
+            this.form.specification = '';
+            this.form.modelType = '';
+            this.form.brandNo = '';
+            this.form.productNumber = '';
+            this.form.qualifiedNumber = '';
+            this.form.unqualifiedNumber = '';
+            this.form.qualificationRate = '';
+            this.form.totalWeight = '';
+            this.form.sampleNumber = '';
+            this.$emit('resetTable');
+          }
+        },
+        immediate: false
+      }
+    },
+    data() {
+      return {
+        executorList: [],
+        sourceList: [],
+        inspectionStandardsList: [],
+        rules: {
+          name: [{ required: true, message: '请输入', trigger: 'blur' }],
+          qualityMode: [
+            { required: true, message: '请选择检验方式', trigger: 'blur' }
+          ],
+          inspectionStandards: [
+            { required: true, message: '请选择检验标准', trigger: 'blur' }
+          ],
+          type: [{ required: true, message: '请选择类型', trigger: 'blur' }],
+          groupId: [
+            { required: true, message: '请选择执行部门', trigger: 'blur' }
+          ],
+          executeId: [
+            { required: true, message: '请选择执行人员:', trigger: 'blur' }
+          ],
+          planSource: [
+            { required: true, message: '请选择计划来源', trigger: 'blur' }
+          ]
+        },
+        isExpanded: false, // 控制展开/收起状态
+        categoryInfo: {},
+        isInforChangeNumber: true,
+        isInfoChangeType: true,
+        isInfoChangeModel: true,
+        isOnce: true,
+        isListData: [{}]
+      };
+    },
+    created() {
+      // this.getDictListIqoCode('iqo_code');
+      this.getDictListIqoCode('measurement_type');
+      console.log(this.form);
+    },
+    methods: {
+      toggleExpand(val) {
+        this.isExpanded = !this.isExpanded;
+      },
+      // 获取检验标准
+      async getDictListIqoCode(code) {
+        let { data: res } = await getByCode(code);
+        this.inspectionStandardsList = res.map((item) => {
+          let values = Object.keys(item);
+          return {
+            value: Number(values[0]),
+            label: item[values[0]]
+          };
+        });
+      },
+      //质检计划类型
+      planChange(value) {
+        if (value == 1) {
+          this.sourceList = [{ label: '采购收货单', value: '1' }];
+        } else if (value == 2) {
+          this.sourceList = [
+            { label: '生产计划', value: '2' },
+            { label: '生产订单', value: '3' },
+            { label: '生产工单', value: '4' }
+          ];
+        }
+      },
+      //选择部门(搜索)
+      searchDeptNodeClick(info, row) {
+        if (info) {
+          const params = { groupId: info };
+          this.getUserList(params);
+          this.form.groupName = row.name;
+        } else {
+          this.form.executeGroupId = null;
+        }
+      },
+      // 获取审核人列表、巡点检人员
+      async getUserList(params) {
+        try {
+          let data = { pageNum: 1, size: -1 };
+          // 如果传了参数就是获取巡点检人员数据
+          if (params) {
+            data = Object.assign(data, params);
+          }
+          const res = await getUserPage(data);
+          this.executorList = res.list;
+        } catch (error) {}
+      },
+      // 执行人选择
+      changeExecutor(val) {
+        if (val) {
+          this.form.executeId = val;
+          this.form.executeName = this.executorList.filter(
+            (item) => item.id === val
+          )[0].name;
+        }
+      },
+      //计划来源选择
+      planSourceChange(val) {
+        if (val) {
+          this.addProduct();
+        }
+      },
+      addProduct() {
+        if (this.form.planSource == 1) {
+          this.$refs.warehousingRef.open();
+        } else if (this.form.planSource == 2) {
+          this.$refs.productionPlanRef.open();
+        } else if (this.form.planSource == 3) {
+          this.$refs.workOrderRef.open();
+        } else if (this.form.planSource == 4) {
+          this.$refs.produceOrderRef.open();
+        } else if (this.form.planSource == 5) {
+          //主数据
+          this.$refs.equipmentRefs.open();
+        } else if (this.form.planSource == 6) {
+          //库存台账
+          this.$refs.stokledgerRef.open();
+        }
+      },
+      //根据类型获取计划来源下拉
+      typeChange(val) {
+        if (val == 1) {
+          this.sourceList = [{ label: '采购收货单', value: '1' }];
+        } else if (val == 2) {
+          this.sourceList = [
+            // { label: '生产计划', value: '2' },
+            // { label: '生产订单', value: '3' },
+            { label: '生产工单', value: '4' }
+          ];
+        } else if (val == 3) {
+          this.sourceList = [
+            // { label: '主数据', value: '5' },
+            { label: '库存台账', value: '6' }
+          ];
+        }
+      },
+
+      //主数据根据来源得到产品
+      handleMainChoose(val) {
+        console.log(val, '主数据根据来源得到产品');
+        if (!val) return;
+
+        console.log();
+        this.form.productName = val.name; //名称
+        this.form.productCode = val.code; //编码
+        this.form.specification = val.specification; //规格
+        this.form.modelType = val.modelType; //型号
+        this.form.brandNo = val.brandNum; //牌号
+        this.form.totalWeight = val.totalWeight; //总重量
+        this.form.inspectionStandards = val.inspectionStandards; //检验标准
+        this.form.isConsumable = val.isConsumable; //0 单件 1 批量
+        this.form.productId = val.id;
+        this.form.netWeight = val.netWeight; //净重
+        // console.log(this.form.type)
+        console.log('----------------->>>>');
+        this.getProductDetails(this.form.productId);
+        this.$emit('changesMainNumberModal', this.form.productNumber);
+        if (this.form.type != 3) {
+          this.$emit('getQualityTemplate', val.code);
+        }
+      },
+
+      //库存台账根据来源得到产品
+      handleStokledgerChoose(list, dimension) {
+        let val = list[0];
+        console.log(val, '库存台账根据来源得到产品');
+        if (!val) return;
+        if (dimension == 3) {
+          this.form.productNumber = val.measureQuantity; //数量
+          this.form.packingUnit = val.packingUnit; //包装单位
+        } else {
+          this.form.productNumber = val.outboundNum; //数量
+          this.form.totalWeight = (
+            (val.weight / val.measureQuantity) *
+            val.outboundNum
+          ).toFixed(2); //总重量
+        }
+        this.form.dimension = dimension;
+        this.form.measureUnit = val.measureUnit; //计量单位
+
+        this.form.productName = val.categoryName; //名称
+        this.form.productCode = val.categoryCode; //编码
+        this.form.specification = val.specification; //规格
+        this.form.modelType = val.categoryModel; //型号
+        this.form.brandNo = val.brandNum; //牌号
+        this.form.inspectionStandards = val.inspectionStandards; //检验标准
+        this.form.productId = val.categoryId;
+        this.form.batchNo = val.batchNo; //批次号
+        console.log('----------------->>111111');
+        this.getProductDetails(this.form.productId, this.form.planSource);
+        if (this.form.planSource == '6') {
+          this.$emit('changesStokledgerNumberModal', list, dimension);
+        }
+        // this.$emit('changesStokledgerNumberModal', list, dimension);
+        if (this.form.type != 3) {
+          this.$emit('getQualityTemplate', val.categoryCode);
+        }
+      },
+
+      //   根据来源得到产品
+      handleChoose(val) {
+        console.log(val, '根据来源得到产品');
+        if (!val) return;
+        this.form.planSourceCode = val.receiveNo;
+        // *** 之前未对生产检验进行判断 当类型是生产检验的时候 productId 是 undefined
+        // 直接赋值 productId  不改变原来逻辑
+        // 这里的字段 receiveNo 从生产检验(生产计划,生产订单,生产工单)里面没有 ->对应的是code 字段 但是不能够进入 getList 方法
+        // 定义一个专门给 生产检验(生产计划,生产订单,生产工单) 的字段传递下去 productionCode
+        let productionCode = '';
+        if (this.form.type == 2) {
+          val.productId = val.categoryId;
+          productionCode = val.code;
+          this.form.planSourceCode = productionCode;
+        }
+        // ***
+        this.form.planSourceId = val.id;
+        // this.form.planSourceCode = val.receiveNo; // 放上去 方便判断
+        this.form.supplierName = val.supplierName;
+        this.form.supplierMark = val.supplierMark;
+        this.form.productName = val.productName;
+        this.form.productCode = val.productCode;
+        this.form.batchNo = val.batchNo;
+        this.form.specification = val.specification;
+        this.form.modelType = val.modelType;
+        this.form.brandNo = val.brandNo;
+        this.form.productNumber = val.totalCount;
+        this.form.qualifiedNumber = val.qualifiedNumber;
+        this.form.unqualifiedNumber = val.unqualifiedNumber;
+        this.form.qualificationRate = val.qualificationRate;
+        this.form.totalWeight = val.totalWeight;
+        this.form.sampleNumber = val.sampleNumber;
+        this.form.inspectionStandards = val.inspectionStandards;
+        this.form.produceTaskName = val.taskName;
+        this.form.produceTaskId = val.taskId;
+        this.form.productId = val.productId;
+        let receiveNo = val.receiveNo;
+        let categoryCode = val.productCode;
+        let categoryid = val.productId;
+        let batchNo = val.batchNo;
+        let productCategoryId = val.productCategoryId;
+        let productCategoryName = val.productCategoryName;
+
+        console.log(this.form.productId, batchNo, productionCode);
+
+        if (receiveNo && categoryCode && categoryid) {
+          this.$emit(
+            'getList',
+            receiveNo,
+            categoryCode,
+            productCategoryId,
+            productCategoryName,
+            categoryid,
+            batchNo,
+            val.supplierName,
+            val.supplierMark
+          );
+        }
+        console.log('-----------------');
+        this.getProductDetails(
+          this.form.productId,
+          batchNo,
+          productionCode,
+          val.id,
+          val.taskId
+        );
+      },
+      //获取产品详情信息-来自主数据
+      // *** 增加 batchNo productionCode 字段 给 生产检验类型用
+      async getProductDetails(
+        val,
+        batchNo = '',
+        productionCode = '',
+        id = '',
+        taskId = ''
+      ) {
+        const data = await getDetailInfo(val);
+        this.categoryInfo = data.category;
+        const qmsData = data.categoryQms;
+
+        // *** 新增 批次号,来源单据 字段传递
+        console.log(this.categoryInfo.measureType, 'getProductDetails');
+        this.form.inspectionStandards = this.categoryInfo.measureType;
+        this.form.qualityMode = qmsData.checkFormula || 1;
+        if (this.form.qualityMode) {
+          this.changeQualityMode(this.form.qualityMode);
+        }
+        data.category.batchNo = batchNo;
+        data.category.id = id;
+        data.category.planSourceCode = productionCode;
+        data.category.taskId = taskId;
+        // ***
+        this.$emit('getCategoryInfo', data);
+      },
+      getsampleMeasureUnit(val) {
+        this.$set(this.form, 'sampleMeasureUnit', val);
+      },
+      changeProductNumber(val) {
+        console.log(val, 'ProductNumber');
+        if (val) {
+          this.$emit('changeProductNumberModel', val);
+          this.form.totalWeight = this.categoryInfo.netWeight * val || 0;
+        } else {
+          this.$emit('resetTable');
+        }
+        // this.isInforChangeNumber = false;
+      },
+      changeInspectionType() {
+        this.isInfoChangeType = false;
+      },
+      changeQualityMode(val) {
+        console.log(val, 'isInfoChangeModel');
+        if (val) {
+          this.$emit('changeModel', val);
+        } else {
+          console.log('清空table2数据');
+          this.$emit('table2');
+        }
+
+        // this.isInfoChangeModel = false;
+      }
+    }
+  };
+</script>
+<style lang="scss" scoped>
+  ::v-deep .el-form-item .el-form-item--medium .more {
+    margin: 0 !important;
+  }
+</style>

+ 2289 - 0
src/views/inspectionPlan/components/new-edit.vue

@@ -0,0 +1,2289 @@
+<!-- 用户编辑弹窗 -->
+<template>
+  <ele-modal
+    :title="title"
+    :visible.sync="visible"
+    :before-close="handleClose"
+    :close-on-click-modal="false"
+    :close-on-press-escape="false"
+    append-to-body
+    width="80%"
+    :maxable="true"
+  >
+    <header-title title="基本信息"></header-title>
+    <base-info
+      ref="baseInfoRefs"
+      v-if="baseForm"
+      :form="baseForm"
+      :btnType="btnType"
+      :isChangeNumber="isChangeNumber"
+      :isChangeType="isChangeType"
+      @resetTable="resetTable"
+      @changeModel="changeModel"
+      @getList="getList"
+      @table2="table2"
+      @getInspectionStandards="getInspectionStandards"
+      :packingLists="packingList"
+      @getCategoryInfo="getCategoryInfo"
+      @changeProductNumberModel="changeProductNumberModel"
+      @changesStokledgerNumberModal="changesStokledgerNumberModal"
+      @getQualityTemplate="getQualityTemplate"
+    ></base-info>
+    <el-row>
+      <header-title title="质检内容"></header-title>
+
+      <el-tabs v-model="activeName" @tab-click="handleClick">
+        <el-tab-pane label="来源清单" name="1">
+          <!-- <ele-pro-table
+            ref="table12"
+            :columns="tableColumns"
+            :datasource="datasource"
+            :needPage="
+              btnType == 'add' ||
+              (btnType == 'edit' && !isFormNumber && !isOrder)
+                ? false
+                : true
+            "
+            @selection-change="handleSelectionChange"
+          > -->
+
+          <!-- 来料列表表格 -->
+          <ele-pro-table
+            ref="table12"
+            :columns="tableColumns"
+            :datasource="datasource"
+            :needPage="
+              btnType == 'add' ||
+              (btnType == 'edit' && !isFormNumber && !isOrder)
+                ? false
+                : true
+            "
+            @selection-change="handleSelectionChange"
+          >
+            <template
+              v-slot:toolbar
+              v-if="this.baseForm.qualityMode == 2 && btnType != 'detail'"
+            >
+              <el-dropdown trigger="click" @command="handleSampleNumber">
+                <el-link type="primary" icon="el-icon-plus">取样</el-link>
+                <el-dropdown-menu slot="dropdown">
+                  <el-dropdown-item command="1">取整样</el-dropdown-item>
+                  <el-dropdown-item command="2">取小样</el-dropdown-item>
+                </el-dropdown-menu>
+              </el-dropdown>
+            </template>
+            <template v-slot:toolkit v-if="this.baseForm.qualityMode == 2">
+              <el-row>
+                <el-form
+                  ref="ruleForm"
+                  :model="formData"
+                  label-width="60px"
+                  size="mini"
+                  :rules="rules"
+                  class="flex"
+                  :show-message="false"
+                >
+                  <el-col :span="6" v-if="conditionType == 2">
+                    <el-form-item
+                      prop="number"
+                      label-width="0"
+                      style="margin-bottom: 0"
+                    >
+                      <el-input
+                        v-model="formData.number"
+                        placeholder="请输入"
+                        size="mini"
+                      ></el-input>
+                    </el-form-item>
+                  </el-col>
+                  <el-col :span="6" v-if="conditionType == 2">
+                    <el-form-item
+                      prop="sampleUnit"
+                      label-width="0"
+                      style="margin: 0"
+                    >
+                      <DictSelection
+                        dictName="计量单位"
+                        clearable
+                        v-model="formData.sampleUnit"
+                        size="mini"
+                        @change="changeSamUnit"
+                      ></DictSelection>
+                    </el-form-item>
+                  </el-col>
+                  <el-col :span="8" v-if="conditionType == 2">
+                    <el-form-item prop="portion" label="数量" style="margin: 0">
+                      <el-input
+                        v-model="formData.portion"
+                        placeholder="请输入"
+                        size="mini"
+                        clearable
+                      ></el-input>
+                    </el-form-item>
+                  </el-col>
+                  <el-col :span="24" v-if="conditionType == 1">
+                    <el-form-item prop="portion" label="数量" style="margin: 0">
+                      <el-input
+                        v-model="formData.portion"
+                        placeholder="请输入"
+                        size="mini"
+                        clearable
+                      ></el-input>
+                    </el-form-item>
+                  </el-col>
+                  <el-col
+                    :span="4"
+                    style="text-align: right"
+                    v-if="conditionType == 1"
+                  >
+                    <el-button
+                      type="primary"
+                      size="mini"
+                      @click="handleExtractFull"
+                      style="margin-right: 12px"
+                      >确认</el-button
+                    >
+                  </el-col>
+                  <el-col
+                    :span="4"
+                    style="text-align: right"
+                    v-if="conditionType == 2"
+                  >
+                    <el-button
+                      type="primary"
+                      size="mini"
+                      @click="handleExtractFull"
+                      style="margin-right: 12px"
+                      >确认</el-button
+                    >
+                  </el-col>
+                </el-form>
+              </el-row>
+            </template>
+          </ele-pro-table>
+        </el-tab-pane>
+        <el-tab-pane label="样品清单" name="2">
+          <el-table
+            v-show="activeName === '2'"
+            v-if="sampleList.length > 0"
+            ref="showSampleListTable"
+            :data="paginatedSampleList"
+            tooltip-effect="dark"
+            :max-height="300"
+            border
+            row-key="id"
+          >
+            <el-table-column
+              label="序号"
+              type="index"
+              width="50"
+              align="center"
+            ></el-table-column>
+            <template v-for="column in tableColumns2">
+              <el-table-column
+                :key="column.prop"
+                :label="column.label"
+                :prop="column.prop"
+                :show-overflow-tooltip="true"
+                :width="column.width"
+                :align="column.align"
+              ></el-table-column>
+            </template>
+          </el-table>
+          <el-pagination
+            v-show="activeName === '2' && sampleList.length > 0"
+            @size-change="handleSampleSizeChange"
+            @current-change="handleSampleCurrentChange"
+            :current-page="samplePagination.currentPage"
+            :page-sizes="[10, 20, 50, 100]"
+            :page-size="samplePagination.pageSize"
+            layout="total, sizes, prev, pager, next, jumper"
+            :total="samplePagination.total"
+            style="margin-top: 10px"
+          ></el-pagination>
+        </el-tab-pane>
+        <el-tab-pane label="质检方案" name="3">
+          <el-button
+            @click="addInspectionTemplate"
+            type="primary"
+            style="margin-top: 5px"
+            >选择质检方案</el-button
+          >
+          <el-table
+            v-show="activeName === '3'"
+            v-if="schemeList.length > 0"
+            ref="showSchemeListTable"
+            :data="paginatedSchemeList"
+            tooltip-effect="dark"
+            :max-height="300"
+            border
+            row-key="id"
+          >
+            <el-table-column
+              label="序号"
+              type="index"
+              width="50"
+              align="center"
+            ></el-table-column>
+            <el-table-column
+              label="质检方案编码"
+              prop="qualitySchemeTemplateCode"
+              align="center"
+              width="170"
+            ></el-table-column>
+            <el-table-column
+              label="质检方案名称"
+              prop="qualitySchemeTemplateName"
+              align="center"
+              width="170"
+            ></el-table-column>
+            <el-table-column
+              label="质检类型"
+              prop="categoryLevelClassName"
+              align="center"
+              width="170"
+            ></el-table-column>
+            <el-table-column
+              label="质检项编码"
+              prop="inspectionCode"
+              align="center"
+              width="170"
+            ></el-table-column>
+            <el-table-column
+              label="质检项名称"
+              prop="inspectionName"
+              align="center"
+            ></el-table-column>
+            <el-table-column
+              label="工艺参数"
+              prop="defaultValue"
+              align="center"
+            >
+              <template slot-scope="scope">
+                <div style="display: flex; flex-direction: row">
+                  <DictSelection
+                    v-if="btnType != 'detail'"
+                    style="width: 85px"
+                    clearable
+                    dictName="数学字符"
+                    v-model="scope.row.symbol"
+                  ></DictSelection>
+                  <el-input
+                    :disabled="btnType == 'detail'"
+                    v-model="scope.row.defaultValue"
+                    placeholder="请输入内容"
+                    style="width: 120px"
+                  ></el-input>
+                  <DictSelection
+                    v-if="btnType != 'detail'"
+                    dictName="工艺参数单位"
+                    clearable
+                    filterable
+                    v-model="scope.row.unitName"
+                    style="width: 100px"
+                  >
+                  </DictSelection>
+                </div>
+              </template>
+            </el-table-column>
+          </el-table>
+          <el-pagination
+            v-show="activeName === '3' && schemeList.length > 0"
+            @size-change="handleSchemeSizeChange"
+            @current-change="handleSchemeCurrentChange"
+            :current-page="schemePagination.currentPage"
+            :page-sizes="[10, 20, 50, 100]"
+            :page-size="schemePagination.pageSize"
+            layout="total, sizes, prev, pager, next, jumper"
+            :total="schemePagination.total"
+            style="margin-top: 10px"
+          ></el-pagination>
+        </el-tab-pane>
+      </el-tabs>
+    </el-row>
+
+    <template v-slot:footer>
+      <el-button @click="handleClose">取消</el-button>
+      <el-button
+        v-if="btnType != 'detail' && btnType != 'issued'"
+        type="primary"
+        :loading="loading"
+        @click="handleSave"
+        >保存</el-button
+      >
+      <el-button
+        v-if="btnType != 'detail'"
+        type="primary"
+        :loading="loading"
+        @click="handleIssued"
+        >下发</el-button
+      >
+      <inspectionTemplateDialog
+        ref="inspectionTemplateRef"
+        @choose="inspectionTemplateSuccess"
+      ></inspectionTemplateDialog>
+    </template>
+  </ele-modal>
+</template>
+
+<script>
+  // import baseInfo from './baseInfo.vue';
+  import baseInfo from './new-baseInfo.vue';
+  import inspectionTemplateDialog from '@/views/inspectionTemplate/components/inspectionTemplateDialog.vue';
+  import { getCode } from '@/api/login';
+  import { save, update, planIssued } from '@/api/inspectionPlan';
+  import {
+    getQualityTemplateList,
+    getTemplateListByPlanId,
+    getSampleListByPlanId,
+    getInventoryListByPlanId,
+    outInRecordsPage,
+    getBatchInfoData,
+    getProductOrder,
+    getProductSteup
+  } from '@/api/inspectionPlan/index.js';
+  import { getQualityTemplateByIds } from '@/api/inspectionTemplate';
+
+  export default {
+    components: {
+      baseInfo,
+      inspectionTemplateDialog
+    },
+    data() {
+      const defaultForm = function () {
+        return {
+          id: '',
+          code: '',
+          name: '',
+          type: '',
+          qualityMode: '',
+          inspectionStandards: '',
+          autoOrder: '',
+          groupId: '',
+          groupName: '',
+          executeId: '',
+          executeName: '',
+          planStartTime: '',
+          planEndTime: '',
+          standard: '',
+          planSource: '',
+          planSourceCode: '',
+          productName: '',
+          productCode: '',
+          batchNo: '',
+          specification: '',
+          modelType: '',
+          brandNo: '',
+          productNumber: '',
+          qualifiedNumber: '',
+          unqualifiedNumber: '',
+          qualificationRate: '',
+          totalWeight: '',
+          sampleNumber: null,
+          sampleMeasureUnit: '',
+          sampleProportion: '',
+          supplierMark: '',
+          remark: '',
+          accessory: [],
+          conditionType: 1
+        };
+      };
+      return {
+        defaultForm,
+        // 表单数据
+        baseForm: { ...defaultForm() },
+
+        tableColumns2: [
+          {
+            label: '样品编码',
+            prop: 'sampleCode',
+            width: '150',
+            align: 'center'
+          },
+          {
+            label: '编码',
+            prop: 'categoryCode',
+            width: '150',
+            align: 'center'
+          },
+          {
+            label: '名称',
+            prop: 'categoryName',
+            width: '150',
+            align: 'center'
+          },
+          { label: '批次号', prop: 'batchNo', align: 'center', width: 120 },
+          { label: '发货条码', prop: 'barcodes', align: 'center' },
+          { label: '包装编码', prop: 'packageNo', align: 'center' },
+          { label: '计量数量', prop: 'measureQuantity', align: 'center' },
+          { label: '计量单位', prop: 'measureUnit', align: 'center' },
+          { label: '物料代号', prop: 'materielDesignation', align: 'center' },
+          { label: '客户代号', prop: 'clientCode', align: 'center' },
+          { label: '刻码', prop: 'engrave', align: 'center' },
+          // { 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' },
+          { label: '货区', prop: 'areaName', align: 'center' },
+          { label: '货架', prop: 'goodsShelfName', align: 'center' },
+          { label: '货位', prop: 'goodsAllocationName', align: 'center' },
+          { label: '生产日期', prop: 'productionDate', align: 'center' },
+          { label: '采购日期', prop: 'purchaseDate', align: 'center' }
+        ],
+
+        packingList: [],
+
+        sourceList: [],
+        sourcePagination: {
+          currentPage: 1,
+          pageSize: 10,
+          total: 0
+        },
+
+        sampleList: [],
+        samplePagination: {
+          currentPage: 1,
+          pageSize: 10,
+          total: 0
+        },
+
+        schemeList: [],
+        schemePagination: {
+          currentPage: 1,
+          pageSize: 10,
+          total: 0
+        },
+
+        // 表单验证规则
+        visible: false,
+        btnType: null,
+        title: null,
+        loading: false,
+        listPage: [],
+
+        activeName: '1',
+        selectedList: [],
+        isCheck: false, // 是否拆包  false 不拆包 true 拆包
+
+        rowIds: '',
+        formData: {
+          number: 1,
+          sampleUnit: '',
+          portion: null
+        },
+        rules: {
+          number: [
+            {
+              required: true,
+              message: '请输入',
+              trigger: 'blur'
+            }
+          ],
+          sampleUnit: [
+            {
+              required: true,
+              message: '请选择样品单位',
+              trigger: 'change'
+            }
+          ],
+          portion: [
+            {
+              required: true,
+              message: '请输入',
+              trigger: 'blur'
+            }
+          ]
+        },
+        isScheme: true,
+        isOrder: true,
+        isConsumable: '', //0 单件 1批量
+        netWeight: '', // 净重
+        conditionType: null,
+        isFormNumber: true,
+
+        sampleListCode: '',
+        productItem: {}, //产品信息
+        isUpdateData: true,
+        isChangeNumber: true,
+        isChangeType: true,
+        isOnce: true,
+        dimensionType: ''
+      };
+    },
+    computed: {
+      tableColumns() {
+        let arr = [
+          // (this.btnType !== 'issued' || this.baseForm.qualityMode === 2)
+          //   ? {
+          //     columnKey: 'selection',
+          //     type: 'selection',
+          //     width: 45,
+          //     align: 'center'
+          //   }
+          //   : null,
+          {
+            columnKey: 'selection',
+            type: 'selection',
+            width: 45,
+            align: 'center'
+          },
+          {
+            columnKey: 'index',
+            label: '序号',
+            type: 'index',
+            width: 55,
+            align: 'center',
+            fixed: 'left'
+          },
+          {
+            label: '编码',
+            prop: 'categoryCode',
+            width: 150,
+            align: 'center',
+            showOverflowTooltip: true
+          },
+          {
+            label: '名称',
+            prop: 'categoryName',
+            width: '150',
+            align: 'center',
+            width: 120,
+            showOverflowTooltip: true
+          },
+          { label: '批次号', prop: 'batchNo', align: 'center', width: 120 },
+          { label: '发货条码', prop: 'barcodes', align: 'center' },
+          {
+            label: '包装编码',
+            prop: 'packageNo',
+            align: 'center',
+            width: 120,
+            showOverflowTooltip: true
+          },
+          { 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' },
+          { label: '客户代号', prop: 'clientCode', align: 'center' },
+          {
+            label: '供应商名称',
+            prop: 'supplierName',
+            align: 'center',
+            width: 120,
+            showOverflowTooltip: true
+          },
+          {
+            label: '供应商代号',
+            prop: 'supplierCode',
+            align: 'center',
+            width: '120'
+          },
+          { label: '刻码', prop: 'engrave', align: 'center' },
+          { label: '重量', prop: 'weight', align: 'center' },
+          { label: '重量单位', prop: 'weightUnit', align: 'center' },
+          {
+            label: '仓库',
+            prop: 'warehouseName',
+            align: 'center',
+            width: 120,
+            showOverflowTooltip: true
+          },
+          { label: '货区', prop: 'areaName', align: 'center' },
+          { label: '货架', prop: 'goodsShelfName', align: 'center' },
+          { label: '货位', prop: 'goodsAllocationName', align: 'center' },
+          {
+            label: '生产日期',
+            prop: 'productionDate',
+            align: 'center',
+            width: 120,
+            showOverflowTooltip: true
+          },
+          {
+            label: '采购日期',
+            prop: 'purchaseDate',
+            align: 'center',
+            width: 120,
+            showOverflowTooltip: true
+          }
+        ];
+        return arr;
+      },
+
+      //分页后的来源列表
+      paginatedSourceList() {
+        const { currentPage, pageSize } = this.sourcePagination;
+        const start = (currentPage - 1) * pageSize;
+        const end = start + pageSize;
+        return this.sourceList.slice(start, end);
+      },
+
+      // 分页后的样品列表
+      paginatedSampleList() {
+        if (this.rowIds && this.isOrder) {
+          console.log(this.sampleList, 'sampleList');
+          return this.sampleList;
+        }
+        const { currentPage, pageSize } = this.samplePagination;
+        const start = (currentPage - 1) * pageSize;
+        const end = start + pageSize;
+        return this.sampleList.slice(start, end);
+      },
+      // 分页后的质检方案列表
+      paginatedSchemeList() {
+        if (this.rowIds && this.isScheme) {
+          console.log('101010');
+          console.log(this.schemeList, 'test');
+          return this.schemeList;
+        }
+        const { currentPage, pageSize } = this.schemePagination;
+        const start = (currentPage - 1) * pageSize;
+        const end = start + pageSize;
+        return this.schemeList.slice(start, end);
+      }
+    },
+    created() {},
+    methods: {
+      //成品检验类型,计划来源主数据,修改数量生成来源清单
+      changeProductNumberModel(num) {
+        // if (
+        //   this.btnType == 'add' ||
+        //   (this.btnType == 'edit' && !this.isUpdateData)
+        // ) {
+        //   this.$refs.table12.setData([]);
+        //   this.isOrder = false;
+        //   let nums = Number(num);
+        //   let p = this.productItem;
+        //   let list = [];
+        //   if (this.isConsumable == 0) {
+        //     for (let i = 0; i < nums; i++) {
+        //       let obj = {
+        //         id: p.id,
+        //         batchNo: p.batchNo,
+        //         categoryCode: p.code, //编码
+        //         categoryName: p.name, //名称
+        //         measureQuantity: 1,
+        //         measureUnit: p.measuringUnit, //计量单位
+        //         weightUnit: p.weightUnit, //重量单位
+        //         weight: p.netWeight //重量
+        //       };
+        //       list.push(obj);
+        //     }
+        //   } else if (this.isConsumable == 1) {
+        //     let obj = {
+        //       id: p.id,
+        //       batchNo: p.batchNo,
+        //       categoryCode: p.code, //编码
+        //       categoryName: p.name, //名称
+        //       measureQuantity: nums, //计量数量
+        //       measureUnit: p.measuringUnit, //计量单位
+        //       weightUnit: p.weightUnit, //重量单位
+        //       weight: p.netWeight * nums //重量
+        //     };
+        //     list.push(obj);
+        //   }
+        //   this.$refs.table12.setData(list);
+
+        //   // *** 如果检验方式是全量的话 还需要同步样品清单数据
+        //   if (
+        //     this.baseForm.qualityMode == 1 &&
+        //     this.baseForm.inspectionStandards
+        //   ) {
+        //     this.isFormNumber = false;
+        //     this.handleSampleList();
+        //   }
+        //   console.log(this.baseForm, 'form --');
+        // }
+        console.log('数据33333');
+        this.$refs.table12.setData([]);
+        this.isOrder = false;
+        let nums = Number(num);
+        let p = this.productItem;
+        let list = [];
+        if (this.isConsumable == 0) {
+          for (let i = 0; i < nums; i++) {
+            let obj = {
+              id: p.id,
+              batchNo: p.batchNo,
+              categoryCode: p.code, //编码
+              categoryName: p.name, //名称
+              measureQuantity: 1,
+              measureUnit: p.measuringUnit, //计量单位
+              weightUnit: p.weightUnit, //重量单位
+              weight: p.netWeight //重量
+            };
+            list.push(obj);
+          }
+        } else if (this.isConsumable == 1) {
+          let obj = {
+            id: p.id,
+            batchNo: p.batchNo,
+            categoryCode: p.code, //编码
+            categoryName: p.name, //名称
+            measureQuantity: nums, //计量数量
+            measureUnit: p.measuringUnit, //计量单位
+            weightUnit: p.weightUnit, //重量单位
+            weight: p.netWeight * nums //重量
+          };
+          list.push(obj);
+        }
+        console.log('数据22222');
+        console.log(this.isOrder);
+        this.$refs.table12.setData(list);
+
+        // *** 如果检验方式是全量的话 还需要同步样品清单数据
+        if (
+          this.baseForm.qualityMode == 1 &&
+          this.baseForm.inspectionStandards
+        ) {
+          this.isFormNumber = false;
+          console.log('+++++++++2');
+          this.handleSampleList();
+        }
+        console.log(this.baseForm, 'form --');
+      },
+
+      //成品类型检验类型,计划来源库存台账, 生成来源清单
+      changesStokledgerNumberModal(val, dimension) {
+        console.log(val, dimension, '获取成品检验订单数据');
+        this.$refs.table12.setData([]);
+        if (dimension) this.dimensionType = dimension;
+        if (dimension == 3) {
+          this.$refs.table12.setData(val);
+          if (this.baseForm.qualityMode == '1') {
+            this.handleUnpackCase(val);
+          } else if (this.baseForm.qualityMode == '2') {
+            this.sampleList = [];
+          }
+          return;
+        }
+        console.log('其他', 'dimension');
+        let item = val[0];
+        let num = Number(item.outboundNum);
+        let list = [];
+        // let weight = (item.weight / item.measureQuantity).toFixed(2);
+        let weight = (
+          (item.weight / item.measureQuantity) *
+          item.outboundNum
+        ).toFixed(2);
+        list.push({
+          ...item,
+          id: 1,
+          packingQuantity: null,
+          measureQuantity: item.outboundNum,
+          weight
+        });
+
+        // for (let i = 0; i < num; i++) {
+        //   list.push({
+        //     ...item,
+        //     id: i + 1,
+        //     packingQuantity: null,
+        //     measureQuantity: 1,
+        //     weight
+        //   });
+        // }
+        // list.push({
+        //   ...item
+        // });
+        console.log(list, 'for循环成品检验订单数据');
+        this.$refs.table12.setData(list);
+        if (this.baseForm.qualityMode == '1') {
+          this.handleUnpackCase(list);
+        } else if (this.baseForm.qualityMode == '2') {
+          this.sampleList = [];
+        }
+      },
+
+      // changesStokledgerNumberModal(val, dimension) {
+      //   console.log(val, dimension, '获取成品检验订单数据');
+      //   this.$refs.table12.setData([]);
+      //   if (dimension) this.dimensionType = dimension;
+      //   if (dimension == 3) return this.$refs.table12.setData(val);
+      //   let item = val[0];
+      //   let num = Number(item.outboundNum);
+      //   let list = [];
+      //   let weight = (item.weight / item.measureQuantity).toFixed(2);
+      //   for (let i = 0; i < num; i++) {
+      //     list.push({
+      //       ...item,
+      //       id: i + 1,
+      //       packingQuantity: null,
+      //       measureQuantity: 1,
+      //       weight
+      //     });
+      //   }
+      //   console.log(list, 'for循环成品检验订单数据');
+      //   this.$refs.table12.setData(list);
+      //   if (this.baseForm.qualityMode == '1') {
+      //     this.handleUnpackCase(list);
+      //   } else if (this.baseForm.qualityMode == '2') {
+      //     this.sampleList = [];
+      //   }
+      // },
+
+      //获取基本信息中计量方式
+      getInspectionStandards(data) {
+        console.log(data, 'data');
+        this.baseForm.inspectionStandards = data;
+        if (this.baseForm.type == '3' && this.baseForm.planSource == '6') {
+          // this.isOrder = false;
+          this.handleSampleList();
+        }
+        if (this.btnType == 'edit' && !this.isOnce) {
+          this.isOrder = false;
+          this.handleSampleList();
+        }
+        this.isOnce = false;
+      },
+      async datasource({ page, limit, where }) {
+        console.log(this.btnType);
+        console.log(this.isScheme, this.isOrder);
+        const res = await getInventoryListByPlanId({
+          ...where,
+          pageNum: page,
+          size: limit
+        });
+        this.packingList = res.list;
+        return res;
+      },
+      // 切换质检内容
+      handleClick(tab) {
+        this.activeName = tab.name;
+      },
+      async open(type, row) {
+        this.visible = true;
+        this.activeName = '1';
+        this.btnType = type;
+        this.title =
+          type == 'add'
+            ? '新增'
+            : type == 'edit'
+            ? '编辑'
+            : type == 'issued'
+            ? '下发'
+            : '详情';
+
+        if (this.btnType === 'add') {
+          const code = await getCode('qms_plan_code');
+          this.baseForm.code = code;
+          this.rowIds = '';
+          return;
+        } else {
+          await this.handleEditOrDetail(row);
+        }
+      },
+      addInspectionTemplate() {
+        this.$refs.inspectionTemplateRef.open();
+      },
+      async inspectionTemplateSuccess(select) {
+        let data = await getQualityTemplateByIds({
+          templateIds: select.map((item) => item.id)
+        });
+        console.log('---------------------------');
+        this.isScheme = false;
+        this.schemeList.push(...data);
+        this.schemePagination.total = this.schemeList.length;
+      },
+      async handleEditOrDetail(row) {
+        console.log('row====', row);
+        row.accessory = row.accessory || [];
+
+        this.baseForm = {
+          ...JSON.parse(JSON.stringify(row)),
+          groupId: row.groupId,
+          qualityMode: row.qualityMode
+        };
+
+        console.log('baseInfo:' + this.baseForm);
+
+        this.$nextTick(() => {
+          if (this.$refs.baseInfoRefs) {
+            // 获取人员
+            if (this.baseForm.groupId) {
+              this.$refs.baseInfoRefs.getUserList({
+                groupId: this.baseForm.groupId
+              });
+            }
+            //根据类型获取计划来源
+            if (this.baseForm.type) {
+              this.$refs.baseInfoRefs.typeChange(this.baseForm.type);
+            }
+            // if (this.baseForm.productId) {
+            //   this.$refs.baseInfoRefs.getProductDetails(
+            //     this.baseForm.productId
+            //   );
+            // }
+          }
+        });
+
+        // 如果是编辑或者详情,则查询物料清单、质检方案和样品列表
+        if (row.id) {
+          this.rowIds = row.id;
+          this.isScheme = true;
+          this.schemePagination.currentPage = 1;
+          this.schemePagination.pageSize = 10;
+          this.schemePagination.total = 0;
+          this.samplePagination.pageSize = 10;
+          this.samplePagination.currentPage = 1;
+          this.samplePagination.total = 0;
+          this.isFormNumber = true;
+          this.isOrder = true;
+          console.log('edit true');
+
+          if (row.isUnpack === 1) {
+            this.isCheck = true;
+          } else {
+            this.isCheck = false;
+          }
+          //操作行点击时查询清单
+          // await this.getInventoryList();
+          await this.reload({ planId: row.id });
+          //操作行点击时查询样品
+          await this.getSampleList(row.id);
+          //操作行点击时查询质检
+          await this.getTemplateList(row.id);
+        }
+      },
+      reload(where) {
+        this.$nextTick(() => {
+          if (this.$refs.table12 && this.$refs.table12.reload)
+            this.$refs.table12.reload({ page: 1, where: where });
+        });
+      },
+      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 || [];
+        console.log(this.sampleList);
+        this.samplePagination.total = res.count;
+      },
+
+      async getTemplateList(id) {
+        let res = await getTemplateListByPlanId({
+          planId: id,
+          pageNum: this.schemePagination.currentPage,
+          size: this.schemePagination.pageSize
+        });
+        console.log(res.list, 'fffffffffffffff方案--------------------------');
+        this.schemeList = res?.list || [];
+        this.schemePagination.total = res.count;
+      },
+      async getList(
+        receiveNo,
+        productCode,
+        productCategoryId,
+        productCategoryName,
+        categoryid,
+        batchNo,
+        supplierName,
+        supplierMark
+      ) {
+        //通过来源和产品 获取来料清单
+        console.log(999999);
+        await this.getGoodsList(
+          receiveNo,
+          productCode,
+          null,
+          productCategoryId,
+          productCategoryName,
+          categoryid,
+          batchNo,
+          supplierName,
+          supplierMark
+        );
+
+        //通过来源和产品 获取质检方案
+        await this.getQualityTemplate(productCode);
+      },
+      async getGoodsList(
+        receiveNo,
+        productCode,
+        ids,
+        productCategoryId,
+        productCategoryName,
+        categoryid,
+        batchNo,
+        supplierName,
+        supplierMark
+      ) {
+        console.log('数据1-1-1-1-1');
+        this.$refs.table12.setData([]);
+
+        console.log(999999);
+        let res;
+        const res1 = await outInRecordsPage({
+          sourceBizNo: receiveNo,
+          categoryCode: productCode,
+          categoryId: categoryid,
+          qualityQlanId: ids,
+          size: -1
+        });
+        console.log(res1, 'res1');
+        if (res1.list.length > 0) {
+          console.log(res1.list[0].status, 'status=2 不赋值');
+          if (res1.list[0].status != 2) {
+            res = res1.list;
+            this.isCheck = true;
+            console.log('this.isCheck=true', this.isCheck);
+          } else {
+            res = [];
+            this.$message.error('此数据已质检,无需再次质检!');
+            return;
+          }
+        } else {
+          let resData = await getBatchInfoData({
+            sourceBizNo: receiveNo,
+            categoryCode: productCode,
+            batchNo: batchNo
+          });
+          console.log(resData, 'resData');
+          if (resData) {
+            if (resData.qualityControl != 2) {
+              this.isCheck = false;
+              res = [resData];
+            } else {
+              res = [];
+              this.$message.error('此数据已质检,无需再次质检!');
+              return;
+            }
+          }
+        }
+
+        console.log(res, '来料清单');
+        if (res.length > 0) {
+          const _arr1 = res.map((m) => {
+            m.sourceId = m.id;
+            m.productCategoryId = productCategoryId;
+            m.productCategoryName = productCategoryName;
+            delete m.id;
+            return { ...m };
+          });
+          console.log(_arr1, '1234567890');
+
+          this.packingList = _arr1;
+          console.log('数据1010101010');
+          this.$refs.table12.setData(_arr1); //赋值
+          const _arr2 = this.$refs.table12.getData();
+          if (_arr2.length > 1) {
+            this.baseForm.productNumber = _arr2.length;
+          } else {
+            this.baseForm.productNumber = _arr2[0].measureQuantity;
+          }
+          //处理样品清单
+          console.log('+++++++++3');
+          await this.handleSampleList();
+        } else {
+          console.log('数据99999');
+          this.$refs.table12.setData([]);
+        }
+      },
+      async handleSampleList() {
+        // let packingList = this.$refs.table12.getData();
+        console.log(
+          this.baseForm.qualityMode,
+          this.baseForm.inspectionStandards,
+          this.btnType
+        );
+
+        if (this.baseForm.type == '1' && this.btnType != 'detail') {
+          if (this.baseForm.inspectionStandards == '2') {
+            console.log(13131313213);
+            this.sampleList = [];
+            let list = [];
+            if (this.baseForm.productNumber) {
+              let p = this.productItem;
+              console.log(p);
+              let obj = {
+                id: p.id,
+                batchNo: p.batchNo,
+                categoryCode: p.code, //编码
+                categoryName: p.name, //名称
+                measureQuantity: this.baseForm.productNumber, //计量数量
+                measureUnit: p.measuringUnit, //计量单位
+                weightUnit: p.weightUnit, //重量单位
+                weight: p.netWeight * this.baseForm.productNumber //重量
+              };
+              list.push(obj);
+            }
+            if (list.length > 0 && list[0].categoryCode) {
+              this.$refs.table12.setData(list);
+              let packList = this.$refs.table12.getData();
+              this.getFullInspectionWeight(packList);
+            }
+
+            // this.$refs.table12.setData(list);
+            // let packList = this.$refs.table12.getData();
+            // console.log(list);
+            // console.log(1654646);
+            // this.getFullInspectionWeight(packList);
+            // this.getFullInspectionWeight(list);
+          } else {
+            if (this.$refs.table12) {
+              let packingList = this.$refs.table12.getData();
+              if (
+                Math.ceil(Number(this.baseForm.productNumber || 0)) ===
+                packingList.length
+              ) {
+                console.log(
+                  '--->',
+                  Math.ceil(Number(this.baseForm.productNumber || 0))
+                );
+                console.log('--->', packingList.length);
+                await this.handleUnpackCase(packingList);
+                return;
+              } else {
+                this.getFullInspectionWeight(packingList);
+              }
+            }
+            // let packingList = this.$refs.table12.getData();
+            // if (
+            //   Math.ceil(Number(this.baseForm.productNumber || 0)) ===
+            //   packingList.length
+            // ) {
+            //   await this.handleUnpackCase(packingList);
+            //   return;
+            // } else {
+            //   this.getFullInspectionWeight(packingList);
+            // }
+          }
+        }
+
+        //全检时 计量时
+        else if (
+          this.baseForm.qualityMode == 1 &&
+          this.baseForm.inspectionStandards == 1 &&
+          this.btnType != 'detail'
+        ) {
+          this.sampleList = [];
+          console.log(this.baseForm, '---isUnpack---');
+          if (this.baseForm.productNumber) {
+            console.log('数据777777');
+            if (this.$refs.table12) {
+              this.$refs.table12.setData([]);
+              let nums = Number(this.baseForm.productNumber);
+              let p = this.productItem;
+              let list = [];
+
+              for (let i = 0; i < nums; i++) {
+                let obj = {
+                  id: p.id,
+                  batchNo: p.batchNo,
+                  categoryCode: p.code, //编码
+                  categoryName: p.name, //名称
+                  measureQuantity: 1,
+                  measureUnit: p.measuringUnit, //计量单位
+                  weightUnit: p.weightUnit, //重量单位
+                  weight: p.netWeight //重量
+                };
+                list.push(obj);
+              }
+              console.log('数据666666');
+              this.$refs.table12.setData(list);
+              let packList = this.$refs.table12.getData();
+              await this.handleUnpackCase(packList);
+
+              return;
+            }
+            // this.$refs.table12.setData([]);
+            // let nums = Number(this.baseForm.productNumber);
+            // let p = this.productItem;
+            // let list = [];
+
+            // for (let i = 0; i < nums; i++) {
+            //   let obj = {
+            //     id: p.id,
+            //     batchNo: p.batchNo,
+            //     categoryCode: p.code, //编码
+            //     categoryName: p.name, //名称
+            //     measureQuantity: 1,
+            //     measureUnit: p.measuringUnit, //计量单位
+            //     weightUnit: p.weightUnit, //重量单位
+            //     weight: p.netWeight //重量
+            //   };
+            //   list.push(obj);
+            // }
+            // console.log('数据666666');
+            // this.$refs.table12.setData(list);
+            // let packList = this.$refs.table12.getData();
+            // await this.handleUnpackCase(packList);
+
+            // return;
+          }
+          // if (this.rowIds) {
+          //   const res = await getInventoryListByPlanId({
+          //     planId: this.rowIds,
+          //     pageNum: 1,
+          //     size: 5000
+          //   });
+          //   // console.log(res.list);
+          //   if (res.list.length > 0) {
+          //     await this.handleUnpackCase(res.list);
+          //   }
+          // } else {
+          // await this.handleUnpackCase(packingList);
+          // }
+
+          // if (this.baseForm.isUnpack != null && this.baseForm.isUnpack != undefined && this.baseForm.isUnpack != '') {
+          //   //拆包
+          //   if (this.baseForm.isUnpack == 1) {
+          //     await this.handleUnpackCase(packingList);
+          //   } else if (this.baseForm.isUnpack == 0) {
+          //     await this.updatePackingList(packingList);
+          //   }
+          // } else {
+          //   console.log(this.isCheck, 'this.isCheck')
+          //   if (!this.isCheck) {
+          //     await this.handleUnpackCase(packingList);
+          //   } else {
+          //     await this.updatePackingList(packingList);
+          //   }
+          // }
+          //全检 计重时
+        } else if (
+          this.baseForm.qualityMode == 1 &&
+          this.baseForm.inspectionStandards == 2 &&
+          this.btnType != 'detail'
+          // (this.btnType != 'detail' || this.btnType != 'edit')
+          // this.btnType == 'add'
+        ) {
+          this.sampleList = [];
+          let list = [];
+          if (this.baseForm.productNumber) {
+            let p = this.productItem;
+            let obj = {
+              id: p.id,
+              batchNo: p.batchNo,
+              categoryCode: p.code, //编码
+              categoryName: p.name, //名称
+              measureQuantity: this.baseForm.productNumber, //计量数量
+              measureUnit: p.measuringUnit, //计量单位
+              weightUnit: p.weightUnit, //重量单位
+              weight: p.netWeight * this.baseForm.productNumber //重量
+            };
+            list.push(obj);
+          }
+          console.log('数据55555');
+          console.log(list);
+          if (list.length > 0 && list[0].categoryCode) {
+            this.$refs.table12.setData(list);
+            let packList = this.$refs.table12.getData();
+            this.getFullInspectionWeight(packList);
+          }
+          // this.$refs.table12.setData(list);
+          // let packList = this.$refs.table12.getData();
+          // this.getFullInspectionWeight(packList);
+          // this.getFullInspectionWeight(packList);
+        } else {
+          this.sampleList = [];
+        }
+      },
+
+      //全检 计重时生成样品清单
+      async getFullInspectionWeight(packingList) {
+        this.updatePackingList(packingList);
+      },
+
+      //拆包处理样品清单数据
+      async handleUnpackCase(packingList) {
+        if (this.baseForm.type == '3') {
+          this.getFullInspectionWeight(packingList);
+        } else {
+          const num = Number(this.baseForm.productNumber || 0);
+          console.log('num:' + num);
+          if (num) {
+            await this.getUnpackSamList(packingList, num);
+          }
+        }
+      },
+      //获取样品编码
+      async getSampleCode() {
+        return await getCode('sample_code');
+      },
+
+      //更新样品清单数据
+      async updatePackingList(list) {
+        console.log(list);
+        console.log(this.isScheme, this.isOrder);
+        for (let i = 0; i < list.length; i++) {
+          list[i].sampleCode = await this.getSampleCode();
+        }
+        this.sampleList = list;
+        this.baseForm.sampleNumber = list.length;
+        this.samplePagination.currentPage = 1;
+        this.samplePagination.total = list.length;
+        // this.samplePagination.total = this.sampleList.length;
+      },
+
+      async getUnpackSamList(list, num) {
+        console.log(list, num);
+        let data = [];
+        list.forEach((oldItem, index) => {
+          const newMeasureQuantity =
+            oldItem.measureQuantity / this.baseForm.productNumber;
+          const newWeight = parseFloat(
+            (oldItem.weight / this.baseForm.productNumber).toFixed(2)
+          );
+
+          // 将 measureQuantity 转换为数字
+          const measureQuantity = Number(oldItem.measureQuantity);
+          // 判断是否有小数部分
+          const hasDecimal = measureQuantity % 1 !== 0;
+          let roundedQuantity;
+          if (hasDecimal) {
+            // 有小数部分,向上取整
+            roundedQuantity = Math.ceil(measureQuantity);
+          } else {
+            roundedQuantity = measureQuantity;
+          }
+
+          delete oldItem.id;
+
+          for (let i = 0; i < roundedQuantity; i++) {
+            data.push({
+              ...oldItem,
+              measureQuantity: 1,
+              weight: this.netWeight || 0
+              // weight:
+              //   num - index >= 1
+              //     ? this.netWeight
+              //     : ((num * 100000 - index * 100000) / 100000) * this.netWeight
+            });
+          }
+        });
+
+        console.log(data, '样品数据-条数', num);
+        await this.updatePackingList(data);
+      },
+      async getQualityTemplate(productCode, ids) {
+        await getQualityTemplateList({
+          productCode: productCode,
+          qualityQlanId: ids
+        }).then((res) => {
+          if (Object.keys(res).length === 0) {
+            return;
+          }
+
+          this.baseForm.sampleProportion = res.checkProportion;
+          // this.baseForm.inspectionStandards = res?.inspectionStandards;
+
+          let combinedList = [];
+          for (let i = 0; i < res.qualityTemplateVOList.length; i++) {
+            res.qualityTemplateVOList[i].inspectionItemVOList =
+              res.qualityTemplateVOList[i]?.inspectionItemVOList.map((item) => {
+                item.templateId = res.qualityTemplateVOList[i]?.id;
+                item.qualitySchemeTemplateCode =
+                  res.qualityTemplateVOList[i]?.qualitySchemeTemplateCode;
+                item.qualitySchemeTemplateName =
+                  res.qualityTemplateVOList[i]?.qualitySchemeTemplateName;
+
+                delete item.id;
+
+                return {
+                  ...item
+                };
+              });
+            combinedList = combinedList.concat(
+              res.qualityTemplateVOList[i].inspectionItemVOList
+            );
+            console.log(combinedList, '质检方案');
+            this.schemeList = combinedList;
+            this.schemePagination.currentPage = 1;
+            this.schemePagination.total = this.schemeList.length;
+          }
+        });
+      },
+      //来料列表表格选择事件
+      handleSelectionChange(selection) {
+        console.log(selection, '勾选');
+        this.selectedList = selection;
+        //如果取小样
+        if (this.conditionType == 2) {
+          if (this.isCheck) {
+            this.formData.portion = selection.length;
+            this.baseForm.sampleNumber = selection.length;
+          } else {
+            this.baseForm.sampleNumber = this.formData.portion;
+          }
+          const data1 = this.$refs.table12.getData();
+          this.$set(this.formData, 'sampleUnit', data1[0]?.measureUnit);
+          this.$set(this.baseForm, 'sampleMeasureUnit', data1[0]?.measureUnit);
+        } else if (this.conditionType == 1) {
+          this.baseForm.sampleNumber = this.formData.portion;
+          this.formData.number = 0;
+        }
+      },
+      //取样方式选择
+      async handleSampleNumber(val) {
+        console.log(val, 'val');
+        this.conditionType = val;
+        //清空样品清单列表
+        this.sampleList = [];
+        // const dataS = this.$refs.table12.getData();
+        //取整样
+        // if (val == 1) {
+        //   if (this.selectedList.length == 0) {
+        //     this.$message.warning('请先选择样品!');
+        //   } else {
+        //     if (this.isCheck) {
+        //       for (let i = 0; i < this.selectedList.length; i++) {
+        //         for (let j = 0; j < this.selectedList[i].measureQuantity; j++) {
+        //           // this.selectedList[i].sampleCode = await this.getSampleCode();
+        //           this.sampleList.push({
+        //             ...this.selectedList[i],
+        //             sampleCode: await this.getSampleCode(),
+        //             measureQuantity: 1,
+        //             weight: this.selectedList[i].weight / this.selectedList[i].measureQuantity
+        //           });
+        //         }
+        //       }
+        //     } else {
+        //       for (let i = 0; i < this.selectedList.length; i++) {
+        //         let forNum = 0;
+        //         if (this.formData.portion != null && this.formData.portion != '') {
+        //           forNum = this.formData.portion;
+        //         } else {
+        //           forNum = this.selectedList[i].measureQuantity;
+        //         }
+        //         for (let j = 0; j < forNum; j++) {
+        //           // this.selectedList[i].sampleCode = await this.getSampleCode();
+        //           this.sampleList.push({
+        //             ...this.selectedList[i],
+        //             sampleCode: await this.getSampleCode(),
+        //             measureQuantity: 1,
+        //             weight: this.selectedList[i].weight / this.selectedList[i].measureQuantity
+        //           });
+        //         }
+        //       }
+
+        //     }
+        //     this.formData.portion = this.sampleList.length;
+        //     this.activeName = '2';
+        //     this.$message.success('取样成功!');
+        //   }
+        // } else if (val == 2) {
+        //   this.formData.sampleUnit = dataS[0].measureUnit;
+
+        //   this.$refs.table12.clearSelection();
+        //   //小样
+        //   if (this.selectedList.length == 0) {
+        //     this.$message.warning('请先选择样品!');
+        //   } else {
+        //     if (this.formData.number == null || this.formData.sampleUnit == '') {
+        //       this.$message.warning('请先选择取样的数量和单位!');
+        //     }
+        //   }
+        // }
+      },
+
+      handleInputNumber(val) {
+        let packingList = this.$refs.table12.getData();
+
+        const maxValue =
+          packingList.length > 1
+            ? packingList.length
+            : packingList[0].measureQuantity;
+
+        if (val > maxValue) {
+          this.$message.warning('数量不能大于计量数量!');
+          this.formData.number = maxValue;
+          return;
+        }
+      },
+
+      // 整样输入框事件
+      handleInput(val) {
+        if (val == 0 || val == '' || val == null) {
+          this.$refs.table12.clearSelection();
+          return;
+        }
+        let packingList = this.$refs.table12.getData();
+        if (!packingList || packingList.length === 0) {
+          return;
+        }
+        // 计算 packingList 中 measureQuantity 字段的总和
+        const measureQuantitySum = packingList.reduce((sum, item) => {
+          const quantity = Number(item.measureQuantity) || 0;
+          return sum + quantity;
+        }, 0);
+        const portion = Number(this.formData.portion);
+        // 清空当前选中
+        this.$refs.table12.clearSelection();
+        if (this.conditionType == 2) {
+          // 取小样
+          // 确保 portion 不超过数据列表长度
+          const safePortion = Math.min(portion, packingList.length);
+          if (this.isCheck) {
+            // 是否拆包  false 不拆包
+            if (portion > packingList.length) {
+              this.$message.warning('取样数量不能大于来源清单数量!');
+              this.formData.portion = packingList.length;
+            }
+          } else {
+            const maxQuantity = Number(packingList[0].measureQuantity);
+            if (portion > maxQuantity) {
+              this.$message.warning('取样数量不能大于计量数量!');
+              this.formData.portion = maxQuantity;
+            }
+          }
+          // 选中前 safePortion 行
+          packingList.slice(0, safePortion).forEach((row) => {
+            this.$refs.table12.toggleRowSelection(row, true);
+          });
+        } else if (this.conditionType == 1) {
+          // 确保 portion 不超过数据列表长度
+          const safePortion = Math.min(portion, measureQuantitySum);
+          if (portion > measureQuantitySum) {
+            this.$message.warning('取样数量不能大于计量数量!');
+            this.formData.portion = measureQuantitySum;
+          }
+          // 选中前 safePortion 行
+          packingList.slice(0, safePortion).forEach((row) => {
+            this.$refs.table12.toggleRowSelection(row, true);
+          });
+        }
+      },
+      async getCategoryInfo(val) {
+        console.log(this.baseForm.type, this.baseForm.planSource);
+        // this.baseForm.isUnpack = val.categoryWms.isUnpack;
+        console.log(val, '产品信息');
+        if (this.baseForm.type == 2 && this.baseForm.planSource == '4') {
+          if (val.category.id) {
+            const res1 = await getProductSteup(val.category.id);
+
+            const index = res1.findIndex(
+              (item) => item.taskId == val.category.taskId
+            );
+
+            if (index) {
+              const res2 = await getProductOrder({
+                taskId: res1[index - 1].taskId,
+                workOrderId: val.category.id
+              });
+
+              if (res2[0].semiProductList.length > 1) {
+                this.baseForm.productNumber = res2[0].semiProductList.length;
+              } else {
+                this.baseForm.productNumber =
+                  res2[0].semiProductList.measureQuantity;
+              }
+            }
+
+            this.isConsumable = val.category.isConsumable;
+            this.netWeight = val.category.netWeight;
+            this.productItem = val.category;
+
+            console.log('+++++++++');
+            this.handleSampleList();
+            return;
+          }
+        }
+
+        console.log('+++++++++9');
+        this.isConsumable = val.category.isConsumable;
+        this.netWeight = val.category.netWeight;
+        this.productItem = val.category; //产品信息
+      },
+      changeSamUnit(val) {
+        console.log(val);
+        this.$refs.baseInfoRefs.getsampleMeasureUnit(val);
+      },
+
+      //整样确认按钮-样品列表右上角确认按钮
+      // handleExtractFull() {
+      //   this.$refs.ruleForm.validate((valid) => {
+      //     if (valid) {
+      //       if (!this.selectedList || this.selectedList.length == 0) {
+      //         this.$message.warning('请先选择样品!');
+      //         return;
+      //       }
+      //       this.sampleList = []
+      //       //取样条数
+      //       let safePortion = Number(this.formData.portion);
+      //       //计量数量
+      //       let measureQ = this.formData.number || 1;
+      //       //计量单位
+      //       let unit = this.formData.sampleUnit;
+      //       //抽检计量整样小样或者抽检计重小样
+      //       if ((this.baseForm.inspectionStandards === 1) || (this.baseForm.inspectionStandards === 2 && this.conditionType == 2)) {
+      //         if (this.conditionType == 2) {
+      //           if (measureQ <= 0) {
+      //             this.$message.info('取样计量数量必须大于0');
+      //             return
+      //           }
+      //         }
+      //         // 计算总计量数量
+      //         const totalQuantity = this.selectedList.reduce((sum, item) => sum + item['measureQuantity'], 0);
+      //         // 验证取样总量不超过总计量数量,只有计量单位相同才进行验证
+      //         if (this.selectedList[0].measureUnit == unit || this.conditionType == 1) {
+      //           if (measureQ * safePortion > totalQuantity) {
+      //             this.$message.info('取样计量数量不能大于总计量数量');
+      //             return
+      //           }
+      //           // 验证每条数据的计量数量都大于等于取样计量数量
+      //           for (const item of this.selectedList) {
+      //             if (item['measureQuantity'] < measureQ) {
+      //               this.$message.info(`条目计量数量小于取样计量数量`);
+      //               return
+      //             }
+      //           }
+      //         }
+
+      //         if (unit === 'KG') {
+      //           let totalMaxPossible = 0;
+      //           this.selectedList.map(item => {
+      //           const maxPossible = item['measureQuantity'] / measureQ;
+      //           totalMaxPossible += maxPossible;});
+      //           if (totalMaxPossible < safePortion) {
+      //             this.formData.portion = totalMaxPossible;
+      //             return this.$message.info(`最大取样条数为${totalMaxPossible}`);
+      //           }
+      //           // 计算总重量
+      //           let totalWeight = this.selectedList.reduce((sum, item) => sum + item['weight'], 0);
+      //           let weightUnit = this.selectedList[0].weightUnit;
+      //           if (weightUnit === 'G') {
+      //             totalWeight = totalWeight / 1000
+      //           }
+      //           if (measureQ * safePortion > totalWeight) {
+      //             this.$message.info('取样计量重量不能大于总计量重量');
+      //             return
+      //           }
+      //           for (const item of this.selectedList) {
+      //             let weight = weightUnit === 'G' ? item.weight / 1000 : item.weight
+      //             if (weight < measureQ) {
+      //               this.$message.info(`勾选条目重量小于取样重量`);
+      //               return
+      //             }
+      //           }
+      //         }
+
+      //         this.getNewFullSampleList(Math.ceil(safePortion), measureQ, unit);
+      //         //抽检计重整样
+      //       } else if (this.baseForm.inspectionStandards === 2 && this.conditionType == 1) {
+      //         for (const item of this.selectedList) {
+      //           if (item['measureQuantity'] < safePortion) {
+      //             this.$message.info(`所选的条目计量数量小于取样计量数量`);
+      //             return
+      //           }
+      //         }
+      //         let list = [];
+      //         for (let i = 0; i < this.selectedList.length; i++) {
+      //           list.push({
+      //             ...this.selectedList[i],
+      //             measureQuantity: safePortion, //作为计量数量
+      //           });
+      //         }
+      //         this.updatePackingList(list);
+      //       }
+      //       this.activeName = '2'
+      //     }
+      //   });
+      // },
+
+      //从来源数组取样到目标数组
+      async getNewFullSampleList(sampleCount, sampleQuantity, sampleUnit) {
+        console.log(
+          '从来源数组取样到目标数组',
+          sampleCount,
+          sampleQuantity,
+          sampleUnit
+        );
+        const sourceArray = this.selectedList;
+        // 检查单位是否匹配
+        const isUnitMismatch =
+          sourceArray.length > 0 && sourceArray[0].measureUnit !== sampleUnit;
+        // 创建副本并计算初始可取样数量
+        const items = sourceArray.map((item) => ({
+          ...item,
+          remainingQuantity: isUnitMismatch
+            ? Infinity
+            : item['measureQuantity'], // 剩余可取样数量
+          maxPossible: item['measureQuantity'] / sampleQuantity // 最大取样次数
+        }));
+
+        const result = [];
+        let remainingCount = sampleCount;
+
+        // 尽可能均匀地从各条目取样
+        while (remainingCount > 0) {
+          // 按剩余可取样比例排序
+          items.sort(
+            (a, b) =>
+              b.remainingQuantity / b['measureQuantity'] -
+              a.remainingQuantity / a['measureQuantity']
+          );
+
+          let distributed = false;
+
+          for (const item of items) {
+            if (
+              (!isUnitMismatch && remainingCount > 0) ||
+              (item.remainingQuantity >= sampleQuantity && remainingCount > 0)
+            ) {
+              // 添加到结果数组
+              this.samplePagination.total = 0;
+              let sampleCode = await this.getSampleCode();
+              if (
+                this.conditionType == 1 &&
+                this.baseForm.inspectionStandards == 1
+              ) {
+                result.push({ ...item, measureQuantity: 1, sampleCode });
+              } else if (
+                this.conditionType == 2 &&
+                (this.baseForm.inspectionStandards == 1 ||
+                  this.baseForm.inspectionStandards == 2)
+              ) {
+                let weight = (item.weight / item.maxPossible).toFixed(2);
+                result.push({
+                  ...item,
+                  measureQuantity: sampleQuantity,
+                  measureUnit: sampleUnit,
+                  sampleCode,
+                  weight
+                });
+              }
+
+              // 更新剩余数量
+              if (!isUnitMismatch) {
+                item.remainingQuantity -= sampleQuantity;
+              }
+              remainingCount--;
+              distributed = true;
+            }
+          }
+
+          // 如果没有分配任何取样
+          if (!distributed) {
+            break;
+          }
+        }
+
+        console.log('样品清单', this.sampleList);
+        console.log('样品清单List', result);
+        this.sampleList = result;
+        console.log(11111);
+        this.samplePagination.total = result.length;
+        console.log(2222);
+        this.baseForm.sampleNumber = this.sampleList.length; // 更新样品数量
+        console.log(33333);
+        this.changeSamUnit(sampleUnit);
+      },
+
+      //抽样确认按钮事件-样品列表右上角确认按钮
+      handleSampleSubmit() {
+        this.$refs.ruleForm.validate((valid) => {
+          if (valid) {
+            this.sampleList = [];
+            this.baseForm.sampleMeasureUnit = this.formData.sampleUnit;
+            let measureQ = this.formData.number;
+            let unit = this.formData.sampleUnit;
+            let nums = Number(this.formData.portion);
+
+            console.log(measureQ, unit, nums, 'measureQ, unit, nums');
+            this.getNewFullSampleList(nums, measureQ, unit);
+            // if (this.conditionType == 1) {
+            //   this.sampleList = this.selectedList
+            // } else {
+            //   let measureQ = this.formData.number;
+            //   let unit = this.formData.sampleUnit;
+            //   let nums = Number(this.formData.portion);
+            //
+            //   console.log(measureQ, unit, nums, 'measureQ, unit, nums')
+            //   this.getNewSampleList(measureQ, unit, nums)
+            // }
+            this.activeName = '2';
+          }
+        });
+      },
+
+      //更新计量数量、单位后重新生成样品列表数据
+      // async getNewSampleList(measureQ, unit, nums) {
+      //   this.sampleList = [];
+      //   if (!this.selectedList || this.selectedList.length == 0) {
+      //     this.$message.warning('请先选择样品!');
+      //     return;
+      //   }
+
+      //   if (!this.isCheck) {
+      //     let measureQuantity = 1;
+      //     if (this.conditionType == 2) {
+      //       measureQuantity = this.formData.number;
+      //     }
+      //     for (let i = 0; i < nums; i++) {
+      //       this.sampleList.push({
+      //         ...this.selectedList[0],
+      //         sampleCode: await this.getSampleCode(),
+      //         measureQuantity: measureQuantity,
+      //         measureUnit: unit,
+      //         weight: this.netWeight || 0
+      //       });
+      //     }
+      //   } else {
+      //     if (this.conditionType == 1) {
+      //       measureQ = 1;
+      //     }
+      //     for (let i = 0; i < this.selectedList.length; i++) {
+      //       this.sampleList.push({
+      //         ...this.selectedList[i],
+      //         sampleCode: await this.getSampleCode(),
+      //         measureQuantity: measureQ,
+      //         measureUnit: unit,
+      //         weight: this.netWeight || 0
+      //       });
+      //     }
+
+      //   }
+      // },
+      //监听类型变化
+      resetTable() {
+        this.$nextTick(() => {
+          this.table1();
+          this.table2();
+        });
+      },
+      table1() {
+        this.$refs.table12.setData([]);
+        this.schemeList = [];
+      },
+      table2() {
+        this.$nextTick(() => {
+          // if (this.btnType == 'edit' && !this.isOnce) {
+          //   this.isOrder = false;
+          this.sampleList = [];
+          // }
+        });
+      },
+      resetForm() {
+        this.baseForm = { ...this.defaultForm() };
+      },
+      handleClose() {
+        this.$nextTick(() => {
+          // 关闭后,销毁所有的表单数据
+          this.resetForm();
+          this.resetTable();
+          this.isScheme = true;
+          this.isOrder = true;
+          this.packingList = [];
+          this.sampleList = [];
+          this.samplePagination = {
+            currentPage: 1,
+            pageSize: 10,
+            total: 0
+          };
+          (this.schemeList = []),
+            (this.schemePagination = {
+              currentPage: 1,
+              pageSize: 10,
+              total: 0
+            });
+          // 表单验证规则
+          this.visible = false;
+          this.btnType = null;
+          this.title = null;
+          this.loading = false;
+          this.listPage = [];
+          this.activeName = '1';
+          this.selectedList = [];
+          this.isCheck = false; // 是否拆包  false 不拆包 true 拆包
+          this.rowIds = '';
+          (this.formData = {
+            number: 1,
+            sampleUnit: '',
+            portion: null
+          }),
+            (this.rules = {
+              number: [
+                {
+                  required: true,
+                  message: '请输入',
+                  trigger: 'blur'
+                }
+              ],
+              sampleUnit: [
+                {
+                  required: true,
+                  message: '请选择样品单位',
+                  trigger: 'change'
+                }
+              ],
+              portion: [
+                {
+                  required: true,
+                  message: '请输入',
+                  trigger: 'blur'
+                }
+              ]
+            });
+          this.isConsumable = ''; //0 单件 1批量
+          this.netWeight = ''; // 净重
+          this.conditionType = null;
+          this.isFormNumber = true;
+          this.sampleListCode = '';
+          this.productItem = {}; //产品信息
+          this.$refs['baseInfoRefs'] &&
+            this.$refs['baseInfoRefs'].$refs.form1.resetFields();
+          this.visible = false;
+          this.baseForm.groupId = '';
+          this.baseForm.qualityMode = '';
+          this.baseForm = { ...this.defaultForm() };
+          this.isChangeNumber = true;
+          this.isChangeType = true;
+          this.isOnce = true;
+          this.dimensionType = '';
+        });
+      },
+
+      /* 保存编辑 */
+      handleSave() {
+        this.$refs.baseInfoRefs.$refs.form1.validate((valid) => {
+          if (!valid) {
+            return false;
+          }
+
+          this.loading = true;
+          if (this.baseForm.isUnpack == null || this.baseForm.isUnpack == '') {
+            this.baseForm.isUnpack = this.isCheck ? 1 : 2;
+          }
+          this.baseForm.conditionType = this.conditionType;
+          let params = {
+            ...this.baseForm,
+            qualityInventoryList: this.$refs.table12.getData(),
+            sampleList: this.sampleList,
+            planTemplateList: this.schemeList
+          };
+          console.log(params, 'params');
+
+          if (this.btnType == 'issued' && this.schemeList.length < 1) {
+            this.$message.warning('质检方案不能为空!');
+            this.loading = false;
+            return;
+          }
+          let URL =
+            this.btnType == 'add' ? save : this.btnType == 'edit' ? update : '';
+          console.log(params, 'params');
+
+          URL(params)
+            .then((msg) => {
+              this.loading = false;
+              this.$message.success(msg);
+              this.handleClose();
+              this.$emit('done');
+            })
+            .catch((e) => {
+              this.loading = false;
+            });
+        });
+      },
+      handleIssued() {
+        if (this.sampleList.length == 0) {
+          this.$message.warning('样品清单为空!先进行修改操作再下发!');
+          return;
+        }
+        this.$refs.baseInfoRefs.$refs.form1.validate((valid) => {
+          if (!valid) {
+            return false;
+          }
+          this.loading = true;
+
+          if (this.baseForm.isUnpack == null || this.baseForm.isUnpack == '') {
+            this.baseForm.isUnpack = this.isCheck ? 1 : 2;
+          }
+          this.baseForm.conditionType = this.conditionType;
+          let params = {
+            ...this.baseForm,
+            qualityInventoryList: this.$refs.table12.getData(),
+            sampleList: this.sampleList,
+            planTemplateList: this.schemeList
+          };
+
+          console.log(params, 'params');
+
+          if (this.btnType == 'issued' && this.schemeList.length < 1) {
+            this.$message.warning('质检方案不能为空!');
+            this.loading = false;
+            return;
+          }
+
+          planIssued(params)
+            .then((msg) => {
+              this.loading = false;
+              this.$message.success(msg);
+              this.handleClose();
+              this.$emit('done');
+            })
+            .catch((e) => {
+              this.loading = false;
+            });
+        });
+      },
+      // 样品列表分页方法
+      async handleSampleSizeChange(val) {
+        this.samplePagination.pageSize = val;
+        this.samplePagination.currentPage = 1;
+        if (this.rowIds && this.isOrder) {
+          await this.getSampleList(this.rowIds);
+        }
+        //操作行点击时查询样品
+      },
+      async handleSampleCurrentChange(val) {
+        this.samplePagination.currentPage = val;
+        if (this.rowIds && this.isOrder) {
+          await this.getSampleList(this.rowIds);
+        }
+      },
+      // 质检方案分页方法
+      async handleSchemeSizeChange(val) {
+        this.schemePagination.pageSize = val;
+        this.schemePagination.currentPage = 1;
+        //操作行点击时查询质检
+        if (this.rowIds && this.isScheme) {
+          await this.getTemplateList(this.rowIds);
+        }
+      },
+      async handleSchemeCurrentChange(val) {
+        this.schemePagination.currentPage = val;
+        //操作行点击时查询质检
+        if (this.rowIds && this.isScheme) {
+          await this.getTemplateList(this.rowIds);
+        }
+      },
+      //检验方式改变时,重新获取样品列表
+      changeModel(val) {
+        console.log('更改检验方式');
+        this.baseForm.qualityMode = val;
+        if (this.btnType != 'issued') {
+          this.baseForm.sampleNumber = '';
+        }
+        console.log(
+          this.baseForm.productNumber,
+          'productNumberproductNumber数量'
+        );
+
+        if (this.baseForm.type == '3') {
+          if (this.$refs.table12 && this.dimensionType) {
+            const listData = this.$refs.table12.getData();
+            console.log(listData, '成品检验订单数据');
+            this.changesStokledgerNumberModal(listData, this.dimensionType);
+          }
+          return;
+        }
+
+        if (this.baseForm.qualityMode == 1) {
+          console.log('+++++++++1');
+          this.handleSampleList();
+        } else {
+          this.sampleList = [];
+        }
+      },
+
+      //确定按钮
+      handleExtractFull() {
+        this.$refs.ruleForm.validate(async (valid) => {
+          if (!valid || !this.validateSelection()) return;
+          this.baseForm.sampleMeasureUnit = this.formData.sampleUnit;
+          this.sampleList = [];
+          const sampleCount = Number(this.formData.portion);
+          const measureQ = this.formData.number || 1;
+          const unit = this.formData.sampleUnit;
+          console.log(this.conditionType, this.baseForm.inspectionStandards);
+          try {
+            if (this.isStandard1OrWeightSample()) {
+              //抽检计量整样小样或者抽检计重小样
+              if (!this.validateMeasureQuantity(measureQ, unit, sampleCount))
+                return;
+              if (unit === 'KG' && !this.validateWeight(measureQ, sampleCount))
+                return; // 若计量单位为重量,还需验证总重量是否足够
+              console.log('getNewFullSampleList');
+              if (this.conditionType == '1' && this.baseForm.type == '3') {
+                await this.handleWeightFullSample(sampleCount);
+              } else {
+                await this.getNewFullSampleList(
+                  Math.ceil(sampleCount),
+                  measureQ,
+                  unit
+                );
+              }
+            } else if (this.isWeightStandardFullSample()) {
+              console.log('handleWeightFullSample');
+              //抽检取计重取整样
+              if (!this.validateSampleCount(sampleCount)) return;
+              await this.handleWeightFullSample(sampleCount);
+            }
+            this.activeName = '2';
+          } catch (error) {
+            console.error('取样处理失败:', error);
+            this.$message.error('取样处理失败');
+          }
+        });
+      },
+      validateSelection() {
+        if (!this.selectedList?.length) {
+          this.$message.warning('请先选择样品!');
+          return false;
+        }
+        return true;
+      },
+
+      isStandard1OrWeightSample() {
+        return (
+          this.baseForm.inspectionStandards === 1 ||
+          (this.baseForm.inspectionStandards === 2 && this.conditionType == 2)
+        );
+      },
+
+      isWeightStandardFullSample() {
+        return (
+          this.baseForm.inspectionStandards === 2 && this.conditionType == 1
+        );
+      },
+
+      validateMeasureQuantity(measureQ, unit, sampleCount) {
+        if (this.conditionType == 2 && measureQ <= 0) {
+          this.$message.info('取样计量数量必须大于0');
+          return false;
+        }
+
+        const totalQuantity = this.selectedList.reduce(
+          (sum, item) => sum + item.measureQuantity,
+          0
+        );
+        if (
+          (this.selectedList[0].measureUnit === unit ||
+            this.conditionType == 1) &&
+          measureQ * sampleCount > totalQuantity
+        ) {
+          this.$message.info('取样计量数量不能大于总计量数量');
+          return false;
+        }
+
+        const invalidItem = this.selectedList.find(
+          (item) => item.measureQuantity < measureQ
+        );
+        if (invalidItem) {
+          this.$message.info('条目计量数量小于取样计量数量');
+          return false;
+        }
+
+        return true;
+      },
+
+      validateWeight(measureQ, sampleCount) {
+        let totalMaxPossible = 0;
+        this.selectedList.forEach((item) => {
+          totalMaxPossible += item.measureQuantity / measureQ;
+        });
+
+        if (totalMaxPossible < sampleCount) {
+          this.formData.portion = totalMaxPossible;
+          this.$message.info(`最大取样条数为${totalMaxPossible}`);
+          return false;
+        }
+
+        let totalWeight = this.selectedList.reduce(
+          (sum, item) => sum + item.weight,
+          0
+        );
+        const weightUnit = this.selectedList[0].weightUnit;
+        if (weightUnit === 'G') totalWeight /= 1000;
+
+        console.log(measureQ * sampleCount, totalWeight);
+
+        if (measureQ * sampleCount > totalWeight) {
+          this.$message.info('取样计量重量不能大于总计量重量');
+          return false;
+        }
+
+        const invalidItem = this.selectedList.find((item) => {
+          const weight =
+            item.weightUnit === 'G' ? item.weight / 1000 : item.weight;
+          return weight < measureQ;
+        });
+
+        if (invalidItem) {
+          this.$message.info('勾选条目重量小于取样重量');
+          return false;
+        }
+
+        return true;
+      },
+
+      validateSampleCount(sampleCount) {
+        const invalidItem = this.selectedList.find(
+          (item) => item.measureQuantity < sampleCount
+        );
+        if (invalidItem) {
+          this.$message.info('所选的条目计量数量小于取样计量数量');
+          return false;
+        }
+        return true;
+      },
+
+      async handleWeightFullSample(sampleCount) {
+        console.log(sampleCount, 'sampleCount');
+        const list = this.selectedList.map((item) => ({
+          ...item,
+          measureQuantity: sampleCount,
+          weight: item.singleWeight
+            ? (Number(item.singleWeight) * Number(sampleCount)).toFixed(2)
+            : (
+                (Number(item.weight) / Number(item.outboundNum)) *
+                Number(sampleCount)
+              ).toFixed(2)
+        }));
+        await this.updatePackingList(list);
+      }
+    }
+  };
+</script>
+
+<style lang="scss" scoped>
+  .location-warp {
+    display: flex;
+
+    .detail {
+      margin-left: 10px;
+    }
+  }
+
+  :deep(.el-form-item__content .el-input-group__prepend) {
+    background-color: #fff;
+  }
+
+  :deep(
+      .el-dialog:not(.ele-dialog-form)
+        .el-dialog__body
+        .el-form
+        .el-form-item:last-child
+    ) {
+    margin-bottom: 22px;
+  }
+
+  .add-product {
+    width: 100%;
+    display: flex;
+    align-items: center;
+    justify-content: flex-end;
+    font-size: 30px;
+    color: #1890ff;
+    margin: 10px 0;
+    cursor: pointer;
+  }
+
+  .el-pagination {
+    padding: 12px 16px;
+    background: #fff;
+    border: 1px solid#ebeef5;
+    border-top: none;
+  }
+
+  .flex {
+    display: flex;
+    align-items: center;
+  }
+</style>

+ 348 - 311
src/views/inspectionPlan/index.vue

@@ -4,16 +4,31 @@
       <!-- <search ref="search" @search="reload"></search> -->
       <seek-page :seekList="seekList" @search="search"></seek-page>
 
-      <ele-pro-table ref="tableRef" :columns="columns" :datasource="datasource" :pageSize="20"
-        :pageSizes="[20, 30, 40, 50, 100]">
+      <ele-pro-table
+        ref="tableRef"
+        :columns="columns"
+        :datasource="datasource"
+        :pageSize="20"
+        :pageSizes="[20, 30, 40, 50, 100]"
+      >
         <!-- 表头工具栏 -->
         <template v-slot:toolbar>
-          <el-button size="small" type="primary" icon="el-icon-plus" class="ele-btn-icon" @click="openEdit('add')">
+          <el-button
+            size="small"
+            type="primary"
+            icon="el-icon-plus"
+            class="ele-btn-icon"
+            @click="openEdit('add')"
+          >
             新增
           </el-button>
         </template>
         <template v-slot:code="{ row }">
-          <el-link type="primary" :underline="false" @click="openEdit('detail', row)">
+          <el-link
+            type="primary"
+            :underline="false"
+            @click="openEdit('detail', row)"
+          >
             {{ row.code }}
           </el-link>
         </template>
@@ -24,20 +39,40 @@
           {{ getDictValue('取样类型', row.qualityMode) }}
         </template>
         <template v-slot:accessory="scope">
-          <el-link v-for="link in scope.row.accessory" :key="link.id" type="primary" :underline="false"
-            @click="downloadFile(link)">
+          <el-link
+            v-for="link in scope.row.accessory"
+            :key="link.id"
+            type="primary"
+            :underline="false"
+            @click="downloadFile(link)"
+          >
             {{ link.name }}
           </el-link>
         </template>
         <!-- 操作列 -->
         <template v-slot:action="{ row }">
-          <el-link type="primary" :underline="false" @click="openEdit('edit', row)" v-if="row.status == 0">
+          <el-link
+            type="primary"
+            :underline="false"
+            @click="openEdit('edit', row)"
+            v-if="row.status == 0"
+          >
             修改
           </el-link>
-          <el-link type="primary" :underline="false" v-if="row.status == 0" @click="openEdit('issued', row)">
+          <el-link
+            type="primary"
+            :underline="false"
+            v-if="row.status == 0"
+            @click="openEdit('issued', row)"
+          >
             下发
           </el-link>
-          <el-popconfirm class="ele-action" title="确定要删除吗?" @confirm="remove(row)" v-if="row.status == 0">
+          <el-popconfirm
+            class="ele-action"
+            title="确定要删除吗?"
+            @confirm="remove(row)"
+            v-if="row.status == 0"
+          >
             <template v-slot:reference>
               <el-link type="danger" :underline="false" icon="el-icon-delete">
                 删除
@@ -47,321 +82,323 @@
         </template>
       </ele-pro-table>
     </el-card>
-    <edit ref="edit" @done="reload"></edit>
+    <!-- <edit ref="edit" @done="reload"></edit> -->
+    <edit ref="edit"></edit>
   </div>
 </template>
 <script>
-import search from './components/search.vue';
-import edit from './components/edit.vue';
-import { getList, removeItem } from '@/api/inspectionPlan';
-import dictMixins from '@/mixins/dictMixins';
-import { getFile } from '@/api/system/file';
-import { getByCode } from '@/api/system/dictionary-data';
+  import search from './components/search.vue';
+  // import edit from './components/edit.vue';
+  import edit from './components/new-edit.vue';
+  import { getList, removeItem } from '@/api/inspectionPlan';
+  import dictMixins from '@/mixins/dictMixins';
+  import { getFile } from '@/api/system/file';
+  import { getByCode } from '@/api/system/dictionary-data';
 
-export default {
-  mixins: [dictMixins],
-  components: {
-    search,
-    edit
-  },
-  data() {
-    return {
-      columns: [
-        {
-          columnKey: 'index',
-          label: '序号',
-          type: 'index',
-          width: 55,
-          align: 'center',
-          showOverflowTooltip: true,
-          fixed: 'left'
-        },
-
-        {
-          prop: 'code',
-          slot: 'code',
-          label: '质检计划编码',
-          width: 160,
-          align: 'center',
-          showOverflowTooltip: true,
-          fixed: 'left'
-        },
-        {
-          label: '质检计划名称',
-          prop: 'name',
-          width: 160,
-          align: 'center',
-          showOverflowTooltip: true,
-          fixed: 'left'
-        },
-        {
-          label: '来源单据编码',
-          prop: 'planSourceCode',
-          width: 160,
-          align: 'center',
-          showOverflowTooltip: true
-        },
-        {
-          prop: 'productCode',
-          width: 120,
-          label: '编码',
-          align: 'center',
-          showOverflowTooltip: true
-        },
-        {
-          prop: 'productName',
-          width: 120,
-          label: '名称',
-          align: 'center',
-          showOverflowTooltip: true
-        },
-        {
-          prop: 'batchNo',
-          label: '批次号',
-          width: 160,
-          align: 'center',
-          showOverflowTooltip: true
-        },
-        {
-          label: '类型',
-          prop: 'type',
-          slot: 'type',
-          width: 120,
-          align: 'center',
-          showOverflowTooltip: true
-        },
-        {
-          label: '检验方式',
-          prop: 'qualityMode',
-          slot: 'qualityMode',
-          width: 120,
-          align: 'center',
-          showOverflowTooltip: true
-        },
-        {
-          label: '自动派单',
-          prop: 'autoOrder',
-          align: 'center',
-          showOverflowTooltip: true,
-          formatter: (row, column, cellValue) => {
-            return cellValue == 1 ? '是' : '否';
-          }
-        },
-        // {
-        //   prop: 'productName',
-        //   label: '产品名称',
-        // },
-        // {
-        //   prop: 'productCode',
-        //   label: '产品编码',
-        // },
-        // {
-        //   prop: 'specification',
-        //   label: '规格',
-        // },
-        // {
-        //   prop: 'brandNo',
-        //   label: '牌号',
-        // },
-
-        // {
-        //   prop: 'productNumber',
-        //   label: '数量',
-        //   width: 60
-        // },
+  export default {
+    mixins: [dictMixins],
+    components: {
+      search,
+      edit
+    },
+    data() {
+      return {
+        columns: [
+          {
+            columnKey: 'index',
+            label: '序号',
+            type: 'index',
+            width: 55,
+            align: 'center',
+            showOverflowTooltip: true,
+            fixed: 'left'
+          },
 
-        {
-          label: '执行部门',
-          prop: 'groupName',
-          align: 'center',
-          showOverflowTooltip: true
-        },
-        {
-          label: '执行人',
-          prop: 'executeName',
-          align: 'center',
-          width: 120,
-          showOverflowTooltip: true
-        },
-        {
-          label: '创建时间',
-          prop: 'createTime',
-          align: 'center',
-          width: 120,
-          showOverflowTooltip: true
-        },
-        {
-          label: '开始时间',
-          prop: 'planStartTime',
-          align: 'center',
-          width: 120,
-          showOverflowTooltip: true
-        },
-        {
-          label: '结束时间',
-          prop: 'planEndTime',
-          align: 'center',
-          width: 120,
-          showOverflowTooltip: true
-        },
-        // {
-        //   label: '附件',
-        //   prop: 'accessory',
-        //   slot: 'accessory',
-        //   align: 'center',
-        //   width: 120,
-        //   showOverflowTooltip: true
-        // },
-        {
-          label: '状态',
-          prop: 'status',
-          width: 70,
-          align: 'center',
-          showOverflowTooltip: true,
-          formatter: (row, column, cellValue) => {
-            return cellValue == 1 ? '已下发' : '未下发';
-          }
-        },
+          {
+            prop: 'code',
+            slot: 'code',
+            label: '质检计划编码',
+            width: 160,
+            align: 'center',
+            showOverflowTooltip: true,
+            fixed: 'left'
+          },
+          {
+            label: '质检计划名称',
+            prop: 'name',
+            width: 160,
+            align: 'center',
+            showOverflowTooltip: true,
+            fixed: 'left'
+          },
+          {
+            label: '来源单据编码',
+            prop: 'planSourceCode',
+            width: 160,
+            align: 'center',
+            showOverflowTooltip: true
+          },
+          {
+            prop: 'productCode',
+            width: 120,
+            label: '编码',
+            align: 'center',
+            showOverflowTooltip: true
+          },
+          {
+            prop: 'productName',
+            width: 120,
+            label: '名称',
+            align: 'center',
+            showOverflowTooltip: true
+          },
+          {
+            prop: 'batchNo',
+            label: '批次号',
+            width: 160,
+            align: 'center',
+            showOverflowTooltip: true
+          },
+          {
+            label: '类型',
+            prop: 'type',
+            slot: 'type',
+            width: 120,
+            align: 'center',
+            showOverflowTooltip: true
+          },
+          {
+            label: '检验方式',
+            prop: 'qualityMode',
+            slot: 'qualityMode',
+            width: 120,
+            align: 'center',
+            showOverflowTooltip: true
+          },
+          {
+            label: '自动派单',
+            prop: 'autoOrder',
+            align: 'center',
+            showOverflowTooltip: true,
+            formatter: (row, column, cellValue) => {
+              return cellValue == 1 ? '是' : '否';
+            }
+          },
+          // {
+          //   prop: 'productName',
+          //   label: '产品名称',
+          // },
+          // {
+          //   prop: 'productCode',
+          //   label: '产品编码',
+          // },
+          // {
+          //   prop: 'specification',
+          //   label: '规格',
+          // },
+          // {
+          //   prop: 'brandNo',
+          //   label: '牌号',
+          // },
 
-        {
-          columnKey: 'action',
-          label: '操作',
-          width: 160,
-          align: 'center',
-          resizable: false,
-          slot: 'action',
-          showOverflowTooltip: true,
-          fixed: 'right'
-        }
-      ],
-      typeList:[],//类型列表
-      qualityMode:[] 
-    };
-  },
-  computed: {
-    seekList() {
-      return [
-        {
-          label: "计划编码:",
-          value: "code",
-          type: "input",
-          placeholder: '',
-        },
-        {
-          label: "计划名称:",
-          value: "name",
-          type: "input",
-          placeholder: '',
-        },
-        {
-          label: "来源单据编码:",
-          value: "planSourceCode",
-          type: "input",
-          placeholder: '',
-        },
-        {
-          label: "编码",
-          value: "productCode",
-          type: "input",
-          placeholder: '',
-          width: 240,
-        },
-        {
-          label: "名称",
-          value: "productName",
-          type: "input",
-          placeholder: '',
-          width: 240,
-        },
-        {
-          label: "类型:",
-          value: 'type',
-          type: "select",
+          // {
+          //   prop: 'productNumber',
+          //   label: '数量',
+          //   width: 60
+          // },
 
-          placeholder: '',
-          width: 240,
-          // 加载状态
-          planList: this.typeList
-        },
-        {
-          label: "检验方式:",
-          value: 'qualityMode',
-          type: "select",
+          {
+            label: '执行部门',
+            prop: 'groupName',
+            align: 'center',
+            showOverflowTooltip: true
+          },
+          {
+            label: '执行人',
+            prop: 'executeName',
+            align: 'center',
+            width: 120,
+            showOverflowTooltip: true
+          },
+          {
+            label: '创建时间',
+            prop: 'createTime',
+            align: 'center',
+            width: 120,
+            showOverflowTooltip: true
+          },
+          {
+            label: '开始时间',
+            prop: 'planStartTime',
+            align: 'center',
+            width: 120,
+            showOverflowTooltip: true
+          },
+          {
+            label: '结束时间',
+            prop: 'planEndTime',
+            align: 'center',
+            width: 120,
+            showOverflowTooltip: true
+          },
+          // {
+          //   label: '附件',
+          //   prop: 'accessory',
+          //   slot: 'accessory',
+          //   align: 'center',
+          //   width: 120,
+          //   showOverflowTooltip: true
+          // },
+          {
+            label: '状态',
+            prop: 'status',
+            width: 70,
+            align: 'center',
+            showOverflowTooltip: true,
+            formatter: (row, column, cellValue) => {
+              return cellValue == 1 ? '已下发' : '未下发';
+            }
+          },
 
-          placeholder: '',
-          width: 240,
-          planList: this.qualityMode
-        },
-      ]
-    }
-  },
-  created() {
-    this.requestDict('质检计划类型');
-    this.requestDict('取样类型');
-    this.getTnspectionPlanType();
-    this.getQualityMethodCode();
-  },
-  methods: {
-    // datasource({ page, limit, where }) {
-    //   return getList({
-    //     ...where,
-    //     pageNum: page,
-    //     size: limit
-    //   });
-    // },
-    datasource({ page, limit, where }) {
-      return getList({
-        pageNum: page,
-        size: limit,
-        ...where
-      });
-    },
-    search(e) {
-      if(Array.isArray(e.createTime)&&e.createTime.length){
-        e.createTimeStart=e.createTime[0];
-        e.createTimeEnd = e.createTime[1];
+          {
+            columnKey: 'action',
+            label: '操作',
+            width: 160,
+            align: 'center',
+            resizable: false,
+            slot: 'action',
+            showOverflowTooltip: true,
+            fixed: 'right'
+          }
+        ],
+        typeList: [], //类型列表
+        qualityMode: []
       };
-      this.reload(e)
-    },
-    openEdit(type, row) {
-      this.$refs.edit.open(type, row);
-    },
-    downloadFile(file) {
-      getFile({ objectName: file.storePath }, file.name);
-    },
-    remove(row) {
-      removeItem([row.id])
-        .then((message) => {
-          this.$message.success(message);
-          this.reload();
-        })
-        .catch((e) => { });
-    },
-    reload(where) {
-      this.$refs.tableRef.reload({ page: 1, where });
     },
+    computed: {
+      seekList() {
+        return [
+          {
+            label: '计划编码:',
+            value: 'code',
+            type: 'input',
+            placeholder: ''
+          },
+          {
+            label: '计划名称:',
+            value: 'name',
+            type: 'input',
+            placeholder: ''
+          },
+          {
+            label: '来源单据编码:',
+            value: 'planSourceCode',
+            type: 'input',
+            placeholder: ''
+          },
+          {
+            label: '编码',
+            value: 'productCode',
+            type: 'input',
+            placeholder: '',
+            width: 240
+          },
+          {
+            label: '名称',
+            value: 'productName',
+            type: 'input',
+            placeholder: '',
+            width: 240
+          },
+          {
+            label: '类型:',
+            value: 'type',
+            type: 'select',
+
+            placeholder: '',
+            width: 240,
+            // 加载状态
+            planList: this.typeList
+          },
+          {
+            label: '检验方式:',
+            value: 'qualityMode',
+            type: 'select',
 
-    async getTnspectionPlanType() {
-      let res = await getByCode('inspection_plan_type');
-      if (res?.code == 0) {
-        let list = res.data.map(item => {
-          let key = Object.keys(item)[0]
-          return {value: key, label: item[key]}
-        })
-        this.typeList = list;
+            placeholder: '',
+            width: 240,
+            planList: this.qualityMode
+          }
+        ];
       }
     },
+    created() {
+      this.requestDict('质检计划类型');
+      this.requestDict('取样类型');
+      this.getTnspectionPlanType();
+      this.getQualityMethodCode();
+    },
+    methods: {
+      // datasource({ page, limit, where }) {
+      //   return getList({
+      //     ...where,
+      //     pageNum: page,
+      //     size: limit
+      //   });
+      // },
+      datasource({ page, limit, where }) {
+        return getList({
+          pageNum: page,
+          size: limit,
+          ...where
+        });
+      },
+      search(e) {
+        if (Array.isArray(e.createTime) && e.createTime.length) {
+          e.createTimeStart = e.createTime[0];
+          e.createTimeEnd = e.createTime[1];
+        }
+        this.reload(e);
+      },
+      openEdit(type, row) {
+        this.$refs.edit.open(type, row);
+      },
+      downloadFile(file) {
+        getFile({ objectName: file.storePath }, file.name);
+      },
+      remove(row) {
+        removeItem([row.id])
+          .then((message) => {
+            this.$message.success(message);
+            this.reload();
+          })
+          .catch((e) => {});
+      },
+      reload(where) {
+        this.$refs.tableRef.reload({ page: 1, where });
+      },
 
-    async getQualityMethodCode() {
-      let res = await getByCode('quality_method_code');
-      if (res?.code == 0) {
-        let list = res.data.map(item => {
-          let key = Object.keys(item)[0]
-          return {value: key, label: item[key]}
-        })
-        this.qualityMode = list;
+      async getTnspectionPlanType() {
+        let res = await getByCode('inspection_plan_type');
+        if (res?.code == 0) {
+          let list = res.data.map((item) => {
+            let key = Object.keys(item)[0];
+            return { value: key, label: item[key] };
+          });
+          this.typeList = list;
+        }
+      },
+
+      async getQualityMethodCode() {
+        let res = await getByCode('quality_method_code');
+        if (res?.code == 0) {
+          let list = res.data.map((item) => {
+            let key = Object.keys(item)[0];
+            return { value: key, label: item[key] };
+          });
+          this.qualityMode = list;
+        }
       }
-    },
-  }
-};
+    }
+  };
 </script>

+ 14 - 3
src/views/inspectionWork/edit.vue

@@ -1246,10 +1246,21 @@
       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
-        ).length;
+        // let noQualifiedNumber = sampleList.filter(
+        //   (item) => item.qualityResults == 2
+        // ).length;
+        let noQualifiedNumber = sampleList.reduce((acc, pro) => {
+          // console.log(acc, pro);
+          // if (pro.qualityResults == 2) {
+          //   return acc + Number(pro.measureQuantity);
+          // }
+          return pro.qualityResults == 2
+            ? acc + Number(pro.measureQuantity)
+            : acc;
+        }, 0);
+        console.log(noQualifiedNumber, 'noQualifiedNumber');
         let qualifiedNumber = sampleNumber - noQualifiedNumber; //不合格数
         let qualificationRate = (
           (qualifiedNumber / sampleNumber) *

+ 2 - 2
vue.config.js

@@ -34,8 +34,8 @@ module.exports = {
         // target: 'http://124.71.68.31:50001',
         // target: 'http://192.168.1.107:18086',
         // target: 'http://192.168.1.125:18086',
-        target: 'http://192.168.1.144:18086',
-        // target: 'http://192.168.1.251:18086',
+        // target: 'http://192.168.1.144:18086',
+        target: 'http://192.168.1.251:18086',
         // target: 'http://192.168.1.251:18186',
         // target: 'http://124.71.68.31:50001',
         changeOrigin: true, // 只有这个值为true的情况下 才表示开启跨域