classDetail.tsx 2.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172
  1. import { defineComponent, ref } from 'vue';
  2. import styles from './index.module.less';
  3. import { NTabs, NTabPane } from 'naive-ui';
  4. import { useRoute } from 'vue-router';
  5. import CBreadcrumb from '@/components/CBreadcrumb';
  6. import ClassStudent from './components/classStudent';
  7. import AfterWork from './components/afterWork';
  8. import ClassRecord from './components/classRecord';
  9. import TestRecode from './components/testRecode';
  10. import { getTabsCache, setTabsCaches } from '@/hooks/use-async';
  11. import { classGroupDetail } from './api';
  12. export default defineComponent({
  13. name: 'base-setting',
  14. setup() {
  15. const classDetailTabs = sessionStorage.getItem('classDetailTabs');
  16. const activeTab = ref(classDetailTabs || 'student');
  17. sessionStorage.removeItem('classDetailTabs');
  18. const route = useRoute();
  19. const routerList = ref([
  20. { name: '班级管理', path: '/classList' },
  21. { name: route.query.name, path: '/classDetail' }
  22. ] as any);
  23. getTabsCache((val: any) => {
  24. if (val.form.tabName) {
  25. activeTab.value = val.form.tabName;
  26. }
  27. });
  28. const setTabs = (val: any) => {
  29. setTabsCaches(val, 'tabName', route);
  30. };
  31. const upgradeFlag = ref();
  32. const getClassGroupDetail = async () => {
  33. try {
  34. const id = route.query.id;
  35. const { data } = await classGroupDetail({ id });
  36. upgradeFlag.value = data.upgradeFlag ? 1 : 0; // 是否为历史班
  37. } catch {
  38. //
  39. }
  40. };
  41. getClassGroupDetail();
  42. return () => (
  43. <div>
  44. <CBreadcrumb list={routerList.value}></CBreadcrumb>
  45. <div class={[styles.listWrap, styles.infoListWrap]}>
  46. <NTabs
  47. class={styles.customTabs}
  48. v-model:value={activeTab.value}
  49. onUpdate:value={(val: any) => setTabs(val)}
  50. size="large"
  51. animated={false}
  52. pane-wrapper-style="margin: 0 -4px"
  53. pane-style="padding-left: 4px; padding-right: 4px; box-sizing: border-box;">
  54. <NTabPane name="student" tab="学员名单">
  55. <ClassStudent upgradeFlag={upgradeFlag.value}></ClassStudent>
  56. </NTabPane>
  57. <NTabPane name="afterWork" tab="课后作业">
  58. <AfterWork upgradeFlag={upgradeFlag.value}></AfterWork>
  59. </NTabPane>
  60. <NTabPane name="practice" tab="练习记录">
  61. <TestRecode></TestRecode>
  62. </NTabPane>
  63. <NTabPane name="attendclass" tab="上课记录">
  64. <ClassRecord />
  65. </NTabPane>
  66. </NTabs>
  67. </div>
  68. </div>
  69. );
  70. }
  71. });