list.tsx 6.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203
  1. import ColEmpty from '@/components/col-empty'
  2. import Pagination from '@/components/pagination'
  3. import request from '@/helpers/request'
  4. import { state } from '@/state'
  5. import { ElMessage, ElMessageBox, ElSkeleton, ElSkeletonItem } from 'element-plus'
  6. import { defineComponent } from 'vue'
  7. import Item from '../components/item'
  8. import styles from './index.module.less'
  9. export default defineComponent({
  10. name: 'list',
  11. props: {
  12. auditStatus: {
  13. type: String,
  14. default: ''
  15. }
  16. },
  17. data() {
  18. return {
  19. pageInfo: {
  20. // 分页规则
  21. limit: 9, // 限制显示条数
  22. page: 1, // 当前页
  23. total: 0, // 总条数
  24. page_size: [10, 20, 40, 50] // 选择限制显示条数
  25. },
  26. list: [] as any[],
  27. loading: true,
  28. dataShow: false // 是否有数据
  29. }
  30. },
  31. mounted() {
  32. if (state.user.data?.entryFlag) {
  33. this.getList()
  34. }
  35. },
  36. methods: {
  37. async getList() {
  38. this.loading = true
  39. try {
  40. const { data } = await request.post(
  41. '/api-website/videoLessonGroup/page',
  42. {
  43. data: {
  44. auditStatus: this.auditStatus,
  45. page: this.pageInfo.page,
  46. rows: this.pageInfo.limit,
  47. teacherId: state.user.data?.userId
  48. }
  49. }
  50. )
  51. this.list = data.rows || []
  52. this.pageInfo.total = data.total
  53. if (data.total <= 0) {
  54. this.dataShow = true
  55. }
  56. } catch {}
  57. if (this.dataShow) {
  58. this.loading = false
  59. } else {
  60. setTimeout(() => {
  61. this.loading = false
  62. }, 200)
  63. }
  64. },
  65. onDetail(item: any) {
  66. if (this.auditStatus === 'UNPASS') {
  67. // this.$message.error('该课程正在审核中,请等待审核结果')
  68. this.$router.push({
  69. path: '/userInfo/videoOperation',
  70. query: {
  71. type: 'edit',
  72. groupId: item.id
  73. }
  74. })
  75. return
  76. } else {
  77. // 跳转对应详情 个人中心不跳转到详情
  78. }
  79. },
  80. async onOffCourse(item: any) {
  81. ElMessageBox.confirm(`是否下架课程?`, '提示', {
  82. confirmButtonText: '确认',
  83. cancelButtonText: '取消',
  84. type: 'warning'
  85. }).then(async () => {
  86. try {
  87. await request.post('/api-website/videoLessonGroup/updateShelves', {
  88. data: {
  89. id: item.id,
  90. shelvesFlag: 0
  91. }
  92. })
  93. ElMessage.success('下架成功')
  94. this.pageInfo.page = 1
  95. this.getList()
  96. } catch {}
  97. })
  98. }
  99. },
  100. render() {
  101. return (
  102. <>
  103. {state.user.data?.entryFlag ? (
  104. <>
  105. <div class="flex flex-wrap">
  106. <ElSkeleton
  107. loading={this.loading}
  108. animated
  109. class="flex justify-between"
  110. count={3}
  111. v-slots={{
  112. template: () => (
  113. <div class="w-[218px]">
  114. <div class="flex flex-col pt-8 w-[218px] rounded-[10px] overflow-hidden m-auto">
  115. <ElSkeletonItem
  116. variant="image"
  117. style={{ width: '100%', height: '122px' }}
  118. ></ElSkeletonItem>
  119. {/* <div class="mx-2.5 py-3.5 border-b border-b-[#F2F2F2]">
  120. <div class="text-lg leading-none font-semibold whitespace-nowrap overflow-hidden text-ellipsis">
  121. <ElSkeletonItem variant="h3"></ElSkeletonItem>
  122. </div>
  123. <div class="text-sm text-[#999] pt-2.5">
  124. <ElSkeletonItem
  125. variant="p"
  126. style={{ width: '50%' }}
  127. ></ElSkeletonItem>
  128. </div>
  129. </div> */}
  130. <div class="text-base px-2.5 pt-2 text-[#666666] leading-none font-semibold whitespace-nowrap overflow-hidden text-ellipsis">
  131. <ElSkeletonItem variant="h3"></ElSkeletonItem>
  132. </div>
  133. <div class="mx-2.5 pt-1.5 pb-2 flex items-center justify-between">
  134. <ElSkeletonItem
  135. variant="p"
  136. style={{ width: '20%' }}
  137. ></ElSkeletonItem>
  138. <p style={{ width: '60%' }}></p>
  139. <ElSkeletonItem
  140. variant="p"
  141. style={{ width: '20%' }}
  142. ></ElSkeletonItem>
  143. </div>
  144. </div>
  145. </div>
  146. )
  147. }}
  148. >
  149. {this.list.map((item: any) => (
  150. <div
  151. class={['w-1/3 pt-8', styles.items]}
  152. onClick={() => this.onDetail(item)}
  153. >
  154. <Item
  155. item={{
  156. type: 'video',
  157. status: this.auditStatus,
  158. id: item.id,
  159. backgroundPic: item.lessonCoverUrl,
  160. courseGroupName: item.lessonName,
  161. studentCount: item.countStudent,
  162. avatar: item.avatar,
  163. teacherName: item.username,
  164. coursePrice: item.lessonPrice,
  165. courseNum: item.lessonCount,
  166. shelvesFlag: item.shelvesFlag
  167. }}
  168. onOffCourse={(item: any) => {
  169. this.onOffCourse(item)
  170. }}
  171. />
  172. </div>
  173. ))}
  174. </ElSkeleton>
  175. </div>
  176. <Pagination
  177. total={this.pageInfo.total}
  178. v-model:page={this.pageInfo.page}
  179. v-model:limit={this.pageInfo.limit}
  180. pageSizes={this.pageInfo.page_size}
  181. pagination={this.getList}
  182. />
  183. {this.dataShow && <ColEmpty />}
  184. </>
  185. ) : (
  186. <ColEmpty
  187. type="teacherCert"
  188. message="您还未完成达人认证,认证后才可创建视频课哦~"
  189. buttonVisibility
  190. buttonText="去认证"
  191. onDetail={() => {
  192. this.$router.push('/teacherAuth')
  193. }}
  194. />
  195. )}
  196. </>
  197. )
  198. }
  199. })