{{template "header" .}} <title>博客 - 码农随笔</title> </head> <body style="background-color: #f9f9f9"> <div class="root-container"> {{template "nav" .}} {{template "memenu" .}} <div class="me-blog-root"> <div class="me-blog-list"> <div class="breadcrumb-container"> <span class="layui-breadcrumb"> <a href="/">首页</a> <a href="">个人中心</a> <a href="/me/blog">我的博客</a> <a><cite>博客列表</cite></a> </span> </div> <el-table :data="tableData" border style="width: 100%" stripe> <el-table-column prop="Title" label="文章" ></el-table-column> <el-table-column prop="Ctime" label="时间" width="120" ></el-table-column> <el-table-column prop="Browses" label="浏览量" width="100" ></el-table-column> <el-table-column fixed="right" label="操作" width="135"> <template slot-scope="scope"> <el-button @click="editClick(scope.row)" type="text" size="small">编辑</el-button> <el-button @click="viewClick(scope.row)" type="text" size="small">查看</el-button> <el-button @click="deleteClick(scope.row)" type="text" size="small">删除</el-button> </template> </el-table-column> </el-table> <div style="margin-top: 10px;text-align: center"> <el-pagination background layout="prev, pager, next" :current-page="pageNum" :total="totals" @current-change="pageChange"> </el-pagination> </div> </div> </div> </div> </body> <script> var app = new Vue({ el: ".root-container", delimiters: ['${', '}'], data: { pageNum: 1, totals: 0, tableData: [] }, created() { this.totals = {{.Page.TotalCount}} const initData = {{.Page.List}} this.tableData= initData.map(x=> {x.Ctime = x.Ctime.substring(0,x.Ctime.indexOf('T'));return x}) }, methods: { editClick(row){ window.open('/blog/edit/'+row.Id) }, viewClick(row){ window.open('/blog/'+row.Id) }, deleteClick(row){ const _this = this this.$confirm('此操作将永久删除,删除后将无法恢复, 是否继续?', '提示', { confirmButtonText: '确定', cancelButtonText: '取消', type: 'warning' }).then(() => { $.post('/api/blog/del/' + row.Id, function (data) { if (data.Status == 0) { _this.getData() _this.$message.success("删除成功") } else if (data.Status == 401) { window.location.href = "/login" } else if (data.Status == 403) { this.$message.error("暂无权限") } else { this.$message.error("服务器异常") } }, 'json') }).catch(() => { }) }, pageChange(page){ this.pageNum = page this.getData() }, getData(){ const _this = this $.get('/api/blog/list',{num: this.pageNum}, function (data) { if (data.Status == 0) { debugger _this.tableData= data.Data.List.map(x=> {x.Ctime = x.Ctime.substring(0,x.Ctime.indexOf('T'));return x}) } else if (data.Status == 401) { window.location.href = "/login" } else { this.$message.error("服务器异常") } }, 'json') } } }) </script> </html>