This commit is contained in:
Sakura9701
2022-09-14 10:24:19 +08:00
parent 71d5a097e0
commit 9c6cc6a683
37 changed files with 4322 additions and 38 deletions

View File

@@ -46,7 +46,7 @@
filterable
allow-create
default-first-option
placeholder="请输入作者姓名">
placeholder="请输入出版社名称">
<el-option
v-for="item in publisherList"
:key="item.value + ''"
@@ -97,7 +97,7 @@
class="upload-demo"
action="http://localhost:9100/pb/oss/fileoss"
:on-preview="handlePreview"
:on-remove="handleRemove"
:on-remove="handleRemoveNovel"
:before-remove="beforeRemove"
:on-success="handleNovelSuccess"
multiple
@@ -242,7 +242,6 @@ export default {
},
methods: {
init(id) {
this.fileList = []
this.dataForm.id = id || 0
this.visible = true
this.$nextTick(() => {
@@ -274,9 +273,14 @@ export default {
var checklist = data.book.type
var authorList = data.book.authorId
var publisherlish = data.book.publisherId
this.dataForm.publisherId = publisherlish.split(',')
if(data.book.authorId != ""){
this.dataForm.authorId = authorList.split(',')
}
if(data.book.publisherId != ""){
this.dataForm.publisherId = publisherlish.split(',')
}
this.dataForm.type = checklist.split(',')
this.dataForm.authorId = authorList.split(',')
console.log(this.dataForm.type)
if (data.book.images != "") {
var img = { name: '', url: data.book.images }

View File

@@ -0,0 +1,138 @@
<template>
<el-dialog
:title="!dataForm.id ? '新增' : '修改'"
:close-on-click-modal="false"
:visible.sync="visible">
<el-form :model="dataForm" :rules="dataRule" ref="dataForm" @keyup.enter.native="dataFormSubmit()" label-width="80px">
<el-form-item label="用户id" prop="userId">
<el-input v-model="dataForm.userId" placeholder="用户id"></el-input>
</el-form-item>
<el-form-item label="图书id" prop="bookId">
<el-input v-model="dataForm.bookId" placeholder="图书id"></el-input>
</el-form-item>
<el-form-item label="图书名称" prop="bookName">
<el-input v-model="dataForm.bookName" placeholder="图书名称"></el-input>
</el-form-item>
<el-form-item label="创建时间" prop="createTime">
<el-input v-model="dataForm.createTime" placeholder="创建时间"></el-input>
</el-form-item>
<el-form-item label="更新时间" prop="updateTime">
<el-input v-model="dataForm.updateTime" placeholder="更新时间"></el-input>
</el-form-item>
<el-form-item label="排序" prop="sort">
<el-input v-model="dataForm.sort" placeholder="排序"></el-input>
</el-form-item>
<el-form-item label="删除标记" prop="delFlag">
<el-input v-model="dataForm.delFlag" placeholder="删除标记"></el-input>
</el-form-item>
</el-form>
<span slot="footer" class="dialog-footer">
<el-button @click="visible = false">取消</el-button>
<el-button type="primary" @click="dataFormSubmit()">确定</el-button>
</span>
</el-dialog>
</template>
<script>
export default {
data () {
return {
visible: false,
dataForm: {
id: 0,
userId: '',
bookId: '',
bookName: '',
createTime: '',
updateTime: '',
sort: '',
delFlag: ''
},
dataRule: {
userId: [
{ required: true, message: '用户id不能为空', trigger: 'blur' }
],
bookId: [
{ required: true, message: '图书id不能为空', trigger: 'blur' }
],
bookName: [
{ required: true, message: '图书名称不能为空', trigger: 'blur' }
],
createTime: [
{ required: true, message: '创建时间不能为空', trigger: 'blur' }
],
updateTime: [
{ required: true, message: '更新时间不能为空', trigger: 'blur' }
],
sort: [
{ required: true, message: '排序不能为空', trigger: 'blur' }
],
delFlag: [
{ required: true, message: '删除标记不能为空', trigger: 'blur' }
]
}
}
},
methods: {
init (id) {
this.dataForm.id = id || 0
this.visible = true
this.$nextTick(() => {
this.$refs['dataForm'].resetFields()
if (this.dataForm.id) {
this.$http({
url: this.$http.adornUrl(`/book/bookbrowserecords/info/${this.dataForm.id}`),
method: 'get',
params: this.$http.adornParams()
}).then(({data}) => {
if (data && data.code === 0) {
this.dataForm.userId = data.bookBrowseRecords.userId
this.dataForm.bookId = data.bookBrowseRecords.bookId
this.dataForm.bookName = data.bookBrowseRecords.bookName
this.dataForm.createTime = data.bookBrowseRecords.createTime
this.dataForm.updateTime = data.bookBrowseRecords.updateTime
this.dataForm.sort = data.bookBrowseRecords.sort
this.dataForm.delFlag = data.bookBrowseRecords.delFlag
}
})
}
})
},
// 表单提交
dataFormSubmit () {
this.$refs['dataForm'].validate((valid) => {
if (valid) {
this.$http({
url: this.$http.adornUrl(`/book/bookbrowserecords/${!this.dataForm.id ? 'save' : 'update'}`),
method: 'post',
data: this.$http.adornData({
'id': this.dataForm.id || undefined,
'userId': this.dataForm.userId,
'bookId': this.dataForm.bookId,
'bookName': this.dataForm.bookName,
'createTime': this.dataForm.createTime,
'updateTime': this.dataForm.updateTime,
'sort': this.dataForm.sort,
'delFlag': this.dataForm.delFlag
})
}).then(({data}) => {
if (data && data.code === 0) {
this.$message({
message: '操作成功',
type: 'success',
duration: 1500,
onClose: () => {
this.visible = false
this.$emit('refreshDataList')
}
})
} else {
this.$message.error(data.msg)
}
})
}
})
}
}
}
</script>

View File

@@ -0,0 +1,199 @@
<template>
<div class="mod-config">
<el-form :inline="true" :model="dataForm" @keyup.enter.native="getDataList()">
<el-form-item>
<el-input v-model="dataForm.key" placeholder="参数名" clearable></el-input>
</el-form-item>
<el-form-item>
<el-button @click="getDataList()">查询</el-button>
<el-button v-if="isAuth('book:bookbrowserecords:save')" type="primary" @click="addOrUpdateHandle()">新增</el-button>
<el-button v-if="isAuth('book:bookbrowserecords:delete')" type="danger" @click="deleteHandle()" :disabled="dataListSelections.length <= 0">批量删除</el-button>
</el-form-item>
</el-form>
<el-table
:data="dataList"
border
v-loading="dataListLoading"
@selection-change="selectionChangeHandle"
style="width: 100%;">
<el-table-column
type="selection"
header-align="center"
align="center"
width="50">
</el-table-column>
<el-table-column
prop="id"
header-align="center"
align="center"
label="">
</el-table-column>
<el-table-column
prop="userId"
header-align="center"
align="center"
label="用户id">
</el-table-column>
<el-table-column
prop="bookId"
header-align="center"
align="center"
label="图书id">
</el-table-column>
<el-table-column
prop="bookName"
header-align="center"
align="center"
label="图书名称">
</el-table-column>
<el-table-column
prop="createTime"
header-align="center"
align="center"
label="创建时间">
</el-table-column>
<el-table-column
prop="updateTime"
header-align="center"
align="center"
label="更新时间">
</el-table-column>
<el-table-column
prop="sort"
header-align="center"
align="center"
label="排序">
</el-table-column>
<el-table-column
prop="delFlag"
header-align="center"
align="center"
label="删除标记">
</el-table-column>
<el-table-column
fixed="right"
header-align="center"
align="center"
width="150"
label="操作">
<template slot-scope="scope">
<el-button type="text" size="small" @click="addOrUpdateHandle(scope.row.id)">修改</el-button>
<el-button type="text" size="small" @click="deleteHandle(scope.row.id)">删除</el-button>
</template>
</el-table-column>
</el-table>
<el-pagination
@size-change="sizeChangeHandle"
@current-change="currentChangeHandle"
:current-page="pageIndex"
:page-sizes="[10, 20, 50, 100]"
:page-size="pageSize"
:total="totalPage"
layout="total, sizes, prev, pager, next, jumper">
</el-pagination>
<!-- 弹窗, 新增 / 修改 -->
<add-or-update v-if="addOrUpdateVisible" ref="addOrUpdate" @refreshDataList="getDataList"></add-or-update>
</div>
</template>
<script>
import AddOrUpdate from './bookbrowserecords-add-or-update'
export default {
data () {
return {
dataForm: {
key: ''
},
dataList: [],
pageIndex: 1,
pageSize: 10,
totalPage: 0,
dataListLoading: false,
dataListSelections: [],
addOrUpdateVisible: false
}
},
components: {
AddOrUpdate
},
activated () {
this.getDataList()
},
methods: {
// 获取数据列表
getDataList () {
this.dataListLoading = true
this.$http({
url: this.$http.adornUrl('/book/bookbrowserecords/list'),
method: 'get',
params: this.$http.adornParams({
'page': this.pageIndex,
'limit': this.pageSize,
'key': this.dataForm.key
})
}).then(({data}) => {
if (data && data.code === 0) {
this.dataList = data.page.list
this.totalPage = data.page.totalCount
} else {
this.dataList = []
this.totalPage = 0
}
this.dataListLoading = false
})
},
// 每页数
sizeChangeHandle (val) {
this.pageSize = val
this.pageIndex = 1
this.getDataList()
},
// 当前页
currentChangeHandle (val) {
this.pageIndex = val
this.getDataList()
},
// 多选
selectionChangeHandle (val) {
this.dataListSelections = val
},
// 新增 / 修改
addOrUpdateHandle (id) {
this.addOrUpdateVisible = true
this.$nextTick(() => {
this.$refs.addOrUpdate.init(id)
})
},
// 删除
deleteHandle (id) {
var ids = id ? [id] : this.dataListSelections.map(item => {
return item.id
})
this.$confirm(`确定对[id=${ids.join(',')}]进行[${id ? '删除' : '批量删除'}]操作?`, '提示', {
confirmButtonText: '确定',
cancelButtonText: '取消',
type: 'warning'
}).then(() => {
this.$http({
url: this.$http.adornUrl('/book/bookbrowserecords/delete'),
method: 'post',
data: this.$http.adornData(ids, false)
}).then(({data}) => {
if (data && data.code === 0) {
this.$message({
message: '操作成功',
type: 'success',
duration: 1500,
onClose: () => {
this.getDataList()
}
})
} else {
this.$message.error(data.msg)
}
})
})
}
}
}
</script>

View File

@@ -1,5 +1,5 @@
<template>
<el-dialog :title="!dataForm.id ? '新增' : '修改'" :close-on-click-modal="false" :visible.sync="visible" @close="handlereset">
<el-dialog :title="!dataForm.id ? '新增' : '修改'" :close-on-click-modal="false" :visible.sync="visible" @close="handlereset">
<el-form :model="dataForm" :rules="dataRule" ref="dataForm" @keyup.enter.native="dataFormSubmit()"
label-width="80px">
<!-- <el-form-item label="" prop="bookId">
@@ -13,16 +13,15 @@
</el-form-item>
<el-form-item label="内容" prop="content">
<el-input v-model="dataForm.content" placeholder="内容" type="textarea"></el-input>
<el-button style="margin-top: 10px;" @click="fontchange(dataForm.content)" type="primary">文字转语音</el-button>
<el-button style="margin-top: 10px;" @click="fontchange(dataForm.content)" type="primary">文字转语音</el-button>
</el-form-item>
<el-form-item label="音频文件上传" prop="voices">
<el-upload class="upload-demo" action="http://localhost:9100/pb/oss/fileoss" :on-preview="handlePreview"
:on-remove="handleRemove" :on-success="handleVoicesSuccess" multiple :limit="3"
:file-list="fileListVoices">
:on-remove="handleRemove" :on-success="handleVoicesSuccess" multiple :limit="3" :file-list="fileListVoices">
<el-button size="small" type="primary">点击上传</el-button>
</el-upload>
<audio controls="controls" hidden src="./static/audio/tsy.wav" ref="audio"></audio>
<audio id="resource" :src="dataForm.voices" controls autoplay="autoplay" v-show='true'></audio>
<audio controls="controls" hidden src="./static/audio/tsy.wav" ref="audio"></audio>
<audio id="resource" :src="dataForm.voices" controls v-show='true'></audio>
</el-form-item>
<!-- <el-form-item label="" prop="createTime">
<el-input v-model="dataForm.createTime" placeholder=""></el-input>
@@ -30,6 +29,32 @@
<el-form-item label="" prop="updateTime">
<el-input v-model="dataForm.updateTime" placeholder=""></el-input>
</el-form-item> -->
<el-form-item label="图片表格" prop="otherContent">
<div class="mod-demo-ueditor">
<el-alert title="提示:" type="warning" :closable="false">
<div slot-scope="">
<p class="el-alert__description">1. 此Demo只提供UEditor官方使用文档入门部署和体验功能具体使用请参考http://fex.baidu.com/ueditor/
</p>
<p class="el-alert__description">2. 浏览器控制台报错请求后台配置项http错误上传功能将不能正常使用此错需要后台提供上传接口方法赋值给serverUrl属性
</p>
</div>
</el-alert>
<component :is="'script'" :id="ueId" class="ueditor-box" type="text/plain" style="width: 100%; height: 260px;">hello world!
</component>
<!-- 获取内容 -->
<p>
<el-button @click="getContent()">获得内容</el-button>
</p>
<el-dialog title="内容" :visible.sync="dialogVisible" :append-to-body="true">
{{ dataForm.otherContent }}
<span slot="footer" class="dialog-footer">
<el-button type="primary" @click="dialogVisible = false"> </el-button>
</span>
</el-dialog>
</div>
</el-form-item>
<el-form-item label="排序" prop="sort">
<el-input v-model="dataForm.sort" placeholder="排序"></el-input>
</el-form-item>
@@ -45,10 +70,15 @@
</template>
<script>
import ueditor from 'ueditor'
export default {
data() {
return {
visible: false,
ue: null,
ueId: `J_ueditorBox_${new Date().getTime()}`,
ueContent: '',
dialogVisible: false,
fileListVoices: [],
dataForm: {
id: 0,
@@ -57,6 +87,7 @@ export default {
number: '',
content: '',
voices: '',
otherContent:'',
createTime: '',
updateTime: '',
sort: '',
@@ -93,6 +124,9 @@ export default {
}
}
},
mounted(){
console.log(this.dataForm.otherContent)
},
methods: {
init(id) {
this.dataForm.id = id || 0
@@ -115,6 +149,13 @@ export default {
this.dataForm.updateTime = data.bookChapterContent.updateTime
this.dataForm.sort = data.bookChapterContent.sort
this.dataForm.delFlag = data.bookChapterContent.delFlag
this.dataForm.otherContent = data.bookChapterContent.otherContent
var uploadUrl = this.$http.adornUrl(`/ueditor/config?token=${this.$cookie.get('token')}`);
this.ue = ueditor.getEditor(this.ueId, {
serverUrl: uploadUrl, // 服务器统一请求接口路径
zIndex: 3000
})
this.setContentValue(this.dataForm.otherContent)
if (data.bookChapterContent.voices != "" && data.bookChapterContent.voices != null && data.bookChapterContent.voices != 'undefined') {
var voices = { name: '音频文件', url: data.bookChapterContent.voices }
@@ -132,6 +173,7 @@ export default {
// 表单提交
dataFormSubmit() {
this.$refs['dataForm'].validate((valid) => {
this.getContent()
if (valid) {
this.$http({
url: this.$http.adornUrl(`/book/bookchaptercontent/${!this.dataForm.id ? 'save' : 'update'}`),
@@ -146,7 +188,8 @@ export default {
'createTime': this.dataForm.createTime,
'updateTime': this.dataForm.updateTime,
'sort': this.dataForm.sort,
'delFlag': this.dataForm.delFlag
'delFlag': this.dataForm.delFlag,
'otherContent':this.dataForm.otherContent
})
}).then(({ data }) => {
if (data && data.code === 0) {
@@ -185,25 +228,43 @@ export default {
},
handlereset() {
this.fileListVoices = [],
this.visible = false
this.visible = false,
this.setContentValue('')
},
fontchange(content){
this.$http({
url: this.$http.adornUrl('/book/bookchaptercontent/signVoices'),
method: 'get',
params: this.$http.adornParams({
'content':content
})
}).then(res => {
fontchange(content) {
this.$http({
url: this.$http.adornUrl('/book/bookchaptercontent/signVoices'),
method: 'get',
params: this.$http.adornParams({
'content': content
})
}).then(res => {
this.$message({
message: '成功',
type: 'success'
})
this.loading = false
this.dataForm.voices = res.data.voices
var voices = { name: '音频文件', url: res.data.voices }
var attr = []
attr.push(voices)
this.fileListVoices = attr
console.log(res)
})
}
},
// 富文本内容赋值
setContentValue(data) {
let vm = this
this.ue.ready(function () {
vm.ue.setContent(data)
})
},
getContent() {
this.dialogVisible = true
this.ue.ready(() => {
this.dataForm.otherContent = this.ue.getContent()
})
},
}
}
</script>

View File

@@ -0,0 +1,156 @@
<template>
<el-dialog
:title="!dataForm.id ? '新增' : '修改'"
:close-on-click-modal="false"
:visible.sync="visible">
<el-form :model="dataForm" :rules="dataRule" ref="dataForm" @keyup.enter.native="dataFormSubmit()" label-width="80px">
<el-form-item label="用户id" prop="userId">
<el-input v-model="dataForm.userId" placeholder="用户id"></el-input>
</el-form-item>
<el-form-item label="图书id" prop="bookId">
<el-input v-model="dataForm.bookId" placeholder="图书id"></el-input>
</el-form-item>
<el-form-item label="章节id" prop="chapterId">
<el-input v-model="dataForm.chapterId" placeholder="章节id"></el-input>
</el-form-item>
<el-form-item label="章节名称" prop="chapterName">
<el-input v-model="dataForm.chapterName" placeholder="章节名称"></el-input>
</el-form-item>
<el-form-item label="章节内容id" prop="contentId">
<el-input v-model="dataForm.contentId" placeholder="章节内容id"></el-input>
</el-form-item>
<el-form-item label="创建时间" prop="createTime">
<el-input v-model="dataForm.createTime" placeholder="创建时间"></el-input>
</el-form-item>
<el-form-item label="更新时间" prop="updateTime">
<el-input v-model="dataForm.updateTime" placeholder="更新时间"></el-input>
</el-form-item>
<el-form-item label="" prop="sort">
<el-input v-model="dataForm.sort" placeholder=""></el-input>
</el-form-item>
<el-form-item label="" prop="delFlag">
<el-input v-model="dataForm.delFlag" placeholder=""></el-input>
</el-form-item>
</el-form>
<span slot="footer" class="dialog-footer">
<el-button @click="visible = false">取消</el-button>
<el-button type="primary" @click="dataFormSubmit()">确定</el-button>
</span>
</el-dialog>
</template>
<script>
export default {
data () {
return {
visible: false,
dataForm: {
id: 0,
userId: '',
bookId: '',
chapterId: '',
chapterName: '',
contentId: '',
createTime: '',
updateTime: '',
sort: '',
delFlag: ''
},
dataRule: {
userId: [
{ required: true, message: '用户id不能为空', trigger: 'blur' }
],
bookId: [
{ required: true, message: '图书id不能为空', trigger: 'blur' }
],
chapterId: [
{ required: true, message: '章节id不能为空', trigger: 'blur' }
],
chapterName: [
{ required: true, message: '章节名称不能为空', trigger: 'blur' }
],
contentId: [
{ required: true, message: '章节内容id不能为空', trigger: 'blur' }
],
createTime: [
{ required: true, message: '创建时间不能为空', trigger: 'blur' }
],
updateTime: [
{ required: true, message: '更新时间不能为空', trigger: 'blur' }
],
sort: [
{ required: true, message: '不能为空', trigger: 'blur' }
],
delFlag: [
{ required: true, message: '不能为空', trigger: 'blur' }
]
}
}
},
methods: {
init (id) {
this.dataForm.id = id || 0
this.visible = true
this.$nextTick(() => {
this.$refs['dataForm'].resetFields()
if (this.dataForm.id) {
this.$http({
url: this.$http.adornUrl(`/book/bookreadrate/info/${this.dataForm.id}`),
method: 'get',
params: this.$http.adornParams()
}).then(({data}) => {
if (data && data.code === 0) {
this.dataForm.userId = data.bookReadRate.userId
this.dataForm.bookId = data.bookReadRate.bookId
this.dataForm.chapterId = data.bookReadRate.chapterId
this.dataForm.chapterName = data.bookReadRate.chapterName
this.dataForm.contentId = data.bookReadRate.contentId
this.dataForm.createTime = data.bookReadRate.createTime
this.dataForm.updateTime = data.bookReadRate.updateTime
this.dataForm.sort = data.bookReadRate.sort
this.dataForm.delFlag = data.bookReadRate.delFlag
}
})
}
})
},
// 表单提交
dataFormSubmit () {
this.$refs['dataForm'].validate((valid) => {
if (valid) {
this.$http({
url: this.$http.adornUrl(`/book/bookreadrate/${!this.dataForm.id ? 'save' : 'update'}`),
method: 'post',
data: this.$http.adornData({
'id': this.dataForm.id || undefined,
'userId': this.dataForm.userId,
'bookId': this.dataForm.bookId,
'chapterId': this.dataForm.chapterId,
'chapterName': this.dataForm.chapterName,
'contentId': this.dataForm.contentId,
'createTime': this.dataForm.createTime,
'updateTime': this.dataForm.updateTime,
'sort': this.dataForm.sort,
'delFlag': this.dataForm.delFlag
})
}).then(({data}) => {
if (data && data.code === 0) {
this.$message({
message: '操作成功',
type: 'success',
duration: 1500,
onClose: () => {
this.visible = false
this.$emit('refreshDataList')
}
})
} else {
this.$message.error(data.msg)
}
})
}
})
}
}
}
</script>

View File

@@ -0,0 +1,211 @@
<template>
<div class="mod-config">
<el-form :inline="true" :model="dataForm" @keyup.enter.native="getDataList()">
<el-form-item>
<el-input v-model="dataForm.key" placeholder="参数名" clearable></el-input>
</el-form-item>
<el-form-item>
<el-button @click="getDataList()">查询</el-button>
<el-button v-if="isAuth('book:bookreadrate:save')" type="primary" @click="addOrUpdateHandle()">新增</el-button>
<el-button v-if="isAuth('book:bookreadrate:delete')" type="danger" @click="deleteHandle()" :disabled="dataListSelections.length <= 0">批量删除</el-button>
</el-form-item>
</el-form>
<el-table
:data="dataList"
border
v-loading="dataListLoading"
@selection-change="selectionChangeHandle"
style="width: 100%;">
<el-table-column
type="selection"
header-align="center"
align="center"
width="50">
</el-table-column>
<el-table-column
prop="id"
header-align="center"
align="center"
label="">
</el-table-column>
<el-table-column
prop="userId"
header-align="center"
align="center"
label="用户id">
</el-table-column>
<el-table-column
prop="bookId"
header-align="center"
align="center"
label="图书id">
</el-table-column>
<el-table-column
prop="chapterId"
header-align="center"
align="center"
label="章节id">
</el-table-column>
<el-table-column
prop="chapterName"
header-align="center"
align="center"
label="章节名称">
</el-table-column>
<el-table-column
prop="contentId"
header-align="center"
align="center"
label="章节内容id">
</el-table-column>
<el-table-column
prop="createTime"
header-align="center"
align="center"
label="创建时间">
</el-table-column>
<el-table-column
prop="updateTime"
header-align="center"
align="center"
label="更新时间">
</el-table-column>
<el-table-column
prop="sort"
header-align="center"
align="center"
label="">
</el-table-column>
<el-table-column
prop="delFlag"
header-align="center"
align="center"
label="">
</el-table-column>
<el-table-column
fixed="right"
header-align="center"
align="center"
width="150"
label="操作">
<template slot-scope="scope">
<el-button type="text" size="small" @click="addOrUpdateHandle(scope.row.id)">修改</el-button>
<el-button type="text" size="small" @click="deleteHandle(scope.row.id)">删除</el-button>
</template>
</el-table-column>
</el-table>
<el-pagination
@size-change="sizeChangeHandle"
@current-change="currentChangeHandle"
:current-page="pageIndex"
:page-sizes="[10, 20, 50, 100]"
:page-size="pageSize"
:total="totalPage"
layout="total, sizes, prev, pager, next, jumper">
</el-pagination>
<!-- 弹窗, 新增 / 修改 -->
<add-or-update v-if="addOrUpdateVisible" ref="addOrUpdate" @refreshDataList="getDataList"></add-or-update>
</div>
</template>
<script>
import AddOrUpdate from './bookreadrate-add-or-update'
export default {
data () {
return {
dataForm: {
key: ''
},
dataList: [],
pageIndex: 1,
pageSize: 10,
totalPage: 0,
dataListLoading: false,
dataListSelections: [],
addOrUpdateVisible: false
}
},
components: {
AddOrUpdate
},
activated () {
this.getDataList()
},
methods: {
// 获取数据列表
getDataList () {
this.dataListLoading = true
this.$http({
url: this.$http.adornUrl('/book/bookreadrate/list'),
method: 'get',
params: this.$http.adornParams({
'page': this.pageIndex,
'limit': this.pageSize,
'key': this.dataForm.key
})
}).then(({data}) => {
if (data && data.code === 0) {
this.dataList = data.page.list
this.totalPage = data.page.totalCount
} else {
this.dataList = []
this.totalPage = 0
}
this.dataListLoading = false
})
},
// 每页数
sizeChangeHandle (val) {
this.pageSize = val
this.pageIndex = 1
this.getDataList()
},
// 当前页
currentChangeHandle (val) {
this.pageIndex = val
this.getDataList()
},
// 多选
selectionChangeHandle (val) {
this.dataListSelections = val
},
// 新增 / 修改
addOrUpdateHandle (id) {
this.addOrUpdateVisible = true
this.$nextTick(() => {
this.$refs.addOrUpdate.init(id)
})
},
// 删除
deleteHandle (id) {
var ids = id ? [id] : this.dataListSelections.map(item => {
return item.id
})
this.$confirm(`确定对[id=${ids.join(',')}]进行[${id ? '删除' : '批量删除'}]操作?`, '提示', {
confirmButtonText: '确定',
cancelButtonText: '取消',
type: 'warning'
}).then(() => {
this.$http({
url: this.$http.adornUrl('/book/bookreadrate/delete'),
method: 'post',
data: this.$http.adornData(ids, false)
}).then(({data}) => {
if (data && data.code === 0) {
this.$message({
message: '操作成功',
type: 'success',
duration: 1500,
onClose: () => {
this.getDataList()
}
})
} else {
this.$message.error(data.msg)
}
})
})
}
}
}
</script>

View File

@@ -0,0 +1,138 @@
<template>
<el-dialog
:title="!dataForm.id ? '新增' : '修改'"
:close-on-click-modal="false"
:visible.sync="visible">
<el-form :model="dataForm" :rules="dataRule" ref="dataForm" @keyup.enter.native="dataFormSubmit()" label-width="80px">
<el-form-item label="" prop="bookId">
<el-input v-model="dataForm.bookId" placeholder=""></el-input>
</el-form-item>
<el-form-item label="书名" prop="bookName">
<el-input v-model="dataForm.bookName" placeholder="书名"></el-input>
</el-form-item>
<el-form-item label="" prop="userId">
<el-input v-model="dataForm.userId" placeholder=""></el-input>
</el-form-item>
<el-form-item label="" prop="createTime">
<el-input v-model="dataForm.createTime" placeholder=""></el-input>
</el-form-item>
<el-form-item label="" prop="updateTime">
<el-input v-model="dataForm.updateTime" placeholder=""></el-input>
</el-form-item>
<el-form-item label="" prop="sort">
<el-input v-model="dataForm.sort" placeholder=""></el-input>
</el-form-item>
<el-form-item label="" prop="delFlag">
<el-input v-model="dataForm.delFlag" placeholder=""></el-input>
</el-form-item>
</el-form>
<span slot="footer" class="dialog-footer">
<el-button @click="visible = false">取消</el-button>
<el-button type="primary" @click="dataFormSubmit()">确定</el-button>
</span>
</el-dialog>
</template>
<script>
export default {
data () {
return {
visible: false,
dataForm: {
id: 0,
bookId: '',
bookName: '',
userId: '',
createTime: '',
updateTime: '',
sort: '',
delFlag: ''
},
dataRule: {
bookId: [
{ required: true, message: '不能为空', trigger: 'blur' }
],
bookName: [
{ required: true, message: '书名不能为空', trigger: 'blur' }
],
userId: [
{ required: true, message: '不能为空', trigger: 'blur' }
],
createTime: [
{ required: true, message: '不能为空', trigger: 'blur' }
],
updateTime: [
{ required: true, message: '不能为空', trigger: 'blur' }
],
sort: [
{ required: true, message: '不能为空', trigger: 'blur' }
],
delFlag: [
{ required: true, message: '不能为空', trigger: 'blur' }
]
}
}
},
methods: {
init (id) {
this.dataForm.id = id || 0
this.visible = true
this.$nextTick(() => {
this.$refs['dataForm'].resetFields()
if (this.dataForm.id) {
this.$http({
url: this.$http.adornUrl(`/book/bookshelf/info/${this.dataForm.id}`),
method: 'get',
params: this.$http.adornParams()
}).then(({data}) => {
if (data && data.code === 0) {
this.dataForm.bookId = data.bookShelf.bookId
this.dataForm.bookName = data.bookShelf.bookName
this.dataForm.userId = data.bookShelf.userId
this.dataForm.createTime = data.bookShelf.createTime
this.dataForm.updateTime = data.bookShelf.updateTime
this.dataForm.sort = data.bookShelf.sort
this.dataForm.delFlag = data.bookShelf.delFlag
}
})
}
})
},
// 表单提交
dataFormSubmit () {
this.$refs['dataForm'].validate((valid) => {
if (valid) {
this.$http({
url: this.$http.adornUrl(`/book/bookshelf/${!this.dataForm.id ? 'save' : 'update'}`),
method: 'post',
data: this.$http.adornData({
'id': this.dataForm.id || undefined,
'bookId': this.dataForm.bookId,
'bookName': this.dataForm.bookName,
'userId': this.dataForm.userId,
'createTime': this.dataForm.createTime,
'updateTime': this.dataForm.updateTime,
'sort': this.dataForm.sort,
'delFlag': this.dataForm.delFlag
})
}).then(({data}) => {
if (data && data.code === 0) {
this.$message({
message: '操作成功',
type: 'success',
duration: 1500,
onClose: () => {
this.visible = false
this.$emit('refreshDataList')
}
})
} else {
this.$message.error(data.msg)
}
})
}
})
}
}
}
</script>

View File

@@ -0,0 +1,199 @@
<template>
<div class="mod-config">
<el-form :inline="true" :model="dataForm" @keyup.enter.native="getDataList()">
<el-form-item>
<el-input v-model="dataForm.key" placeholder="参数名" clearable></el-input>
</el-form-item>
<el-form-item>
<el-button @click="getDataList()">查询</el-button>
<el-button v-if="isAuth('book:bookshelf:save')" type="primary" @click="addOrUpdateHandle()">新增</el-button>
<el-button v-if="isAuth('book:bookshelf:delete')" type="danger" @click="deleteHandle()" :disabled="dataListSelections.length <= 0">批量删除</el-button>
</el-form-item>
</el-form>
<el-table
:data="dataList"
border
v-loading="dataListLoading"
@selection-change="selectionChangeHandle"
style="width: 100%;">
<el-table-column
type="selection"
header-align="center"
align="center"
width="50">
</el-table-column>
<el-table-column
prop="id"
header-align="center"
align="center"
label="">
</el-table-column>
<el-table-column
prop="bookId"
header-align="center"
align="center"
label="">
</el-table-column>
<el-table-column
prop="bookName"
header-align="center"
align="center"
label="书名">
</el-table-column>
<el-table-column
prop="userId"
header-align="center"
align="center"
label="">
</el-table-column>
<el-table-column
prop="createTime"
header-align="center"
align="center"
label="">
</el-table-column>
<el-table-column
prop="updateTime"
header-align="center"
align="center"
label="">
</el-table-column>
<el-table-column
prop="sort"
header-align="center"
align="center"
label="">
</el-table-column>
<el-table-column
prop="delFlag"
header-align="center"
align="center"
label="">
</el-table-column>
<el-table-column
fixed="right"
header-align="center"
align="center"
width="150"
label="操作">
<template slot-scope="scope">
<el-button type="text" size="small" @click="addOrUpdateHandle(scope.row.id)">修改</el-button>
<el-button type="text" size="small" @click="deleteHandle(scope.row.id)">删除</el-button>
</template>
</el-table-column>
</el-table>
<el-pagination
@size-change="sizeChangeHandle"
@current-change="currentChangeHandle"
:current-page="pageIndex"
:page-sizes="[10, 20, 50, 100]"
:page-size="pageSize"
:total="totalPage"
layout="total, sizes, prev, pager, next, jumper">
</el-pagination>
<!-- 弹窗, 新增 / 修改 -->
<add-or-update v-if="addOrUpdateVisible" ref="addOrUpdate" @refreshDataList="getDataList"></add-or-update>
</div>
</template>
<script>
import AddOrUpdate from './bookshelf-add-or-update'
export default {
data () {
return {
dataForm: {
key: ''
},
dataList: [],
pageIndex: 1,
pageSize: 10,
totalPage: 0,
dataListLoading: false,
dataListSelections: [],
addOrUpdateVisible: false
}
},
components: {
AddOrUpdate
},
activated () {
this.getDataList()
},
methods: {
// 获取数据列表
getDataList () {
this.dataListLoading = true
this.$http({
url: this.$http.adornUrl('/book/bookshelf/list'),
method: 'get',
params: this.$http.adornParams({
'page': this.pageIndex,
'limit': this.pageSize,
'key': this.dataForm.key
})
}).then(({data}) => {
if (data && data.code === 0) {
this.dataList = data.page.list
this.totalPage = data.page.totalCount
} else {
this.dataList = []
this.totalPage = 0
}
this.dataListLoading = false
})
},
// 每页数
sizeChangeHandle (val) {
this.pageSize = val
this.pageIndex = 1
this.getDataList()
},
// 当前页
currentChangeHandle (val) {
this.pageIndex = val
this.getDataList()
},
// 多选
selectionChangeHandle (val) {
this.dataListSelections = val
},
// 新增 / 修改
addOrUpdateHandle (id) {
this.addOrUpdateVisible = true
this.$nextTick(() => {
this.$refs.addOrUpdate.init(id)
})
},
// 删除
deleteHandle (id) {
var ids = id ? [id] : this.dataListSelections.map(item => {
return item.id
})
this.$confirm(`确定对[id=${ids.join(',')}]进行[${id ? '删除' : '批量删除'}]操作?`, '提示', {
confirmButtonText: '确定',
cancelButtonText: '取消',
type: 'warning'
}).then(() => {
this.$http({
url: this.$http.adornUrl('/book/bookshelf/delete'),
method: 'post',
data: this.$http.adornData(ids, false)
}).then(({data}) => {
if (data && data.code === 0) {
this.$message({
message: '操作成功',
type: 'success',
duration: 1500,
onClose: () => {
this.getDataList()
}
})
} else {
this.$message.error(data.msg)
}
})
})
}
}
}
</script>