| <!DOCTYPE html>
 <html>
 <head>
 
 <meta charset="utf-8">
 <title>SpringMVC案例</title>
 
 <link rel="stylesheet" href="../plugins/elementui/index.css">
 <link rel="stylesheet" href="../plugins/font-awesome/css/font-awesome.min.css">
 <link rel="stylesheet" href="../css/style.css">
 </head>
 
 <body class="hold-transition">
 
 <div id="app">
 
 <div class="content-header">
 <h1>图书管理</h1>
 </div>
 
 <div class="app-container">
 <div class="box">
 <div class="filter-container">
 <el-input placeholder="图书名称" style="width: 200px;" class="filter-item"></el-input>
 <el-button class="dalfBut">查询</el-button>
 <el-button type="primary" class="butT" @click="openSave()">新建</el-button>
 </div>
 
 <el-table size="small" current-row-key="id" :data="dataList" stripe highlight-current-row>
 <el-table-column type="index" align="center" label="序号"></el-table-column>
 <el-table-column prop="type" label="图书类别" align="center"></el-table-column>
 <el-table-column prop="name" label="图书名称" align="center"></el-table-column>
 <el-table-column prop="description" label="描述" align="center"></el-table-column>
 <el-table-column label="操作" align="center">
 <template slot-scope="scope">
 <el-button type="primary" size="mini">编辑</el-button>
 <el-button size="mini" type="danger">删除</el-button>
 </template>
 </el-table-column>
 </el-table>
 
 <div class="pagination-container">
 <el-pagination
 class="pagiantion"
 @current-change="handleCurrentChange"
 :current-page="pagination.currentPage"
 :page-size="pagination.pageSize"
 layout="total, prev, pager, next, jumper"
 :total="pagination.total">
 </el-pagination>
 </div>
 
 
 <div class="add-form">
 <el-dialog title="新增图书" :visible.sync="dialogFormVisible">
 <el-form ref="dataAddForm" :model="formData" :rules="rules" label-position="right" label-width="100px">
 <el-row>
 <el-col :span="12">
 <el-form-item label="图书类别" prop="type">
 <el-input v-model="formData.type"/>
 </el-form-item>
 </el-col>
 <el-col :span="12">
 <el-form-item label="图书名称" prop="name">
 <el-input v-model="formData.name"/>
 </el-form-item>
 </el-col>
 </el-row>
 <el-row>
 <el-col :span="24">
 <el-form-item label="描述">
 <el-input v-model="formData.description" type="textarea"></el-input>
 </el-form-item>
 </el-col>
 </el-row>
 </el-form>
 <div slot="footer" class="dialog-footer">
 <el-button @click="dialogFormVisible = false">取消</el-button>
 <el-button type="primary" @click="saveBook()">确定</el-button>
 </div>
 </el-dialog>
 </div>
 
 </div>
 </div>
 </div>
 </body>
 
 
 <script src="../js/vue.js"></script>
 <script src="../plugins/elementui/index.js"></script>
 <script type="text/javascript" src="../js/jquery.min.js"></script>
 <script src="../js/axios-0.18.0.js"></script>
 
 <script>
 var vue = new Vue({
 
 el: '#app',
 
 data:{
 dataList: [],
 formData: {},
 dialogFormVisible: false,
 dialogFormVisible4Edit:false,
 pagination: {},
 },
 
 
 created() {
 this.getAll();
 },
 
 methods: {
 
 resetForm() {
 
 this.formData = {};
 },
 
 
 openSave() {
 this.dialogFormVisible = true;
 this.resetForm();
 },
 
 
 saveBook () {
 axios.post("/books",this.formData).then((res)=>{
 
 });
 },
 
 
 getAll() {
 axios.get("/books").then((res)=>{
 this.dataList = res.data;
 });
 },
 
 }
 })
 </script>
 </html>
 
 |