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,45 +22,47 @@ | ||
22 | </script> | 22 | </script> |
23 | 23 | ||
24 | <template> | 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 | <BasicTable @register="register"> | 27 | <BasicTable @register="register"> |
27 | <template #function="{ record }"> | 28 | <template #function="{ record }"> |
28 | <a-tooltip :title="record.function"> | 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 | <span>{{ record.function.slice(0, 13) }}</span> | 31 | <span>{{ record.function.slice(0, 13) }}</span> |
31 | </a-button> | 32 | </a-button> |
32 | </a-tooltip> | 33 | </a-tooltip> |
33 | </template> | 34 | </template> |
34 | <template #release="{ record }"> | 35 | <template #release="{ record }"> |
35 | <a-tooltip :title="record.release"> | 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 | <span>{{ record.release.slice(0, 30) }}</span> | 38 | <span>{{ record.release.slice(0, 30) }}</span> |
38 | </a-button> | 39 | </a-button> |
39 | </a-tooltip> | 40 | </a-tooltip> |
40 | </template> | 41 | </template> |
41 | <template #subscribe="{ record }"> | 42 | <template #subscribe="{ record }"> |
42 | <a-tooltip :title="record.subscribe"> | 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 | <span>{{ record.subscribe.slice(0, 30) }}</span> | 45 | <span>{{ record.subscribe.slice(0, 30) }}</span> |
45 | </a-button> | 46 | </a-button> |
46 | </a-tooltip> | 47 | </a-tooltip> |
47 | </template> | 48 | </template> |
48 | <template #platform="{ record }"> | 49 | <template #platform="{ record }"> |
49 | <a-tooltip :title="record.platform"> | 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 | <span>{{ record.platform }}</span> | 52 | <span>{{ record.platform }}</span> |
52 | </a-button> | 53 | </a-button> |
53 | </a-tooltip> | 54 | </a-tooltip> |
54 | </template> | 55 | </template> |
55 | <template #device="{ record }"> | 56 | <template #device="{ record }"> |
56 | <a-tooltip :title="record.device"> | 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 | <span>{{ record.device }}</span> | 59 | <span>{{ record.device }}</span> |
59 | </a-button> | 60 | </a-button> |
60 | </a-tooltip> | 61 | </a-tooltip> |
61 | </template> | 62 | </template> |
62 | </BasicTable> | 63 | </BasicTable> |
63 | - </section> | 64 | + </div> |
65 | + <!-- </section> --> | ||
64 | </template> | 66 | </template> |
65 | <style scoped> | 67 | <style scoped> |
66 | :deep(.ant-table-body) { | 68 | :deep(.ant-table-body) { |
@@ -4,7 +4,7 @@ export const topicTableColumn: BasicColumn[] = [ | @@ -4,7 +4,7 @@ export const topicTableColumn: BasicColumn[] = [ | ||
4 | { | 4 | { |
5 | title: '设备类型', | 5 | title: '设备类型', |
6 | dataIndex: 'deviceType', | 6 | dataIndex: 'deviceType', |
7 | - width: 50, | 7 | + width: 40, |
8 | customRender: ({ text, index }: { text: any; index: number }) => { | 8 | customRender: ({ text, index }: { text: any; index: number }) => { |
9 | const obj: any = { | 9 | const obj: any = { |
10 | children: text, | 10 | children: text, |
@@ -28,31 +28,31 @@ export const topicTableColumn: BasicColumn[] = [ | @@ -28,31 +28,31 @@ export const topicTableColumn: BasicColumn[] = [ | ||
28 | { | 28 | { |
29 | title: '功能', | 29 | title: '功能', |
30 | dataIndex: 'function', | 30 | dataIndex: 'function', |
31 | - width: 100, | 31 | + width: 80, |
32 | slots: { customRender: 'function' }, | 32 | slots: { customRender: 'function' }, |
33 | }, | 33 | }, |
34 | { | 34 | { |
35 | title: '发布主题', | 35 | title: '发布主题', |
36 | dataIndex: 'release', | 36 | dataIndex: 'release', |
37 | - width: 120, | 37 | + width: 80, |
38 | slots: { customRender: 'release' }, | 38 | slots: { customRender: 'release' }, |
39 | }, | 39 | }, |
40 | { | 40 | { |
41 | title: '订阅主题', | 41 | title: '订阅主题', |
42 | dataIndex: 'subscribe', | 42 | dataIndex: 'subscribe', |
43 | - width: 120, | 43 | + width: 80, |
44 | slots: { customRender: 'subscribe' }, | 44 | slots: { customRender: 'subscribe' }, |
45 | }, | 45 | }, |
46 | { | 46 | { |
47 | title: '平台', | 47 | title: '平台', |
48 | dataIndex: 'platform', | 48 | dataIndex: 'platform', |
49 | - width: 30, | 49 | + width: 50, |
50 | slots: { customRender: 'platform' }, | 50 | slots: { customRender: 'platform' }, |
51 | }, | 51 | }, |
52 | { | 52 | { |
53 | title: '设备', | 53 | title: '设备', |
54 | dataIndex: 'device', | 54 | dataIndex: 'device', |
55 | - width: 30, | 55 | + width: 50, |
56 | slots: { customRender: 'device' }, | 56 | slots: { customRender: 'device' }, |
57 | }, | 57 | }, |
58 | ]; | 58 | ]; |
@@ -46,6 +46,12 @@ | @@ -46,6 +46,12 @@ | ||
46 | <TableAction | 46 | <TableAction |
47 | :actions="[ | 47 | :actions="[ |
48 | { | 48 | { |
49 | + label: '进入', | ||
50 | + icon: 'ant-design:login-outlined', | ||
51 | + tooltip: '以客户用户身份登录', | ||
52 | + onClick: handleLoginCustomAdmin.bind(null, record), | ||
53 | + }, | ||
54 | + { | ||
49 | label: '用户详情', | 55 | label: '用户详情', |
50 | auth: 'api:yt:user:get', | 56 | auth: 'api:yt:user:get', |
51 | icon: 'clarity:info-standard-line', | 57 | icon: 'clarity:info-standard-line', |
@@ -96,6 +102,14 @@ | @@ -96,6 +102,14 @@ | ||
96 | import { useGo } from '/@/hooks/web/usePage'; | 102 | import { useGo } from '/@/hooks/web/usePage'; |
97 | import { useBatchDelete } from '/@/hooks/web/useBatchDelete'; | 103 | import { useBatchDelete } from '/@/hooks/web/useBatchDelete'; |
98 | import { Authority } from '/@/components/Authority'; | 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 | export default defineComponent({ | 114 | export default defineComponent({ |
101 | name: 'AccountManagement', | 115 | name: 'AccountManagement', |
@@ -168,8 +182,32 @@ | @@ -168,8 +182,32 @@ | ||
168 | function handleView(record: Recordable) { | 182 | function handleView(record: Recordable) { |
169 | go('/system/account_detail/' + record.id); | 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 | return { | 209 | return { |
210 | + handleLoginCustomAdmin, | ||
173 | registerTable, | 211 | registerTable, |
174 | registerModal, | 212 | registerModal, |
175 | handleCreate, | 213 | handleCreate, |