| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359 |
- <template>
- <div class="courseware-list">
- <div class="toolbar">
- <button
- v-for="item in statusList"
- :key="item.key"
- :class="['filter-btn', { active: curStatus === item.key }]"
- type="button"
- @click="changeStatus(item.key)"
- >
- {{ item.label }}
- </button>
- <div class="search-wrap">
- <el-input
- v-model.trim="searchText"
- class="search-input"
- placeholder="搜素关键词..."
- @keydown.enter.native="getList({ cur_page: 1 })"
- >
- <el-button slot="prepend" icon="el-icon-search" @click="getList({ cur_page: 1 })" />
- <el-button slot="append" icon="el-icon-close" @click="clearSearch" />
- </el-input>
- </div>
- </div>
- <div class="card-grid">
- <slot name="card"></slot>
- </div>
- <div class="pagination">
- <div class="pagination-lite">共 {{ total }} 本教材</div>
- <PaginationPage
- :is-init="false"
- layout="prev, pager, next, jumper"
- :total="total"
- :page-size="9"
- @getList="getList"
- />
- </div>
- </div>
- </template>
- <script>
- import PaginationPage from '@/components/PaginationPage.vue';
- export default {
- name: 'CoursewareList',
- components: {
- PaginationPage,
- },
- props: {
- statusList: {
- type: Array,
- required: true,
- },
- currentStatus: {
- type: String,
- default: 'all',
- },
- total: {
- type: Number,
- default: 0,
- },
- },
- data() {
- return {
- curStatus: this.currentStatus,
- searchText: '',
- };
- },
- computed: {
- totalPages() {
- return Math.max(1, Math.ceil(this.total / this.pageSize));
- },
- },
- methods: {
- /**
- * 切换状态
- * @param {string} status - 状态值
- */
- changeStatus(status) {
- this.curStatus = status;
- this.$emit('update:currentStatus', status);
- this.$emit('getList', { cur_page: 1, name: this.searchText });
- },
- /**
- * 获取列表数据
- * @param {Object} data - 额外的查询参数
- */
- getList(data) {
- this.$emit('getList', { ...data, name: this.searchText });
- },
- clearSearch() {
- this.searchText = '';
- this.getList({ cur_page: 1 });
- },
- },
- };
- </script>
- <style lang="scss" scoped>
- .courseware-list {
- display: flex;
- flex-direction: column;
- width: 1280px;
- padding: 0 0 12px;
- margin: 0 auto;
- overflow: hidden;
- background: #f7f9fe;
- .toolbar {
- display: flex;
- gap: 10px;
- align-items: center;
- margin: 80px 0 22px;
- .filter-btn {
- padding: 6px 18px;
- font-size: 13px;
- color: #64748b;
- cursor: pointer;
- background: #fff;
- border: 1px solid #e2e8f0;
- border-radius: 20px;
- transition: all 0.25s ease;
- &:hover {
- color: #2d3e8f;
- border-color: #2d3e8f;
- }
- &.active {
- color: #fff;
- background: #2d3e8f;
- border-color: #2d3e8f;
- }
- }
- .search-icon-btn {
- width: 32px;
- height: 32px;
- padding: 0;
- color: #64748b;
- cursor: pointer;
- background: #fff;
- border: 1px solid #e2e8f0;
- border-radius: 50%;
- }
- .search-input {
- width: 210px;
- height: 32px;
- padding: 0 12px;
- color: #1f2937;
- background: #fff;
- border: 1px solid #fcfcfc;
- border-radius: 16px;
- outline: none;
- box-shadow: 0 2px 10px rgba(0, 0, 0, 15%);
- :deep(.el-input__inner) {
- background-color: #fff;
- border: none;
- }
- .el-button {
- background-color: #fff;
- }
- :deep(.el-input-group__prepend),
- :deep(.el-input-group__append) {
- color: #000;
- background-color: #fff;
- border: none;
- .el-button {
- padding: 8px 0;
- }
- }
- :deep(.el-input-group__prepend) {
- padding-right: 0;
- }
- :deep(.el-input-group__append) {
- padding-right: 0;
- }
- }
- }
- .card-grid {
- display: grid;
- flex: 1;
- grid-template-rows: repeat(2, minmax(0, 1fr));
- grid-template-columns: repeat(3, minmax(0, 1fr));
- gap: 20px;
- min-height: 0;
- overflow: hidden;
- .prod-card {
- display: flex;
- height: 191px;
- overflow: hidden;
- cursor: pointer;
- background: #fff;
- border: 1px solid rgba(226, 232, 240, 40%);
- border-radius: 12px;
- box-shadow: 0 2px 10px rgba(0, 0, 0, 3%);
- transition: all 0.25s ease;
- &:hover {
- box-shadow: 0 6px 20px rgba(45, 62, 143, 7%);
- transform: translateY(-2px);
- }
- .card-cover {
- width: 130px;
- min-height: 185px;
- color: #fff;
- background: linear-gradient(180deg, #4a90d9, #2d6cbf);
- img {
- width: 100%;
- height: 100%;
- object-fit: cover;
- }
- }
- .card-right {
- display: flex;
- flex: 1;
- flex-direction: column;
- padding: 16px 18px 14px;
- }
- .card-name {
- margin-bottom: 12px;
- font-size: 15px;
- font-weight: 600;
- color: #1f2937;
- }
- .card-meta {
- display: flex;
- flex: 1;
- flex-direction: column;
- gap: 16px;
- }
- .meta-row {
- display: flex;
- gap: 8px;
- align-items: center;
- font-size: 12px;
- color: #64748b;
- }
- .meta-label {
- min-width: 60px;
- }
- .avatar-group {
- display: flex;
- }
- .mini-avatar {
- display: flex;
- align-items: center;
- justify-content: center;
- width: 22px;
- height: 22px;
- margin-left: -4px;
- font-size: 10px;
- color: #fff;
- background: #2d3e8f;
- border: 2px solid #fff;
- border-radius: 50%;
- &:first-child {
- margin-left: 0;
- }
- }
- .card-time {
- font-size: 11px;
- color: #94a3b8;
- }
- .card-bottom {
- display: flex;
- gap: 10px;
- align-items: center;
- padding-top: 12px;
- }
- .progress-bar {
- flex: 1;
- height: 6px;
- overflow: hidden;
- background: #e5e7eb;
- border-radius: 3px;
- .fill {
- height: 100%;
- background: #4a7dd4;
- border-radius: 3px;
- }
- }
- .progress-text {
- font-size: 11px;
- color: #94a3b8;
- }
- .status-btn {
- padding: 4px 12px;
- font-size: 12px;
- border: none;
- border-radius: 16px;
- &.building {
- color: #f59e0b;
- background: #fef3c7;
- }
- &.reviewing {
- color: #8b5cf6;
- background: #ede9fe;
- }
- &.done {
- color: #3b82f6;
- background: #dbeafe;
- }
- &.published {
- color: #10b981;
- background: #d1fae5;
- }
- }
- }
- }
- .pagination {
- display: flex;
- column-gap: 20px;
- align-items: center;
- justify-content: center;
- margin-top: 36px;
- .pagination-lite {
- font-size: 13px;
- color: #94a3b8;
- text-align: center;
- }
- }
- }
- </style>
|