Commit 0e414ba3c10b4e47a85feb1a38cae66c815719d8
1 parent
61d4efd5
feat(demo): add route multi tabs show
添加同一路由演示多个不同参数的tab close: #817
Showing
5 changed files
with
91 additions
and
3 deletions
src/locales/lang/en/routes/demo.ts
@@ -163,7 +163,7 @@ export default { | @@ -163,7 +163,7 @@ export default { | ||
163 | moduleName: 'System management', | 163 | moduleName: 'System management', |
164 | 164 | ||
165 | account: 'Account management', | 165 | account: 'Account management', |
166 | - | 166 | + account_detail: 'Account detail', |
167 | password: 'Change password', | 167 | password: 'Change password', |
168 | 168 | ||
169 | dept: 'Department management', | 169 | dept: 'Department management', |
src/locales/lang/zh_CN/routes/demo.ts
@@ -157,6 +157,7 @@ export default { | @@ -157,6 +157,7 @@ export default { | ||
157 | system: { | 157 | system: { |
158 | moduleName: '系统管理', | 158 | moduleName: '系统管理', |
159 | account: '账号管理', | 159 | account: '账号管理', |
160 | + account_detail: '账号详情', | ||
160 | password: '修改密码', | 161 | password: '修改密码', |
161 | dept: '部门管理', | 162 | dept: '部门管理', |
162 | menu: '菜单管理', | 163 | menu: '菜单管理', |
src/router/routes/modules/demo/system.ts
@@ -18,11 +18,22 @@ const system: AppRouteModule = { | @@ -18,11 +18,22 @@ const system: AppRouteModule = { | ||
18 | name: 'AccountManagement', | 18 | name: 'AccountManagement', |
19 | meta: { | 19 | meta: { |
20 | title: t('routes.demo.system.account'), | 20 | title: t('routes.demo.system.account'), |
21 | - ignoreKeepAlive: true, | 21 | + ignoreKeepAlive: false, |
22 | }, | 22 | }, |
23 | component: () => import('/@/views/demo/system/account/index.vue'), | 23 | component: () => import('/@/views/demo/system/account/index.vue'), |
24 | }, | 24 | }, |
25 | { | 25 | { |
26 | + path: 'account_detail/:id', | ||
27 | + name: 'AccountDetail', | ||
28 | + meta: { | ||
29 | + title: t('routes.demo.system.account_detail'), | ||
30 | + ignoreKeepAlive: true, | ||
31 | + showMenu: false, | ||
32 | + currentActiveMenu: '/system/account', | ||
33 | + }, | ||
34 | + component: () => import('/@/views/demo/system/account/AccountDetail.vue'), | ||
35 | + }, | ||
36 | + { | ||
26 | path: 'role', | 37 | path: 'role', |
27 | name: 'RoleManagement', | 38 | name: 'RoleManagement', |
28 | meta: { | 39 | meta: { |
src/views/demo/system/account/AccountDetail.vue
0 → 100644
1 | +<template> | ||
2 | + <PageWrapper | ||
3 | + :title="`用户` + userId + `的资料`" | ||
4 | + content="这是用户资料详情页面。本页面仅用于演示相同路由在tab中打开多个页面并且显示不同的数据" | ||
5 | + contentBackground | ||
6 | + @back="goBack" | ||
7 | + > | ||
8 | + <template #extra> | ||
9 | + <a-button type="danger"> 禁用账号 </a-button> | ||
10 | + <a-button type="primary"> 修改密码 </a-button> | ||
11 | + </template> | ||
12 | + <template #footer> | ||
13 | + <a-tabs default-active-key="detail" v-model:activeKey="currentKey"> | ||
14 | + <a-tab-pane key="detail" tab="用户资料" /> | ||
15 | + <a-tab-pane key="logs" tab="操作日志" /> | ||
16 | + </a-tabs> | ||
17 | + </template> | ||
18 | + <div class="pt-4 m-4 desc-wrap"> | ||
19 | + <template v-if="currentKey == 'detail'"> | ||
20 | + <div v-for="i in 10" :key="i">这是用户{{ userId }}资料Tab</div> | ||
21 | + </template> | ||
22 | + <template v-if="currentKey == 'logs'"> | ||
23 | + <div v-for="i in 10" :key="i">这是用户{{ userId }}操作日志Tab</div> | ||
24 | + </template> | ||
25 | + </div> | ||
26 | + </PageWrapper> | ||
27 | +</template> | ||
28 | + | ||
29 | +<script> | ||
30 | + import { defineComponent, ref } from 'vue'; | ||
31 | + import { useRoute } from 'vue-router'; | ||
32 | + import { PageWrapper } from '/@/components/Page'; | ||
33 | + import { useGo } from '/@/hooks/web/usePage'; | ||
34 | + import { useTabs } from '/@/hooks/web/useTabs'; | ||
35 | + import { Tabs } from 'ant-design-vue'; | ||
36 | + export default defineComponent({ | ||
37 | + name: 'AccountDetail', | ||
38 | + components: { PageWrapper, ATabs: Tabs, ATabPane: Tabs.TabPane }, | ||
39 | + setup() { | ||
40 | + const route = useRoute(); | ||
41 | + const go = useGo(); | ||
42 | + // 此处可以得到用户ID | ||
43 | + const userId = ref(route.params?.id); | ||
44 | + const currentKey = ref('detail'); | ||
45 | + const { setTitle } = useTabs(); | ||
46 | + // TODO | ||
47 | + // 本页代码仅作演示,实际应当通过userId从接口获得用户的相关资料 | ||
48 | + | ||
49 | + // 设置Tab的标题(不会影响页面标题) | ||
50 | + setTitle('详情:用户' + userId.value); | ||
51 | + | ||
52 | + // 页面左侧点击返回链接时的操作 | ||
53 | + function goBack() { | ||
54 | + // 本例的效果时点击返回始终跳转到账号列表页,实际应用时可返回上一页 | ||
55 | + go('/system/account'); | ||
56 | + } | ||
57 | + return { userId, currentKey, goBack }; | ||
58 | + }, | ||
59 | + }); | ||
60 | +</script> | ||
61 | + | ||
62 | +<style></style> |
src/views/demo/system/account/index.vue
@@ -9,12 +9,19 @@ | @@ -9,12 +9,19 @@ | ||
9 | <TableAction | 9 | <TableAction |
10 | :actions="[ | 10 | :actions="[ |
11 | { | 11 | { |
12 | + icon: 'clarity:eye-show-solid', | ||
13 | + title: '查看用户详情', | ||
14 | + onClick: handleView.bind(null, record), | ||
15 | + }, | ||
16 | + { | ||
12 | icon: 'clarity:note-edit-line', | 17 | icon: 'clarity:note-edit-line', |
18 | + title: '编辑用户资料', | ||
13 | onClick: handleEdit.bind(null, record), | 19 | onClick: handleEdit.bind(null, record), |
14 | }, | 20 | }, |
15 | { | 21 | { |
16 | icon: 'ant-design:delete-outlined', | 22 | icon: 'ant-design:delete-outlined', |
17 | color: 'error', | 23 | color: 'error', |
24 | + title: '删除此账号', | ||
18 | popConfirm: { | 25 | popConfirm: { |
19 | title: '是否确认删除', | 26 | title: '是否确认删除', |
20 | confirm: handleDelete.bind(null, record), | 27 | confirm: handleDelete.bind(null, record), |
@@ -39,11 +46,13 @@ | @@ -39,11 +46,13 @@ | ||
39 | import AccountModal from './AccountModal.vue'; | 46 | import AccountModal from './AccountModal.vue'; |
40 | 47 | ||
41 | import { columns, searchFormSchema } from './account.data'; | 48 | import { columns, searchFormSchema } from './account.data'; |
49 | + import { useGo } from '/@/hooks/web/usePage'; | ||
42 | 50 | ||
43 | export default defineComponent({ | 51 | export default defineComponent({ |
44 | name: 'AccountManagement', | 52 | name: 'AccountManagement', |
45 | components: { BasicTable, PageWrapper, DeptTree, AccountModal, TableAction }, | 53 | components: { BasicTable, PageWrapper, DeptTree, AccountModal, TableAction }, |
46 | setup() { | 54 | setup() { |
55 | + const go = useGo(); | ||
47 | const [registerModal, { openModal }] = useModal(); | 56 | const [registerModal, { openModal }] = useModal(); |
48 | const [registerTable, { reload, updateTableDataRecord }] = useTable({ | 57 | const [registerTable, { reload, updateTableDataRecord }] = useTable({ |
49 | title: '账号列表', | 58 | title: '账号列表', |
@@ -58,7 +67,7 @@ | @@ -58,7 +67,7 @@ | ||
58 | showTableSetting: true, | 67 | showTableSetting: true, |
59 | bordered: true, | 68 | bordered: true, |
60 | actionColumn: { | 69 | actionColumn: { |
61 | - width: 80, | 70 | + width: 120, |
62 | title: '操作', | 71 | title: '操作', |
63 | dataIndex: 'action', | 72 | dataIndex: 'action', |
64 | slots: { customRender: 'action' }, | 73 | slots: { customRender: 'action' }, |
@@ -98,6 +107,10 @@ | @@ -98,6 +107,10 @@ | ||
98 | reload({ searchInfo: { deptId } }); | 107 | reload({ searchInfo: { deptId } }); |
99 | } | 108 | } |
100 | 109 | ||
110 | + function handleView(record: Recordable) { | ||
111 | + go('/system/account_detail/' + record.id); | ||
112 | + } | ||
113 | + | ||
101 | return { | 114 | return { |
102 | registerTable, | 115 | registerTable, |
103 | registerModal, | 116 | registerModal, |
@@ -106,6 +119,7 @@ | @@ -106,6 +119,7 @@ | ||
106 | handleDelete, | 119 | handleDelete, |
107 | handleSuccess, | 120 | handleSuccess, |
108 | handleSelect, | 121 | handleSelect, |
122 | + handleView, | ||
109 | }; | 123 | }; |
110 | }, | 124 | }, |
111 | }); | 125 | }); |