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

+ 36 - 9
src/api/inspectionPlan/index.js

@@ -1,6 +1,5 @@
 import request from '@/utils/request';
 
-
 // 列表
 
 export async function getList(data) {
@@ -71,9 +70,12 @@ export async function removeItem(data) {
 // 清单列表接口 1
 
 export async function getPurchaseWarehouseGoods(params) {
-  const res = await request.get(`/wms/outInDetailRecordTwo/getPurchaseWarehouseGoods`, {
-    params
-  });
+  const res = await request.get(
+    `/wms/outInDetailRecordTwo/getPurchaseWarehouseGoods`,
+    {
+      params
+    }
+  );
   if (res.data.code == 0) {
     return res.data.data;
   }
@@ -101,10 +103,12 @@ export async function getQualityTemplateList(params) {
   // return Promise.reject(new Error(res.data.message));
 }
 
-
 // 修改时查询 质检方案
 export async function getTemplateListByPlanId(data) {
-  const res = await request.post(`/qms/quality_plan/getQualityTemplateList`, data);
+  const res = await request.post(
+    `/qms/quality_plan/getQualityTemplateList`,
+    data
+  );
   if (res.data.code == 0) {
     return res.data.data;
   }
@@ -113,7 +117,10 @@ export async function getTemplateListByPlanId(data) {
 
 // 修改时查询 质检样品
 export async function getSampleListByPlanId(data) {
-  const res = await request.post(`/qms/quality_plan/getQualitySampleList`, data);
+  const res = await request.post(
+    `/qms/quality_plan/getQualitySampleList`,
+    data
+  );
   if (res.data.code == 0) {
     return res.data.data;
   }
@@ -121,7 +128,10 @@ export async function getSampleListByPlanId(data) {
 }
 // 修改时查询 质检清单
 export async function getInventoryListByPlanId(data) {
-  const res = await request.post(`/qms/quality_plan/getQueryQualityInventory`, data);
+  const res = await request.post(
+    `/qms/quality_plan/getQueryQualityInventory`,
+    data
+  );
   if (res.data.code == 0) {
     return res.data.data;
   }
@@ -147,7 +157,6 @@ export async function getBatchInfoData(params) {
   return Promise.reject(new Error(res.data.message));
 }
 
-
 // 详情接口
 
 export async function getDetailInfo(id) {
@@ -157,3 +166,21 @@ export async function getDetailInfo(id) {
   }
   return Promise.reject(new Error(res.data.message));
 }
+
+// 获取生产检验的成品工单数据
+export async function getProductOrder(data) {
+  const res = await request.post(`/pda/mes/workreport/listWorkReport`, data);
+  if (res.data.code == 0) {
+    return res.data.data;
+  }
+  return Promise.reject(new Error(res.data.message));
+}
+
+// 获取当前成品的操作步骤
+export async function getProductSteup(id) {
+  const res = await request.get(`/pda/mes/workorder/getTaskInstanceById/${id}`);
+  if (res.data.code == 0) {
+    return res.data.data;
+  }
+  return Promise.reject(new Error(res.data.message));
+}

+ 14 - 5
src/api/inspectionTemplate/index.js

@@ -1,6 +1,6 @@
 import request from '@/utils/request';
 
-export async function pageByBom (data) {
+export async function pageByBom(data) {
   let par = new URLSearchParams(data);
   const res = await request.get(`/qms/qualitylevel/pageByBom?` + par, {});
   if (res.data.code == 0) {
@@ -9,7 +9,6 @@ export async function pageByBom (data) {
   return Promise.reject(new Error(res.data.message));
 }
 
-
 // 新增
 export async function save(data) {
   const res = await request.post(`/qms/qualitytemplate/save`, data);
@@ -36,6 +35,14 @@ export async function getById(id) {
   return Promise.reject(new Error(res.data.message));
 }
 
+//复制
+export async function copyData(id) {
+  const res = await request.get(`/qms/qualitytemplate/copy/${id}`);
+  if (res.data.code == 0) {
+    return res.data;
+  }
+  return Promise.reject(new Error(res.data.message));
+}
 
 // 删除
 export async function removeItem(data) {
@@ -58,9 +65,8 @@ export async function getList(data) {
   return Promise.reject(new Error(res.data.message));
 }
 
-
 export async function templatecategoryPage(params) {
-  const res = await request.get(`/qms/templatecategory/page`, {params});
+  const res = await request.get(`/qms/templatecategory/page`, { params });
   if (res.data.code == 0) {
     return res.data.data;
   }
@@ -69,7 +75,10 @@ export async function templatecategoryPage(params) {
 
 // 通过方案ids获取质检项
 export async function getQualityTemplateByIds(data) {
-  const res = await request.post(`/qms/qualitytemplate/getQualityTemplateByIds`, data);
+  const res = await request.post(
+    `/qms/qualitytemplate/getQualityTemplateByIds`,
+    data
+  );
   if (res.data.code == 0) {
     return res.data.data;
   }

+ 523 - 383
src/views/inspectionPlan/components/baseInfo.vue

@@ -43,14 +43,26 @@
             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-form-item label="计量类型" prop="inspectionStandards">
           <!-- 计量 计重 -->
-          <el-select style="width: 100%" v-model="form.inspectionStandards" placeholder="请选择">
+          <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"
@@ -58,13 +70,30 @@
               :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-input
+            clearable
+            v-model="form.code"
+            placeholder="请输入"
+            disabled
+          />
         </el-form-item>
       </el-col>
       <el-col :span="6">
@@ -114,11 +143,9 @@
         </el-form-item>
       </el-col>
     </el-row>
-    <div style="text-align: right;margin-bottom: 22px;">
+    <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-up"></i>收起 </div>
         <div v-if="!isExpanded">
           <i class="el-icon-arrow-down"></i>展开更多
         </div>
@@ -223,12 +250,18 @@
               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>
+              <template #append>{{
+                form.dimension == 3
+                  ? form.packingUnit
+                  : form.dimension == 2
+                  ? form.measureUnit
+                  : categoryInfo.measuringUnit
+              }}</template>
             </el-input>
           </el-form-item>
         </el-col>
@@ -311,7 +344,10 @@
         </el-col>
         <el-col :span="6">
           <el-form-item label="附件:" prop="accessory">
-            <fileUpload v-model="form.accessory" :type="btnType == 'detail' ? 'view' : ''" />
+            <fileUpload
+              v-model="form.accessory"
+              :type="btnType == 'detail' ? 'view' : ''"
+            />
           </el-form-item>
         </el-col>
       </el-row>
@@ -321,411 +357,515 @@
     <productionPlan ref="productionPlanRef" @choose="handleChoose" />
     <workOrder ref="workOrderRef" @choose="handleChoose" />
     <produceOrder ref="produceOrderRef" @choose="handleChoose" />
-    <EquipmentDialog ref="equipmentRefs" @choose="handleMainChoose" :type="2" :treeIds="['9']" />
+    <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 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 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 { 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';
+  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: ''
+  export default {
+    components: {
+      EquipmentDialog,
+      produceOrder,
+      workOrder,
+      productionPlan,
+      warehousing,
+      deptSelect,
+      fileUpload,
+      stokledger
     },
-    packingLists: {
-      type: Array,
-      default: () => []
-    }
-  },
-  computed: {
-    quantityShow() {
-      if (this.btnType == 'detail') {
-        return false;
+    props: {
+      form: {
+        type: Object,
+        default: () => {}
+      },
+      btnType: {
+        type: String,
+        default: ''
+      },
+      packingLists: {
+        type: Array,
+        default: () => []
+      },
+      isChangeNumber: {
+        type: Boolean,
+        default: true
+      },
+      isChangeType: {
+        type: Boolean,
+        default: true
       }
-      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 (newVal && this.form.planSource == '5') { //主数据来源才生效
-        if (newVal && this.quantityShow) {
-          this.$emit('changeProductNumberModel', newVal);
-          this.form.totalWeight = this.categoryInfo.netWeight * newVal || 0;
-        } else {
-          console.log('清空样品清单');
-          this.$emit('table2');
+    },
+
+    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);
+          // 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
       },
-      immediate: false
+      '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
+      }
     },
-    'form.qualityMode': {
-      handler(newVal) {
-        if (newVal) {
-          this.$emit('changeModel', newVal);
-        } else {
-          console.log('清空样品清单');
-          this.$emit('table2');
+    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' }
+          ];
         }
       },
-      immediate: false
-    },
-    'form.inspectionStandards': {
-      handler(newVal) {
-        if (newVal) {
-          this.$emit('getInspectionStandards', newVal);
+      //选择部门(搜索)
+      searchDeptNodeClick(info, row) {
+        if (info) {
+          const params = { groupId: info };
+          this.getUserList(params);
+          this.form.groupName = row.name;
         } else {
-          console.log('清空样品清单');
-          this.$emit('table2');
+          this.form.executeGroupId = null;
         }
       },
-      immediate: false
-    },
-    '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');
+      // 获取审核人列表、巡点检人员
+      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;
         }
       },
-      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');
+      //计划来源选择
+      planSourceChange(val) {
+        if (val) {
+          this.addProduct();
         }
       },
-      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' }
-        ]
+      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();
+        }
       },
-      isExpanded: false, // 控制展开/收起状态
-      categoryInfo: {}
-    };
-  },
-  created() {
-    this.getDictListIqoCode('iqo_code');
-  },
-  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);
+      //根据类型获取计划来源下拉
+      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' }
+          ];
         }
-        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;
-      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)
-      this.getProductDetails(this.form.productId);
-      this.$emit('changesMainNumberModal', this.form.productNumber);
-      if (this.form.type != 3) {
-        this.$emit('getQualityTemplate', val.code);
-      }
-    },
+      //主数据根据来源得到产品
+      handleMainChoose(val) {
+        console.log(val, '主数据根据来源得到产品');
+        if (!val) return;
 
-    //库存台账根据来源得到产品
-    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; //计量单位
+        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)
+        this.getProductDetails(this.form.productId);
+        this.$emit('changesMainNumberModal', this.form.productNumber);
+        if (this.form.type != 3) {
+          this.$emit('getQualityTemplate', val.code);
+        }
+      },
 
-      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; //批次号
-      this.getProductDetails(this.form.productId);
-      this.$emit('changesStokledgerNumberModal', list, dimension);
-      if (this.form.type != 3) {
-        this.$emit('getQualityTemplate', val.categoryCode);
-      }
-    },
+      //库存台账根据来源得到产品
+      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; //计量单位
 
-    //   根据来源得到产品
-    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;
+        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; //批次号
+        this.getProductDetails(this.form.productId);
+        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;
 
-      if (receiveNo && categoryCode && categoryid) {
-        this.$emit(
-          'getList',
-          receiveNo,
-          categoryCode,
-          productCategoryId,
-          productCategoryName,
-          categoryid,
+        console.log(this.form.productId, batchNo, productionCode);
+
+        if (receiveNo && categoryCode && categoryid) {
+          this.$emit(
+            'getList',
+            receiveNo,
+            categoryCode,
+            productCategoryId,
+            productCategoryName,
+            categoryid,
+            batchNo,
+            val.supplierName,
+            val.supplierMark
+          );
+        }
+        this.getProductDetails(
+          this.form.productId,
           batchNo,
-          val.supplierName,
-          val.supplierMark
+          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);
+        this.form.inspectionStandards = this.categoryInfo.measureType;
+        this.form.qualityMode = qmsData.checkFormula || 1;
+        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() {
+        this.isInforChangeNumber = false;
+      },
+      changeInspectionType() {
+        this.isInfoChangeType = false;
+      },
+      changeQualityMode() {
+        this.isInfoChangeModel = false;
       }
-      this.getProductDetails(this.form.productId, batchNo, productionCode);
-    },
-    //获取产品详情信息-来自主数据
-    // *** 增加 batchNo productionCode 字段 给 生产检验类型用
-    async getProductDetails(val, batchNo = '', productionCode = '') {
-      const data = await getDetailInfo(val);
-      this.categoryInfo = data.category;
-      // *** 新增 批次号,来源单据 字段传递
-      data.category.batchNo = batchNo;
-      data.category.planSourceCode = productionCode;
-      // ***
-      this.$emit('getCategoryInfo', data);
-    },
-    getsampleMeasureUnit(val) {
-      this.$set(this.form, 'sampleMeasureUnit', val);
     }
-  }
-};
+  };
 </script>
 <style lang="scss" scoped>
