feat(frontend): 管理端改用 Gi Admin Pro 框架 + 腾讯云主题

前端此前只有本地实现、从未入库,本次首次纳入版本管理。

框架切换
  · 以 Gi Admin Pro(Vue3 + Vite + TS + Arco Design Vue + Pinia)为底
  · 剥离 14 个演示页面目录 / 121 个文件(demo 28、file 20、form 19、system 18…)
  · 依赖 dependencies 35 → 19,devDependencies 31 → 27
  · 保留框架核心:layout、Gi* 组件库、hooks、权限指令、错误页、登录页

主题:腾讯云 / TDesign 官方色板
  · 主色 #0052D9(腾讯蓝)、成功 #00A870、警告 #ED7B2F、危险 #E34D59
  · 页面底色 #f3f3f3、文字 rgba(0,0,0,90/60/40/26%)
  · 覆盖 Arco 底层色板 + 显式语义别名(primary/success/warning/danger/link/neutral)
  · 三个改了不生效也不报错的坑已记入注释:
      1) Arco 色值是逗号分隔 RGB 三元组,不是 #RRGGBB
      2) Arco 把色板定义在 body 而非 :root,必须写 `:root, body`
      3) setting.json 的 themeColor 会以内联样式写进 body,优先级高于样式表

对接后端(三处契约差异在 @/utils/http 统一适配)
  · 响应信封 {code,msg,data} → {code,success,message,data}
  · Token 头 token → Authorization: Bearer
  · 分页 {list,total} → 补一份 records,list 原样保留
  · 40101 → 登录页;登录密码 RSA 加密(公钥走 /auth/public-key,轮换无需重建前端)
  · 路由:后端只下发菜单键,前端在本地路由表上过滤(有哪些页面归代码,谁能看归后端)

已实现页面(浏览器实测通过)
  · 登录:RSA 加密 + 自适应验证码/租户码 + 账号锁定提示
  · 工作台:真实数据(组织 6 个 / 角色 1 个 / 权限 25 项)
  · 组织架构:三级树 + CRUD + 占用校验
  · 租户管理:开通租户 + 初始密码只显示一次的强确认
  · 待建页:未实现菜单显示所属里程碑
  · 权限菜单:学校管理员看不到「租户管理」

视觉资产按腾讯云主题重做
  · logo.svg(渐变圆角方 + 填)、favicon.svg(小尺寸做减法)、login-hero.svg(材料归集)
  · 登录页点阵纹理走主题变量,换主色自动跟随
  · 文案改为产品实际能力:自动改名 / 强制压缩 / 隐私保护

清理模板遗留(约 17MB + 三处外部依赖)
  · 百度统计脚本(上报到 gi-demo 作者的统计账号)
  · 用户菜单「项目地址」(跳转模板作者的 Gitee 仓库)
  · 两份 8.8MB mp3、388KB favicon.ico、57KB 模板插画、未引用字体与 loading.gif
  · 「个人中心」指向已删除的 /system/account(点了 404)
  · 头部头像在无 avatarUrl 时渲染成裂图 → 改为姓名首字兜底

后端修复
  · 新增 GET /auth/public-key(前端加密登录密码用)
  · DataSeeder.ancestor_path 生成错误:子节点本该是 /16/17/ 却写成 /17/
    该字段是「按院系统计」的索引,错了会漏人/多人且不报错 —— 改为从库里读父节点路径
  · seedDemoOrgs 曾放在租户作用域外 + admin 早退分支之后,导致启动失败 / 永不执行
  · 示范租户补一套三级组织树(1 学校 / 2 院系 / 3 班级),供界面演示
