图书展示对应页面:

图书借阅(前端)_前端


1.src/views/Book/contain/index.vue

HTML 内容模板()元素是一种用于保存客户端内容机制,该内容在加载页面时不会呈现,但随后可以 (原文为 may be) 在运行时使用 JavaScript 实例化。

模板中定义了工具栏、搜索、表单组件、表格渲染、分类组件等元素

图书借阅(前端)_javascript_02

data返回值包括权限(新增,编辑,删除)、输入规则和获取表格数据的方法

图书借阅(前端)_搜索_03


完整代码:

<template>
<div class="app-container">
<!--工具栏-->
<div class="head-container">
<div>
<!-- 搜索 -->
<el-input v-model="query.blurry" clearable size="small" placeholder="模糊搜索" style="width: 200px;" class="filter-item" @keyup.enter.native="crud.toQuery" />
<rrOperation />
</div>
<!--如果想在工具栏加入更多按钮,可以使用插槽方式, slot = 'left' or 'right'-->

<!--表单组件-->
<el-dialog :close-on-click-modal="false" :before-close="crud.cancelCU" :visible.sync="crud.status.cu > 0" :title="crud.status.title" width="500px">
<el-form ref="form" :model="form" :rules="rules" size="small" label-width="80px">
<el-form-item label="编号" prop="number">
<el-input v-model="form.number" style="width: 370px;" />
</el-form-item>
<el-form-item label="书名">
<el-input v-model="form.name" style="width: 370px;" />
</el-form-item>
<el-form-item label="isbn">
<el-input v-model="form.isbn" style="width: 370px;" />
</el-form-item>
<el-form-item label="作者">
<el-input v-model="form.author" style="width: 370px;" />
</el-form-item>
<el-form-item label="译者">
<el-input v-model="form.translator" style="width: 370px;" />
</el-form-item>
<el-form-item label="出版商">
<el-input v-model="form.publisher" style="width: 370px;" />
</el-form-item>
<el-form-item label="版本">
<el-input v-model="form.edition" style="width: 370px;" />
</el-form-item>
<el-form-item label="购买日期">
<el-input v-model="form.buyDate" style="width: 370px;" />
</el-form-item>
<el-form-item label="购买原因">
<el-input v-model="form.whyBuy" style="width: 370px;" />
</el-form-item>
<el-form-item label="购买地点">
<el-input v-model="form.whereBy" style="width: 370px;" />
</el-form-item>
<el-form-item label="类别">
<el-input v-model="form.category" style="width: 370px;" />
</el-form-item>
<el-form-item label="存放地点">
<el-input v-model="form.place" style="width: 370px;" />
</el-form-item>
<el-form-item label="借阅人">
<el-input v-model="form.borrower" style="width: 370px;" />
</el-form-item>
<el-form-item label="借还时间">
<el-date-picker
v-model="form.borrowTime"
type="datetime"
placeholder="选择日期时间"
default-time="12:00:00"
style="width: 370px;"
/>
</el-form-item>
<el-form-item label="借阅状态">
<el-radio-group v-model="form.status" style="width: 370px;">
<el-radio label="借出">借出</el-radio>
<el-radio label="在库">在库</el-radio>
</el-radio-group>
</el-form-item>
</el-form>
<div slot="footer" class="dialog-footer">
<el-button type="text" @click="crud.cancelCU">取消</el-button>
<el-button :loading="crud.status.cu === 2" type="primary" @click="crud.submitCU">确认</el-button>
</div>
</el-dialog>
<!--表格渲染-->
<el-table ref="table" v-loading="crud.loading" :data="crud.data" size="small" style="width: 100%;" stripe @selection-change="crud.selectionChangeHandler">
<el-table-column type="selection" width="55" />
<el-table-column sortable prop="number" label="编号" width="85" />
<el-table-column sortable prop="name" label="书名" width="185" />
<el-table-column sortable prop="isbn" label="isbn" />
<el-table-column sortable prop="author" label="作者" />
<el-table-column sortable prop="translator" label="译者" />
<el-table-column sortable prop="publisher" label="出版商" />
<el-table-column sortable prop="edition" label="版本" />
<el-table-column sortable prop="buyDate" label="购买日期" />
<el-table-column sortable prop="whyBuy" label="购买原因" />
<el-table-column sortable prop="whereBy" label="购买地点" />
<el-table-column sortable prop="category" label="分类" />
<el-table-column sortable prop="place" label="存放位置" />
<el-table-column sortable prop="borrower" label="借阅人" />
<el-table-column sortable prop="borrowTime" label="借还时间" />
<el-table-column sortable prop="status" label="借阅状态" />
</el-table>
<!--分页组件-->
<pagination />
</div>
</div>
</template>

