|
|
@ -1,79 +1,120 @@ |
|
|
|
<template> |
|
|
|
<template> |
|
|
|
<div> |
|
|
|
<div> |
|
|
|
<el-card shadow="hover" class="m-b-20"> |
|
|
|
<el-card shadow="hover" |
|
|
|
|
|
|
|
class="m-b-20"> |
|
|
|
<div class="flex-between"> |
|
|
|
<div class="flex-between"> |
|
|
|
<el-page-header @back="back" :content="form.id ? '编辑课程' : '新增课程'"></el-page-header> |
|
|
|
<el-page-header @back="back" |
|
|
|
|
|
|
|
:content="form.id ? '编辑课程' : '新增课程'"></el-page-header> |
|
|
|
</div> |
|
|
|
</div> |
|
|
|
</el-card> |
|
|
|
</el-card> |
|
|
|
|
|
|
|
|
|
|
|
<el-card shadow="hover" class="m-b-20"> |
|
|
|
<el-card shadow="hover" |
|
|
|
<el-form :model="form" :rules="rules" ref="form" :disabled="isDetail" label-width="120px" label-suffix=":"> |
|
|
|
class="m-b-20"> |
|
|
|
<el-form-item prop="courseName" label="课程名称"> |
|
|
|
<el-form :model="form" |
|
|
|
|
|
|
|
:rules="rules" |
|
|
|
|
|
|
|
ref="form" |
|
|
|
|
|
|
|
:disabled="isDetail" |
|
|
|
|
|
|
|
label-width="120px" |
|
|
|
|
|
|
|
label-suffix=":"> |
|
|
|
|
|
|
|
<el-form-item prop="courseName" |
|
|
|
|
|
|
|
label="课程名称"> |
|
|
|
<div class="d-inline-block"> |
|
|
|
<div class="d-inline-block"> |
|
|
|
<el-input placeholder="请输入课程名称" v-model="form.courseName" clearable maxlength="25" @change="nameChange"></el-input> |
|
|
|
<el-input placeholder="请输入课程名称" |
|
|
|
|
|
|
|
v-model="form.courseName" |
|
|
|
|
|
|
|
clearable |
|
|
|
|
|
|
|
maxlength="25" |
|
|
|
|
|
|
|
@change="nameChange"></el-input> |
|
|
|
</div> |
|
|
|
</div> |
|
|
|
</el-form-item> |
|
|
|
</el-form-item> |
|
|
|
<el-form-item prop="courseType" label="课程类型"> |
|
|
|
<el-form-item prop="courseType" |
|
|
|
|
|
|
|
label="课程类型"> |
|
|
|
<div class="d-inline-block"> |
|
|
|
<div class="d-inline-block"> |
|
|
|
<el-select v-model="form.courseType" placeholder="请选择课程类型"> |
|
|
|
<el-select v-model="form.courseType" |
|
|
|
<el-option label="免费" :value="0"></el-option> |
|
|
|
placeholder="请选择课程类型"> |
|
|
|
|
|
|
|
<el-option label="免费" |
|
|
|
|
|
|
|
:value="0"></el-option> |
|
|
|
<!-- <el-option label="付费" :value="1"></el-option> --> |
|
|
|
<!-- <el-option label="付费" :value="1"></el-option> --> |
|
|
|
</el-select> |
|
|
|
</el-select> |
|
|
|
</div> |
|
|
|
</div> |
|
|
|
</el-form-item> |
|
|
|
</el-form-item> |
|
|
|
<el-form-item prop="visibleRange" label="可见范围"> |
|
|
|
<el-form-item prop="visibleRange" |
|
|
|
|
|
|
|
label="可见范围"> |
|
|
|
<div> |
|
|
|
<div> |
|
|
|
<el-radio v-model="form.visibleRange" :label="0" @change="visibleChange">仅本校</el-radio> |
|
|
|
<el-radio v-model="form.visibleRange" |
|
|
|
|
|
|
|
:label="0" |
|
|
|
|
|
|
|
@change="visibleChange">仅本校</el-radio> |
|
|
|
</div> |
|
|
|
</div> |
|
|
|
<div> |
|
|
|
<div> |
|
|
|
<el-radio v-model="form.visibleRange" :label="1" @change="visibleChange">全平台</el-radio> |
|
|
|
<el-radio v-model="form.visibleRange" |
|
|
|
|
|
|
|
:label="1" |
|
|
|
|
|
|
|
@change="visibleChange">全平台</el-radio> |
|
|
|
</div> |
|
|
|
</div> |
|
|
|
</el-form-item> |
|
|
|
</el-form-item> |
|
|
|
<el-form-item prop="schoolClassificationsIds" label="课程分类"> |
|
|
|
<el-form-item prop="schoolClassificationsIds" |
|
|
|
|
|
|
|
label="课程分类"> |
|
|
|
<div class="d-inline-block"> |
|
|
|
<div class="d-inline-block"> |
|
|
|
<el-select v-model="form.schoolClassificationsIds" placeholder="请选择课程分类" multiple> |
|
|
|
<el-select v-model="form.schoolClassificationsIds" |
|
|
|
<el-option v-for="item in classificationList" :key="item.id" :label="item.classificationName" :value="item.id"></el-option> |
|
|
|
placeholder="请选择课程分类" |
|
|
|
|
|
|
|
multiple> |
|
|
|
|
|
|
|
<el-option v-for="item in classificationList" |
|
|
|
|
|
|
|
:key="item.id" |
|
|
|
|
|
|
|
:label="item.classificationName" |
|
|
|
|
|
|
|
:value="item.id"></el-option> |
|
|
|
</el-select> |
|
|
|
</el-select> |
|
|
|
</div> |
|
|
|
</div> |
|
|
|
</el-form-item> |
|
|
|
</el-form-item> |
|
|
|
<el-form-item v-if="form.visibleRange == 1" prop="platformClassificationIds" label="平台课程分类"> |
|
|
|
<el-form-item v-if="form.visibleRange == 1" |
|
|
|
|
|
|
|
prop="platformClassificationIds" |
|
|
|
|
|
|
|
label="平台课程分类"> |
|
|
|
<div class="d-inline-block"> |
|
|
|
<div class="d-inline-block"> |
|
|
|
<el-select v-model="form.platformClassificationIds" placeholder="请选择平台课程分类" multiple> |
|
|
|
<el-select v-model="form.platformClassificationIds" |
|
|
|
<el-option v-for="item in platformClassificationList" :key="item.id" :label="item.classificationName" :value="item.id"></el-option> |
|
|
|
placeholder="请选择平台课程分类" |
|
|
|
|
|
|
|
multiple> |
|
|
|
|
|
|
|
<el-option v-for="item in platformClassificationList" |
|
|
|
|
|
|
|
:key="item.id" |
|
|
|
|
|
|
|
:label="item.classificationName" |
|
|
|
|
|
|
|
:value="item.id"></el-option> |
|
|
|
</el-select> |
|
|
|
</el-select> |
|
|
|
</div> |
|
|
|
</div> |
|
|
|
</el-form-item> |
|
|
|
</el-form-item> |
|
|
|
<el-form-item prop="coverUrl" label="课程封面"> |
|
|
|
<el-form-item prop="coverUrl" |
|
|
|
<el-upload |
|
|
|
label="课程封面"> |
|
|
|
class="avatar-uploader" |
|
|
|
<el-upload class="avatar-uploader" |
|
|
|
accept=".jpg,.png,.jpeg" |
|
|
|
accept=".jpg,.png,.jpeg" |
|
|
|
:on-remove="handleRemove" |
|
|
|
:on-remove="handleRemove" |
|
|
|
:on-error="uploadError" |
|
|
|
:on-error="uploadError" |
|
|
|
:on-success="uploadSuccess" |
|
|
|
|
|
|
|
:before-remove="beforeRemove" |
|
|
|
:before-remove="beforeRemove" |
|
|
|
:limit="1" |
|
|
|
:limit="1" |
|
|
|
:on-exceed="handleExceed" |
|
|
|
:on-exceed="handleExceed" |
|
|
|
:action="this.api.fileupload" |
|
|
|
action="" |
|
|
|
:headers="headers" |
|
|
|
:http-request="handleRequest"> |
|
|
|
name="file" |
|
|
|
<img v-if="form.coverUrl" |
|
|
|
> |
|
|
|
:src="form.coverUrl" |
|
|
|
<img v-if="form.coverUrl" :src="form.coverUrl" class="avatar"> |
|
|
|
class="avatar"> |
|
|
|
<div class="uploader-default" v-else> |
|
|
|
<div class="uploader-default" |
|
|
|
|
|
|
|
v-else> |
|
|
|
<i class="el-icon-plus"></i> |
|
|
|
<i class="el-icon-plus"></i> |
|
|
|
<p>上传封面</p> |
|
|
|
<p>上传封面</p> |
|
|
|
</div> |
|
|
|
</div> |
|
|
|
|
|
|
|
|
|
|
|
<div slot="tip" class="el-upload__tip"> |
|
|
|
<div slot="tip" |
|
|
|
|
|
|
|
class="el-upload__tip"> |
|
|
|
<p>只能上传jpg/png文件</p> |
|
|
|
<p>只能上传jpg/png文件</p> |
|
|
|
<p>课程封面图将按2:1显示,最佳分辨率1400*700</p> |
|
|
|
<p>课程封面图将按2:1显示,最佳分辨率1400*700</p> |
|
|
|
</div> |
|
|
|
</div> |
|
|
|
</el-upload> |
|
|
|
</el-upload> |
|
|
|
</el-form-item> |
|
|
|
</el-form-item> |
|
|
|
<el-form-item prop="courseIntroduction" label="课程介绍"> |
|
|
|
<el-form-item prop="courseIntroduction" |
|
|
|
<quill :border="true" :readonly="isDetail" v-model="form.courseIntroduction" :height="400" /> |
|
|
|
label="课程介绍"> |
|
|
|
|
|
|
|
<quill :border="true" |
|
|
|
|
|
|
|
:readonly="isDetail" |
|
|
|
|
|
|
|
v-model="form.courseIntroduction" |
|
|
|
|
|
|
|
:height="400" /> |
|
|
|
</el-form-item> |
|
|
|
</el-form-item> |
|
|
|
<el-form-item> |
|
|
|
<el-form-item> |
|
|
|
<el-button type="primary" @click="save(0)" v-show="!isDetail">{{ form.id ? "更新" : "创建" }}</el-button> |
|
|
|
<el-button type="primary" |
|
|
|
|
|
|
|
@click="save(0)" |
|
|
|
|
|
|
|
v-show="!isDetail">{{ form.id ? "更新" : "创建" }}</el-button> |
|
|
|
</el-form-item> |
|
|
|
</el-form-item> |
|
|
|
</el-form> |
|
|
|
</el-form> |
|
|
|
</el-card> |
|
|
|
</el-card> |
|
|
@ -84,9 +125,10 @@ |
|
|
|
import util from "@/libs/util"; |
|
|
|
import util from "@/libs/util"; |
|
|
|
import Setting from "@/setting"; |
|
|
|
import Setting from "@/setting"; |
|
|
|
import quill from "@/components/quill"; |
|
|
|
import quill from "@/components/quill"; |
|
|
|
|
|
|
|
import Oss from '@/components/upload/upload.js' |
|
|
|
|
|
|
|
|
|
|
|
export default { |
|
|
|
export default { |
|
|
|
data() { |
|
|
|
data () { |
|
|
|
const that = this |
|
|
|
const that = this |
|
|
|
return { |
|
|
|
return { |
|
|
|
headers: { |
|
|
|
headers: { |
|
|
@ -168,7 +210,7 @@ export default { |
|
|
|
data.push(e) |
|
|
|
data.push(e) |
|
|
|
}) |
|
|
|
}) |
|
|
|
resolve(data) |
|
|
|
resolve(data) |
|
|
|
}).catch(res => {}) |
|
|
|
}).catch(res => { }) |
|
|
|
} else if (level === 1) { |
|
|
|
} else if (level === 1) { |
|
|
|
// 城市 |
|
|
|
// 城市 |
|
|
|
that.$get(that.api.queryCity, { |
|
|
|
that.$get(that.api.queryCity, { |
|
|
@ -183,7 +225,7 @@ export default { |
|
|
|
data.push(e) |
|
|
|
data.push(e) |
|
|
|
}) |
|
|
|
}) |
|
|
|
resolve(data) |
|
|
|
resolve(data) |
|
|
|
}).catch(res => {}) |
|
|
|
}).catch(res => { }) |
|
|
|
} else if (level === 2) { |
|
|
|
} else if (level === 2) { |
|
|
|
// 学校 |
|
|
|
// 学校 |
|
|
|
that.$get(that.api.getSchoolsByProvince, { |
|
|
|
that.$get(that.api.getSchoolsByProvince, { |
|
|
@ -200,7 +242,7 @@ export default { |
|
|
|
data.push(e) |
|
|
|
data.push(e) |
|
|
|
}) |
|
|
|
}) |
|
|
|
resolve(data) |
|
|
|
resolve(data) |
|
|
|
}).catch(res => {}) |
|
|
|
}).catch(res => { }) |
|
|
|
} else { |
|
|
|
} else { |
|
|
|
resolve([]) |
|
|
|
resolve([]) |
|
|
|
} |
|
|
|
} |
|
|
@ -212,15 +254,15 @@ export default { |
|
|
|
watch: { |
|
|
|
watch: { |
|
|
|
// 监听信息是否有更改,有的话页面离开的时候要询问是否要保存 |
|
|
|
// 监听信息是否有更改,有的话页面离开的时候要询问是否要保存 |
|
|
|
form: { |
|
|
|
form: { |
|
|
|
handler(val){ |
|
|
|
handler (val) { |
|
|
|
this.updateTime++ |
|
|
|
this.updateTime++ |
|
|
|
}, |
|
|
|
}, |
|
|
|
deep:true |
|
|
|
deep: true |
|
|
|
} |
|
|
|
} |
|
|
|
}, |
|
|
|
}, |
|
|
|
// 离开的时候判断是否有保存更改的信息,没有则拦截并提示 |
|
|
|
// 离开的时候判断是否有保存更改的信息,没有则拦截并提示 |
|
|
|
beforeRouteLeave(to, from, next) { |
|
|
|
beforeRouteLeave (to, from, next) { |
|
|
|
if(this.updateTime){ |
|
|
|
if (this.updateTime) { |
|
|
|
this.$confirm(`您所更改的内容未更新,是否更新?`, '提示', { |
|
|
|
this.$confirm(`您所更改的内容未更新,是否更新?`, '提示', { |
|
|
|
type: 'warning' |
|
|
|
type: 'warning' |
|
|
|
}).then(() => { |
|
|
|
}).then(() => { |
|
|
@ -228,11 +270,11 @@ export default { |
|
|
|
}).catch(() => { |
|
|
|
}).catch(() => { |
|
|
|
next() |
|
|
|
next() |
|
|
|
}) |
|
|
|
}) |
|
|
|
}else{ |
|
|
|
} else { |
|
|
|
next() |
|
|
|
next() |
|
|
|
} |
|
|
|
} |
|
|
|
}, |
|
|
|
}, |
|
|
|
mounted() { |
|
|
|
mounted () { |
|
|
|
this.getClassification() |
|
|
|
this.getClassification() |
|
|
|
this.form.id && this.getData() |
|
|
|
this.form.id && this.getData() |
|
|
|
}, |
|
|
|
}, |
|
|
@ -241,7 +283,7 @@ export default { |
|
|
|
}, |
|
|
|
}, |
|
|
|
methods: { |
|
|
|
methods: { |
|
|
|
// 分类 |
|
|
|
// 分类 |
|
|
|
getClassification() { |
|
|
|
getClassification () { |
|
|
|
// 中台分类 |
|
|
|
// 中台分类 |
|
|
|
this.$post(this.api.listClassification, { |
|
|
|
this.$post(this.api.listClassification, { |
|
|
|
pageNum: 1, |
|
|
|
pageNum: 1, |
|
|
@ -249,7 +291,7 @@ export default { |
|
|
|
platformSource: 0 |
|
|
|
platformSource: 0 |
|
|
|
}).then(({ page }) => { |
|
|
|
}).then(({ page }) => { |
|
|
|
this.platformClassificationList = page.records |
|
|
|
this.platformClassificationList = page.records |
|
|
|
}).catch(res => {}) |
|
|
|
}).catch(res => { }) |
|
|
|
|
|
|
|
|
|
|
|
// 教师端分类 |
|
|
|
// 教师端分类 |
|
|
|
this.$post(this.api.listClassification, { |
|
|
|
this.$post(this.api.listClassification, { |
|
|
@ -258,9 +300,9 @@ export default { |
|
|
|
platformSource: Setting.platformSource |
|
|
|
platformSource: Setting.platformSource |
|
|
|
}).then(({ page }) => { |
|
|
|
}).then(({ page }) => { |
|
|
|
this.classificationList = page.records |
|
|
|
this.classificationList = page.records |
|
|
|
}).catch(res => {}) |
|
|
|
}).catch(res => { }) |
|
|
|
}, |
|
|
|
}, |
|
|
|
getData() { |
|
|
|
getData () { |
|
|
|
this.$post(`${this.api.findTheoreticalCourse}?id=${this.form.id}`).then(({ data }) => { |
|
|
|
this.$post(`${this.api.findTheoreticalCourse}?id=${this.form.id}`).then(({ data }) => { |
|
|
|
// 分类id处理 |
|
|
|
// 分类id处理 |
|
|
|
if (data.platformClassificationList) { |
|
|
|
if (data.platformClassificationList) { |
|
|
@ -280,10 +322,10 @@ export default { |
|
|
|
name: "cover.jpg", |
|
|
|
name: "cover.jpg", |
|
|
|
url: data.coverUrl |
|
|
|
url: data.coverUrl |
|
|
|
}) |
|
|
|
}) |
|
|
|
}).catch(err => {}) |
|
|
|
}).catch(err => { }) |
|
|
|
}, |
|
|
|
}, |
|
|
|
// 名称判重 |
|
|
|
// 名称判重 |
|
|
|
nameChange(val) { |
|
|
|
nameChange (val) { |
|
|
|
this.$post(this.api.checkRepeatTheoreticalCourse, { |
|
|
|
this.$post(this.api.checkRepeatTheoreticalCourse, { |
|
|
|
id: this.form.id, |
|
|
|
id: this.form.id, |
|
|
|
courseName: val, |
|
|
|
courseName: val, |
|
|
@ -295,32 +337,33 @@ export default { |
|
|
|
}) |
|
|
|
}) |
|
|
|
}, |
|
|
|
}, |
|
|
|
// 可见范围回调 |
|
|
|
// 可见范围回调 |
|
|
|
visibleChange(val) { |
|
|
|
visibleChange (val) { |
|
|
|
this.rules.platformClassificationIds[0].required = val == 1 |
|
|
|
this.rules.platformClassificationIds[0].required = val == 1 |
|
|
|
}, |
|
|
|
}, |
|
|
|
handleExceed(files, fileList) { // 上传文件 |
|
|
|
handleExceed (files, fileList) { // 上传文件 |
|
|
|
util.warningMsg("当前限制选择 1 个文件,如需更换,请删除上一个文件再重新选择!"); |
|
|
|
util.warningMsg("当前限制选择 1 个文件,如需更换,请删除上一个文件再重新选择!"); |
|
|
|
}, |
|
|
|
}, |
|
|
|
uploadSuccess(res, file, fileList) { |
|
|
|
handleRequest ({ file }) { |
|
|
|
this.form.coverUrl = res.data.filesResult.fileUrl |
|
|
|
this.form.coverUrl && Oss.del(this.form.coverUrl) |
|
|
|
|
|
|
|
Oss.upload(file).then(res => { |
|
|
|
|
|
|
|
this.form.coverUrl = res.url |
|
|
|
|
|
|
|
}) |
|
|
|
}, |
|
|
|
}, |
|
|
|
uploadError(err, file, fileList) { |
|
|
|
uploadError (err, file, fileList) { |
|
|
|
this.$message({ |
|
|
|
this.$message({ |
|
|
|
message: "上传出错,请重试!", |
|
|
|
message: "上传出错,请重试!", |
|
|
|
type: "error", |
|
|
|
type: "error", |
|
|
|
center: true |
|
|
|
center: true |
|
|
|
}); |
|
|
|
}); |
|
|
|
}, |
|
|
|
}, |
|
|
|
beforeRemove(file, fileList) { |
|
|
|
beforeRemove (file, fileList) { |
|
|
|
return this.$confirm(`确定移除 ${file.name}?`); |
|
|
|
return this.$confirm(`确定移除 ${file.name}?`); |
|
|
|
}, |
|
|
|
}, |
|
|
|
handleRemove(file, fileList) { |
|
|
|
handleRemove () { |
|
|
|
let fileName = this.form.coverUrl.replace('https://huoran.oss-cn-shenzhen.aliyuncs.com/', ""); |
|
|
|
Oss.del(this.form.coverUrl) |
|
|
|
this.$del(`${this.api.fileDeletion}?keys=${fileName}`).then(res => { |
|
|
|
|
|
|
|
this.form.coverUrl = '' |
|
|
|
this.form.coverUrl = '' |
|
|
|
}).catch(res => {}); |
|
|
|
|
|
|
|
}, |
|
|
|
}, |
|
|
|
save(cb) { |
|
|
|
save (cb) { |
|
|
|
this.$refs.form.validate((valid) => { |
|
|
|
this.$refs.form.validate((valid) => { |
|
|
|
if (valid) { |
|
|
|
if (valid) { |
|
|
|
if (this.nameRepeat) return util.errorMsg('当前课程名已存在!') |
|
|
|
if (this.nameRepeat) return util.errorMsg('当前课程名已存在!') |
|
|
@ -359,10 +402,10 @@ export default { |
|
|
|
}) |
|
|
|
}) |
|
|
|
}, |
|
|
|
}, |
|
|
|
// 返回上一页 |
|
|
|
// 返回上一页 |
|
|
|
backPage() { |
|
|
|
backPage () { |
|
|
|
this.$router.back() |
|
|
|
this.$router.back() |
|
|
|
}, |
|
|
|
}, |
|
|
|
back() { |
|
|
|
back () { |
|
|
|
const updateTime = this.updateTime |
|
|
|
const updateTime = this.updateTime |
|
|
|
// 更改了信息才需要提示 |
|
|
|
// 更改了信息才需要提示 |
|
|
|
if (updateTime) { |
|
|
|
if (updateTime) { |
|
|
@ -395,7 +438,7 @@ $avatar-width: 104px; |
|
|
|
overflow: hidden; |
|
|
|
overflow: hidden; |
|
|
|
|
|
|
|
|
|
|
|
&:hover { |
|
|
|
&:hover { |
|
|
|
border-color: #409EFF; |
|
|
|
border-color: #409eff; |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
.uploader-default { |
|
|
|
.uploader-default { |
|
|
@ -446,7 +489,8 @@ $avatar-width: 104px; |
|
|
|
/deep/ .d-inline-block { |
|
|
|
/deep/ .d-inline-block { |
|
|
|
width: 216px; |
|
|
|
width: 216px; |
|
|
|
|
|
|
|
|
|
|
|
.el-select, .el-input { |
|
|
|
.el-select, |
|
|
|
|
|
|
|
.el-input { |
|
|
|
width: 100%; |
|
|
|
width: 100%; |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|