list.tsx 5.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171
  1. import ColEmpty from '@/components/col-empty'
  2. import Pagination from '@/components/pagination'
  3. import request from '@/helpers/request'
  4. import styles from './index.module.less'
  5. import { ElSkeleton, ElSkeletonItem } from 'element-plus'
  6. import { defineComponent } from 'vue'
  7. import { state } from '@/state'
  8. import MusicItem from './item'
  9. export default defineComponent({
  10. name: 'list',
  11. props: {
  12. auditStatus: {
  13. type: String,
  14. default: ''
  15. },
  16. onNumber: {
  17. type: Function,
  18. default: (data: any) => {}
  19. }
  20. },
  21. data() {
  22. return {
  23. pageInfo: {
  24. // 分页规则
  25. limit: 10, // 限制显示条数
  26. page: 1, // 当前页
  27. total: 0, // 总条数
  28. page_size: [10, 20, 40, 50] // 选择限制显示条数
  29. },
  30. list: [] as any[],
  31. loading: false,
  32. dataShow: false // 是否有数据
  33. }
  34. },
  35. mounted() {
  36. if (state.user.data?.musicianFlag) {
  37. this.getList()
  38. }
  39. },
  40. methods: {
  41. async getList() {
  42. this.loading = true
  43. try {
  44. const { data } = await request.post(
  45. '/api-website/music/sheet/teacher/list',
  46. {
  47. data: {
  48. auditStatus: this.auditStatus,
  49. page: this.pageInfo.page,
  50. rows: this.pageInfo.limit
  51. }
  52. }
  53. )
  54. this.list = data.list.rows || []
  55. this.pageInfo.total = data.list.total
  56. if (data.list.total <= 0) {
  57. this.dataShow = true
  58. }
  59. // 统计数据
  60. this.onNumber({
  61. doing: data.doing || 0,
  62. pass: data.pass || 0,
  63. unPass: data.unPass || 0
  64. })
  65. } catch {}
  66. if (this.dataShow) {
  67. this.loading = false
  68. } else {
  69. setTimeout(() => {
  70. this.loading = false
  71. }, 200)
  72. }
  73. }
  74. },
  75. render() {
  76. return (
  77. <>
  78. {state.user.data?.entryFlag ? (
  79. <>
  80. <div>
  81. <ElSkeleton
  82. loading={this.loading}
  83. animated
  84. class=" w-full m-auto px-[14px] flex items-center flex-col"
  85. count={3}
  86. v-slots={{
  87. template: () => (
  88. <div class="h-[94px] flex items-center justify-between w-full mb-2 pt-2">
  89. <div class="w-2/3 flex items-center">
  90. <ElSkeletonItem
  91. variant="circle"
  92. style={{ width: '88px', height: '88px' }}
  93. ></ElSkeletonItem>
  94. <div class="w-1/2 pl-2">
  95. <ElSkeletonItem variant="h3"></ElSkeletonItem>
  96. <ElSkeletonItem
  97. variant="p"
  98. style={{ width: '50%' }}
  99. ></ElSkeletonItem>
  100. </div>
  101. </div>
  102. <ElSkeletonItem
  103. variant="p"
  104. style={{ width: '20%' }}
  105. ></ElSkeletonItem>
  106. </div>
  107. )
  108. }}
  109. >
  110. {this.list.map((item: any) => (
  111. <MusicItem
  112. onClick={(item: any) => {
  113. if (this.auditStatus === 'UNPASS') {
  114. console.log(item)
  115. this.$router.push({
  116. path: '/userInfo/musicOperation',
  117. query: {
  118. type: 'update',
  119. id: item.id
  120. }
  121. })
  122. } else {
  123. // 跳转对应详情 个人中心不跳转到详情
  124. }
  125. }}
  126. item={{
  127. id: item.id,
  128. addName: item.addName,
  129. addUserAvatar: item.addUserAvatar,
  130. musicSheetName: item.musicSheetName,
  131. subjectNames: item.subjectNames,
  132. composer: item.composer,
  133. chargeType: item.chargeType
  134. }}
  135. class={[
  136. styles.musicListItem,
  137. 'pt-2 cursor-pointer border-b border-solid border-[#E7E6E6] hover:bg-[#F4F4F4]'
  138. ]}
  139. />
  140. ))}
  141. </ElSkeleton>
  142. </div>
  143. <Pagination
  144. total={this.pageInfo.total}
  145. v-model:page={this.pageInfo.page}
  146. v-model:limit={this.pageInfo.limit}
  147. pageSizes={this.pageInfo.page_size}
  148. pagination={this.getList}
  149. />
  150. {this.dataShow && <ColEmpty />}
  151. </>
  152. ) : (
  153. <div class="px-[38px]">
  154. <ColEmpty
  155. type="teacherCert"
  156. message="您还未完成达人认证,认证后才可创建视频课哦~"
  157. buttonVisibility
  158. buttonText="去认证"
  159. onDetail={() => {
  160. this.$router.push('/teacherAuth')
  161. }}
  162. />
  163. </div>
  164. )}
  165. </>
  166. )
  167. }
  168. })