index.tsx 1.9 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374
  1. import OHeader from '@/components/o-header'
  2. import OSticky from '@/components/o-sticky'
  3. import request from '@/helpers/request'
  4. import { Tab, Tabs } from 'vant'
  5. import { defineComponent, reactive } from 'vue'
  6. import List from './components/list'
  7. import styles from './index.module.less'
  8. export default defineComponent({
  9. name: 'train-report',
  10. setup() {
  11. const state = reactive({
  12. loading: true,
  13. orchestraList: [] as any,
  14. height: 'auto'
  15. })
  16. // 获取乐团列表
  17. const getOrchestras = async () => {
  18. try {
  19. state.loading = true
  20. const { data } = await request.post('/api-school/orchestra/page', {
  21. data: {
  22. page: 1,
  23. rows: 100,
  24. status: 'DONE'
  25. }
  26. })
  27. const temps = data.rows || []
  28. const s = [] as any
  29. temps.forEach((item: any) => {
  30. s.push({
  31. text: item.name,
  32. value: item.id
  33. })
  34. })
  35. s.unshift({
  36. text: '全部乐团',
  37. value: ''
  38. })
  39. state.orchestraList = [...s]
  40. state.loading = false
  41. } catch {
  42. //
  43. state.loading = false
  44. }
  45. }
  46. getOrchestras()
  47. return () => (
  48. <div class={styles.train}>
  49. <OSticky
  50. position="top"
  51. onGetHeight={(height: any) => {
  52. document.documentElement.style.setProperty('--header-height', height + 'px')
  53. state.height = height
  54. }}
  55. >
  56. <OHeader />
  57. </OSticky>
  58. {!state.loading && (
  59. <Tabs sticky lineWidth={20} lineHeight={4} offsetTop={state.height} swipeable animated>
  60. <Tab title="周报" name="WEEKLY">
  61. <List type="WEEKLY" orchestraList={state.orchestraList} />
  62. </Tab>
  63. <Tab title="月报" name="MONTHLY">
  64. <List type="MONTHLY" orchestraList={state.orchestraList} />
  65. </Tab>
  66. </Tabs>
  67. )}
  68. </div>
  69. )
  70. }
  71. })