Article.vue 3.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115
  1. <style lang="scss">
  2. .apply {
  3. .filter {
  4. background: #fff;
  5. padding: 20px 20px 10px;
  6. border: 1px solid #ededed;
  7. border-radius: 2px;
  8. margin-bottom: 10px;
  9. margin-top: 10px;
  10. .el-form-item {
  11. margin-bottom: 10px;
  12. }
  13. .el-input,
  14. .el-select {
  15. width: 150px;
  16. }
  17. }
  18. thead {
  19. th {
  20. background: #eee;
  21. }
  22. }
  23. }
  24. </style>
  25. <template>
  26. <section class="apply">
  27. <p>内容管理 > 文章管理</p>
  28. <div class="filter">
  29. <el-form label-width="80px" :inline="true" size="small">
  30. <el-form-item label="文章标题">
  31. <el-input placeholder="请输入文章标题" clearable v-model="form.title"></el-input>
  32. </el-form-item>
  33. <el-form-item>
  34. <el-button @click="getData" type="primary" icon="el-icon-search">搜索</el-button>
  35. <el-button @click="$router.push({path:'/addArticle'})" type="primary">新增文章</el-button>
  36. </el-form-item>
  37. </el-form>
  38. </div>
  39. <el-table class="table" :data="list" border style="width: 100%" v-loading='loading'>
  40. <!-- <el-table-column type="selection" fixed="left" width="55"></el-table-column> -->
  41. <el-table-column prop="title" label="文章标题"></el-table-column>
  42. <el-table-column prop="ctime" label="创建时间"></el-table-column>
  43. <el-table-column prop="zip" width="400" label="操作">
  44. <template slot-scope="scope">
  45. <!-- <el-button size="mini" type="success">查看</el-button> -->
  46. <el-button
  47. @click="$router.push({path:'/addArticle',query:{id:scope.row.id}})"
  48. size="mini"
  49. type="warning"
  50. >编辑</el-button>
  51. <el-button @click="del(scope.row.id)" size="mini" type="danger">删除</el-button>
  52. </template>
  53. </el-table-column>
  54. </el-table>
  55. <Page ref="pageButton" :total="total" @pageChange="gopage" />
  56. </section>
  57. </template>
  58. <script>
  59. import Page from "../../components/Page";
  60. export default {
  61. name: "articles",
  62. components: {
  63. Page
  64. },
  65. data() {
  66. return {
  67. form: { title: "" ,page:1,page_size:20},
  68. total: 1,
  69. list: [],
  70. loading:false,
  71. };
  72. },
  73. methods: {
  74. gopage(size){
  75. if(size){
  76. this.form.page_size=size
  77. }
  78. this.form.page=this.$refs.pageButton.page
  79. this.getData()
  80. },
  81. getData() {
  82. this.loading=true
  83. let parm=this.form
  84. this.$api.getArticleList(parm).then(res => {
  85. this.loading=false
  86. if (res.status == 200) {
  87. this.list = res.data.data.list;
  88. this.total = res.data.data.total;
  89. } else {
  90. this.$message({
  91. message: res.message,
  92. type: "error"
  93. });
  94. }
  95. });
  96. },
  97. del(id){
  98. this.$confirm('确定删除吗', '提示', {
  99. type: 'warning'
  100. }).then(() => {
  101. this.$api.delArticle({id:id}).then((res)=>{
  102. this.$message({
  103. message: '删除成功',
  104. type: 'success'
  105. })
  106. this.getData()
  107. })
  108. })
  109. },
  110. },
  111. created() {
  112. this.getData();
  113. }
  114. };
  115. </script>