Commit 13f151d6bc935f9b6616a7e19e7816fe1ab834ad
Merge branch 'local_dev_ft' into 'main'
feat:新增以客户进入 See merge request huang/yun-teng-iot-front!467
Showing
3 changed files
with
53 additions
and
13 deletions
... | ... | @@ -22,45 +22,47 @@ |
22 | 22 | </script> |
23 | 23 | |
24 | 24 | <template> |
25 | - <section class="bg-gray-100 p-4 dark:bg-dark-900 w-full h-full"> | |
25 | + <!-- <section class="bg-gray-100 p-4 dark:bg-dark-900 w-full h-full"> --> | |
26 | + <div> | |
26 | 27 | <BasicTable @register="register"> |
27 | 28 | <template #function="{ record }"> |
28 | 29 | <a-tooltip :title="record.function"> |
29 | - <a-button type="text" class="ml-2" @click="handeleCopy(record.function)"> | |
30 | + <a-button type="text" class="" @click="handeleCopy(record.function)"> | |
30 | 31 | <span>{{ record.function.slice(0, 13) }}</span> |
31 | 32 | </a-button> |
32 | 33 | </a-tooltip> |
33 | 34 | </template> |
34 | 35 | <template #release="{ record }"> |
35 | 36 | <a-tooltip :title="record.release"> |
36 | - <a-button type="text" class="ml-2" @click="handeleCopy(record.release)"> | |
37 | + <a-button type="text" class="" @click="handeleCopy(record.release)"> | |
37 | 38 | <span>{{ record.release.slice(0, 30) }}</span> |
38 | 39 | </a-button> |
39 | 40 | </a-tooltip> |
40 | 41 | </template> |
41 | 42 | <template #subscribe="{ record }"> |
42 | 43 | <a-tooltip :title="record.subscribe"> |
43 | - <a-button type="text" class="ml-2" @click="handeleCopy(record.subscribe)"> | |
44 | + <a-button type="text" class="" @click="handeleCopy(record.subscribe)"> | |
44 | 45 | <span>{{ record.subscribe.slice(0, 30) }}</span> |
45 | 46 | </a-button> |
46 | 47 | </a-tooltip> |
47 | 48 | </template> |
48 | 49 | <template #platform="{ record }"> |
49 | 50 | <a-tooltip :title="record.platform"> |
50 | - <a-button type="text" class="ml-2" @click="handeleCopy(record.platform)"> | |
51 | + <a-button type="text" style="margin-left: -10px" @click="handeleCopy(record.platform)"> | |
51 | 52 | <span>{{ record.platform }}</span> |
52 | 53 | </a-button> |
53 | 54 | </a-tooltip> |
54 | 55 | </template> |
55 | 56 | <template #device="{ record }"> |
56 | 57 | <a-tooltip :title="record.device"> |
57 | - <a-button type="text" class="ml-2" @click="handeleCopy(record.device)"> | |
58 | + <a-button type="text" style="margin-left: -10px" @click="handeleCopy(record.device)"> | |
58 | 59 | <span>{{ record.device }}</span> |
59 | 60 | </a-button> |
60 | 61 | </a-tooltip> |
61 | 62 | </template> |
62 | 63 | </BasicTable> |
63 | - </section> | |
64 | + </div> | |
65 | + <!-- </section> --> | |
64 | 66 | </template> |
65 | 67 | <style scoped> |
66 | 68 | :deep(.ant-table-body) { | ... | ... |
... | ... | @@ -4,7 +4,7 @@ export const topicTableColumn: BasicColumn[] = [ |
4 | 4 | { |
5 | 5 | title: '设备类型', |
6 | 6 | dataIndex: 'deviceType', |
7 | - width: 50, | |
7 | + width: 40, | |
8 | 8 | customRender: ({ text, index }: { text: any; index: number }) => { |
9 | 9 | const obj: any = { |
10 | 10 | children: text, |
... | ... | @@ -28,31 +28,31 @@ export const topicTableColumn: BasicColumn[] = [ |
28 | 28 | { |
29 | 29 | title: '功能', |
30 | 30 | dataIndex: 'function', |
31 | - width: 100, | |
31 | + width: 80, | |
32 | 32 | slots: { customRender: 'function' }, |
33 | 33 | }, |
34 | 34 | { |
35 | 35 | title: '发布主题', |
36 | 36 | dataIndex: 'release', |
37 | - width: 120, | |
37 | + width: 80, | |
38 | 38 | slots: { customRender: 'release' }, |
39 | 39 | }, |
40 | 40 | { |
41 | 41 | title: '订阅主题', |
42 | 42 | dataIndex: 'subscribe', |
43 | - width: 120, | |
43 | + width: 80, | |
44 | 44 | slots: { customRender: 'subscribe' }, |
45 | 45 | }, |
46 | 46 | { |
47 | 47 | title: '平台', |
48 | 48 | dataIndex: 'platform', |
49 | - width: 30, | |
49 | + width: 50, | |
50 | 50 | slots: { customRender: 'platform' }, |
51 | 51 | }, |
52 | 52 | { |
53 | 53 | title: '设备', |
54 | 54 | dataIndex: 'device', |
55 | - width: 30, | |
55 | + width: 50, | |
56 | 56 | slots: { customRender: 'device' }, |
57 | 57 | }, |
58 | 58 | ]; | ... | ... |
... | ... | @@ -46,6 +46,12 @@ |
46 | 46 | <TableAction |
47 | 47 | :actions="[ |
48 | 48 | { |
49 | + label: '进入', | |
50 | + icon: 'ant-design:login-outlined', | |
51 | + tooltip: '以客户用户身份登录', | |
52 | + onClick: handleLoginCustomAdmin.bind(null, record), | |
53 | + }, | |
54 | + { | |
49 | 55 | label: '用户详情', |
50 | 56 | auth: 'api:yt:user:get', |
51 | 57 | icon: 'clarity:info-standard-line', |
... | ... | @@ -96,6 +102,14 @@ |
96 | 102 | import { useGo } from '/@/hooks/web/usePage'; |
97 | 103 | import { useBatchDelete } from '/@/hooks/web/useBatchDelete'; |
98 | 104 | import { Authority } from '/@/components/Authority'; |
105 | + import { getMyInfo, getPermCode, getUserToken } from '/@/api/sys/user'; | |
106 | + import { useUserStore } from '/@/store/modules/user'; | |
107 | + import { usePermissionStore } from '/@/store/modules/permission'; | |
108 | + import { router } from '/@/router'; | |
109 | + import { RoleEnum } from '/@/enums/roleEnum'; | |
110 | + import { RouteRecordRaw } from 'vue-router'; | |
111 | + import { PAGE_NOT_FOUND_ROUTE } from '/@/router/routes/basic'; | |
112 | + import { PageEnum } from '/@/enums/pageEnum'; | |
99 | 113 | |
100 | 114 | export default defineComponent({ |
101 | 115 | name: 'AccountManagement', |
... | ... | @@ -168,8 +182,32 @@ |
168 | 182 | function handleView(record: Recordable) { |
169 | 183 | go('/system/account_detail/' + record.id); |
170 | 184 | } |
185 | + const userStore = useUserStore(); | |
186 | + | |
187 | + const permissionStore = usePermissionStore(); | |
188 | + async function handleLoginCustomAdmin(record: { tbUser: string; id: string }) { | |
189 | + try { | |
190 | + const { token, refreshToken } = await getUserToken(record.id); | |
191 | + userStore.storeToken(token, refreshToken); | |
192 | + const userInfo = await getMyInfo(); | |
193 | + const permissionList = await getPermCode(); | |
194 | + permissionStore.setPermCodeList(permissionList); | |
195 | + userStore.setUserInfo(userInfo); | |
196 | + userStore.setRoleList(userInfo.roles as RoleEnum[]); | |
197 | + const routes = await permissionStore.buildRoutesAction(); | |
198 | + routes.forEach((route) => { | |
199 | + router.addRoute(route as unknown as RouteRecordRaw); | |
200 | + }); | |
201 | + router.addRoute(PAGE_NOT_FOUND_ROUTE as unknown as RouteRecordRaw); | |
202 | + permissionStore.setDynamicAddedRoute(true); | |
203 | + go(PageEnum.BASE_HOME); | |
204 | + } catch (error) { | |
205 | + } finally { | |
206 | + } | |
207 | + } | |
171 | 208 | |
172 | 209 | return { |
210 | + handleLoginCustomAdmin, | |
173 | 211 | registerTable, |
174 | 212 | registerModal, |
175 | 213 | handleCreate, | ... | ... |