赵雪银 学习记录

develoop
edana 6 months ago
parent 9fee759040
commit d1ea92bb45
  1. 1
      Teaching_integration_platform_admin_template
  2. 6594
      pnpm-lock.yaml
  3. 10
      src/api/record.js
  4. 10
      src/api/user/record.js
  5. 269
      src/views/MyCourseStudy/learningProcess.vue

@ -0,0 +1 @@
Subproject commit be31783972a0cdd8d1abfe03df8ef24a73854b0c

File diff suppressed because it is too large Load Diff

@ -0,0 +1,10 @@
import request from '@/utils/request'
//获取浏览记录列表
export const getRecordListService = (params) =>
request.get('/learningrecords/getall', { params })
//删除浏览记录
export function DelRecordService(ids) {
return request.delete(
`h/learningrecords/delete?ids=${ids}`,
)
}

@ -0,0 +1,10 @@
import request from '@/utils/request'
//获取浏览记录列表
export const getRecordListService = (params) =>
request.get('http://localhost:8080/learningrecords/getall', { params })
//删除浏览记录
export function DelRecordService(ids) {
return request.delete(
`http://localhost:8080/learningrecords/delete?ids=${ids}`,
)
}

@ -1,10 +1,269 @@
<script setup>
// import router from '@/router'
import { ref } from 'vue'
import { getRecordListService, DelRecordService } from '@/api/user/record.js'
import { ElMessageBox, ElMessage } from 'element-plus'
import { useRouter } from 'vue-router'
const total = ref(0)
const recordList = ref([])
const selectedIds = ref([])
const loading = ref(false)
const showCheckbox = ref(false)
const params = ref({
pagesize: '15',
pagenum: '1',
userId: '1',
})
//
const getrecordList = async () => {
loading.value = true
const res = await getRecordListService(params.value)
recordList.value = res.data.list
console.log(res)
//
total.value = res.data.total
loading.value = false
}
getrecordList()
//
const onSizeChange = (size) => {
// console.log('', size)
//访
//
params.value.pagenum = 1
params.value.pagesize = size
//
getrecordList()
}
const onCurrentChange = (page) => {
recordList.value.pagenum = page
getrecordList()
}
//
const onDeleteRecord = async (ids) => {
await ElMessageBox.confirm('你确认删除该条浏览信息吗?', '温馨提示', {
type: 'warning',
confirmButtonText: '确认',
cancelButtonText: '取消',
})
await DelRecordService(ids)
// console.log(ids)
ElMessage({ type: 'success', message: '删除成功' })
getrecordList()
}
//
// change toggleSelection
// id selectedIds
const toggleSelection = (id) => {
if (selectedIds.value.includes(id)) {
selectedIds.value = selectedIds.value.filter((recordId) => recordId !== id)
} else {
selectedIds.value.push(id)
}
console.log(selectedIds)
}
// selectedIds
// selectedIds
// selectedIds record selectedIds
const deleteSelected = async () => {
//
if (selectedIds.value.length === 0) {
await ElMessageBox.confirm('请选择你要删除的内容', '温馨提示', {
type: 'warning',
confirmButtonText: '确认',
})
return
}
await ElMessageBox.confirm('你确认删除浏览记录吗?', '温馨提示', {
type: 'warning',
confirmButtonText: '确认',
cancelButtonText: '取消',
})
//
await DelRecordService(selectedIds.value)
.then(() => {
recordList.value = recordList.value.filter(
(item) => !selectedIds.value.includes(item.id),
)
selectedIds.value = []
})
.catch((error) => {
console.error('删除失败:', error)
})
ElMessage({ type: 'success', message: '删除成功' })
getrecordList()
}
//
const router = useRouter()
const goToAnotherPage = (address) => {
//console.log(address)
router.push(address)
}
</script>
<template> <template>
<div>学习过程</div> <div class="record">
<div class="content">
<!-- 头部 -->
<div class="header">
<el-button type="primary" plain>浏览记录</el-button>
<el-button
type="danger"
plain
style="float: right"
@click="deleteSelected"
>
批量删除
</el-button>
<el-button
type="primary"
plain
@click="toggleCheckbox"
style="float: right"
>
管理
</el-button>
</div>
<!-- 中间 -->
<div class="record-list">
<ul v-if="recordList.length > 0">
<li v-for="record in recordList" :key="record.id" v-loading="loading">
<input
type="checkbox"
:value="record.id"
@change="toggleSelection(record.id)"
v-if="showCheckbox"
/>
<div class="right">
<div class="video">
<img
:src="record.content"
style="width: 100%"
height="100%"
@click="goToAnotherPage(record.address)"
/>
</div>
<div class="info">
<div class="tv">
<div class="name">
{{ record.coursesName }}
</div>
<el-icon
style="float: right"
@click="onDeleteRecord(record.id)"
>
<Delete />
</el-icon>
</div>
<div class="tv">
<div class="time">{{ record.time }}</div>
<div class="views">{{ record.number }} 观看次数</div>
</div>
</div>
</div>
</li>
</ul>
<el-empty v-else description="暂时没有浏览记录" />
</div>
</div>
<!-- 分页 -->
<div class="example-pagination-block">
<el-pagination
v-model:current-page="params.pagenum"
v-model:page-size="params.pagesize"
:page-sizes="[2, 5, 7, 15]"
:background="true"
layout="jumper,total, sizes, prev, pager, next "
:total="total"
@current-change="onCurrentChange"
@size-change="onSizeChange"
style="margin-top: 20px; justify-content: flex-end"
/>
</div>
</div>
</template> </template>
<script lang="ts" setup> <style scoped>
import {} from 'vue' .right {
float: right;
}
</script> .record {
display: flex;
flex-direction: column;
min-height: 100vh;
}
.content {
flex: 1;
}
.example-pagination-block {
position: sticky;
bottom: 0;
margin: 0 auto;
/* text-align: center; */
}
<style lang="scss" scoped></style> .record-list {
margin: 10px 0;
}
ul {
/* flex-wrap: wrap; */
/* margin-bottom: 10px; */
list-style-type: none;
padding: 10;
display: flex;
flex-wrap: wrap;
/* justify-content: space-evenly; */
justify-content: start;
}
li {
transition: filter 0.3s; /* 添加过渡动画 */
flex: 0 0 20%;
/* width: 18%; */
margin-bottom: 10px;
padding: 10px;
box-sizing: border-box;
/* border: 1px solid #ccc; */
/* border-radius: 4px; */
/* text-align: center; */
transition: box-shadow 0.3s;
cursor: pointer;
}
li:hover {
box-shadow: 0 2px 6px rgba(0, 0, 0, 0.2);
}
.video {
width: 100%;
height: 150px;
background-color: #d7e8f2;
}
.info {
display: flex;
/* overflow: hidden; */
flex-direction: column;
}
.name {
float: left;
margin: 5px;
font-size: 15px;
}
.tv {
/* display: grid */
margin: 5px;
font-size: 10px;
display: flex;
justify-content: space-between;
align-items: center;
}
.time {
float: left;
}
.views {
float: right;
}
</style>

Loading…
Cancel
Save