<script>
import crudBookInformation from '@/api/system/bookInformation'
import CRUD, { presenter, header, form, crud } from '@crud/crud'
import rrOperation from '@crud/RR.operation'
import pagination from '@crud/Pagination'
// import DateRangePicker from '@/components/DateRangePicker'

const defaultForm = { id: null, number: null, name: null, isbn: null, author: null, translator: null, publisher: null, edition: null, buyDate: null, whyBuy: null, whereBy: null, category: null, place: null, borrower: null, borrowTime: null, status: null, createBy: null, createTime: null, updateBy: null, updateTime: null }
export default {
name: 'BookInformation',
components: { pagination, rrOperation },
mixins: [presenter(), header(), form(defaultForm), crud()],
cruds() {
return CRUD({ title: 'bookinformation', url: 'api/bookInformation', idField: 'id', sort: 'id', crudMethod: { ...crudBookInformation }})
},
data() {
return {
permission: {
add: ['admin', 'bookInformation:add'],
edit: ['admin', 'bookInformation:edit'],
del: ['admin', 'bookInformation:del']
},
rules: {
number: [
{ required: true, message: '不能为空', trigger: 'blur' }
]
}}
},
methods: {
// 钩子:在获取表格数据之前执行,false 则代表不获取数据
[CRUD.HOOK.beforeRefresh]() {
return true
}
}
}
</script>

<style scoped>

</style>

2.src/api/system/bookInformation.js

定义了添加、删除和编辑功能

图书借阅(前端)_javascript_04

借阅审批:

图书借阅(前端)_前端_05


1.src/views/Book/approve/index.vue模板中定义了工具栏、搜索、表单组件、表格渲染、分类组件等元素

图书借阅(前端)_搜索_06


规定数据不能为空以及获取规则

图书借阅(前端)_javascript_07


完整代码:

