wait-approval.tsx 2.9 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798
  1. import OEmpty from '@/components/o-empty'
  2. import dayjs from 'dayjs'
  3. import { List, PullRefresh, showToast } from 'vant'
  4. import OFullRefresh from '@/components/o-full-refresh'
  5. import { defineComponent, reactive, ref, onMounted, TransitionGroup } from 'vue'
  6. import { useRouter } from 'vue-router'
  7. import styles from './wait-approval.module.less'
  8. import request from '@/helpers/request'
  9. import ApprovalItem from './approval-item'
  10. import { approvalManageStrips } from '..'
  11. export default defineComponent({
  12. name: 'wait-approval',
  13. setup(props, { emit }) {
  14. const router = useRouter()
  15. const forms = reactive({
  16. page: 1,
  17. rows: 1000
  18. })
  19. const refreshing = ref(false)
  20. const loading = ref(false)
  21. const finished = ref(false)
  22. const list = ref([])
  23. const getList = async () => {
  24. if (loading.value) return
  25. loading.value = true
  26. if (refreshing.value) {
  27. finished.value = false
  28. forms.page = 1
  29. list.value = []
  30. }
  31. try {
  32. const res = await request.post('/api-school/userApproveRecord/page', {
  33. data: { ...forms, hasHandle: false }
  34. // hideLoading: refreshing.value
  35. })
  36. if (Array.isArray(res?.data?.rows)) {
  37. forms.page = res.data.current + 1
  38. list.value = list.value.concat(res.data.rows || [])
  39. finished.value = !res.data.next
  40. approvalManageStrips.approval = list.value.length
  41. } else {
  42. finished.value = false
  43. }
  44. } catch (e: any) {
  45. finished.value = true
  46. }
  47. loading.value = false
  48. refreshing.value = false
  49. }
  50. const gotoDetail = (row: any) => {
  51. // leaveCategoryId 1请假 2退团
  52. router.push({ path: '/student-leave', query: { id: row.id, type: 'doing' } })
  53. }
  54. onMounted(() => {
  55. getList()
  56. })
  57. return () => (
  58. <OFullRefresh
  59. modelValue={refreshing.value}
  60. onRefresh={() => {
  61. refreshing.value = true
  62. getList()
  63. }}
  64. style="min-height: calc(100vh - var(--van-tabs-line-height) - var(--header-height) - 1.33333rem);"
  65. >
  66. <List
  67. loading={loading.value}
  68. finished={finished.value}
  69. finished-text=" "
  70. loading-text=" "
  71. onLoad={getList}
  72. >
  73. <TransitionGroup name="van-fade">
  74. {list.value.map((item: any, itemIndex: number) => (
  75. <div
  76. key={`index-${itemIndex}`}
  77. onClick={() => {
  78. gotoDetail(item)
  79. }}
  80. >
  81. <ApprovalItem item={item} type="wait"></ApprovalItem>
  82. </div>
  83. ))}
  84. </TransitionGroup>
  85. </List>
  86. {!loading.value && !list.value.length && (
  87. <div class="emptyFixedHeightContainer">
  88. <OEmpty tips="暂无审批" />
  89. </div>
  90. )}
  91. </OFullRefresh>
  92. )
  93. }
  94. })