提交 553118a7 authored 作者: 翟畅's avatar 翟畅

zc

上级 2cc30ebd
......@@ -35,6 +35,7 @@ import questionsRouter from './modules/questions'
import courseRouter from './modules/course'
import paperRouter from './modules/paper'
import resourceRouter from './modules/resource'
import specialRouter from './modules/special'
import informationRouter from './modules/information'
import companyRouter from './modules/company'
import marketManageRouter from './modules/marketingManage'
......@@ -100,6 +101,8 @@ export const constantRoutes = [
companyRouter,
//营销信息
marketManageRouter,
//专题管理
specialRouter,
//题库管理
questionsRouter,
//课程管理
......
import Layout from '@/layout'
const specialRouter = {
path: '/special_manage',
component: Layout,
redirect: '/special_manage/specialSingle',
name: 'specialManage',
meta: {
title: '专题管理',
icon: 'folder'
},
children: [
{
path: 'specialSingle',
component: () => import('@/views/special_manage/special_module/index'),
name: 'specialSingle',
meta: {
title: '专题管理'
},
}, {
path: 'createSpecialSingle',
component: () => import('@/views/special_manage/special_module/create'),
name: 'createSpecialSingle',
meta: {
title: '新建专题',noCache: true, activeMenu: `/special_manage/specialSingle`
},
hidden: true
},{
path: 'editSpecialSingle',
component: () => import('@/views/special_manage/special_module/edit'),
name: 'editSpecialSingle',
meta: {
title: '编辑专题',noCache: true, activeMenu: `/special_manage/specialSingle`
},
hidden: true
},
{
path: 'specialRecommendedSingle',
component: () => import('@/views/special_manage/special_module/content'),
name: 'specialRecommendedSingle',
meta: {
title: '推荐内容',noCache: true,activeMenu: `/special_manage/specialSingle`
},
hidden: true
},
]
}
export default specialRouter
<template>
<div class="divBox">
<el-card class="box-card">
<div slot="header" class="clearfix">
<div class="back_box" @click="goBack()" v-if="this.$route.query.id">
<img src="@/assets/img/common/back.png"><span>返回</span>
</div>
<el-button class="mr10" size="small" type='primary' v-for="(item,index) in topBtn" :key="index" @click="handleBtn(item.url)">{{item.name}}</el-button>
</div>
<el-table ref="table" class="table_box" v-loading="listLoading" :data="dataList" style="width: 100%" size="mini" @selection-change="selectionChange" highlight-current-row @filter-change="filterChange">
<el-table-column type="selection" ref="selectionCheckbox" width="50" align="center"></el-table-column>
<el-table-column label="封面" min-width="4%" align="center">
<template slot-scope="scope">
<el-image v-if="scope.row.cover" :class="'cover'+scope.row.resourceType" :src="coverUrl(scope.row.cover)" :preview-src-list="[coverUrl(scope.row.cover)]"/>
<img v-else :class="'cover'+scope.row.resourceType" src="@/assets/img/common/nol_book.png"/>
</template>
</el-table-column>
<el-table-column prop="resourceName" label="推荐内容标题" show-overflow-tooltip min-width="20%"></el-table-column>
<el-table-column prop="sort" label="排序号" align="center" min-width="10%"></el-table-column>
<el-table-column prop="diyModeName" label="自定义模块" align="center" min-width="10%"></el-table-column>
<el-table-column label="添加时间" align="center" min-width="10%">
<template slot-scope="scope">
<span v-if="scope.row.createdTime">{{scope.row.createdTime}}</span>
<span v-else>{{scope.row.uploadTime}}</span>
</template>
</el-table-column>
<el-table-column prop="resourceType_zh" label="资源类型" align="center" min-width="10%" :filter-multiple="false" :filters="filterStatus" column-key="resourceType">
<template slot-scope="scope">
<span v-if="scope.row.resourceType == 2">电子书</span>
<span v-if="scope.row.resourceType == 1">纸质书</span>
<span v-if="scope.row.resourceType == 3">文章</span>
<span v-if="scope.row.resourceType == 5">视频</span>
<span v-if="scope.row.resourceType == 6">音频</span>
<span v-if="scope.row.resourceType == 7">专题</span>
<span v-if="scope.row.resourceType == 10">课程</span>
<span v-if="scope.row.resourceType == 11">有声书</span>
</template>
</el-table-column>
<el-table-column label="操作" min-width="10%" align="center">
<template slot-scope="scope">
<el-button type="text" size="small" v-for="(item,index) in lineBtn" @click="handleBtn(item.url,scope.row.id,scope.row.sort)" v-if="(item.url != 'removeLine' || scope.row.status == 0)" :key="index">{{item.name}}</el-button>
</template>
</el-table-column>
</el-table>
<div class="block">
<el-pagination
@size-change="sizeChange"
@current-change="currentChange"
:current-page="listQuery.pageNum"
:page-sizes="[30, 50, 100, 200]"
:page-size="listQuery.pageSize"
layout="total, sizes, prev, pager, next, jumper"
:total="total"
/>
</div>
<el-dialog title="修改排序" :visible.sync="dialogOrder" width="450px" :close-on-click-modal="false">
<el-form :rules="rules" :model="sortForm" label-position="right" label-width="100px" ref="sortForm">
<el-form-item label="排序号:" prop="sort" v-if="dialogOrder">
<el-input v-model="sortForm.sort" style="width:80%"></el-input>
</el-form-item>
</el-form>
<span class="dialog-footer" style="text-align:center;width:100%;display:inline-block">
<el-button @click="dialogOrder = false">取消</el-button>
<el-button @click="editOrder" :loading="sending" type="primary">确定</el-button>
</span>
</el-dialog>
<content-dialog :showDialog.sync="dialogContent" :bookId="$route.query.id" @close='dialogContent = false' @saveContent="getList"></content-dialog>
</el-card>
</div>
</template>
<script>
import {specialRecDelAPI,specialUpdateSortAPI,recommendListAPI} from '@/api/resource/special'
import { confirm } from '@/utils/function'
import { getSelectionIds } from '@/filters/getIds'
import { sortValidate } from '@/utils/validate'
import { specialList } from '@/utils/static'
import contentDialog from './content_dialog.vue'
export default {
components:{
contentDialog
},
data() {
return {
topBtn:[],
lineBtn:[],
specialList,
filterStatus:[
{text:'电子书',value:2},
{text:'纸质书',value:1},
{text:'文章',value:3},
{text:'视频',value:5},
{text:'音频',value:6},
{text:'课程',value:10},
{text:'有声书',value:11}
],
dataList: [],
listQuery:{
projectId: null,
resourceType: '',
pageNum: 1,
pageSize: 50
},
updateRelationForm:{
ids:[]
},
resourceType: 1,
total:null,
checkAll: false,
status: 1,
listLoading: false,
chooiceList: [],
dialogOrder: false,
dialogContent:false,
sortId: null,
sending: false,
sortForm: {
sort: null,
},
rules:{
sort:[
{required: true , message: '请输入排序号' },
{pattern: sortValidate, message:'请输入0-99999之间的整数'}
]
},
}
},
created() {
setTimeout(() => {
let list = this.$store.state.btn.btnList;
list.forEach(item => {
if(item.type == 8){
this.topBtn.push(item)
}else if(item.type == 9 ){
this.lineBtn.push(item)
}
})
},0)
this.listQuery.projectId = this.$route.query.id
this.getList()
},
methods: {
goBack(){
let view = this.$route
this.$store.dispatch('tagsView/delView', view)
this.$router.replace({path:this.$route.meta.activeMenu})
},
filterChange(filters){
this.listQuery.resourceType = filters.resourceType[0]
this.getList(1)
},
getList(num) {
this.listLoading = true
this.listQuery.pageNum = num ? num : this.listQuery.pageNum
recommendListAPI(this.listQuery).then(res => {
if(res.data.code === 0){
this.dataList = res.data.data.list
this.total = res.data.data.total
} else {
this.$message.error('获取数据失败');
}
this.listLoading = false
})
},
handleBtn(btnName,id,sort) {
let status = {
'editSortLine':()=>{ //修改排序
this.dialogOrder = true;
this.sortId = id;
this.sortForm.sort = sort;
console.log(this.sortForm.sort,'this.sortForm.sort')
this.$nextTick(()=>{
this.$refs['sortForm'].resetFields();
})
this.$forceUpdate()
},
'batchCancelBtn':()=>{ this.removeData() }, //删除
'recommendBtn':()=>{ //推荐内容
this.dialogContent = true
},
}
status[btnName]()
},
removeData() {//删除数据
if(this.isExist(this.chooiceList)){//至少选中一条
confirm.apply(this,['确定批量取消选择的数据吗?']).then(() => {
this.updateRelationForm.ids = getSelectionIds(this.chooiceList)
specialRecDelAPI(this.updateRelationForm.ids).then(res =>{
if (res.data.code === 0) {
this.$message.success('批量取消成功');
this.getList()
} else {
this.$message.error('批量取消失败');
}
})
});
}
},
editOrder() { //修改排序
let sortObj = {
id: this.sortId,
sort: this.sortForm.sort
}
this.$refs['sortForm'].validate((valid) => {
if(valid){
this.sending = true
specialUpdateSortAPI(sortObj).then(res => {
if(res.data.code === 0) {
this.$message.success('修改排序成功')
this.dialogOrder = false
this.getList()
} else {
this.$message.error('修改排序失败')
}
this.sending = false
})
}
})
},
selectAll(val) {//顶部全选
this.checkAll = val.length > 0
},
selectionChange(val) {//勾选table
this.chooiceList = val
this.checkAll = val.length === this.dataList.length && this.dataList.length > 0
},
sizeChange(val){
this.listQuery.pageSize = val
this.getList()
},
currentChange(val) {
this.listQuery.pageNum = val
this.getList()
},
}
}
</script>
<style lang="scss" scoped>
.cover1,.cover2{
width: 28px;
height: 38px;
}
.cover10{
width: 48px;
height: 27px;
}
.cover3,.cover5,.cover6,.cover7,.cover11{
width: 40px;
height: 28px
}
.el-dropdown-link {
cursor: pointer;
color: #409EFF;
font-size: 12px;
}
.table_box{
min-height: 540px;
}
.el-icon-arrow-down {
font-size: 12px;
}
</style>
\ No newline at end of file
<template>
<div>
<el-dialog title="推荐内容" class="fixHeight" :visible.sync="openDialog" width="60%" :before-close="cancel" @close="emptyResource" :close-on-click-modal="false">
<el-form inline :model="listQuery">
<el-form-item style="width:120px">
<el-select v-model="diyModelId" placeholder="请选择资源" style="width:100%" @change="getList(1)">
<el-option v-for="(item,index) in moudelList" :key="index" :label="item.name" :value="item.id"></el-option>
</el-select>
</el-form-item>
<el-form-item v-for="item in searchBox" :key="item.name">
<el-input v-model="listQuery[item.name]" @keyup.enter.native="getList(1)"
:placeholder="item.placeholder" clearable></el-input>
</el-form-item>
<el-form-item>
<el-button type="primary" @click="getList(1)" icon="el-icon-search">检索</el-button>
</el-form-item>
</el-form>
<div style="height:400px;overflow:auto;">
<el-table ref="multipleTable" :data="dataList" highlight-current-row tooltip-effect="dark" @selection-change="selectionChange">
<el-table-column type="selection" ref="selectionCheckbox"></el-table-column>
<el-table-column prop="name" label="资源名称" min-width="17%" show-overflow-tooltip></el-table-column>
<el-table-column prop="author" min-width="10%" label="作者" align="center" v-if="listQuery.resourceType != 7 && listQuery.resourceType != 10"></el-table-column>
<el-table-column label="上传时间" min-width="15%" align="center">
<template slot-scope="scope">
<span v-if="scope.row.createdTime">{{scope.row.createdTime}}</span>
<span v-else>{{scope.row.uploadTime}}</span>
</template>
</el-table-column>
<el-table-column label="状态" min-width="10%" align="center">
<template slot-scope="scope">
<span v-if="scope.row.bookStatus == 1 || scope.row.status == 1">已上架</span>
<span v-if="scope.row.bookStatus == 0 || scope.row.status == 0">已下架</span>
</template>
</el-table-column>
</el-table>
</div>
<!-- 分页以及底部按钮-->
<div class="box_pagination">
<el-pagination
@size-change="sizeChange"
@current-change="currentChange"
:current-page="listQuery.pageNum"
:page-sizes="[30, 50, 100, 200]"
:page-size="listQuery.pageSize"
layout="total, sizes, prev, pager, next, jumper"
:total="total">
</el-pagination>
</div>
<div class="dialog_footer">
<el-button @click="cancel">取消</el-button>
<el-button @click="dataSubmit" type="primary" :loading="sending">确定</el-button>
</div>
</el-dialog>
</div>
</template>
<script>
import { authorRecommendAllAPI } from '@/api/resource/author'
import {specialTemplateAPI,specialSaveRecAPI} from '@/api/resource/special'
import { getSelectionIds } from '@/filters/getIds'
export default {
data() {
return {
dataList: [],
diyModelId:null,
chooiceList: [],
moudelList:[],
searchBox:[{name:'name',placeholder:'请输入资源名称'}],
listQuery:{
id:null,
pageSize: 50,
pageNum:1,
resourceType:null,
type:null
},
openDialog:false,
total: null,
sending: false,
resourceList:[{id:2,name:'电子书'},{id:1,name:'纸质书'},{id:3,name:'文章'},{id:5,name:'视频'},{id:6,name:'音频'},{id:10,name:'课程'},{id:11,name:'有声书'},{id:7,name:'专题'}],
}
},
props:['showDialog','bookId'],
watch:{
showDialog(val){
this.openDialog = val
if(val){
this.sending = false
this.specialTemplate()
}
}
},
methods: {
specialTemplate(){
specialTemplateAPI(this.$route.query.id).then(res => {
if(res.data.code == 0){
this.moudelList = res.data.data
this.diyModelId = this.moudelList[0].id
this.getList(1)
}
})
},
emptyResource(){
this.listQuery={
pageNum: 1,
pageSize: 50,
resourceType:this.type,
type:2
}
},
getList(num) {
this.listQuery.type = 7
this.listQuery.pageNum = num ? num : this.listQuery.pageNum
this.listQuery.id = this.bookId
this.listQuery.resourceType = this.moudelList.filter(el => el.id == this.diyModelId)[0].resourceType
authorRecommendAllAPI(this.listQuery).then(res =>{//列表
if (res.data.code === 0) {
this.dataList = res.data.data?res.data.data.list:[]
this.total = res.data.data?res.data.data.total:0
} else {
this.$message.error('数据加载失败');
}
})
},
selectionChange(val) {//勾选table
this.chooiceList = val
},
dataSubmit() { //添加按钮
this.sending = true
if(this.isExist(this.chooiceList)){//至少选中一条
let resourceIds = getSelectionIds(this.chooiceList)
let data = {
resourceIds,
diyModelId:this.diyModelId,
projectId: this.$route.query.id,
resourceType: this.listQuery.resourceType
}
specialSaveRecAPI(data).then(res =>{
if (res.data.code === 0) {
this.$message.success('添加成功');
this.$emit('saveContent')
this.$emit('close')
return
} else {
this.sending = false
this.$message.error('添加失败');
}
})
} else {
this.sending = false
}
},
sizeChange(val){
this.listQuery.pageSize = val
this.getList()
},
currentChange(val) {
this.listQuery.pageNum = val
this.getList()
},
cancel(){
this.$emit('close')
}
},
}
</script>
<style scoped>
.dialog_footer{
width: 200px;
margin: 20px auto;
display: flex;
justify-content: space-between;
}
.bottom_check{
float: left;
height: 28px;
line-height: 28px;
padding: 2px 5px;
font-size: 13px;
}
.box_pagination{
min-height: 52px;
display: flex;
justify-content: center;
align-items: center;
margin-top: 10px;
}
</style>
\ No newline at end of file
<template>
<div>
<edit></edit>
</div>
</template>
<script>
import edit from './component'
export default {
name:'createSpecialSingle',
components:{
edit
}
}
</script>
\ No newline at end of file
<template>
<div>
<edit></edit>
</div>
</template>
<script>
import edit from './component'
export default {
name:'editSpecialSingle',
components:{
edit
}
}
</script>
\ No newline at end of file
Markdown 格式
0%
您添加了 0 到此讨论。请谨慎行事。
请先完成此评论的编辑!
注册 或者 后发表评论