Просмотр исходного кода

已添加的物品禁止再次勾选;出库数量可输入小数点后两位;去掉根据委外发货编码判断委外的是否质检状态;

yijing 1 год назад
Родитель
Сommit
4678a79fb9

+ 81 - 10
src/views/bpm/outgoingManagement/components/AssetsDialog.vue

@@ -6,7 +6,7 @@
           <el-form-item label="列表维度:" prop="dimension">
             <template>
               <el-select style="width: 100%" @change="changeDimensionHandler" v-model="dimension" placeholder="请选择">
-                <el-option label="物料维度" value="4"> </el-option>
+                <!-- <el-option label="物料维度" value="4"> </el-option> -->
                 <el-option label="包装维度" value="3"> </el-option>
                 <el-option label="批次维度" value="2"> </el-option>
                 <el-option label="物品维度" value="1"> </el-option>
@@ -67,8 +67,21 @@
       <el-main>
         <el-table ref="multipleTable" :data="tableData" tooltip-effect="dark" height="50vh" border row-key="id"
           style="width: 100%" :header-cell-style="{ background: '#F0F3F3', border: 'none' }"
-          @selection-change="handleSelectionChange">
-          <el-table-column type="selection" :reserve-selection="true" width="55" align="center" fixed="left">
+          @selection-change="handleSelectionChange" :key="productLists.length">
+
+          <el-table-column v-if="dimension == 1" type="selection" :reserve-selection="true" width="55" align="center"
+            fixed="left" :selectable="(row) => {
+              return !this.productLists.some(
+                (it) => it.categoryId == row.categoryId
+              );
+            }">
+          </el-table-column>
+          <el-table-column v-else-if="dimension != 1" type="selection" :reserve-selection="true" width="55"
+            align="center" fixed="left" :selectable="(row) => {
+              return !this.productLists.some(
+                (it) => it.id == row.id
+              );
+            }">
           </el-table-column>
           <el-table-column label="序号" type="index" width="50" fixed="left">
           </el-table-column>
@@ -138,10 +151,11 @@
 import storageApi from '@/api/warehouseManagement';
 import AssetTree from '../../stockManagement/components/assetTree.vue';
 import { getDetailById, quantityDelivery } from '@/api/classifyManage';
