develoop
edana 5 months ago
parent d2712808e3
commit 2bec33e17b
  1. 10
      src/api/user/record.js
  2. 9
      src/api/user/resource.js
  3. 20
      src/views/MyCourseStudy/learningProcess.vue
  4. 140
      src/views/courseResources/componse/resourceAdd.vue
  5. 129
      src/views/courseResources/index.vue

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

@ -1,9 +0,0 @@
import request from '@/utils/request'
//获取ppt资源列表
export const getpptResourceListService = (params) =>
request.get('http://localhost:8080/courses/getall', { params })
export function DelpptResourceListService(ids) {
return request.delete(
`http://localhost:8080/learningrecords/delete?ids=${ids}`,
)
}

@ -1,10 +1,10 @@
<script setup> <script setup>
// import router from '@/router' // import router from '@/router'
import { ref } from 'vue' import { ref } from 'vue'
//getRecordListService,
import { DelRecordService } from '@/api/user/record.js'
import { ElMessageBox, ElMessage } from 'element-plus' import { ElMessageBox, ElMessage } from 'element-plus'
import { useRouter } from 'vue-router' import { useRouter } from 'vue-router'
//
import { LearningRecordsControllerService } from '../../../generated/services/LearningRecordsControllerService' import { LearningRecordsControllerService } from '../../../generated/services/LearningRecordsControllerService'
const total = ref(0) const total = ref(0)
const recordList = ref([]) const recordList = ref([])
@ -19,12 +19,14 @@ const params = ref({
// //
const getrecordList = async () => { const getrecordList = async () => {
console.log(1111111) //console.log(1111111)
loading.value = true loading.value = true
// const res = await getRecordListService(params.value) // const res = await getRecordListService(params.value)
const res = await LearningRecordsControllerService.getAllUsingGet3( const res = await LearningRecordsControllerService.getAllUsingGet3(
params.value, params.value.userId,
params.value.pagenum,
params.value.pagesize,
) )
recordList.value = res.data.records recordList.value = res.data.records
console.log(res) console.log(res)
@ -55,7 +57,11 @@ const onDeleteRecord = async (ids) => {
confirmButtonText: '确认', confirmButtonText: '确认',
cancelButtonText: '取消', cancelButtonText: '取消',
}) })
await DelRecordService(ids) //await DelRecordService(ids)
console.log('hello')
await LearningRecordsControllerService.deleteRecordsUsingDelete3(ids)
// console.log(ids) // console.log(ids)
ElMessage({ type: 'success', message: '删除成功' }) ElMessage({ type: 'success', message: '删除成功' })
getrecordList() getrecordList()
@ -97,7 +103,9 @@ const deleteSelected = async () => {
}) })
// //
await DelRecordService(selectedIds.value) await LearningRecordsControllerService.deleteRecordsUsingDelete3(
selectedIds.value,
)
.then(() => { .then(() => {
recordList.value = recordList.value.filter( recordList.value = recordList.value.filter(
(item) => !selectedIds.value.includes(item.id), (item) => !selectedIds.value.includes(item.id),

@ -1,5 +1,141 @@
<script setup></script> <script setup>
import { ref } from 'vue'
const props = defineProps(['dafulIndex'])
//
const visibleDramwer = ref(false)
//
const defaultForm = {
description: '',
id: '',
img: '',
name: '',
type: '',
path: '',
}
//
const formModel = ref({
...defaultForm,
})
//
const imgUrl = ref('')
const onSelectFile = (uploadFile) => {
imgUrl.value = URL.createObjectURL(uploadFile.raw)
}
//selectedOption
// const selectedOption = ref('')
//
// import tool from '@/utils/oss.js'
// const FileList = ref([])
// const upload = async (option) => {
// const res = await tool.oss.upload(option.file)
// console.log(22, res)
// console.log(res.name)
// const url = 'https://wenyu132.oss-cn-beijing.aliyuncs.com/' + res.name
// console.log(url)
// }
//open
const open = (row) => {
visibleDramwer.value = true
if (row.id) {
//row.id
console.log('编辑回显')
} else {
//
formModel.value = {
...defaultForm,
}
}
}
defineExpose({
open,
})
const selectVal = ref(props.dafulIndex)
const selectOp = ref([
{ label: 'ppt', value: '1' },
{ label: '图片', value: '2' },
{ label: '视频', value: '3' },
{ label: 'PDF', value: '4' },
{ label: '文件', value: '5' },
{ label: '音频', value: '6' },
])
function handleSel() {}
</script>
<template> <template>
<div></div> <el-drawer
v-model="visibleDramwer"
:title="formModel.id ? '编辑资源' : '添加资源'"
direction="rtl"
size="50%"
>
<!-- 添加资源表单 -->
<el-form :model="formModel" ref="formRef" label-width="100px">
<el-form-item label="资源名称" prop="name">
<el-input
v-model="formModel.name"
placeholder="请输入资源名称"
></el-input>
</el-form-item>
<el-form-item label="资源类型">
<div class="flex flex-wrap gap-4 items-center">
<el-select
@change="handleSel"
v-model="selectVal"
placeholder="Select"
size="large"
style="width: 240px"
>
<el-option
v-for="item in selectOp"
:key="item.value"
:label="item.label"
:value="item.value"
/>
</el-select>
</div>
</el-form-item>
<el-form-item label="资源简介" prop="description">
资源简介
<!-- <el-input
v-model="formModel.description"
placeholder="请输入资源简介"
></el-input> -->
</el-form-item>
<el-form-item label="上传资源" prop="img">
<!-- 此处需要关闭element-plus的自动上传不需要配置action等参数
只需要前端的本地预览图片无需在提交前上传图标
-->
<el-upload
class="avatar-uploader"
:show-file-list="false"
:auto-upload="false"
:onchange="onSelectFile"
>
<img v-if="imgUrl" :src="imgUrl" class="avatar" />
<el-icon v-else class="avatar-uploader-icon">
<Plus />
</el-icon>
</el-upload>
<!-- <el-upload
v-model:file-list="FileList"
:http-request="upload"
class="upload-demo"
multiple
>
<el-button type="primary">点击上传</el-button>
<template #tip>
<div class="el-upload__tip">只能上传jpg/png文件,且不超过500kb</div>
</template>
</el-upload> -->
</el-form-item>
<el-form-item class="bottom-box">
<el-button type="info" @click="onRemoval">取消</el-button>
<el-button type="primary">确定</el-button>
</el-form-item>
</el-form>
</el-drawer>
</template> </template>
<style scoped></style> <style scoped></style>

@ -7,14 +7,14 @@ import pdf from '@/assets/icons/pdf (1).png'
import test from '@/assets/icons/文件.png' import test from '@/assets/icons/文件.png'
import audio from '@/assets/icons/音频1.png' import audio from '@/assets/icons/音频1.png'
import { ElMessageBox, ElMessage } from 'element-plus'
import { ref } from 'vue' import { ref } from 'vue'
//
const visibleDramwer = ref(false)
//selectedOption
const selectedOption = ref('')
import { getpptResourceListService } from '@/api/user/resource.js' import { LearningRecordsControllerService } from '../../../generated/services/LearningRecordsControllerService'
import { DelpptResourceListService } from '@/api/user/resource.js' import { CourseResourceControllerService } from '../../../generated/services/CourseResourceControllerService'
import resourceAdd from './componse/resourceAdd.vue'
const total = ref(0) const total = ref(0)
const pptresourceList = ref([]) const pptresourceList = ref([])
const loading = ref(false) const loading = ref(false)
@ -27,7 +27,11 @@ const params = ref({
// //
const getpptresourceList = async () => { const getpptresourceList = async () => {
loading.value = true loading.value = true
const res = await getpptResourceListService(params.value) const res = await CourseResourceControllerService.getAllUsingGet1(
params.value.pagenum,
params.value.pagesize,
params.value.type,
)
pptresourceList.value = res.data.records pptresourceList.value = res.data.records
console.log(res) console.log(res)
// //
@ -59,81 +63,49 @@ const onCurrentChange = (page) => {
// -ID // -ID
const onDeleteResource = async (ids) => { const onDeleteResource = async (ids) => {
console.log(111111111111111)
await ElMessageBox.confirm('你确认删除该条浏览信息吗?', '温馨提示', { await ElMessageBox.confirm('你确认删除该条浏览信息吗?', '温馨提示', {
type: 'warning', type: 'warning',
confirmButtonText: '确认', confirmButtonText: '确认',
cancelButtonText: '取消', cancelButtonText: '取消',
}) })
await DelpptResourceListService(ids) console.log(ids)
// console.log(ids) await CourseResourceControllerService.deleteRecordsUsingDelete1(ids)
ElMessage({ type: 'success', message: '删除成功' }) ElMessage({ type: 'success', message: '删除成功' })
getpptresourceList() getpptresourceList()
} }
//
import tool from '@/utils/oss.js' const param = ref({
const FileList = ref([]) coursesId: '',
const upload = async (option) => { userId: '1',
const res = await tool.oss.upload(option.file) open: '1',
console.log(22, res) download: '0',
console.log(res.name) content: '',
const url = 'https://wenyu132.oss-cn-beijing.aliyuncs.com/' + res.name address: '/portal',
console.log(url) type: '4',
})
//
const generateRecords = async (rescource) => {
param.value.content = rescource.img
param.value.coursesId = rescource.id.toString()
await LearningRecordsControllerService.saveRecordsUsingPost1(param.value)
// console.log(param)
}
const resourceAddRef = ref()
//
const onAddResource = () => {
resourceAddRef.value.open({})
}
//
const onEditResource = (row) => {
resourceAddRef.value.open(row)
} }
</script> </script>
<template> <template>
<div> <div>
<div class="top"> <div class="top">
<el-button @click="visibleDramwer = true">添加资源</el-button> <el-button @click="onAddResource">添加资源</el-button>
<el-drawer v-model="visibleDramwer">
<!-- 添加资源表单 -->
<el-form>
<el-form-item label="资源名称">
<el-input placeholder="请输入资源名称"></el-input>
</el-form-item>
<el-form-item label="资源类型">
<el-select v-model="selectedOption" placeholder="资源类型">
<el-option
class="vertical-option"
label="选项1"
value="1"
></el-option>
<el-option
class="vertical-option"
label="选项2"
value="2"
></el-option>
<el-option
class="vertical-option"
label="选项3"
value="3"
></el-option>
</el-select>
</el-form-item>
<el-form-item label="资源简介">
<el-input placeholder="请输入资源简介"></el-input>
</el-form-item>
<el-form-item label="上传资源">
<el-upload
v-model:file-list="FileList"
:http-request="upload"
class="upload-demo"
multiple
>
<el-button type="primary">点击上传</el-button>
<template #tip>
<div class="el-upload__tip">
只能上传jpg/png文件,且不超过500kb
</div>
</template>
</el-upload>
</el-form-item>
<el-form-item class="bottom-box">
<el-button type="info" @click="onRemoval">取消</el-button>
<el-button type="primary">确定</el-button>
</el-form-item>
</el-form>
</el-drawer>
</div> </div>
<div class="body"> <div class="body">
<div class="nav"> <div class="nav">
@ -155,7 +127,7 @@ const upload = async (option) => {
</div> </div>
</el-col> </el-col>
<el-col :span="4" @click="showComponent('3')"> <el-col :span="4" @click="changeType('3')">
<div class="nav-info"> <div class="nav-info">
<div class="nav-info-pic"> <div class="nav-info-pic">
<img style="height: 50px" :src="video" /> <img style="height: 50px" :src="video" />
@ -165,13 +137,13 @@ const upload = async (option) => {
</el-col> </el-col>
<el-col :span="4"> <el-col :span="4">
<div class="nav-info"> <div class="nav-info">
<div class="nav-info-pic" @click="showComponent('4')"> <div class="nav-info-pic" @click="changeType('4')">
<img style="height: 50px" :src="pdf" /> <img style="height: 50px" :src="pdf" />
</div> </div>
<div class="nav-info-name">PDF</div> <div class="nav-info-name">PDF</div>
</div> </div>
</el-col> </el-col>
<el-col :span="4" @click="showComponent('5')"> <el-col :span="4" @click="changeType('5')">
<div class="nav-info"> <div class="nav-info">
<div class="nav-info-pic"> <div class="nav-info-pic">
<img style="height: 50px" :src="test" /> <img style="height: 50px" :src="test" />
@ -179,7 +151,7 @@ const upload = async (option) => {
<div class="nav-info-name">文件</div> <div class="nav-info-name">文件</div>
</div> </div>
</el-col> </el-col>
<el-col :span="4" @click="showComponent('6')"> <el-col :span="4" @click="changeType('6')">
<div class="nav-info"> <div class="nav-info">
<div class="nav-info-pic"> <div class="nav-info-pic">
<img style="height: 50px" :src="audio" /> <img style="height: 50px" :src="audio" />
@ -201,14 +173,14 @@ const upload = async (option) => {
> >
<div> <div>
<div class="icon"> <div class="icon">
<el-icon @click="onDeleteResource(ids)"> <el-icon @click="onDeleteResource(resource.id)">
<Delete /> <Delete />
</el-icon> </el-icon>
<el-icon> <el-icon @click="onEditResource">
<Edit /> <Edit />
</el-icon> </el-icon>
</div> </div>
<div class="vedio"> <div class="vedio" @click="generateRecords(resource)">
<img style="height: 200px" :src="resource.img" /> <img style="height: 200px" :src="resource.img" />
</div> </div>
<div class="resource-info"> <div class="resource-info">
@ -235,6 +207,11 @@ const upload = async (option) => {
style="margin-top: 20px; justify-content: flex-end" style="margin-top: 20px; justify-content: flex-end"
/> />
</div> </div>
<!-- 添加编辑的抽屉 -->
<resource-add
:dafulIndex="params.type"
ref="resourceAddRef"
></resource-add>
</div> </div>
</div> </div>
</div> </div>

Loading…
Cancel
Save