|
|
|
|
|
<template>
|
|
|
|
|
|
<div>
|
|
|
|
|
|
<xy-dialog ref="dialog" :width="70" :is-show.sync="isShow" :type="'form'" :title="type === 'add' ? '新增课程' : '编辑课程'"
|
|
|
|
|
|
:form="form" :rules='rules' @submit="submit">
|
|
|
|
|
|
<template v-slot:name>
|
|
|
|
|
|
<div class="xy-table-item">
|
|
|
|
|
|
<div class="xy-table-item-label" style="font-weight: bold">
|
|
|
|
|
|
<span style="color: red;font-weight: bold;padding-right: 4px;">*</span>课程名称:
|
|
|
|
|
|
</div>
|
|
|
|
|
|
<div class="xy-table-item-content">
|
|
|
|
|
|
<el-input v-model="form.name" placeholder="请输入课程名称" clearable style="width: 100%;"></el-input>
|
|
|
|
|
|
</div>
|
|
|
|
|
|
</div>
|
|
|
|
|
|
</template>
|
|
|
|
|
|
<template v-slot:type>
|
|
|
|
|
|
<div class="xy-table-item">
|
|
|
|
|
|
<div class="xy-table-item-label" style="font-weight: bold">
|
|
|
|
|
|
<span style="color: red;font-weight: bold;padding-right: 4px;">*</span>课程类别:
|
|
|
|
|
|
</div>
|
|
|
|
|
|
<div class="xy-table-item-content">
|
|
|
|
|
|
<el-select v-model="form.type" placeholder="请选择类别" clearable style="width: 100%;">
|
|
|
|
|
|
<el-option v-for="item in course_type" :key="item.id" :label="item.value" :value="item.id">
|
|
|
|
|
|
</el-option>
|
|
|
|
|
|
</el-select>
|
|
|
|
|
|
</div>
|
|
|
|
|
|
</div>
|
|
|
|
|
|
</template>
|
|
|
|
|
|
<template v-slot:image_id>
|
|
|
|
|
|
<div class="xy-table-item">
|
|
|
|
|
|
<div class="xy-table-item-label" style="font-weight: bold;">
|
|
|
|
|
|
<span style="color: red;font-weight: bold;padding-right: 4px;">*</span>课程封面(750*400):
|
|
|
|
|
|
</div>
|
|
|
|
|
|
<div class="xy-table-item-content">
|
|
|
|
|
|
<el-upload :action="action" class='upload-demo' :limit="1" list-type="picture-card" :file-list="imgList"
|
|
|
|
|
|
ref="pictureUpload" :before-upload="beforeUpload" :auto-upload="true" :on-success="uploadSuccess"
|
|
|
|
|
|
:on-remove="uploadRemove">
|
|
|
|
|
|
<i class="el-icon-plus"></i>
|
|
|
|
|
|
</el-upload>
|
|
|
|
|
|
</div>
|
|
|
|
|
|
</div>
|
|
|
|
|
|
</template>
|
|
|
|
|
|
<template v-slot:content>
|
|
|
|
|
|
<div class="xy-table-item">
|
|
|
|
|
|
<div class="xy-table-item-label" style="font-weight: bold">
|
|
|
|
|
|
<span style="color: red;font-weight: bold;padding-right: 4px;">*</span>课程简介:
|
|
|
|
|
|
</div>
|
|
|
|
|
|
<div class="xy-table-item-content">
|
|
|
|
|
|
<my-tinymce v-if="showTinymce" @input="saveContent" :value="form.content"></my-tinymce>
|
|
|
|
|
|
</div>
|
|
|
|
|
|
</div>
|
|
|
|
|
|
</template>
|
|
|
|
|
|
<template v-slot:dateRange>
|
|
|
|
|
|
<div class="xy-table-item">
|
|
|
|
|
|
<div class="xy-table-item-label" style="font-weight: bold">
|
|
|
|
|
|
<span style="color: red;font-weight: bold;padding-right: 4px;">*</span>开课日期:
|
|
|
|
|
|
</div>
|
|
|
|
|
|
<div class="xy-table-item-content">
|
|
|
|
|
|
<el-date-picker @change="changeDateRange" style="width: 100%;" v-model="form.dateRange"
|
|
|
|
|
|
type="daterange" range-separator="至"
|
|
|
|
|
|
value-format="yyyy-MM-dd"
|
|
|
|
|
|
format="yyyy-MM-dd"
|
|
|
|
|
|
start-placeholder="开课日期" end-placeholder="结束日期">
|
|
|
|
|
|
</el-date-picker>
|
|
|
|
|
|
</div>
|
|
|
|
|
|
</div>
|
|
|
|
|
|
</template>
|
|
|
|
|
|
|
|
|
|
|
|
<template v-slot:total>
|
|
|
|
|
|
<div class="xy-table-item">
|
|
|
|
|
|
<div class="xy-table-item-label" style="font-weight: bold">
|
|
|
|
|
|
<span style="color: red;font-weight: bold;padding-right: 4px;"></span>开课人数:
|
|
|
|
|
|
</div>
|
|
|
|
|
|
<div class="xy-table-item-content">
|
|
|
|
|
|
<el-input style="width: 100%;" v-model="form.total" placeholder="请输入开课人数" clearable></el-input>
|
|
|
|
|
|
</div>
|
|
|
|
|
|
</div>
|
|
|
|
|
|
</template>
|
|
|
|
|
|
<template v-slot:class>
|
|
|
|
|
|
<div class="xy-table-item">
|
|
|
|
|
|
<div class="xy-table-item-label" style="font-weight: bold">
|
|
|
|
|
|
<span style="color: red;font-weight: bold;padding-right: 4px;"></span>所在班级(地点):
|
|
|
|
|
|
</div>
|
|
|
|
|
|
<div class="xy-table-item-content">
|
|
|
|
|
|
<el-input style="width: 100%;" v-model="form.class" placeholder="请输入所在班级(地点)" clearable></el-input>
|
|
|
|
|
|
</div>
|
|
|
|
|
|
</div>
|
|
|
|
|
|
</template>
|
|
|
|
|
|
<template v-slot:company_type>
|
|
|
|
|
|
<div class="xy-table-item">
|
|
|
|
|
|
<div class="xy-table-item-label" style="font-weight: bold">
|
|
|
|
|
|
<span style="color: red;font-weight: bold;padding-right: 4px;"></span>面向学员的企业性质:
|
|
|
|
|
|
</div>
|
|
|
|
|
|
<div class="xy-table-item-content">
|
|
|
|
|
|
<el-select style="width: 100%;" v-model="form.company_type" placeholder="请选择" clearable>
|
|
|
|
|
|
<el-option v-for="item in course_type" :key="item.id" :label="item.value" :value="item.id">
|
|
|
|
|
|
</el-option>
|
|
|
|
|
|
</el-select>
|
|
|
|
|
|
</div>
|
|
|
|
|
|
</div>
|
|
|
|
|
|
</template>
|
|
|
|
|
|
<template v-slot:industry>
|
|
|
|
|
|
<div class="xy-table-item">
|
|
|
|
|
|
<div class="xy-table-item-label" style="font-weight: bold">
|
|
|
|
|
|
<span style="color: red;font-weight: bold;padding-right: 4px;"></span>所属行业:
|
|
|
|
|
|
</div>
|
|
|
|
|
|
<div class="xy-table-item-content">
|
|
|
|
|
|
<el-select style="width: 100%;" v-model="form.industry" placeholder="请选择" clearable>
|
|
|
|
|
|
<el-option v-for="item in course_type" :key="item.id" :label="item.value" :value="item.id">
|
|
|
|
|
|
</el-option>
|
|
|
|
|
|
</el-select>
|
|
|
|
|
|
</div>
|
|
|
|
|
|
</div>
|
|
|
|
|
|
</template>
|
|
|
|
|
|
<template v-slot:status>
|
|
|
|
|
|
<div class="xy-table-item">
|
|
|
|
|
|
<div class="xy-table-item-label" style="font-weight: bold">
|
|
|
|
|
|
<span style="color: red;font-weight: bold;padding-right: 4px;"></span>状态:
|
|
|
|
|
|
</div>
|
|
|
|
|
|
<div class="xy-table-item-content">
|
|
|
|
|
|
<el-select style="width: 100%;" v-model="form.status" placeholder="请选择" clearable>
|
|
|
|
|
|
<el-option v-for="item in course_status" :key="item.id" :label="item.value" :value="item.id">
|
|
|
|
|
|
</el-option>
|
|
|
|
|
|
</el-select>
|
|
|
|
|
|
</div>
|
|
|
|
|
|
</div>
|
|
|
|
|
|
</template>
|
|
|
|
|
|
<template v-slot:settings>
|
|
|
|
|
|
<div class="xy-table-item">
|
|
|
|
|
|
<div class="xy-table-item-label" style="font-weight: bold;display:none">
|
|
|
|
|
|
<span style="color: red;font-weight: bold;padding-right: 4px;"></span>
|
|
|
|
|
|
</div>
|
|
|
|
|
|
<div class="xy-table-item-content" style="flex-grow: 1;">
|
|
|
|
|
|
课时设置:<el-button type="primary" icon="md-add" style="margin-bottom: 10px"
|
|
|
|
|
|
@click="form.settings.push({ name: '',desc:''})">新增</el-button>
|
|
|
|
|
|
<xy-table style="width: 100%" :height="260" :is-page="false" :list="form.settings"
|
|
|
|
|
|
:table-item="settings_Table">
|
|
|
|
|
|
<template v-slot:btns>
|
|
|
|
|
|
<el-table-column label="操作" width="90" header-align="center" align="center">
|
|
|
|
|
|
<template v-slot:default="scope">
|
|
|
|
|
|
<el-button size="small" type="danger" plain
|
|
|
|
|
|
@click="form.settings.splice(scope.$index, 1)">删除</el-button>
|
|
|
|
|
|
</template>
|
|
|
|
|
|
</el-table-column>
|
|
|
|
|
|
</template>
|
|
|
|
|
|
</xy-table>
|
|
|
|
|
|
</div>
|
|
|
|
|
|
</div>
|
|
|
|
|
|
</template>
|
|
|
|
|
|
</xy-dialog>
|
|
|
|
|
|
|
|
|
|
|
|
</div>
|
|
|
|
|
|
</template>
|
|
|
|
|
|
|
|
|
|
|
|
<script>
|
|
|
|
|
|
import myMixins from "@/mixin/selectMixin.js";
|
|
|
|
|
|
import {
|
|
|
|
|
|
show,
|
|
|
|
|
|
save
|
|
|
|
|
|
} from "@/api/course/index.js"
|
|
|
|
|
|
export default {
|
|
|
|
|
|
mixins: [myMixins],
|
|
|
|
|
|
data() {
|
|
|
|
|
|
return {
|
|
|
|
|
|
isShow: false,
|
|
|
|
|
|
type: 'add',
|
|
|
|
|
|
action: `${process.env.VUE_APP_UPLOAD_API}`,
|
|
|
|
|
|
id: '',
|
|
|
|
|
|
showTinymce: false,
|
|
|
|
|
|
imgList: [],
|
|
|
|
|
|
form: {
|
|
|
|
|
|
name: '',
|
|
|
|
|
|
type: '',
|
|
|
|
|
|
image_id: '',
|
|
|
|
|
|
content: '',
|
|
|
|
|
|
dateRange: '',
|
|
|
|
|
|
total: '',
|
|
|
|
|
|
class: '',
|
|
|
|
|
|
company_type: '',
|
|
|
|
|
|
industry: '',
|
|
|
|
|
|
status: 0,
|
|
|
|
|
|
settings: [],
|
|
|
|
|
|
},
|
|
|
|
|
|
settings_Table: [{
|
|
|
|
|
|
label: "课时名称",
|
|
|
|
|
|
width: 180,
|
|
|
|
|
|
customFn: (row) => {
|
|
|
|
|
|
return ( <el-input placeholder = "请输入课时名称"
|
|
|
|
|
|
type = "text"
|
|
|
|
|
|
v-model = {
|
|
|
|
|
|
row.name
|
|
|
|
|
|
}>
|
|
|
|
|
|
</el-input>
|
|
|
|
|
|
);
|
|
|
|
|
|
},
|
|
|
|
|
|
}, {
|
|
|
|
|
|
label: "课时简介",
|
|
|
|
|
|
customFn: (row) => {
|
|
|
|
|
|
return ( <el-input placeholder = "请输入课时简介"
|
|
|
|
|
|
type = "text"
|
|
|
|
|
|
v-model = {
|
|
|
|
|
|
row.desc
|
|
|
|
|
|
}>
|
|
|
|
|
|
</el-input>
|
|
|
|
|
|
);
|
|
|
|
|
|
},
|
|
|
|
|
|
}],
|
|
|
|
|
|
rules: {
|
|
|
|
|
|
name: [{
|
|
|
|
|
|
required: true,
|
|
|
|
|
|
message: '请输入标题'
|
|
|
|
|
|
}],
|
|
|
|
|
|
type: [{
|
|
|
|
|
|
required: true,
|
|
|
|
|
|
message: '请选择课程类别'
|
|
|
|
|
|
}],
|
|
|
|
|
|
content: [{
|
|
|
|
|
|
required: true,
|
|
|
|
|
|
message: '请输入课程简介'
|
|
|
|
|
|
}],
|
|
|
|
|
|
// image_id: [{
|
|
|
|
|
|
// required: true,
|
|
|
|
|
|
// message: '请上传课程封面'
|
|
|
|
|
|
// }],
|
|
|
|
|
|
dateRange:[{
|
|
|
|
|
|
required: true,
|
|
|
|
|
|
message: '请选择开课日期'
|
|
|
|
|
|
}],
|
|
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
},
|
|
|
|
|
|
created() {},
|
|
|
|
|
|
methods: {
|
|
|
|
|
|
saveContent(e) {
|
|
|
|
|
|
this.form.content = e
|
|
|
|
|
|
},
|
|
|
|
|
|
changeDateRange(e){
|
|
|
|
|
|
if(e){
|
|
|
|
|
|
this.form.start_date = e[0]
|
|
|
|
|
|
this.form.end_date = e[1]
|
|
|
|
|
|
console.log(e,this.form)
|
|
|
|
|
|
}else{
|
|
|
|
|
|
this.form.start_date = ''
|
|
|
|
|
|
this.form.end_date = ''
|
|
|
|
|
|
}
|
|
|
|
|
|
},
|
|
|
|
|
|
uploadFail(err) {
|
|
|
|
|
|
console.log(err)
|
|
|
|
|
|
},
|
|
|
|
|
|
beforeUpload(file) {
|
|
|
|
|
|
console.log(file)
|
|
|
|
|
|
const isImage = file.type.includes('image');
|
|
|
|
|
|
const isLt2M = file.size / 1024 / 1024 < 2;
|
|
|
|
|
|
if (!isImage) {
|
|
|
|
|
|
this.$message.error('请上传正确的图片格式文件');
|
|
|
|
|
|
}
|
|
|
|
|
|
if (!isLt2M) {
|
|
|
|
|
|
this.$message.error('上传文件大小不能超过2MB');
|
|
|
|
|
|
}
|
|
|
|
|
|
return isImage && isLt2M;
|
|
|
|
|
|
},
|
|
|
|
|
|
uploadSuccess(response, file, fileList) {
|
|
|
|
|
|
console.log(response, file, fileList)
|
|
|
|
|
|
this.form.image_id = response.id
|
|
|
|
|
|
this.imgList = fileList
|
|
|
|
|
|
},
|
|
|
|
|
|
uploadRemove(file, fileList) {
|
|
|
|
|
|
this.imgList = fileList
|
|
|
|
|
|
this.form.image_id = ''
|
|
|
|
|
|
},
|
|
|
|
|
|
submit() {
|
|
|
|
|
|
if (this.id) {
|
|
|
|
|
|
this.form.id = this.id
|
|
|
|
|
|
}
|
|
|
|
|
|
if (this.type == 'add') {
|
|
|
|
|
|
this.form.id = ''
|
|
|
|
|
|
}
|
|
|
|
|
|
save({
|
|
|
|
|
|
...this.form
|
|
|
|
|
|
}).then(res => {
|
|
|
|
|
|
this.$message({
|
|
|
|
|
|
type: 'success',
|
|
|
|
|
|
message: this.type === 'add' ? '新增课程成功' : '编辑课程成功'
|
|
|
|
|
|
})
|
|
|
|
|
|
this.isShow = false
|
|
|
|
|
|
this.$emit('refresh')
|
|
|
|
|
|
})
|
|
|
|
|
|
},
|
|
|
|
|
|
|
|
|
|
|
|
getDetail() {
|
|
|
|
|
|
show({
|
|
|
|
|
|
id: this.id,
|
|
|
|
|
|
// show_relation: ['image']
|
|
|
|
|
|
}).then(res => {
|
|
|
|
|
|
this.form = this.base.requestToForm(res, this.form)
|
|
|
|
|
|
if(res.image){
|
|
|
|
|
|
this.imgList.push(res.image)
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
this.form.dateRange = [res.start_date,res.end_date]
|
|
|
|
|
|
this.showTinymce = true
|
|
|
|
|
|
})
|
|
|
|
|
|
}
|
|
|
|
|
|
},
|
|
|
|
|
|
watch: {
|
|
|
|
|
|
isShow(newVal) {
|
|
|
|
|
|
if (newVal) {
|
|
|
|
|
|
if (this.type === 'editor') {
|
|
|
|
|
|
this.getDetail()
|
|
|
|
|
|
}else{
|
|
|
|
|
|
this.showTinymce = true
|
|
|
|
|
|
}
|
|
|
|
|
|
} else {
|
|
|
|
|
|
this.id = ''
|
|
|
|
|
|
this.showTinymce = false
|
|
|
|
|
|
this.imgList = []
|
|
|
|
|
|
this.$refs['dialog'].reset()
|
|
|
|
|
|
}
|
|
|
|
|
|
},
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
</script>
|
|
|
|
|
|
|
|
|
|
|
|
<style scoped lang="scss">
|
|
|
|
|
|
::v-deep .content,
|
|
|
|
|
|
::v-deep .settings {
|
|
|
|
|
|
flex-basis: 100%;
|
|
|
|
|
|
}
|
|
|
|
|
|
</style>
|