From f9e459cabed0617fe44f483f6442fa53306d07c5 Mon Sep 17 00:00:00 2001
From: xuhuajiao <13476289682@163.com>
Date: Tue, 16 Jun 2026 16:03:49 +0800
Subject: [PATCH] ssologin
---
src/router/index.js | 2 +-
src/router/routers.js | 4 +-
src/utils/request.js | 5 +-
.../collectionLibrary/index.vue | 65 ++++-
.../module/collectHeader.vue | 29 +++
src/views/features/403.vue | 90 -------
src/views/features/ssoLogin.vue | 223 ++++++++++++++++++
7 files changed, 322 insertions(+), 96 deletions(-)
delete mode 100644 src/views/features/403.vue
create mode 100644 src/views/features/ssoLogin.vue
diff --git a/src/router/index.js b/src/router/index.js
index 619dc0d..3e143d9 100644
--- a/src/router/index.js
+++ b/src/router/index.js
@@ -9,7 +9,7 @@ import { filterAsyncRouter } from '@/store/modules/permission'
NProgress.configure({ showSpinner: false })// NProgress Configuration
-const whiteList = ['/login']// no redirect whitelist
+const whiteList = ['/login', '/ssoLogin']// no redirect whitelist
router.beforeEach((to, from, next) => {
if (to.meta.title) {
diff --git a/src/router/routers.js b/src/router/routers.js
index 47ddee9..6ec1026 100644
--- a/src/router/routers.js
+++ b/src/router/routers.js
@@ -21,8 +21,8 @@ export const constantRouterMap = [
hidden: true
},
{
- path: '/403',
- component: (resolve) => require(['@/views/features/403'], resolve),
+ path: '/ssoLogin',
+ component: (resolve) => require(['@/views/features/ssoLogin'], resolve),
hidden: true
},
{
diff --git a/src/utils/request.js b/src/utils/request.js
index 9e5e59f..77a04ed 100644
--- a/src/utils/request.js
+++ b/src/utils/request.js
@@ -27,7 +27,10 @@ service.interceptors.request.use(
if (getToken()) {
config.headers['Authorization'] = getToken() // 让每个请求携带自定义token 请根据实际情况自行修改
}
- config.headers['Content-Type'] = 'application/json'
+ // 只在没有设置 Content-Type 时才设置默认值
+ if (!config.headers['Content-Type']) {
+ config.headers['Content-Type'] = 'application/json'
+ }
return config
},
error => {
diff --git a/src/views/collectReorganizi/collectionLibrary/index.vue b/src/views/collectReorganizi/collectionLibrary/index.vue
index 11ae5fd..549701e 100644
--- a/src/views/collectReorganizi/collectionLibrary/index.vue
+++ b/src/views/collectReorganizi/collectionLibrary/index.vue
@@ -193,9 +193,17 @@ export default {
filterData(data) {
return data.filter(node => {
if (node.children && node.children.length > 0) {
- node.children = this.filterData(node.children) // 递归处理子节点
+ // 在递归前,收集子节点中 isType === 3 的 id
+ const typeThreeIds = node.children
+ .filter(child => child.isType === 3)
+ .map(child => child.id)
+ if (typeThreeIds.length > 0) {
+ node.typeThreeId = typeThreeIds
+ }
+ // 递归处理子节点
+ node.children = this.filterData(node.children)
}
- return node.isType !== 3 // 过滤掉isType为3的节点
+ return node.isType !== 3
})
},
// 逆归实现 获取指定元素
@@ -276,6 +284,11 @@ export default {
},
[CRUD.HOOK.afterRefresh]() {
this.crud.data = this.filterData(this.transformData(this.crud.data))
+ console.log('this.crud.data', this.crud.data)
+
+ // 读取 SSO 数据,自动选中节点
+ this.handleSSOData()
+
this.$nextTick(() => {
let currentKey
if (localStorage.getItem('currentArchivesKey') !== null) {
@@ -313,6 +326,54 @@ export default {
}
})
},
+ handleSSOData() {
+ const ssoDataStr = localStorage.getItem('ssoData')
+ if (!ssoDataStr) return
+
+ const ssoData = JSON.parse(ssoDataStr)
+ const { categoryId, fondsId } = ssoData
+
+ if (!categoryId || !fondsId) return
+
+ // 1. 找到顶级节点(全宗)
+ const topLevelNode = this.findTopLevelNode(this.crud.data, fondsId)
+ if (!topLevelNode) return
+
+ // 2. 递归查找包含该 categoryId 的父节点(typeThreeId 中包含 categoryId)
+ const targetNode = this.findNodeByTypeThreeId(topLevelNode.children, categoryId)
+ if (!targetNode) return
+
+ // 3. 构建 currentKey 对象
+ const currentKey = {
+ id: targetNode.id,
+ fondsId: fondsId,
+ isType: targetNode.isType,
+ fondName: topLevelNode.fondName,
+ fondsNo: topLevelNode.fondsNo,
+ arrangeType: targetNode.arrangeType,
+ code: targetNode.code
+ }
+
+ // 4. 存储到 localStorage,覆盖默认设置
+ localStorage.setItem('currentArchivesKey', JSON.stringify(currentKey))
+
+ // 注意:不删除 ssoData,让 collectHeader.vue 处理完 archiveNo 检索后再删除
+ },
+ // 根据 typeThreeId 查找节点
+ findNodeByTypeThreeId(tree, categoryId) {
+ for (const node of tree) {
+ // 如果当前节点的 typeThreeId 包含目标 categoryId
+ if (node.typeThreeId && node.typeThreeId.includes(categoryId)) {
+ return node
+ }
+ // 递归查找子节点
+ if (node.children && node.children.length > 0) {
+ const res = this.findNodeByTypeThreeId(node.children, categoryId)
+ if (res) return res
+ }
+ }
+ return null
+ },
defaultSetting(currentKey) {
if (this.crud.data[0].isType === 0) {
currentKey = this.findNode(this.crud.data[0].children, (node) => {
diff --git a/src/views/collectReorganizi/collectionLibrary/module/collectHeader.vue b/src/views/collectReorganizi/collectionLibrary/module/collectHeader.vue
index ae88fd5..f971db0 100644
--- a/src/views/collectReorganizi/collectionLibrary/module/collectHeader.vue
+++ b/src/views/collectReorganizi/collectionLibrary/module/collectHeader.vue
@@ -636,8 +636,37 @@ export default {
// this.restoreAdvancedSearchConditions()
this.getInitArchivesClass()
this.getCategoryDataTree()
+
+ // 读取 SSO 的 archiveNo 并自动检索
+ this.handleSSOArchiveNo()
},
methods: {
+ handleSSOArchiveNo() {
+ const ssoDataStr = localStorage.getItem('ssoData')
+ if (!ssoDataStr) return
+
+ const ssoData = JSON.parse(ssoDataStr)
+ const { archiveNo } = ssoData
+
+ if (!archiveNo) {
+ // 如果没有 archiveNo,也清理 ssoData
+ localStorage.removeItem('ssoData')
+ return
+ }
+
+ // 设置搜索关键词
+ this.query.search = archiveNo
+
+ // 等待页面初始化完成后执行搜索
+ this.$nextTick(() => {
+ this.handleSearch(this.collectLevel)
+
+ // 搜索完成后清理 ssoData,避免下次刷新重复触发
+ setTimeout(() => {
+ localStorage.removeItem('ssoData')
+ }, 2000)
+ })
+ },
// 从 localStorage 恢复高级检索条件
restoreAdvancedSearchConditions() {
const savedConditions = localStorage.getItem('advancedSearchConditions')
diff --git a/src/views/features/403.vue b/src/views/features/403.vue
deleted file mode 100644
index 44d2782..0000000
--- a/src/views/features/403.vue
+++ /dev/null
@@ -1,90 +0,0 @@
-
-
-
-
-
-
- Oops!
-
- 你没有权限去该页面
-
-
-
-
-
-
-
-
-
-
-
-
diff --git a/src/views/features/ssoLogin.vue b/src/views/features/ssoLogin.vue
new file mode 100644
index 0000000..4b9f073
--- /dev/null
+++ b/src/views/features/ssoLogin.vue
@@ -0,0 +1,223 @@
+
+
+
+
+
+
+
+
+
+
+
+
✕
+
登录失败
+
{{ message }}
+
+
+
+
+
+
+
+
+