<template>
<div class="app-container">
<!--工具栏-->
<div class="head-container">
<div v-if="crud.props.searchToggle">
<!-- 搜索 -->
<el-input v-model="query.blurry" clearable size="small" placeholder="模糊搜索" style="width: 200px;" class="filter-item" @keyup.enter.native="crud.toQuery" />
<!-- <date-range-picker v-model="query.createTime" class="date-item" />-->
<rrOperation />
</div>
<!--如果想在工具栏加入更多按钮,可以使用插槽方式, slot = 'left' or 'right'-->
<crudOperation />
<!--表单组件-->
<el-dialog :close-on-click-modal="false" :before-close="crud.cancelCU" :visible.sync="crud.status.cu > 0" :title="crud.status.title" width="500px">
<el-form ref="form" :model="form" :rules="rules" size="small" label-width="80px">
<el-form-item label="编号" prop="number">
<el-input v-model="form.number" style="width: 370px;" />
</el-form-item>
<el-form-item label="书名">
<el-input v-model="form.name" style="width: 370px;" />
</el-form-item>
<el-form-item label="isbn">
<el-input v-model="form.isbn" style="width: 370px;" />
</el-form-item>
<el-form-item label="作者">
<el-input v-model="form.author" style="width: 370px;" />
</el-form-item>
<el-form-item label="译者">
<el-input v-model="form.translator" style="width: 370px;" />
</el-form-item>
<el-form-item label="出版商">
<el-input v-model="form.publisher" style="width: 370px;" />
</el-form-item>
<el-form-item label="版本">
<el-input v-model="form.edition" style="width: 370px;" />
</el-form-item>
<el-form-item label="购买日期">
<el-input v-model="form.buyDate" style="width: 370px;" />
</el-form-item>
<el-form-item label="购买原因">
<el-input v-model="form.whyBuy" style="width: 370px;" />
</el-form-item>
<el-form-item label="购买地点">
<el-input v-model="form.whereBy" style="width: 370px;" />
</el-form-item>
<el-form-item label="类别">
<el-input v-model="form.category" style="width: 370px;" />
</el-form-item>
<el-form-item label="存放地点">
<el-input v-model="form.place" style="width: 370px;" />
</el-form-item>
<el-form-item label="借阅人">
<el-input v-model="form.borrower" style="width: 370px;" />
</el-form-item>
<el-form-item label="借还时间">
<el-date-picker
v-model="form.borrowTime"
type="datetime"
placeholder="选择日期时间"
default-time="12:00:00"
style="width: 370px;"
/>
</el-form-item>
<el-form-item label="借阅状态">
<el-radio-group v-model="form.status" style="width: 370px;">
<el-radio label="借出">借出</el-radio>
<el-radio label="在库">在库</el-radio>
</el-radio-group>
</el-form-item>
</el-form>
<div slot="footer" class="dialog-footer">
<el-button type="text" @click="crud.cancelCU">取消</el-button>
<el-button :loading="crud.status.cu === 2" type="primary" @click="crud.submitCU">确认</el-button>
</div>
</el-dialog>
<!--表格渲染-->
<el-table ref="table" v-loading="crud.loading" :data="crud.data" size="small" style="width: 100%;" stripe @selection-change="crud.selectionChangeHandler">
<el-table-column type="selection" width="55" />
<el-table-column sortable prop="number" label="编号" width="85" />
<el-table-column sortable prop="name" label="书名" width="185" />
<el-table-column sortable prop="isbn" label="isbn" />
<el-table-column sortable prop="author" label="作者" />
<el-table-column sortable prop="translator" label="译者" />
<el-table-column sortable prop="publisher" label="出版商" />
<el-table-column sortable prop="edition" label="版本" />
<el-table-column sortable prop="buyDate" label="购买日期" />
<el-table-column sortable prop="whyBuy" label="购买原因" />
<el-table-column sortable prop="whereBy" label="购买地点" />
<el-table-column sortable prop="category" label="分类" />
<el-table-column sortable prop="place" label="存放位置" />
<el-table-column sortable prop="borrower" label="借阅人" />
<el-table-column sortable prop="borrowTime" label="借还时间" />
<el-table-column sortable prop="status" label="借阅状态" />
<el-table-column label="操作" width="150px" align="center">
<template slot-scope="scope">
<udOperation
:data="scope.row"
/>
</template>
</el-table-column>
</el-table>
<!--分页组件-->
<pagination />
</div>
</div>
</template>

<script>
import crudBookInformation from '@/api/system/bookInformation'
import CRUD, { presenter, header, form, crud } from '@crud/crud'
import rrOperation from '@crud/RR.operation'
import crudOperation from '@crud/CRUD.operation'
import udOperation from '@crud/UD.operation'
import pagination from '@crud/Pagination'
// import DateRangePicker from '@/components/DateRangePicker'

const defaultForm = { id: null, number: null, name: null, isbn: null, author: null, translator: null, publisher: null, edition: null, buyDate: null, whyBuy: null, whereBy: null, category: null, place: null, borrower: null, borrowTime: null, status: null, createBy: null, createTime: null, updateBy: null, updateTime: null }
export default {
name: 'BookInformation',
components: { pagination, crudOperation, rrOperation, udOperation },
mixins: [presenter(), header(), form(defaultForm), crud()],
cruds() {
return CRUD({ title: 'bookinformation', url: 'api/bookInformation', idField: 'id', sort: 'id', crudMethod: { ...crudBookInformation }})
},
data() {
return {
rules: {
number: [
{ required: true, message: '不能为空', trigger: 'blur' }
]
}}
},
methods: {
// 钩子:在获取表格数据之前执行,false 则代表不获取数据
[CRUD.HOOK.beforeRefresh]() {
return true
}
}
}
</script>

<style scoped>

</style>