yijing 1 rok temu
rodzic
commit
345c491196

+ 13 - 5
src/views/inspectionPlan/components/baseInfo.vue

@@ -180,9 +180,13 @@
             message: '请输入取样数量',
             trigger: 'blur'
           }">
-            <el-input type="number" v-model="form.sampleNumber" disabled>
-              <template #append>{{ form.sampleMeasureUnit }}</template>
-            </el-input>
+            <div style="display: flex;align-items: center;justify-content: space-between;">
+              <el-input type="number" v-model="form.sampleNumber" disabled style="width: calc(100% - 80px)">
+              </el-input>
+              <DictSelection dictName="计量单位" clearable v-model="form.sampleMeasureUnit" disabled size="mini"
+                style="width: 80px;margin-left: 15px;">
+              </DictSelection>
+            </div>
           </el-form-item>
         </el-col>
         <el-col :span="6">
@@ -299,7 +303,7 @@ export default {
           this.form.qualificationRate = '';
           this.form.totalWeight = '';
           this.form.sampleNumber = '';
-          this.form.sampleMeasureUnit = '';
+          // this.form.sampleMeasureUnit = '';
           this.sourceList = [];
           this.$emit('resetTable');
         }
@@ -323,7 +327,7 @@ export default {
           this.form.qualificationRate = '';
           this.form.totalWeight = '';
           this.form.sampleNumber = '';
-          this.form.sampleMeasureUnit = '';
+          // this.form.sampleMeasureUnit = '';
           this.$emit('resetTable');
         }
       },
@@ -487,6 +491,10 @@ export default {
 
       this.$emit('getCategoryInfo', this.categoryInfo)
     },
+    getsampleMeasureUnit(val) {
+      console.log(val, '单位')
+      this.form.sampleMeasureUnit = val
+    }
 
   }
 };

+ 195 - 194
src/views/inspectionPlan/components/edit.vue

@@ -6,7 +6,6 @@
     <base-info ref="baseInfoRefs" v-if="baseForm" :form="baseForm" :btnType="btnType" @resetTable="resetTable"
       @getList="getList" @changeModel="changeModel" @table2="table2" :packingLists="packingList"
       @getCategoryInfo="getCategoryInfo"></base-info>
-
     <el-row>
       <header-title title="质检内容"></header-title>
 
@@ -15,7 +14,7 @@
           <!-- 来料列表表格 -->
           <ele-pro-table ref="table12" :columns="tableColumns" :datasource="datasource"
             @selection-change="handleSelectionChange" :initLoad="false">
-            <template v-slot:toolbar>
+            <template v-slot:toolbar v-if="this.baseForm.qualityMode == 2">
               <el-dropdown trigger="click" @command="handleSampleNumber">
                 <el-link type="primary" icon="el-icon-plus">取样</el-link>
                 <el-dropdown-menu slot="dropdown">
@@ -23,15 +22,13 @@
                   <el-dropdown-item command="2">取小样</el-dropdown-item>
                 </el-dropdown-menu>
               </el-dropdown>
-
             </template>
-            <template v-slot:toolkit>
-              <template v-if="condition == 2">
+            <template v-slot:toolkit v-if="this.baseForm.qualityMode == 2">
+              <template v-if="baseForm.conditionType == 2">
                 <div style="display: flex;align-items: center;">
-                  <el-input v-model="formData.number" style="width: 120px;" placeholder="请输入" size="mini"
-                    @input="handleSampleSubmit"></el-input>
+                  <el-input v-model="formData.number" style="width: 120px;" placeholder="请输入" size="mini"></el-input>
                   <DictSelection dictName="计量单位" clearable v-model="formData.sampleUnit" size="mini"
-                    style="width: 120px;margin-left: 12px;" @change="handleSampleSubmit">
+                    style="width: 120px;margin-left: 12px;" @change="changeSamUnit">
                   </DictSelection>
                 </div>
               </template>