-::v-deep .el-form-item .el-form-item--medium .more {
-  margin: 0 !important;
-}
+  ::v-deep .el-form-item .el-form-item--medium .more {
+    margin: 0 !important;
+  }
 </style>

+ 251 - 20
src/views/inspectionPlan/components/edit.vue

@@ -16,6 +16,8 @@
       v-if="baseForm"
       :form="baseForm"
       :btnType="btnType"
+      :isChangeNumber="isChangeNumber"
+      :isChangeType="isChangeType"
       @resetTable="resetTable"
       @changeModel="changeModel"
       @getList="getList"
@@ -29,7 +31,7 @@
     ></base-info>
     <el-row>
       <header-title title="质检内容"></header-title>
-      <!-- :needPage="btnType == 'add' ? false : true" -->
+
       <el-tabs v-model="activeName" @tab-click="handleClick">
         <el-tab-pane label="来源清单" name="1">
           <!-- 来料列表表格 -->
@@ -37,10 +39,12 @@
             ref="table12"
             :columns="tableColumns"
             :datasource="datasource"
-            :needPage="btnType != 'detail' ? false : true"
+            :needPage="
+              btnType == 'add' || (btnType == 'edit' && (!isScheme || !isOrder))
+                ? false
+                : true
+            "
             @selection-change="handleSelectionChange"