+import { forEach } from 'lodash';
 export default {
   components: { AssetTree },
   props: {
-    treeIds: { type: Array, default: () => [] }
+    treeIds: { type: Array, default: () => [] },
   },
   data() {
     return {
@@ -187,7 +201,8 @@ export default {
       selectionList: [],
       materialType: '',
       warehouseList: [],
-      dimension: '3'
+      dimension: '1',
+      productLists: []
     };
   },
   created() {
@@ -196,7 +211,8 @@ export default {
   watch: {
     tableData(val) {
       this.doLayout();
-    }
+    },
+
   },
   methods: {
     errorVerify(row) {
@@ -228,7 +244,22 @@ export default {
     // 出库数量限制
     handleInput(row, value) {
       if (row.outboundNum <= row.measureQuantity) {
-        return (row.outboundNum = value.replace(/^(0+)|[^\d]+/g, ''));
+        // return (row.outboundNum = value.replace(/^(0+)|[^\d]+/g, ''));
+
+        // 过滤掉非数字和小数点的字符
+        const filteredValue = value.replace(/[^0-9.]/g, '');
+        // 限制只能有一个小数点
+        const singleDotValue = filteredValue.replace(/(\..*)\./g, '$1');
+
+        let finalValue = '';
+        const dotIndex = singleDotValue.indexOf('.');
+        if (dotIndex !== -1) {
+          // 截取小数点后最多两位
+          finalValue = singleDotValue.slice(0, dotIndex + 3);
+        } else {
+          finalValue = singleDotValue;
+        }
+        return row.outboundNum = finalValue;
       } else {
         row.outboundNum = row.measureQuantity;
       }
@@ -241,6 +272,7 @@ export default {
       this.changeDimension(e);
     },
     async changeDimension(e) {
+      console.log('changeDimension')
       this.dimension = e;
       if (this.dimension == 1) {
         // 物品维度
@@ -265,13 +297,52 @@ export default {
         }
         this.tableData = data.list;
         this.total = data.count;
+
+      }
+      this.updateProductOutboundNums(this.tableData)
+    },
+    updateProductOutboundNums(list) {
+      console.log(this.productLists, 'this.productLists')
+
+      if (this.dimension == 1) {
+        //物品层
+        for (let i = 0; i < list.length; i++) {
+          const item = list[i];
+          const matchedProduct = this.productLists.find(product => {
+            const isMatch = product.categoryId === item.categoryId;
+            return isMatch;
+          });
+
+          if (matchedProduct) {
+            this.$set(item, 'outboundNum', matchedProduct.measureQuantity);
+          } else {
+            console.warn('No match for item.id:', item.id);
+          }
+        }
+
+      } else {
+        for (let i = 0; i < list.length; i++) {
+          const item = list[i];
+          const matchedProduct = this.productLists.find(product => {
+            const isMatch = product.id === item.id;
+            return isMatch;
+          });
+
+          if (matchedProduct) {
+            this.$set(item, 'outboundNum', matchedProduct.measureQuantity);
+          } else {
+            console.warn('No match for item.id:', item.id);
+          }
+        }
       }
+
     },
-    open() {
+    open(val) {
+      this.productLists = val || [];
       this.visible = true;
       this.$nextTick(() => {
-        this.$refs.treeList.getTreeData().then((data) => {
-          this.handleNodeClick(data);
+        this.$refs.treeList.getTreeData().then(async (data) => {
+          await this.handleNodeClick(data);
         });
       });
     },

+ 58 - 30
src/views/bpm/outgoingManagement/outbound.vue

@@ -120,33 +120,6 @@
                 :prop="item.prop" :show-overflow-tooltip="item.showOverflowTooltip"></el-table-column>
               <el-table-column label="批次号" prop="batchNo" align="center" :show-overflow-tooltip="true">
               </el-table-column>
-              <!-- <el-table-column
-                label="最小包装单元"
-                align="center"
-                width="120"
-                prop="minPackingQuantity"
-              >
-                <template slot-scope="{ row, $index }">
-                  {{ row.minPackingQuantity }} {{ row.measureUnit }} /{{
-                    row.packingUnit
-                  }}
-                </template>
-</el-table-column>
-
-<el-table-column label="包装数量" prop="packingQuantity" align="center">
-  <template slot-scope="{ row, $index }">
-                  {{ row.packingQuantity }} {{ row.packingUnit }}
-                </template>
-</el-table-column>
-<el-table-column label="计量数量" prop="measureQuantity" width="100" align="center">
-</el-table-column>
-<el-table-column label="计量单位" prop="measureUnit" align="center">
-  <template slot-scope="{ row, $index }">
-                  <template>
-                    {{ row.measureUnit }}
-                  </template>
-  </template>
-</el-table-column> -->
               <el-table-column label="包装数量" prop="packingQuantity" width="80"></el-table-column>
               <el-table-column label="单位" prop="packingUnit"></el-table-column>
               <el-table-column label="计量数量" prop="measureQuantity" :show-overflow-tooltip="true"></el-table-column>
@@ -178,6 +151,12 @@
                 :show-overflow-tooltip="true"></el-table-column>
               <el-table-column prop="supplierCode" label="供应商代号" min-width="200"
                 :show-overflow-tooltip="true"></el-table-column>
+              <el-table-column label="操作" width="120" align="center">
+                <template slot="header" slot-scope="scope"> 操作 </template>
+                <template slot-scope="{ row, $index }">
+                  <el-link type="danger" @click="deleteProductList(row, $index)">删除</el-link>
+                </template>
+              </el-table-column>
             </el-table>
           </div>
           <header-title class="mt20" title="包装清单"></header-title>
@@ -264,7 +243,8 @@
         </div>
       </div>
     </el-card>
-    <AssetsDialog ref="assetsDialogRef" :treeIds="formData.extInfo?.assetType" @detailData="detailData" />
+    <AssetsDialog ref="assetsDialogRef" :treeIds="formData.extInfo?.assetType" @detailData="detailData"
+      :productLists="this.productList" />
   </div>
 </template>
 
@@ -564,6 +544,10 @@ export default {
       this.materielFetchData();
 
       this.formData.outInDetailList = this.productList;
+
+      console.log(this.productList, 'this.productList')
+      console.log(this.packingList, 'this.packingList')
+
     },
     async getReturnStorage() {
       return new Promise((resolve) => {
@@ -678,10 +662,17 @@ export default {
       // this.formData.extInfo.createUserName = this.user.info.name;
       // this.formData.createUserId = this.user.info.userId;
 
-      // 物品类型
       this.formData.extInfo.assetType = Array.from(
         new Set(this.form.categoryLevelTopId.split(','))
       );
+
+      //委外出库
+      if (this.bizType == 7 && this.form.productList) {
+        const categoryids = this.form.productList.map(p => p.productCategoryId)
+        console.log(categoryids, '委外出库的物品id')
+        this.formData.extInfo.assetType = categoryids
+      }
+
       // 出库类型
       this.formData.bizType = this.bizType;
       // 添加单据来源
@@ -855,13 +846,50 @@ export default {
       if (!this.formData.bizType && this.formData.bizType !== 0)
         return this.$message.error('请选择出库场景');
 
-      this.$refs.assetsDialogRef.open();
+      this.$refs.assetsDialogRef.open(this.productList);
     },
     handleBizSceneChange() {
       if (this.formData.extInfo.assetType == 7) {
         this.formData.extInfo.sourceBizNo = '';
       }
       this.formData.sourceBizNo = '';
+    },
+    deleteProductList(row, index) {
+      // 1. 获取当前物料的所有包装列表
+      const targetPackages = row.outInDetailRecordRequestList || []
+      const packageIds = new Set(targetPackages.map(p => p.id))
+
+      console.log('targetPackages', targetPackages)
+      console.log('packageIds包装的id', packageIds)
+
+
+      // 从packingList中移除相关包装
+      this.packingList = this.packingList.filter(p =>
+        !packageIds.has(p.id) &&
+        p.categoryCode !== row.categoryCode
+      )
+      console.log('包装列表', this.packingList)
+
+      // 从materialList中移除关联物料
+      const materialIds = new Set()
+      targetPackages.forEach(packageItem => {
+        packageItem.materialDetailList.forEach(material => {
+          materialIds.add(material.id)
+        })
+      })
+      this.materialList = this.materialList.filter(m =>
+        !materialIds.has(m.id) &&
+        m.categoryCode !== row.categoryCode
+      )
+
+      this.productList.splice(index, 1)
+
+      // this.$nextTick(() => {
+      //   this.$refs.productListTable?.doLayout()
+      //   this.$refs.showPackingListTable?.doLayout()
+      //   this.$refs.multipleTable?.doLayout()
+      // })
+
     }
   },
   watch: {

+ 26 - 17
src/views/bpm/stockManagement/storage.vue

@@ -2664,15 +2664,20 @@ export default {
         let measureQuantity = row.measureQuantity / row.packingQuantity;
         let status = null;
         //通过委外发货单编码判断是不是委外  委外收货 质检状态显示已质检
-        if (this.form.outsourceSendCode != '') {
-          status = 2;
+        // if (this.form.outsourceSendCode != '') {
+        //   status = 2;
+        // } else {
+        //   // 0未检 1待检 2 已检
+        //   if (row.qualityControl == 1) {
+        //     status = 0;
+        //   } else {
+        //     status = 2;
+        //   }
+        // }
+        if (row.qualityControl == 1) {
+          status = 0;
         } else {
-          // 0未检 1待检 2 已检
-          if (row.qualityControl == 1) {
-            status = 0;
-          } else {
-            status = 2;
-          }
+          status = 2;
         }
 
         for (let index = 0; index < packingCodeList.length; index++) {
@@ -2835,17 +2840,21 @@ export default {
           console.log(filterArr[0], 'filterArr[0]')
           let status = null;
           //通过委外发货单编码判断是不是委外  委外收货 质检状态显示已质检
-          if (this.form.outsourceSendCode != '') {
-            status = 2;
+          // if (this.form.outsourceSendCode != '') {
+          //   status = 2;
+          // } else {
+          //   // 0未检 1待检 2 已检
+          //   if (row.qualityControl == 1) {
+          //     status = 0;
+          //   } else {
+          //     status = 2;
+          //   }
+          // }
+          if (row.qualityControl == 1) {
+            status = 0;
           } else {
-            // 0未检 1待检 2 已检
-            if (row.qualityControl == 1) {
-              status = 0;
-            } else {
-              status = 2;
-            }
+            status = 2;
           }
-
           let item = {
             index: row.index + '-' + index, // 包装索引
             warehouseId: row.warehouseId, // 仓库id