@@ -85,10 +82,6 @@
       </el-tabs>
     </el-row>
 
-    <!-- <div class="add-product" @click="addProduct" v-if="btnType != 'detail'">
-      <i class="el-icon-circle-plus-outline"></i>
-    </div> -->
-
     <template v-slot:footer>
       <el-button @click="handleClose">取消</el-button>
       <el-button v-if="btnType != 'detail' && btnType != 'issued'" type="primary" :loading="loading"
@@ -111,22 +104,6 @@
         <template v-for="column in tableColumns2">
           <el-table-column :label="column.label" :prop="column.prop" :show-overflow-tooltip="true" :width="column.width"
             :align="column.align">
-            <!-- <template slot-scope="scope">
-              <template v-if="column.prop === 'measureQuantity'">
-                <el-input v-model="scope.row.measureQuantity" type="number"></el-input>
-              </template>
-    <template v-else-if="column.prop === 'measureUnit'">
-                <DictSelection dictName="计量单位" clearable v-model="scope.row.measureUnit">
-                </DictSelection>
-              </template>
-    <template v-else-if="column.prop === 'isUnpack'">
-                <el-switch v-model="scope.row.isUnpack">
-                </el-switch>
-              </template>
-    <template v-else>
-                {{ scope.row[column.prop] }}
-              </template>
-    </template> -->
           </el-table-column>
         </template>
       </el-table>
