Merge remote-tracking branch 'origin/master'
# Conflicts: # src/views/TextBook/index.vue
This commit is contained in:
commit
b8d7d0b6c7
|
@ -26,3 +26,7 @@ yarn.lock
|
||||||
# 编译生成的文件
|
# 编译生成的文件
|
||||||
auto-imports.d.ts
|
auto-imports.d.ts
|
||||||
components.d.ts
|
components.d.ts
|
||||||
|
|
||||||
|
|
||||||
|
*.zip
|
||||||
|
*.7z
|
||||||
|
|
3103
pnpm-lock.yaml
3103
pnpm-lock.yaml
File diff suppressed because it is too large
Load Diff
Binary file not shown.
After Width: | Height: | Size: 419 B |
Binary file not shown.
After Width: | Height: | Size: 419 B |
|
@ -0,0 +1,98 @@
|
||||||
|
<!-- jz排序组件 -->
|
||||||
|
<template>
|
||||||
|
<div class="jzSortCom">
|
||||||
|
<div class="jsItem" v-for="{ label, key } in sortData" :key="key" @click.stop="handleSortChange(key)">
|
||||||
|
<!-- 排序字段名称 -->
|
||||||
|
<span>{{ label }}</span>
|
||||||
|
<!-- 排序图标 -->
|
||||||
|
<div class="isIconList">
|
||||||
|
<img :src="getSortIcon(key, 'asc')" class="up" />
|
||||||
|
<img :src="getSortIcon(key, 'desc')" />
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</template>
|
||||||
|
|
||||||
|
<script setup>
|
||||||
|
import sortIcon from '@/assets/images/sortIcon.png'; // 排序图标
|
||||||
|
import sortIconAct from '@/assets/images/sortIconAct.png'; // 排序图标-选中
|
||||||
|
|
||||||
|
defineProps({
|
||||||
|
// 排序初始化数据 Array<{ label: string; key: string }>
|
||||||
|
sortData: {
|
||||||
|
type: Array,
|
||||||
|
default: () => []
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
|
const sortRes = defineModel({}); // 组件值 {key: string; order: 'asc' | 'desc' | ''}
|
||||||
|
|
||||||
|
// 获取排序图标
|
||||||
|
const getSortIcon = (key, order) => {
|
||||||
|
return sortRes.value.key === key && sortRes.value.order === order ? sortIconAct : sortIcon;
|
||||||
|
};
|
||||||
|
|
||||||
|
// 排序change事件
|
||||||
|
const handleSortChange = (keyName) => {
|
||||||
|
// 排序映射
|
||||||
|
const sortMap = new Map([
|
||||||
|
[1, 'desc'],
|
||||||
|
[2, 'asc'],
|
||||||
|
[3, ''],
|
||||||
|
['desc', 1],
|
||||||
|
['asc', 2],
|
||||||
|
['', 3],
|
||||||
|
[undefined, 3]
|
||||||
|
]);
|
||||||
|
const { key, order } = sortRes.value;
|
||||||
|
let kn = keyName; // 当前点击的key
|
||||||
|
let st = 1; // 同上映射:1 降序 2 升序 3 无排序
|
||||||
|
if (keyName === key) {
|
||||||
|
const orderNum = sortMap.get(order); // 当前排序状态
|
||||||
|
st = orderNum === 3 ? 1 : orderNum + 1; // 下一个排序状态
|
||||||
|
}
|
||||||
|
sortRes.value = { key: kn, order: sortMap.get(st) }; // 更新排序状态
|
||||||
|
};
|
||||||
|
</script>
|
||||||
|
|
||||||
|
<style scoped lang="scss">
|
||||||
|
.jzSortCom {
|
||||||
|
display: flex;
|
||||||
|
align-items: center;
|
||||||
|
|
||||||
|
.jsItem {
|
||||||
|
display: flex;
|
||||||
|
align-items: center;
|
||||||
|
font-size: 15px;
|
||||||
|
color: #a8abb2;
|
||||||
|
letter-spacing: 1px;
|
||||||
|
font-weight: 600;
|
||||||
|
cursor: pointer;
|
||||||
|
|
||||||
|
.isIconList {
|
||||||
|
display: flex;
|
||||||
|
align-items: center;
|
||||||
|
justify-content: center;
|
||||||
|
flex-direction: column;
|
||||||
|
margin-left: 6px;
|
||||||
|
img {
|
||||||
|
width: 10px;
|
||||||
|
height: auto;
|
||||||
|
background-color: transparent;
|
||||||
|
|
||||||
|
&.up {
|
||||||
|
transform: rotate(180deg);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
img + img {
|
||||||
|
margin-top: 2px;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
.jsItem + .jsItem {
|
||||||
|
margin-left: 60px;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
</style>
|
|
@ -27,7 +27,6 @@
|
||||||
</el-checkbox-group>
|
</el-checkbox-group>
|
||||||
</el-form-item>
|
</el-form-item>
|
||||||
|
|
||||||
|
|
||||||
<el-form-item label="学科">
|
<el-form-item label="学科">
|
||||||
<el-checkbox-group>
|
<el-checkbox-group>
|
||||||
<el-checkbox-button>语文</el-checkbox-button>
|
<el-checkbox-button>语文</el-checkbox-button>
|
||||||
|
@ -57,7 +56,6 @@
|
||||||
</el-checkbox-group>
|
</el-checkbox-group>
|
||||||
</el-form-item>
|
</el-form-item>
|
||||||
|
|
||||||
|
|
||||||
<el-form-item label="类型">
|
<el-form-item label="类型">
|
||||||
<el-checkbox-group>
|
<el-checkbox-group>
|
||||||
<el-checkbox-button>全部</el-checkbox-button>
|
<el-checkbox-button>全部</el-checkbox-button>
|
||||||
|
@ -83,7 +81,7 @@
|
||||||
</el-form>
|
</el-form>
|
||||||
</el-card>
|
</el-card>
|
||||||
|
|
||||||
<el-row :gutter="10" style="margin-top: 10px;">
|
<el-row :gutter="10" style="margin-top: 10px">
|
||||||
<el-col :span="6">
|
<el-col :span="6">
|
||||||
<el-card>
|
<el-card>
|
||||||
<template #header>
|
<template #header>
|
||||||
|
@ -101,26 +99,21 @@
|
||||||
<el-col :span="18">
|
<el-col :span="18">
|
||||||
<el-card>
|
<el-card>
|
||||||
<div class="card-right-header">
|
<div class="card-right-header">
|
||||||
<el-table :data="tableSortData" :default-sort="{ prop: 'date', order: 'descending' }">
|
<!-- 排序组件 -->
|
||||||
<el-table-column prop="date" label="上传时间" sortable width="180" />
|
<JzSort v-model="sortResult" :sortData="sortData" />
|
||||||
<el-table-column prop="name" label="浏览量" sortable width="180" />
|
|
||||||
<el-table-column prop="address" label="下载量" sortable width="180" />
|
|
||||||
</el-table>
|
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
<div class="book-grid">
|
<div class="book-grid">
|
||||||
<el-card v-for="item in 6">
|
<el-card v-for="item in 6" :key="item">
|
||||||
<div class="book-content">
|
<div class="book-content">
|
||||||
<img class="file-type" src="@/assets/images/word.png" alt="">
|
<img class="file-type" src="@/assets/images/word.png" alt="" />
|
||||||
<img src="@/assets/images/book.png" alt="">
|
<img src="@/assets/images/book.png" alt="" />
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
<template #footer>
|
<template #footer>
|
||||||
<div class="book-title">汉字文化云课堂</div>
|
<div class="book-title">汉字文化云课堂</div>
|
||||||
<div class="book-des">
|
<div class="book-des">
|
||||||
<div class="book-teacher">
|
<div class="book-teacher"><span>蒋老师</span> | <span>一年级(2)班</span></div>
|
||||||
<span>王老师</span> | <span>一年级(2)班</span>
|
|
||||||
</div>
|
|
||||||
<div class="book-view">
|
<div class="book-view">
|
||||||
<span>
|
<span>
|
||||||
<el-icon>
|
<el-icon>
|
||||||
|
@ -141,17 +134,19 @@
|
||||||
</template>
|
</template>
|
||||||
|
|
||||||
<script setup>
|
<script setup>
|
||||||
import { ref } from 'vue'
|
import { ref, watchEffect } from 'vue';
|
||||||
import { View } from '@element-plus/icons-vue'
|
import { View } from '@element-plus/icons-vue';
|
||||||
|
|
||||||
|
import JzSort from '@/components/JzSort/index.vue';
|
||||||
|
|
||||||
const tableData = [
|
const tableData = [
|
||||||
{
|
{
|
||||||
id: 1,
|
id: 1,
|
||||||
name: '全部',
|
name: '全部'
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
id: 2,
|
id: 2,
|
||||||
name: '我上学了',
|
name: '我上学了'
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
id: 3,
|
id: 3,
|
||||||
|
@ -159,42 +154,33 @@ const tableData = [
|
||||||
children: [
|
children: [
|
||||||
{
|
{
|
||||||
id: 31,
|
id: 31,
|
||||||
name: '1 天地人',
|
name: '1 天地人'
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
id: 32,
|
id: 32,
|
||||||
name: '2金木水火土',
|
name: '2金木水火土'
|
||||||
},
|
}
|
||||||
],
|
]
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
id: 4,
|
id: 4,
|
||||||
name: '汉语拼音',
|
name: '汉语拼音'
|
||||||
},
|
}
|
||||||
]
|
];
|
||||||
|
|
||||||
const tableSortData = [
|
// 排序初始化数据
|
||||||
{
|
const sortData = [
|
||||||
date: '2016-05-03',
|
{ label: '上传时间', key: 'date' },
|
||||||
name: 'Tom',
|
{ label: '浏览量', key: 'num1' },
|
||||||
address: 'No. 189, Grove St, Los Angeles',
|
{ label: '下载量', key: 'num2' }
|
||||||
},
|
];
|
||||||
{
|
const sortResult = ref({}); // 排序结果
|
||||||
date: '2016-05-02',
|
|
||||||
name: 'Tom',
|
// 监听排序结果
|
||||||
address: 'No. 189, Grove St, Los Angeles',
|
watchEffect(() => {
|
||||||
},
|
console.log('===排序 改变了===', sortResult.value);
|
||||||
{
|
// TODO: 排序逻辑
|
||||||
date: '2016-05-04',
|
});
|
||||||
name: 'Tom',
|
|
||||||
address: 'No. 189, Grove St, Los Angeles',
|
|
||||||
},
|
|
||||||
{
|
|
||||||
date: '2016-05-01',
|
|
||||||
name: 'Tom',
|
|
||||||
address: 'No. 189, Grove St, Los Angeles',
|
|
||||||
},
|
|
||||||
]
|
|
||||||
</script>
|
</script>
|
||||||
|
|
||||||
<style lang="scss" scoped>
|
<style lang="scss" scoped>
|
||||||
|
@ -223,9 +209,9 @@ const tableSortData = [
|
||||||
}
|
}
|
||||||
|
|
||||||
.card-right-header {
|
.card-right-header {
|
||||||
:deep(.el-table__body-wrapper) {
|
padding-bottom: 12px;
|
||||||
display: none;
|
border-bottom: 1px solid #ebeef5;
|
||||||
}
|
margin-bottom: 16px;
|
||||||
}
|
}
|
||||||
|
|
||||||
.book-grid {
|
.book-grid {
|
||||||
|
@ -266,3 +252,4 @@ const tableSortData = [
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
</style>
|
</style>
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue