Commit 6b1ba1da authored by 王飞龙's avatar 王飞龙

新闻 课程页面修改

parent b47b1bca
...@@ -135,6 +135,20 @@ export function praseStrEmpty(str) { ...@@ -135,6 +135,20 @@ export function praseStrEmpty(str) {
} }
return str return str
} }
export function deepClone(source) {
if (!source && typeof source !== 'object') {
throw new Error('error arguments', 'deepClone')
}
const targetObj = source.constructor === Array ? [] : {}
Object.keys(source).forEach(keys => {
if (source[keys] && typeof source[keys] === 'object') {
targetObj[keys] = deepClone(source[keys])
} else {
targetObj[keys] = source[keys]
}
})
return targetObj
}
/** /**
* 构造树型结构数据 * 构造树型结构数据
......
...@@ -61,7 +61,13 @@ ...@@ -61,7 +61,13 @@
</el-row> </el-row>
<el-row> <el-row>
<el-col :span="8"> <el-col :span="8">
<el-form-item label="封面:"> <el-form-item
label="封面:"
prop="pictureId"
:rules="[
{ required: !(controls.isOperation === '3'), trigger: 'blur' }
]"
>
<el-upload <el-upload
class="avatar-uploader" class="avatar-uploader"
action="#" action="#"
......
...@@ -74,7 +74,15 @@ ...@@ -74,7 +74,15 @@
<span>{{ scope.$index + 1 }}</span> <span>{{ scope.$index + 1 }}</span>
</template> </template>
</el-table-column> </el-table-column>
<el-table-column align="left" prop="title" label="新闻标题" width="500" show-overflow-tooltip /> <el-table-column align="left" prop="title" label="新闻标题" width="300" show-overflow-tooltip />
<el-table-column align="left" prop="remarks" label="新闻摘要" width="300" show-overflow-tooltip />
<el-table-column align="left" label="新闻标题图" prop="pictureId">
<template slot-scope="scope">
<div :id="step(scope.$index)">
<el-image :src="imagePath+scope.row.path" :preview-src-list="scope.row.srclist" style="width:100%;height:100%;" @click="handleClickStop(scope.$index)" @mouseover="justEnter($event)" @mouseout="justOut($event)" />
</div>
</template>
</el-table-column>
<el-table-column align="left" prop="isForntPage" label="是否为头条新闻" show-overflow-tooltip> <el-table-column align="left" prop="isForntPage" label="是否为头条新闻" show-overflow-tooltip>
<template slot-scope="scope"> <template slot-scope="scope">
<span>{{ scope.row.isForntPage === 1 ? '是' : '否' }}</span> <span>{{ scope.row.isForntPage === 1 ? '是' : '否' }}</span>
...@@ -91,14 +99,6 @@ ...@@ -91,14 +99,6 @@
</template> </template>
</el-table-column> </el-table-column>
<!-- <el-table-column align="left" label="封面" prop="pictureId">-->
<!-- <template slot-scope="scope">-->
<!-- <div :id="step(scope.$index)">-->
<!-- <el-image :src="imagePath+scope.row.path" :preview-src-list="scope.row.srclist" style="width:100%;height:100%;" @click="handleClickStop(scope.$index)" @mouseover="justEnter($event)" @mouseout="justOut($event)" />-->
<!-- </div>-->
<!-- </template>-->
<!-- </el-table-column>-->
<!-- 发布状态-->
<el-table-column align="left" prop="releaseStatus" label="发布状态" show-overflow-tooltip> <el-table-column align="left" prop="releaseStatus" label="发布状态" show-overflow-tooltip>
<template slot-scope="scope"> <template slot-scope="scope">
<el-switch <el-switch
......
...@@ -2,7 +2,7 @@ ...@@ -2,7 +2,7 @@
<div class="shiftInformation_update"> <div class="shiftInformation_update">
<div class="updateContainer"> <div class="updateContainer">
<div class="topTitle"> <div class="topTitle">
<span class="topTitleText">{{title}}</span> <span class="topTitleText">{{ title }}</span>
</div> </div>
<div class="twoTitle"> <div class="twoTitle">
<el-tag v-if="form.flag==='1'" type="success">已发布</el-tag> <el-tag v-if="form.flag==='1'" type="success">已发布</el-tag>
...@@ -85,6 +85,44 @@ ...@@ -85,6 +85,44 @@
</el-form-item> </el-form-item>
</el-col> </el-col>
</el-row> </el-row>
<el-row>
<el-col :span="8">
<el-form-item label="封面:">
<el-upload
class="avatar-uploader"
action="#"
:http-request="handleUpload"
:show-file-list="false"
:on-success="handleAvatarSuccess"
:before-upload="beforeAvatarUpload"
>
<img v-if="imageUrl" :src="imageUrl" style="height: 200px;width: 200px">
<i v-else class="el-icon-plus avatar-uploader-icon" />
</el-upload>
</el-form-item>
</el-col>
</el-row>
<el-row>
<el-col :span="24">
<el-form-item
label="新闻摘要:"
prop="remarks"
:rules="{ required: !(controls.isOperation === '3'), message: '请填写新闻简介', trigger: 'blur' }"
>
<el-input
v-model.trim="form.remarks"
type="textarea"
:disabled="secondFromDisabled"
placeholder="请输入新闻摘要"
size="small"
rows="3"
class="normalInput"
:maxlength="300"
/>
</el-form-item>
</el-col>
</el-row>
<el-row> <el-row>
<el-col :span="24"> <el-col :span="24">
<el-form-item <el-form-item
......
...@@ -420,8 +420,8 @@ ...@@ -420,8 +420,8 @@
@close="clearResDialog" @close="clearResDialog"
> >
<el-upload <el-upload
accept=".zip, .rar"
ref="resUploadDialog" ref="resUploadDialog"
accept=".zip, .rar"
class="upload-demo" class="upload-demo"
:file-list="resForm.filelist" :file-list="resForm.filelist"
:action="resForm.resUrl" :action="resForm.resUrl"
...@@ -462,7 +462,6 @@ ...@@ -462,7 +462,6 @@
:http-request="uploadCustom" :http-request="uploadCustom"
:on-remove="removeCover" :on-remove="removeCover"
drag drag
> >
<i class="el-icon-upload" /> <i class="el-icon-upload" />
<div class="el-upload__text">将文件拖到此处,或<em>点击上传</em></div> <div class="el-upload__text">将文件拖到此处,或<em>点击上传</em></div>
...@@ -1042,23 +1041,31 @@ export default { ...@@ -1042,23 +1041,31 @@ export default {
}, },
// 根据岗位的id获取岗位的名称 // 根据岗位的id获取岗位的名称
getJobClassificationName(dictValue) { getJobClassificationName(dictValue) {
let name = '' if (!dictValue) {
return ''
}
const values = dictValue.split(',') // 将逗号分隔的多个值分割成数组
const names = []
this.valueOptions.forEach(item => { this.valueOptions.forEach(item => {
if (item.dictValue === dictValue) { if (values.includes(item.dictValue)) {
name = item.dictLabel names.push(item.dictLabel) // 将找到的名称添加到数组中
} }
}) })
return name return names.join(',') // 将名称数组拼接成逗号分隔的字符串
}, },
// 根据技术分类的id获取技术分类的名称 // 根据技术分类的id获取技术分类的名称
getCourseDirectionName(dictValue) { getCourseDirectionName(dictValue) {
let name = '' if (!dictValue) {
return ''
}
const values = dictValue.split(',') // 将逗号分隔的多个值分割成数组
const names = []
this.courseDirection.forEach(item => { this.courseDirection.forEach(item => {
if (item.dictValue === dictValue) { if (values.includes(item.dictValue)) {
name = item.dictLabel names.push(item.dictLabel) // 将找到的名称添加到数组中
} }
}) })
return name return names.join(',') // 将名称数组拼接成逗号分隔的字符串
}, },
// 获取难度等级 // 获取难度等级
getDifficultyLevel() { getDifficultyLevel() {
...@@ -1078,13 +1085,17 @@ export default { ...@@ -1078,13 +1085,17 @@ export default {
}, },
// 根据id获取课程方案的名称 // 根据id获取课程方案的名称
getCoursePlanName(dictValue) { getCoursePlanName(dictValue) {
let name = '' if (!dictValue) {
return ''
}
const values = dictValue.split(',') // 将逗号分隔的多个值分割成数组
const names = []
this.coursePlanOptions.forEach(item => { this.coursePlanOptions.forEach(item => {
if (item.dictValue === dictValue) { if (values.includes(item.dictValue)) {
name = item.dictLabel names.push(item.dictLabel) // 将找到的名称添加到数组中
} }
}) })
return name return names.join(',') // 将名称数组拼接成逗号分隔的字符串
}, },
// 查询讲师 // 查询讲师
getTeacher() { getTeacher() {
......
...@@ -14,7 +14,7 @@ ...@@ -14,7 +14,7 @@
</el-row> </el-row>
<el-row :gutter="20"> <el-row :gutter="20">
<el-col :span="24"> <el-col :span="24">
<el-form-item label="一句话介绍:" prop="lessonBrief" :rules="[{ required: status !== '3', message: '请输入一句话介绍', trigger: 'blur' }]" > <el-form-item label="一句话介绍:" prop="lessonBrief" :rules="[{ required: status !== '3', message: '请输入一句话介绍', trigger: 'blur' }]">
<el-input v-model="form.lessonBrief" auto-complete="off" placeholder="请输入一句话介绍" :maxlength="100" /> <el-input v-model="form.lessonBrief" auto-complete="off" placeholder="请输入一句话介绍" :maxlength="100" />
</el-form-item> </el-form-item>
</el-col> </el-col>
...@@ -34,10 +34,11 @@ ...@@ -34,10 +34,11 @@
</el-form-item> </el-form-item>
</el-col> </el-col>
<el-col :span="12"> <el-col :span="12">
<el-form-item label="课程方案:" prop="classPlan" :rules="[{ required: status !== '3', message: '请输入课程方案', trigger: 'blur' }]"> <el-form-item label="课程方案:" prop="classPlan" :rules="[{ required: status !== '3', message: '请选择课程方案', trigger: 'change' }]">
<el-select <el-select
v-model="form.classPlan" v-model="form.classPlan"
filterable filterable
multiple
class="normalSelct" class="normalSelct"
> >
<el-option <el-option
...@@ -55,8 +56,8 @@ ...@@ -55,8 +56,8 @@
<el-form-item label="岗位分类:" prop="jobClassify"> <el-form-item label="岗位分类:" prop="jobClassify">
<el-select <el-select
v-model="form.jobClassify" v-model="form.jobClassify"
filterable
class="normalSelct" class="normalSelct"
multiple
> >
<el-option <el-option
v-for="(items,index) in valueOptions" v-for="(items,index) in valueOptions"
...@@ -71,7 +72,7 @@ ...@@ -71,7 +72,7 @@
<el-form-item label="技术分类:" prop="tecClassify"> <el-form-item label="技术分类:" prop="tecClassify">
<el-select <el-select
v-model="form.tecClassify" v-model="form.tecClassify"
filterable multiple
class="normalSelct" class="normalSelct"
> >
<el-option <el-option
...@@ -215,6 +216,7 @@ import { ...@@ -215,6 +216,7 @@ import {
} from '@/api/courseManagement/indexApi' } from '@/api/courseManagement/indexApi'
import { getDict } from '@/api/system/dict/data' import { getDict } from '@/api/system/dict/data'
import { listCmsLecturer } from '@/api/courseManagement/cmsLecturer' import { listCmsLecturer } from '@/api/courseManagement/cmsLecturer'
import { deepClone, praseStrEmpty } from '@/utils/common'
export default { export default {
name: 'Index', name: 'Index',
...@@ -353,12 +355,13 @@ export default { ...@@ -353,12 +355,13 @@ export default {
// 保存 // 保存
submit() { submit() {
this.$refs.courseRef.validate(valid => { this.$refs.courseRef.validate(valid => {
console.log('this.businessid', this.businessId) // this.businessId = praseStrEmpty(this.businessId)
// console.log('this.businessid', this.businessId)
console.log(this.businessid !== null) console.log(this.businessid !== null)
console.log(this.businessid !== undefined) console.log(this.businessid !== undefined)
console.log(this.businessid !== '') console.log(this.businessid !== '')
if (valid) { if (valid) {
if (this.businessid !== null && this.businessid !== '') { if (praseStrEmpty(this.businessId) !== '') {
console.log('更新') console.log('更新')
this.updateClass() this.updateClass()
} else { } else {
...@@ -372,12 +375,42 @@ export default { ...@@ -372,12 +375,42 @@ export default {
getLessonDetail() { getLessonDetail() {
detailBLesson(this.businessId).then(res => { detailBLesson(this.businessId).then(res => {
this.form = res.data this.form = res.data
this.imageUrl = this.imagePath + res.data.defaultUrl if (praseStrEmpty(this.form.classPlan) === '') {
// 把字符串转换成数组
this.form.classPlan = []
} else {
this.form.classPlan = this.form.classPlan.split(',')
}
if (praseStrEmpty(this.form.jobClassify) === '') {
this.form.jobClassify = []
} else {
this.form.jobClassify = this.form.jobClassify.split(',')
}
if (praseStrEmpty(this.form.tecClassify) === '') {
this.form.tecClassify = []
} else {
this.form.tecClassify = this.form.tecClassify.split(',')
}
this.imageUrl = res.data.defaultUrl
console.log('this.form', this.form.classPlan)
}) })
}, },
// 新增课程 // 新增课程
createClass() { createClass() {
blessonAdd(this.form).then(res => { console.log('调用了新增方法')
console.log('this.form', this.form)
// 克隆一个this.form对象
const form = deepClone(this.form)
if (form.classPlan.length > 0) {
form.classPlan = form.classPlan.join(',')
}
if (form.jobClassify.length > 0) {
form.jobClassify = form.jobClassify.join(',')
}
if (form.tecClassify.length > 0) {
form.tecClassify = form.tecClassify.join(',')
}
blessonAdd(form).then(res => {
let type = res.code let type = res.code
const message = res.message const message = res.message
type = (type === 200) ? 'success' : 'warning' type = (type === 200) ? 'success' : 'warning'
...@@ -393,6 +426,7 @@ export default { ...@@ -393,6 +426,7 @@ export default {
}, },
// 修改课程 // 修改课程
updateClass() { updateClass() {
console.log('调用了修改方法')
const form = { const form = {
businessId: this.businessId, businessId: this.businessId,
lessonName: this.form.lessonName, lessonName: this.form.lessonName,
...@@ -411,7 +445,15 @@ export default { ...@@ -411,7 +445,15 @@ export default {
flag: this.form.flag, flag: this.form.flag,
lessonTeaName: this.form.lessonTeaName, lessonTeaName: this.form.lessonTeaName,
defaultUrl: this.form.defaultUrl defaultUrl: this.form.defaultUrl
}
if (form.classPlan.length > 0) {
form.classPlan = form.classPlan.join(',')
}
if (form.jobClassify.length > 0) {
form.jobClassify = form.jobClassify.join(',')
}
if (form.tecClassify.length > 0) {
form.tecClassify = form.tecClassify.join(',')
} }
// 调用了编辑方法 // 调用了编辑方法
blessonAdd(form).then(res => { blessonAdd(form).then(res => {
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment