Переглянути джерело

1.完成文章管理页面、隐藏书源管理页面

master
xiexiang 3 роки тому
джерело
коміт
fcf7d75825
7 змінених файлів з 244 додано та 87 видалено
  1. +44
    -0
      src/api/books-management.js
  2. +1
    -0
      src/icons/svg/disabled.svg
  3. +1
    -0
      src/icons/svg/keyboard.svg
  4. +1
    -0
      src/router/modules/books-management.js
  5. +19
    -7
      src/views/books-management/ShuYuan-page/index.vue
  6. +54
    -16
      src/views/books-management/article-page/components/edit-dialog.vue
  7. +124
    -64
      src/views/books-management/article-page/index.vue

+ 44
- 0
src/api/books-management.js Переглянути файл

@@ -0,0 +1,44 @@
import request from '@/utils/request'

/**
* 书籍管理
*/


export function booksCategory(params) {
return request({
url: '/category/index', // 书源分类
method: 'get',
params: params
})
}
export function booksSource(params) {
return request({
url: '/platform/index', // 书源
method: 'get',
params: params
})
}

export function getBooksList(params) {
return request({
url: '/book/index', // 书籍列表
method: 'get',
params: params
})
}

export function updateBooks(id) {
return request({
url: `/book/update/${id}`, // 编辑书籍
method: 'put'
})
}

export function deleteBooks(id) {
return request({
url: `/book/delete/${id}`, // 删除书籍
method: 'delete'
})
}


+ 1
- 0
src/icons/svg/disabled.svg Переглянути файл

@@ -0,0 +1 @@
<svg width="19" height="18" xmlns="http://www.w3.org/2000/svg"><path d="M13.908 1.155a8.999 8.999 0 1 0-8.815 15.692 8.999 8.999 0 0 0 8.815-15.692zm-7.99 14.219a7.313 7.313 0 0 1-2.792-9.956 7.313 7.313 0 0 1 9.956-2.792 7.313 7.313 0 0 1 2.792 9.956 7.313 7.313 0 0 1-9.956 2.792zM4.9 15.176l1.717.965L14.1 2.824l-1.717-.966L4.9 15.176z" fill="" fill-rule="nonzero"/></svg>

+ 1
- 0
src/icons/svg/keyboard.svg Переглянути файл

@@ -0,0 +1 @@
<svg width="15" height="14" xmlns="http://www.w3.org/2000/svg"><path d="M7.5 0a7 7 0 1 1 0 14 7 7 0 0 1 0-14zm0 1.273a5.727 5.727 0 1 0 0 11.454 5.727 5.727 0 0 0 0-11.454zm2.61 8.145v1.273H4.89V9.418h5.22zM4.763 6.555v1.272H3.49V6.555h1.273zm4.454 0v1.272H7.945V6.555h1.273zm-2.227 0v1.272H5.718V6.555h1.273zm4.454 0v1.272h-1.272V6.555h1.272zM4.764 4.009v1.273H3.49V4.009h1.273zm4.454 0v1.273H7.945V4.009h1.273zm-2.227 0v1.273H5.718V4.009h1.273zm4.454 0v1.273h-1.272V4.009h1.272z" fill="" fill-rule="nonzero"/></svg>

+ 1
- 0
src/router/modules/books-management.js Переглянути файл

