chencc пре 1 година
родитељ
комит
1893d4152f

+ 16 - 4
src/api/inspectionPlan/index.js

@@ -94,10 +94,11 @@ export async function getQualityTemplateList(params) {
   const res = await request.get(`/qms/qualitytemplate/getQualityTemplateList`, {
     params
   });
-  if (res.data.code == 0) {
-    return res.data.data;
-  }
-  return Promise.reject(new Error(res.data.message));
+  return res.data.data;
+  // if (res.data.code == 0) {
+  //   return res.data.data;
+  // }
+  // return Promise.reject(new Error(res.data.message));
 }
 
 
@@ -134,3 +135,14 @@ export async function getByCategoryId(data) {
   }
   return Promise.reject(new Error(res.data.message));
 }
+
+// 清单列表接口 3
+export async function getBatchInfoData(params) {
+  const res = await request.get(`/wms/outindetailtwo/getBatchInfo`, {
+    params
+  });
+  if (res.data.code == 0) {
+    return res.data.data;
+  }
+  return Promise.reject(new Error(res.data.message));
+}

+ 7 - 0
src/api/inspectionWork/index.js

@@ -91,3 +91,10 @@ export async function queryQualityTempleContent(data) {
     return res.data.data;
   }
 }
+// 仓库定义列表
+export async function warehouseList(data) {
+  const res = await request.post('/wms/warehouse/select/warehouseList', data);
+  if (res.data.code == 0) {
+    return res.data.data;
+  }
+}

+ 29 - 1
src/api/samplemanagement/index.js

