AccountDetail.vue 2.1 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162
  1. <template>
  2. <PageWrapper
  3. :title="`用户` + userId + `的资料`"
  4. content="这是用户资料详情页面。本页面仅用于演示相同路由在tab中打开多个页面并且显示不同的数据"
  5. contentBackground
  6. @back="goBack"
  7. >
  8. <template #extra>
  9. <a-button type="primary" 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. <script>
  29. import { defineComponent, ref } from 'vue';
  30. import { useRoute } from 'vue-router';
  31. import { PageWrapper } from '/@/components/Page';
  32. import { useGo } from '/@/hooks/web/usePage';
  33. import { useTabs } from '/@/hooks/web/useTabs';
  34. import { Tabs } from 'ant-design-vue';
  35. export default defineComponent({
  36. name: 'AccountDetail',
  37. components: { PageWrapper, ATabs: Tabs, ATabPane: Tabs.TabPane },
  38. setup() {
  39. const route = useRoute();
  40. const go = useGo();
  41. // 此处可以得到用户ID
  42. const userId = ref(route.params?.id);
  43. const currentKey = ref('detail');
  44. const { setTitle } = useTabs();
  45. // TODO
  46. // 本页代码仅作演示,实际应当通过userId从接口获得用户的相关资料
  47. // 设置Tab的标题(不会影响页面标题)
  48. setTitle('详情:用户' + userId.value);
  49. // 页面左侧点击返回链接时的操作
  50. function goBack() {
  51. // 本例的效果时点击返回始终跳转到账号列表页,实际应用时可返回上一页
  52. go('/system/account');
  53. }
  54. return { userId, currentKey, goBack };
  55. },
  56. });
  57. </script>
  58. <style></style>