@@ -19,6 +19,7 @@ const booksManagement = {
meta: { title: '文章管理' }
},
{
hidden: true,
path: 'ShuYuan',
component: () => import('@/views/books-management/ShuYuan-page/index'),
name: 'memberManagement',


+ 19
- 7
src/views/books-management/ShuYuan-page/index.vue Переглянути файл

@@ -64,6 +64,7 @@
size="mini"
@click="openGatherDialog(null)"
>
<svg-icon icon-class="keyboard" />
一键采集书籍
</el-button>
<el-button
@@ -74,6 +75,9 @@
>
定时采集书籍
</el-button>
<span class="btn-text">
上次采集时间: 2021-08-09 13:52:42
</span>
</div>
<el-button
type="primary"
@@ -89,7 +93,6 @@
border
fit
tooltip-effect="dark"
>
<el-table-column
type="index"
@@ -129,8 +132,9 @@
/>
<CustomButton
tip-text="禁用"
is-svg
type="danger"
icon="el-icon-circle-close"
icon="disabled"
@onClick="openDeleteDialog(scope.row)"
/>
</template>
@@ -226,7 +230,7 @@ export default {
// }
// })
},
// 更新操作
refreshData() {
this._baseRequest(true)
@@ -254,15 +258,13 @@ export default {
},
// 删除操作弹窗
openDeleteDialog(scope) {
this.$confirm('是否确认删除改书籍?删除后该书源信息将永久删除, 且不可复原, 请谨慎操作!', '删除提示', {
this.$confirm('是否确认禁用该书籍?禁用后该书源信息将停止使用, 请谨慎操作!', '禁用提示', {
confirmButtonText: '确定',
cancelButtonText: '取消',
type: 'warning'
}).then(() => {
this.selectItem = scope.row
}).catch(() => {
this.$message.info('已取消删除')
})
}).catch(() => {})
},
// 每页数据
handleSizeChange(val) {
@@ -301,6 +303,16 @@ export default {
.drop-down{
margin: 0 10px;
}
.btn-text{
color: #A97402;
font-size: 14px;
padding: 6px 10px 6px 3px;
margin-left: 8px;
background: rgba(255, 193, 61, 0.2);
border-radius: 2px;
border: 1px solid rgba(255, 193, 61, 0.5);
box-sizing: border-box;
}
}
.pagination-container{
display: flex;


+ 54
- 16
src/views/books-management/article-page/components/edit-dialog.vue Переглянути файл

@@ -14,53 +14,54 @@
>
<el-form-item label="电子书ID">
<el-input
v-model="formData.name"
v-model="formData.book_id"
placeholder="电子书ID"
:disabled="true"
/>
</el-form-item>
<el-form-item label="书名">
<el-input
v-model="formData.name"
v-model="formData.book_name"
placeholder="请输入"
/>
</el-form-item>
<el-form-item label="书源">
<el-input
v-model="formData.name"
v-model="formData.source_name"
placeholder="书源"
:disabled="true"
/>
</el-form-item>
<el-form-item label="分类">
<el-select
v-model="formData.name"
v-model="formData.book_type"
placeholder="请输入"
style="width: 100%"
>
<el-option
label="区域一"
value="shanghai"
/>
<el-option
label="区域二"
value="beijing"
v-for="(item, index) in categoryList"
:key="index"
:label="item.category_name"
:value="item.id"
/>
</el-select>
</el-form-item>
<el-form-item label="简介">
<el-input
v-model="formData.name"
v-model="formData.book_intro"
type="textarea"
:rows="5"
:resize="false"
placeholder="认识一下, 这是一个简介"
resize="false"
placeholder="简介"
/>
</el-form-item>
</el-form>
</el-main>
<el-footer>
<el-button type="primary">
<el-button
type="primary"
@click="_postRequest()"
>
确认
</el-button>
<el-button @click="handleClose">
@@ -73,13 +74,17 @@

<script>
import Dialog from '@/components/Dialog/index'
import { updateBooks, booksCategory } from '@/api/books-management'
export default {
components: { Dialog },
props: {
isDialog: {
type: Boolean,
default: false
},
selectItem: {
type: Object,
default: () => {}
}
},
data() {
@@ -93,11 +98,44 @@ export default {
// 弹窗标题
dialogTitle: '编辑书籍',
formData: {
name: '132456'
id: '',
book_id: '',
book_name: '',
book_intro: '',
book_type: '',
source_name: '',
source_platform: ''
},
categoryList: []
}
},
watch: {
isDialog(val) {
if (val) {
this.formData = this.selectItem
// 书源分类请求
booksCategory({ source_platform: this.formData.source_platform }).then(resp => {
if (parseInt(resp.error_code) === 0) {
this.categoryList = resp.data
} else {
this.$message.error(resp.message)
}
})
}
}
},
methods: {
_postRequest() {
updateBooks(Number(this.formData.id)).then(resp => {
if (parseInt(resp.error_code) === 0) {
this.$message.success('操作成功!')
this.$emit('handle-success')
this.handleClose()
} else {
this.$message.error(resp.message)
}
})
},
handleClose() {
this.$emit('handle-close')
}


+ 124
- 64
src/views/books-management/article-page/index.vue Переглянути файл

@@ -21,20 +21,27 @@
</el-form-item>
<el-form-item
label="分类"
prop="name"
prop="category_id"
>
<el-input
v-model="formData.name"
<el-select
v-model="formData.category_id"
placeholder="请输入"
size="mini"
/>
>
<el-option
v-for="(item, index) in categoryList"
:key="index"
:label="item.category_name"
:value="item.id"
/>
</el-select>
</el-form-item>
<el-form-item
label="简介"
prop="name"
prop="desc"
>
<el-input
v-model="formData.name"
v-model="formData.desc"
placeholder="请输入"
size="mini"
/>
@@ -67,25 +74,29 @@
size="mini"
@click="refreshData()"
/>
<el-dropdown class="drop-down">
<el-dropdown
trigger="click"
class="drop-down"
@command="handleCommand"
>
<el-button
type="warning"
size="mini"
>
书源<i class="el-icon-arrow-down el-icon--right" />
<i class="el-icon-tickets" />
书源
<i class="el-icon-arrow-down el-icon--right" />
</el-button>
<el-dropdown-menu slot="dropdown">
<el-dropdown-item>黄金糕</el-dropdown-item>
<el-dropdown-item
v-for="(item, index) in Object.entries(booksSource)"
:key="index"
:command="item[1].value"
>
{{ item[1].name }}
</el-dropdown-item>
</el-dropdown-menu>
</el-dropdown>
<el-button
type="danger"
icon="el-icon-delete"
size="mini"
@click="openDeleteDialog()"
>
删除
</el-button>
</div>
<el-button
type="primary"
@@ -97,6 +108,8 @@
<!-- 数据 -->
<div class="table-container">
<el-table
v-loading="loading"
class="tableData"
:data="tableData"
border
fit
@@ -104,25 +117,28 @@
@selection-change="handleSelectionChange"
>
<el-table-column
type="selection"
type="index"
label="序号"
align="center"
width="55"
/>
<el-table-column
label="电子书ID"
align="center"
prop="name"
min-width="100"
prop="book_id"
width="100"
/>
<el-table-column
label="书名"
align="center"
prop="name"
prop="book_name"
width="150"
/>
<el-table-column
label="书源"
align="center"
prop="filterKeyNum"
prop="source_name"
width="150"
>
<template slot-scope="">
<!-- <span style="color: #1890FF;cursor:pointer;" @click="openNumDialog(scope.row)">{{ scope.row.filterKeyNum }}</span>-->
@@ -131,20 +147,19 @@
<el-table-column
label="分类"
align="center"
prop="usePvdStr"
>
<template slot-scope="">
<!-- <span :style="{ color: scope.row.usePvdArr.length === 0 ? '#999999' : '#1890FF' }" style="cursor:pointer;" @click="openPlatformDialog(scope.row)">{{ scope.row.usePvdStr }}</span>-->
</template>
</el-table-column>
prop="category_name"
width="150"
/>
<el-table-column
label="简介"
align="center"
prop="memo"
prop="book_intro"
min-width="400"
/>
<el-table-column
label="操作"
align="center"
width="100"
>
<template slot-scope="scope">
<CustomButton
@@ -167,11 +182,11 @@
<!-- 底部分页组件 -->
<div class="pagination-container">
<el-pagination
:current-page="formData.currentPage"
:current-page="formData.current_page"
:page-sizes="[10, 20, 30, 40]"
:page-size="formData.limit"
:page-size="formData.per_page"
layout="total, prev, pager, next, sizes,jumper"
:total="formData.total"
:total="total"
@size-change="handleSizeChange"
@current-change="handleCurrentChange"
/>
@@ -180,7 +195,9 @@
<!-- 文章编辑页面-->
<ArticleEditDialog
:is-dialog="isEditDialog"
:select-item="selectItem"
@handle-close="isEditDialog = false"
@handle-success="_baseRequest"
/>
</el-container>
</template>
@@ -191,6 +208,7 @@
* */
import CustomButton from '@/components/CustomButton/index'
import ArticleEditDialog from './components/edit-dialog'
import {getBooksList, deleteBooks, booksSource, booksCategory} from '@/api/books-management'
// 编辑弹窗组件
export default {
components: { CustomButton, ArticleEditDialog },
@@ -205,44 +223,76 @@ export default {
// 多选列表数据
multipleSelection: [],
// 表格数据
tableData: [
{
name: '11'
}
],
tableData: [],
// 表单参数
formData: {
name: '',
category_id: '',
desc: '',
source_platform: 1,
// 默认显示页
currentPage: 1,
page: 1,
// 每页页数
limit: 10,
// 总页数
total: 10
}
page_size: 10
},
loading: false,
// 书源
booksSource: {},
// 书源分类
categoryList: [],
// 总页数
total: 10
}
},
created() {
this._baseRequest()
},
methods: {
// 下拉回调
handleCommand(val) {
this.formData.source_platform = val.toString()
this._baseRequest()
},
// 基础请求
_baseRequest(refres = false) {
// const params = {
// name: this.formData.name,
// p: this.formData.currentPage,
// limit: this.formData.limit
// }
// filterWordList(params).then(resp => {
// if (parseInt(resp.code) === 0) {
if (refres) {
this.$message.success('刷新成功~')
}
// // console.log(JSON.stringify(resp.data))
// this.tableData = resp.data.list
// this.formData.total = resp.data.total
// }
// })
this.loading = true
const params = this.formData
// 书源分类接口
booksSource().then(resp1 => {
if (parseInt(resp1.error_code) === 0) {
this.booksSource = resp1.data
} else {
this.$message.error(resp1.message)
}
})
// 书源分类请求
booksCategory({ source_platform: this.formData.source_platform }).then(resp => {
if (parseInt(resp.error_code) === 0) {
this.categoryList = resp.data
} else {
this.$message.error(resp.message)
}
})
getBooksList(params).then(resp => {
if (parseInt(resp.error_code) === 0) {
if (refres) {
this.$message.success('刷新成功~')
}
this.tableData = resp.data.data.map(item => {
Object.entries(this.booksSource).forEach(val => {
if (val[1].value === item.source_platform) {
item.source_name = val[1].name
console.log(item.source_name)
}
})
return item
})
this.total = resp.data.total
this.loading = false
} else {
this.$message.error(resp.message)
}
})
},
handleSelectionChange(val) {
this.multipleSelection = val
@@ -257,36 +307,43 @@ export default {
},
// 重置操作
resetForm(val) {
this.formData.source_platform = 1
this.$refs[val].resetFields()
this._baseRequest()
},
// 打开编辑弹窗操作
openEditDialog(row) {
this.isEditDialog = true
this.selectItem = row
console.log(row)
},
// 删除操作弹窗
openDeleteDialog(scope) {
openDeleteDialog(row) {
this.$confirm('是否确认删除改书籍?删除后该书源信息将永久删除, 且不可复原, 请谨慎操作!', '删除提示', {
confirmButtonText: '确定',
cancelButtonText: '取消',
type: 'warning'
}).then(() => {
this.selectItem = scope.row
}).catch(() => {
this.$message.info('已取消删除')
})
deleteBooks(Number(row.id)).then(resp => {
if (parseInt(resp.error_code) === 0) {
this.$message.success('操作成功!')
this._baseRequest()
} else {
this.$message.error(resp.message)
}
})
}).catch(() => {})
},
// 每页数据
handleSizeChange(val) {
console.log(`每页 ${val} 条`)
this.formData.limit = val
this.formData.page_size = val
this._baseRequest()
},
// 当前页
handleCurrentChange(val) {
console.log(`当前页: ${val}`)
this.formData.currentPage = val
this.formData.page= val
this._baseRequest()
}
}
@@ -298,6 +355,9 @@ export default {
width: 100%;
height: 100%;
.el-main{
.tableData{

}
.div-main{
display: flex;
flex-flow: row wrap;


Завантаження…
Відмінити
Зберегти