-            :page-size="50000"
-            :page-sizes="[5000]"
           >
             <template
               v-slot:toolbar
@@ -319,7 +323,9 @@
     getSampleListByPlanId,
     getInventoryListByPlanId,
     outInRecordsPage,
-    getBatchInfoData
+    getBatchInfoData,
+    getProductOrder,
+    getProductSteup
   } from '@/api/inspectionPlan/index.js';
   import { getQualityTemplateByIds } from '@/api/inspectionTemplate';
 
@@ -476,7 +482,10 @@
         isFormNumber: true,
 
         sampleListCode: '',
-        productItem: {} //产品信息
+        productItem: {}, //产品信息
+        isUpdateData: true,
+        isChangeNumber: true,
+        isChangeType: true
       };
     },
     computed: {
@@ -602,6 +611,55 @@
     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);
@@ -634,6 +692,7 @@
           };
           list.push(obj);
         }
+        console.log('数据22222');
         this.$refs.table12.setData(list);
 
         // *** 如果检验方式是全量的话 还需要同步样品清单数据
@@ -649,6 +708,7 @@
 
       //成品类型检验类型,计划来源库存台账, 生成来源清单
       changesStokledgerNumberModal(val, dimension) {
+        console.log('数据11111');
         this.$refs.table12.setData([]);
         if (dimension == 3) return this.$refs.table12.setData(val);
         let item = val[0];
@@ -664,6 +724,7 @@
             weight
           });
         }
