index.vue 2.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081
  1. <template>
  2. <div id="index">
  3. <el-row>
  4. <el-col :span="24" class="top">
  5. <topInfo :topTitle="topTitle" :display="display" @add="add"></topInfo>
  6. </el-col>
  7. <el-col :span="24" class="main">
  8. <el-col :span="24" class="list">
  9. <newsList :tableData="tableData" :total="total" @deleteRow="deleteRow" @select="select" @publish="publish"></newsList>
  10. </el-col>
  11. </el-col>
  12. </el-row>
  13. </div>
  14. </template>
  15. <script>
  16. import topInfo from '@/layout/custom/topInfo.vue';
  17. import newsList from '@/layout/news/newsList.vue';
  18. import { mapState, createNamespacedHelpers, mapGetters } from 'vuex';
  19. const { mapActions: tNewsCenter } = createNamespacedHelpers('tNewsCenter');
  20. export default {
  21. name: 'index',
  22. props: {},
  23. components: {
  24. topInfo, //头部导航
  25. newsList, //列表
  26. },
  27. data: () => ({
  28. topTitle: '新闻中心管理',
  29. display: 'block',
  30. tableData: [],
  31. total: 0,
  32. }),
  33. created() {
  34. this.select();
  35. },
  36. computed: {},
  37. methods: {
  38. ...tNewsCenter(['create', 'delete', 'update', 'fetch', 'query']),
  39. async select({ skip = 0, limit = 10, ...info } = {}) {
  40. const res = await this.query({ skip, limit, ...info });
  41. if (this.$checkRes(res)) {
  42. this.$set(this, `tableData`, res.data);
  43. this.$set(this, `total`, res.total);
  44. }
  45. },
  46. add() {
  47. this.$router.push({ path: '/news/detail' });
  48. },
  49. async deleteRow({ id, skip = 0, limit = 10, ...info } = {}) {
  50. const res = await this.delete(id);
  51. this.$checkRes(res, '删除成功', '删除失败');
  52. this.select({ skip, limit, ...info });
  53. },
  54. async publish({ row ,skip = 0, limit = 10, ...info } = {}){
  55. let res = await this.update({id:row.id,publish_state:1,publish_state_description:'已发布',publish_time:new Date().getTime()});
  56. this.$checkRes(res, '发布成功', '发布失败');
  57. this.select({ skip, limit, ...info });
  58. },
  59. },
  60. };
  61. </script>
  62. <style lang="less" scoped>
  63. .top {
  64. height: 50px;
  65. margin: 0 0 10px 0;
  66. }
  67. .main {
  68. min-height: 765px;
  69. background: #ffffff;
  70. }
  71. .search {
  72. width: 97%;
  73. height: 35px;
  74. margin: 20px;
  75. }
  76. .list {
  77. padding: 0 20px;
  78. }
  79. </style>