Explorar o código

Merge branch 'dev' into test

mlchen hai 1 día
pai
achega
2f7eb8c270

A diferenza do arquivo foi suprimida porque é demasiado grande
+ 514 - 124
src/BIZComponents/inventoryTable.vue


+ 27 - 10
src/BIZComponents/inventoryTableDetails.vue

@@ -132,7 +132,11 @@
   import timeDialog from '@/components/timeDialog/index.vue';
   import tabMixins from '@/mixins/tableColumnsMixin';
   import { levelList, pricingWayList, quoteTypeOp } from '@/enum/dict.js';
-  import { getInventoryTotalAPI } from '@/api/wms';
+  import {
+    getInventoryTotalAPI,
+    buildInventoryTotalQueryKey,
+    matchInventoryTotal
+  } from '@/api/wms';
   import { getSummaries } from '@/utils/util.js';
   import { getAllQuantity } from '@/BIZComponents/setProduct.js';
 
@@ -540,10 +544,18 @@
           },
           {
             minWidth: 160,
-            prop: 'availableCountBase',
+            prop: 'stockCountBase',
             label: '库存数量',
             showOverflowTooltip: true,
             align: 'center',
+            isNone: !this.isWms
+          },
+          {
+            minWidth: 160,
+            prop: 'availableCountBase',
+            label: this.isWms ? '可用数量' : '库存数量',
+            showOverflowTooltip: true,
+            align: 'center',
           },
           {
             minWidth: 140,
@@ -1077,22 +1089,27 @@
           }
           if (this.isWms) {
             let codeList = this.form.datasource
-            .filter((item) => item.productCode)
-            .map((item) => item.batchNo ? [item.productCode, item.batchNo].join(',') : item.productCode);
+              .filter((item) => item.productCode)
+              .map((item) => buildInventoryTotalQueryKey(item));
             //获取仓库库存
             let inventoryTotalList = await getInventoryTotalAPI(codeList);
             this.form.datasource
               .filter((item) => item.productCode)
-              .forEach((item, index) => {
+              .forEach((item) => {
                 let find =
-                  inventoryTotalList.find(
-                                    (key) => (key.code + ',' + key.batchNo == item.productCode+','+item.batchNo)
-                                  ) || {};
+                  inventoryTotalList.find((key) =>
+                    matchInventoryTotal(item, key)
+                  ) || {};
                 this.form.datasource;
                 this.$set(
-                  this.form.datasource[index],
+                  item,
+                  'stockCountBase',
+                  find.stockCountBase == null ? 0 : find.stockCountBase
+                );
+                this.$set(
+                  item,
                   'availableCountBase',
-                  find.availableCountBase
+                  find.availableCountBase == null ? 0 : find.availableCountBase
                 );
               });
           }

+ 20 - 12
src/BIZComponents/product-list.vue

@@ -221,6 +221,11 @@
         type: Boolean,
         default: false
       },
+      // 是否回传库存数量
+      showStockCount: {
+        type: Boolean,
+        default: false
+      },
       /*已选择的产品*/
       data: {
         type: Array,
@@ -260,7 +265,7 @@
       showSaleCount: {
         type: Boolean,
         default: false
-      },
+      }
     },
 
     data() {
@@ -432,10 +437,9 @@
             align: 'center',
             showOverflowTooltip: true,
             formatter: (row, column) => {
-              return row.extField?.layBy ? this.getDictValue(
-                '贮藏',
-                row.extField?.layBy
-              ) : '';
+              return row.extField?.layBy
+                ? this.getDictValue('贮藏', row.extField?.layBy)
+                : '';
             }
           },
           {
@@ -444,12 +448,9 @@
             align: 'center',
             showOverflowTooltip: true,
             formatter: (row, column) => {
-              let unit = ''
-              if(row.warrantyPeriodUnit) {
-                unit = this.getDictValue(
-                  '保质期单位',
-                  row.warrantyPeriodUnit
-                );
+              let unit = '';
+              if (row.warrantyPeriodUnit) {
+                unit = this.getDictValue('保质期单位', row.warrantyPeriodUnit);
               }
               return row.warrantyPeriod ? row.warrantyPeriod + unit : '';
             }
@@ -626,7 +627,10 @@
               // item['supplierCode'] = supplierList[item.categoryId][0].code;
               // item['supplierId'] = supplierList[item.categoryId][0].id;
               // item['supplierName'] = supplierList[item.categoryId][0].name;
-              item['supplierName'] = supplierList[item.categoryId].find((i) => i.id == item.supplierId)?.name || '';
+              item['supplierName'] =
+                supplierList[item.categoryId].find(
+                  (i) => i.id == item.supplierId
+                )?.name || '';
             }
           });
         }
