CoursewareList.vue 7.6 KB

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