课件详情等

This commit is contained in:
18571350067 2021-11-26 16:01:51 +08:00
parent 646123cbbe
commit 6ed7aadbf7
6 changed files with 353 additions and 198 deletions

View File

@ -1,9 +1,10 @@
<template>
<a-card :bordered="false" title="系統新增">
<template slot="extra">
<a-button type="primary" @click="goback">返回</a-button>
<a-button type="primary" @click="save">保存</a-button>
</template>
<a-form-model :model="form">
<div style="width: 100%; height: 40px; margin-bottom: 8px; margin-left: 80%">
<a-button type="primary" @click="goback">返回</a-button>
</div>
<a-row>
<!-- 课程名称 -->
<a-col :span="18" :offset="3">
@ -19,7 +20,9 @@
<a-col :span="9" :offset="3">
<a-form-model-item label="课程类别" :label-col="{ span: 8 }" :wrapper-col="{ span: 12 }">
<a-select v-model="form.courseType" placeholder="--请选择--">
<a-select-option v-for="(item,index) in dictCourseType" :key="index" :value="item.value"> {{item.name}} </a-select-option>
<a-select-option v-for="(item, index) in dictCourseType" :key="index" :value="item.value">
{{ item.name }}
</a-select-option>
</a-select>
</a-form-model-item>
</a-col>
@ -50,7 +53,9 @@
<a-col :span="9" :offset="3">
<a-form-model-item label="所属行业" :label-col="{ span: 8 }" :wrapper-col="{ span: 12 }">
<a-select v-model="form.industryInvolved" placeholder="--请选择--">
<a-select-option v-for="(item,index) in industry" :key="index" :value="item.value"> {{item.name}} </a-select-option>
<a-select-option v-for="(item, index) in industry" :key="index" :value="item.value">
{{ item.name }}
</a-select-option>
</a-select>
</a-form-model-item>
</a-col>
@ -69,7 +74,9 @@
<a-col :span="9" :offset="3">
<a-form-model-item label="选择岗位" :label-col="{ span: 8 }" :wrapper-col="{ span: 12 }">
<a-select v-model="form.job" placeholder="--请选择--">
<a-select-option v-for="(item,index) in dictPerson" :key="index" :value="item.value"> {{ item.name }} </a-select-option>
<a-select-option v-for="(item, index) in dictPerson" :key="index" :value="item.value">
{{ item.name }}
</a-select-option>
</a-select>
</a-form-model-item>
</a-col>
@ -100,20 +107,20 @@
<a-modal :visible="previewVisible" :footer="null" @cancel="handleCancel">
<img alt="example" style="width: 100%" :src="previewImage" />
</a-modal>
</a-form-model-item>
</a-col>
<!-- <a-upload name="file" list-type="picture-card" class="avatar-uploader" :show-upload-list="false" action="" :headers="getToken()" :change="onSuccess">
<img v-if="imageUrl" :src="imageUrl" alt="avatar" />
<div v-else>
<a-icon :type="loading ? 'loading' : 'plus'" />
<div class="ant-upload-text">封面图片</div>
</div>
</a-upload> -->
<!-- 标签选择器 -->
<a-col :span="18" :offset="3">
<a-form-model-item label="课程标签" :label-col="{ span: 4 }" :wrapper-col="{ span: 15 }">
<a-select mode="tags" style="width: 100%" placeholder="标签选择或新增" @change="handleTagChange" :value="this.form.tags">
<a-select-option v-for="(item,index) in dictCourseTag" :key="index" :value="item.value">
{{ item.name }}
</a-select-option>
</a-select>
</a-form-model-item>
</a-col>
</a-row>
<div style="width: 100%; height: 40px; margin-bottom: 8px; margin-left: 50%">
<a-button type="primary" @click="save">保存</a-button>
</div>
</a-form-model>
</a-card>
</template>
@ -133,14 +140,17 @@ export default {
dataValue: 1,
form: {
coverPath: '',
tags:[],
courseTags:[]
},
url: '',
previewVisible: false,
fileList: [],
previewImage: [],
dictPerson:[],
dictCourseType:[],
industry:[]
dictPerson: [],
dictCourseType: [],
industry: [],
dictCourseTag:[],
}
},
components: {
@ -148,28 +158,21 @@ export default {
getCourseDetails,
},
created() {
this.dictionaryDropDown()
if (this.$route.query.id) {
getCourseDetails({ id: this.$route.query.id }).then((res) => {
this.form = res.data
this.form = res.data;
this.form.isRequired = this.form.isRequired + '';
// this.form.courseType = this.form.courseType + ''
// this.form.industryInvolved = this.form.industryInvolved + ''
this.form.isRequired = this.form.isRequired + ''
// this.form.is
this.dictEcho();
this.form.tags = [];
this.form.courseTags.forEach((item,index) => {
this.form.tags.push(item.dictValue.toString());
});
})
}
this.dictionaryDropDown()
},
methods: {
// getPersonType() {
// return dictGet(Object.assign(parameter)).then((res) => {
// return res
// })
// },
//
onChange(dataValue) {
console.log('changed', dataValue)
@ -185,32 +188,33 @@ export default {
})
},
dictionaryDropDown () {
this.formLoading = true
//
dictionaryDropDown({ dictionaryCode: '0007' }).then((res) => {
this.industry = res.data
this.formLoading = false
})
//
dictionaryDropDown({ dictionaryCode: '0006' }).then((res) => {
this.dictCourseType = res.data
this.formLoading = false
})
//
dictionaryDropDown({ dictionaryCode: '0005' }).then((res) => {
this.dictPerson = res.data
this.formLoading = false
})
},
//
dictEcho(){
console.log("form___",this.form)
dictionaryDropDown() {
this.formLoading = false
//
dictionaryDropDown({ dictionaryCode: '0007' }).then((res) => {
this.industry = res.data
})
//
dictionaryDropDown({ dictionaryCode: '0006' }).then((res) => {
this.dictCourseType = res.data
})
//
dictionaryDropDown({ dictionaryCode: '0005' }).then((res) => {
this.dictPerson = res.data
})
//
dictionaryDropDown({dictionaryCode: '0008'}).then((res) => {
const tagList = res.data
console.log(tagList)
for ( let i = 0; i < tagList.length; i++) {
console.log(tagList[i]);
tagList[i].value = tagList[i].value.toString()
}
console.log(tagList)
this.dictCourseTag = tagList
})
},
//
goback() {
this.$router.push({
@ -239,11 +243,18 @@ export default {
this.previewImage = file.url || file.preview
this.previewVisible = true
},
//
handleChange({ fileList }) {
this.fileList = fileList
this.fileList.file = fileList[0]
this.form.coverPath = this.fileList.file.response.url
},
//
handleTagChange(value) {
console.log('value------' ,value);
this.form.tags = value;
},
},
}

View File

@ -54,6 +54,7 @@ export default {
//
dictionaryDropDown() {
this.formLoading = true
//
dictionaryDropDown({ dictionaryCode: '0006' }).then((res) => {
this.dictCourseType = res.data

View File

@ -43,6 +43,7 @@
<script>
import { STable, SearchCom } from '@/components'
import { getCourseList, deleteCourse } from '@/api/course/course'
import { dictionaryDropDown } from '@/api/sys/dictionaryItem'
export default {
components: {
@ -51,8 +52,12 @@ export default {
},
data() {
return {
queryParam: { courseName: this.$route.query.courseName || '' }, //, orgId: this.$route.query.courseUserOrgId || ''
queryOptions: [{ type: 'input', placeholder: '课程名称', key: 'courseName' }],
dictCourseTag: [],
queryParam: { courseName: this.$route.query.courseName || '' },
queryOptions: [
{ type: 'input', placeholder: '课程名称', key: 'courseName' },
{ type: 'select', placeholder: '请选择标签', key: 'tag', options: [] },
],
loadData: (parameter) => {
return getCourseList(Object.assign(parameter, this.queryParam)).then((res) => {
return res
@ -67,8 +72,27 @@ export default {
],
}
},
created() {},
created() {
this.dictionaryDropDown()
console.log('aaa', this.dictCourseTag)
},
methods: {
//
dictionaryDropDown() {
this.formLoading = false
//
dictionaryDropDown({ dictionaryCode: '0008' }).then((res) => {
const tagList = res.data
console.log(tagList)
for (let i = 0; i < tagList.length; i++) {
console.log(tagList[i])
tagList[i].id = tagList[i].value.toString()
}
console.log(tagList)
this.queryOptions[1].options = tagList
})
},
handleRefresh() {
this.$refs.table.refresh(true)
},
@ -89,22 +113,22 @@ export default {
this.$router.push({
path: '/course/CourseAdd',
query: {
courseName: this.queryParam.courseName
},
})
},
//
courseQuestion(record) {
this.$router.push({
path: '/course/question/QuestionList',
query: {
id: record.id,
courseName: this.queryParam.courseName,
pageNum: this.$refs.table.localPagination.current
},
})
},
},
//
courseQuestion(record) {
this.$router.push({
path: '/course/question/QuestionList',
query: {
id: record.id,
courseName: this.queryParam.courseName,
pageNum: this.$refs.table.localPagination.current,
},
})
},
}
</script>

View File

@ -1,154 +1,273 @@
<template>
<a-card :bordered="false" title="添加课件">
<a-form-model :model="form">
<div style="width: 100%; height: 40px; margin-bottom: 8px; margin-left: 80%">
<a-button type="primary" @click="goback">返回</a-button>
</div>
<a-row>
<!-- 课程名称 -->
<a-col :span="18" :offset="3">
<a-form-model-item label="课件名称" :label-col="{ span: 4 }" :wrapper-col="{ span: 15 }">
<a-input v-model="form.courseName" v-decorator="['courseName', { rules: [{ required: true, message: '请填写课程名称' }] }]" />
</a-form-model-item>
</a-col>
<!-- 课件分类 -->
<a-col :span="9" :offset="3">
<a-form-model-item label="课件分类" :label-col="{ span: 8 }" :wrapper-col="{ span: 12 }">
<a-button type="primary" @click="classify">添加分类</a-button>
</a-form-model-item>
</a-col>
<!-- 课件大小 -->
<a-col :span="9">
<a-form-item label="课件大小" :label-col="{ span: 9 }" :wrapper-col="{ span: 14 }">
<div>
<a-input-number :disabled="false"/>
<div style="marginTop:15px">
<a-button type="primary" @click="toggle">
Toggle disabled
</a-button>
<template slot="extra">
<a-button @click="goback">返回</a-button>
<a-button type="primary" @click="save">保存</a-button>
</template>
<a-tabs type="card" :default-active-key="parentTabKey" @change="parentcallback">
<a-tab-pane key="1" tab="文件上传">
<a-tabs :default-active-key="tabkey" @change="callback">
<a-tab-pane key="1" tab="视频上传">
<div style="background: #ececec; padding: 30px">
<a-card title="视频上传" :bordered="false" style="width: 100%">
<div style="margin-bottom: 30px">
课件名称&nbsp;
<a-input placeholder="课件名称" v-model="videoForm.name" style="width: 40%" />
</div>
</div>
</a-form-item>
</a-col>
<div style="margin-bottom: 30px; margin-top: 20px">
课件分类&nbsp;<a-select mode="multiple" style="width: 30%" placeholder="请选择分类">
<a-select-option v-for="i in 25" :key="(i + 9).toString(36) + i">
{{ (i + 9).toString(36) + i }}
</a-select-option>
</a-select>
<a-button type="primary" @click="showModal" style="margin-left: 20px"> 添加分类 </a-button>
<!-- 上传课件 -->
<a-col :span="18" :offset="3">
<a-form-model-item label="上传课件" :label-col="{ span: 4 }" :wrapper-col="{ span: 15 }">
<a-upload action="/dawa/sys/oss/upload?sourceId=course" list-type="picture-card" :file-list="fileList" :headers="getToken()" @change="handleChange" @preview="handlePreview">
<div v-if="fileList.length < 1">
<a-icon type="plus" />
<div class="ant-upload-text">上传</div>
</div>
</a-upload>
<a-modal :visible="previewVisible" :footer="null" @cancel="handleCancel">
<img alt="example" style="width: 100%" :src="previewImage" />
</a-modal>
<!-- 课件分类弹框 -->
<a-modal v-model="visible" title="模板下载" cancelText="关闭" :ok-button-props="{ style: { display: 'none' } }">
<h1>hello world</h1>
</a-modal>
</div>
<div>课件大小&nbsp;
<a-input :disabled="true" :value="videoForm.sizeStr" style="width: 140px" />&nbsp;&nbsp;&nbsp; MB
</div>
<br />
<div>
视频上传&nbsp; <a-upload list-type="picture" :default-file-list="successOssFile" :beforeUpload="beforeUpload" :remove="deleteVideo" :disabled="uploadLoading">
<a-button>
<a-icon type="upload" /> {{uploadButtonText}}
</a-button>&nbsp;&nbsp;&nbsp;
</a-upload>
</div>
</a-card>
</div>
</a-tab-pane>
<a-tab-pane key="2" tab="文本上传">
<div style="background: #ececec; padding: 30px">
<a-card title="视频上传" :bordered="false" style="width: 100%">
<div style="margin-bottom: 30px">
视频上传&nbsp; <a-upload list-type="picture" :beforeUpload="beforeUpload">
<a-button>
<a-icon type="upload" /> 选择文件
</a-button>&nbsp;&nbsp;&nbsp;
</a-upload>
</div>
<div style="margin-bottom: 30px">
课件名称&nbsp;
<a-input placeholder="课件名称" v-model="textForm.name" style="width: 40%" />
</div>
<div style="margin-bottom: 30px; margin-top: 20px">
课件分类&nbsp;<a-select mode="multiple" style="width: 30%" placeholder="请选择分类">
<a-select-option v-for="i in 25" :key="(i + 9).toString(36) + i">
{{ (i + 9).toString(36) + i }}
</a-select-option>
</a-select>
<a-button type="primary" @click="showModal" style="margin-left: 20px"> 添加分类 </a-button>
<!-- <a-upload name="file" list-type="picture-card" class="avatar-uploader" :show-upload-list="false" action="" :headers="getToken()" :change="onSuccess">
<img v-if="imageUrl" :src="imageUrl" alt="avatar" />
<div v-else>
<a-icon :type="loading ? 'loading' : 'plus'" />
<div class="ant-upload-text">封面图片</div>
</div>
</a-upload> -->
</a-form-model-item>
</a-col>
</a-row>
<div style="width: 100%; height: 40px; margin-bottom: 8px; margin-left: 50%">
<a-button type="primary" @click="save">保存</a-button>
</div>
</a-form-model>
<!-- 课件分类弹框 -->
<a-modal v-model="visible" title="模板下载" cancelText="关闭" :ok-button-props="{ style: { display: 'none' } }">
<h1>hello world</h1>
</a-modal>
</div>
<div>课件大小&nbsp;
<a-input :disabled="true" :value="textForm.size" style="width: 140px" />
</div>
</a-card>
</div>
</a-tab-pane>
</a-tabs>
</a-tab-pane>
<a-tab-pane key="2" tab="视频服务器链接"> </a-tab-pane>
<a-tab-pane key="3" tab="第三方连接"> Content of Tab Pane 3 </a-tab-pane>
</a-tabs>
</a-card>
</template>
<script>
import { courseAdd, getCourseDetails } from '@/api/course/course'
import storage from 'store'
import { STable } from '@/components'
import { ACCESS_TOKEN } from '@/store/mutation-types'
import storage from 'store'
import axios from 'axios'
import { ossUpload } from '@/api/sys/oss'
import { coursewareAdd } from '@/api/course/courseware'
import { dictionaryDropDown } from '@/api/sys/dictionaryItem'
import { forEach } from 'store/storages/all'
export default {
name: 'step1',
data() {
return {
dataValue: 1,
form: {},
personType: [
{ id: '1', name: '人员类别1' },
{ id: '2', name: '人员类别2' },
{ id: '3', name: '人员类别3' },
],
previewVisible: false,
fileList: [],
previewImage :[
]
}
},
components: {
courseAdd,
getCourseDetails
},
created() {
if (this.$route.query.id) {
getCourseDetails({ id: this.$route.query.id }).then(res => {
this.form = res.data;
this.form.courseType = this.form.courseType + '';
this.form.industryInvolved = this.form.industryInvolved + '';
this.form.isRequired = this.form.isRequired + '';
});
visible: false,
textForm: {},
videoForm: {
sizeStr: '0',
videoPath: [], //
},
parentTabKey: '1',
tabkey: '1',
uploadButtonText: '选择文件',
successOssFile: [],
uploadLoading: false, //
}
},
components: {},
created() {},
methods: {
//
goback(){
this.$router.push({path:"/course/CourseList",query:{} })
goback() {
this.$router.push({
path: '/course/CoursewareList',
query: {
id: this.$route.query.courseId,
},
})
},
//
parentcallback(key) {},
//
callback(key) {
console.log(key)
},
//Tonken
getToken() {
let hreader = {};
hreader[ACCESS_TOKEN] = storage.get(ACCESS_TOKEN);
return hreader;
let hreader = {}
hreader[ACCESS_TOKEN] = storage.get(ACCESS_TOKEN)
return hreader
},
onSuccess(file) {
console.log('1---', file);
beforeUpload(file) {
this.uploadLoading = true
this.uploadButtonText = '上传中...'
// ()
var suffix = file.name.substring(file.name.lastIndexOf('.') + 1)
if (suffix != 'mp4') return this.$message.error('文件类型必须是mp4')
//
const data = new FormData()
data.append('file', file)
data.append('fileType', 'mp4')
//token
const header = {}
header['Content-Type'] = 'multipart/form-data'
header[ACCESS_TOKEN] = storage.get(ACCESS_TOKEN)
axios
.post(ossUpload(), data, { headers: header })
.then((res) => {
this.uploadLoading = false
this.uploadButtonText = '选择文件'
if (res.data.code === 200) {
this.$message.success('视频上传成功!')
res.data.uuid = file.uid
res.data.size = file.size
this.successOssFile.push(res.data)
//
this.refreshFileSize()
} else {
this.$message.error(res.data.msg)
this.$refs.inputFile.value = ''
}
})
.catch((err) => {
this.$message.error(err)
})
return false
},
handleCancel() {
this.previewVisible = false;
},
async handlePreview(file) {
if (!file.url && !file.preview) {
file.preview = await getBase64(file.originFileObj);
//
refreshFileSize() {
this.videoForm.size = 0
for (let i = 0; i < this.successOssFile.length; i++) {
//
let fileSize = this.successOssFile[i].size
//MB
var videoSize = parseFloat(fileSize) / 1024 / 1024
//
this.videoForm.size = this.videoForm.size + parseFloat(videoSize)
}
this.previewImage = file.url || file.preview;
this.previewVisible = true;
},
handleChange({ fileList }) {
this.fileList = fileList;
this.videoForm.sizeStr = this.videoForm.size.toFixed(2)
},
//
deleteVideo(file) {
//
for (let i = 0; i < this.successOssFile.length; i++) {
if (this.successOssFile[i].uuid == file.uid) {
this.successOssFile.splice(i, 1)
break
}
}
this.refreshFileSize()
},
//
showModal() {
this.visible = true
},
//
save() {
//
this.successOssFile.forEach((item, index) => {
this.videoForm.videoPath.push(item.url)
})
console.log(this.videoForm.videoPath.toString())
//JSON
this.videoForm.videoPath = this.videoForm.videoPath.toString();
//ID
this.videoForm.courseId = this.$route.query.courseId;
console.log(this.videoForm)
let from;
if (this.parentTabKey == '1' && this.tabkey == '1') {
//
from = this.videoFormV()
if (typeof form == 'boolean' && !form) return
}
//
coursewareAdd(from).then((res) =>{
console.log(res);
if (res.code == 200) {
this.$message.success('课件保存成功!');
this.goback();
}else{
this.$message.error('保存失败!');
}
})
},
//
videoFormV() {
//
if (!this.videoForm.name || this.videoForm.name === '') {
this.$message.error('课件名称不能为空!')
return false
} else if (this.videoForm.videoPath.length == 0) {
this.$message.error('请上传课件文件!')
return false
}
let form = {};
form = this.videoForm;
console.log('111111',form);
return form;
},
},
}
// Base64
function getBase64(file) {
return new Promise((resolve, reject) => {
const reader = new FileReader();
reader.readAsDataURL(file);
reader.onload = () => resolve(reader.result);
reader.onerror = error => reject(error);
});
}
</script>
<style scoped>
</style>

View File

@ -44,8 +44,8 @@ export default {
columns: [
{ title: '课件名称', width: '160px', align: 'center', dataIndex: 'name', key: 'name' },
{ title: '课件分类',width: '300px',align: 'center', dataIndex: 'coursewareClassifyId', key: 'coursewareClassifyId',},
{ title: '课时/分', width: '160px', align: 'center', dataIndex: 'hour', key: 'hour' },
{ title: '课件大小', width: '160px', align: 'center', dataIndex: 'coursewareSize', key: 'coursewareSize' },
{ title: '课时/分', width: '160px', align: 'center', dataIndex: 'duration', key: 'duration' },
{ title: '课件大小(MB)', width: '160px', align: 'center', dataIndex: 'sizeStr', key: 'sizeStr'},
{ title: '操作', key: 'operation', width: '200px', align: 'center', scopedSlots: { customRender: 'action' } },
],
}
@ -53,7 +53,8 @@ export default {
methods: {
//
coursewareAdd(){
this.$router.push({path:"/course/CoursewareAddOrUpdate",query:{}})
this.$router.push({path:"/course/CoursewareAddOrUpdate",query:{courseId: this.$route.query.id}})
console.log('IDIDIDID',this.$route.query.id)
},
//

View File

@ -249,7 +249,6 @@ export default {
} else if (this.tabKey === '5') {
from = this.CompletionV()
if (typeof from == 'boolean' && !from) return
console.log('5---', this.Completion)
}
from.courseId = this.$route.query.courseId