20251205任务数据分配分页
This commit is contained in:
@@ -8,12 +8,18 @@
|
||||
prefix-icon="el-icon-search"
|
||||
clearable
|
||||
size="small"
|
||||
@input="handleSearch"
|
||||
@keyup.enter.native="handleSearch"
|
||||
></el-input>
|
||||
<el-button
|
||||
class="forest-btn search-btn"
|
||||
size="small"
|
||||
icon="el-icon-search"
|
||||
@click="handleSearch"
|
||||
>搜索</el-button>
|
||||
</div>
|
||||
<div class="toolbar-actions">
|
||||
<el-button class="forest-btn" size="medium" icon="el-icon-download" @click="openBatchDownloadDialog">
|
||||
批量数据下载
|
||||
批量数据下载
|
||||
</el-button>
|
||||
<el-button class="forest-btn ghost" size="medium" icon="el-icon-copy-document" @click="ExchangeData()">
|
||||
任务数据复制
|
||||
@@ -98,6 +104,18 @@
|
||||
</template>
|
||||
</el-table-column>
|
||||
</el-table>
|
||||
<!-- 分页组件 -->
|
||||
<div class="pagination-container">
|
||||
<el-pagination
|
||||
@size-change="handleSizeChange"
|
||||
@current-change="handleCurrentChange"
|
||||
:current-page="pageNum"
|
||||
:page-sizes="[10, 20, 50, 100]"
|
||||
:page-size="pageSize"
|
||||
layout="total, sizes, prev, pager, next, jumper"
|
||||
:total="total"
|
||||
></el-pagination>
|
||||
</div>
|
||||
<el-card class="box-card" v-show="tpkCardV">
|
||||
<div slot="header" class="clearfix">
|
||||
<span style="float: left; padding: 3px 0; font-size: 16px"
|
||||
@@ -734,6 +752,11 @@ export default {
|
||||
filteredData: [], // 过滤后的数据
|
||||
batchDownloadDialogVisible: false, // 批量下载对话框显示
|
||||
batchDownloadSelectedTasks: [], // 勾选的任务ID
|
||||
// 分页相关属性
|
||||
pageNum: 1,
|
||||
pageSize: 10,
|
||||
total: 0,
|
||||
totalPages: 0
|
||||
|
||||
};
|
||||
},
|
||||
@@ -771,33 +794,71 @@ export default {
|
||||
|
||||
this.$message.success("批量下载请求已发起");
|
||||
},
|
||||
// 搜索处理方法
|
||||
// 搜索处理方法 - 搜索时重置到第一页并重新加载数据
|
||||
handleSearch() {
|
||||
if (!this.searchKeyword.trim()) {
|
||||
this.filteredData = [...this.tasksData];
|
||||
} else {
|
||||
const keyword = this.searchKeyword.toLowerCase();
|
||||
this.filteredData = this.tasksData.filter(item => {
|
||||
return (
|
||||
(item.taskName && item.taskName.toLowerCase().includes(keyword)) ||
|
||||
(item.databaseName && item.databaseName.toLowerCase().includes(keyword)) ||
|
||||
(item.introduction && item.introduction.toLowerCase().includes(keyword))
|
||||
);
|
||||
});
|
||||
}
|
||||
this.pageNum = 1;
|
||||
this.init();
|
||||
},
|
||||
// 分页大小改变处理
|
||||
handleSizeChange(val) {
|
||||
this.pageSize = val;
|
||||
this.pageNum = 1;
|
||||
this.init();
|
||||
},
|
||||
// 当前页改变处理
|
||||
handleCurrentChange(val) {
|
||||
this.pageNum = val;
|
||||
this.init();
|
||||
},
|
||||
|
||||
// formatter(row, column) {
|
||||
// return row.address;
|
||||
// },
|
||||
//读取数据库 初始化数据 - 使用分页接口获取数据
|
||||
init() {
|
||||
let that = this;
|
||||
// 从 store 获取数据
|
||||
const taskData = that.$store.state.taskData.selectTaskHasCreated || [];
|
||||
that.tasksData = taskData;
|
||||
that.filteredData = [...that.tasksData]; // 初始化过滤数据
|
||||
that.srcTaskOptions = taskData;
|
||||
that.destTaskOptions = taskData;
|
||||
// 构建请求参数
|
||||
const params = {
|
||||
pageNum: that.pageNum,
|
||||
pageSize: that.pageSize,
|
||||
keyword: that.searchKeyword && that.searchKeyword.trim() ? that.searchKeyword.trim() : ''
|
||||
};
|
||||
|
||||
request({
|
||||
url: "/task/selectTaskHasCreatedPaginated",
|
||||
method: "get",
|
||||
params: params
|
||||
}).then(function (response) {
|
||||
if (response.data.success === true) {
|
||||
const result = response.data.data;
|
||||
|
||||
// 从返回的数据结构中提取数据数组和分页信息
|
||||
that.tasksData = result.data || [];
|
||||
|
||||
// 分页信息在 pageInfo 对象中
|
||||
if (result.pageInfo) {
|
||||
that.total = result.pageInfo.total || 0;
|
||||
that.totalPages = result.pageInfo.totalPages || 0;
|
||||
that.pageNum = result.pageInfo.pageNum || 1;
|
||||
that.pageSize = result.pageInfo.pageSize || 10;
|
||||
} else {
|
||||
// 兼容旧格式(如果 pageInfo 不存在)
|
||||
that.total = result.total || 0;
|
||||
that.totalPages = result.totalPages || 0;
|
||||
that.pageNum = result.pageNum || 1;
|
||||
that.pageSize = result.pageSize || 10;
|
||||
}
|
||||
|
||||
that.filteredData = [...that.tasksData];
|
||||
that.srcTaskOptions = that.tasksData;
|
||||
that.destTaskOptions = that.tasksData;
|
||||
} else if (response.data.status === "401") {
|
||||
that.$alert(response.data.message);
|
||||
that.$router.push({ path: "/login" });
|
||||
} else {
|
||||
that.$message.error(response.data.message || "获取数据失败");
|
||||
}
|
||||
}).catch(function (error) {
|
||||
console.error("获取数据失败:", error);
|
||||
that.$message.error("获取数据失败,请稍后重试");
|
||||
});
|
||||
},
|
||||
beforeTpkUpload(file) {
|
||||
if (file.type != "tpk") {
|
||||
@@ -1563,11 +1624,20 @@ export default {
|
||||
|
||||
.search-box {
|
||||
flex: 0 0 auto;
|
||||
display: flex;
|
||||
align-items: center;
|
||||
gap: 12px;
|
||||
width: 450px;
|
||||
}
|
||||
|
||||
:deep(.search-box .el-input) {
|
||||
width: 100%;
|
||||
flex: 1;
|
||||
}
|
||||
|
||||
.search-btn {
|
||||
flex-shrink: 0;
|
||||
padding: 0 20px;
|
||||
min-width: 80px;
|
||||
}
|
||||
|
||||
.toolbar-actions {
|
||||
@@ -1600,6 +1670,13 @@ export default {
|
||||
filter: brightness(1.05);
|
||||
}
|
||||
|
||||
.pagination-container {
|
||||
display: flex;
|
||||
justify-content: flex-end;
|
||||
margin-top: 20px;
|
||||
padding: 16px 0;
|
||||
}
|
||||
|
||||
#tableStyle {
|
||||
margin-bottom: 30px;
|
||||
background: rgba(255, 255, 255, 0.92);
|
||||
|
||||
Reference in New Issue
Block a user