+        console.log('数据1221212121');
         this.$refs.table12.setData(list);
       },
 
@@ -672,9 +733,12 @@
         console.log(data, 'data');
         this.baseForm.inspectionStandards = data;
         this.isOrder = false;
+        console.log(1313322);
         this.handleSampleList();
       },
       async datasource({ page, limit, where }) {
+        console.log(this.btnType);
+        console.log(this.isScheme, this.isOrder);
         const res = await getInventoryListByPlanId({
           ...where,
           pageNum: page,
@@ -731,6 +795,8 @@
           qualityMode: row.qualityMode
         };
 
+        console.log('baseInfo:' + this.baseForm);
+
         this.$nextTick(() => {
           if (this.$refs.baseInfoRefs) {
             // 获取人员
@@ -818,6 +884,7 @@
         supplierMark
       ) {
         //通过来源和产品 获取来料清单
+        console.log(999999);
         await this.getGoodsList(
           receiveNo,
           productCode,
@@ -844,8 +911,10 @@
         supplierName,
         supplierMark
       ) {
+        console.log('数据1-1-1-1-1');
         this.$refs.table12.setData([]);
 
+        console.log(999999);
         let res;
         const res1 = await outInRecordsPage({
           sourceBizNo: receiveNo,
@@ -897,6 +966,7 @@
           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) {
@@ -907,18 +977,62 @@
           //处理样品清单
           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
-        // );
+        // let packingList = this.$refs.table12.getData();
+        console.log(
+          this.baseForm.qualityMode,
+          this.baseForm.inspectionStandards,
+          this.btnType
+        );
+
+        if (this.baseForm.type == '1') {
+          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);
+            }
+
+            this.$refs.table12.setData(list);
+            let packList = this.$refs.table12.getData();
+            // console.log(list);
+            // console.log(1654646);
+            this.getFullInspectionWeight(packList);
+            // this.getFullInspectionWeight(list);
+          } else {
+            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);
+            }
+          }
+        }
+
         //全检时 计量时
-        if (
+        else if (
           this.baseForm.qualityMode == 1 &&
           this.baseForm.inspectionStandards == 1 &&
           this.btnType != 'detail'
@@ -926,6 +1040,7 @@
           this.sampleList = [];
           console.log(this.baseForm, '---isUnpack---');
           if (this.baseForm.productNumber) {
+            console.log('数据777777');
             this.$refs.table12.setData([]);
             let nums = Number(this.baseForm.productNumber);
             let p = this.productItem;
@@ -944,6 +1059,7 @@
               };
               list.push(obj);
             }
+            console.log('数据666666');
             this.$refs.table12.setData(list);
             let packList = this.$refs.table12.getData();
             await this.handleUnpackCase(packList);
@@ -984,6 +1100,8 @@
           this.baseForm.qualityMode == 1 &&
           this.baseForm.inspectionStandards == 2 &&
           this.btnType != 'detail'
+          // (this.btnType != 'detail' || this.btnType != 'edit')
+          // this.btnType == 'add'
         ) {
           this.sampleList = [];
           let list = [];
@@ -1001,10 +1119,17 @@
             };
             list.push(obj);
           }
-          this.$refs.table12.setData(list);
-          let packList = this.$refs.table12.getData();
-          // console.log(list);
-          this.getFullInspectionWeight(packList);
+          console.log('数据55555');
+          console.log(list);
+          if (list[0].batchNo) {
+            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 = [];
         }
@@ -1089,8 +1214,9 @@
           if (Object.keys(res).length === 0) {
             return;
           }
+
           this.baseForm.sampleProportion = res.checkProportion;
-          this.baseForm.inspectionStandards = res?.inspectionStandards;
+          // this.baseForm.inspectionStandards = res?.inspectionStandards;
 
           let combinedList = [];
           for (let i = 0; i < res.qualityTemplateVOList.length; i++) {
@@ -1268,9 +1394,40 @@
           });
         }
       },