This commit is contained in:
2026-09-28 20:49:55 +08:00
parent 9d7a8ca845
commit 87ece5a971
237 changed files with 25215 additions and 26 deletions
+270
View File
@@ -0,0 +1,270 @@
<template>
<GiPageLayout>
<!-- 左:组织树 -->
<template #left>
<a-card :bordered="false" class="org__tree-card">
<template #title>
<a-space>
<IconFolder />
<span>组织架构</span>
</a-space>
</template>
<template #extra>
<span class="org__hint">{{ totalNodes }} 个节点</span>
</template>
<a-input-search v-model="keyword" placeholder="搜索名称或编码" allow-clear class="org__search" />
<a-spin v-if="loading" class="org__loading" />
<a-empty v-else-if="!tree.length" description="还没有组织">
<a-button v-if="canManage" type="primary" size="small" @click="onAdd(null)">
新增顶级组织
</a-button>
</a-empty>
<a-tree v-else v-model:selected-keys="selectedKeys" :data="treeData" :field-names="{ key: 'id', title: 'orgName', children: 'children' }"
block-node :default-expand-all @select="onSelect">
<template #title="node">
<span class="org__node">
<span class="org__node-name">{{ node.orgName }}</span>
<a-tag size="small" class="org__node-type">{{ ORG_TYPE_NAMES[node.orgType] ?? '—' }}</a-tag>
<span v-if="node.studentCount" class="org__node-count">{{ node.studentCount }} 人</span>
</span>
</template>
</a-tree>
<template #footer>
<a-button v-if="canManage" long size="small" @click="onAdd(null)">
<template #icon><IconPlus /></template>
新增顶级组织
</a-button>
</template>
</a-card>
</template>
<!-- 右:详情 -->
<a-card v-if="!selected" :bordered="false">
<a-empty description="从左侧选择一个组织" />
</a-card>
<template v-else>
<a-card :bordered="false">
<template #title>{{ selected.orgName }}</template>
<template #extra>
<a-tag>{{ ORG_TYPE_NAMES[selected.orgType] ?? '未知' }}</a-tag>
</template>
<a-descriptions :column="2" size="large">
<a-descriptions-item label="组织编码">{{ selected.orgCode ?? '—' }}</a-descriptions-item>
<a-descriptions-item label="负责人">{{ selected.leaderName ?? '未指定' }}</a-descriptions-item>
<a-descriptions-item label="排序号">{{ selected.sortNo }}</a-descriptions-item>
<a-descriptions-item label="学生数">{{ selected.studentCount ?? 0 }} 人</a-descriptions-item>
<a-descriptions-item label="下级组织">{{ (selected.children ?? []).length }} 个</a-descriptions-item>
<a-descriptions-item label="状态">
<a-tag :color="selected.status === 1 ? 'green' : 'gray'">
{{ selected.status === 1 ? '正常' : '停用' }}
</a-tag>
</a-descriptions-item>
</a-descriptions>
<a-space v-if="canManage" class="org__acts">
<a-button type="primary" size="small" @click="onAdd(selected)">
<template #icon><IconPlus /></template>
新增下级
</a-button>
<a-button size="small" @click="onEdit(selected)">
<template #icon><IconEdit /></template>
修改
</a-button>
<a-popconfirm content="删除后不可恢复,确认删除?" type="warning" @ok="onDelete(selected)">
<a-button size="small" status="danger">
<template #icon><IconDelete /></template>
删除
</a-button>
</a-popconfirm>
</a-space>
</a-card>
<a-card v-if="(selected.children ?? []).length" :bordered="false">
<template #title>下级组织</template>
<template #extra>
<span class="org__hint">{{ (selected.children ?? []).length }} 个</span>
</template>
<a-table :data="selected.children" :pagination="false" row-key="id" size="small">
<template #columns>
<a-table-column title="名称" data-index="orgName" />
<a-table-column title="类型" :width="110">
<template #cell="{ record }">
<a-tag size="small">{{ ORG_TYPE_NAMES[record.orgType] ?? '—' }}</a-tag>
</template>
</a-table-column>
<a-table-column title="编码" data-index="orgCode" :width="130" />
<a-table-column title="学生数" data-index="studentCount" :width="90" />
<a-table-column title="操作" :width="80">
<template #cell="{ record }">
<a-link @click="onSelect([record.id], { node: record })">查看</a-link>
</template>
</a-table-column>
</template>
</a-table>
</a-card>
</template>
<OrgFormModal ref="formModalRef" @save-success="load" />
</GiPageLayout>
</template>
<script setup lang="ts">
import { Message } from '@arco-design/web-vue'
import { IconDelete, IconEdit, IconFolder, IconPlus } from '@arco-design/web-vue/es/icon'
import * as orgApi from '@/apis/xt/org'
import type { OrgTreeVO } from '@/apis/xt/org'
import { ORG_TYPE_NAMES } from '@/apis/xt/org'
import { useUserStore } from '@/stores'
import OrgFormModal from './OrgFormModal.vue'
/**
* 组织架构。
*
* 形态:左树右详情,是管理后台最常规的主从布局。
* 服务端的约束(编码唯一、类型层级、有下级不可删)在界面上提前提示,
* 但不做前端拦截 —— 判定权威在服务端,前端只负责减少无效提交。
*/
defineOptions({ name: 'Org' })
const userStore = useUserStore()
const loading = ref(false)
const tree = ref<OrgTreeVO[]>([])
const selected = ref<OrgTreeVO | null>(null)
const selectedKeys = ref<(string | number)[]>([])
const keyword = ref('')
const formModalRef = useTemplateRef('formModalRef')
const canManage = computed(() => userStore.permissions.includes('org:manage'))
const totalNodes = computed(() => countNodes(tree.value))
function countNodes(nodes: OrgTreeVO[]): number {
return nodes.reduce((s, n) => s + 1 + countNodes(n.children ?? []), 0)
}
/** 按关键字过滤(命中则保留其祖先链) */
const treeData = computed(() => {
const k = keyword.value.trim().toLowerCase()
if (!k) return tree.value
const walk = (nodes: OrgTreeVO[]): OrgTreeVO[] =>
nodes
.map((n) => {
const children = walk(n.children ?? [])
const hit = `${n.orgName} ${n.orgCode ?? ''}`.toLowerCase().includes(k)
return hit || children.length ? { ...n, children } : null
})
.filter(Boolean) as OrgTreeVO[]
return walk(tree.value)
})
function findById(nodes: OrgTreeVO[], id: number): OrgTreeVO | null {
for (const n of nodes) {
if (n.id === id) return n
const hit = findById(n.children ?? [], id)
if (hit) return hit
}
return null
}
async function load() {
loading.value = true
try {
const res = await orgApi.getOrgTree({ withCount: true })
tree.value = res.data ?? []
// 刷新后保持选中
if (selected.value) {
selected.value = findById(tree.value, selected.value.id)
}
} finally {
loading.value = false
}
}
function onSelect(keys: (string | number)[], data?: { node: OrgTreeVO }) {
const id = Number(keys[0] ?? '')
if (!id) {
selected.value = null
return
}
selected.value = data?.node?.id === id ? data.node : findById(tree.value, id)
}
function onAdd(parent: OrgTreeVO | null) {
formModalRef.value?.add(parent)
}
function onEdit(row: OrgTreeVO) {
formModalRef.value?.edit(row)
}
async function onDelete(row: OrgTreeVO) {
await orgApi.deleteOrg(row.id)
Message.success('已删除')
if (selected.value?.id === row.id) {
selected.value = null
selectedKeys.value = []
}
await load()
}
onMounted(load)
</script>
<style lang="scss" scoped>
.org {
&__tree-card {
height: 100%;
}
&__search {
margin-bottom: 10px;
}
&__loading {
display: block;
padding: 40px 0;
text-align: center;
}
&__hint {
font-size: 12px;
color: var(--color-text-3);
}
&__node {
display: inline-flex;
gap: 6px;
align-items: center;
}
&__node-name {
overflow: hidden;
text-overflow: ellipsis;
white-space: nowrap;
}
&__node-type {
flex: none;
transform: scale(0.88);
}
&__node-count {
flex: none;
font-size: 11px;
color: var(--color-text-3);
}
&__acts {
margin-top: 18px;
padding-top: 14px;
border-top: 1px solid var(--color-border-2);
}
}
</style>