课件详情等
This commit is contained in:
parent
646123cbbe
commit
6ed7aadbf7
|
@ -1,9 +1,10 @@
|
|||
<template>
|
||||
<a-card :bordered="false" title="系統新增">
|
||||
<a-form-model :model="form">
|
||||
<div style="width: 100%; height: 40px; margin-bottom: 8px; margin-left: 80%">
|
||||
<template slot="extra">
|
||||
<a-button type="primary" @click="goback">返回</a-button>
|
||||
</div>
|
||||
<a-button type="primary" @click="save">保存</a-button>
|
||||
</template>
|
||||
<a-form-model :model="form">
|
||||
<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() {
|
||||
this.formLoading = false
|
||||
// 行业
|
||||
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
|
||||
})
|
||||
// 标签项 默认选中的多选框
|
||||
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
|
||||
})
|
||||
},
|
||||
|
||||
// 编辑回显字典项
|
||||
dictEcho(){
|
||||
console.log("form___",this.form)
|
||||
},
|
||||
|
||||
|
||||
|
||||
//返回
|
||||
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;
|
||||
},
|
||||
},
|
||||
}
|
||||
|
||||
|
|
|
@ -54,6 +54,7 @@ export default {
|
|||
|
||||
//获取数据字典
|
||||
dictionaryDropDown() {
|
||||
this.formLoading = true
|
||||
// 课程类别
|
||||
dictionaryDropDown({ dictionaryCode: '0006' }).then((res) => {
|
||||
this.dictCourseType = res.data
|
||||
|
|
|
@ -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,10 +113,11 @@ export default {
|
|||
this.$router.push({
|
||||
path: '/course/CourseAdd',
|
||||
query: {
|
||||
courseName: this.queryParam.courseName
|
||||
courseName: this.queryParam.courseName,
|
||||
},
|
||||
})
|
||||
},
|
||||
},
|
||||
|
||||
//题库
|
||||
courseQuestion(record) {
|
||||
|
@ -101,10 +126,9 @@ export default {
|
|||
query: {
|
||||
id: record.id,
|
||||
courseName: this.queryParam.courseName,
|
||||
pageNum: this.$refs.table.localPagination.current
|
||||
pageNum: this.$refs.table.localPagination.current,
|
||||
},
|
||||
})
|
||||
},
|
||||
},
|
||||
}
|
||||
</script>
|
|
@ -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>
|
||||
</div>
|
||||
</div>
|
||||
</a-form-item>
|
||||
</a-col>
|
||||
|
||||
<!-- 上传课件 -->
|
||||
<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-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%">
|
||||
<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">
|
||||
课件名称:
|
||||
<a-input placeholder="课件名称" v-model="videoForm.name" style="width: 40%" />
|
||||
</div>
|
||||
</a-form-model>
|
||||
<div style="margin-bottom: 30px; margin-top: 20px">
|
||||
课件分类: <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-modal v-model="visible" title="模板下载" cancelText="关闭" :ok-button-props="{ style: { display: 'none' } }">
|
||||
<h1>hello world</h1>
|
||||
</a-modal>
|
||||
</div>
|
||||
<div>课件大小:
|
||||
<a-input :disabled="true" :value="videoForm.sizeStr" style="width: 140px" /> MB
|
||||
</div>
|
||||
<br />
|
||||
<div>
|
||||
视频上传: <a-upload list-type="picture" :default-file-list="successOssFile" :beforeUpload="beforeUpload" :remove="deleteVideo" :disabled="uploadLoading">
|
||||
<a-button>
|
||||
<a-icon type="upload" /> {{uploadButtonText}}
|
||||
</a-button>
|
||||
</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">
|
||||
视频上传: <a-upload list-type="picture" :beforeUpload="beforeUpload">
|
||||
<a-button>
|
||||
<a-icon type="upload" /> 选择文件
|
||||
</a-button>
|
||||
</a-upload>
|
||||
</div>
|
||||
<div style="margin-bottom: 30px">
|
||||
课件名称:
|
||||
<a-input placeholder="课件名称" v-model="textForm.name" style="width: 40%" />
|
||||
</div>
|
||||
<div style="margin-bottom: 30px; margin-top: 20px">
|
||||
课件分类: <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-modal v-model="visible" title="模板下载" cancelText="关闭" :ok-button-props="{ style: { display: 'none' } }">
|
||||
<h1>hello world</h1>
|
||||
</a-modal>
|
||||
</div>
|
||||
<div>课件大小:
|
||||
<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);
|
||||
|
||||
},
|
||||
handleCancel() {
|
||||
this.previewVisible = false;
|
||||
},
|
||||
async handlePreview(file) {
|
||||
if (!file.url && !file.preview) {
|
||||
file.preview = await getBase64(file.originFileObj);
|
||||
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 = ''
|
||||
}
|
||||
this.previewImage = file.url || file.preview;
|
||||
this.previewVisible = true;
|
||||
},
|
||||
handleChange({ fileList }) {
|
||||
this.fileList = fileList;
|
||||
})
|
||||
.catch((err) => {
|
||||
this.$message.error(err)
|
||||
})
|
||||
|
||||
return false
|
||||
},
|
||||
|
||||
//刷新大小
|
||||
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.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>
|
|
@ -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)
|
||||
},
|
||||
|
||||
//返回
|
||||
|
|
|
@ -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
|
||||
|
|
Loading…
Reference in New Issue