-      getCategoryInfo(val) {
+      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') {
+          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;
+
+          this.handleSampleList();
+          return;
+        }
+
         this.isConsumable = val.category.isConsumable;
         this.netWeight = val.category.netWeight;
         this.productItem = val.category; //产品信息
@@ -1372,6 +1529,7 @@
 
       //从来源数组取样到目标数组
       async getNewFullSampleList(sampleCount, sampleQuantity, sampleUnit) {
+        console.log('从来源数组取样到目标数组');
         const sourceArray = this.selectedList;
         // 检查单位是否匹配
         const isUnitMismatch =
@@ -1521,6 +1679,7 @@
         });
       },
       table1() {
+        console.log('数据44444');
         this.$refs.table12.setData([]);
         this.schemeList = [];
       },
@@ -1537,9 +1696,73 @@
           // 关闭后,销毁所有的表单数据
           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;
         });
       },
 
@@ -1683,6 +1906,7 @@
           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()) {
               //抽检计量整样小样或者抽检计重小样
@@ -1690,13 +1914,14 @@
                 return;
               if (unit === 'KG' && !this.validateWeight(measureQ, sampleCount))
                 return; // 若计量单位为重量,还需验证总重量是否足够
-
+              console.log('getNewFullSampleList');
               await this.getNewFullSampleList(
                 Math.ceil(sampleCount),
                 measureQ,
                 unit
               );
             } else if (this.isWeightStandardFullSample()) {
+              console.log('handleWeightFullSample');
               //抽检取计重取整样
               if (!this.validateSampleCount(sampleCount)) return;
               await this.handleWeightFullSample(sampleCount);
@@ -1720,6 +1945,10 @@
         return (
           this.baseForm.inspectionStandards === 1 ||
           (this.baseForm.inspectionStandards === 2 && this.conditionType == 2)
+          // this.baseForm.inspectionStandards === 1 ||
+          // (this.baseForm.inspectionStandards === 2 &&
+          //   this.conditionType == 2) ||
+          // (this.baseForm.inspectionStandards === 2 && this.conditionType == 2)
         );
       },
 
