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

新闻 课程页面修改

parent b47b1bca
......@@ -135,6 +135,20 @@ export function praseStrEmpty(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 @@
</el-row>
<el-row>
<el-col :span="8">
<el-form-item label="封面:">
<el-form-item
label="封面:"
prop="pictureId"
:rules="[
{ required: !(controls.isOperation === '3'), trigger: 'blur' }
]"
>
<el-upload
class="avatar-uploader"
action="#"
......
......@@ -74,7 +74,15 @@
<span>{{ scope.$index + 1 }}</span>
</template>
</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>
<template slot-scope="scope">
<span>{{ scope.row.isForntPage === 1 ? '是' : '否' }}</span>
......@@ -91,14 +99,6 @@
</template>
</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>
<template slot-scope="scope">
<el-switch
......
......@@ -2,7 +2,7 @@
<div class="shiftInformation_update">
<div class="updateContainer">
<div class="topTitle">
<span class="topTitleText">{{title}}</span>
<span class="topTitleText">{{ title }}</span>
</div>
<div class="twoTitle">
<el-tag v-if="form.flag==='1'" type="success">已发布</el-tag>
......@@ -85,6 +85,44 @@
</el-form-item>
</el-col>
</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-col :span="24">
<el-form-item
......
......@@ -420,8 +420,8 @@
@close="clearResDialog"
>
<el-upload
accept=".zip, .rar"
ref="resUploadDialog"
accept=".zip, .rar"
class="upload-demo"
:file-list="resForm.filelist"
:action="resForm.resUrl"
......@@ -462,7 +462,6 @@
:http-request="uploadCustom"
:on-remove="removeCover"
drag
>
<i class="el-icon-upload" />
<div class="el-upload__text">将文件拖到此处,或<em>点击上传</em></div>
......@@ -1042,23 +1041,31 @@ export default {
},
// 根据岗位的id获取岗位的名称
getJobClassificationName(dictValue) {
let name = ''
if (!dictValue) {
return ''
}
const values = dictValue.split(',') // 将逗号分隔的多个值分割成数组
const names = []
this.valueOptions.forEach(item => {
if (item.dictValue === dictValue) {
name = item.dictLabel
if (values.includes(item.dictValue)) {
names.push(item.dictLabel) // 将找到的名称添加到数组中
}
})
return name
return names.join(',') // 将名称数组拼接成逗号分隔的字符串
},
// 根据技术分类的id获取技术分类的名称
getCourseDirectionName(dictValue) {
let name = ''
if (!dictValue) {
return ''
}
const values = dictValue.split(',') // 将逗号分隔的多个值分割成数组
const names = []
this.courseDirection.forEach(item => {
if (item.dictValue === dictValue) {
name = item.dictLabel
if (values.includes(item.dictValue)) {
names.push(item.dictLabel) // 将找到的名称添加到数组中
}
})
return name
return names.join(',') // 将名称数组拼接成逗号分隔的字符串
},
// 获取难度等级
getDifficultyLevel() {
......@@ -1078,13 +1085,17 @@ export default {
},
// 根据id获取课程方案的名称
getCoursePlanName(dictValue) {
let name = ''
if (!dictValue) {
return ''
}
const values = dictValue.split(',') // 将逗号分隔的多个值分割成数组
const names = []
this.coursePlanOptions.forEach(item => {
if (item.dictValue === dictValue) {
name = item.dictLabel
if (values.includes(item.dictValue)) {
names.push(item.dictLabel) // 将找到的名称添加到数组中
}
})
return name
return names.join(',') // 将名称数组拼接成逗号分隔的字符串
},
// 查询讲师
getTeacher() {
......
......@@ -14,7 +14,7 @@
</el-row>
<el-row :gutter="20">
<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-form-item>
</el-col>
......@@ -34,10 +34,11 @@
</el-form-item>
</el-col>
<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
v-model="form.classPlan"
filterable
multiple
class="normalSelct"
>
<el-option
......@@ -55,8 +56,8 @@
<el-form-item label="岗位分类:" prop="jobClassify">
<el-select
v-model="form.jobClassify"
filterable
class="normalSelct"
multiple
>
<el-option
v-for="(items,index) in valueOptions"
......@@ -71,7 +72,7 @@
<el-form-item label="技术分类:" prop="tecClassify">
<el-select
v-model="form.tecClassify"
filterable
multiple
class="normalSelct"
>
<el-option
......@@ -215,6 +216,7 @@ import {
} from '@/api/courseManagement/indexApi'
import { getDict } from '@/api/system/dict/data'
import { listCmsLecturer } from '@/api/courseManagement/cmsLecturer'
import { deepClone, praseStrEmpty } from '@/utils/common'
export default {
name: 'Index',
......@@ -353,12 +355,13 @@ export default {
// 保存
submit() {
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 !== undefined)
console.log(this.businessid !== '')
if (valid) {
if (this.businessid !== null && this.businessid !== '') {
if (praseStrEmpty(this.businessId) !== '') {
console.log('更新')
this.updateClass()
} else {
......@@ -372,12 +375,42 @@ export default {
getLessonDetail() {
detailBLesson(this.businessId).then(res => {
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() {
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
const message = res.message
type = (type === 200) ? 'success' : 'warning'
......@@ -393,6 +426,7 @@ export default {
},
// 修改课程
updateClass() {
console.log('调用了修改方法')
const form = {
businessId: this.businessId,
lessonName: this.form.lessonName,
......@@ -411,7 +445,15 @@ export default {
flag: this.form.flag,
lessonTeaName: this.form.lessonTeaName,
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 => {
......
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