From e72d24db3a5b774768c86e8dde4283c7359e8420 Mon Sep 17 00:00:00 2001
From: CD配唱片 <CD配唱片>
Date: 星期四, 24 四月 2025 16:03:35 +0800
Subject: [PATCH] 优化表格触底加载js交互功能逻辑
---
src/utils/request.js | 2 +-
src/components/HxlhTable/index.vue | 3 +++
src/views/basicData/processRoute/index.vue | 46 +++++++++++++++++++++++++++++++++++-----------
vite.config.js | 6 +++---
4 files changed, 42 insertions(+), 15 deletions(-)
diff --git a/src/components/HxlhTable/index.vue b/src/components/HxlhTable/index.vue
index 34bc34e..7f2e9dd 100644
--- a/src/components/HxlhTable/index.vue
+++ b/src/components/HxlhTable/index.vue
@@ -39,6 +39,9 @@
@checkbox-all="checkChangeall"
@scroll-boundary="scrollBoundaryEvent"
>
+ <template v-slot:rowIndex="row">
+ <slot name="rowIndex" v-bind="row" />
+ </template>
<template v-slot:buttons="row">
<slot name="buttons" v-bind="row" />
</template>
diff --git a/src/utils/request.js b/src/utils/request.js
index 6ff4157..be37721 100644
--- a/src/utils/request.js
+++ b/src/utils/request.js
@@ -17,7 +17,7 @@
// axios涓姹傞厤缃湁baseURL閫夐」锛岃〃绀鸿姹俇RL鍏叡閮ㄥ垎
baseURL: import.meta.env.VITE_APP_BASE_API,
// 瓒呮椂
- timeout: 1000000
+ timeout: 300000
})
diff --git a/src/views/basicData/processRoute/index.vue b/src/views/basicData/processRoute/index.vue
index cdad7f9..e4b782c 100644
--- a/src/views/basicData/processRoute/index.vue
+++ b/src/views/basicData/processRoute/index.vue
@@ -77,6 +77,9 @@
@bottomAutoLoadMore="handleAutoLoadMore"
@on-checkbox="handleCheckboxChange"
>
+ <template #rowIndex="{ rowIndex }">
+ {{ rowIndex }}
+ </template>
</HxlhTable>
<!-- 鐢ㄦ埛瀵煎叆瀵硅瘽妗� -->
<el-dialog
@@ -325,7 +328,7 @@
// 琛ㄦ牸閰嶇疆-寮圭獥
const exampleColumns = ref([
- { type: "seq", title: "搴忓彿", width: 60 },
+ { type: "seq", title: "搴忓彿", width: 60, slots: { default: "rowIndex" } },
{
title: "鏂欏彿",
field: "itemNo",
@@ -399,11 +402,12 @@
// align:"center",
// }
]);
+const hasMore = ref(true);
const data = reactive({
form: {},
queryParams: {
- pageNum: 1,
- pageSize: 10000,
+ pageNum: 0,
+ pageSize: 10,
itemNo: null,
integrationDay: null,
},
@@ -413,7 +417,7 @@
const { queryParams, form, rules } = toRefs(data);
/** 鏌ヨ宸ヨ壓璺嚎鍒楄〃 */
-function getList() {
+async function getList() {
loading.value = true;
queryParams.value.params = {};
if (null != daterangeIntegrationDay && "" != daterangeIntegrationDay) {
@@ -422,16 +426,36 @@
queryParams.value.params["endIntegrationDay"] =
daterangeIntegrationDay.value[1];
}
- listProcessRoute(queryParams.value).then((response) => {
- processRouteList.value = response.rows;
- total.value = response.total;
- loading.value = false;
- });
-}
+ const response = await listProcessRoute(queryParams.value)
+ // processRouteList.value = response.rows;
+ if(processRouteList.value.length < queryParams.value.pageSize){
+ hasMore.value = false;
+ processRouteList.value = response.rows
+ }else{
+ processRouteList.value = [...processRouteList.value,...response.rows];
+ }
+
+ // total.value = response.total;
+ loading.value = false;
+
+}
+// async function loadData() {
+// try {
+// const response = await fetch(`https://api.example.com/products?page=${this.page}&limit=${this.pageSize}`);
+// const data = await response.json();
+// if (data.length < this.pageSize) {
+// this.hasMore = false;
+// }
+// this.products.push(...data);
+// this.page++;
+// } catch (error) {
+// console.error('Error fetching data:', error);
+// }
+// }
function handleAutoLoadMore(){
- queryParams.value.pageNum++;
getList();
+ queryParams.value.pageNum++;
}
// 鍙栨秷鎸夐挳
function cancel() {
diff --git a/vite.config.js b/vite.config.js
index b751e24..212f287 100644
--- a/vite.config.js
+++ b/vite.config.js
@@ -11,8 +11,8 @@
// https://vitejs.dev/config/
export default defineConfig(({ mode, command }) => {
const env = loadEnv(mode, process.cwd());
- const { VITE_APP_ENV, VITE_APP_BASE_API, VITE_API_URL } = env;
- console.log(VITE_APP_BASE_API, VITE_API_URL);
+ const { VITE_APP_ENV, VITE_APP_BASE_API } = env;
+ console.log(VITE_APP_BASE_API, VITE_APP_ENV);
// 鏍规嵁鐜鍙橀噺鍔ㄦ�佽缃唬鐞�
const proxyConfig = () => {
const personProxy = {
@@ -48,7 +48,7 @@
switch (VITE_APP_ENV) {
case "development":
- return personProxy;
+ return devProxy;
case "int":
return devProxy;
case "uat":
--
Gitblit v1.9.3