فهرست منبع

fix: 修复发货单 物品清单 列不显示的问题

tzx 2 روز پیش
والد
کامیت
06ed194b3c

+ 10 - 5
src/BIZComponents/selectStockLedger/selectStockLedgerDialog.vue

@@ -558,10 +558,15 @@
         }
         let idList = list.map((item) => item.categoryId);
 
-        // 获取包装规格
-        let packingSpecification = await getCategoryPackageDisposition({
-          categoryIds: idList
-        });
+        // 获取包装规格(接口异常时置空,不阻断选择流程)
+        let packingSpecification = [];
+        try {
+          packingSpecification = await getCategoryPackageDisposition({
+            categoryIds: idList
+          });
+        } catch (e) {
+          console.error('获取包装规格失败:', e);
+        }
 
         list.forEach((item, index) => {
           item.productName = item.categoryName;
@@ -572,7 +577,7 @@
           if (this.showSaleCount) {
             item.saleCount = item.saleCount;
           }
-          item['packageDispositionList'] = packingSpecification
+          item['packageDispositionList'] = (packingSpecification || [])
             .filter(
               (ite) => item.categoryId == ite.categoryId && ite.conversionUnit
             )

+ 25 - 132
src/views/saleManage/saleOrder/invoice/components/inventoryTable.vue

@@ -8,6 +8,7 @@
         :datasource="form.datasource"
         class="time-form"
         @columns-change="handleColumnChange"
+        @header-dragend="handleHeaderDragend"
         :cache-key="cacheKeyUrl"
         height="350"
         full-height="calc(100vh - 76px)"
@@ -93,8 +94,8 @@
               @change="batchNoChange(scope.$index, scope.row)"
             >
               <el-option
-                v-for="item in scope.row.batchNoList || []"
-                :key="item.id"
+                v-for="(item, optIndex) in scope.row.batchNoList || []"
+                :key="`${item.id}_${optIndex}`"
                 :label="item.batchNo"
                 :value="item.id"
               >
@@ -112,27 +113,6 @@
           <el-form-item
             :prop="'datasource.' + scope.$index + '.blockCount'"
             :rules="[{ required: true, message: '请输入', trigger: 'blur' }]"
-    <ele-pro-table
-      ref="table"
-      :needPage="false"
-      :columns="columns"
-      :datasource="form.datasource"
-      class="time-form"
-      :selection.sync="selection"
-      @columns-change="handleColumnChange"
-      @header-dragend="handleHeaderDragend"
-      :cache-key="cacheKeyUrl"
-    >
-      <!-- 表头工具栏 -->
-      <template v-slot:toolbar>
-        <div class="headbox">
-          <el-button
-            v-if="isShowAdd && needProduce != 4"
-            size="small"
-            type="primary"
-            icon="el-icon-plus"
-            class="ele-btn-icon"
-            @click="handlAdd"
           >
             <el-input
               v-model="scope.row.blockCount"
@@ -178,42 +158,6 @@
                 trigger: 'blur'
               }
             ]"
-            新增
-          </el-button>
-          <el-button
-            size="small"
-            type="danger"
-            icon="el-icon-delete"
-            class="ele-btn-icon"
-            :disabled="!selection.length"
-            @click="batchRemove"
-          >
-            批量删除
-          </el-button>
-        </div>
-      </template>
-      <template v-slot:technicalDrawings="{ row, $index }">
-        <el-form-item :prop="'datasource.' + $index + '.technicalDrawings'">
-          <fileMain v-model="row.technicalDrawings" type="view"></fileMain>
-        </el-form-item>
-      </template>
-      <template v-slot:remark="{ row, $index }">
-        <el-form-item :prop="'datasource.' + $index + '.remark'">
-          <el-input
-            clearable
-            v-model="row.remark"
-            type="textarea"
-            placeholder="请输入"
-          />
-        </el-form-item>
-      </template>
-      <template v-slot:stockLedger="scope">
-        <el-form-item>
-          <el-popover
-            @hide="() => (selection = [])"
-            placement="right"
-            width="60%"
-            trigger="hover"
           >
             <el-select
               v-if="needProduce == 4 && orderNoList.length > 1"
@@ -282,8 +226,8 @@
               @change="warehouseChange(scope.$index, scope.row, true)"
             >
               <el-option
-                v-for="item in scope.row.warehouseList"
-                :key="item.warehouseId"
+                v-for="(item, optIndex) in scope.row.warehouseList"
+                :key="`${item.warehouseId}_${optIndex}`"
                 :label="item.warehouseName"
                 :value="item.warehouseId"
               >
@@ -469,31 +413,25 @@
         </template>
         <!-- 操作列 -->
         <template v-slot:action="scope">