@@ -1778,6 +2007,8 @@
         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;

+ 10 - 0
src/views/inspectionTemplate/AddorUpdate.vue

@@ -105,6 +105,15 @@
             {{ getDictValue('质检标准类型', row.qualityStandardType) }}
           </template>
 
+          <template v-slot:inspectionName="{ row }">
+            <div>
+              <el-input
+                v-model="row.inspectionName"
+                style="width: 160px"
+              ></el-input
+            ></div>
+          </template>
+
           <template v-slot:defaultValue="{ row }">
             <div style="width: 100%; display: flex">
               <DictSelection
@@ -260,6 +269,7 @@
           },
           {
             prop: 'inspectionName',
+            slot: 'inspectionName',
             label: '名称',
             showOverflowTooltip: true,
             align: 'center',

+ 31 - 9
src/views/inspectionTemplate/index.vue

@@ -39,6 +39,14 @@
 
         <!-- 操作列 -->
         <template v-slot:action="{ row }">
+          <el-link
+            type="primary"
+            :underline="false"
+            icon="el-icon-tickets"
+            @click="copyData(row)"
+          >
+            复制
+          </el-link>
           <el-link
             type="primary"
             :underline="false"
@@ -90,7 +98,12 @@
 <script>
   import AddOrUpdate from './AddorUpdate';
   import search from './components/search.vue';
-  import { getList, removeItem, update } from '@/api/inspectionTemplate';
+  import {
+    getList,
+    removeItem,
+    update,
+    copyData
+  } from '@/api/inspectionTemplate';
   export default {
     components: {
       AddOrUpdate,
@@ -148,7 +161,7 @@
           {
             columnKey: 'action',
             label: '操作',
-            width: 200,
+            width: 260,
             align: 'center',
             resizable: false,
             slot: 'action',
@@ -213,14 +226,23 @@
         let status = row.status === 1 ? 0 : 1;
         dataForm['status'] = status;
         dataForm['id'] = row.id;
-        update(dataForm).then((res) => {
-          this.loading = false;
-          this.$message.success('操作成功!');
-          this.visible = false;
+        update(dataForm)
+          .then((res) => {
+            this.loading = false;
+            this.$message.success('操作成功!');
+            this.visible = false;
+            this.getDataList();
+          })
+          .catch((e) => {
+            this.loading = false;
+          });
+      },
+      copyData(row) {
+        console.log(row.id);
+        copyData(row.id).then((res) => {
+          console.log(res);
+          this.$message.success('复制成功!');
           this.getDataList();
-        })
-        .catch((e) => {
-          this.loading = false;
         });
       }
     }

+ 2 - 0
vue.config.js

@@ -36,6 +36,8 @@ module.exports = {
         // 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.251:18186',
+        // target: 'http://124.71.68.31:50001',
         changeOrigin: true, // 只有这个值为true的情况下 才表示开启跨域
         pathRewrite: {
           '^/api': ''