@@ -2,7 +2,35 @@ import request from '@/utils/request';
 
 // 列表
 export async function getList(data) {
-  const res = await request.get(`/qms/sample/page`, data);
+  let par = new URLSearchParams(data);
+  const res = await request.get(`/qms/sample/page?` + par, {});
+  if (res.data.code == 0) {
+    return res.data.data;
+  }
+  return Promise.reject(new Error(res.data.message));
+}
+// 列表
+export async function getSampleQWorkOrderIdPage(data) {
+  let par = new URLSearchParams(data);
+  const res = await request.get(`/qms/sample/getSampleQWorkOrderId?` + par, {});
+  if (res.data.code == 0) {
+    return res.data.data;
+  }
+  return Promise.reject(new Error(res.data.message));
+}
+// 详情页面
+
+export async function getById(id) {
+  const res = await request.get(`/qms/sample/getById/` + id, {});
+  if (res.data.code == 0) {
+    return res.data;
+  }
+  return Promise.reject(new Error(res.data.message));
+}
+
+
+export async function disposeSubmit(data) {
+  const res = await request.post(`/qms/sample/dispose`, data);
   if (res.data.code == 0) {
     return res.data.data;
   }

+ 165 - 134
src/views/inspectionPlan/components/baseInfo.vue

@@ -1,4 +1,5 @@
 <template>
+
   <el-form ref="form1" :model="form" :rules="rules" label-width="120px">
     <el-row>
       <el-col :span="6">
@@ -16,26 +17,19 @@
       <el-col :span="6">
         <el-form-item label="检验方式:" prop="qualityMode">
           <DictSelection dictName="取样类型" v-model="form.qualityMode" clearable
-            :disabled="btnType == 'detail' || btnType == 'issued'"></DictSelection>
+            :disabled="btnType == 'detail' || btnType == 'issued'">
+          </DictSelection>
         </el-form-item>
       </el-col>
       <el-col :span="6">
-<!--        <el-form-item label="检验标准:" prop="inspectionStandards">-->
-<!--          <el-select v-model="form.inspectionStandards" placeholder="请选择" style="width: 100%" clearable></el-select>-->
-<!--        </el-form-item>-->
+        <!--        <el-form-item label="检验标准:" prop="inspectionStandards">-->
+        <!--          <el-select v-model="form.inspectionStandards" placeholder="请选择" style="width: 100%" clearable></el-select>-->
+        <!--        </el-form-item>-->
         <el-form-item label="检验标准" prop="inspectionStandards">
           <!-- 计量 计重 -->
-          <el-select
-            style="width: 100%"
-            v-model="form.inspectionStandards"
-            placeholder="请选择"
-          >
-            <el-option
-              v-for="item in inspectionStandardsList"
-              :label="item.label"
-              :value="item.value"
-              :key="item.value"
-            >
+          <el-select style="width: 100%" v-model="form.inspectionStandards" placeholder="请选择">
+            <el-option v-for="item in inspectionStandardsList" :label="item.label" :value="item.value"
+              :key="item.value">
             </el-option>
           </el-select>
         </el-form-item>
@@ -71,120 +65,141 @@
         </el-form-item>
       </el-col>
     </el-row>
-    <el-row>
-      <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 />
-        </el-form-item>
-      </el-col>
-      <el-col :span="6">
-        <el-form-item label="合格品数量:" prop=" qualifiedNumber">
-          <el-input type="number" v-model="form.qualifiedNumber" disabled />
-        </el-form-item>
-      </el-col>
-    </el-row>
-    <el-row>
-      <el-col :span="6">
-        <el-form-item label="不合格品数量:" prop=" unqualifiedNumber">
-          <el-input type="number" v-model="form.unqualifiedNumber" disabled />
-        </el-form-item>
-      </el-col>
-      <el-col :span="6">
-        <el-form-item label="合格率:" prop="qualificationRate">
-          <el-input type="number" 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'" />
-        </el-form-item>
-      </el-col>
-      <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'
-        }">
-          <el-input type="number" v-model="form.sampleNumber" @change="handleChangeNumber"
-            :disabled="btnType == 'detail' || btnType == 'issued'" />
-        </el-form-item>
-      </el-col>
-    </el-row>
-    <el-row>
-      <el-col :span="24">
-        <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-row>
-    <el-row>
-      <el-col :span="8">
-        <el-form-item label="附件:" prop="accessory">
-          <fileUpload v-model="form.accessory" />
-        </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="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 />
+          </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 />
+          </el-form-item>
+        </el-col>
+        <el-col :span="6">
+          <el-form-item label="不合格品数量:" prop="unqualifiedNumber">
+            <el-input type="number" v-model="form.unqualifiedNumber" disabled />
+          </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'" />
+          </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'
+          }">
+            <el-input type="number" v-model="form.sampleNumber" @change="handleChangeNumber"
+              :disabled="btnType == 'detail' || btnType == 'issued'" />
+          </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-row>
+      <el-row>
+        <el-col :span="24">
+          <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-row>
+      <el-row>
+        <el-col :span="8">
+          <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" />
@@ -314,13 +329,17 @@ export default {
         executeId: [
           { required: true, message: '请选择执行人员:', trigger: 'blur' }
         ]
-      }
+      },
+      isExpanded: false // 控制展开/收起状态
     };
   },
   created() {
     this.getDictListIqoCode('iqo_code');
   },
   methods: {
+    toggleExpand() {
+      this.isExpanded = !this.isExpanded;
+    },
     async getDictListIqoCode(code) {
       let { data: res } = await getByCode(code);
       this.inspectionStandardsList = res.map((item) => {
@@ -334,7 +353,7 @@ export default {
     //质检计划类型
     planChange(value) {
       if (value == 1) {
-        this.sourceList = [{ label: '采购收货单', value: '1' }];
+        this.sourceList = [{ label: '采购收货单', value: '1' }];
       } else if (value == 2) {
         this.sourceList = [
           { label: '生产计划', value: '2' },
@@ -397,8 +416,12 @@ export default {
     handleChoose(val) {
       if (!val) return;
       this.form.planSourceId = val.id;
+      // this.form.planReceiveId = val.receiveId;
+
       this.form.planSourceCode = val.receiveNo;
+      console.log(this.form.planSourceCode, 'this.form.planSourceCode')
 
+      this.form.supplierMark = val.supplierMark;
       this.form.productName = val.productName;
       this.form.productCode = val.productCode;
       this.form.batchNo = val.batchNo;
@@ -412,13 +435,17 @@ export default {
       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);
+        this.$emit('getList', receiveNo, categoryCode, productCategoryId, productCategoryName, categoryid, batchNo);
       }
     },
 
@@ -428,7 +455,7 @@ export default {
     },
     typeChange(val) {
       if (val == 1) {
-        this.sourceList = [{ label: '采购收货单', value: '1' }];
+        this.sourceList = [{ label: '采购收货单', value: '1' }];
       } else if (val == 2) {
         this.sourceList = [
           { label: '生产计划', value: '2' },
@@ -440,4 +467,8 @@ export default {
   }
 };
 </script>
-<style lang="scss" scoped></style>
+<style lang="scss" scoped>
+::v-deep .el-form-item .el-form-item--medium .more {
+  margin: 0 !important;
+}
+</style>

+ 184 - 91
src/views/inspectionPlan/components/edit.vue

@@ -6,7 +6,7 @@
     <base-info ref="baseInfoRefs" v-if="baseForm" :form="baseForm" :btnType="btnType" @resetTable="resetTable"
       @getList="getList" @changeModel="changeModel" @changeNumber="changeNumber" @table2="table2"></base-info>
 
-    <el-row style="margin-top: 24px">
+    <el-row>
       <header-title title="质检内容"></header-title>
       <el-tabs v-model="activeName" @tab-click="handleClick">
         <el-tab-pane label="来源清单" name="1"></el-tab-pane>
@@ -89,7 +89,7 @@
 import baseInfo from './baseInfo.vue';
 
 import { getCode } from '@/api/login';
-import {save, update, planIssued} from '@/api/inspectionPlan';
+import { save, update, planIssued } from '@/api/inspectionPlan';
 import {
   getPurchaseWarehouseGoods,
   getQualityTemplateList,
@@ -97,7 +97,8 @@ import {
   getSampleListByPlanId,
   getInventoryListByPlanId,
   outInRecordsPage,
-  getByCategoryId
+  getByCategoryId,
+  getBatchInfoData
 } from '@/api/inspectionPlan/index.js';
 export default {
   components: {
@@ -134,6 +135,9 @@ export default {
         qualificationRate: '',
         totalWeight: '',
         sampleNumber: null,
+        sampleProportion: '',
+        supplierMark: '',
+        // planReceiveId: '',
 
         remark: '',
         accessory: []
@@ -159,7 +163,7 @@ export default {
         { label: '批次号', prop: 'batchNo', align: 'center' },
         { label: '发货条码', prop: 'barcodes', align: 'center' },
         { label: '包装编码', prop: 'packageNo', align: 'center' },
-        { label: '包装数量', prop: 'packingQuantity', align: 'center' },
+        // { label: '包装数量', prop: 'packingQuantity', align: 'center' },
         { label: '包装单位', prop: 'packingUnit', align: 'center' },
         { label: '计量数量', prop: 'measureQuantity', align: 'center' },
         { label: '计量单位', prop: 'measureUnit', align: 'center' },
@@ -204,7 +208,8 @@ export default {
       listPage: [],
 
       activeName: '1',
-      selectedList: []
+      selectedList: [],
+      isCheck: false
     };
   },
   computed: {
@@ -235,14 +240,11 @@ export default {
     // 切换质检内容
     handleClick(tab) {
       this.activeName = tab.name;
-      // if (this.activeName === '2') {
-      //   this.updateSampleList();
-      // }
     },
 
     checkSelectable(row, index) {
       // 只有当质检方式为抽检(qualityMode=2)时才可选
-      return this.baseForm.qualityMode === 2;
+      return this.btnType != 'issued' || this.baseForm.qualityMode === 2;
     },
     async open(type, row) {
       this.activeName = '1';
@@ -331,45 +333,56 @@ export default {
       this.schemePagination.currentPage = 1;
       this.schemePagination.total = this.schemeList.length;
     },
-    async getList(receiveNo, productCode, productCategoryId, productCategoryName,categoryid) {
+    async getList(receiveNo, productCode, productCategoryId, productCategoryName, categoryid, batchNo) {
       //通过来源和产品 获取来料清单
-      await this.getGoodsList(receiveNo, productCode, null, productCategoryId, productCategoryName,categoryid);
+      await this.getGoodsList(receiveNo, productCode, null, productCategoryId, productCategoryName, categoryid, batchNo);
 
-      //通过抽样方式获取样品列表 全检 样品列表等于来料清单列表
-      if (this.baseForm.qualityMode == 1) {
-        this.sampleList = this.packingList;
-        this.samplePagination.currentPage = 1;
-        this.samplePagination.total = this.packingList.length;
-      }
       //通过来源和产品 获取质检方案
       this.getQualityTemplate(productCode);
     },
-    async getGoodsList(receiveNo, productCode, ids, productCategoryId, productCategoryName,categoryid) {
+    async getGoodsList(receiveNo, productCode, ids, productCategoryId, productCategoryName, categoryid, batchNo) {
       let res;
-      // 根据物品id 编码查询主数据中物品编码是否需要拆包 是走 包装明细表  否 走获取产品表
-      let cateRes = await getByCategoryId({
-        categoryId: categoryid
-      })
-      if (cateRes) {
-        if (cateRes.isUnpack == 1) {
-          res = await outInRecordsPage({
-            // receiveNo: receiveNo,
-            sourceBizNo: receiveNo,
-            categoryCode: productCode,
-            categoryId: categoryid,
-            qualityQlanId: ids,
-            size:-1
-          });
-        }else{
-          // 获取没有拆包的产品数据 --- 等接口
-
+      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;
+        } 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 (Array.isArray(res?.list)) {
+      if (res.length > 0) {
         let _arr1 = [];
-        _arr1 = res.list.map((m) => {
+        _arr1 = res.map((m) => {
           m.sourceId = m.id;
           m.productCategoryId = productCategoryId;
           m.productCategoryName = productCategoryName;
@@ -381,50 +394,112 @@ export default {
         this.packingList = _arr1;
         this.pagination.total = this.packingList.length;
         console.log(this.packingList, '来料清单');
+        if (this.packingList.length > 1) {
+          this.baseForm.productNumber = this.packingList.length;
+        } else {
+          this.baseForm.productNumber = this.packingList[0].measureQuantity;
+        }
+        this.aaa();
       } else {
         this.packingList = [];
       }
     },
+    aaa() {
+      console.log('aaa')
+      if (this.baseForm.qualityMode == 1) {
+        this.sampleList = [];
+        if (!this.isCheck) {
+          const num = Number(this.baseForm.productNumber || 0);
+          if (num) {
+            this.getUnpackSamList(this.packingList, num)
+          }
+        } else {
+          if (this.baseForm.qualityMode == 1) {
+            this.sampleList = this.packingList;
+            this.samplePagination.currentPage = 1;
+            this.samplePagination.total = this.packingList.length;
+          } else {
+            this.sampleList = [];
+          }
+        }
+      } else {
+        this.sampleList = [];
+      }
+
+    },
+    getUnpackSamList(list, num) {
+      const data = [];
+      list.forEach(oldItem => {
+        const newMeasureQuantity = oldItem.measureQuantity / this.baseForm.productNumber;
+        const newWeight = parseFloat((oldItem.weight / this.baseForm.productNumber).toFixed(2))
+
+        delete oldItem.id;
+
+        for (let i = 0; i < num; i++) {
+          data.push({
+            ...oldItem,
+            measureQuantity: newMeasureQuantity,
+            weight: newWeight
+          });
+        }
+      });
+
+      console.log(data, 'datadatadatadatadatadata', num)
+
+      this.sampleList = data;
+      this.samplePagination.currentPage = 1;
+      this.samplePagination.total = data.length;
+
+    },
     async getQualityTemplate(productCode, ids) {
-      let res = await getQualityTemplateList({
+
+      await getQualityTemplateList({
         productCode: productCode,
         qualityQlanId: ids
-      });
-      this.baseForm.inspectionStandards = res?.inspectionStandards;
+      }).then((res) => {
+        if (Object.keys(res).length === 0) {
+          this.$message.error('请确认该物品是否配置质检方案!');
+          return;
+        }
+        this.baseForm.sampleProportion = res.checkProportion;
+        this.baseForm.inspectionStandards = res?.inspectionStandards;
 
-      let combinedList = [];
-      for (let i = 0; i < res.qualityTemplateVOList.length; i++) {
+        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;
+          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;
+        }
+      });
 
-            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, '勾选列表');
       if (this.baseForm.qualityMode === 2) {
         this.selectedList = selection;
 
         this.sampleList = selection;
-        this.samplePagination.currentPage = 1;
-        this.samplePagination.total = selection.length;
+        // console.log(this.sampleList, 'sampleList勾选列表')
+        // this.samplePagination.currentPage = 1;
+        // this.samplePagination.total = selection.length;
         this.baseForm.sampleNumber = selection.length;
       }
     },
@@ -457,26 +532,14 @@ export default {
     },
     changeModel(val) {
       this.baseForm.qualityMode = val;
-      this.updateSampleList();
-    },
-    updateSampleList() {
-      if (this.baseForm.qualityMode === 1) {
-        // 全检
-        this.sampleList = this.packingList;
-        this.samplePagination.currentPage = 1;
-        this.samplePagination.total = this.packingList.length;
-        this.baseForm.sampleNumber = '';
-      } else if (this.btnType != 'add' && this.baseForm.qualityMode === 2) {
-        // 抽检
-        if (this.selectedList.length > 0) {
-          this.sampleList = this.selectedList;
-          this.samplePagination.currentPage = 1;
-          this.samplePagination.total = this.sampleList.length;
-          this.baseForm.sampleNumber = this.sampleList.length;
-        }
+      console.log(this.baseForm.productNumber, 'productNumberproductNumber数量')
+      if (this.baseForm.qualityMode == 1) {
+        this.aaa()
+      } else {
+        this.sampleList = [];
       }
-      console.log(this.sampleList, '样品列表更新完成');
     },
+
     changeNumber(val) {
       if (this.baseForm.qualityMode !== 2) {
         return;
@@ -485,15 +548,35 @@ export default {
         this.$refs.showPackingListTable.clearSelection();
         return;
       }
+      console.log('取样数量', val, this.isCheck)
 
-      if (val > this.packingList.length) {
-        this.$message.warning('取样数量不能大于物料明细总数!');
-        return;
+      if (this.isCheck) {
+        if (val > this.packingList.length) {
+          this.$message.warning('取样数量不能大于来源清单数量!');
+          return;
+        }
+        const rows = this.packingList.slice(0, val);
+        rows.forEach((row) => {
+          this.$refs.showPackingListTable.toggleRowSelection(row);
+        });
+        if (this.baseForm.qualityMode == 1) {
+          this.sampleList = this.packingList;
+          this.samplePagination.currentPage = 1;
+          this.samplePagination.total = this.packingList.length;
+        } else {
+          this.sampleList = this.selectedList;
+        }
+
+      } else {
+        if (val > this.packingList[0].measureQuantity) {
+          this.$message.warning('取样数量不能大于计量数量!');
+          return;
+        }
+        const num = Number(val);
+        if (num) {
+          this.getUnpackSamList(this.packingList, num);
+        }
       }
-      const rows = this.packingList.slice(0, val);
-      rows.forEach((row) => {
-        this.$refs.showPackingListTable.toggleRowSelection(row);
-      });
     },
 
     resetTable() {
@@ -528,7 +611,9 @@ export default {
         }
 
         this.loading = true;
-
+        if (this.baseForm.isUnpack == null || this.baseForm.isUnpack == '') {
+          this.baseForm.isUnpack = this.isCheck ? 1 : 2;
+        }
         let params = {
           ...this.baseForm,
           qualityInventoryList: this.packingList,
@@ -559,12 +644,20 @@ export default {
       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;
+        }
+
         let params = {
           ...this.baseForm,
           qualityInventoryList: this.packingList,
@@ -627,7 +720,7 @@ export default {
 .el-pagination {
   padding: 12px 16px;
   background: #fff;
-  border: 1px solid #ebeef5;
+  border: 1px solid#ebeef5;
   border-top: none;
 }
 </style>

+ 107 - 0
src/views/inspectionPlan/components/searchWarehousing.vue

@@ -0,0 +1,107 @@
+<!-- 搜索表单 -->
+<template>
+  <el-form
+    label-width="100px"
+    class="ele-form-search"
+    @keyup.enter.native="search"
+    @submit.native.prevent
+  >
+    <el-row :gutter="15">
+      <el-col v-bind="styleResponsive ? { lg: 6, md: 12 } : { span: 6 }">
+        <el-form-item label="收货单编码:">
+          <el-input clearable v-model="where.receiveNo" placeholder="请输入" />
+        </el-form-item>
+      </el-col>
+
+      <el-col v-bind="styleResponsive ? { lg: 6, md: 12 } : { span: 6 }">
+        <el-form-item label="产品编号:">
+          <el-input clearable v-model="where.productCode" placeholder="请输入" />
+        </el-form-item>
+      </el-col>
+      <el-col v-bind="styleResponsive ? { lg: 6, md: 12 } : { span: 6 }">
+        <el-form-item label="产品名称:">
+          <el-input clearable v-model="where.productName" placeholder="请输入" />
+        </el-form-item>
+      </el-col>
+      <el-col v-bind="styleResponsive ? { lg: 6, md: 12 } : { span: 6 }">
+        <el-form-item label="批次号:">
+          <el-input clearable v-model="where.batchNo" placeholder="请输入" />
+        </el-form-item>
+      </el-col>
+    </el-row>
+    <el-row :gutter="15">
+
+      <!-- <el-col v-bind="styleResponsive ? { lg: 6, md: 12 } : { span: 6 }">
+        <el-form-item label="质检结果:">
+          <el-select
+            v-model="where.qualityResults"
+            placeholder="请选择"
+            style="width: 100%"
+          >
+            <el-option label="合格" :value="1" />
+            <el-option label="不合格" :value="2" />
+          </el-select>
+        </el-form-item>
+      </el-col>
+      <el-col v-bind="styleResponsive ? { lg: 6, md: 12 } : { span: 6 }">
+        <el-form-item label="质检状态:">
+          <el-select
+            v-model="where.qualityStatus"
+            placeholder="请选择"
+            style="width: 100%"
+          >
+            <el-option label="未检" :value="0" />
+            <el-option label="已检" :value="1" />
+          </el-select>
+        </el-form-item>
+      </el-col> -->
+      <el-col v-bind="styleResponsive ? { lg: 24, md: 24 } : { span: 24 }">
+        <div style="text-align: right;margin-bottom: 8px;">
+          <el-button
+            type="primary"
+            icon="el-icon-search"
+            class="ele-btn-icon"
+            @click="search"
+          >
+            查询
+          </el-button>
+          <el-button @click="reset">重置</el-button>
+        </div>
+      </el-col>
+    </el-row>
+  </el-form>
+</template>
+
+<script>
+  export default {
+    data() {
+      // 默认表单数据
+      const defaultWhere = {
+        qualityStatus: 0,
+      };
+      return {
+        defaultWhere: { ...defaultWhere },
+        // 表单数据
+        where: { ...defaultWhere }
+      };
+    },
+    computed: {
+      // 是否开启响应式布局
+      styleResponsive() {
+        return this.$store.state.theme.styleResponsive;
+      }
+    },
+    methods: {
+      /* 搜索 */
+      search() {
+        console.log(this.where);
+        this.$emit('search', this.where);
+      },
+      /*  重置 */
+      reset() {
+        this.where = { ...this.defaultWhere };
+        this.search();
+      }
+    }
+  };
+</script>

+ 11 - 3
src/views/inspectionPlan/components/warehousing.vue

@@ -11,6 +11,7 @@
     <div>
       <el-row>
         <el-col :span="24" class="table_col" v-if="equipmentdialog">
+          <searchWarehousing ref="search" @search="reload"></searchWarehousing>
           <ele-pro-table
             ref="equiTable"
             :columns="columns"
@@ -38,9 +39,12 @@
     purchaseorderreceive,
     purchaseorderreceiveGetById
   } from '@/api/inspectionPlan/index.js';
+  import searchWarehousing from './searchWarehousing.vue';
 
   export default {
-    components: {},
+    components: {
+      searchWarehousing
+    },
     props: {
       selectList: Array,
       type: {
@@ -132,7 +136,7 @@
 
           {
             prop: 'supplierMark',
-            label: '供应商名称',
+            label: '供应商代号',
             align: 'center',
             showOverflowTooltip: true,
             minWidth: 140
@@ -180,7 +184,8 @@
           ...where,
           pageNum: page,
           reviewStatus: '2',
-          size: limit
+          size: limit,
+          isQmsQuery:1
         });
       },
       open(ids) {
@@ -209,6 +214,9 @@
         // });
         this.$emit('choose', this.current);
         this.handleClose();
+      },
+      reload(where) {
+        this.$refs.equiTable.reload({ page: 1, where });
       }
     }
   };

+ 9 - 9
src/views/inspectionPlan/index.vue

@@ -2,7 +2,7 @@
   <div class="ele-body">
     <el-card shadow="never">
       <search ref="search" @search="reload"></search>
-      <ele-pro-table ref="tableRef" :columns="columns" :datasource="datasource">
+      <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')">
@@ -179,14 +179,14 @@ export default {
           width: 120,
           showOverflowTooltip: true
         },
-        {
-          label: '附件',
-          prop: 'accessory',
-          slot: 'accessory',
-          align: 'center',
-          width: 120,
-          showOverflowTooltip: true
-        },
+        // {
+        //   label: '附件',
+        //   prop: 'accessory',
+        //   slot: 'accessory',
+        //   align: 'center',
+        //   width: 120,
+        //   showOverflowTooltip: true
+        // },
         {
           label: '状态',
           prop: 'status',

+ 247 - 0
src/views/inspectionWork/components/QualityContentTabs.vue

@@ -0,0 +1,247 @@
+<template>
+  <el-row>
+    <header-title title="质检内容">
+      <el-button type="primary" :loading="loading" v-if="type != 'detail'"
+        @click="$emit('batch-quality')">批量质检</el-button>
+    </header-title>
+
+    <el-tabs v-model="activeName" @tab-click="handleClick">
+      <!--  -->
+      <el-tab-pane label="来源清单" name="1">
+        <el-table v-if="packingList.length > 0" ref="showPackingListTable" :data="paginatedPackingList"
+          tooltip-effect="dark" :max-height="300" border row-key="id"
+          @selection-change="$emit('selection-change', $event)">
+          <el-table-column type="selection" width="55" align="center" :reserve-selection="true"
+            :selectable="checkSelectable"></el-table-column>
+          <el-table-column label="序号" type="index" width="50" align="center"></el-table-column>
+          <template v-for="column in tableColumns">
+            <el-table-column :label="column.label" :prop="column.prop" :show-overflow-tooltip="true"
+              :width="column.width" :align="column.align"></el-table-column>
+          </template>
+        </el-table>
+        <el-pagination @size-change="handleSizeChange" @current-change="handleCurrentChange"
+          :current-page="pagination.currentPage" :page-sizes="[10, 20, 50, 100]" :page-size="pagination.pageSize"
+          layout="total, sizes, prev, pager, next" :total="packingList.length" style="margin-top: 16px" />
+      </el-tab-pane>
+      <!--  -->
+      <el-tab-pane label="样品清单" name="2">
+        <el-table 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" fixed="left"></el-table-column>
+          <template v-for="column in tableColumns">
+            <el-table-column :key="column.prop" :label="column.label" :prop="column.prop" :fixed="column.fixed"
+              :show-overflow-tooltip="true" :width="column.width" :align="column.align">
+              <template slot-scope="scope">
+                <template v-if="column.prop === 'categoryCode'">
+                  <el-link type="primary" :underline="false" @click="handleDetail(scope.$index, scope.row, 'detail')">
+                    {{ scope.row.categoryCode }}
+                  </el-link>
+                </template>
+                <template v-else-if="column.prop === 'weight'">
+                  <el-input type="number" v-model="scope.row.weight" :min="0"
+                    @input="inputWeight(scope.row, scope.$index)"></el-input>
+                </template>
+                <template v-else>
+                  {{ scope.row[column.prop] }}
+                </template>
+              </template>
+            </el-table-column>
+          </template>
+          <el-table-column label="处置状态" prop="disposalStatus" align="center" width="80" fixed="right"
+            :show-overflow-tooltip="true">
+            <template slot-scope="scope">
+              <span v-if="scope.row.disposalStatus == 1 && form.qualityType == 2">返工</span>
+              <span v-if="scope.row.disposalStatus == 2 && form.qualityType == 2">返修</span>
+              <span v-if="scope.row.disposalStatus == 3">报废</span>
+              <span v-if="scope.row.disposalStatus == 4 && form.qualityType == 2">降级使用</span>
+              <span v-if="scope.row.disposalStatus == 5 && form.qualityType == 2">让步接收</span>
+              <span v-if="scope.row.disposalStatus == 6">留样</span>
+              <span v-if="scope.row.disposalStatus == 7">消耗</span>
+              <span v-if="scope.row.disposalStatus == 8">回用</span>
+            </template>
+          </el-table-column>
+          <el-table-column label="处置时间" prop="disposeTime" align="center" width="100" fixed="right"
+            :show-overflow-tooltip="true">
+          </el-table-column>
+          <el-table-column label="质检状态" prop="qualityStatus" align="center" width="120" fixed="right"
+            :show-overflow-tooltip="true">
+            <template slot-scope="scope">
+              <span v-if="scope.row.qualityStatus == 0">未检</span>
+              <span v-if="scope.row.qualityStatus == 1">已检</span>
+              <span v-if="scope.row.qualityStatus == 2">待检</span>
+            </template>
+          </el-table-column>
+          <el-table-column label="质检结果" prop="qualityResults" align="center" width="120" fixed="right"
+            :show-overflow-tooltip="true">
+            <template slot-scope="scope">
+              <el-select v-model="scope.row.qualityResults" placeholder="请选择" style="width: 100%;"
+                :disabled="type == 'detail'" size="mini">
+                <el-option v-for="item in qualityResultsList" :key="item.value" :label="item.label" :value="item.value">
+                </el-option>
+              </el-select>
+            </template>
+          </el-table-column>
+          <el-table-column label="操作" align="center" width="120" fixed="right" v-if="type != 'detail'">
+            <template slot-scope="scope">
+              <el-link :type="scope.row.isValid ? 'primary' : 'danger'" :underline="false"
+                @click="handleDetail(scope.$index, scope.row, 'report')">
+                质检
+              </el-link>
+              <el-link type='primary' :underline="false" @click="handleDispose(scope.$index, scope.row, 'dispose')">处置
+              </el-link>
+            </template>
+          </el-table-column>
+        </el-table>
+        <el-pagination @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="sampleList.length" />
+      </el-tab-pane>
+      <!--  -->
+      <el-tab-pane label="质检方案" name="3">
+        <el-table :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">
+          </el-table-column>
+          <el-table-column label="质检方案名称" prop="qualitySchemeTemplateName" align="center"></el-table-column>
+          <el-table-column label="质检类型" prop="categoryLevelClassName" align="center"></el-table-column>
+          <el-table-column label="质检项编码" prop="inspectionCode" align="center"></el-table-column>
+          <el-table-column label="质检项名称" prop="inspectionName" align="center"></el-table-column>
+          <el-table-column label="工艺参数" prop="defaultValue" align="center">
+          </el-table-column>
+        </el-table>
+        <el-pagination @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="schemeList.length" />
+      </el-tab-pane>
+    </el-tabs>
+  </el-row>
+</template>
+
+<script>
+export default {
+  props: {
+    type: String,
+    packingList: Array,
+    sampleList: Array,
+    schemeList: Array,
+    loading: Boolean,
+    form: Object
+  },
+  data() {
+    return {
+      activeName: '2',
+      pagination: { currentPage: 1, pageSize: 10 },
+      samplePagination: { currentPage: 1, pageSize: 10 },
+      schemePagination: { currentPage: 1, pageSize: 10 },
+
+      qualityResultsList: [{
+        value: 1,
+        label: '合格'
+      },
+      {
+        value: 2,
+        label: '不合格'
+      }],
+      tableColumns: [
+        {
+          label: '编码',
+          prop: 'categoryCode',
+          width: '160',
+          align: 'center',
+          fixed: 'left'
+        },
+        {
+          label: '名称',
+          prop: 'categoryName',
+          width: '150',
+          align: 'center'
+        },
+        { label: '批次号', prop: 'batchNo', align: 'center' },
+        { label: '发货条码', prop: 'barcodes', align: 'center' },
+        { label: '包装编码', prop: 'packageNo', align: 'center' },
+        // { label: '包装数量', prop: 'packingQuantity', align: 'center' },
+        { label: '包装单位', prop: 'packingUnit', align: 'center' },
+        { label: '计量数量', prop: 'measureQuantity', align: 'center' },
+        { label: '计量单位', prop: 'measureUnit', align: 'center' },
+        { label: '物料代号', prop: 'materielDesignation', align: 'center' },
+        { label: '客户代号', prop: 'clientCode', align: 'center' },
+        { label: '刻码', prop: 'engrave', align: 'center' },
+        { label: '重量', prop: 'weight', align: 'center', width: "100" },
+        { label: '重量单位', prop: 'weightUnit', align: 'center', width: "100" },
+        { 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' },
+      ],
+
+    }
+  },
+
+  computed: {
+    paginatedPackingList() {
+      const start =
+        (this.pagination.currentPage - 1) * this.pagination.pageSize;
+      const end = start + this.pagination.pageSize;
+      return this.packingList.slice(start, end);
+    },
+    // 分页后的样品列表
+    paginatedSampleList() {
+      const { currentPage, pageSize } = this.samplePagination;
+      const start = (currentPage - 1) * pageSize;
+      const end = start + pageSize;
+      return this.sampleList?.slice(start, end);
+    },
+    // 分页后的质检方案列表
+    paginatedSchemeList() {
+      const { currentPage, pageSize } = this.schemePagination;
+      const start = (currentPage - 1) * pageSize;
+      const end = start + pageSize;
+      return this.schemeList?.slice(start, end);
+    }
+  },
+  methods: {
+    handleClick(tab) {
+      this.activeName = tab.name
+    },
+    checkSelectable(row, index) {
+      // 只有当质检方式为抽检(qualityMode=2)时   类型不是生产检验  才可选
+      return this.form.qualityType != 2 && this.form.qualityMode === 2;
+    },
+    handleDetail(index, row, type) {
+      this.$emit('handleDetail', index, row, type)
+    },
+    inputWeight(row, index) {
+      this.$emit('inputWeight', row, index)
+    },
+    handleDispose(index, row, type) {
+      this.$emit('handleDispose', index, row, type)
+    },
+    // 分页方法
+    handleSizeChange(val) {
+      this.pagination.pageSize = val;
+      this.pagination.currentPage = 1;
+    },
+    handleCurrentChange(val) {
+      this.pagination.currentPage = val;
+    },
+    handleSampleSizeChange(val) {
+      this.samplePagination.pageSize = val;
+      this.samplePagination.currentPage = 1;
+    },
+    handleSampleCurrentChange(val) {
+      this.samplePagination.currentPage = val;
+    },
+    handleSchemeSizeChange(val) {
+      this.schemePagination.pageSize = val;
+      this.schemePagination.currentPage = 1;
+    },
+    handleSchemeCurrentChange(val) {
+      this.schemePagination.currentPage = val;
+    },
+  }
+}
+</script>

+ 87 - 49
src/views/inspectionWork/components/baseInfo.vue

@@ -59,18 +59,25 @@
       </el-col>
       <el-col :span="6">
         <el-form-item label="总数量:" prop="total">
-          <el-input type="number" v-model="form.total" @input="inputTotal" />
+          <el-input type="number" v-model="form.total" @input="inputTotal" disabled />
         </el-form-item>
       </el-col>
     </el-row>
-    <el-row>
-      <el-col :span="6">
+    <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-col :span="6" v-if="parseInt(qualityType1) == 2">
         <el-form-item label="工艺路线:">
           <el-input @click.native="openVersion" clearable v-model="form.produceRoutingName"
             :disabled="btnType == 'detail'" placeholder="请选择" />
         </el-form-item>
       </el-col>
-      <el-col :span="6">
+      <el-col :span="6" v-if="parseInt(qualityType1) == 2">
         <el-form-item label="工序:">
           <el-select style="width: 100%" v-model="form.produceTaskId" placeholder="请选择" clearable
             @change="produceTaskChange" :disabled="btnType == 'detail'">
@@ -81,16 +88,14 @@
       </el-col>
       <el-col :span="6">
         <el-form-item label="合格数:" prop="qualifiedNumber">
-          <el-input v-model="form.qualifiedNumber" :disabled="btnType == 'detail'" placeholder="请输入"></el-input>
+          <el-input v-model="form.qualifiedNumber" disabled placeholder="请输入"></el-input>
         </el-form-item>
       </el-col>
       <el-col :span="6">
         <el-form-item label="不合格数:" prop="noQualifiedNumber">
-          <el-input v-model="form.noQualifiedNumber" :disabled="btnType == 'detail'" placeholder="请输入"></el-input>
+          <el-input v-model="form.noQualifiedNumber" disabled placeholder="请输入"></el-input>
         </el-form-item>
       </el-col>
-    </el-row>
-    <el-row>
       <el-col :span="6">
         <el-form-item label="质检部门" prop="groupId">
           <deptSelect :disabled="btnType == 'detail'" v-model="form.groupId" @changeGroup="searchDeptNodeClick" />
@@ -115,16 +120,14 @@
           <el-input v-model="form.hours" :disabled="btnType == 'detail'"></el-input>
         </el-form-item>
       </el-col>
-    </el-row>
-    <el-row>
       <el-col :span="6">
         <el-form-item label="合格率:" prop="qualificationRate">
-          <el-input type="number" v-model="form.qualificationRate" />
+          <el-input v-model="form.qualificationRate" disabled />
         </el-form-item>
       </el-col>
       <el-col :span="6">
         <el-form-item label="不合格率:" prop="noQualificationRate">
-          <el-input type="number" v-model="form.noQualificationRate" />
+          <el-input v-model="form.noQualificationRate" disabled />
         </el-form-item>
       </el-col>
       <el-col :span="6">
@@ -137,60 +140,58 @@
           required: form.qualityMode == 2 ? true : false,
           message: '请输入取样数量',
           trigger: 'blur'
-        }">
-          <el-input type="number" v-model="form.sampleNumber" />
+        }" v-if="form.qualityMode == 2">
+          <el-input type="number"
+            :disabled="form.qualityMode ==null || form.qualityMode == 1 || (form.qualityMode == 2 && form.sampleNumber) ? true : false"
+            v-model="form.sampleNumber" @change="handleChangeNumber" />
         </el-form-item>
       </el-col>
-    </el-row>
-    <el-row>
+
       <el-col :span="6">
         <el-form-item label="检验标准" prop="inspectionStandards">
           <!-- 计量 计重 -->
-          <el-select
-            style="width: 100%"
-            v-model="form.inspectionStandards"
-            placeholder="请选择"
-          >
-            <el-option
-              v-for="item in inspectionStandardsList"
-              :label="item.label"
-              :value="item.value"
-              :key="item.value"
-            >
+          <el-select style="width: 100%" v-model="form.inspectionStandards" placeholder="请选择"
+            :disabled="parseInt(qualityType1) == 1">
+            <el-option v-for="item in inspectionStandardsList" :label="item.label" :value="item.value"
+              :key="item.value">
             </el-option>
           </el-select>
         </el-form-item>
       </el-col>
       <el-col :span="6">
         <el-form-item label="检验方式:" prop="qualityMode">
-          <DictSelection dictName="取样类型" v-model="form.qualityMode" disabled></DictSelection>
+          <!-- <DictSelection dictName="取样类型" v-model="form.qualityMode" :disabled="qualityType == 1"></DictSelection> -->
+          <el-select style="width: 100%" v-model="form.qualityMode" placeholder="请选择"
+            :disabled="parseInt(qualityType1) == 1">
+            <el-option v-for="item in qualityModeList" :label="item.label" :value="item.value" :key="item.value">
+            </el-option>
+          </el-select>
         </el-form-item>
       </el-col>
       <el-col :span="6">
-        <el-form-item label="质检状态:" prop="qualityResults">
-          <el-select v-model="form.qualityResults" placeholder="请选择" style="width: 100%"
-                     :disabled="btnType == 'detail' || btnType == 'issued'" clearable>
+        <el-form-item label="质检结果:" prop="qualityResults">
+          <el-select v-model="form.qualityResults" placeholder="请选择" style="width: 100%" :disabled="btnType == 'issued'"
+            clearable>
             <el-option label="合格" :value=1 />
             <el-option label="不合格" :value=2 />
           </el-select>
         </el-form-item>
       </el-col>
-    </el-row>
-    <el-row>
-      <el-col :span="24">
-        <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-row>
-    <el-row>
-      <el-col :span="8">
-        <el-form-item label="附件:" prop="imgUrl">
-          <fileUpload v-model="form.imgUrl" />
-        </el-form-item>
-      </el-col>
-    </el-row>
+      <el-row>
+        <el-col :span="24">
+          <el-form-item label="备注:" prop="remark">
+            <el-input type="textarea" v-model="form.remark" placeholder="请输入" :disabled="btnType == 'issued'" />
+          </el-form-item>
+        </el-col>
+      </el-row>
+      <el-row>
+        <el-col :span="8">
+          <el-form-item label="附件:" prop="imgUrl">
+            <fileUpload v-model="form.imgUrl" :type="btnType == 'detail' ? 'view' : ''" />
+          </el-form-item>
+        </el-col>
+      </el-row>
+    </div>
     <ProductionVersion ref="versionRefs" @changeProduct="changeProduct" />
     <EquipmentDialog ref="equipmentRefs" @choose="choose" />
   </el-form>
@@ -205,7 +206,7 @@ import EquipmentDialog from './EquipmentDialog.vue';
 import { getUserPage } from '@/api/system/organization';
 
 import { getProduceTaskList } from '@/api/aps';
-import {getByCode} from "@/api/system/dictionary-data";
+import { getByCode } from "@/api/system/dictionary-data";
 
 export default {
   components: {
@@ -222,9 +223,24 @@ export default {
     btnType: {
       type: String,
       default: ''
+    },
+    qualityType1: {
+      type: String,
+      default: ''
     }
   },
   watch: {
+    'form.qualityMode': {
+      handler(newVal) {
+        if (newVal) {
+          this.$emit('changeModel', newVal);
+        } else {
+          console.log('清空样品清单');
+          // this.$emit('table2');
+        }
+      },
+      immediate: false
+    },
   },
   data() {
     return {
@@ -255,12 +271,19 @@ export default {
       },
       produceTaskList: [],
       inspectionStandardsList: [],
+      qualityModeList: [],
+      isExpanded: false
+
     };
   },
   created() {
     this.getDictListIqoCode('iqo_code');
+    this.getQualityModeList('quality_method_code');
   },
   methods: {
+    toggleExpand() {
+      this.isExpanded = !this.isExpanded;
+    },
     async getDictListIqoCode(code) {
       let { data: res } = await getByCode(code);
       this.inspectionStandardsList = res.map((item) => {
@@ -271,6 +294,16 @@ export default {
         };
       });
     },
+    async getQualityModeList(code) {
+      let { data: res } = await getByCode(code);
+      this.qualityModeList = res.map((item) => {
+        let values = Object.keys(item);
+        return {
+          value: Number(values[0]),
+          label: item[values[0]]
+        };
+      });
+    },
     // 打开工艺路线弹窗
     openVersion() {
       this.$refs.versionRefs.open();
@@ -294,7 +327,7 @@ export default {
         routingId: this.form.produceRoutingId,
         size: -1
       });
-      this.produceTaskList = res.list;
+      this.produceTaskList = res?.list;
     },
     // 选择工序
     produceTaskChange() {
@@ -354,6 +387,11 @@ export default {
         this.form.qualifiedNumber = val;
       }
     },
+    handleChangeNumber(val) {
+      this.form.sampleNumber = val;
+      console.log(val);
+      this.$emit('changeNumber', val);
+    },
   }
 };
 </script>

+ 219 - 0
src/views/inspectionWork/components/sampleDisposeDialog.vue

@@ -0,0 +1,219 @@
+<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">
+    <el-form ref="form1" :model="formData" :rules="rules" label-width="120px">
+      <el-row>
+        <el-col :span="6">
+          <el-form-item label="处置方式" prop="disposalStatus" align="center">
+            <el-select v-model="formData.disposalStatus" placeholder="请选择" style="width: 100%;" v-if="qualityType == 1">
+              <el-option v-for="item in disposalStatusListType" :key="item.value" :label="item.label"
+                :value="item.value">
+              </el-option>
+            </el-select>
+            <el-select v-model="formData.disposalStatus" placeholder="请选择" style="width: 100%;" v-else>
+              <el-option v-for="item in disposalStatusList" :key="item.value" :label="item.label" :value="item.value">
+              </el-option>
+            </el-select>
+          </el-form-item>
+        </el-col>
+        <el-col :span="6" v-if="formData.disposalStatus == 3">
+          <el-form-item label="处置仓库" prop="disposeWarehouseId" align="center">
+            <el-select v-model="formData.disposeWarehouseId" placeholder="请选择" style="width: 100%;" clearable
+              @change="handleWarehouseChange" filterable>
+              <el-option v-for="item in warehouseList" :key="item.disposeWarehouseId" :label="item.disposeWarehouseName"
+                :value="item.disposeWarehouseId">
+              </el-option>
+            </el-select>
+          </el-form-item>
+        </el-col>
+        <el-col :span="6">
+          <el-form-item label="留样日期" prop="sampleDate" align="center">
+            <el-date-picker class="w100" v-model="formData.sampleDate" 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="disposeTime">
+            <el-date-picker class="w100" v-model="formData.disposeTime" type="date" value-format="yyyy-MM-dd"
+              placeholder="请输入"></el-date-picker>
+          </el-form-item>
+        </el-col>
+      </el-row>
+      <el-row style="margin-top:12px">
+        <el-col :span="24">
+          <el-form-item label="留样条件" prop="sampleCondition" align="center">
+            <el-input v-model="formData.sampleCondition" placeholder="请输入" style="width: 100%;"></el-input>
+          </el-form-item>
+        </el-col>
+      </el-row>
+      <el-row style="margin-top:12px">
+        <el-col :span="24">
+          <el-form-item label="生产商/受托生产" prop="producerManufacturer" align="center">
+            <el-input v-model="formData.producerManufacturer" placeholder="请输入" style="width: 100%;"></el-input>
+          </el-form-item>
+        </el-col>
+      </el-row>
+      <el-row style="margin-top:12px">
+        <el-col :span="24">
+          <el-form-item label="留样地点" prop="samplePlace" align="center">
+            <el-input type="textarea" v-model="formData.samplePlace" placeholder="请输入" style="width: 100%;"></el-input>
+          </el-form-item>
+        </el-col>
+      </el-row>
+      <el-row style="margin-top:12px">
+        <el-col :span="24">
+          <el-form-item label="留样备注" prop="sampleRemark" align="center">
+            <el-input type="textarea" v-model="formData.sampleRemark" placeholder="请输入" style="width: 100%;"></el-input>
+          </el-form-item>
+        </el-col>
+      </el-row>
+    </el-form>
+    <template v-slot:footer>
+      <el-button @click="handleClose">取消</el-button>
+      <el-button type="primary" @click="handleConfirm">
+        确认
+      </el-button>
+    </template>
+  </ele-modal>
+</template>
+
+<script>
+
+import { warehouseList } from '@/api/inspectionWork';
+
+export default {
+  components: {
+
+  },
+  data() {
+
+    return {
+      title: '',
+      visible: false,
+      rowIndex: 0,
+      type: '',
+      formData: {},
+      qualityType: '',
+      warehouseList: [],
+      // 表单验证规则
+      rules: {
+        disposeTime: [
+          {
+            required: true,
+            message: '请输入绑定手机号',
+            trigger: 'blur'
+          }
+        ],
+        disposalStatus: [
+          {
+            required: true,
+            message: '请选择处置方式',
+            trigger: 'blur'
+          }
+        ],
+      },
+      disposalStatusList: [
+        {
+          value: 1,
+          label: '返工'
+        },
+        {
+          value: 2,
+          label: '返修'
+        },
+        {
+          value: 3,
+          label: '报废'
+        },
+        {
+          value: 4,
+          label: '降级使用'
+        },
+        {
+          value: 5,
+          label: '让步接收'
+        },
+        {
+          value: 6,
+          label: '留样'
+        },
+        {
+          value: 7,
+          label: '消耗'
+        },
+        {
+          value: 8,
+          label: '回用'
+        },
+      ],
+      disposalStatusListType: [
+        {
+          value: 3,
+          label: '报废'
+        },
+        {
+          value: 6,
+          label: '留样'
+        },
+        {
+          value: 7,
+          label: '消耗'
+        },
+        {
+          value: 8,
+          label: '回用'
+        },
+      ]
+    };
+  },
+  computed: {
+  },
+
+  created() {
+    this.getWarehouseList();
+  },
+  methods: {
+    handleWarehouseChange(val) {
+      this.warehouseList.findIndex((item) => {
+        if (item.disposeWarehouseId == val) {
+          this.formData.disposeWarehouseName = item.disposeWarehouseName;
+        }
+      })
+    },
+    async getWarehouseList() {
+      let res = await warehouseList({});
+      this.warehouseList = res.map((item) => {
+        item.disposeWarehouseName = item.name;
+        item.disposeWarehouseId = item.id;
+        return {
+          ...item
+        }
+      })
+    },
+    async openDispose(index, row, type, qualityType) {
+
+      this.qualityType = qualityType;
+      this.rowIndex = index
+      this.type = type;
+      this.formData = row;
+
+
+      this.visible = true;
+    },
+    handleClose() {
+      this.visible = false;
+    },
+    handleConfirm() {
+      this.$refs.form1.validate((valid) => {
+        if (valid) {
+          console.log(this.formData, "sdfd");
+          this.$emit('handleDisposeConfirm', this.formData, this.rowIndex);
+
+          this.visible = false;
+        }
+      })
+
+    },
+  }
+};
+</script>

+ 18 - 26
src/views/inspectionWork/components/sampleListDialog.vue

@@ -7,7 +7,7 @@
             <el-table-column type="expand">
                 <template slot-scope="props">
                     <div style="padding: 10px;">
-                        <el-table :data="props.row.children" border >
+                        <el-table :data="props.row.qualitySampleTemplateList" border>
                             <el-table-column label="质检方案编码" prop="qualitySchemeTemplateCode" align="center">
                             </el-table-column>
                             <el-table-column label="质检方案名称" prop="qualitySchemeTemplateName"
@@ -41,12 +41,14 @@
             </el-table-column>
             <template v-for="column in tableColumns">
                 <el-table-column :label="column.label" :prop="column.prop" :fixed="column.fixed"
-                    :show-overflow-tooltip="true" :width="column.width" :align="column.align">
+                    :show-overflow-tooltip="true" :width="column.width" :align="column.align"
+                    :formatter="column.formatter">
                 </el-table-column>
             </template>
             <el-table-column label="操作" align="center" width="80">
                 <template slot-scope="scope">
-                    <el-link :underline="false" type="primary">
+                    <el-link :underline="false" type="primary"
+                        @click="handleDispose(scope.$index, scope.row, 'dispose')">
                         处置
                     </el-link>
                 </template>
@@ -101,7 +103,13 @@ export default {
                 { label: '重量', prop: 'weight', align: 'center' },
                 { label: '重量单位', prop: 'weightUnit', align: 'center' },
                 { label: '仓库', prop: 'warehouseName', align: 'center', },
-                { label: '质检结果', prop: '', align: 'center', },
+                {
+                    label: '质检结果', prop: 'qualityResults', align: 'center', formatter: (row, column) => {
+                        if (row.qualityResults) {
+                            return row.qualityResults == 1 ? '合格' : row.qualityResults == 2 ? '不合格' : row.qualityResults == 3 ? '让步接收' : '';
+                        }
+                    }
+                },
                 // { label: '货区', prop: 'areaName', align: 'center', },
                 // { label: '货架', prop: 'goodsShelfName', align: 'center', },
                 // { label: '货位', prop: 'goodsAllocationName', align: 'center', },
@@ -129,41 +137,25 @@ export default {
 
     created() { },
     methods: {
-        async openDia(index, row, type, list,isStatus) {
+        async openDia(index, row, type, list, isStatus) {
+            this.tableData = [];
             this.rowIndex = index
             this.type = type;
-            if (row != null && row.isStatus) {
-              this.tableDataUpdate(list);
-            }else{
-              if (isStatus){
-                this.tableDataUpdate(list);
-              }
-            }
+            console.log(list, 'lklllllllllllllllllkkkkkkkkkkkkkkkkkkkkk');
             this.tableData = list;
 
             this.visible = true;
         },
         handleClose() {
-            this.tableData.forEach((item) => {
-                item.children.forEach((child) => {
-                    child.qualityResultContent = '';
-                    child.qualityResults = ''
-                })
-            })
             this.visible = false;
         },
         handleConfirm() {
             this.visible = false;
             this.$emit('handleConfirm', this.tableData, this.rowIndex);
         },
-      tableDataUpdate(list) {
-        for (let i = 0; i < list.length; i++) {
-          const arr = list[i].children
-          for (let j = 0; j < arr.length; j++) {
-            arr[j].qualityResults = 1
-          }
-        }
-      }
+        handleDispose(index, row, type) {
+            this.$emit('handleDispose', index, row, type);
+        },
     }
 };
 </script>

+ 715 - 0
src/views/inspectionWork/edit copy.vue

@@ -0,0 +1,715 @@
+<template>
+  <div class="ele-body">
+    <el-card shadow="never">
+      <header-title title="基本信息">
+        <el-button @click="cancel">返回</el-button>
+        <el-button type="primary" @click="save" :loading="loading" v-if="type != 'detail'">保存</el-button>
+        <el-button type="primary" @click="handleReporting" :loading="loading" v-if="type != 'detail'">报工完成</el-button>
+      </header-title>
+      <base-info ref="baseInfoRefs" v-if="form" :form="form" :btnType="type" :qualityType1="qualityType"
+        @changeModel="changeModel" @changeNumber="changeNumber"></base-info>
+      <el-row>
+        <header-title title="质检内容">
+          <el-button type="primary" :loading="loading" v-if="type != 'detail'"
+            @click="batchQuality(null, null, 'report')">批量质检</el-button>
+        </header-title>
+        <el-tabs v-model="activeName" @tab-click="handleClick">
+          <el-tab-pane label="来源清单" name="1"></el-tab-pane>
+          <el-tab-pane label="样品清单" name="2"></el-tab-pane>
+          <el-tab-pane label="质检方案" name="3"></el-tab-pane>
+        </el-tabs>
+      </el-row>
+      <!--  -->
+      <el-row style="margin-top: 24px">
+        <el-table v-show="activeName === '1'" v-if="packingList.length > 0" ref="showPackingListTable"
+          :data="paginatedPackingList" tooltip-effect="dark" :max-height="300" border row-key="id"
+          @selection-change="handleSelectionChange1">
+          <el-table-column type="selection" width="55" align="center" :reserve-selection="true"
+            :selectable="checkSelectable"></el-table-column>
+          <el-table-column label="序号" type="index" width="50" align="center"></el-table-column>
+          <template v-for="column in tableColumns">
+            <el-table-column :label="column.label" :prop="column.prop" :show-overflow-tooltip="true"
+              :width="column.width" :align="column.align"></el-table-column>
+          </template>
+        </el-table>
+        <el-pagination v-show="activeName === '1' && packingList.length > 0" @size-change="handleSizeChange"
+          @current-change="handleCurrentChange" :current-page="pagination.currentPage" :page-sizes="[10, 20, 50, 100]"
+          :page-size="pagination.pageSize" layout="total, sizes, prev, pager, next" :total="packingList.length"
+          style="margin-top: 16px" />
+        <!--  -->
+        <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" fixed="left"></el-table-column>
+          <template v-for="column in tableColumns">
+            <el-table-column :key="column.prop" :label="column.label" :prop="column.prop" :fixed="column.fixed"
+              :show-overflow-tooltip="true" :width="column.width" :align="column.align">
+              <template slot-scope="scope">
+                <template v-if="column.prop === 'categoryCode'">
+                  <el-link type="primary" :underline="false" @click="handleDetail(scope.$index, scope.row, 'detail')">
+                    {{ scope.row.categoryCode }}
+                  </el-link>
+                </template>
+                <template v-else-if="column.prop === 'weight'">
+                  <el-input type="number" v-model="scope.row.weight" :min="0"></el-input>
+                </template>
+                <template v-else>
+                  {{ scope.row[column.prop] }}
+                </template>
+              </template>
+            </el-table-column>
+          </template>
+          <el-table-column label="处置状态" prop="disposalStatus" align="center" width="80" fixed="right"
+            :show-overflow-tooltip="true">
+            <template slot-scope="scope">
+              <span v-if="scope.row.disposalStatus == 1 && form.qualityType == 2">返工</span>
+              <span v-if="scope.row.disposalStatus == 2 && form.qualityType == 2">返修</span>
+              <span v-if="scope.row.disposalStatus == 3">报废</span>
+              <span v-if="scope.row.disposalStatus == 4 && form.qualityType == 2">降级使用</span>
+              <span v-if="scope.row.disposalStatus == 5 && form.qualityType == 2">让步接收</span>
+              <span v-if="scope.row.disposalStatus == 6">留样</span>
+              <span v-if="scope.row.disposalStatus == 7">消耗</span>
+              <span v-if="scope.row.disposalStatus == 8">回用</span>
+            </template>
+          </el-table-column>
+          <el-table-column label="处置时间" prop="disposeTime" align="center" width="100" fixed="right"
+            :show-overflow-tooltip="true">
+          </el-table-column>
+          <el-table-column label="质检状态" prop="qualityStatus" align="center" width="120" fixed="right"
+            :show-overflow-tooltip="true">
+            <template slot-scope="scope">
+              <span v-if="scope.row.qualityStatus == 0">未检</span>
+              <span v-if="scope.row.qualityStatus == 1">已检</span>
+              <span v-if="scope.row.qualityStatus == 2">待检</span>
+            </template>
+          </el-table-column>
+          <el-table-column label="质检结果" prop="qualityResults" align="center" width="110" fixed="right"
+            :show-overflow-tooltip="true">
+            <template slot-scope="scope">
+              <el-select v-model="scope.row.qualityResults" placeholder="请选择" style="width: 100%;"
+                :disabled="type == 'detail'" size="mini">
+                <el-option v-for="item in qualityResultsList" :key="item.value" :label="item.label" :value="item.value">
+                </el-option>
+              </el-select>
+            </template>
+          </el-table-column>
+          <el-table-column label="操作" align="center" width="120" fixed="right" v-if="type != 'detail'">
+            <template slot-scope="scope">
+              <el-link :type="scope.row.isValid ? 'primary' : 'danger'" :underline="false"
+                @click="handleDetail(scope.$index, scope.row, 'report')">
+                质检
+              </el-link>
+              <el-link type='primary' :underline="false" @click="handleDispose(scope.$index, scope.row, 'dispose')">处置
+              </el-link>
+            </template>
+          </el-table-column>
+        </el-table>
+        <el-pagination v-show="activeName === '2'" v-if="sampleList" @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="sampleList.length"
+          style="margin-top: 10px"></el-pagination>
+        <!--  -->
+        <el-table v-show="activeName === '3'" 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">
+          </el-table-column>
+          <el-table-column label="质检方案名称" prop="qualitySchemeTemplateName" align="center"></el-table-column>
+          <el-table-column label="质检类型" prop="categoryLevelClassName" align="center"></el-table-column>
+          <el-table-column label="质检项编码" prop="inspectionCode" align="center"></el-table-column>
+          <el-table-column label="质检项名称" prop="inspectionName" align="center"></el-table-column>
+          <el-table-column label="工艺参数" prop="defaultValue" align="center">
+          </el-table-column>
+        </el-table>
+        <el-pagination v-show="activeName === '3'" @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="schemeList.length"
+          style="margin-top: 10px"></el-pagination>
+      </el-row>
+    </el-card>
+
+    <sampleListDialog ref="detailRef" @handleConfirm="handleConfirm" @handleDispose="handleDispose"></sampleListDialog>
+    <sampleDisposeDialog ref="disposeRef" @handleDisposeConfirm="handleDisposeConfirm"></sampleDisposeDialog>
+  </div>
+</template>
+
+<script>
+import baseInfo from './components/baseInfo.vue';
+
+import { getCode } from '@/api/login';
+import { save, update, getById, exeReportWork, queryQualitySamplContent, queryQualityTempleContent, queryQualityInventory } from '@/api/inspectionWork';
+
+import dictMixins from '@/mixins/dictMixins';
+
+// import term from './term';
+import sampleListDialog from './components/sampleListDialog.vue';
+import sampleDisposeDialog from './components/sampleDisposeDialog.vue';
+
+import { finishPageTab } from '@/utils/page-tab-util';
+export default {
+  components: {
+    baseInfo,
+    // term
+    sampleListDialog,
+    sampleDisposeDialog
+  },
+  mixins: [dictMixins],
+
+  data() {
+    const defaultForm = function () {
+      return {
+        code: '',
+        qualityType: null,
+        qualityModeproduceRoutingId: '',
+        produceRoutingName: '',
+        produceTaskId: '',
+        produceTaskName: '',
+        productName: '',
+        productCode: '',
+        batchNo: '',
+        specification: '',
+        modelType: '',
+        brandNo: '',
+        total: '',
+        qualifiedNumber: '',
+        noQualifiedNumber: '',
+        groupId: '',
+        groupName: '',
+        qualityId: '',
+        qualityName: '',
+        qualityTime: '',
+        hours: '',
+        qualificationRate: '',
+        noQualificationRate: '',
+        totalWeight: '',
+        sampleNumber: '',
+        imgUrl: [],
+        qualityTimeStart: '',
+        qualityTimeEnd: ''
+      };
+    };
+    return {
+      defaultForm,
+      // 表单数据
+      form: { ...defaultForm() },
+      voList: [],
+
+      // 表单验证规则
+      categoryParamList: [],
+      type: '',
+      title: '',
+      loading: false,
+
+      tabTaskId: null,
+      activeName: '2',
+      qualityResultsList: [{
+        value: 1,
+        label: '合格'
+      },
+      {
+        value: 2,
+        label: '不合格'
+      },
+      {
+        value: 3,
+        label: '让步接收'
+      }],
+      tableColumns: [
+        {
+          label: '编码',
+          prop: 'categoryCode',
+          width: '160',
+          align: 'center',
+          fixed: 'left'
+        },
+        {
+          label: '名称',
+          prop: 'categoryName',
+          width: '150',
+          align: 'center'
+        },
+        { label: '批次号', prop: 'batchNo', align: 'center' },
+        { label: '发货条码', prop: 'barcodes', align: 'center' },
+        { label: '包装编码', prop: 'packageNo', align: 'center' },
+        // { label: '包装数量', prop: 'packingQuantity', align: 'center' },
+        { label: '包装单位', prop: 'packingUnit', align: 'center' },
+        { label: '计量数量', prop: 'measureQuantity', align: 'center' },
+        { label: '计量单位', prop: 'measureUnit', align: 'center' },
+        { label: '物料代号', prop: 'materielDesignation', align: 'center' },
+        { label: '客户代号', prop: 'clientCode', align: 'center' },
+        { label: '刻码', prop: 'engrave', align: 'center' },
+        { label: '重量', prop: 'weight', align: 'center', width: "100" },
+        { label: '重量单位', prop: 'weightUnit', align: 'center', width: "100" },
+        { 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: [],
+      pagination: {
+        currentPage: 1,
+        pageSize: 10,
+        total: 0
+      },
+
+      sampleList: [],
+      samplePagination: {
+        currentPage: 1,
+        pageSize: 10,
+        total: 0
+      },
+      schemeList: [],
+      schemePagination: {
+        currentPage: 1,
+        pageSize: 10,
+        total: 0
+      },
+      isValid: true,
+      isStatus: true,
+      SampleListbyReportList: [],
+      qualityTimeStart: ''
+
+    };
+  },
+  watch: {
+    '$route.query.id': {
+      handler(id) {
+        if (id) {
+          this.getDetail();
+        } else {
+          this.form = { ...defaultForm() };
+
+        }
+      }
+    },
+  },
+  computed: {
+    paginatedPackingList() {
+      const start =
+        (this.pagination.currentPage - 1) * this.pagination.pageSize;
+      const end = start + this.pagination.pageSize;
+      return this.packingList.slice(start, end);
+    },
+    // 分页后的样品列表
+    paginatedSampleList() {
+      const { currentPage, pageSize } = this.samplePagination;
+      const start = (currentPage - 1) * pageSize;
+      const end = start + pageSize;
+      return this.sampleList?.slice(start, end);
+    },
+    // 分页后的质检方案列表
+    paginatedSchemeList() {
+      const { currentPage, pageSize } = this.schemePagination;
+      const start = (currentPage - 1) * pageSize;
+      const end = start + pageSize;
+      return this.schemeList?.slice(start, end);
+    }
+  },
+  created() {
+    this.open()
+    if (this.$route.query.id) {
+      this.getDetail();
+    }
+  },
+  methods: {
+
+    checkSelectable(row, index) {
+      // 只有当质检方式为抽检(qualityMode=2)时才可选
+      return this.form.qualityMode === 2;
+    },
+    changeModel(val) {
+      this.form.qualityMode = val;
+      if (this.form.qualityMode == 1) {
+        if (this.schemeList.length == 0) {
+          for (let i = 0; i < this.packingList.length; i++) {
+            console.log(this.packingList[i], 'selection[i]')
+            this.$set(this.packingList[i], 'qualityStatus', 2)
+          }
+        }
+
+        this.sampleList = this.packingList;
+        this.samplePagination.currentPage = 1;
+        this.samplePagination.total = this.packingList.length;
+      } else {
+        this.sampleList = [];
+      }
+    },
+    changeNumber(val) {
+      if (this.form.qualityMode !== 2) {
+        return;
+      }
+      if (val <= 0) {
+        this.$refs.showPackingListTable.clearSelection();
+        return;
+      }
+
+      if (val > this.packingList.length) {
+        this.$message.warning('取样数量不能大于物料明细总数!');
+        return;
+      }
+      const rows = this.packingList.slice(0, val);
+      rows.forEach((row) => {
+        this.$refs.showPackingListTable.toggleRowSelection(row);
+      });
+
+    },
+    getNowDate() {
+      let date = new Date(),
+        obj = {
+          year: date.getFullYear(), //获取当前月份(0-11,0代表1月)
+          month: date.getMonth() + 1, //获取当前月份(0-11,0代表1月)
+          strDate: date.getDate(), // 获取当前日(1-31)
+          hour: date.getHours(), //获取当前小时(0 ~ 23)
+          minute: date.getMinutes(), //获取当前分钟(0 ~ 59)
+          second: date.getSeconds() //获取当前秒数(0 ~ 59)
+        };
+      Object.keys(obj).forEach((key) => {
+        if (obj[key] < 10) obj[key] = `0${obj[key]}`;
+      });
+      return obj;
+    },
+    handleSelectionChange1(selection) {
+      console.log(selection, '勾选列表');
+      this.form.sampleNumber = selection.length;
+      if (this.form.qualityMode === 2) {
+        this.selectedList = selection;
+
+        if (this.schemeList.length == 0) {
+          for (let i = 0; i < selection.length; i++) {
+            console.log(selection[i], 'selection[i]')
+            this.$set(selection[i], 'qualityStatus', 2)
+          }
+        }
+
+        // if (this.qualityType == 2 && selection.length > 0) {
+        //   const ProductSampleList = [];
+
+        //   selection.forEach(oldItem => {
+        //     const count = oldItem.measureQuantity;
+        //     const newMeasureQuantity = oldItem.measureQuantity / count;
+        //     const newWeight = parseFloat((oldItem.weight / count).toFixed(2))
+        //     console.log(count, newMeasureQuantity, newWeight)
+        //     delete oldItem.id;
+
+        //     for (let i = 0; i < count; i++) {
+        //       ProductSampleList.push({
+        //         ...oldItem,
+        //         measureQuantity: newMeasureQuantity,
+        //         weight: newWeight
+        //       });
+        //     }
+        //   });
+        //   this.sampleList = ProductSampleList;
+        //   this.samplePagination.currentPage = 1;
+        //   this.samplePagination.total = selection.length;
+        // } else {
+          this.sampleList = selection;
+          this.samplePagination.currentPage = 1;
+          this.samplePagination.total = selection.length;
+          this.form.sampleNumber = selection.length;
+        // }
+      }
+    },
+
+    async open() {
+      this.type = this.$route.query.type;
+      this.qualityType = this.$route.query.qualityType;
+      this.title = this.type == 'add' ? '新增' : this.type == 'edit' ? '报工' : '详情';
+
+      if (this.type == 'add') {
+        const code = await getCode('quality_work_order_code');
+        this.form.code = code;
+      } else {
+        if (this.$route.query.qualityTimeStart != '' || this.$route.query.qualityTimeStart != null || this.$route.query.qualityTimeStart != undefined) {
+          this.qualityTimeStart = this.getNowTime();
+          console.log(this.qualityTimeStart, '开始报工时间')
+        }
+      }
+    },
+    getNowTime() {
+      const nowDate = this.getNowDate()
+      return nowDate.year + '-' + nowDate.month + '-' + nowDate.strDate + ' ' + nowDate.hour + ':' + nowDate.minute + ':' + nowDate.second
+    },
+    getNowTimes() {
+      const nowDate = this.getNowDate()
+      return nowDate.year + '-' + nowDate.month + '-' + nowDate.strDate
+    },
+    async getDetail() {
+
+      getById(this.$route.query.id).then((res) => {
+        this.form = res.data;
+
+        this.tabTaskId =
+          this.categoryParamList[0] && this.categoryParamList[0].id;
+
+        if (this.form.groupId) {
+          this.$nextTick(() => {
+            this.$refs.baseInfoRefs?.getUserList({
+              groupId: this.form.groupId
+            });
+          });
+        }
+        if (this.form.produceRoutingId) {
+          this.$nextTick(() => {
+            this.$refs.baseInfoRefs?.getTaskList();
+          })
+        }
+      });
+      await this.queryQualityInventory()
+      await this.queryQualitySamplContent()
+      await this.queryQualityTempleContent()
+    },
+    async queryQualityInventory() {
+      let res = await queryQualityInventory({ qualityWorkerId: this.$route.query.id });
+      console.log(res, '清单列表');
+      this.packingList = res;
+      this.samplePagination.currentPage = 1;
+      this.samplePagination.total = this.packingList.length;
+    },
+    async queryQualitySamplContent() {
+      const res = await queryQualitySamplContent({ qualityWorkerId: this.$route.query.id })
+      let addStatus = res.map((item) => {
+        item.isValid = true;
+        item.disposeTime = item.disposeTime ? item.disposeTime.split(' ')[0] : null;
+        item.sampleDate = item.sampleDate ? item.sampleDate.split(' ')[0] : null;
+        return {
+          ...item
+        }
+      })
+      console.log(addStatus, '样品清单')
+
+      //生产
+      if (this.qualityType == 2 && addStatus[0]?.measureQuantity) {
+        const ProductSampleList = [];
+
+        addStatus.forEach(oldItem => {
+          const count = oldItem.measureQuantity;
+          const newMeasureQuantity = oldItem.measureQuantity / count;
+          const newWeight = parseFloat((oldItem.weight / count).toFixed(2))
+          console.log(count, newMeasureQuantity, newWeight)
+          delete oldItem.id;
+
+          for (let i = 0; i < count; i++) {
+            ProductSampleList.push({
+              ...oldItem,
+              measureQuantity: newMeasureQuantity,
+              weight: newWeight
+            });
+          }
+        });
+
+        this.sampleList = ProductSampleList;
+        this.samplePagination.currentPage = 1;
+        this.samplePagination.total = this.sampleList.length;
+      } else {
+        //样品
+        this.sampleList = addStatus;
+        this.samplePagination.currentPage = 1;
+        this.samplePagination.total = this.sampleList.length;
+      }
+    },
+    async queryQualityTempleContent() {
+      const res = await queryQualityTempleContent({ qualityWorkerId: this.$route.query.id })
+      console.log(res, '222');
+      // 方案
+      this.schemeList = res;
+      this.schemePagination.currentPage = 1;
+      this.schemePagination.total = this.schemeList.length;
+    },
+    handleClick(tab) {
+      this.activeName = tab.name;
+    },
+    // 来料清单列表分页方法
+    handleSizeChange(val) {
+      this.pagination.pageSize = val;
+      this.pagination.currentPage = 1;
+    },
+    handleCurrentChange(val) {
+      this.pagination.currentPage = val;
+    },
+
+    // 样品列表分页方法
+    handleSampleSizeChange(val) {
+      this.samplePagination.pageSize = val;
+      this.samplePagination.currentPage = 1;
+    },
+    handleSampleCurrentChange(val) {
+      this.samplePagination.currentPage = val;
+    },
+    // 质检方案分页方法
+    handleSchemeSizeChange(val) {
+      this.schemePagination.pageSize = val;
+      this.schemePagination.currentPage = 1;
+    },
+    handleSchemeCurrentChange(val) {
+      this.schemePagination.currentPage = val;
+    },
+    /* 保存编辑 */
+    save() {
+      this.$refs.baseInfoRefs.$refs.form1.validate((valid) => {
+        if (!valid) {
+          return false;
+        }
+        this.loading = true;
+        let URL =
+          this.type == 'add' ? save : this.type == 'edit' ? update : '';
+
+        this.form.qualityTimeStart = new Date(this.qualityTimeStart)
+
+        delete this.form['qualityTimeEnd']
+
+        let params = {
+          ...this.form,
+          sampleList: this.sampleList,
+          planTemplateList: this.schemeList,
+          qualityInventoryList: this.packingList
+        }
+        URL(params)
+          .then((msg) => {
+            this.loading = false;
+            this.$message.success(msg);
+            this.cancel();
+            this.$emit('done');
+          })
+          .catch((e) => {
+            this.loading = false;
+          });
+      });
+    },
+    update() {
+      this.loading = true;
+      this.form['status'] = 1;
+      update({ ...this.form })
+        .then((msg) => {
+          this.loading = false;
+          this.$message.success(msg);
+          this.$emit('done');
+        })
+        .catch((e) => {
+          this.loading = false;
+        });
+    },
+    restForm() {
+      this.form = { ...this.defaultForm() };
+      this.$nextTick(() => {
+        this.$refs.baseInfoRefs.$refs.form1.clearValidate();
+      });
+    },
+    cancel() {
+      finishPageTab();
+      this.$router.go(-1);
+    },
+    handleDetail(index, row, type) {
+      if (!this.sampleList[index] || !this.schemeList) {
+        return;
+      }
+      const selectedData = [];
+      selectedData.push(this.sampleList[index])
+
+      this.$refs.detailRef.openDia(index, row, type, selectedData, null);
+    },
+    handleDispose(index, row, type) {
+      if (!this.sampleList[index]) {
+        return;
+      }
+
+      this.sampleList[index].sampleDate = this.getNowTimes();
+
+      this.sampleList[index].disposeTime = this.getNowTimes();
+
+      console.log(index, row, type, this.qualityType)
+
+      this.$refs.disposeRef.openDispose(index, row, type, this.qualityType);
+    },
+    // 报工
+    handleReporting(index, row) {
+      this.$refs.baseInfoRefs.$refs.form1.validate((valid) => {
+        if (!valid) {
+          return false;
+        }
+
+        for (let i = 0; i < this.sampleList.length; i++) {
+
+          const qualityStatus = this.sampleList[i].qualityStatus;
+
+          if (qualityStatus == '2') {
+            this.$message.error('请完成以下样品质检!')
+            this.loading = false;
+            return
+          }
+        }
+
+        this.form.qualityTimeEnd = new Date(this.getNowTime())
+        this.form.qualityTimeStart = new Date(this.qualityTimeStart)
+        let params = {
+          ...this.form,
+          sampleList: this.sampleList,
+          planTemplateList: this.schemeList,
+          qualityInventoryList: this.packingList
+        }
+        console.log(params, 'params')
+        exeReportWork(params)
+          .then((msg) => {
+            this.loading = false;
+            this.$message.success(msg);
+            this.cancel();
+            this.$emit('done');
+          })
+          .catch((e) => {
+            this.loading = false;
+          });
+      })
+    },
+    // 处理确认事件
+    handleDisposeConfirm(row, index) {
+      if (index > -1) {
+        this.$set(this.sampleList, index, row)
+      }
+    },
+    //确认报工
+    handleConfirm(list, index) {
+      console.log(list)
+
+      // 检查有效性
+      for (const item of list) {
+        for (const child of item.qualitySampleTemplateList) {
+
+          console.log(child, 'child')
+          if (!child.qualityResultContent || !child.qualityResults) {
+            this.$message.error('请完善报工内容!');
+            return;
+          }
+        }
+      }
+      console.log(list, 'listlistlistlist')
+      list.forEach((item) => {
+        if (item.qualitySampleTemplateList.some(child => child.qualityResults === 2)) {
+          item.isValid = false;
+          item.qualityResults = 2;
+        } else {
+          item.isValid = true;
+          item.qualityResults = 1;
+        }
+        item.qualityStatus = 1;
+      })
+      if (index != null) {
+        this.$set(this.sampleList, index, list[0]);
+      } else {
+        this.$set(this.sampleList, null, list);
+      }
+      console.log(this.sampleList, '222表')
+
+    },
+    // 批量质检
+    batchQuality(index, row, type) {
+      this.$refs.detailRef.openDia(null, null, type, this.sampleList, null)
+    }
+  }
+};
+</script>
+
+<style lang="scss" scoped></style>

+ 311 - 294
src/views/inspectionWork/edit.vue

@@ -3,118 +3,25 @@
     <el-card shadow="never">
       <header-title title="基本信息">
         <el-button @click="cancel">返回</el-button>
-        <el-button type="primary" @click="save" :loading="loading">保存</el-button>
-        <el-button type="primary" @click="handleReporting" :loading="loading">报工完成</el-button>
+        <el-button type="primary" @click="save" :loading="loading" v-if="type != 'detail'">保存</el-button>
+        <el-button type="primary" @click="handleReporting" :loading="loading" v-if="type != 'detail'">报工完成</el-button>
       </header-title>
-      <base-info ref="baseInfoRefs" v-if="form" :form="form" :btnType="type"></base-info>
-      <el-row>
-        <header-title title="质检内容">
-          <el-button type="primary" :loading="loading" @click="batchQuality(null,null,'report')">批量质检</el-button>
-        </header-title>
-        <el-tabs v-model="activeName" @tab-click="handleClick">
-          <el-tab-pane label="来源清单" name="1"></el-tab-pane>
-          <el-tab-pane label="样品清单" name="2"></el-tab-pane>
-          <el-tab-pane label="质检方案" name="3"></el-tab-pane>
-        </el-tabs>
-      </el-row>
-      <el-row style="margin-top: 24px">
-        <el-table v-show="activeName === '1'" v-if="packingList.length > 0" ref="showPackingListTable"
-          :data="paginatedPackingList" 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 tableColumns">
-            <el-table-column :label="column.label" :prop="column.prop" :show-overflow-tooltip="true"
-              :width="column.width" :align="column.align"></el-table-column>
-          </template>
-        </el-table>
-        <!--  -->
-        <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"
-          @selection-change="handleSelectionChange">
-          <el-table-column type="selection" width="55" align="center" fixed="left"></el-table-column>
-          <el-table-column label="序号" type="index" width="50" align="center" fixed="left"></el-table-column>
-
-          <template v-for="column in tableColumns">
-            <el-table-column :key="column.prop" :label="column.label" :prop="column.prop" :fixed="column.fixed" :show-overflow-tooltip="true"
-              :width="column.width" :align="column.align">
-              <template slot-scope="scope">
-                <template v-if="column.prop === 'categoryCode'">
-                  <el-link type="primary" :underline="false" @click="handleDetail(scope.$index, scope.row, 'detail')">
-                    {{ scope.row.categoryCode }}
-                  </el-link>
-                </template>
-<!--                <template v-else-if="column.prop === 'weight'">-->
-<!--                  <el-input v-model="scope.row.weight"></el-input>-->
-<!--                </template>-->
-                <template v-else>
-                  {{ scope.row[column.prop] }}
-                </template>
-              </template>
-            </el-table-column>
-          </template>
-          <el-table-column label="重量" prop="weight" align="center" width="100" fixed="right">
-            <template slot-scope="scope">
-              <el-input type="number" v-model="scope.row.weight" :min="0"></el-input>
-            </template>
-          </el-table-column>
-          <el-table-column label="重量单位" prop="weightUnit" align="center" width="80" fixed="right"></el-table-column>
-          <el-table-column label="质检状态" prop="qualityStatus" align="center" width="120" fixed="right">
-            <template slot-scope="scope">
-              <span v-if="scope.row.qualityStatus == 0 ">未质检</span>
-              <span v-if="scope.row.qualityStatus == 1 ">已质检</span>
-            </template>
-          </el-table-column>
-          <el-table-column label="质检结果" prop="qualityResults" align="center" width="120" fixed="right">
-            <template slot-scope="scope">
-              <el-select v-model="scope.row.qualityResults" placeholder="请选择" style="width: 100%;"
-                :disabled="type == 'detail'" size="mini">
-                <el-option v-for="item in qualityResultsList" :key="item.value" :label="item.label" :value="item.value">
-                </el-option>
-              </el-select>
-            </template>
-          </el-table-column>
-          <el-table-column label="操作" align="center" width="120" fixed="right">
-            <template slot-scope="scope">
-              <el-link :type="scope.row.isValid ? 'primary' : 'danger'" :underline="false"
-                @click="handleDetail(scope.$index, scope.row, 'report')">
-                质检
-              </el-link>
-              <el-link type='primary' :underline="false"> 处置 </el-link>
-            </template>
-          </el-table-column>
-        </el-table>
-        <el-pagination v-show="activeName === '2'" v-if="sampleList" @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="sampleList.length"
-          style="margin-top: 10px"></el-pagination>
-
-        <!--  -->
-        <el-table v-show="activeName === '3'" 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">
-          </el-table-column>
-          <el-table-column label="质检方案名称" prop="qualitySchemeTemplateName" align="center"></el-table-column>
-          <el-table-column label="质检类型" prop="categoryLevelClassName" align="center"></el-table-column>
-          <el-table-column label="质检项编码" prop="inspectionCode" align="center"></el-table-column>
-          <el-table-column label="质检项名称" prop="inspectionName" align="center"></el-table-column>
-          <el-table-column label="工艺参数" prop="defaultValue" align="center">
-          </el-table-column>
-        </el-table>
-        <el-pagination v-show="activeName === '3'" @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="schemeList.length"
-          style="margin-top: 10px"></el-pagination>
-      </el-row>
+      <base-info ref="baseInfoRefs" v-if="form" :form="form" :btnType="type" :qualityType1="qualityType"
+        @changeModel="changeModel" @changeNumber="changeNumber"></base-info>
+
+      <quality-content-tabs :type="type" :packing-list="packingList" :sample-list="sampleList" :scheme-list="schemeList"
+        :loading="loading" :form="form" @selection-change="handleSelectionChange1" @batch-quality="batchQuality"
+        @handleDetail="handleDetail" @inputWeight="inputWeight" @handleDispose="handleDispose" />
     </el-card>
 
-    <sampleListDialog ref="detailRef" @handleConfirm="handleConfirm"></sampleListDialog>
+    <sampleListDialog ref="detailRef" @handleConfirm="handleConfirm" @handleDispose="handleDispose"></sampleListDialog>
+    <sampleDisposeDialog ref="disposeRef" @handleDisposeConfirm="handleDisposeConfirm"></sampleDisposeDialog>
   </div>
 </template>
 
 <script>
 import baseInfo from './components/baseInfo.vue';
+import QualityContentTabs from './components/QualityContentTabs.vue'
 
 import { getCode } from '@/api/login';
 import { save, update, getById, exeReportWork, queryQualitySamplContent, queryQualityTempleContent, queryQualityInventory } from '@/api/inspectionWork';
@@ -123,13 +30,15 @@ import dictMixins from '@/mixins/dictMixins';
 
 // import term from './term';
 import sampleListDialog from './components/sampleListDialog.vue';
+import sampleDisposeDialog from './components/sampleDisposeDialog.vue';
 
 import { finishPageTab } from '@/utils/page-tab-util';
 export default {
   components: {
     baseInfo,
-    // term
-    sampleListDialog
+    QualityContentTabs,
+    sampleListDialog,
+    sampleDisposeDialog
   },
   mixins: [dictMixins],
 
@@ -137,7 +46,7 @@ export default {
     const defaultForm = function () {
       return {
         code: '',
-        qualityType: '',
+        qualityType: null,
         qualityModeproduceRoutingId: '',
         produceRoutingName: '',
         produceTaskId: '',
@@ -162,6 +71,8 @@ export default {
         totalWeight: '',
         sampleNumber: '',
         imgUrl: [],
+        qualityTimeStart: '',
+        qualityTimeEnd: '',
       };
     };
     return {
@@ -177,75 +88,17 @@ export default {
       loading: false,
 
       tabTaskId: null,
-      activeName: '2',
-      qualityResultsList: [{
-        value: 1,
-        label: '合格'
-      },
-      {
-        value: 2,
-        label: '不合格'
-      },
-      {
-        value: 3,
-        label: '让步接收'
-      }],
-      tableColumns: [
-        {
-          label: '编码',
-          prop: 'categoryCode',
-          width: '160',
-          align: 'center',
-          fixed:'left'
-        },
-        {
-          label: '名称',
-          prop: 'categoryName',
-          width: '150',
-          align: 'center'
-        },
-        { label: '批次号', prop: 'batchNo', align: 'center' },
-        { label: '发货条码', prop: 'barcodes', align: 'center' },
-        { label: '包装编码', prop: 'packageNo', align: 'center' },
-        { label: '包装数量', prop: 'packingQuantity', align: 'center' },
-        { label: '包装单位', prop: 'packingUnit', align: 'center' },
-        { label: '计量数量', prop: 'measureQuantity', align: 'center' },
-        { label: '计量单位', prop: 'measureUnit', align: 'center' },
-        { label: '物料代号', prop: 'materielDesignation', align: 'center' },
-        { label: '客户代号', prop: 'clientCode', align: 'center' },
-        { label: '刻码', prop: 'engrave', align: 'center' },
-        // { 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' },
-      ],
+      // activeName: '2',
 
-      packingList: [],
-      pagination: {
-        currentPage: 1,
-        pageSize: 10,
-        total: 0
-      },
 
+      packingList: [],
       sampleList: [],
-      samplePagination: {
-        currentPage: 1,
-        pageSize: 10,
-        total: 0
-      },
       schemeList: [],
-      schemePagination: {
-        currentPage: 1,
-        pageSize: 10,
-        total: 0
-      },
+
       isValid: true,
       isStatus: true,
       SampleListbyReportList: [],
+      qualityTimeStart: ''
 
     };
   },
@@ -256,33 +109,11 @@ export default {
           this.getDetail();
         } else {
           this.form = { ...defaultForm() };
-
         }
       }
     },
   },
-  computed: {
-    paginatedPackingList() {
-      const start =
-        (this.pagination.currentPage - 1) * this.pagination.pageSize;
-      const end = start + this.pagination.pageSize;
-      return this.packingList.slice(start, end);
-    },
-    // 分页后的样品列表
-    paginatedSampleList() {
-      const { currentPage, pageSize } = this.samplePagination;
-      const start = (currentPage - 1) * pageSize;
-      const end = start + pageSize;
-      return this.sampleList?.slice(start, end);
-    },
-    // 分页后的质检方案列表
-    paginatedSchemeList() {
-      const { currentPage, pageSize } = this.schemePagination;
-      const start = (currentPage - 1) * pageSize;
-      const end = start + pageSize;
-      return this.schemeList?.slice(start, end);
-    }
-  },
+
   created() {
     this.open()
     if (this.$route.query.id) {
@@ -290,20 +121,201 @@ export default {
     }
   },
   methods: {
+    //切换检验方式
+    changeModel(val,flag) {
+      debugger
+      this.form.qualityMode = val;
+      //检验方式 全检
+      if (this.form.qualityMode == 1) {
+        this.form.sampleNumber = ''
+        if (this.schemeList.length == 0) {
+          for (let i = 0; i < this.packingList.length; i++) {
+            console.log(this.packingList[i], 'selection[i]')
+            this.$set(this.packingList[i], 'qualityStatus', 2)
+          }
+        }
+        this.getProSamList(this.packingList)
+
+      } else {
+        if (!flag){
+          this.sampleList = [];
+        }
+      }
+    },
+    //根据类型判断样品清单现实列表数据
+    getProSamList(list) {
+      //生产检验
+      if (this.qualityType == '2' ) {
+        if (this.form.qualityMode != null){
+          const ProductSampleList = [];
+          console.log(list, 'list')
+          list.forEach(oldItem => {
+            const count = oldItem.measureQuantity;
+            const newMeasureQuantity = oldItem.measureQuantity / count;
+            const newWeight = parseFloat((oldItem.weight / count).toFixed(2))
+
+            console.log(typeof (oldItem.qualitySampleTemplateList), 'ssssss')
+
+            // 遍历新数组设置 qualityResults 默认值
+            this.schemeList.forEach(item => {
+              if (typeof item === 'object' && item !== null) {
+                item.qualityResults = 1; // 设置默认值
+              }
+              delete item.id;
+            });
+
+            console.log(oldItem, 'oldItem')
+            console.log(count, newMeasureQuantity, newWeight)
+            delete oldItem.id;
 
-    handleSelectionChange(val) {
-      console.log(val, '选中数据')
+            if (oldItem.qualitySampleTemplateList == undefined || oldItem.qualitySampleTemplateList == null || oldItem.qualitySampleTemplateList.length == 0) {
+              oldItem.qualitySampleTemplateList = JSON.parse(JSON.stringify(this.schemeList))
+              for (let i = 0; i < count; i++) {
+                ProductSampleList.push({
+                  ...oldItem,
+                  measureQuantity: newMeasureQuantity,
+                  weight: newWeight,
+                  qualitySampleTemplateList: JSON.parse(JSON.stringify(this.schemeList))
+                });
+              }
+              console.log(ProductSampleList, 'ProductSampleList')
+              this.sampleList = ProductSampleList;
+              const pNum = ProductSampleList.reduce((sum, item) => {
+                return sum + Number(item.weight || 0);
+              }, 0);
+              this.form.totalWeight = parseFloat(pNum.toFixed(2));
+            }
+          });
+        }
+      } else {
+        this.sampleList = list;
+      }
     },
-    async open(type) {
+    //输入取样数量
+    changeNumber(val) {
+      if (this.form.qualityMode !== 2) {
+        return;
+      }
+      if (val <= 0) {
+        this.$refs.showPackingListTable.clearSelection();
+        return;
+      }
+
+      if (this.qualityType == '2') {
+        //生产检验的抽检逻辑
+        if (val > this.packingList[0].measureQuantity) {
+          this.$message.warning('取样数量不能大于来源清单的计量数量!');
+          return;
+        }
+
+        const ProductSampleList = [];
+
+        this.packingList.forEach(oldItem => {
+          const count = oldItem.measureQuantity;
+          const newMeasureQuantity = oldItem.measureQuantity / count;
+          const newWeight = parseFloat((oldItem.weight / count).toFixed(2))
+          console.log(count, newMeasureQuantity, newWeight)
+          delete oldItem.id;
+          // 遍历新数组设置 qualityResults 默认值
+          this.schemeList.forEach(item => {
+            if (typeof item === 'object' && item !== null) {
+              item.qualityResults = 1; // 设置默认值
+            }
+            delete item.id;
+          });
+          for (let i = 0; i < val; i++) {
+            ProductSampleList.push({
+              ...oldItem,
+              measureQuantity: newMeasureQuantity,
+              weight: newWeight,
+              qualitySampleTemplateList: JSON.parse(JSON.stringify(this.schemeList))
+            });
+          }
+        });
+        this.sampleList = ProductSampleList;
+        const pNum = ProductSampleList.reduce((sum, item) => {
+          return sum + Number(item.weight || 0);
+        }, 0);
+        this.form.totalWeight = parseFloat(pNum.toFixed(2));
+      } else {
+        if (val > this.packingList.length) {
+          this.$message.warning('取样数量不能大于物料明细总数!');
+          return;
+        }
+        const rows = this.packingList.slice(0, val);
+        rows.forEach((row) => {
+          this.$refs.showPackingListTable.toggleRowSelection(row);
+        });
+      }
+
+    },
+    getNowDate() {
+      let date = new Date(),
+        obj = {
+          year: date.getFullYear(), //获取当前月份(0-11,0代表1月)
+          month: date.getMonth() + 1, //获取当前月份(0-11,0代表1月)
+          strDate: date.getDate(), // 获取当前日(1-31)
+          hour: date.getHours(), //获取当前小时(0 ~ 23)
+          minute: date.getMinutes(), //获取当前分钟(0 ~ 59)
+          second: date.getSeconds() //获取当前秒数(0 ~ 59)
+        };
+      Object.keys(obj).forEach((key) => {
+        if (obj[key] < 10) obj[key] = `0${obj[key]}`;
+      });
+      return obj;
+    },
+    //来源清单勾选事件
+    handleSelectionChange1(selection) {
+      console.log(selection, '勾选列表');
+      this.form.sampleNumber = selection.length;
+      if (this.form.qualityMode === 2) {
+        this.selectedList = selection;
+
+        if (this.schemeList.length == 0) {
+          for (let i = 0; i < selection.length; i++) {
+            console.log(selection[i], 'selection[i]')
+            this.$set(selection[i], 'qualityStatus', 2)
+            // 遍历新数组设置 qualityResults 默认值
+            this.schemeList.forEach(item => {
+              if (typeof item === 'object' && item !== null) {
+                item.qualityResults = 1; // 设置默认值
+              }
+              delete item.id;
+            });
+            this.$set(selection[i], 'qualitySampleTemplateList', JSON.parse(JSON.stringify(this.schemeList)))
+          }
+        }
+        this.sampleList = selection;
+        //赋值取样数量
+        this.form.sampleNumber = selection.length;
+
+      }
+    },
+
+    async open() {
       this.type = this.$route.query.type;
-      this.title = this.type == 'add' ? '新增' : type == 'edit' ? '报工' : '详情';
+      this.qualityType = this.$route.query.qualityType;
+      this.title = this.type == 'add' ? '新增' : this.type == 'edit' ? '报工' : '详情';
 
       if (this.type == 'add') {
         const code = await getCode('quality_work_order_code');
         this.form.code = code;
+      } else {
+        if (this.$route.query.qualityTimeStart != '' || this.$route.query.qualityTimeStart != null || this.$route.query.qualityTimeStart != undefined) {
+          this.qualityTimeStart = this.getNowTime();
+        }
       }
     },
+    getNowTime() {
+      const nowDate = this.getNowDate()
+      return nowDate.year + '-' + nowDate.month + '-' + nowDate.strDate + ' ' + nowDate.hour + ':' + nowDate.minute + ':' + nowDate.second
+    },
+    getNowTimes() {
+      const nowDate = this.getNowDate()
+      return nowDate.year + '-' + nowDate.month + '-' + nowDate.strDate
+    },
     async getDetail() {
+
       getById(this.$route.query.id).then((res) => {
         this.form = res.data;
 
@@ -312,70 +324,53 @@ export default {
 
         if (this.form.groupId) {
           this.$nextTick(() => {
-            if (this.$refs.baseInfoRefs) {
-              this.$refs.baseInfoRefs.getUserList({
-                groupId: this.form.groupId
-              });
-              this.$refs.baseInfoRefs.getTaskList();
-            }
+            this.$refs.baseInfoRefs?.getUserList({
+              groupId: this.form.groupId
+            });
           });
         }
+        if (this.form.produceRoutingId) {
+          this.$nextTick(() => {
+            this.$refs.baseInfoRefs?.getTaskList();
+          })
+        }
+
       });
       await this.queryQualityInventory()
-      await this.queryQualitySamplContent()
       await this.queryQualityTempleContent()
+      await this.queryQualitySamplContent()
+
     },
     async queryQualityInventory() {
       let res = await queryQualityInventory({ qualityWorkerId: this.$route.query.id });
       console.log(res, '清单列表');
       this.packingList = res;
-      this.samplePagination.currentPage = 1;
-      this.samplePagination.total = this.packingList.length;
     },
     async queryQualitySamplContent() {
       const res = await queryQualitySamplContent({ qualityWorkerId: this.$route.query.id })
-
       let addStatus = res.map((item) => {
         item.isValid = true;
-        item.qualityResults = 1;
-        item.qualityStatus = 0;
+        item.disposeTime = item.disposeTime ? item.disposeTime.split(' ')[0] : null;
+        item.sampleDate = item.sampleDate ? item.sampleDate.split(' ')[0] : null;
         return {
           ...item
         }
       })
-      console.log(addStatus, 'addStatus')
-      //样品
-      this.sampleList = addStatus;
-      this.samplePagination.currentPage = 1;
-      this.samplePagination.total = this.sampleList.length;
+      console.log(addStatus, '样品清单12123123')
+
+      if (addStatus.length > 0) {
+        this.sampleList = addStatus;
+      } else {
+        this.getProSamList(this.packingList)
+      }
     },
     async queryQualityTempleContent() {
       const res = await queryQualityTempleContent({ qualityWorkerId: this.$route.query.id })
-      console.log(res, '222');
-      // 方案
+      console.log(res, '质检方案');
       this.schemeList = res;
-      this.schemePagination.currentPage = 1;
-      this.schemePagination.total = this.schemeList.length;
-    },
-    handleClick(tab) {
-      this.activeName = tab.name;
-    },
-    // 样品列表分页方法
-    handleSampleSizeChange(val) {
-      this.samplePagination.pageSize = val;
-      this.samplePagination.currentPage = 1;
-    },
-    handleSampleCurrentChange(val) {
-      this.samplePagination.currentPage = val;
-    },
-    // 质检方案分页方法
-    handleSchemeSizeChange(val) {
-      this.schemePagination.pageSize = val;
-      this.schemePagination.currentPage = 1;
-    },
-    handleSchemeCurrentChange(val) {
-      this.schemePagination.currentPage = val;
     },
+
+
     /* 保存编辑 */
     save() {
       this.$refs.baseInfoRefs.$refs.form1.validate((valid) => {
@@ -383,11 +378,24 @@ export default {
           return false;
         }
         this.loading = true;
-        save(this.form)
+        let URL =
+          this.type == 'add' ? save : this.type == 'edit' ? update : '';
+
+        this.form.qualityTimeStart = new Date(this.qualityTimeStart)
+
+        delete this.form['qualityTimeEnd']
+
+        let params = {
+          ...this.form,
+          sampleList: this.sampleList,
+          planTemplateList: this.schemeList,
+          qualityInventoryList: this.packingList
+        }
+        URL(params)
           .then((msg) => {
             this.loading = false;
             this.$message.success(msg);
-            this.handleClose();
+            this.cancel();
             this.$emit('done');
           })
           .catch((e) => {
@@ -419,22 +427,35 @@ export default {
       this.$router.go(-1);
     },
     handleDetail(index, row, type) {
-      if (row.isStatus == undefined) {
-        row.isStatus = true;
-      }else {
-        row.isStatus = false;
-      }
       if (!this.sampleList[index] || !this.schemeList) {
         return;
       }
+      const selectedData = [];
+      selectedData.push(this.sampleList[index])
 
-      const selectedData = this.sampleList[index];
-      const mergedData = [{
-        ...selectedData,
-        children: [...this.schemeList]
-      }];
-      console.log(index, row, type, mergedData, 'index, row, type, mergedData')
-      this.$refs.detailRef.openDia(index, row, type, mergedData,null);
+      this.$refs.detailRef.openDia(index, row, type, selectedData, null);
+    },
+    inputWeight(row, index) {
+      console.log(row, index, '输入重量')
+
+      const pNum = this.sampleList.reduce((sum, item) => {
+        return sum + Number(item.weight || 0);
+      }, 0);
+      this.form.totalWeight = parseFloat(pNum.toFixed(2));
+
+    },
+    handleDispose(index, row, type) {
+      if (!this.sampleList[index]) {
+        return;
+      }
+
+      this.sampleList[index].sampleDate = this.getNowTimes();
+
+      this.sampleList[index].disposeTime = this.getNowTimes();
+
+      console.log(index, row, type, this.qualityType)
+
+      this.$refs.disposeRef.openDispose(index, row, type, this.qualityType);
     },
     // 报工
     handleReporting(index, row) {
@@ -442,6 +463,20 @@ export default {
         if (!valid) {
           return false;
         }
+
+        for (let i = 0; i < this.sampleList.length; i++) {
+
+          const qualityStatus = this.sampleList[i].qualityStatus;
+
+          if (qualityStatus == '2') {
+            this.$message.error('请完成以下样品质检!')
+            this.loading = false;
+            return
+          }
+        }
+
+        this.form.qualityTimeEnd = new Date(this.getNowTime())
+        this.form.qualityTimeStart = new Date(this.qualityTimeStart)
         let params = {
           ...this.form,
           sampleList: this.sampleList,
@@ -449,12 +484,11 @@ export default {
           qualityInventoryList: this.packingList
         }
         console.log(params, 'params')
-        // return;
         exeReportWork(params)
           .then((msg) => {
             this.loading = false;
             this.$message.success(msg);
-            this.handleClose();
+            this.cancel();
             this.$emit('done');
           })
           .catch((e) => {
@@ -462,13 +496,19 @@ export default {
           });
       })
     },
+    // 处理确认事件
+    handleDisposeConfirm(row, index) {
+      if (index > -1) {
+        this.$set(this.sampleList, index, row)
+      }
+    },
     //确认报工
     handleConfirm(list, index) {
       console.log(list)
 
       // 检查有效性
       for (const item of list) {
-        for (const child of item.children) {
+        for (const child of item.qualitySampleTemplateList) {
 
           console.log(child, 'child')
           if (!child.qualityResultContent || !child.qualityResults) {
@@ -477,52 +517,29 @@ export default {
           }
         }
       }
-
-      // 处理数据
-      const hasInvalidItem = list.some(item =>
-        item.children.some(child => child.qualityResults === 2)
-      );
-      console.log('是否有不合格数据', hasInvalidItem)
-
-      for (const item of list) {
-        const filteredData = item.children.filter((item) =>
-          item.qualityResults == 2
-        );
-        console.log(filteredData, '不合格数据')
-        if (filteredData.length > -1) {
-          this.form.noQualifiedNumber = filteredData.length;
-          this.form.qualifiedNumber = item.children.length - filteredData.length;
-        }
-      }
       console.log(list, 'listlistlistlist')
-
-      const processedList = list.map(item => {
-        item.qualityResults = hasInvalidItem ? 2 : 1;
-        item.qualityStatus = 1;
-        item.qualitySampleTemplateList = item.children;
-        item.isValid = !hasInvalidItem
-        delete item.children;
-        return {
-          ...item,
+      list.forEach((item) => {
+        if (item.qualitySampleTemplateList.some(child => child.qualityResults === 2)) {
+          item.isValid = false;
+          item.qualityResults = 2;
         }
-      });
-
-      this.$set(this.sampleList, index, processedList[0]);
-
-      console.log(this.sampleList, processedList, '222表')
-
-      // this.SampleListbyReportList = processedList;
+        else {
+          item.isValid = true;
+          item.qualityResults = 1;
+        }
+        item.qualityStatus = 1;
+      })
+      if (index != null) {
+        this.$set(this.sampleList, index, list[0]);
+      } else {
+        this.$set(this.sampleList, null, list);
+      }
+      console.log(this.sampleList, '222表')
 
     },
     // 批量质检
-    batchQuality(index, row,type){
-      if (!this.isStatus){
-        this.isStatus = false;
-      }
-      this.sampleList.forEach((item) => {
-        item.children=this.schemeList;
-      });
-      this.$refs.detailRef.openDia(null, null,type, this.sampleList, this.isStatus)
+    batchQuality(index, row, type) {
+      this.$refs.detailRef.openDia(null, null, 'report', this.sampleList, null)
     }
   }
 };

+ 46 - 23
src/views/inspectionWork/index.vue

@@ -2,13 +2,14 @@
   <div class="ele-body">
     <el-card shadow="never">
       <search ref="search" @search="search"></search>
-      <ele-pro-table ref="table" :columns="columns" :datasource="datasource">
+      <ele-pro-table ref="table" :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>
-        </template>
+        <!--        <template v-slot:toolbar>-->
+        <!--          <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)">
@@ -45,13 +46,13 @@
           <el-link type="primary" :underline="false" v-if="row.status == 0" @click="openEdit('edit', 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">
                 删除
               </el-link>
             </template>
-          </el-popconfirm>
+</el-popconfirm> -->
         </template>
       </ele-pro-table>
     </el-card>
@@ -219,6 +220,12 @@ export default {
           slot: 'accessory',
           showOverflowTooltip: true
         },
+        {
+          label: '创建时间',
+          prop: 'createTime',
+          align: 'center',
+          width: 160
+        },
         {
           prop: 'status',
           label: '状态',
@@ -226,14 +233,8 @@ export default {
           width: 80,
           formatter: (row, column, cellValue) => {
             return cellValue == 0 ? '未报工' : cellValue == 1 ? '已报工' : '';
-          }
-        },
-
-        {
-          label: '创建时间',
-          prop: 'createTime',
-          align: 'center',
-          width: 160
+          },
+          fixed: 'right'
         },
         {
           columnKey: 'action',
@@ -267,14 +268,36 @@ export default {
       });
     },
     openEdit(type, row) {
-      // this.$refs.edit.open(type, row);
-      this.$router.push({
-        path: '/inspectionWork/edit',
-        query: {
-          type: type,
-          id: row.id || ''
+      const menusList = this.$store.state.user.menus;
+      let found = false;
+      for (const item of menusList) {
+        if (item.children) {
+          for (const item2 of item.children) {
+            if (item2.path === '/inspectionWork/edit') {
+              found = true;
+              const id = type !== 'add' ? row.id : '';
+              const qualityType = type !== 'add' ? row.qualityType : null;
+              const qualityTimeStart = row.qualityTimeStart || '';
+
+              this.$router.push({
+                path: '/inspectionWork/edit',
+                query: {
+                  type,
+                  id,
+                  qualityType,
+                  qualityTimeStart
+                }
+              });
+              return;
+            }
+          }
         }
-      });
+
+      }
+
+      if (!found) {
+        this.$message.error('请到角色管理配置菜单权限!');
+      }
     },
     downloadFile(file) {
       getFile({ objectName: file.storePath }, file.name);

+ 77 - 0
src/views/samplemanagement/components/baseInfo.vue

@@ -0,0 +1,77 @@
+<template>
+  <el-form ref="form1" :model="form"  label-width="120px">
+    <el-row>
+      <el-col :span="6">
+        <el-form-item label="编码:" prop="sampleCode">
+          <el-input clearable v-model="form.sampleCode" placeholder="请输入" disabled />
+        </el-form-item>
+      </el-col>
+      <el-col :span="6">
+        <el-form-item label="物品名称:" prop=" categoryName">
+          <el-input v-model="form.categoryName" disabled />
+        </el-form-item>
+      </el-col>
+      <el-col :span="6">
+        <el-form-item label="物品编码:" prop=" categoryCode">
+          <el-input v-model="form.categoryCode" 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-row>
+    <el-row>
+      <el-col :span="6">
+        <el-form-item label="规格:" prop=" specification">
+          <el-input v-model="form.specification" disabled />
+        </el-form-item>
+      </el-col>
+      <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="weight">
+          <el-input type="number" v-model="form.weight" disabled/>
+        </el-form-item>
+      </el-col>
+    </el-row>
+  </el-form>
+</template>
+<script>
+//接口
+import { rules } from 'eslint-config-prettier';
+
+export default {
+  components: {
+  },
+  props: {
+    form: {
+      type: Object,
+      default: () => { }
+    },
+    btnType: {
+      type: String,
+      default: ''
+    }
+  },
+  watch: {},
+  data() {
+    return {
+    };
+  },
+  created() {
+  },
+  methods: {
+  }
+};
+</script>
+<style lang="scss" scoped></style>

+ 267 - 0
src/views/samplemanagement/components/edit.vue

@@ -0,0 +1,267 @@
+<!-- 用户编辑弹窗 -->
+<template>
+  <div class="ele-body">
+    <el-card shadow="never">
+      <header-title>
+        <el-button @click="cancel">返回</el-button>
+        <el-button type="primary" @click="submit" :loading="loading">提交</el-button>
+      </header-title>
+      <base-info ref="baseInfoRefs" v-if="baseForm" :form="baseForm" :btnType="btnType"></base-info>
+      <ele-pro-table ref="table" :columns="tableColumns" :datasource="datasource" :pageSize="20"
+        :pageSizes="[20, 30, 40, 50, 100]">
+        <!-- 表头工具栏 -->
+        <template v-slot:toolbar>
+        </template>
+        <template v-slot:categoryCode="{ row }">
+          <el-link type="primary" :underline="false">
+            {{ row.categoryCode }}
+          </el-link>
+        </template>
+        <!-- 操作列 -->
+        <template v-slot:action="{ row }">
+          <el-link type="primary" :underline="false" @click="handleDispose(row, 'dispose')">
+            处置
+          </el-link>
+        </template>
+      </ele-pro-table>
+
+      <!--    <template v-slot:footer>-->
+      <!--      <el-button @click="handleClose">取消</el-button>-->
+      <!--    </template>-->
+      <!--  </ele-modal>-->
+    </el-card>
+    <sampleDisposeDialog ref="disposeRef" @handleDisposeConfirm="handleDisposeConfirm"></sampleDisposeDialog>
+  </div>
+</template>
+
+<script>
+import { getSampleQWorkOrderIdPage, getById, disposeSubmit } from "@/api/samplemanagement";
+import baseInfo from './baseInfo.vue';
+import { finishPageTab } from "@/utils/page-tab-util";
+import sampleDisposeDialog from '@/views/inspectionWork/components/sampleDisposeDialog.vue';
+
+export default {
+  components: {
+    baseInfo,
+    sampleDisposeDialog
+  },
+  data() {
+    const defaultForm = function () {
+      return {
+      };
+    };
+    return {
+      defaultForm,
+      // 表单数据
+      baseForm: { ...defaultForm() },
+      title: null,
+      btnType: null,
+      visible: false,
+      loading: false,
+      qualityWorkOrderId: '',
+      qualitySampleList: [],
+      tableColumns: [
+        { label: '编码', prop: 'categoryCode', width: '150', align: 'center', showOverflowTooltip: true, slot: 'categoryCode' },
+        { label: '名称', prop: 'categoryName', width: '150', align: 'center', showOverflowTooltip: true },
+        { label: '批次号22222', prop: 'batchNo', align: 'center', showOverflowTooltip: true },
+        { label: '发货条码', prop: 'barcodes', align: 'center', showOverflowTooltip: true },
+        { label: '包装编码', prop: 'packageNo', align: 'center', showOverflowTooltip: true },
+        { label: '包装数量', prop: 'packingQuantity', align: 'center', showOverflowTooltip: true },
+        { label: '包装单位', prop: 'packingUnit', align: 'center', showOverflowTooltip: true },
+        { label: '计量数量', prop: 'measureQuantity', align: 'center', showOverflowTooltip: true },
+        { label: '计量单位', prop: 'measureUnit', align: 'center', showOverflowTooltip: true },
+        { label: '物料代号', prop: 'materielDesignation', align: 'center', showOverflowTooltip: true },
+        { label: '客户代号', prop: 'clientCode', align: 'center', showOverflowTooltip: true },
+        { label: '刻码', prop: 'engrave', align: 'center', showOverflowTooltip: true },
+        { label: '仓库', prop: 'warehouseName', align: 'center', showOverflowTooltip: true },
+        { label: '货区', prop: 'areaName', align: 'center', showOverflowTooltip: true },
+        { label: '货架', prop: 'goodsShelfName', align: 'center', showOverflowTooltip: true },
+        { label: '货位', prop: 'goodsAllocationName', align: 'center', showOverflowTooltip: true },
+        { label: '生产日期', prop: 'productionDate', align: 'center', showOverflowTooltip: true },
+        { label: '采购日期', prop: 'purchaseDate', align: 'center', showOverflowTooltip: true },
+        { label: '重量', prop: 'weight', align: 'center', showOverflowTooltip: true, fixed: 'right' },
+        { label: '重量单位', prop: 'weightUnit', align: 'center', showOverflowTooltip: true, fixed: 'right' },
+        {
+          label: '处置状态', prop: 'disposalStatus', align: 'center', showOverflowTooltip: true, fixed: 'right', formatter: (row, column, cellValue) => {
+            return cellValue == 1 ? '返工' : cellValue == 2 ? '返修' : cellValue == 3 ? '报废' : cellValue == 4 ? '降级使用' :
+              cellValue == 5 ? '让步接收' : cellValue == 6 ? '留样' : cellValue == 7 ? '消耗' : cellValue == 8 ? '回用' : '';
+          }
+        },
+        { label: '处置时间', prop: 'disposeTime', align: 'center', showOverflowTooltip: true, fixed: 'right' },
+        {
+          label: '质检状态', prop: 'qualityStatus', align: 'center', showOverflowTooltip: true, fixed: 'right', formatter: (row, column, cellValue) => {
+            return cellValue == 0 ? '未检' : cellValue == 1 ? '已检' : cellValue == 2 ? '待检' : '';
+          }
+        },
+        {
+          label: '质检结果', prop: 'qualityResults', align: 'center', showOverflowTooltip: true, fixed: 'right', formatter: (row, column, cellValue) => {
+            return cellValue == 1 ? '合格' : cellValue == 2 ? '不合格' : '';
+          }
+        },
+        { columnKey: 'action', label: '操作', align: 'center', width: 120, resizable: false, slot: 'action', fixed: 'right' }
+      ],
+      tableData: []
+    };
+  },
+  computed: {
+  },
+  watch: {
+  },
+
+  created() {
+    if (this.$route.query.id) {
+      this.getDetail();
+    }
+  },
+  methods: {
+    async datasource({ page, where, limit }) {
+      where.qualityWorkOrderId = this.$route.query.qualityWorkOrderId;
+      const arr = await getSampleQWorkOrderIdPage({
+        ...where,
+        pageNum: page,
+        size: limit
+      });
+      this.tableData = arr.list;
+      console.log(arr, 'arr')
+      return arr.list;
+    },
+    async getDetail() {
+      this.visible = true;
+      this.qualityWorkOrderId = this.$route.query.qualityWorkOrderId;
+      getById(this.$route.query.id).then(res => {
+        this.btnType = this.$route.query.type;
+        console.log(res, 'res.data');
+        this.baseForm = res.data;
+      });
+    },
+    async open(type, row) {
+      this.btnType = type;
+      this.title = type == 'add' ? '新增' : type == 'edit' ? '编辑' : '详情';
+      if (this.btnType != 'add') {
+        this.qualityWorkOrderId = row.qualityWorkOrderId;
+        this.baseForm = JSON.parse(JSON.stringify(row));
+      }
+      this.visible = true;
+    },
+    resetForm() {
+      this.baseForm = { ...this.defaultForm() };
+    },
+    handleClose() {
+      this.resetForm();
+      // this.resetTable();
+      this.visible = false;
+    },
+    cancel() {
+      finishPageTab();
+      this.$router.go(-1);
+    },
+    async submit() {
+      console.log(this.tableData, '表格');
+
+      for (let i = 0; i < this.tableData.length; i++) {
+        const disposalStatus = this.tableData[i].disposalStatus;
+        const disposeTime = this.tableData[i].disposeTime;
+        const qualityStatus = this.tableData[i].qualityStatus;
+        if (disposalStatus == null || disposeTime == null) {
+          this.$message.error('请完善处置状态和处置时间!')
+          this.loading = false;
+          return
+        }
+        if (qualityStatus == '2') {
+          this.$message.error('请完善质检状态!')
+          this.loading = false;
+          return
+        }
+      }
+      this.loading = true;
+      let pData = {
+        ...form,
+        qualitySampleUpdatePOList: this.tableData,
+      }
+      disposeSubmit(pData)
+        .then((msg) => {
+          this.loading = false;
+          this.$message.success(msg);
+          this.cancel();
+          this.$emit('done');
+        })
+        .catch((e) => {
+          this.loading = false;
+        });
+    },
+    handleDispose(row, type) {
+
+      row.sampleDate = this.getNowTimes();
+
+      row.disposeTime = this.getNowTimes();
+
+      console.log(null, row, type, this.$route.query.qualityType)
+
+      this.$refs.disposeRef.openDispose(null, row, type, this.$route.query.qualityType);
+    },
+    // 处理确认事件
+    handleDisposeConfirm(row, index) {
+      console.log(row, index, '处置确认');
+    },
+    getNowDate() {
+      let date = new Date(),
+        obj = {
+          year: date.getFullYear(), //获取当前月份(0-11,0代表1月)
+          month: date.getMonth() + 1, //获取当前月份(0-11,0代表1月)
+          strDate: date.getDate(), // 获取当前日(1-31)
+          hour: date.getHours(), //获取当前小时(0 ~ 23)
+          minute: date.getMinutes(), //获取当前分钟(0 ~ 59)
+          second: date.getSeconds() //获取当前秒数(0 ~ 59)
+        };
+      Object.keys(obj).forEach((key) => {
+        if (obj[key] < 10) obj[key] = `0${obj[key]}`;
+      });
+      return obj;
+    },
+    getNowTime() {
+      const nowDate = this.getNowDate()
+      return nowDate.year + '-' + nowDate.month + '-' + nowDate.strDate + ' ' + nowDate.hour + ':' + nowDate.minute + ':' + nowDate.second
+    },
+    getNowTimes() {
+      const nowDate = this.getNowDate()
+      return nowDate.year + '-' + nowDate.month + '-' + nowDate.strDate
+    },
+  }
+};
+</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;
+}
+</style>

+ 23 - 6
src/views/samplemanagement/index.vue

@@ -2,7 +2,7 @@
     <div class="ele-body">
         <el-card shadow="never">
             <search ref="search" @search="reload"></search>
-            <ele-pro-table ref="table" :columns="columns" :datasource="datasource">
+            <ele-pro-table ref="table" :columns="columns" :datasource="datasource" :pageSize="20"  :pageSizes="[20, 30, 40, 50, 100]">
                 <!-- 表头工具栏 -->
                 <template v-slot:toolbar>
 
@@ -14,19 +14,22 @@
                     </el-link>
                 </template>
 
+
                 <!-- 操作列 -->
                 <template v-slot:action="{ row }">
-                    <el-link type="primary" :underline="false" @click="processingMethod">
+                    <el-link type="primary" :underline="false" @click="processingMethod('process', row)">
                         处理
                     </el-link>
                 </template>
             </ele-pro-table>
             <!-- <processingInfo ref="processingRefs"></processing> -->
         </el-card>
+<!--      <edit ref="edit" ></edit>-->
     </div>
 </template>
 <script>
 import search from './components/search.vue';
+import edit from './components/edit.vue';
 
 import { getList } from '@/api/samplemanagement';
 
@@ -35,7 +38,8 @@ import dictMixins from '@/mixins/dictMixins';
 export default {
     mixins: [dictMixins],
     components: {
-        search
+      search,
+      edit
     },
     data() {
         return {
@@ -51,8 +55,12 @@ export default {
                 {prop: 'batchNo',label: '批次号',slot: 'batchNo', align: 'center',width: 100,showOverflowTooltip: true},
                 {prop: 'weight',label: '重量',slot: 'weight', align: 'center',width: 100,showOverflowTooltip: true},
                 {prop: 'weightUnit',label: '重量单位',slot: 'weightUnit', align: 'center',width: 100,showOverflowTooltip: true},
-                {prop: 'weightUnit',label: '重量单位',slot: 'weightUnit', align: 'center',width: 100,showOverflowTooltip: true},
                 {prop: 'disposeTime',label: '处置时间',slot: 'disposeTime', align: 'center',width: 180,showOverflowTooltip: true},
+                {prop: 'status',label: '状态',align: 'center',width: 80,fixed: 'right',
+                  formatter: (row, column, cellValue) => {
+                    return cellValue == 1 ? '已处置' : cellValue == 2 ? '未处置' : '';
+                  }
+                },
                 {columnKey: 'action',label: '操作',align: 'center',width: 120,resizable: false,slot: 'action',fixed: 'right'}
             ]
         };
@@ -72,8 +80,17 @@ export default {
         reload(where) {
             this.$refs.table.reload({ page: 1, where });
         },
-        processingMethod() {
-            this.$refs.processingRefs.open()
+        processingMethod(type, row) {
+          this.$router.push({
+            path: '/samplemanagement/components/edit',
+            query: {
+              type: type,
+              qualityWorkOrderId: row.qualityWorkOrderId || '',
+              id: row.id || '',
+              qualityType: row.qualityType || ''
+            }
+          });
+            // this.$refs.edit.open(type, row)
         },
     }
 };