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

refactor(发货单): 移除挂起功能及相关代码

liujt 7 месяцев назад
Родитель
Сommit
adac9f96d8

+ 2 - 2
src/views/saleManage/saleOrder/invoice/components/addInvoiceDialog.vue

@@ -605,7 +605,7 @@ import {
         const data = await getSendSaleOrderrecordDetailSplit(id);
         // this.partbAddress = data.saleOrder[0].partbAddress;
         // this.saleOrderValue = data.saleOrder;
-        if (data.saleOrderList) {
+        if (data.saleOrderList) { 
           this.setData(data.saleOrderList, 'sendInit');
         } else if (data.saleOrder) {
           this.setData([data.saleOrder], 'sendInit');
@@ -930,7 +930,7 @@ import {
             });
           }),
           new Promise((resolve, reject) => {
-            this.$refs.inventoryTableref.validateFormOptimized((valid) => {
+            this.$refs.inventoryTableref.validateForm((valid) => {
               if (!valid) {
                 reject(false);
               } else {

+ 1 - 249
src/views/saleManage/saleOrder/invoice/components/inventoryTable.vue

@@ -293,15 +293,7 @@
         <el-form-item
           :prop="'datasource.' + scope.$index + '.warehouseNum'"
         > 
-          <el-link
-            v-if="scope.row.isSuspend === 1"
-            :underline="false"
-            type="primary"
-            @click="pendingReplaceTable(scope.row, scope.$index)"
-          >
-            {{ scope.row.warehouseNum }}
-          </el-link>
-          <span v-else>{{ scope.row.warehouseNum }}</span>
+          <span>{{ scope.row.warehouseNum }}</span>
         </el-form-item>
       </template>
       <!-- <template v-slot:saleUnit="scope">
@@ -376,27 +368,6 @@
         >
           替代料
         </el-link>
-        
-        <!-- <template v-if="scope.row.batchNo && $hasPermission('eom:saleordersendrecord:pending' ) && needPending == 1">
-          <el-popconfirm
-            v-if="scope.row.isSuspend === 1"
-            class="ele-action"
-            title="确定要取消挂起吗?"
-            @confirm="pending(scope.row, 0)"
-          >
-            <template v-slot:reference>
-              <el-link
-                type="primary"
-                :underline="false"
-              >
-            取消挂起
-          </el-link>
-            </template>
-          </el-popconfirm>
-          <el-link v-else type="primary" :underline="false" @click="pendingReplaceTable(scope.row, scope.$index)">
-                挂起
-          </el-link>
-        </template> -->
       </template>
     </ele-pro-table>
     <productListNew
@@ -421,10 +392,6 @@
       ref="selectStockLedgerDialogRef"
       @changeParent="replaceTable"
     ></selectStockLedgerDialog>
-    <selectStockLedgerDialogPending
-      ref="selectStockLedgerDialogPendingRef"
-      @changeParent="pendingReplaceTableConfirm"
-    ></selectStockLedgerDialogPending>
     <BIZproductList
       ref="BIZproductListRef"
       classType="1"
@@ -460,7 +427,6 @@
   import { parameterGetByCode } from '@/api/main/index.js';
   import { getSummaries } from '@/utils/util.js';
   import { getBatchList } from '@/api/wms';
-  import selectStockLedgerDialogPending from './selectStockLedger/selectStockLedgerDialog.vue';
 
   export default {
     mixins: [dictMixins, getDynamicsColumns, tabMixins],
@@ -497,7 +463,6 @@
       stockLedgerDialog,
       selectStockLedgerDialog,
       BIZproductList,
-      selectStockLedgerDialogPending
     },
     data() {
       const defaultForm = {
@@ -566,18 +531,11 @@
         },
         rules: {},
         columnsVersion: 1,
-        needPending: 0
       };
     },
     created() {
       this.requestDict('产地');
       this.requestDict('生产类型');
-      // 发起时物品清单是否需要挂起 //0否 1是
-      parameterGetByCode({
-        code: 'eom_saleOreder_invoice_pending'
-      }).then((res) => {
-        this.needPending = res.value;
-      });
       parameterGetByCode({
         code: 'eom_saleManage_invoice_warehouseId'
       }).then((res) => {
@@ -994,62 +952,6 @@
       // this.clientEnvironmentId =
     },
     methods: {
-       // 挂起/取消挂起功能
-      async pending(row) {
-        console.log('pending~~~', row)
-          // 取消挂起不需要二次确认
-          this.$set(row, 'isSuspend', 0);
-          this.$forceUpdate();
-          this.current['offsetDetail'] = [];
-          this.current['isSuspend'] = 0;
-          this.$set(this.current, 'warehouseList', await getIdWarehouseList({
-              categoryId: this.current.id
-            }))
-          this.$set(this.current, 'warehouseId', '')
-      },
-      // 通过挂起状态设置行样式
-      tableRowClassName({row}) {
-        // console.log('tableRowClassName', row)
-        if (row.isSuspend == 1) {
-          return 'warning-row';
-        }
-        return '';
-      },
-      // 挂起选择库存
-      pendingReplaceTable(row, index) {
-        // console.log('handleWarehouseClick', row, index)
-        this.current = row;
-        this.$refs.selectStockLedgerDialogPendingRef.open(row, index)
-      },
-      pendingReplaceTableConfirm(list) {
-        console.log('confirm', list)
-        list.forEach((item) => {
-          // item.warehouseList = item.warehouseList.map( i => {
-          //   return {
-          //     warehouseName: i.warehouse_name,
-          //     warehouseId: i.warehouse_id,
-          //   }
-          // })
-          item.warehouseList = [{
-            warehouseName: item.warehouseName,
-            warehouseId: item.warehouseId,
-          }]
-        });
-
-        // if(list[0].warehouseList.length == 1) {
-        //   this.$set(this.current, 'warehouseId', list[0].warehouseId)
-        // }
-    
-        this.$set(this.current, 'warehouseList', list[0].warehouseList)
-        this.$set(this.current, 'warehouseId', list[0].warehouseId)
-        this.$set(this.current, 'warehouseNum', list[0].measureQuantity)
-        this.current['offsetDetail'] = list
-        this.$set(this.current, 'isSuspend', 1)
-        console.log('current', this.current)
-        // this.$emit('pendingReplaceTableConfirm', list);
-        // this.$emit('replaceTableChange', list);
-        // console.log('pendingReplaceTableConfirm', list)
-      },
       getSummaries(param) {
         if (this.clientEnvironmentId != 4) {
           return;
@@ -1940,18 +1842,10 @@
         //开始表单校验
         this.$refs.form.validate((valid, obj) => {
           let is = false;
-          let isBatchNo = false;
-          let isSuspend = false;
           this.form.datasource.forEach((item) => {
             if (Number(item.totalCount) > item.orderTotalCount) {
               is = true;
             }
-            if (item.batchStockId == 999) {
-              isBatchNo = true;
-            }
-            if(item.isSuspend == 1 && (Number(item.totalCount) > item.warehouseNum)) {
-              isSuspend = true;
-            }
           });
           // 退货单退货不校验数量,实物赔偿无法计算
           if (is && this.sourceType != 3) {
@@ -1960,106 +1854,6 @@
               callback(false);
             }
           }
-          if (isBatchNo) {
-            this.$message.warning('你填的批次号与库存批次号不相符,请重新选择批次号出库或删除批次号');
-            callback(false);
-          }
-          if (isSuspend) {
-            this.$message.warning('挂起产品发货数量不能大于库存');
-            callback(false);
-          }
-
-          if (obj) {
-            let messages = Object.keys(obj).map((key) => obj[key][0]);
-            if (messages.length > 0) {
-              this.$message.warning(messages[0].message);
-            }
-          }
-
-          callback(valid);
-        });
-      },
-
-      /**
-       * 优化后的表单校验方法 - 重构版本
-       * 添加了详细的注释、错误消息常量和更清晰的结构
-       */
-      validateFormOptimized(callback) {
-        // 使用常量存储错误消息
-        const ERROR_MESSAGES = {
-          QUANTITY_EXCEEDS_ORDER: '发货数量大于订单总数量',
-          BATCH_NUMBER_INVALID: '你填的批次号与库存批次号不相符,请重新选择批次号出库或删除批次号',
-          SUSPENDED_PRODUCT_OVERSTOCK: '挂起产品发货数量不能大于库存'
-        };
-
-        // 开始表单校验
-        this.$refs.form.validate((valid, obj) => {
-          // 收集所有校验错误
-          const errors = [];
-
-          // 遍历数据源进行业务规则校验
-          this.form.datasource.forEach((item, index) => {
-            const productInfo = this.getProductDisplayInfo(item);
-            
-            // 检查数量是否超过订单数量(退货单除外)
-            if (this.isQuantityExceedsOrder(item)) {
-              if (this.sourceType != 3) { // 非退货单
-                errors.push({ 
-                  type: 'quantity', 
-                  message: `产品[${productInfo.name}]的发货数量${item.totalCount}大于订单总数量${item.orderTotalCount}`, 
-                  stopValidation: this.isTotalCount == 1,
-                  item: item
-                });
-              }
-            }
-
-            // 检查批次号是否正确
-            // if (this.isBatchNumberInvalid(item)) {
-            //   errors.push({ 
-            //     type: 'batch', 
-            //     message: `产品[${productInfo.name}]填写的批次号与库存批次号不相符,请重新选择批次号出库或删除批次号`, 
-            //     stopValidation: true,
-            //     item: item
-            //   });
-            // }
-
-            if (this.isBatchNumberInvalid(item) && item.isSuspend != 1) {
-              // 获取当前批次号和正确的库存批次号信息
-              const currentBatchNumber = item.batchNo || '未填写';
-              // const availableBatches = item.availableBatchNumbers || item.validBatchNumbers || [];
-              // const batchInfo = availableBatches.length > 0 
-              //   ? `当前可选择批次号:${availableBatches.join('、')}` 
-              //   : '当前无有效批次';
-              
-              errors.push({ 
-                type: 'batch', 
-                message: `第${index + 1}条产品[${productInfo.name}]填写的批次号"${currentBatchNumber}"与库存批次号不相符,请重新选择批次号出库或删除批次号`, 
-                stopValidation: true,
-                item: item
-              });
-            }
-
-            // 检查产品库存
-            if (this.isProductOverstock(item)) {
-              errors.push({ 
-                type: 'suspend', 
-                message: `产品[${productInfo.name}]的发货数量${item.totalCount}不能大于库存${item.warehouseNum}`, 
-                stopValidation: true,
-                item: item
-              });
-            }
-          });
-
-          // 如果存在错误,显示第一个错误并根据情况终止校验
-          if (errors.length > 0) {
-            this.$message.warning(errors[0].message);
-            if (errors[0].stopValidation) {
-              callback(false);
-              return;
-            }
-          }
-
-          // 显示表单字段错误(如果存在)
           if (obj) {
             let messages = Object.keys(obj).map((key) => obj[key][0]);
             if (messages.length > 0) {
@@ -2070,48 +1864,6 @@
           callback(valid);
         });
       },
-
-      /**
-       * 检查数量是否超过订单数量
-       * @param {Object} item 数据项
-       * @returns {boolean} 是否超过
-       */
-      isQuantityExceedsOrder(item) {
-        return Number(item.totalCount) > item.orderTotalCount;
-      },
-
-      /**
-       * 检查批次号是否无效
-       * @param {Object} item 数据项
-       * @returns {boolean} 是否无效
-       */
-      isBatchNumberInvalid(item) {
-        return item.batchStockId == 999;
-      },
-
-      /**
-       * 检查挂起产品是否超过库存
-       * @param {Object} item 数据项
-       * @returns {boolean} 是否超过
-       */
-      isProductOverstock(item) {
-        return Number(item.totalCount) > item.warehouseNum;
-      },
-
-      /**
-       * 获取产品显示信息
-       * @param {Object} item 数据项
-       * @returns {Object} 包含产品名称和编码的对象
-       */
-      getProductDisplayInfo(item) {
-        return {
-          name: item.productName || item.name || '未知产品',
-          code: item.productCode || item.code || '',
-          info: item.productName && item.productCode 
-            ? `${item.productName}(${item.productCode})` 
-            : (item.productName || item.name || '未知产品')
-        };
-      }
     }
   };
 </script>