@@ -687,6 +691,10 @@
           list.forEach((item) => {
             let find =
               inventoryTotalList.find((key) => key.code == item.code) || {};
+            if (this.showStockCount) {
+              item.stockCountBase = find.stockCountBase;
+              item.lockQuantity = find.lockQuantity;
+            }
             item.availableCountBase = find.availableCountBase;
           });
         }

+ 52 - 24
src/BIZComponents/selectStockLedger/selectStockLedgerDialog.vue

@@ -76,7 +76,9 @@
     </el-card>
 
     <div slot="footer">
-      <el-button v-if="!isView" type="primary" size="small" @click="selected">选择</el-button>
+      <el-button v-if="!isView" type="primary" size="small" @click="selected"
+        >选择</el-button
+      >
       <el-button size="small" @click="handleClose">关闭</el-button>
     </div>
   </ele-modal>
@@ -112,6 +114,11 @@
         type: Boolean,
         default: false
       },
+      // 是否按库存余额和锁库数量展示可用数量
+      showStockCount: {
+        type: Boolean,
+        default: false
+      },
       cacheKeyUrl: {
         type: String,
         default: 'eom-sales-selectStockLedgerDialog-202605131603'
@@ -131,7 +138,7 @@
         curNodeData: {},
         selection: [],
         treeData: [],
-        dimension:'2',
+        dimension: '2',
         defaultProps: {
           children: 'children',
           label: 'name'
@@ -166,12 +173,14 @@
             align: 'center',
             reserveSelection: true,
             selectable: (row) => {
+              if (this.showStockCount) {
+                return this.getAvailableStockCount(row) != 0;
+              }
               const measureQuantity = parseFloat(row.measureQuantity) || 0;
               const lockQuantity = parseFloat(row.lockQuantity) || 0;
               const available = measureQuantity - lockQuantity;
               return available != 0;
             }
-
           };
         }
 
@@ -215,16 +224,17 @@
             label: '牌号',
             showOverflowTooltip: true
           },