-          <div>
-            <el-popconfirm
-              class="ele-action"
-              title="确定要删除吗?"
-              @confirm="remove(scope.$index)"
-            >
-              <template v-slot:reference>
-                <el-link
-                  type="danger"
-                  :underline="false"
-                  icon="el-icon-delete"
-                >
-                  删除
-                </el-link>
-              </template>
-            </el-popconfirm>
-            <el-link
-              type="primary"
-              :underline="false"
-              icon="el-icon-edit"
-              @click="selectStockLedgerDialogOpen(scope.row)"
-            >
-              替代料
-            </el-link>
-          </div>
+          <el-popconfirm
+            class="ele-action"
+            title="确定要删除吗?"
+            @confirm="remove(scope.$index)"
+          >
+            <template v-slot:reference>
+              <el-link type="danger" :underline="false" icon="el-icon-delete">
+                删除
+              </el-link>
+            </template>
+          </el-popconfirm>
+          <el-link
+            type="primary"
+            :underline="false"
+            icon="el-icon-edit"
+            @click="selectStockLedgerDialogOpen(scope.row)"
+          >
+            替代料
+          </el-link>
         </template>
       </ele-pro-table>
     </div>
@@ -610,7 +548,6 @@
       };
       return {
         cacheKeyUrl: 'eos-saleManage-invoice-inventoryTable-2026082501',
-        widthsVersion: 0,
         current: {},
         childrenColumns: [
           {
@@ -694,25 +631,9 @@
       },
       columns() {
         let columnsVersion = this.columnsVersion;
-        // 强制重新计算(每次进入时读取缓存宽度)
-        this.widthsVersion;
-        const cacheWidths = this.getStorage(this.cacheKeyUrl + 'Widths') || {};
-        const applyWidth = (col) => {
-          if (col.prop && cacheWidths[col.prop]) {
-            return { ...col, width: cacheWidths[col.prop], minWidth: undefined };
-          }
-          return col;
-        };
         return [
           {
             width: 60,
-            type: 'selection',
-            columnKey: 'selection',
-            align: 'center',
-            fixed: 'left'
-          },
-          {
-            width: 45,
             type: 'index',
             columnKey: 'index',
             align: 'center',
@@ -1144,7 +1065,7 @@
             fixed: 'right',
             showOverflowTooltip: true
           }
-        ].map(applyWidth);
+        ];
       }
     },
     mounted() {
@@ -1870,27 +1791,6 @@
         this.setSort();
       },
 
-      batchRemove() {
-        if (!this.selection.length) return;
-        this.$confirm('确定要批量删除选中的物品吗?', '提示', {
-          confirmButtonText: '确定',
-          cancelButtonText: '取消',
-          type: 'warning'
-        }).then(() => {
-          const ids = this.selection.map(item => item.tempId ?? item.id);
-          this.form.datasource = this.form.datasource.filter(
-            item => !ids.includes(item.tempId ?? item.id)
-          );
-          this.selection = [];
-          this.setSort();
-          this.$refs.table.reload();
-          this.$message.success('删除成功');
-        }).catch(() => {});
-      },
-      // 清空表格
-      restTable() {
-        this.form.datasource = [];
-      },
       // 重新排序
       setSort() {
         this.form.datasource.forEach((n, index) => {
@@ -1947,13 +1847,6 @@
 
           callback(valid);
         });
-      },
-      // 列头拖拽结束 - 保存列宽到本地缓存
-      handleHeaderDragend(newWidth, oldWidth, column) {
-        if (!column.property) return;
-        const widths = this.getStorage(this.cacheKeyUrl + 'Widths') || {};
-        widths[column.property] = newWidth;
-        this.setStorage(this.cacheKeyUrl + 'Widths', widths);
       }
     }
   };

+ 9 - 5
src/views/saleManage/saleOrder/invoice/components/replaceTable.vue

@@ -1104,12 +1104,15 @@
         if (data) {
           if (type == 'add') {
             data.forEach((item) => {
-              const data = this.warehouseList.find(
+              // 库存台账带入的仓库可能不在仓库下拉列表中,找不到时保留原值,避免中断添加流程
+              const warehouse = this.warehouseList.find(
                 (val) => val.id == item.warehouseId
               );
-              item['warehouseId'] = data.id;
-              item['warehouseName'] = data.name;
-              item['warehouseCode'] = data.code;
+              if (warehouse) {
+                item['warehouseId'] = warehouse.id;
+                item['warehouseName'] = warehouse.name;
+                item['warehouseCode'] = warehouse.code;
+              }
               item.totalPrice = 0;
               item.singlePrice = 0;
               item.discountSinglePrice = 0;
@@ -1117,11 +1120,12 @@
             });
           }
 
+          const appendStart = this.form.datasource.length;
           this.form.datasource = [...this.form.datasource,...data];
           data.forEach(async (item, index) => {
             if (item.warehouseId) {
               this.$set(
-                this.form.datasource[index],
+                this.form.datasource[appendStart + index],
                 'warehouseNum',
                 await getWarehouseOutStock({
                   warehouseId: item.warehouseId,