CoursewareList.vue 7.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359
  1. <template>
  2. <div class="courseware-list">
  3. <div class="toolbar">
  4. <button
  5. v-for="item in statusList"
  6. :key="item.key"
  7. :class="['filter-btn', { active: curStatus === item.key }]"
  8. type="button"
  9. @click="changeStatus(item.key)"
  10. >
  11. {{ item.label }}
  12. </button>
  13. <div class="search-wrap">
  14. <el-input
  15. v-model.trim="searchText"
  16. class="search-input"
  17. placeholder="搜素关键词..."
  18. @keydown.enter.native="getList({ cur_page: 1 })"
  19. >
  20. <el-button slot="prepend" icon="el-icon-search" @click="getList({ cur_page: 1 })" />
  21. <el-button slot="append" icon="el-icon-close" @click="clearSearch" />
  22. </el-input>
  23. </div>
  24. </div>
  25. <div class="card-grid">
  26. <slot name="card"></slot>
  27. </div>
  28. <div class="pagination">
  29. <div class="pagination-lite">共 {{ total }} 本教材</div>
  30. <PaginationPage
  31. :is-init="false"
  32. layout="prev, pager, next, jumper"
  33. :total="total"
  34. :page-size="9"
  35. @getList="getList"
  36. />
  37. </div>
  38. </div>
  39. </template>
  40. <script>
  41. import PaginationPage from '@/components/PaginationPage.vue';
  42. export default {
  43. name: 'CoursewareList',
  44. components: {
  45. PaginationPage,
  46. },
  47. props: {
  48. statusList: {
  49. type: Array,
  50. required: true,
  51. },
  52. currentStatus: {
  53. type: String,
  54. default: 'all',
  55. },
  56. total: {
  57. type: Number,
  58. default: 0,
  59. },
  60. },
  61. data() {
  62. return {
  63. curStatus: this.currentStatus,
  64. searchText: '',
  65. };
  66. },
  67. computed: {
  68. totalPages() {
  69. return Math.max(1, Math.ceil(this.total / this.pageSize));
  70. },
  71. },
  72. methods: {
  73. /**
  74. * 切换状态
  75. * @param {string} status - 状态值
  76. */
  77. changeStatus(status) {
  78. this.curStatus = status;
  79. this.$emit('update:currentStatus', status);
  80. this.$emit('getList', { cur_page: 1, name: this.searchText });
  81. },
  82. /**
  83. * 获取列表数据
  84. * @param {Object} data - 额外的查询参数
  85. */
  86. getList(data) {
  87. this.$emit('getList', { ...data, name: this.searchText });
  88. },
  89. clearSearch() {
  90. this.searchText = '';
  91. this.getList({ cur_page: 1 });
  92. },
  93. },
  94. };
  95. </script>
  96. <style lang="scss" scoped>
  97. .courseware-list {
  98. display: flex;
  99. flex-direction: column;
  100. width: 1280px;
  101. padding: 0 0 12px;
  102. margin: 0 auto;
  103. overflow: hidden;
  104. background: #f7f9fe;
  105. .toolbar {
  106. display: flex;
  107. gap: 10px;
  108. align-items: center;
  109. margin: 80px 0 22px;
  110. .filter-btn {
  111. padding: 6px 18px;
  112. font-size: 13px;
  113. color: #64748b;
  114. cursor: pointer;
  115. background: #fff;
  116. border: 1px solid #e2e8f0;
  117. border-radius: 20px;
  118. transition: all 0.25s ease;
  119. &:hover {
  120. color: #2d3e8f;
  121. border-color: #2d3e8f;
  122. }
  123. &.active {
  124. color: #fff;
  125. background: #2d3e8f;
  126. border-color: #2d3e8f;
  127. }
  128. }
  129. .search-icon-btn {
  130. width: 32px;
  131. height: 32px;
  132. padding: 0;
  133. color: #64748b;
  134. cursor: pointer;
  135. background: #fff;
  136. border: 1px solid #e2e8f0;
  137. border-radius: 50%;
  138. }
  139. .search-input {
  140. width: 210px;
  141. height: 32px;
  142. padding: 0 12px;
  143. color: #1f2937;
  144. background: #fff;
  145. border: 1px solid #fcfcfc;
  146. border-radius: 16px;
  147. outline: none;
  148. box-shadow: 0 2px 10px rgba(0, 0, 0, 15%);
  149. :deep(.el-input__inner) {
  150. background-color: #fff;
  151. border: none;
  152. }
  153. .el-button {
  154. background-color: #fff;
  155. }
  156. :deep(.el-input-group__prepend),
  157. :deep(.el-input-group__append) {
  158. color: #000;
  159. background-color: #fff;
  160. border: none;
  161. .el-button {
  162. padding: 8px 0;
  163. }
  164. }
  165. :deep(.el-input-group__prepend) {
  166. padding-right: 0;
  167. }
  168. :deep(.el-input-group__append) {
  169. padding-right: 0;
  170. }
  171. }
  172. }
  173. .card-grid {
  174. display: grid;
  175. flex: 1;
  176. grid-template-rows: repeat(2, minmax(0, 1fr));
  177. grid-template-columns: repeat(3, minmax(0, 1fr));
  178. gap: 20px;
  179. min-height: 0;
  180. overflow: hidden;
  181. .prod-card {
  182. display: flex;
  183. height: 191px;
  184. overflow: hidden;
  185. cursor: pointer;
  186. background: #fff;
  187. border: 1px solid rgba(226, 232, 240, 40%);
  188. border-radius: 12px;
  189. box-shadow: 0 2px 10px rgba(0, 0, 0, 3%);
  190. transition: all 0.25s ease;
  191. &:hover {
  192. box-shadow: 0 6px 20px rgba(45, 62, 143, 7%);
  193. transform: translateY(-2px);
  194. }
  195. .card-cover {
  196. width: 130px;
  197. min-height: 185px;
  198. color: #fff;
  199. background: linear-gradient(180deg, #4a90d9, #2d6cbf);
  200. img {
  201. width: 100%;
  202. height: 100%;
  203. object-fit: cover;
  204. }
  205. }
  206. .card-right {
  207. display: flex;
  208. flex: 1;
  209. flex-direction: column;
  210. padding: 16px 18px 14px;
  211. }
  212. .card-name {
  213. margin-bottom: 12px;
  214. font-size: 15px;
  215. font-weight: 600;
  216. color: #1f2937;
  217. }
  218. .card-meta {
  219. display: flex;
  220. flex: 1;
  221. flex-direction: column;
  222. gap: 16px;
  223. }
  224. .meta-row {
  225. display: flex;
  226. gap: 8px;
  227. align-items: center;
  228. font-size: 12px;
  229. color: #64748b;
  230. }
  231. .meta-label {
  232. min-width: 60px;
  233. }
  234. .avatar-group {
  235. display: flex;
  236. }
  237. .mini-avatar {
  238. display: flex;
  239. align-items: center;
  240. justify-content: center;
  241. width: 22px;
  242. height: 22px;
  243. margin-left: -4px;
  244. font-size: 10px;
  245. color: #fff;
  246. background: #2d3e8f;
  247. border: 2px solid #fff;
  248. border-radius: 50%;
  249. &:first-child {
  250. margin-left: 0;
  251. }
  252. }
  253. .card-time {
  254. font-size: 11px;
  255. color: #94a3b8;
  256. }
  257. .card-bottom {
  258. display: flex;
  259. gap: 10px;
  260. align-items: center;
  261. padding-top: 12px;
  262. }
  263. .progress-bar {
  264. flex: 1;
  265. height: 6px;
  266. overflow: hidden;
  267. background: #e5e7eb;
  268. border-radius: 3px;
  269. .fill {
  270. height: 100%;
  271. background: #4a7dd4;
  272. border-radius: 3px;
  273. }
  274. }
  275. .progress-text {
  276. font-size: 11px;
  277. color: #94a3b8;
  278. }
  279. .status-btn {
  280. padding: 4px 12px;
  281. font-size: 12px;
  282. border: none;
  283. border-radius: 16px;
  284. &.building {
  285. color: #f59e0b;
  286. background: #fef3c7;
  287. }
  288. &.reviewing {
  289. color: #8b5cf6;
  290. background: #ede9fe;
  291. }
  292. &.done {
  293. color: #3b82f6;
  294. background: #dbeafe;
  295. }
  296. &.published {
  297. color: #10b981;
  298. background: #d1fae5;
  299. }
  300. }
  301. }
  302. }
  303. .pagination {
  304. display: flex;
  305. column-gap: 20px;
  306. align-items: center;
  307. justify-content: center;
  308. margin-top: 36px;
  309. .pagination-lite {
  310. font-size: 13px;
  311. color: #94a3b8;
  312. text-align: center;
  313. }
  314. }
  315. }
  316. </style>