-          this.dimension=="2"?
-          {
-            prop: 'batchNo',
-            label: '批次号',
-            align: 'center',
-            showOverflowTooltip: true
-          }:{
-              width:1
-          },
-          this.dimension == "2"
+          this.dimension == '2'
+            ? {
+                prop: 'batchNo',
+                label: '批次号',
+                align: 'center',
+                showOverflowTooltip: true
+              }
+            : {
+                width: 1
+              },
+          this.dimension == '2'
             ? {
                 prop: 'systemBatchNo',
                 label: '系统内部批次号',
@@ -281,7 +291,11 @@
             label: '库存',
             showOverflowTooltip: true,
             align: 'center',
-            minWidth: 90
+            minWidth: 90,
+            formatter: (row) =>
+              this.showStockCount
+                ? this.getStockCount(row)
+                : row.measureQuantity
           },
           {
             prop: 'lockQuantity',
@@ -297,6 +311,9 @@
             align: 'center',
             minWidth: 90,
             formatter: (row) => {
+              if (this.showStockCount) {
+                return this.getAvailableStockCount(row);
+              }
               // 使用toFixed处理浮点数精度问题,保留4位小数
               const measureQuantity = parseFloat(row.measureQuantity) || 0;
               const lockQuantity = parseFloat(row.lockQuantity) || 0;
@@ -371,7 +388,7 @@
 
       /* 表格数据源 */
       async datasource({ page, limit, where, order }) {
-        this.dimension = where.dimension||'2';
+        this.dimension = where.dimension || '2';
         let api = where.dimension == '1' ? getOutindetailtwoList : getBatchList;
 
         const data = await api({
@@ -381,7 +398,7 @@
           size: limit
         });
         this.getTabColumns();
-        return data
+        return data;
       },
 
       /* 刷新表格 */
@@ -421,16 +438,27 @@
         this.current = row;
         this.radio = row.id;
       },
-      // 限制订单数量不超过可用数量(measureQuantity - lockQuantity)
+      // 新接口返回 stockCountBase,旧接口使用 measureQuantity 表示当前库存
+      getStockCount(row) {
+        if (row.stockCountBase !== undefined && row.stockCountBase !== null) {
+          return Number(row.stockCountBase);
+        }
+        return Number(row.measureQuantity || 0);
+      },
+      getAvailableStockCount(row) {
+        const available =
+          this.getStockCount(row) - Number(row.lockQuantity || 0);
+        return Number(available.toFixed(4));
+      },
+      // 限制订单数量不超过当前可用数量
       handleSaleCountInput(row) {
-        const measureQuantity = parseFloat(row.measureQuantity) || 0;
-        const lockQuantity = parseFloat(row.lockQuantity) || 0;
-        const available = measureQuantity - lockQuantity;
+        const available = this.showStockCount
+          ? this.getAvailableStockCount(row)
+          : (parseFloat(row.measureQuantity) || 0) -
+            (parseFloat(row.lockQuantity) || 0);
         const val = parseFloat(row.saleCount);
         if (!isNaN(val) && val > available) {
-          this.$message.warning(
-            `订单数量不能超过可用数量(${available})`
-          );
+          this.$message.warning(`订单数量不能超过可用数量(${available})`);
           this.$set(row, 'saleCount', available);
         }
       },
@@ -511,7 +539,7 @@
           item.productCategoryName = '';
           item.productBrand = item.brandNum;
           item.provenance = item.provenance || [];
-          if(this.showSaleCount){
+          if (this.showSaleCount) {
             item.saleCount = item.saleCount;
           }
           item['packageDispositionList'] = packingSpecification

+ 21 - 4
src/api/saleManage/saleorder.js

@@ -45,18 +45,36 @@ export async function getIdWarehouseList(params) {
   return Promise.reject(new Error(res.data.message));
 }
 /**
- * 查询库存可用数
+ * 查询库存数量和可用数
  */
-export async function getWarehouseOutStock(params) {
+export async function getWarehouseOutStockInfo(params) {
   const res = await request.get(`/wms/stocktwo/getWarehouseOutStock`, {
     params
   });
   if (res.data.code == 0) {
-    return res.data.data;
+    const data = res.data.data;
+    if (data && typeof data === 'object') {
+      return {
+        stockCountBase: data.stockCountBase || 0,
+        availableCountBase: data.availableCountBase || 0
+      };
+    }
+    return {
+      stockCountBase: data || 0,
+      availableCountBase: data || 0
+    };
   }
   return Promise.reject(new Error(res.data.message));
 }
 
+/**
+ * 兼容原有页面,仅返回可用数量
+ */
+export async function getWarehouseOutStock(params) {
+  const data = await getWarehouseOutStockInfo(params);
+  return data.availableCountBase;
+}
+
 /**
  * 获取信息详情
  */
@@ -218,4 +236,3 @@ export async function batchCompleted(data) {
   }
   return Promise.reject(new Error(res.data.message));
 }
-

+ 60 - 1
src/api/wms/index.js

@@ -14,6 +14,65 @@ export async function getInventoryTotalAPI(data) {
   return Promise.reject(new Error(res.data.message));
 }
 
+/**
+ * 生成库存统计查询键;传入字符串时保持旧格式原样透传。
+ */
+export function buildInventoryTotalQueryKey(value, batchNo, systemBatchNo) {
+  if (typeof value === 'string') {
+    return value;
+  }
+  const item = value || {};
+  const code = item.productCode || item.code || '';
+  const resolvedBatchNo = batchNo !== undefined ? batchNo : item.batchNo;
+  const resolvedSystemBatchNo =
+    systemBatchNo !== undefined ? systemBatchNo : item.systemBatchNo;
+  if (!code) {
+    return '';
+  }
+  const keyParts = [code];
+  if (
+    resolvedBatchNo !== undefined &&
+    resolvedBatchNo !== null &&
+    resolvedBatchNo !== ''
+  ) {
+    keyParts.push(resolvedBatchNo);
+    if (
+      resolvedSystemBatchNo !== undefined &&
+      resolvedSystemBatchNo !== null &&
+      resolvedSystemBatchNo !== ''
+    ) {
+      keyParts.push(resolvedSystemBatchNo);
+    }
+  }
+  return keyParts.join(',');
+}
+
+/**
+ * 按物品编码、业务批次和系统批次匹配库存统计结果。
+ */
+export function matchInventoryTotal(item, result) {
+  if (!item || !result) {
+    return false;
+  }
+  const code = item.productCode || item.code;
+  if (!code || String(result.code) !== String(code)) {
+    return false;
+  }
+  const itemBatchNo = item.batchNo == null ? '' : String(item.batchNo);
+  const resultBatchNo = result.batchNo == null ? '' : String(result.batchNo);
+  if (resultBatchNo !== itemBatchNo) {
+    return false;
+  }
+  const itemSystemBatchNo =
+    item.systemBatchNo == null ? '' : String(item.systemBatchNo);
+  const resultSystemBatchNo =
+    result.systemBatchNo == null ? '' : String(result.systemBatchNo);
+  if (resultSystemBatchNo !== itemSystemBatchNo) {
+    return false;
+  }
+  return true;
+}
+
 export async function getSubPage(data) {
   const res = await request.get('/main/categoryLevel/getSubPage', {
     params: data
@@ -278,4 +337,4 @@ export async function getCategoryPackageDisposition (data){
       return res.data.data;
     }
     return Promise.reject(new Error(res.data.message));
-  }
+  }

+ 2 - 1
src/views/saleManage/saleOrder/components/addDialogNew.vue

@@ -576,6 +576,7 @@
         :showSummary="true"
         :defTaxRate="13"
         :showSortLine="true"
+        :showStockCount="true"
         :showSaleCount="form.needProduce == 0"
       ></inventoryTable>
       <headerTitle
@@ -701,7 +702,7 @@
 
       <el-button @click="cancel">返回</el-button>
     </div>
-    <selectStockLedgerDialog ref="selectStockLedgerDialogRef" :isSupplier="true" :isView="true" :cacheKeyUrl="cacheKeyUrl+'saleOrderss'"></selectStockLedgerDialog>
+    <selectStockLedgerDialog ref="selectStockLedgerDialogRef" :isSupplier="true" :isView="true" :show-stock-count="true" :cacheKeyUrl="cacheKeyUrl+'saleOrderss'"></selectStockLedgerDialog>
     <quotationList
       ref="quotationListRef"
       @changeParent="changeQuotationList"

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

@@ -32,6 +32,16 @@
             />
           </el-form-item>
         </el-col>
+        <el-col :span="12">
+          <el-form-item label="订单类型">
+            <el-input
+              :value="formatNeedProduce(saleOrderNeedProduce)"
+              disabled
+            />
+          </el-form-item>
+        </el-col>
+      </el-row>
+      <el-row :gutter="12">
         <el-col :span="12">
           <el-form-item label="受托收货单">
             <el-input
@@ -43,8 +53,6 @@
             />
           </el-form-item>
         </el-col>
-      </el-row>
-      <el-row :gutter="12">
         <el-col :span="12">
           <el-form-item label="退货单">
             <el-input
@@ -56,6 +64,8 @@
             />
           </el-form-item>
         </el-col>
+      </el-row>
+      <el-row :gutter="12">
         <el-col :span="12">
           <el-form-item label="客户名称" prop="contactName">
             <el-input v-model="form.contactName" disabled></el-input>
@@ -387,6 +397,7 @@
         isSpecialeSubmit: false,
         fullscreen: false,
         saleOrderValue: {},
+        saleOrderNeedProduce: '',
         detailData: {},
         payWayOptions: [],
         delDetailIds: [],
@@ -465,6 +476,18 @@
       stockShow() {
         this.$refs.selectStockLedgerDialogRef.open('', -1);
       },
+      formatNeedProduce(value) {
+        if (value === null || value === undefined || value === '') {
+          return '';
+        }
+        return value == 1
+          ? '有客户生产性订单'
+          : value == 2
+          ? '无客户生产性订单'
+          : value == 4
+          ? '不定向订单'
+          : '库存式订单';
+      },
       //销售发货数量是否限制不能大于采购总数//0否 1是
       parameterGetByCode() {
         parameterGetByCode({
@@ -476,6 +499,7 @@
 
       //选择订单回调
       changeOrder(obj) {
+        this.saleOrderNeedProduce = obj?.[0]?.needProduce ?? '';
         this.form = Object.assign({}, this.form, {
           productionRequirements: obj
             .map((item) => item.productionRequirements)
@@ -527,6 +551,7 @@
         };
 
         this.loading = false;
+        this.saleOrderNeedProduce = data.needProduce ?? '';
         this.saleOrderValue = JSON.parse(JSON.stringify(data));
         this.oldProductList = JSON.parse(JSON.stringify(data.productList));
         this.partbAddress = data.partbAddress;
@@ -656,6 +681,11 @@
 
         this.loading = true;
         const data = await getSendSaleOrderrecordDetailSplit(id, 1);
+        this.saleOrderNeedProduce =
+          data.needProduce ??
+          data.saleOrderList?.[0]?.needProduce ??
+          data.saleOrder?.needProduce ??
+          '';
         // this.partbAddress = data.saleOrder[0].partbAddress;
         // this.saleOrderValue = data.saleOrder;
         if (data.saleOrderList) {
@@ -672,7 +702,10 @@
             });
             data.carNo = data.carNo ? data.carNo.split(',') : [];
             this.form = data;
-            this.form.needProduce = data?.saleOrderList[0]?.needProduce;
+            this.form.needProduce =
+              data.needProduce ??
+              data.saleOrderList?.[0]?.needProduce ??
+              data.saleOrder?.needProduce;
             this.form.deliveryTypeId = data.deliveryTypeId + '';
             this.$refs.inventoryTableref &&
               this.$refs.inventoryTableref.putTableValue(
@@ -712,8 +745,10 @@
             pricingWay: '',
             sourceNo: '',
             sourceId: '',
-            sourceType: ''
+            sourceType: '',
+            needProduce: ''
           });
+          this.saleOrderNeedProduce = '';
           this.$refs.inventoryTableref &&
             this.$refs.inventoryTableref.putTableValue([], true);
           return;
@@ -732,6 +767,8 @@
         // });
         const data = await getReturnSaleOrderrecordDetail(row.id);
         if (data) {
+          this.saleOrderNeedProduce =
+            data.needProduce ?? data.saleOrder?.needProduce ?? '';
           this.$nextTick(() => {
             let {
               carNo,
@@ -800,7 +837,9 @@
               payAmount,
               projectName,
               projectId,
-              projectSn: projectCode
+              projectSn: projectCode,
+              needProduce:
+                data.needProduce ?? data.saleOrder?.needProduce ?? ''
             });
 
             productList.forEach((item, index) => {
@@ -835,8 +874,10 @@
             pricingWay: '',
             sourceNo: '',
             sourceId: '',
-            sourceType: ''
+            sourceType: '',
+            needProduce: ''
           });
+          this.saleOrderNeedProduce = '';
           this.$refs.inventoryTableref &&
             this.$refs.inventoryTableref.putTableValue([], true);
           return;
@@ -919,8 +960,10 @@
             productionRequirements: '',
             sourceType: '',
             sourceNo: '',
-            sourceId: ''
+            sourceId: '',
+            needProduce: ''
           });
+          this.saleOrderNeedProduce = '';
           this.$refs.inventoryTableref &&
             this.$refs.inventoryTableref.putTableValue([]);
           return;
@@ -934,6 +977,7 @@
       //打开新增编辑弹框
       async open(type, row, orderId) {
         this.title = type === 'add' ? '新增发货单' : '修改';
+        this.saleOrderNeedProduce = '';
         this.parameterGetByCode();
         this.visible = true;
         this.carList = await carBookPageListAPI({ pageNum: 1, size: 100 });
@@ -963,6 +1007,7 @@
         this.title = '新增发货单';
         this.visible = true;
         this.isUpdate = false;
+        this.saleOrderNeedProduce = '';
         this.getInfo(row);
       },
       totalCountChange(num) {
@@ -1045,6 +1090,7 @@
             carList: this.$refs.stowageTableRef.getTableValue(),
             trakNoteList: this.$refs.taskInfoTableRef.getTableValue()
           });
+          delete commitData.needProduce;
           commitData.carNo = commitData.carNo.toString();
 
           let is = false;
@@ -1178,6 +1224,7 @@
           this.$refs['formRef'] && this.$refs['formRef'].resetFields();
           this.$store.commit('order/clearUserData');
           this.form = copyObj(this.formDef);
+          this.saleOrderNeedProduce = '';
           this.visible = false;
         });
       }

+ 15 - 0
src/views/saleManage/saleOrder/invoice/components/detailDialog.vue

@@ -82,6 +82,9 @@
             <el-form-item prop="orderNo" label="订单编码:">
               <el-input v-model="form.orderNo" disabled></el-input>
             </el-form-item>
+            <el-form-item label="订单类型:">
+              <el-input :value="formatNeedProduce(form.needProduce)" disabled></el-input>
+            </el-form-item>
             <el-form-item prop="replied" label="是否回执:">
               <el-select v-model="form.replied" disabled style="width: 100%">
                 <el-option label="是" :value="1"></el-option>
@@ -255,6 +258,18 @@
 
     },
     methods: {
+      formatNeedProduce(value) {
+        if (value === null || value === undefined || value === '') {
+          return '';
+        }
+        return value == 1
+          ? '有客户生产性订单'
+          : value == 2
+          ? '无客户生产性订单'
+          : value == 4
+          ? '不定向订单'
+          : '库存式订单';
+      },
       async open(row) {
         this.activeComp = 'main';
         this.visible = true;

+ 84 - 71
src/views/saleManage/saleOrder/invoice/components/inventoryTable.vue

@@ -234,6 +234,14 @@
             </el-select>
           </el-form-item>
         </template>
+        <template v-slot:availableCountBase="{ row }">
+          <span>{{
+            row.availableCountBase === undefined ||
+            row.availableCountBase === null
+              ? 0
+              : row.availableCountBase
+          }}</span>
+        </template>
 
         <template v-slot:singlePrice="scope">
           <el-form-item
@@ -346,11 +354,6 @@
             </el-input>
           </el-form-item>
         </template>
-        <template v-slot:warehouseNum="scope">
-          <el-form-item :prop="'datasource.' + scope.$index + '.warehouseNum'">
-            <span>{{ scope.row.warehouseNum }}</span>
-          </el-form-item>
-        </template>
         <template v-slot:cuttingLength="{ row, $index }">
           <el-form-item :prop="'datasource.' + $index + '.cuttingLength'">
             <el-input v-model="row.cuttingLength" placeholder="请输入">
@@ -469,7 +472,7 @@
   import dictMixins from '@/mixins/dictMixins';
   import productListNew from './product-listNew.vue';
   import {
-    getWarehouseOutStock,
+    getWarehouseOutStockInfo,
     getIdWarehouseList
   } from '@/api/saleManage/saleorder';
 
@@ -543,7 +546,7 @@
         // warehouseName:'',
       };
       return {
-        cacheKeyUrl: 'eos-saleManage-invoice-inventoryTable-202605131602',
+        cacheKeyUrl: 'eos-saleManage-invoice-inventoryTable-2026082501',
         current: {},
         childrenColumns: [
           {
@@ -768,10 +771,16 @@
           },
           {
             width: 100,
-            prop: 'warehouseNum',
-            label: '库存',
-            align: 'center',
-            slot: 'warehouseNum'
+            prop: 'stockCountBase',
+            label: '库存数量',
+            align: 'center'
+          },
+          {
+            width: 100,
+            prop: 'availableCountBase',
+            label: '可用数量',
+            slot: 'availableCountBase',
+            align: 'center'
           },
 
           // {
@@ -1109,6 +1118,44 @@
         this.selection = [];
       },
 
+      // 将接口返回的库存数量和可用数量同步到当前物品清单行。
+      setWarehouseOutStock(index, stockInfo) {
+        const stockCountBase = stockInfo?.stockCountBase || 0;
+        const availableCountBase = stockInfo?.availableCountBase || 0;
+        this.$set(
+          this.form.datasource[index],
+          'stockCountBase',
+          stockCountBase
+        );
+        this.$set(
+          this.form.datasource[index],
+          'availableCountBase',
+          availableCountBase
+        );
+        // 保留原字段,兼容已有发货数量校验和提交逻辑。
+        this.$set(
+          this.form.datasource[index],
+          'warehouseNum',
+          availableCountBase
+        );
+      },
+
+      async refreshWarehouseOutStock(index, row) {
+        if (!row.warehouseId) {
+          this.setWarehouseOutStock(index, {});
+          return;
+        }
+        const stockInfo = await getWarehouseOutStockInfo({
+          warehouseId: row.warehouseId,
+          code: row.productCode,
+          batchNo: row.batchNo,
+          systemBatchNo: row.systemBatchNo,
+          colorKey: row.colorKey,
+          modelType: row.modelType
+        });
+        this.setWarehouseOutStock(index, stockInfo);
+      },
+
       async warehouseChange(index, row, isReset = false) {
         console.log('warehouseChange', index, row.warehouseId, isReset);
         const data = row.warehouseList.find(
@@ -1128,20 +1175,6 @@
           data?.warehouseCode || 0
         );
 
-        const warehouseOutStock = await getWarehouseOutStock({
-          warehouseId: data?.warehouseId || '',
-          code: row.productCode,
-          batchNo: row.batchNo,
-          systemBatchNo: row.systemBatchNo,
-          colorKey: row.colorKey,
-          modelType: row.modelType
-        });
-        this.$set(
-          this.form.datasource[index],
-          'warehouseNum',
-          warehouseOutStock || 0
-        );
-
         const tempBatchNoList = await getBatchList({
           warehouseId: data?.warehouseId || '',
           categoryCode: row.productCode,
@@ -1159,11 +1192,13 @@
           this.$set(this.form.datasource[index], 'batchNo', '');
           this.$set(this.form.datasource[index], 'systemBatchNo', '');
         }
+        await this.refreshWarehouseOutStock(index, this.form.datasource[index]);
       },
 
       //批次号选择
       async batchNoChange(index, row) {
         if (!row.batchStockId) {
+          this.$set(this.form.datasource[index], 'batchStockId', '');
           this.$set(this.form.datasource[index], 'batchNo', '');
           this.$set(this.form.datasource[index], 'systemBatchNo', '');
           // this.$set(this.form.datasource[index], 'warehouseNum', '');
@@ -1180,19 +1215,9 @@
             );
           }
 
-          this.$set(
-            this.form.datasource[index],
-            'warehouseNum',
-            row.warehouseId
-              ? await getWarehouseOutStock({
-                  warehouseId: row.warehouseId,
-                  code: row.productCode,
-                  batchNo: row.batchNo,
-                  systemBatchNo: row.systemBatchNo,
-                  colorKey: row.colorKey,
-                  modelType: row.modelType
-                })
-              : ''
+          await this.refreshWarehouseOutStock(
+            index,
+            this.form.datasource[index]
           );
 
           return;
@@ -1201,13 +1226,13 @@
           (item) => item.id == row.batchStockId
         );
         this.$set(this.form.datasource[index], 'batchNo', data.batchNo);
-        this.$set(this.form.datasource[index], 'systemBatchNo', data.systemBatchNo);
-
         this.$set(
           this.form.datasource[index],
-          'warehouseNum',
-          data.measureQuantity || 0
+          'systemBatchNo',
+          data.systemBatchNo
         );
+
+        await this.refreshWarehouseOutStock(index, this.form.datasource[index]);
       },
       //改变数量
       changeCount(row, index, isBlockCount = true, weightType) {
@@ -1502,6 +1527,12 @@
         let comitDatasource = this.form.datasource;
         if (comitDatasource.length === 0) return [];
         comitDatasource.forEach(async (v) => {
+          // 清空批次时同步清理批次库存 ID,避免更新接口残留旧批次。
+          if (!v.batchNo) {
+            v.batchNo = '';
+            v.systemBatchNo = '';
+            v.batchStockId = '';
+          }
           if (v.modelKey) {
             v.modelKey = v.modelKey;
           }
@@ -1615,17 +1646,9 @@
                 })
               );
               if (item.warehouseId) {
-                this.$set(
-                  this.form.datasource[index],
-                  'warehouseNum',
-                  await getWarehouseOutStock({
-                    warehouseId: item.warehouseId,
-                    code: item.productCode,
-                    batchNo: item.batchNo,
-                    systemBatchNo: item.systemBatchNo,
-                    colorKey: item.colorKey,
-                    modelType: item.modelType
-                  })
+                await this.refreshWarehouseOutStock(
+                  index,
+                  this.form.datasource[index]
                 );
               } else if (this.form.datasource[index]?.warehouseList?.length) {
                 this.$set(
@@ -1673,20 +1696,7 @@
             'warehouseList',
             tempWarehouse
           );
-          if (item.warehouseId) {
-            this.$set(
-              this.form.datasource[index],
-              'warehouseNum',
-              await getWarehouseOutStock({
-                warehouseId: item.warehouseId,
-                code: item.productCode,
-                batchNo: item.batchNo,
-                systemBatchNo: item.systemBatchNo,
-                colorKey: item.colorKey,
-                modelType: item.modelType
-              })
-            );
-          } else {
+          if (!item.warehouseId) {
             if (this.form.datasource[index]?.warehouseList?.length) {
               this.$set(
                 this.form.datasource[index],
@@ -1728,10 +1738,9 @@
               'systemBatchNo',
               batchNoObj.systemBatchNo || ''
             );
-            this.$set(
-              this.form.datasource[index],
-              'warehouseNum',
-              batchNoObj.measureQuantity || 0
+            await this.refreshWarehouseOutStock(
+              index,
+              this.form.datasource[index]
             );
           } else {
             //不存在
@@ -1744,6 +1753,8 @@
             // 设置为不存在的批次ID
             this.$set(this.form.datasource[index], 'batchStockId', 999);
             this.$set(this.form.datasource[index], 'warehouseNum', '');
+            this.$set(this.form.datasource[index], 'stockCountBase', '');
+            this.$set(this.form.datasource[index], 'availableCountBase', '');
             this.$set(this.form.datasource[index], 'warehouseId', '');
           }
 
@@ -1769,6 +1780,8 @@
             );
             this.$set(this.form.datasource[index], 'batchStockId', 999);
             this.$set(this.form.datasource[index], 'warehouseNum', '');
+            this.$set(this.form.datasource[index], 'stockCountBase', '');
+            this.$set(this.form.datasource[index], 'availableCountBase', '');
           }
         }
       },

+ 23 - 0
src/views/saleManage/saleOrder/invoice/index.vue

@@ -429,6 +429,29 @@
             showOverflowTooltip: true,
             minWidth: 200
           },
+          {
+            prop: 'needProduce',
+            label: '订单类型',
+            align: 'center',
+            showOverflowTooltip: true,
+            minWidth: 150,
+            formatter: (_row, _column, cellValue) => {
+              if (
+                cellValue === null ||
+                cellValue === undefined ||
+                cellValue === ''
+              ) {
+                return '';
+              }
+              return cellValue == 1
+                ? '有客户生产性订单'
+                : cellValue == 2
+                ? '无客户生产性订单'
+                : cellValue == 4
+                ? '不定向订单'
+                : '库存式订单';
+            }
+          },
           {
             prop: 'productNames',
             label: '产品名称',

Algúns arquivos non se mostraron porque demasiados arquivos cambiaron neste cambio