From 014e6dc2998e90760d8cca8309ba43969d2493a7 Mon Sep 17 00:00:00 2001 From: wxlong Date: Fri, 28 Nov 2025 14:46:02 +0800 Subject: [PATCH] =?UTF-8?q?20251128API:selectAllWithTableName/selectAll/se?= =?UTF-8?q?lectTaskHasCreated=E6=8F=90=E5=89=8D=E7=BC=93=E5=AD=98?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- index.html | 2 +- src/App.vue | 61 +++++++++++- src/assets/css/common.scss | 2 +- src/assets/css/main.css | 26 +++++ src/components/Analysis/analysisPage.vue | 42 +++----- .../DataManagement/DataManagement.vue | 26 ++--- src/components/DataManagement/featureInfo.vue | 15 +-- src/components/Home.vue | 1 + src/components/Statistic/statPage.vue | 26 ++--- src/components/Supervision/ViewTask.vue | 62 ++++-------- .../TaskManagement/manage/DataManage.vue | 25 ++--- .../TaskManagement/manage/ManualAllocate.vue | 32 +++--- .../TaskManagement/manage/TaskManage.vue | 44 ++++----- src/components/TaskManagement/xml/main.vue | 47 ++++----- src/components/login/login.vue | 77 +++++++++++---- src/components/vuex/store.js | 99 ++++++++++++++++++- src/router/index.js | 57 ++++++++++- 17 files changed, 415 insertions(+), 229 deletions(-) diff --git a/index.html b/index.html index b32f4ec..be532e1 100644 --- a/index.html +++ b/index.html @@ -131,7 +131,7 @@ diff --git a/src/assets/css/common.scss b/src/assets/css/common.scss index 14b3119..44823ea 100644 --- a/src/assets/css/common.scss +++ b/src/assets/css/common.scss @@ -554,7 +554,7 @@ overflow-y: scroll; height: calc(100% - 70px); - padding: 20px 24px; + padding: 8px 8px; width: 420px; box-shadow: 0 15px 35px rgba(76, 175, 80, 0.14), inset 0 1px 0 rgba(255, 255, 255, 0.6); backdrop-filter: blur(4px); diff --git a/src/assets/css/main.css b/src/assets/css/main.css index 7301240..af1c141 100644 --- a/src/assets/css/main.css +++ b/src/assets/css/main.css @@ -135,6 +135,7 @@ ul { float: right; text-align: left; font-size: 15px; + font-weight: bold !important; border-left: 0px solid #000; z-index: 999; margin-right: 0px; @@ -157,6 +158,7 @@ ul { width: 140px; text-align: center; color: #2E7D32 !important; + font-weight: bold !important; transition: all 0.3s ease; } @@ -447,6 +449,29 @@ el-aside.tac.el-menu-item, border-radius: 0 0 14px 14px !important; } +/* el-scrollbar 最大宽度设置,超出部分隐藏 */ +.el-scrollbar { + max-width: 480px !important; + overflow-x: hidden !important; + overflow-y: auto !important; +} + +.el-scrollbar__wrap { + max-width: 480px !important; + overflow-x: hidden !important; + overflow-y: auto !important; +} + +.el-scrollbar__view { + max-width: 480px !important; + overflow-x: hidden !important; +} + +/* 隐藏横向滚动条 */ +.el-scrollbar__bar.is-horizontal { + display: none !important; +} + .el-input__inner { height: 35px !important; } @@ -549,6 +574,7 @@ el-aside.tac.el-menu-item, .container .topbar-wrap .topbar-title { margin-right: 0px; height: 70px; + font-weight: bold !important; } } diff --git a/src/components/Analysis/analysisPage.vue b/src/components/Analysis/analysisPage.vue index ea1a614..d0b1d0f 100644 --- a/src/components/Analysis/analysisPage.vue +++ b/src/components/Analysis/analysisPage.vue @@ -770,32 +770,22 @@ export default { this.wTaskOptions = []; let that = this; - request({ - url: "/task/selectTaskHasCreated", - method: "get", - }).then(function (response) { - if (response.data.success == true) { - var jsondata = JSON.parse(response.data.data); - var options = jsondata.data; - for (var i = 0; i < options.length; i++) { - that.reportoptions.push({ - value: options[i].id, - label: options[i].taskName, - }); - that.taskoptions.push({ - value: options[i].id, - label: options[i].taskName, - }); - that.wTaskOptions.push({ - value: options[i].id, - label: options[i].taskName, - }); - } - } else if (response.data.status == "401") { - that.$alert(response.data.message); - that.$router.push({ path: "/login" }); - } - }); + // 从 store 获取数据 + const taskData = that.$store.state.taskData.selectTaskHasCreated || []; + for (var i = 0; i < taskData.length; i++) { + that.reportoptions.push({ + value: taskData[i].id, + label: taskData[i].taskName, + }); + that.taskoptions.push({ + value: taskData[i].id, + label: taskData[i].taskName, + }); + that.wTaskOptions.push({ + value: taskData[i].id, + label: taskData[i].taskName, + }); + } }, getWarningTables() { if (this.warningform.task != "") { diff --git a/src/components/DataManagement/DataManagement.vue b/src/components/DataManagement/DataManagement.vue index f38cc39..ee8548b 100644 --- a/src/components/DataManagement/DataManagement.vue +++ b/src/components/DataManagement/DataManagement.vue @@ -363,24 +363,14 @@ export default { getTasks () { this.taskoptions = [] let that = this - request({ - url: '/task/selectTaskHasCreated', - method: 'get' - }).then(function (response) { - if (response.data.success === true) { - var jsondata = JSON.parse(response.data.data) - var options = jsondata.data - for (var i = 0; i < options.length; i++) { - that.taskoptions.push({ - value: options[i].id, - label: options[i].taskName - }) - } - } else if (response.data.status === '401') { - that.$alert(response.data.message) - that.$router.push({path: '/login'}) - } - }) + // 从 store 获取数据 + const taskData = that.$store.state.taskData.selectTaskHasCreated || [] + for (var i = 0; i < taskData.length; i++) { + that.taskoptions.push({ + value: taskData[i].id, + label: taskData[i].taskName + }) + } }, getTables () { if (this.task === '') { diff --git a/src/components/DataManagement/featureInfo.vue b/src/components/DataManagement/featureInfo.vue index 4065bce..f69e2dd 100644 --- a/src/components/DataManagement/featureInfo.vue +++ b/src/components/DataManagement/featureInfo.vue @@ -551,8 +551,8 @@ export default { display: flex; align-items: center; justify-content: center; - min-height: 400px; - margin-bottom: 20px; + height: 270px; + margin-bottom: 0px; width: 100%; overflow: visible; } @@ -564,7 +564,7 @@ export default { align-items: center; justify-content: center; max-width: 100%; - min-height: 400px; + height: 270px; z-index: 1; } @@ -633,16 +633,17 @@ export default { .thumbnail-nav { display: flex; - gap: 12px; + gap: 8px; justify-content: center; flex-wrap: wrap; - padding: 10px 0; + padding: 4px 0; + height: 60px; border-top: 1px solid rgba(129, 199, 132, 0.3); } .thumbnail-item { - width: 80px; - height: 80px; + width: 72px; + height: 48px; border-radius: 8px; overflow: hidden; border: 2px solid transparent; diff --git a/src/components/Home.vue b/src/components/Home.vue index 1eb1bf4..4ca4aaa 100644 --- a/src/components/Home.vue +++ b/src/components/Home.vue @@ -129,6 +129,7 @@ export default { } .topbar-title .el-menu--horizontal > .el-menu-item { + font-weight: bold !important; height: 50px; line-height: 70px; width: 114px; diff --git a/src/components/Statistic/statPage.vue b/src/components/Statistic/statPage.vue index c06aeb8..2afc3ba 100644 --- a/src/components/Statistic/statPage.vue +++ b/src/components/Statistic/statPage.vue @@ -523,24 +523,14 @@ export default { getTasks1() { this.stattaskoptions = []; let that = this; - request({ - url: "/task/selectTaskHasCreated", - method: "get", - }).then(function (response) { - if (response.data.success == true) { - var jsondata = JSON.parse(response.data.data); - var options = jsondata.data; - for (var i = 0; i < options.length; i++) { - that.stattaskoptions.push({ - value: options[i].id, - label: options[i].taskName, - }); - } - } else if (response.data.status == "401") { - that.$alert(response.data.message); - that.$router.push({ path: "/login" }); - } - }); + // 从 store 获取数据 + const taskData = that.$store.state.taskData.selectTaskHasCreated || []; + for (var i = 0; i < taskData.length; i++) { + that.stattaskoptions.push({ + value: taskData[i].id, + label: taskData[i].taskName, + }); + } }, getTables1() { if (this.stattask === "") { diff --git a/src/components/Supervision/ViewTask.vue b/src/components/Supervision/ViewTask.vue index 70bb450..161ec65 100644 --- a/src/components/Supervision/ViewTask.vue +++ b/src/components/Supervision/ViewTask.vue @@ -1476,37 +1476,24 @@ export default { }); this.map.addOverlay(this.trackLayerOverLay); }, - // 初始化任务清单 + // 初始化任务清单 - 从 store 获取数据 initList() { that.routelist = []; that.routelist2 = []; - // 连接后台测试: - request({ - url: "/task/selectAllWithTableName", - method: "get", - }) - .then(function (response) { - if (response.data.status == "401") { - that.$alert(response.data.message); - that.$router.push({ path: "/login" }); - } else { - // 把数据装入下拉菜单中 - for (let i = 0; i < response.data.data.length; i++) { - let newData = { - value: response.data.data[i].databaseName, - label: response.data.data[i].taskName, - id: response.data.data[i].id, - tableNames: response.data.data[i].tableNames, - }; - that.routelist.push(newData); - that.list.push(newData); - that.routelist2.push(newData); - } - } - }) - .catch(function (err) { - console.log(err); - }); + // 从 store 获取数据 + const taskData = that.$store.state.taskData.selectAllWithTableName || []; + // 把数据装入下拉菜单中 + for (let i = 0; i < taskData.length; i++) { + 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); + } }, // 左侧面板收缩动画 collapse() { @@ -4785,20 +4772,11 @@ export default { }, }, mounted() { - api - .getAllTask() - .then((res) => { - if (res.data.status == "401") { - that.$alert(response.data.message); - that.$router.push({ path: "/login" }); - } - that.taskList = JSON.parse(res.data).data; - if (that.taskList.length) that.listQuery.taskId = that.taskList[0].id; - that.chooseTask(that.listQuery.taskId); - }) - .catch((error) => { - this.$message.error(error); - }); + // 从 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); }, watch: { activeItem: { diff --git a/src/components/TaskManagement/manage/DataManage.vue b/src/components/TaskManagement/manage/DataManage.vue index c379781..e3601c3 100644 --- a/src/components/TaskManagement/manage/DataManage.vue +++ b/src/components/TaskManagement/manage/DataManage.vue @@ -792,25 +792,12 @@ export default { // }, init() { let that = this; - // 请求任务列表 - that.tasksData = []; - that.srcTaskOptions = []; - that.destTaskOptions = []; - request({ - url: "/task/selectTaskHasCreated", - method: "get", - }).then(function (response) { - if (response.data.success == true) { - var jsondata = JSON.parse(response.data.data); - that.tasksData = jsondata.data; - that.filteredData = [...that.tasksData]; // 初始化过滤数据 - that.srcTaskOptions = jsondata.data; - that.destTaskOptions = jsondata.data; - } else if (response.data.status == "401") { - that.$alert(response.data.message); - that.$router.push({ path: "/login" }); - } - }); + // 从 store 获取数据 + const taskData = that.$store.state.taskData.selectTaskHasCreated || []; + that.tasksData = taskData; + that.filteredData = [...that.tasksData]; // 初始化过滤数据 + that.srcTaskOptions = taskData; + that.destTaskOptions = taskData; }, beforeTpkUpload(file) { if (file.type != "tpk") { diff --git a/src/components/TaskManagement/manage/ManualAllocate.vue b/src/components/TaskManagement/manage/ManualAllocate.vue index a94fbda..14edc97 100644 --- a/src/components/TaskManagement/manage/ManualAllocate.vue +++ b/src/components/TaskManagement/manage/ManualAllocate.vue @@ -765,27 +765,19 @@ export default { } else { let geojsonObject = result.data.data; this.drawgridLayer(geojsonObject, flag, isRedraw); - request({ - url: "/task/selectAllWithTableName", - method: "get", - }).then((response) => { - if (response.data.status == "401") { - this.$alert(response.data.message); - this.$router.push({ path: "/login" }); - } else { - // 把数据装入查看表的下拉菜单中 - let temp = response.data.data; - let current = temp.find((item) => { - return item.id == this.taskId; - }); - this.taskValue = { - value: current.databaseName, - label: current.taskName, - id: current.id, - tableNames: current.tableNames, - }; - } + // 从 store 获取数据 + const taskData = this.$store.state.taskData.selectAllWithTableName || []; + let current = taskData.find((item) => { + return item.id == this.taskId; }); + if (current) { + this.taskValue = { + value: current.databaseName, + label: current.taskName, + id: current.id, + tableNames: current.tableNames, + }; + } } }) .catch((error) => { diff --git a/src/components/TaskManagement/manage/TaskManage.vue b/src/components/TaskManagement/manage/TaskManage.vue index 6e032a2..42c627f 100644 --- a/src/components/TaskManagement/manage/TaskManage.vue +++ b/src/components/TaskManagement/manage/TaskManage.vue @@ -370,34 +370,24 @@ export default { }, init() { let that = this; - // 请求任务列表 - request({ - url: "/task/selectTaskHasCreated", - method: "get", - }).then(function (response) { - if (response.data.success == true) { - var jsondata = JSON.parse(response.data.data); - that.tasksData = jsondata.data; - //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; - } - } - // 应用当前筛选和搜索 - that.applyFilter(); - } else if (response.data.status == "401") { - that.$alert(response.data.message); - that.$router.push({ path: "/login" }); + // 从 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; + } else { + that.tasksData[i].isAllocationOptional = false; } - }); + if (that.tasksData[i].allocated == "true") { + that.tasksData[i].allocated = true; + } else { + that.tasksData[i].allocated = false; + } + } + // 应用当前筛选和搜索 + that.applyFilter(); request({ url: "/user/all_worker", method: "get", diff --git a/src/components/TaskManagement/xml/main.vue b/src/components/TaskManagement/xml/main.vue index 36be1ad..69c5800 100644 --- a/src/components/TaskManagement/xml/main.vue +++ b/src/components/TaskManagement/xml/main.vue @@ -295,37 +295,28 @@ export default { } }, - //读取数据库 初始化xml + //读取数据库 初始化xml - 从 store 获取数据 init() { let that = this; - request({ - url: "/task/selectAll", - method: "get", - }).then(function (response) { - if (response.data.success == true) { - var jsondata = JSON.parse(response.data.data); - that.xmlData = jsondata.data; - that.filteredData = [...that.xmlData]; // 初始化过滤数据 - 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; - } - } - } else if (response.data.status == "401") { - that.$alert(response.data.message); - that.$router.push({ path: "/login" }); + // 从 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; + } 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; + } + } }, // 修改方法参数,从index改为id changeRestricted(id, val) { diff --git a/src/components/login/login.vue b/src/components/login/login.vue index dfcff9d..f1fd70a 100644 --- a/src/components/login/login.vue +++ b/src/components/login/login.vue @@ -72,14 +72,33 @@ v20251113betav20251006 + + + +
+ +

{{ initErrorMessage }}

+
+
+ 重试 +
+
diff --git a/src/components/vuex/store.js b/src/components/vuex/store.js index 82950e7..fe07f4e 100644 --- a/src/components/vuex/store.js +++ b/src/components/vuex/store.js @@ -1,5 +1,6 @@ import Vue from 'vue' import Vuex from 'vuex' +import { ajax as request } from "@/request.js"; Vue.use(Vuex) export const store = new Vuex.Store({ @@ -15,7 +16,17 @@ export const store = new Vuex.Store({ LocalLocation: { currentPosition: '', currentLocation: '' - } + }, + // 登录后初始化的任务数据 + taskData: { + selectAllWithTableName: [], // /api/task/selectAllWithTableName 的数据 + selectAll: [], // /api/task/selectAll/ 的数据 + selectTaskHasCreated: [] // /api/task/selectTaskHasCreated 的数据 + }, + // 初始化状态 + taskDataInitialized: false, + taskDataInitializing: false, + initError: null // 初始化错误信息 }, mutations: { updateDrawtool(state, drawtool) { @@ -63,6 +74,28 @@ export const store = new Vuex.Store({ }, updatePosition(state, position) { state.LocalLocation.currentPosition = position + }, + // 设置任务数据 + setTaskDataSelectAllWithTableName(state, data) { + state.taskData.selectAllWithTableName = data + }, + setTaskDataSelectAll(state, data) { + state.taskData.selectAll = data + }, + setTaskDataSelectTaskHasCreated(state, data) { + state.taskData.selectTaskHasCreated = data + }, + setTaskDataInitialized(state, value) { + state.taskDataInitialized = value + }, + setTaskDataInitializing(state, value) { + state.taskDataInitializing = value + }, + setInitError(state, error) { + state.initError = error + }, + clearInitError(state) { + state.initError = null } }, @@ -87,6 +120,70 @@ export const store = new Vuex.Store({ }, updatePosition({ commit, state }, obj) { commit("updatePosition", obj.position) + }, + // 初始化任务数据 + async initTaskData({ commit, state }) { + commit('setTaskDataInitializing', true) + commit('setTaskDataInitialized', false) + + try { + // 调用3个接口 + const [response1, response2, response3] = await Promise.all([ + request({ + url: "/task/selectAllWithTableName", + method: "get", + }), + request({ + url: "/task/selectAll/", + method: "get", + }), + request({ + url: "/task/selectTaskHasCreated", + method: "get", + }) + ]) + + // 检查是否有401错误 + if (response1.data.status == "401" || response2.data.status == "401" || response3.data.status == "401") { + throw new Error("认证失败,请重新登录") + } + + // 处理第一个接口的数据 + let data1 = response1.data.data || [] + commit('setTaskDataSelectAllWithTableName', data1) + + // 处理第二个接口的数据 + let data2 = [] + if (response2.data.success == true && response2.data.data) { + try { + const parsed = JSON.parse(response2.data.data) + data2 = parsed.data || [] + } catch (e) { + data2 = response2.data.data || [] + } + } + commit('setTaskDataSelectAll', data2) + + // 处理第三个接口的数据 + let data3 = [] + if (response3.data.success == true && response3.data.data) { + try { + const parsed = JSON.parse(response3.data.data) + data3 = parsed.data || [] + } catch (e) { + data3 = response3.data.data || [] + } + } + commit('setTaskDataSelectTaskHasCreated', data3) + + commit('setTaskDataInitialized', true) + commit('setTaskDataInitializing', false) + return { success: true } + } catch (error) { + commit('setTaskDataInitialized', false) + commit('setTaskDataInitializing', false) + return { success: false, error: error.message || '初始化失败,请重试' } + } } }, diff --git a/src/router/index.js b/src/router/index.js index d1d31d9..2cc1877 100644 --- a/src/router/index.js +++ b/src/router/index.js @@ -1,5 +1,6 @@ import Vue from 'vue' import VueRouter from 'vue-router' +import { store } from '@/components/vuex/store' const Home = () => import('@/components/Home') const ViewTask = () => import('@/components/Supervision/ViewTask') const statPage = () => import('@/components/Statistic/statPage') @@ -148,21 +149,73 @@ const routes = [ const router = new VueRouter({ routes }) -router.beforeEach((to, from, next) => { +router.beforeEach(async (to, from, next) => { if (to.path.startsWith('/login')) { window.sessionStorage.removeItem('access-user') window.sessionStorage.removeItem('access-id') + // 清除初始化状态 + store.commit('setTaskDataInitialized', false) + store.commit('clearInitError') next() } else if (to.path.startsWith('/register') || to.path.startsWith('/modifypassword') || to.path.startsWith('/forgetpassword') || to.path.startsWith('/addinfo')) { window.sessionStorage.removeItem('access-user') window.sessionStorage.removeItem('access-id') + // 清除初始化状态 + store.commit('setTaskDataInitialized', false) + store.commit('clearInitError') next() } else { let user = window.sessionStorage.getItem('access-user') === '' ? false : window.sessionStorage.getItem('access-user') if (!user) { next({ path: '/login' }) } else { - next() + // 检查数据是否已初始化 + const isInitialized = store.state.taskDataInitialized + const isInitializing = store.state.taskDataInitializing + + // 如果数据未初始化且不在初始化中,则进行初始化 + if (!isInitialized && !isInitializing) { + try { + const result = await store.dispatch('initTaskData') + if (result.success) { + // 初始化成功,继续路由 + next() + } else { + // 初始化失败,显示错误提示并阻止路由 + store.commit('setInitError', result.error) + // 阻止路由跳转,显示错误对话框 + next(false) + } + } catch (error) { + // 初始化异常 + store.commit('setInitError', error.message || '初始化失败,请重试') + next(false) + } + } else if (isInitializing) { + // 正在初始化中,等待完成(最多等待5秒) + let waited = 0 + const maxWait = 5000 + const checkInterval = setInterval(() => { + waited += 100 + if (!store.state.taskDataInitializing || waited >= maxWait) { + clearInterval(checkInterval) + if (store.state.taskDataInitialized) { + next() + } else { + if (waited >= maxWait) { + store.commit('setTaskDataInitializing', false) + store.commit('setInitError', '初始化超时,请重试') + } else { + store.commit('setInitError', '初始化失败,请重试') + } + next(false) + } + } + }, 100) + } else { + // 已初始化,继续路由 + next() + } } } })