[TOC]前端
頁面效果vue
Vue前端java
@Table(name = "t_order") @Data @NoArgsConstructor @AllArgsConstructor public class Order { private String oid; @Column(name="create_time") @JsonFormat(pattern = "yyyy-MM-dd",timezone = "GMT+8") private Date createTime; //建立時間 @Column(name="total_price") private Double totalPrice; //總價 private Integer status; //訂單狀態 private Integer uid; //用戶表外鍵 }
<template> <div> <!-- 展現數據 --> <el-table :data="pageInfo.list" border style="width: 100%"> <el-table-column prop="createTime" label="建立時間" width="180"></el-table-column> <el-table-column prop="totalPrice" label="總價" width="180"></el-table-column> <el-table-column prop="status" label="狀態" width="180"> <template slot-scope="scope"> <el-tag v-if="scope.row.status == 0">未付款</el-tag> <el-tag v-if="scope.row.status == 1" type="success">已付款</el-tag> <el-tag v-if="scope.row.status == 2" type="info">已發貨</el-tag> <el-tag v-if="scope.row.status == 3" type="warning">已收貨</el-tag> <el-tag v-if="scope.row.status == 4" type="danger">結束</el-tag> </template> </el-table-column> <el-table-column label="操做"> <template> <el-button size="mini">Edit</el-button> <el-button size="mini" type="danger">Delete</el-button> </template> </el-table-column> </el-table> <!-- 分頁條 --> <el-pagination background @size-change="handleSizeChange" @current-change="handleCurrentChange" :current-page="params.pageNum" :page-sizes="[2,4,6]" :page-size="params.pageSize" layout="total, sizes, prev, pager, next, jumper" :total="pageInfo.total" ></el-pagination> </div> </template> <script> import { myOrder } from "../api"; export default { data() { return { uid: 1, //當前用戶(模擬用戶登陸數據) pageInfo: {}, //分頁數據 params: { pageNum: 1, pageSize: 2 } }; }, created() { //頁面加載發送ajax進行查詢 this.findAll(); }, methods: { async findAll() { let { data: baseResult } = await myOrder(this.uid, this.params); this.pageInfo = baseResult.data; }, handleSizeChange(val) { this.params.pageNum = 1; this.params.pageSize = val; this.findAll(); console.log(`每頁 ${val} 條`); }, handleCurrentChange(val) { this.params.pageNum = val; this.findAll(); console.log(`當前頁: ${val}`); } } }; </script> <style> </style>