Files
huangguo_admin/src/views/lsjMediaLibrary/novelList/index.vue
T
2026-03-04 15:10:57 +08:00

335 lines
12 KiB
Vue

<template>
<div class="pf-warpper avlist">
<el-row class="table-form">
<el-form :inline="true" :model="searchData" class="form-inline" size="mini">
<el-form-item>
<el-input placeholder="请输入关键词" clearable v-model="searchData.keywords" @clear="onClear('keywords')" />
</el-form-item>
<el-form-item>
<el-input placeholder="请输入ID" clearable v-model="searchData.ids" @clear="onClear('id')" />
</el-form-item>
<el-form-item>
<el-select placeholder="请选择是否完结" clearable v-model="searchData.is_end" @clear="onClear('is_end')">
<el-option label="已完结" value="y" />
<el-option label="未完结" value="n" />
</el-select>
</el-form-item>
<el-form-item>
<el-select placeholder="请选择分类" clearable v-model="searchData.cat_id" @clear="onClear('cat_id')">
<el-option label="有声" value="audio" />
<el-option label="成人" value="18R" />
<el-option label="贤者" value="normal" />
</el-select>
</el-form-item>
<el-form-item>
<el-date-picker v-model="time" type="daterange" range-separator="至" value-format="yyyy-MM-dd HH:mm:ss"
start-placeholder="开始日期" end-placeholder="结束日期">
</el-date-picker>
</el-form-item>
<el-form-item>
<el-button @click="onSeach" icon="el-icon-search" plain type="primary">搜索</el-button>
<!-- <el-button @click="add" icon="el-icon-circle-plus-outline" plain type="success">新增</el-button> -->
<el-button @click="addPostArray" icon="el-icon-circle-plus-outline" plain type="warning">批量加入后台视频库</el-button>
</el-form-item>
</el-form>
</el-row>
<el-row>
<el-col>
<el-table :data="resData" element-loading-text="拼命加载中" border height="735" highlight-current-row
style="width: 100%; font-size: 10px" v-loading="loading" :row-style="{ height: '30px' }"
:cell-style="{ padding: '5px' }" @selection-change="handleSelectionChange">
<el-table-column type="selection" width="50"> </el-table-column>
<el-table-column align="center" label="ID" width="190px">
<template slot-scope="scope">{{ scope.row.id }}</template>
</el-table-column>
<el-table-column align="center" label="标题" width="190px" show-overflow-tooltip>
<template slot-scope="scope">{{ scope.row.name }}</template>
</el-table-column>
<el-table-column align="center" label="子标题" width="190px" show-overflow-tooltip>
<template slot-scope="scope">{{ scope.row.sub_title }}</template>
</el-table-column>
<el-table-column align="center" label="别名" width="390px" show-overflow-tooltip>
<template slot-scope="scope">{{ scope.row.alias_name }}</template>
</el-table-column>
<el-table-column align="center" label="描述" width="190px" show-overflow-tooltip>
<template slot-scope="scope">{{ scope.row.description }}</template>
</el-table-column>
<el-table-column align="center" label="封面" width="80px">
<template slot-scope="scope">
<ShowImg style="width: 30px; height: 30px; margin: 0 auto" :noNeedDoamin="true" :urls="scope.row.img">
</ShowImg>
</template>
</el-table-column>
<el-table-column align="center" label="分类名称" width="390px" show-overflow-tooltip>
<template slot-scope="scope">{{ scope.row.category_name }}</template>
</el-table-column>
<el-table-column align="center" label="章节数量">
<template slot-scope="scope">{{
scope.row.chapter_count
}}</template>
</el-table-column>
<el-table-column align="center" label="标签" width="300px">
<template slot-scope="scope">
<el-tag :key="index + 'tagData'" style="margin: 2px" v-for="(item, index) in scope.row.tags"
size="mini">
{{ item.name }}
</el-tag>
</template>
</el-table-column>
<el-table-column align="center" label="类型">
<template slot-scope="scope">{{ scope.row.type }}</template>
</el-table-column>
<el-table-column align="center" label="价格">
<template slot-scope="scope">{{ scope.row.money }}</template>
</el-table-column>
<el-table-column align="center" label="是否有声" width="110px">
<template slot-scope="scope">
<el-button plain size="mini">{{
scope.row.is_adult === 'y' ? '有声' : '文本' }}</el-button>
</template>
</el-table-column>
<el-table-column align="center" label="更新状态" width="110px">
<template slot-scope="scope">{{
scope.row.update_status | changeUpdateStatus
}}</template>
</el-table-column>
<el-table-column align="center" label="是否完结" width="110px">
<template slot-scope="scope">
<el-button plain size="mini">{{
scope.row.is_end === 'y' ? '已完结' : '未完结' }}</el-button>
</template>
</el-table-column>
<el-table-column align="center" width="120px" label="最后更新时间">
<template slot-scope="scope">{{ scope.row.last_update | BeiJingTime }}</template>
</el-table-column>
<el-table-column align="center" width="120px" label="创建时间">
<template slot-scope="scope">{{ scope.row.created_at | BeiJingTime }}</template>
</el-table-column>
<el-table-column align="center" fixed="right" label="操作" width="300">
<template slot-scope="scope">
<el-button @click="addPost(scope.$index, scope.row)" size="mini"
:type="scope.row.isAdd ? 'info' : 'primary'" :disabled="scope.row.isAdd ? true : false">{{
`${scope.row.isAdd ? '已加入后台资源库' : '加入后台资源库'}` }}</el-button>
<el-button @click="handleEdit(scope.$index, scope.row)" size="mini" type="primary">查看详情</el-button>
<!-- <el-button @click="handleDelete(scope.$index, scope.row)" size="mini" type="danger">删除</el-button> -->
</template>
</el-table-column>
</el-table>
</el-col>
</el-row>
<div class="table-pagination">
<el-pagination :current-page="page" :page-size="page_size"
:page-sizes="[10, 20, 30, 50, 100]" :total="total" @current-change="handleCurrentChange"
@size-change="handleSizeChange" layout="total, sizes, prev, pager, next, jumper" />
</div>
<!-- 查看详情 -->
<Edit :data="editData" v-if="editVisible" @close="closeEdit" />
<NovelDetailView v-if="showDetail" :itemData="novelDetailData" @close="closeEdit"
/>
</div>
</template>
<script>
// 引入模块
import ShowImg from '@/components/ShowImg/index.vue'
import Edit from './components/AddOrEdit'
import { lsjNovelList, lsjNovelDel, lsjNovelAdd } from '@/api/lsjMediaLibrary/novelList.js'
import { audioAdd } from '@/api/novelsManagement/audio.js'
import { isNumber } from 'mathjs/lib/entry/typeChecks'
import NovelDetailView from '@/components/NovelDetailView/index.vue'
export default {
name: 'MediaCat',
components: {
ShowImg,
Edit,
NovelDetailView
},
data() {
return {
page: 1,
page_size: 20,
novelDetailData:[],
// 请求列表参数
searchData: {
id: undefined,
name: undefined, // 外用状态
status: undefined, // "string",当前状态
cat_id: undefined // 视频归类
},
time: undefined,
resData: [], // el-table表格数据
total: 0, // 数据总条数
selectArray: undefined,
editShowLocationVisible: undefined,
showDetail: false,
loading: true, // 列表加载状态
// 编辑数据
editVisible: false, // 新增或编辑弹出框
editData: {
title: '查看详情',
data: {}
}
}
},
filters: {
changeUpdateStatus(v){
switch (v) {
case '0':
return '更新中'
case '1':
return '更新完成'
}
},
},
mounted() {
this.getMediaSearch()
},
methods: {
showDetailFn(row) {
this.novelDetailData = row
this.showDetail = true
},
// TODO:加入后台视频库
addPost(index, row) {
lsjNovelAdd({ id: row.id }).then((res) => {
if (res.code === 200) {
this.$message.success('加入成功!')
this.getMediaSearch()
} else {
this.$message.error('加入失败!')
}
})
},
// 加入后台音频库
addAudioArray() {
Object.keys(this.selectArray).forEach((key) => {
if (!this.selectArray[key].isAdd) {
this.audioListFn(key, this.selectArray[key])
}
})
},
// TODO:加入音频视频库
audioListFn(index, row) {
audioAdd({ fileId: row.id }).then((res) => {
if (res.code === 200) {
this.$message.success('加入成功!')
this.getMediaSearch()
} else {
this.$message.error('加入失败!')
}
})
},
// TODO:请求影片列表数据
getMediaSearch() {
this.loading = true
if(isNumber(this.page)|| isNumber(this.page_size)){
this.searchData.page = this.page + ''
this.searchData.page_size = this.page_size + ''
}
if (this.time) {
this.searchData.start_time = this.time[0]
this.searchData.end_time = this.time[1]
} else {
this.searchData.start_time = undefined
this.searchData.end_time = undefined
}
lsjNovelList(this.searchData).then((res) => {
if (res.code === 200) {
this.resData = res.data.data
this.total = Number(res.data.total)
} else {
this.$message.error('请求列表失败!')
this.resData = []
this.total = 0
}
this.loading = false
})
},
// TODO:删除影片列表数据
handleDelete(index, row) {
this.$confirm('确定删除?', '警告', {
confirmButtonText: '确定',
cancelButtonText: '取消',
type: 'warning'
}).then(() => {
lsjNovelDel({ id: row.id }).then((res) => {
if (res.code === 200) {
this.getMediaSearch()
this.$message.success('成功删除!')
} else {
this.$message.error(res.tip)
}
})
})
},
addPostArray() {
Object.keys(this.selectArray).forEach((key) => {
if (!this.selectArray[key].isAdd) {
this.addPost(key, this.selectArray[key])
}
})
},
onSeach() {
this.page = 1
this.page_size = 20
this.getMediaSearch()
},
// 切换每页数据量
handleSizeChange(val) {
this.page_size = val
this.getMediaSearch()
},
// 切换页数
handleCurrentChange(val) {
this.page = val
this.getMediaSearch()
},
handleSelectionChange(val) {
this.selectArray = val
},
// 新增按钮
add() {
this.editVisible = true // 新增或编辑弹出框
this.editData = {
title: '新增',
data: {}
}
},
// 编辑按钮
handleEdit(index, row) {
this.editVisible = true // 新增或编辑弹出框
this.editData = {
title: '查看详情',
data: row
}
},
// 关闭编辑弹窗
closeEdit() {
this.editVisible = false
this.editShowLocationVisible = false
this.showDetail = false
this.getMediaSearch()
},
// 清空某一项筛选列表
onClear(key) {
this.searchData[key] = undefined
this.getMediaSearch()
}
}
}
</script>