添加自动加载开关,是的分页加载器不自动加载数据,而是可以通过更新默认参数后,再执行,避免了mixins导致先执行导致的接收不到this.formedId的传参

This commit is contained in:
WindowBird 2025-09-05 17:27:47 +08:00
parent e26975588b
commit 7b6863f3f1
3 changed files with 14 additions and 7 deletions

View File

@ -5,6 +5,7 @@
* @param {Object} options.defaultParams - 默认查询参数
* @param {string} options.mode - 分页模式'loadMore' 'pager'
* @param {number} options.pageSize - 每页数量
* @param {boolean} options.autoLoad - 是否在创建时自动加载数据默认为true
* @returns {Object} Vue组件选项对象
*/
export function createPagination(options = {}) {
@ -13,6 +14,7 @@ export function createPagination(options = {}) {
defaultParams = {},
mode = "loadMore",
pageSize = 10,
autoLoad = true, // 新增参数,控制是否自动加载
} = options;
return {
@ -207,8 +209,10 @@ export function createPagination(options = {}) {
},
created() {
// 初始化时加载第一页数据
// 只有在 autoLoad 为 true 时才自动加载数据
if (autoLoad) {
this.winB_GetList();
}
},
};
}

View File

@ -153,6 +153,7 @@ export default {
fetchData: getProjectSchedule,
mode: "loadMore",
pageSize: 2,
autoLoad: false, // false
}),
],
data() {
@ -165,6 +166,7 @@ export default {
selectedIndex: 0,
customAmount: "",
payAmount: "",
formedId: null, // formedId data
projectDetails: {
// createBy: null,
@ -207,7 +209,7 @@ export default {
// templeId: "12",
// title: "01232",
// content:
// "<p>020202020202020202020202020202020202020202020202...</p>",
// "<p>020202020202020202020202020202020202020202...</p>",
// status: "1",
// templeName: "",
// createTime: "2025-07-09 13:50:57",
@ -231,10 +233,11 @@ export default {
if (options) {
console.log("接收到的参数:", options.formedId);
this.formedId = options.formedId;
//
this.winB_UpdateParams({ formedId: this.formedId });
}
//
this.loadPageData();
this.winB_GetList();
},
methods: {
//

View File

@ -17,18 +17,18 @@ import {
const ENV_CONFIG = {
develop: {
// 开发环境
baseUrl: "http://192.168.2.58:4501",
baseUrl: "http://192.168.2.58:4502",
//baseUrl: "https://testlu.chuangtewl.com/prod-api",
appId: 1,
},
trial: {
// 体验版
baseUrl: "http://192.168.2.58:4501",
baseUrl: "http://192.168.2.58:4502",
appId: 1,
},
release: {
// 正式版
baseUrl: "http://192.168.2.58:4501",
baseUrl: "http://192.168.2.58:4502",
appId: 1,
},
};