20251205任务数据分配分页
This commit is contained in:
@@ -12,8 +12,8 @@ module.exports = {
|
||||
assetsPublicPath: '/',
|
||||
proxyTable: {
|
||||
'/': {
|
||||
// target:'http://127.0.0.1:9006/',
|
||||
target:'http://8.130.135.159:9006/',
|
||||
target:'http://127.0.0.1:9006/',
|
||||
// target:'http://8.130.135.159:9006/',
|
||||
// target:'http://8.130.135.159:9001/',
|
||||
// target:'http://127.0.0.1:9001/',
|
||||
changeOrigin: true,
|
||||
|
||||
@@ -36,7 +36,7 @@
|
||||
</div>
|
||||
</div>
|
||||
<div id="leftPanelScroll">
|
||||
<el-tabs v-model="activeName">
|
||||
<el-tabs v-model="activeName">
|
||||
<el-tab-pane label="任务进度" name="first">
|
||||
<el-select
|
||||
v-model="task"
|
||||
@@ -773,19 +773,19 @@ export default {
|
||||
// 从 store 获取数据
|
||||
const taskData = that.$store.state.taskData.selectTaskHasCreated || [];
|
||||
for (var i = 0; i < taskData.length; i++) {
|
||||
that.reportoptions.push({
|
||||
that.reportoptions.push({
|
||||
value: taskData[i].id,
|
||||
label: taskData[i].taskName,
|
||||
});
|
||||
that.taskoptions.push({
|
||||
});
|
||||
that.taskoptions.push({
|
||||
value: taskData[i].id,
|
||||
label: taskData[i].taskName,
|
||||
});
|
||||
that.wTaskOptions.push({
|
||||
});
|
||||
that.wTaskOptions.push({
|
||||
value: taskData[i].id,
|
||||
label: taskData[i].taskName,
|
||||
});
|
||||
}
|
||||
});
|
||||
}
|
||||
},
|
||||
getWarningTables() {
|
||||
if (this.warningform.task != "") {
|
||||
|
||||
@@ -26,7 +26,7 @@
|
||||
</div>
|
||||
</div>
|
||||
<div id="leftPanelScroll">
|
||||
<el-tabs v-model="activeName">
|
||||
<el-tabs v-model="activeName">
|
||||
<el-tab-pane label="数据查看" name="second">
|
||||
<div>
|
||||
<p class="mylabel">
|
||||
@@ -230,7 +230,7 @@
|
||||
</div>
|
||||
</el-tab-pane>
|
||||
</el-tabs>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</transition>
|
||||
@@ -360,11 +360,11 @@ export default {
|
||||
// 从 store 获取数据
|
||||
const taskData = that.$store.state.taskData.selectTaskHasCreated || []
|
||||
for (var i = 0; i < taskData.length; i++) {
|
||||
that.taskoptions.push({
|
||||
that.taskoptions.push({
|
||||
value: taskData[i].id,
|
||||
label: taskData[i].taskName
|
||||
})
|
||||
}
|
||||
})
|
||||
}
|
||||
},
|
||||
getTables () {
|
||||
if (this.task === '') {
|
||||
@@ -856,7 +856,7 @@ export default {
|
||||
}
|
||||
|
||||
// 获取并显示要素属性(无论哪个标签页都获取)
|
||||
that.getFeatureData()
|
||||
that.getFeatureData()
|
||||
}
|
||||
})
|
||||
this.map.addInteraction(this.selectclick)
|
||||
@@ -1145,7 +1145,7 @@ export default {
|
||||
var videodata = []
|
||||
// 处理媒体文件URL
|
||||
if (jsondata.mediaFileURLs && Array.isArray(jsondata.mediaFileURLs)) {
|
||||
for (var i = 0; i < jsondata.mediaFileURLs.length; i++) {
|
||||
for (var i = 0; i < jsondata.mediaFileURLs.length; i++) {
|
||||
var url = jsondata.mediaFileURLs[i]
|
||||
if (!url) continue
|
||||
|
||||
|
||||
@@ -24,7 +24,7 @@
|
||||
></i>
|
||||
</div>
|
||||
<div id="leftPanelScroll">
|
||||
<el-tabs v-model="activeName">
|
||||
<el-tabs v-model="activeName">
|
||||
<el-tab-pane label="统计分析" name="second">
|
||||
<div>
|
||||
<el-select
|
||||
@@ -526,11 +526,11 @@ export default {
|
||||
// 从 store 获取数据
|
||||
const taskData = that.$store.state.taskData.selectTaskHasCreated || [];
|
||||
for (var i = 0; i < taskData.length; i++) {
|
||||
that.stattaskoptions.push({
|
||||
that.stattaskoptions.push({
|
||||
value: taskData[i].id,
|
||||
label: taskData[i].taskName,
|
||||
});
|
||||
}
|
||||
});
|
||||
}
|
||||
},
|
||||
getTables1() {
|
||||
if (this.stattask === "") {
|
||||
|
||||
@@ -39,7 +39,7 @@
|
||||
</div>
|
||||
</div>
|
||||
<div id="leftPanelScroll">
|
||||
<el-collapse v-model="activeItem" accordion>
|
||||
<el-collapse v-model="activeItem" accordion>
|
||||
<el-collapse-item name="1">
|
||||
<template slot="title">
|
||||
<img
|
||||
@@ -1482,18 +1482,18 @@ export default {
|
||||
that.routelist2 = [];
|
||||
// 从 store 获取数据
|
||||
const taskData = that.$store.state.taskData.selectAllWithTableName || [];
|
||||
// 把数据装入下拉菜单中
|
||||
// 把数据装入下拉菜单中
|
||||
for (let i = 0; i < taskData.length; i++) {
|
||||
let newData = {
|
||||
let newData = {
|
||||
value: taskData[i].databaseName,
|
||||
label: taskData[i].taskName,
|
||||
id: taskData[i].id,
|
||||
tableNames: taskData[i].tableNames,
|
||||
};
|
||||
that.routelist.push(newData);
|
||||
that.list.push(newData);
|
||||
that.routelist2.push(newData);
|
||||
}
|
||||
};
|
||||
that.routelist.push(newData);
|
||||
that.list.push(newData);
|
||||
that.routelist2.push(newData);
|
||||
}
|
||||
},
|
||||
// 左侧面板收缩动画
|
||||
collapse() {
|
||||
@@ -1759,7 +1759,9 @@ export default {
|
||||
// if (name != "") {
|
||||
// name = feature.get(name).toString();
|
||||
// }
|
||||
let name = feature.get("_upload_name").toString();
|
||||
// 安全获取 _upload_name,如果不存在则使用空字符串
|
||||
let uploadName = feature.get("_upload_name");
|
||||
let name = uploadName != null && uploadName !== undefined ? uploadName.toString() : "";
|
||||
var styles = {
|
||||
Point: new Style({
|
||||
image: new CircleStyle({
|
||||
@@ -4775,8 +4777,8 @@ export default {
|
||||
// 从 store 获取数据
|
||||
const taskData = this.$store.state.taskData.selectAll || [];
|
||||
that.taskList = taskData;
|
||||
if (that.taskList.length) that.listQuery.taskId = that.taskList[0].id;
|
||||
that.chooseTask(that.listQuery.taskId);
|
||||
if (that.taskList.length) that.listQuery.taskId = that.taskList[0].id;
|
||||
that.chooseTask(that.listQuery.taskId);
|
||||
},
|
||||
watch: {
|
||||
activeItem: {
|
||||
|
||||
@@ -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);
|
||||
|
||||
@@ -768,16 +768,16 @@ export default {
|
||||
// 从 store 获取数据
|
||||
const taskData = this.$store.state.taskData.selectAllWithTableName || [];
|
||||
let current = taskData.find((item) => {
|
||||
return item.id == this.taskId;
|
||||
});
|
||||
return item.id == this.taskId;
|
||||
});
|
||||
if (current) {
|
||||
this.taskValue = {
|
||||
value: current.databaseName,
|
||||
label: current.taskName,
|
||||
id: current.id,
|
||||
tableNames: current.tableNames,
|
||||
};
|
||||
}
|
||||
this.taskValue = {
|
||||
value: current.databaseName,
|
||||
label: current.taskName,
|
||||
id: current.id,
|
||||
tableNames: current.tableNames,
|
||||
};
|
||||
}
|
||||
}
|
||||
})
|
||||
.catch((error) => {
|
||||
|
||||
@@ -8,8 +8,14 @@
|
||||
prefix-icon="el-icon-search"
|
||||
clearable
|
||||
size="small"
|
||||
@input="handleSearch"
|
||||
@keyup.enter.native="handleSearch"
|
||||
></el-input>
|
||||
<el-button
|
||||
class="forest-btn-small search-btn"
|
||||
size="small"
|
||||
icon="el-icon-search"
|
||||
@click="handleSearch"
|
||||
>搜索</el-button>
|
||||
</div>
|
||||
|
||||
<el-table
|
||||
@@ -42,11 +48,12 @@
|
||||
</el-dropdown>
|
||||
</template>
|
||||
<template slot-scope="scope">
|
||||
<el-checkbox
|
||||
label="需要分配"
|
||||
<el-switch
|
||||
v-model="scope.row.isAllocationOptional"
|
||||
@change="changeisAllocationOptional(scope.row.id)"
|
||||
></el-checkbox>
|
||||
active-color="#4CAF50"
|
||||
inactive-color="#E0E0E0"
|
||||
@change="changeisAllocationOptional(scope.row.id, scope.row)"
|
||||
></el-switch>
|
||||
</template>
|
||||
</el-table-column>
|
||||
<el-table-column min-width="95" filterable label="是否已分配" sortable>
|
||||
@@ -144,6 +151,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-dialog
|
||||
v-dialogDrag
|
||||
@@ -294,52 +313,53 @@ export default {
|
||||
},
|
||||
],
|
||||
searchKeyword: "", // 搜索关键词
|
||||
// 分页相关属性
|
||||
pageNum: 1,
|
||||
pageSize: 10,
|
||||
total: 0,
|
||||
totalPages: 0
|
||||
};
|
||||
},
|
||||
methods: {
|
||||
// 搜索处理方法
|
||||
// 搜索处理方法 - 搜索时重置到第一页并重新加载数据
|
||||
handleSearch() {
|
||||
this.applyFilter();
|
||||
this.pageNum = 1;
|
||||
this.init();
|
||||
},
|
||||
// 分页大小改变处理
|
||||
handleSizeChange(val) {
|
||||
this.pageSize = val;
|
||||
this.pageNum = 1;
|
||||
this.init();
|
||||
},
|
||||
// 当前页改变处理
|
||||
handleCurrentChange(val) {
|
||||
this.pageNum = val;
|
||||
this.init();
|
||||
},
|
||||
|
||||
// 应用筛选和搜索
|
||||
applyFilter() {
|
||||
let filtered = [...this.tasksData];
|
||||
|
||||
// 先应用分配状态筛选
|
||||
if (this.currentFilter === 'need') {
|
||||
filtered = filtered.filter(item => item.isAllocationOptional === true);
|
||||
} else if (this.currentFilter === 'notNeed') {
|
||||
filtered = filtered.filter(item => item.isAllocationOptional === false);
|
||||
}
|
||||
|
||||
// 再应用搜索关键词筛选
|
||||
if (this.searchKeyword.trim()) {
|
||||
const keyword = this.searchKeyword.toLowerCase();
|
||||
filtered = filtered.filter(item => {
|
||||
return item.taskName && item.taskName.toLowerCase().includes(keyword);
|
||||
});
|
||||
}
|
||||
|
||||
this.filteredData = filtered;
|
||||
},
|
||||
|
||||
// 筛选处理方法
|
||||
// 筛选处理方法 - 筛选时重置到第一页并重新加载数据
|
||||
handleFilter(command) {
|
||||
this.currentFilter = command;
|
||||
this.applyFilter();
|
||||
this.pageNum = 1;
|
||||
// 筛选是在前端进行的,因为后端接口不支持分配状态筛选
|
||||
// 所以需要重新获取数据后应用筛选
|
||||
this.init();
|
||||
},
|
||||
|
||||
// 修改方法参数,从index改为taskId
|
||||
changeisAllocationOptional(taskId) {
|
||||
let row = this.tasksData.find(item => item.id === taskId);
|
||||
changeisAllocationOptional(taskId, row) {
|
||||
if (!row) return;
|
||||
|
||||
// 保存原始状态,用于请求失败时恢复
|
||||
const originalValue = !row.isAllocationOptional;
|
||||
const newValue = row.isAllocationOptional;
|
||||
|
||||
let that = this;
|
||||
let str = row.isAllocationOptional === true
|
||||
let str = newValue === true
|
||||
? "确认任务需要分配吗?"
|
||||
: "确认任务无需分配吗?";
|
||||
let res = row.isAllocationOptional === true ? 0 : 1;
|
||||
let res = newValue === true ? 0 : 1;
|
||||
|
||||
this.$confirm(str, "提示", {})
|
||||
.then(() => {
|
||||
@@ -353,41 +373,97 @@ export default {
|
||||
}).then(function (response) {
|
||||
if (response.data.success == true) {
|
||||
that.$message.success("设置成功");
|
||||
|
||||
// 重新获取数据以确保状态同步
|
||||
that.init();
|
||||
// 请求成功,状态已经改变,不需要额外操作
|
||||
} else if (response.data.status == "401") {
|
||||
// 请求失败,恢复原始状态
|
||||
row.isAllocationOptional = originalValue;
|
||||
that.$alert(response.data.message);
|
||||
that.$router.push({ path: "/login" });
|
||||
} else {
|
||||
// 请求失败,恢复原始状态
|
||||
row.isAllocationOptional = originalValue;
|
||||
that.$message.error("设置失败");
|
||||
}
|
||||
}).catch(function (error) {
|
||||
// 请求异常,恢复原始状态
|
||||
row.isAllocationOptional = originalValue;
|
||||
console.error("设置失败:", error);
|
||||
that.$message.error("设置失败,请稍后重试");
|
||||
});
|
||||
})
|
||||
.catch(() => {
|
||||
// 取消操作,不需要回滚状态
|
||||
// 用户取消操作,恢复原始状态
|
||||
row.isAllocationOptional = originalValue;
|
||||
});
|
||||
},
|
||||
init() {
|
||||
let that = this;
|
||||
// 从 store 获取数据
|
||||
const taskData = that.$store.state.taskData.selectTaskHasCreated || [];
|
||||
that.tasksData = taskData;
|
||||
//0表示需要分配
|
||||
for (var i = 0; i < that.tasksData.length; i++) {
|
||||
if (that.tasksData[i].isAllocationOptional == 0) {
|
||||
that.tasksData[i].isAllocationOptional = true;
|
||||
// 构建请求参数
|
||||
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;
|
||||
}
|
||||
|
||||
//0表示需要分配
|
||||
for (var i = 0; i < that.tasksData.length; i++) {
|
||||
if (that.tasksData[i].isAllocationOptional == 0) {
|
||||
that.tasksData[i].isAllocationOptional = true;
|
||||
} else {
|
||||
that.tasksData[i].isAllocationOptional = false;
|
||||
}
|
||||
if (that.tasksData[i].allocated == "true") {
|
||||
that.tasksData[i].allocated = true;
|
||||
} else {
|
||||
that.tasksData[i].allocated = false;
|
||||
}
|
||||
}
|
||||
|
||||
// 应用当前筛选(只应用分配状态筛选,搜索已由后端处理)
|
||||
let filtered = [...that.tasksData];
|
||||
if (that.currentFilter === 'need') {
|
||||
filtered = filtered.filter(item => item.isAllocationOptional === true);
|
||||
} else if (that.currentFilter === 'notNeed') {
|
||||
filtered = filtered.filter(item => item.isAllocationOptional === false);
|
||||
}
|
||||
that.filteredData = filtered;
|
||||
} else if (response.data.status === "401") {
|
||||
that.$alert(response.data.message);
|
||||
that.$router.push({ path: "/login" });
|
||||
} else {
|
||||
that.tasksData[i].isAllocationOptional = false;
|
||||
that.$message.error(response.data.message || "获取数据失败");
|
||||
}
|
||||
if (that.tasksData[i].allocated == "true") {
|
||||
that.tasksData[i].allocated = true;
|
||||
} else {
|
||||
that.tasksData[i].allocated = false;
|
||||
}
|
||||
}
|
||||
// 应用当前筛选和搜索
|
||||
that.applyFilter();
|
||||
}).catch(function (error) {
|
||||
console.error("获取数据失败:", error);
|
||||
that.$message.error("获取数据失败,请稍后重试");
|
||||
});
|
||||
|
||||
// 获取工作人员列表
|
||||
request({
|
||||
url: "/user/all_worker",
|
||||
method: "get",
|
||||
@@ -611,12 +687,21 @@ export default {
|
||||
|
||||
.search-box {
|
||||
flex: 0 0 auto;
|
||||
display: flex;
|
||||
align-items: center;
|
||||
gap: 12px;
|
||||
width: 450px;
|
||||
margin-bottom: 20px;
|
||||
}
|
||||
|
||||
:deep(.search-box .el-input) {
|
||||
width: 100%;
|
||||
flex: 1;
|
||||
}
|
||||
|
||||
.search-btn {
|
||||
flex-shrink: 0;
|
||||
padding: 0 20px;
|
||||
min-width: 80px;
|
||||
}
|
||||
|
||||
.forest-btn-small {
|
||||
@@ -657,6 +742,13 @@ export default {
|
||||
box-shadow: 0 14px 28px rgba(76, 175, 80, 0.12);
|
||||
}
|
||||
|
||||
.pagination-container {
|
||||
display: flex;
|
||||
justify-content: flex-end;
|
||||
margin-top: 20px;
|
||||
padding: 16px 0;
|
||||
}
|
||||
|
||||
:deep(#tableStyle .el-table__header-wrapper th) {
|
||||
background: linear-gradient(90deg, #e0f0e2, #f2fbf3) !important;
|
||||
color: #1b5e20 !important;
|
||||
@@ -708,18 +800,34 @@ export default {
|
||||
transform: translateY(-1px);
|
||||
}
|
||||
|
||||
:deep(#tableStyle .el-checkbox__input.is-checked .el-checkbox__inner) {
|
||||
/* Switch 组件样式 */
|
||||
:deep(#tableStyle .el-switch.is-checked .el-switch__core) {
|
||||
background-color: #4caf50 !important;
|
||||
border-color: #4caf50 !important;
|
||||
}
|
||||
|
||||
:deep(#tableStyle .el-checkbox__inner) {
|
||||
:deep(#tableStyle .el-switch__core) {
|
||||
border-color: rgba(129, 199, 132, 0.5) !important;
|
||||
background-color: #e0e0e0 !important;
|
||||
transition: all 0.3s ease !important;
|
||||
}
|
||||
|
||||
:deep(#tableStyle .el-checkbox__input.is-disabled.is-checked .el-checkbox__inner) {
|
||||
background-color: rgba(76, 175, 80, 0.5) !important;
|
||||
border-color: rgba(76, 175, 80, 0.5) !important;
|
||||
:deep(#tableStyle .el-switch.is-checked .el-switch__core::after) {
|
||||
background-color: #ffffff !important;
|
||||
}
|
||||
|
||||
:deep(#tableStyle .el-switch__core::after) {
|
||||
background-color: #ffffff !important;
|
||||
box-shadow: 0 2px 4px rgba(0, 0, 0, 0.15) !important;
|
||||
}
|
||||
|
||||
:deep(#tableStyle .el-switch:hover .el-switch__core) {
|
||||
border-color: rgba(76, 175, 80, 0.8) !important;
|
||||
}
|
||||
|
||||
:deep(#tableStyle .el-switch.is-checked:hover .el-switch__core) {
|
||||
background-color: #66bb6a !important;
|
||||
border-color: #66bb6a !important;
|
||||
}
|
||||
|
||||
.el-dropdown-link {
|
||||
|
||||
@@ -522,7 +522,7 @@ export default {
|
||||
border-radius: 20px;
|
||||
box-shadow: 0 14px 32px rgba(76, 175, 80, 0.12);
|
||||
border: 1px solid rgba(129, 199, 132, 0.25);
|
||||
}
|
||||
}
|
||||
|
||||
.toolbar-container {
|
||||
display: flex;
|
||||
|
||||
@@ -128,7 +128,15 @@ export default {
|
||||
tables: [],
|
||||
};
|
||||
this.$store.dispatch("updateData", { config: config1 });
|
||||
this.$router.push({ path: "/main" });
|
||||
// 检查当前路径,避免重复导航
|
||||
if (this.$route.path !== "/main") {
|
||||
this.$router.push({ path: "/main" }).catch(err => {
|
||||
// 忽略 NavigationDuplicated 错误
|
||||
if (err.name !== 'NavigationDuplicated') {
|
||||
console.error('路由导航错误:', err)
|
||||
}
|
||||
})
|
||||
}
|
||||
},
|
||||
addTable() {
|
||||
this.$router.push({
|
||||
@@ -252,7 +260,15 @@ export default {
|
||||
tables: [],
|
||||
};
|
||||
that.$store.dispatch("updateData", { config: config1 });
|
||||
that.$router.push({ path: "/main" });
|
||||
// 检查当前路径,避免重复导航
|
||||
if (that.$route.path !== "/main") {
|
||||
that.$router.push({ path: "/main" }).catch(err => {
|
||||
// 忽略 NavigationDuplicated 错误
|
||||
if (err.name !== 'NavigationDuplicated') {
|
||||
console.error('路由导航错误:', err)
|
||||
}
|
||||
})
|
||||
}
|
||||
that.$notify.success({
|
||||
title: "提示",
|
||||
message: "提交成功",
|
||||
@@ -309,7 +325,15 @@ export default {
|
||||
id: that.id,
|
||||
},
|
||||
}).then(function (response) {
|
||||
that.$router.push({ path: "/main" });
|
||||
// 检查当前路径,避免重复导航
|
||||
if (that.$route.path !== "/main") {
|
||||
that.$router.push({ path: "/main" }).catch(err => {
|
||||
// 忽略 NavigationDuplicated 错误
|
||||
if (err.name !== 'NavigationDuplicated') {
|
||||
console.error('路由导航错误:', err)
|
||||
}
|
||||
})
|
||||
}
|
||||
if (response.data.success) {
|
||||
that.$alert(response.data.message, "提示", {
|
||||
confirmButtonText: "确定",
|
||||
|
||||
@@ -8,15 +8,21 @@
|
||||
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-plus" @click="addRow()"
|
||||
>添加任务</el-button
|
||||
>
|
||||
>添加任务</el-button
|
||||
>
|
||||
<el-button class="forest-btn ghost" size="medium" icon="el-icon-upload" @click="addXml()"
|
||||
>导入xml文件</el-button
|
||||
>导入xml文件</el-button
|
||||
>
|
||||
</div>
|
||||
</div>
|
||||
@@ -124,6 +130,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-dialog
|
||||
v-dialogDrag
|
||||
class="taskDialog"
|
||||
@@ -244,8 +262,8 @@
|
||||
</div>
|
||||
<div class="dialog-footer">
|
||||
<el-button class="forest-btn" size="medium" @click="UploadXml()"
|
||||
>确认</el-button
|
||||
>
|
||||
>确认</el-button
|
||||
>
|
||||
</div>
|
||||
</el-dialog>
|
||||
</div>
|
||||
@@ -276,47 +294,106 @@ export default {
|
||||
fileList: [],
|
||||
searchKeyword: "", // 搜索关键词
|
||||
filteredData: [], // 过滤后的数据
|
||||
// 分页相关属性
|
||||
pageNum: 1,
|
||||
pageSize: 10,
|
||||
total: 0,
|
||||
totalPages: 0
|
||||
};
|
||||
},
|
||||
methods: {
|
||||
// 搜索处理方法
|
||||
// 搜索处理方法 - 搜索时重置到第一页并重新加载数据
|
||||
handleSearch() {
|
||||
if (!this.searchKeyword.trim()) {
|
||||
this.filteredData = [...this.xmlData];
|
||||
} else {
|
||||
const keyword = this.searchKeyword.toLowerCase();
|
||||
this.filteredData = this.xmlData.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();
|
||||
},
|
||||
|
||||
//读取数据库 初始化xml - 从 store 获取数据
|
||||
//读取数据库 初始化xml - 使用分页接口获取数据
|
||||
init() {
|
||||
let that = this;
|
||||
// 从 store 获取数据
|
||||
const taskData = that.$store.state.taskData.selectAll || [];
|
||||
that.xmlData = taskData;
|
||||
that.filteredData = [...that.xmlData]; // 初始化过滤数据
|
||||
for (var i = 0; i < that.xmlData.length; i++) {
|
||||
if (that.xmlData[i].hasCreateTables == 1) {
|
||||
that.xmlData[i].hasCreateTables = true;
|
||||
// 构建请求参数
|
||||
const params = {
|
||||
pageNum: that.pageNum,
|
||||
pageSize: that.pageSize,
|
||||
keyword: that.searchKeyword && that.searchKeyword.trim() ? that.searchKeyword.trim() : ''
|
||||
};
|
||||
|
||||
request({
|
||||
url: "/task/selectAllWithKeywordPaginated",
|
||||
method: "get",
|
||||
params: params
|
||||
}).then(function (response) {
|
||||
if (response.data.success === true) {
|
||||
// 解析 data 字段(可能是 JSON 字符串)
|
||||
let result;
|
||||
if (typeof response.data.data === 'string') {
|
||||
try {
|
||||
result = JSON.parse(response.data.data);
|
||||
} catch (e) {
|
||||
console.error("解析数据失败:", e);
|
||||
that.$message.error("数据格式错误,请稍后重试");
|
||||
return;
|
||||
}
|
||||
} else {
|
||||
result = response.data.data;
|
||||
}
|
||||
|
||||
// 从返回的数据结构中提取数据数组和分页信息
|
||||
that.xmlData = 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;
|
||||
}
|
||||
|
||||
// 处理数据格式转换
|
||||
for (var i = 0; i < that.xmlData.length; i++) {
|
||||
if (that.xmlData[i].hasCreateTables == 1) {
|
||||
that.xmlData[i].hasCreateTables = true;
|
||||
} else {
|
||||
that.xmlData[i].hasCreateTables = false;
|
||||
}
|
||||
if (
|
||||
that.xmlData[i].isReviewerRestricted == 1 ||
|
||||
that.xmlData[i].isReviewerRestricted == true
|
||||
) {
|
||||
that.xmlData[i].isReviewerRestricted = true;
|
||||
} else {
|
||||
that.xmlData[i].isReviewerRestricted = false;
|
||||
}
|
||||
}
|
||||
|
||||
that.filteredData = [...that.xmlData];
|
||||
} else if (response.data.status === "401") {
|
||||
that.$alert(response.data.message);
|
||||
that.$router.push({ path: "/login" });
|
||||
} else {
|
||||
that.xmlData[i].hasCreateTables = false;
|
||||
that.$message.error(response.data.message || "获取数据失败");
|
||||
}
|
||||
if (
|
||||
that.xmlData[i].isReviewerRestricted == 1 ||
|
||||
that.xmlData[i].isReviewerRestricted == true
|
||||
) {
|
||||
that.xmlData[i].isReviewerRestricted = true;
|
||||
} else {
|
||||
that.xmlData[i].isReviewerRestricted = false;
|
||||
}
|
||||
}
|
||||
}).catch(function (error) {
|
||||
console.error("获取数据失败:", error);
|
||||
that.$message.error("获取数据失败,请稍后重试");
|
||||
});
|
||||
},
|
||||
// 修改方法参数,从index改为id
|
||||
changeRestricted(id, val) {
|
||||
@@ -487,6 +564,7 @@ export default {
|
||||
title: "提示",
|
||||
message: "创建成功",
|
||||
});
|
||||
// 重新加载当前页数据
|
||||
that.init();
|
||||
} else if (response.data.message == "hasCreated") {
|
||||
that.$confirm("该任务已经创库,是否重新创库?", "提示", {
|
||||
@@ -593,7 +671,7 @@ export default {
|
||||
return;
|
||||
}
|
||||
if (!this.xmlform.xmlkey) {
|
||||
that.$alert("请输入数据库名称!", "提示", {
|
||||
this.$alert("请输入数据库名称!", "提示", {
|
||||
confirmButtonText: "确定",
|
||||
});
|
||||
return;
|
||||
@@ -722,11 +800,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 {
|
||||
@@ -961,6 +1048,13 @@ export default {
|
||||
text-align: right;
|
||||
margin-top: 12px;
|
||||
}
|
||||
|
||||
.pagination-container {
|
||||
display: flex;
|
||||
justify-content: flex-end;
|
||||
margin-top: 20px;
|
||||
padding: 16px 0;
|
||||
}
|
||||
</style>
|
||||
|
||||
<style>
|
||||
|
||||
@@ -209,9 +209,25 @@ export default {
|
||||
sessionStorage.getItem("access-user") == "SuperAdmin" ||
|
||||
sessionStorage.getItem("access-user") == "Leader"
|
||||
) {
|
||||
that.$router.push({ path: "/view" });
|
||||
// 检查当前路径,避免重复导航
|
||||
if (that.$route.path !== "/view") {
|
||||
that.$router.push({ path: "/view" }).catch(err => {
|
||||
// 忽略 NavigationDuplicated 错误
|
||||
if (err.name !== 'NavigationDuplicated') {
|
||||
console.error('路由导航错误:', err)
|
||||
}
|
||||
})
|
||||
}
|
||||
} else if (sessionStorage.getItem("access-user") == "Operator") {
|
||||
that.$router.push({ path: "/main" });
|
||||
// 检查当前路径,避免重复导航
|
||||
if (that.$route.path !== "/main") {
|
||||
that.$router.push({ path: "/main" }).catch(err => {
|
||||
// 忽略 NavigationDuplicated 错误
|
||||
if (err.name !== 'NavigationDuplicated') {
|
||||
console.error('路由导航错误:', err)
|
||||
}
|
||||
})
|
||||
}
|
||||
} else {
|
||||
that.$notify.error({
|
||||
title: "提示",
|
||||
|
||||
@@ -150,6 +150,12 @@ const router = new VueRouter({
|
||||
routes
|
||||
})
|
||||
router.beforeEach(async (to, from, next) => {
|
||||
// 如果目标路径与当前路径相同,直接放行,避免 NavigationDuplicated 错误
|
||||
if (to.path === from.path) {
|
||||
next()
|
||||
return
|
||||
}
|
||||
|
||||
if (to.path.startsWith('/login')) {
|
||||
window.sessionStorage.removeItem('access-user')
|
||||
window.sessionStorage.removeItem('access-id')
|
||||
|
||||
Reference in New Issue
Block a user