@@ -144,13 +121,11 @@ import baseInfo from './baseInfo.vue';
 import { getCode } from '@/api/login';
 import { save, update, planIssued } from '@/api/inspectionPlan';
 import {
-  getPurchaseWarehouseGoods,
   getQualityTemplateList,
   getTemplateListByPlanId,
   getSampleListByPlanId,
   getInventoryListByPlanId,
   outInRecordsPage,
-  getByCategoryId,
   getBatchInfoData
 } from '@/api/inspectionPlan/index.js';
 export default {
@@ -194,84 +169,16 @@ export default {
         // planReceiveId: '',
 
         remark: '',
-        accessory: []
+        accessory: [],
+
+        conditionType: null,
       };
     };
     return {
       defaultForm,
       // 表单数据
       baseForm: { ...defaultForm() },
-      tableColumns: [
-        {
-          columnKey: 'selection',
-          type: 'selection',
-          width: 45,
-          align: 'center',
-          selectable: (row, index) => {
-            // 只有当质检方式为抽检(qualityMode=2)时才可选
-            return this.btnType != 'issued' || this.baseForm.qualityMode === 2;
-          },
-        },
-        {
-          columnKey: 'index',
-          label: '序号',
-          type: 'index',
-          width: 55,
-          align: 'center',
-          fixed: 'left'
-        },
-        {
-          label: '编码',
-          prop: 'categoryCode',
-          width: 150,
-          align: 'center',
-          showOverflowTooltip: true
-        },
-        {
-          label: '名称',
-          prop: 'categoryName',
-          width: '150',
-          align: 'center',
-          width: 120,
-          showOverflowTooltip: true
-        },
-        { label: '批次号', prop: 'batchNo', align: 'center' },
-        { label: '发货条码', prop: 'barcodes', align: 'center' },
-        {
-          label: '包装编码', prop: 'packageNo', align: 'center',
-          width: 120,
-          showOverflowTooltip: true
-        },
-        { label: '包装数量', prop: 'packingQuantity', align: 'center' },
-        { label: '包装单位', prop: 'packingUnit', align: 'center' },
-        { label: '计量数量', prop: 'measureQuantity', align: 'center' },
-        { label: '计量单位', prop: 'measureUnit', align: 'center' },
-        { label: '物料代号', prop: 'materielDesignation', align: 'center' },
-        { label: '客户代号', prop: 'clientCode', align: 'center' },
-        { label: '供应商名称', prop: 'supplierName', align: 'center', width: '120' },
-        { label: '供应商代号', prop: 'supplierCode', align: 'center', width: '120' },
-        { label: '刻码', prop: 'engrave', align: 'center' },
-        { label: '重量', prop: 'weight', align: 'center' },
-        { label: '重量单位', prop: 'weightUnit', align: 'center' },
-        {
-          label: '仓库', prop: 'warehouseName', align: 'center',
-          width: 120,
-          showOverflowTooltip: true
-        },
-        { label: '货区', prop: 'areaName', align: 'center' },
-        { label: '货架', prop: 'goodsShelfName', align: 'center' },
-        { label: '货位', prop: 'goodsAllocationName', align: 'center' },
-        {
-          label: '生产日期', prop: 'productionDate', align: 'center',
-          width: 120,
-          showOverflowTooltip: true
-        },
-        {
-          label: '采购日期', prop: 'purchaseDate', align: 'center',
-          width: 120,
-          showOverflowTooltip: true
-        }
-      ],
+
       tableColumns2: [
         {
           label: '编码',
@@ -304,6 +211,7 @@ export default {
         { label: '生产日期', prop: 'productionDate', align: 'center' },
         { label: '采购日期', prop: 'purchaseDate', align: 'center' }
       ],
+
       packingList: [],
 
       sampleList: [],
@@ -340,11 +248,84 @@ export default {
         sampleUnit: '',
         portion: null
       },
-      condition: null,
       isConsumable: '',
     };
   },
   computed: {
+    tableColumns() {
+      let arr = [
+
+        (this.btnType !== 'issued' || this.baseForm.qualityMode === 2)
+          ? {
+            columnKey: 'selection',
+            type: 'selection',
+            width: 45,
+            align: 'center'
+          }
+          : null,
+        {
+          columnKey: 'index',
+          label: '序号',
+          type: 'index',
+          width: 55,
+          align: 'center',
+          fixed: 'left'
+        },
+        {
+          label: '编码',
+          prop: 'categoryCode',
+          width: 150,
+          align: 'center',
+          showOverflowTooltip: true
+        },
+        {
+          label: '名称',
+          prop: 'categoryName',
+          width: '150',
+          align: 'center',
+          width: 120,
+          showOverflowTooltip: true
+        },
+        { label: '批次号', prop: 'batchNo', align: 'center' },
+        { label: '发货条码', prop: 'barcodes', align: 'center' },
+        {
+          label: '包装编码', prop: 'packageNo', align: 'center',
+          width: 120,
+          showOverflowTooltip: true
+        },
+        { label: '包装数量', prop: 'packingQuantity', align: 'center' },
+        { label: '包装单位', prop: 'packingUnit', align: 'center' },
+        { label: '计量数量', prop: 'measureQuantity', align: 'center' },
+        { label: '计量单位', prop: 'measureUnit', align: 'center' },
+        { label: '物料代号', prop: 'materielDesignation', align: 'center' },
+        { label: '客户代号', prop: 'clientCode', align: 'center' },
+        { label: '供应商名称', prop: 'supplierName', align: 'center', width: 120, showOverflowTooltip: true },
+        { label: '供应商代号', prop: 'supplierCode', align: 'center', width: '120' },
+        { label: '刻码', prop: 'engrave', align: 'center' },
+        { label: '重量', prop: 'weight', align: 'center' },
+        { label: '重量单位', prop: 'weightUnit', align: 'center' },
+        {
+          label: '仓库', prop: 'warehouseName', align: 'center',
+          width: 120,
+          showOverflowTooltip: true
+        },
+        { label: '货区', prop: 'areaName', align: 'center' },
+        { label: '货架', prop: 'goodsShelfName', align: 'center' },
+        { label: '货位', prop: 'goodsAllocationName', align: 'center' },
+        {
+          label: '生产日期', prop: 'productionDate', align: 'center',
+          width: 120,
+          showOverflowTooltip: true
+        },
+        {
+          label: '采购日期', prop: 'purchaseDate', align: 'center',
+          width: 120,
+          showOverflowTooltip: true
+        }
+      ]
+      return arr
+
+    },
     // 分页后的样品列表
     paginatedSampleList() {
       const { currentPage, pageSize } = this.samplePagination;
@@ -360,7 +341,6 @@ export default {
       return this.schemeList.slice(start, end);
     }
   },
-
   created() { },
   methods: {
     async datasource({ page, limit, where }) {
@@ -373,78 +353,78 @@ export default {
         this.isCheck = false
       }
       this.packingList = res.list;
-      console.log(this.packingList, '===========================================this.packingList')
+
       return res.list;
     },
     // 切换质检内容
     handleClick(tab) {
       this.activeName = tab.name;
     },
-
     async open(type, row) {
       this.visible = true;
-
       this.activeName = '1';
       this.btnType = type;
-      this.title =
-        type == 'add'
-          ? '新增'
-          : type == 'edit'
-            ? '编辑'
-            : type == 'issued'
-              ? '下发'
-              : '详情';
-      if (this.btnType != 'add') {
-        row.accessory = row.accessory || [];
-        console.log('row====', row);
-
-        this.baseForm.groupId = row.groupId;
-        this.baseForm.qualityMode = row.qualityMode;
-        this.baseForm = JSON.parse(JSON.stringify(row));
-
-        //根据类型获取计划来源
-        if (this.baseForm.type) {
-          this.$nextTick(() => {
-            if (this.$refs.baseInfoRefs) {
-              this.$refs.baseInfoRefs.typeChange(this.baseForm.type);
-            }
-          });
-        }
-        // 获取人员
-        if (this.baseForm.groupId) {
-          this.$nextTick(() => {
-            if (this.$refs.baseInfoRefs) {
-              this.$refs.baseInfoRefs.getUserList({
-                groupId: this.baseForm.groupId
-              });
-            }
-          });
-        }
-        // 如果是编辑或者详情,则查询物料清单、质检方案和样品列表
-        if (row.id) {
-          this.rowIds = row.id;
-
-          //操作行点击时查询清单
-          // await this.getInventoryList();
-          await this.reload({ planId: row.id });
+      this.title = type == 'add' ? '新增' : type == 'edit' ? '编辑' : type == 'issued' ? '下发' : '详情';
 
+      if (this.btnType === 'add') {
+        const code = await getCode('qms_plan_code');
+        this.baseForm.code = code;
+        return;
+      }
+      await this.handleEditOrDetail(row);
+    },
+    async handleEditOrDetail(row) {
+      console.log('row====', row);
+      row.accessory = row.accessory || [];
 
-          //操作行点击时查询样品
-          await this.getSampleList(row?.id);
-          //操作行点击时查询质检
-          await this.getTemplateList(row?.id);
+      this.baseForm = {
+        ...JSON.parse(JSON.stringify(row)),
+        groupId: row.groupId,
+        qualityMode: row.qualityMode
+      };
 
+      this.$nextTick(() => {
+        if (this.$refs.baseInfoRefs) {
+          // 获取人员
+          if (this.baseForm.groupId) {
+            this.$refs.baseInfoRefs.getUserList({
+              groupId: this.baseForm.groupId
+            });
+          }
+          //根据类型获取计划来源
+          if (this.baseForm.type) {
+            this.$refs.baseInfoRefs.typeChange(this.baseForm.type);
+          }
           if (this.baseForm.productId) {
-            this.$nextTick(() => {
-              this.$refs.baseInfoRefs.getProductDetails(this.baseForm.productId)
-            })
+            this.$refs.baseInfoRefs.getProductDetails(this.baseForm.productId);
           }
         }
-      } else {
-        const code = await getCode('qms_plan_code');
-        this.baseForm.code = code;
-      }
+      });
 
+      // 如果是编辑或者详情,则查询物料清单、质检方案和样品列表
+      if (row.id) {
+        this.rowIds = row.id;
+
+        //操作行点击时查询清单
+        // await this.getInventoryList();
+        await this.reload({ planId: row.id });
+        
+        this.$nextTick(() => {
+          if (this.$refs.table12) {
+            this.$refs.table12.doLayout()
+          }
+        })
+        if (this.baseForm.type == 1) {
+          this.sampleList = this.$refs.table12.getData()
+        } else {
+          this.sampleList = []
+        }
+
+        //操作行点击时查询样品
+        await this.getSampleList(row.id);
+        //操作行点击时查询质检
+        await this.getTemplateList(row.id);
+      }
     },
     reload(where) {
       this.$nextTick(() => {
@@ -480,6 +460,9 @@ export default {
       this.getQualityTemplate(productCode);
     },
     async getGoodsList(receiveNo, productCode, ids, productCategoryId, productCategoryName, categoryid, batchNo, supplierName, supplierMark) {
+      this.$refs.table12.setData([])
+
+
       let res;
       const res1 = await outInRecordsPage({
         sourceBizNo: receiveNo,
@@ -530,34 +513,41 @@ export default {
             ...m
           };
         });
+        console.log(_arr1, '1234567890')
+
         this.packingList = _arr1;
-        this.pagination.total = this.packingList.length;
+        this.$refs.table12.setData(_arr1);//赋值
+
 
-        if (this.packingList.length > 1) {
-          this.baseForm.productNumber = this.packingList.length;
+        const _arr2 = this.$refs.table12.getData();
+        if (_arr2.length > 1) {
+          this.baseForm.productNumber = _arr2.length;
         } else {
-          this.baseForm.productNumber = this.packingList[0].measureQuantity;
+          this.baseForm.productNumber = _arr2[0].measureQuantity;
         }
+        //处理样品清单
         this.aaa();
       } else {
-        this.packingList = [];
+        this.$refs.table12.setData([]);
       }
     },
     aaa() {
       console.log('aaa')
+      let packingList = this.$refs.table12.getData();
+
       if (this.baseForm.qualityMode == 1) {
         this.sampleList = [];
         if (this.baseForm.isUnpack != null && this.baseForm.isUnpack != undefined && this.baseForm.isUnpack != '') {
           if (this.baseForm.isUnpack == 2) {
             const num = Number(this.baseForm.productNumber || 0);
             if (num) {
-              this.getUnpackSamList(this.packingList, num)
+              this.getUnpackSamList(packingList, num)
             }
           } else if (this.baseForm.isUnpack == 1) {
             if (this.baseForm.qualityMode == 1) {
-              this.sampleList = this.packingList;
+              this.sampleList = packingList;
               this.samplePagination.currentPage = 1;
-              this.samplePagination.total = this.packingList.length;
+              this.samplePagination.total = packingList.length;
             } else {
               this.sampleList = [];
             }
@@ -566,13 +556,13 @@ export default {
           if (!this.isCheck) {
             const num = Number(this.baseForm.productNumber || 0);
             if (num) {
-              this.getUnpackSamList(this.packingList, num)
+              this.getUnpackSamList(packingList, num)
             }
           } else {
             if (this.baseForm.qualityMode == 1) {
-              this.sampleList = this.packingList;
+              this.sampleList = packingList;
               this.samplePagination.currentPage = 1;
-              this.samplePagination.total = this.packingList.length;
+              this.samplePagination.total = packingList.length;
             } else {
               this.sampleList = [];
             }
@@ -656,6 +646,11 @@ export default {
       this.formData.portion = selection.length;
 
       this.baseForm.sampleNumber = selection.length;
+      //如果取小样
+      if (this.baseForm.conditionType == 2) {
+        // this.baseForm.sampleMeasureUnit = this.$refs.table12.getData()[0].measureUnit
+        this.formData.sampleUnit = this.$refs.table12.getData()[0].measureUnit
+      }
     },
 
     // 样品列表分页方法
@@ -693,7 +688,7 @@ export default {
       });
     },
     table1() {
-      this.packingList = [];
+      this.$refs.table12.setData([])
       this.schemeList = [];
     },
     table2() {
@@ -723,7 +718,7 @@ export default {
         }
         let params = {
           ...this.baseForm,
-          qualityInventoryList: this.packingList,
+          qualityInventoryList: this.$refs.table12.getData(),
           sampleList: this.sampleList,
           planTemplateList: this.schemeList,
         };
@@ -767,7 +762,7 @@ export default {
 
         let params = {
           ...this.baseForm,
-          qualityInventoryList: this.packingList,
+          qualityInventoryList: this.$refs.table12.getData(),
           sampleList: this.sampleList,
           planTemplateList: this.schemeList,
         };
@@ -793,46 +788,48 @@ export default {
       this.loading = false;
     },
     handleSampleNumber(val) {
-
-      this.condition = val;
-
-      if (this.selectedList.length == 0) {
-        this.$message.warning('请先选择样品!');
-        return
-      } else {
-        if (val == 1) {
-          this.sampleList = this.selectedList
-          this.activeName = '2'
-          this.$message.success('取样成功!');
-          return;
+      console.log(val, 'val')
+      this.baseForm.conditionType = val;
+      //清空样品清单列表
+      this.sampleList = []
+      //取整样
+      if (val == 1) {
+        this.sampleList = this.$refs.table12.getData()
+        this.formData.portion = this.$refs.table12.getData().length
+        this.$refs.table12.toggleAllSelection();
+        this.activeName = '2'
+        this.$message.success('取样成功!');
+      } else if (val == 2) {
+        this.$refs.table12.clearSelection();
+        //小样
+        if (this.selectedList.length == 0) {
+          this.$message.warning('请先选择样品!');
         } else {
           if (this.formData.number == null && this.formData.sampleUnit == '') {
             this.$message.warning('请先选择取样的数量和单位!');
-            return
           }
         }
       }
-      this.$refs.table.clearSelection();
     },
     handleInput() {
       if (this.formData.portion == null || this.formData.portion == '' || this.formData.portion == 0) {
-        debugger;
         this.$message.warning('生成取样数量不能为空!');
+        this.$refs.table12.clearSelection();
         return;
       }
-
+      let packingList = this.$refs.table12.getData()
       console.log(this.isCheck, 'this.isCheck')
       if (this.isCheck) {
-        if (this.formData.portion > this.packingList.length) {
+        if (this.formData.portion > packingList.length) {
           this.$message.warning('取样数量不能大于来源清单数量!');
           return;
         }
-        const rows = this.packingList.slice(0, this.formData.portion);
+        const rows = packingList.slice(0, this.formData.portion);
         rows.forEach((row) => {
-          this.$refs.table.toggleRowSelection(row);
+          this.$refs.table12.toggleRowSelection(row);
         });
       } else {
-        if (this.formData.portion > this.packingList[0].measureQuantity) {
+        if (this.formData.portion > packingList[0].measureQuantity) {
           this.$message.warning('取样数量不能大于计量数量!');
           return;
         }
@@ -862,6 +859,10 @@ export default {
     getCategoryInfo(val) {
       this.isConsumable = val.isConsumable;
     },
+    changeSamUnit(val) {
+      console.log(val, 'dddd')
+      this.$refs.baseInfoRefs.getsampleMeasureUnit(val)
+    },
     handleSampleSubmit() {
 
       if (this.formData.portion == null || this.formData.portion == 0) {
@@ -869,7 +870,7 @@ export default {
         return;
       }
       this.baseForm.sampleMeasureUnit = this.formData.sampleUnit
-      if (this.condition == 1) {
+      if (this.baseForm.conditionType == 1) {
         this.sampleList = this.selectedList
       } else {
         let measureQ = this.formData.number;