Jelajahi Sumber

Merge branch 'dev' into test

liujt 1 Minggu lalu
induk
melakukan
6997450380

+ 7 - 2
src/BIZComponents/selectStockLedger/selectStockLedgerDialog.vue

@@ -53,6 +53,7 @@
             :cache-key="cacheKeyUrl"
             :page-size="20"
             @columns-change="handleColumnChange"
+            @header-dragend="handleHeaderDragend"
           >
             <template v-slot:saleCount="{ row }">
               <el-input
@@ -75,7 +76,7 @@
     </el-card>
 
     <div slot="footer">
-      <el-button 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>
@@ -114,6 +115,10 @@
       cacheKeyUrl: {
         type: String,
         default: 'eom-sales-selectStockLedgerDialog-202605131603'
+      },
+      isView: {
+        type: Boolean,
+        default: false
       }
     },
 
@@ -334,7 +339,7 @@
             align: 'center'
           }
         ];
-        return tempData.filter((item) => !item.hide);
+        return this.applyColumnWidth(tempData.filter((item) => !item.hide));
       }
     },
     methods: {

+ 82 - 39
src/mixins/tableColumnsMixin.js

@@ -5,10 +5,17 @@ export default {
   data() {
     return {
       newColumns: [],
-      tabMixinsInit: true //进入页面是否默认请求列配置
+      tabMixinsInit: true, //进入页面是否默认请求列配置
+      // 列宽映射(prop/columnKey -> 宽度),用于 computed columns 应用拖拽/缓存后的宽度
+      columnWidthMap: {},
+      // 每页条数(页面可在自身 data 覆盖默认值)
+      pageSize: 10
     };
   },
   created() {
+    // 同步读取本地保存的每页条数,保证 ele-pro-table 首次加载即用正确值
+    this.initPageSize();
+
     //从服务器获取缓存列表配置
     if (this.tabMixinsInit) {
       this.getTabColumns();
@@ -69,6 +76,11 @@ export default {
     // 获取table-column配置
     async getTabColumns() {
       const res = await this.getByTableId(this.cacheKeyUrl);
+      // 从服务端配置恢复每页条数(优先服务端,同步本地缓存)
+      if (res?.pageSize) {
+        this.pageSize = res.pageSize;
+        this.setStorage(this.cacheKeyUrl + 'PageSize', res.pageSize);
+      }
       if (res?.columnConfig?.length > 0) {
         //对比接口返回和本地columns
         let { nlist, type } = this.columnsContrast(res.columnConfig);
@@ -80,17 +92,9 @@ export default {
           this.saveColumns(uniqueLabelList);
         }
         this.setStorage(this.cacheKeyUrl + 'Cols', nlist);
-        // 从缓存恢复列宽到本地列(下次进入生效)
+        // 从缓存恢复列宽到 columnWidthMap,并应用到列
         this.applyColumnWidthFromCache();
-        // 更新列
-        if (this._computedWatchers && this._computedWatchers.columns) {
-          // console.log('columns 是计算属性');
-          this.columnsVersion++;
-        } else {
-          // console.log('columns 是 data 属性');
-          this.columns = [...this.columns];
-          this.newColumns = [...this.newColumns];
-        }
+        this.applyColumnWidths();
       }
     },
     getColumns() {
@@ -100,6 +104,31 @@ export default {
         return this.columns;
       }
     },
+    // 同步读取本地保存的每页条数(localStorage),用于首次加载
+    initPageSize() {
+      const local = this.getStorage(this.cacheKeyUrl + 'PageSize');
+      if (local) {
+        this.pageSize = local;
+      }
+    },
+    // 每页条数变化处理:在 datasource({ limit }) 中调用,变化时保存
+    handlePageSize(limit) {
+      if (limit && limit !== this.pageSize) {
+        this.pageSize = limit;
+        this.savePageSize(limit);
+      }
+    },
+    // 保存每页条数到 localStorage + 服务端 table-config(同时带上当前列配置)
+    savePageSize(size) {
+      this.setStorage(this.cacheKeyUrl + 'PageSize', size);
+      // 服务端持久化:tableId + pageSize + columnConfig 三参数齐全
+      const columnConfig = this.getStorage(this.cacheKeyUrl + 'Cols') || [];
+      this.saveTableConfig({
+        tableId: this.cacheKeyUrl,
+        pageSize: size,
+        columnConfig
+      });
+    },
     // 根据 prop / columnKey / label 查找本地列(支持 children 递归)
     findColumnByKey(key, label) {
       let result = null;
@@ -119,23 +148,43 @@ export default {
       loop(this.getColumns() || []);
       return result;
     },
-    // 表头拖拽列宽变化回调:更新本地列并持久化
+    // 表头拖拽列宽变化回调:更新列宽映射并持久化
     handleHeaderDragend(newWidth, oldWidth, column) {
       if (!column || !newWidth) return;
       const key = column.property || column.columnKey;
-      const label = column.label;
-      const target = this.findColumnByKey(key, label);
-      if (target) {
-        target.width = newWidth;
-        // 触发 ele-pro-table 重新渲染(render 时 props 会带上 width)
-        if (this._computedWatchers && this._computedWatchers.columns) {
-          this.columnsVersion++;
-        } else {
-          this.columns = [...this.columns];
-        }
-      }
+      if (!key) return;
+      // 仅持久化新宽度,不触发 columns 重算。
+      // el-table 在拖拽过程中已实时更新列宽,此处重算会导致整表重渲染抖动;
+      // 刷新后由 applyColumnWidthFromCache 从缓存恢复,无需拖拽时同步映射。
       this.persistColumnWidth(key, newWidth);
     },
+    // 应用列宽并触发表格更新(自动区分 columns 是 computed 还是 data)
+    applyColumnWidths() {
+      const isComputed = !!(this._computedWatchers && this._computedWatchers.columns);
+      if (isComputed) {
+        // computed 场景:columns 内部已调用 applyColumnWidth,这里只需触发重算
+        this.columnsVersion++;
+      } else {
+        // data 场景:直接应用宽度到 data 数组并触发更新
+        this.applyColumnWidth(this.columns);
+        this.columns = [...this.columns];
+      }
+    },
+    // 应用列宽映射到列数组(供 computed columns 生成列后调用,或 data columns 直接应用)
+    applyColumnWidth(columns) {
+      const map = this.columnWidthMap || {};
+      const keys = Object.keys(map);
+      if (!keys.length || !columns) return columns;
+      const loop = (cols) => {
+        (cols || []).forEach((col) => {
+          const k = col.prop || col.columnKey;
+          if (k && map[k] != null) this.$set(col, 'minWidth', map[k]);
+          if (col.children && col.children.length) loop(col.children);
+        });
+      };
+      loop(columns);
+      return columns;
+    },
     // 持久化列宽到列设置(localStorage 与 ele-pro-table 共用 cacheKey+'Cols',并同步服务端)
     persistColumnWidth(key, width) {
       if (!key) return;
@@ -143,7 +192,7 @@ export default {
       const cached = this.getStorage(storageKey) || [];
       const setting = cached.find((c) => (c.columnKey || c.prop || c.id) === key);
       if (setting) {
-        setting.width = width;
+        setting.minWidth = width;
       } else {
         cached.push({
           id: key,
@@ -151,7 +200,7 @@ export default {
           columnKey: key,
           label: key,
           checked: true,
-          width
+          minWidth: width
         });
       }
       this.setStorage(storageKey, cached);
@@ -159,23 +208,15 @@ export default {
         this.debouncedSaveColumns(cached);
       }
     },
-    // 从缓存恢复列宽到本地列(下次进入页面时调用)
+    // 从缓存恢复列宽到 columnWidthMap(供 computed columns 应用)
     applyColumnWidthFromCache() {
       const cached = this.getStorage(this.cacheKeyUrl + 'Cols') || [];
-      const widthMap = {};
       cached.forEach((c) => {
         const k = c.columnKey || c.prop || c.id;
-        if (k && c.width != null) widthMap[k] = c.width;
+        if (k && c.minWidth != null) {
+          this.$set(this.columnWidthMap, k, c.minWidth);
+        }
       });
-      if (!Object.keys(widthMap).length) return;
-      const loop = (cols) => {
-        (cols || []).forEach((col) => {
-          const k = col.columnKey || col.prop;
-          if (k && widthMap[k] != null) col.width = widthMap[k];
-          if (col.children && col.children.length) loop(col.children);
-        });
-      };
-      loop(this.getColumns());
     },
     //服务器和本地配置columns对比
     columnsContrast(list) {
@@ -241,10 +282,11 @@ export default {
       return { nlist: [...updated, ...added], type: updateType };
     },
 
-    // 提交columns配置
+    // 提交columns配置(tableId + pageSize + columnConfig 三参数齐全)
     async saveColumns(e) {
       const data = {
         tableId: this.cacheKeyUrl,
+        pageSize: this.pageSize,
         columnConfig: e
       };
       const msg = await this.saveTableConfig(data);
@@ -328,6 +370,7 @@ export default {
       } catch (error) {
         console.error('保存列配置失败:', error);
       }
-    }
+    },
+    
   }
 };

+ 14 - 1
src/views/purchasingManage/purchaseOrder/components/addDialogNew.vue

@@ -506,6 +506,12 @@
         title="物品清单"
         style="margin-top: 30px"
       >
+        <el-button
+          type="primary"
+          size="mini"
+          style="margin-bottom: 5px"
+          @click="stockShow"
+          >库存台账</el-button>
         <el-button
           type="primary"
           size="mini"
@@ -623,6 +629,8 @@
       <el-button @click="cancel">返回</el-button>
     </div>
 
+    <selectStockLedgerDialog ref="selectStockLedgerDialogRef" :isSupplier="true" :isView="true" :cacheKeyUrl="cacheKeyUrl+'saleOrderss'"></selectStockLedgerDialog>
+
     <parentList
       ref="parentRef"
       @changeParent="changeParent"
@@ -800,6 +808,7 @@
   import { formatPrice } from '@/BIZComponents/setProduct.js';
   import { parameterGetByCode } from '@/api/main/index.js';
   import orderListDialog from '@/views/purchasingManage/purchaseOrder/invoice/components/orderListDialog.vue';
+  import selectStockLedgerDialog from '@/BIZComponents/selectStockLedger/selectStockLedgerDialog.vue'; //库存台账
 
   export default {
     mixins: [dictMixins],
@@ -829,7 +838,8 @@
       returnOrderDealDialog,
       purchaseReturnOrderDialog,
       PaymentCollectionPlan,
-      orderListDialog
+      orderListDialog,
+      selectStockLedgerDialog
     },
     data() {
       let formDef = {
@@ -1071,6 +1081,9 @@
       });
     },
     methods: {
+      stockShow() {
+        this.$refs.selectStockLedgerDialogRef.open('', -1);
+      },
       orderListShow() {
         if (!this.form.partbName) {
           this.$message.warning('请先选择供应商');

+ 3 - 17
src/views/purchasingManage/purchaseOrder/invoice/components/addInvoiceDialog.vue

@@ -179,7 +179,6 @@
   import { copyObj } from '@/utils/util';
   import outSourceSendDialog from '@/views/purchasingManage/purchaseOrder/invoice/components/outSourceSendDialog.vue';
   import { getPurchaseOutSourceSendDetailAPI } from '@/api/purchasingManage/outSourceSend';
-  import { getWarehouseListByIds } from '@/api/purchasingManage/returnGoods';
   // import fileMain from '@/components/addDoc/index.vue';
   import processSubmitDialog from '@/BIZComponents/processSubmitDialog/processSubmitDialog.vue';
 
@@ -547,13 +546,7 @@
                 this.loading = false;
                 this.$message.success('修改成功');
                 if (type === 'sub') {
-                  let storemanIds = '';
-                  let ids = commitData.productList.map(
-                    (item) => item.warehouseId
-                  );
-                  let warehouseList = await getWarehouseListByIds(ids || []);
-                  storemanIds = warehouseList.map((item) => item.ownerId);
-                  this.sub(res, commitData.sourceType, storemanIds.toString());
+                  this.sub(res, commitData.sourceType);
                   return;
                 }
                 this.cancel();
@@ -569,13 +562,7 @@
                 this.loading = false;
                 this.$message.success('新增成功');
                 if (type === 'sub') {
-                  let storemanIds = '';
-                  let ids = commitData.productList.map(
-                    (item) => item.warehouseId
-                  );
-                  let warehouseList = await getWarehouseListByIds(ids || []);
-                  storemanIds = warehouseList.map((item) => item.ownerId);
-                  this.sub(res, commitData.sourceType, storemanIds.toString());
+                  this.sub(res, commitData.sourceType);
                   return;
                 }
                 this.cancel();
@@ -590,7 +577,7 @@
           // 表单验证未通过,不执行保存操作
         }
       },
-      async sub(res, sourceType, storemanIds) {
+      async sub(res, sourceType) {
         const data = await getReceiveSaleOrderrecordDetail(
           this.businessId || res
         );
@@ -608,7 +595,6 @@
               businessCode: data.receiveNo,
               receiveType: data.receiveType,
               sourceType: data.sourceType,
-              storemanIds: storemanIds.toString(),
               businessName: data.supplierName,
               businessType: '采购收货'
             }

+ 0 - 7
src/views/purchasingManage/purchaseOrder/invoice/index.vue

@@ -223,7 +223,6 @@
     receiveGenerateQualityPlan
   } from '@/api/purchasingManage/purchaseorderreceive';
   import dictMixins from '@/mixins/dictMixins';
-  import { getWarehouseListByIds } from '@/api/purchasingManage/returnGoods';
   import processSubmitDialog from '@/BIZComponents/processSubmitDialog/processSubmitDialog.vue';
   import tabMixins from '@/mixins/tableColumnsMixin';
   import { enterprisePage } from '@/api/contractManage/contractBook';
@@ -486,11 +485,6 @@
       },
       async sub(res) {
         const data = await getReceiveSaleOrderrecordDetail(res.id);
-        let storemanIds = '';
-        let ids = data.productList.map((item) => item.warehouseId);
-        let warehouseList = await getWarehouseListByIds(ids || []);
-        storemanIds = warehouseList.map((item) => item.ownerId);
-
         this.processSubmitDialogFlag = true;
         let key =
           res.sourceType == '1'
@@ -505,7 +499,6 @@
               businessCode: res.receiveNo,
               receiveType: res.receiveType,
               sourceType: res.sourceType,
-              storemanIds: storemanIds.toString(),
               businessName: res.supplierName,
               businessType: '采购收货'
             }

+ 15 - 4
src/views/saleManage/saleOrder/components/addDialogNew.vue

@@ -539,15 +539,20 @@
         style="margin-top: 30px"
         v-if="form.needProduce != 4"
       >
+        <el-button
+          type="primary"
+          size="mini"
+          style="margin-bottom: 5px"
+          @click="stockShow"
+          >库存台账</el-button>
         <el-button
           type="primary"
           size="mini"
           style="margin-bottom: 5px"
           @click="orderListShow"
           v-if="!form.id"
-          >历史记录</el-button
-        ></headerTitle
-      >
+          >历史记录</el-button>
+      </headerTitle>
       <inventoryTable
         v-if="form.needProduce != 4"
         :isSuspend="form.isSuspend"
@@ -696,6 +701,7 @@
 
       <el-button @click="cancel">返回</el-button>
     </div>
+    <selectStockLedgerDialog ref="selectStockLedgerDialogRef" :isSupplier="true" :isView="true" :cacheKeyUrl="cacheKeyUrl+'saleOrderss'"></selectStockLedgerDialog>
     <quotationList
       ref="quotationListRef"
       @changeParent="changeQuotationList"
@@ -806,6 +812,7 @@
   import PaymentCollectionPlan from '@/BIZComponents/paymentCollectionPlan/Index.vue';
   import { shippingModeOp, transactionMethodsOp } from '@/enum/dict.js';
   import { formatPrice } from '@/BIZComponents/setProduct.js';
+  import selectStockLedgerDialog from '@/BIZComponents/selectStockLedger/selectStockLedgerDialog.vue'; //库存台账
   export default {
     mixins: [dictMixins],
     components: {
@@ -825,7 +832,8 @@
       saleOrderListDialog,
       opportunityDialog,
       personSelect,
-      PaymentCollectionPlan
+      PaymentCollectionPlan,
+      selectStockLedgerDialog
     },
     props: {
       contactData: {
@@ -1119,6 +1127,9 @@
       });
     },
     methods: {
+      stockShow() {
+        this.$refs.selectStockLedgerDialogRef.open('', -1);
+      },
       setIssueNumber(len) {
         this.form.issueNumber = len;
       },

+ 10 - 3
src/views/saleManage/saleOrder/index.vue

@@ -44,11 +44,12 @@
                 full-height="calc(100vh - 116px)"
                 tool-class="ele-toolbar-form"
                 :selection.sync="selection"
-                :page-size="20"
+                :page-size="pageSize"
                 @columns-change="handleColumnChange"
                 :cache-key="cacheKeyUrl"
                 show-summary
                 :summary-method="getSummaries"
+                @header-dragend="handleHeaderDragend"
               >
                 <!-- 表头工具栏 -->
                 <template v-slot:toolbar>
@@ -572,6 +573,7 @@ export default {
       isRequired: true,
       isTotalCount: '0',
       columnsVersion: 1,
+      pageSize: 20,
       timeR: null,
       toDoReminder: {},
       groupName: '',
@@ -673,7 +675,8 @@ export default {
     },
     columns() {
       let columnsVersion = this.columnsVersion;
-      return [
+       
+      const list = [
         {
           width: 45,
           type: 'selection',
@@ -1014,6 +1017,8 @@ export default {
           fixed: 'right'
         }
       ];
+
+      return this.applyColumnWidth(list);
     }
   },
   watch: {
@@ -1163,7 +1168,9 @@ export default {
     },
     /* 表格数据源 */
     datasource({ page, limit, where, order }) {
-      console.log('where~~~', where);
+      console.log('where~~~', where, limit);
+      // 捕获并持久化每页条数变化
+      this.handlePageSize(limit);
       if(where?.needProduces?.length){
         where['needProduces'] = where.needProduces.join(',');
       }

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

@@ -175,6 +175,18 @@
         </el-col>
       </el-row>
     </el-form>
+    <headerTitle
+        title="物品清单"
+        style="margin-top: 30px"
+        v-if="form.needProduce != 4"
+      >
+        <el-button
+          type="primary"
+          size="mini"
+          style="margin-bottom: 5px"
+          @click="stockShow"
+          >库存台账</el-button>
+      </headerTitle>
     <el-tabs v-model="activeName" style="margin-top: 15px" type="border-card">
       <el-tab-pane label="物品清单" name="first">
         <inventoryTable
@@ -231,6 +243,8 @@
 
       <el-button @click="cancel">返回</el-button>
     </div>
+
+    <selectStockLedgerDialog ref="selectStockLedgerDialogRef" :isSupplier="true" :isView="true" :cacheKeyUrl="cacheKeyUrl+'saleOrderss'"></selectStockLedgerDialog>
     <orderListDialog
       ref="orderListDialogRef"
       @changeParent="changeOrder"
@@ -298,7 +312,7 @@
   import { getWarehouseListByIds } from '@/api/purchasingManage/returnGoods';
   import returnOrderDialog from '@/views/saleManage/saleOrder/customerReturnOrder/returnOrderDialog.vue';
   import { getReturnSaleOrderrecordDetail } from '@/api/saleManage/returnGoods';
-
+  import selectStockLedgerDialog from '@/BIZComponents/selectStockLedger/selectStockLedgerDialog.vue'; //库存台账
   export default {
     mixins: [dictMixins],
     components: {
@@ -314,7 +328,8 @@
       entrustedReceiveDialog,
       stowageTable,
       replaceTable,
-      returnOrderDialog
+      returnOrderDialog,
+      selectStockLedgerDialog
     },
 
     //客户管理数据
@@ -447,6 +462,9 @@
     },
 
     methods: {
+      stockShow() {
+        this.$refs.selectStockLedgerDialogRef.open('', -1);
+      },
       //销售发货数量是否限制不能大于采购总数//0否 1是
       parameterGetByCode() {
         parameterGetByCode({

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

@@ -26,6 +26,7 @@
               children: 'children',
               hasChildren: 'hasChildren'
             }"
+            @header-dragend="handleHeaderDragend"
           >
             <!-- 表头工具栏 -->
             <template v-slot:toolbar>