index.vue 3.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151
  1. <template>
  2. <div class="list">
  3. <img src="../../../assets/ztjytop.jpg" class="topimg">
  4. <div class="title" @click="titleClick">习近平:在学习贯彻习近平新时代中国特色社会主义思想主题教育工作会议上的讲话</div>
  5. <div class="listBox" v-for="item in menu" :key="item.code">
  6. <div class="ListHedir">
  7. <div class="listtitle">{{ item.name }}</div>
  8. <div class="listMore" @click="more(item.code)">更多</div>
  9. </div>
  10. <ul class="listBody">
  11. <li class="listItem" v-for="i in list[item.code]" :key="i._id" @click="detailsClick(i)">
  12. <div class="listname">{{ i.title }}</div>
  13. <div class="listtime">{{ i.createAt | dates }}</div>
  14. </li>
  15. </ul>
  16. </div>
  17. </div>
  18. </template>
  19. <script>
  20. import moment from 'moment';
  21. import { mapState, mapActions } from 'vuex';
  22. export default {
  23. name: 'listHome',
  24. components: {},
  25. computed: {
  26. ...mapState(['contentList', 'listTotal', 'menusall'])
  27. },
  28. data() {
  29. return {
  30. pageSize: 10,
  31. menu: {},
  32. code: '',
  33. list: {}
  34. };
  35. },
  36. async mounted() {
  37. // 所有菜单
  38. await this.menusQueryAll();
  39. // 当前菜单
  40. this.code = this.$route.params.code;
  41. // 获取一例菜单
  42. this.menu = this.menusall.filter(e => e.parentCode == this.$route.params.code);
  43. this.menu.map(async e => {
  44. const data = await this.filterQuery(e.code);
  45. this.$set(this.list, e.code, data);
  46. });
  47. },
  48. methods: {
  49. ...mapActions(['contentsList', 'menusQueryAll']),
  50. // 查询函数
  51. async filterQuery (bind) {
  52. const res = await this.contentsList({ filter: { bind }, paging: { page: 0, size: 10 } });
  53. return res?.data;
  54. },
  55. // 标题点击
  56. titleClick() {
  57. // 649b8056a88d955bb62af9a1 / 649cd0ae43f8327dc3544357
  58. const routeUrl = this.$router.resolve('/templates/ztjy/details/649b8056a88d955bb62af9a1');
  59. window.open(routeUrl.href, '_blank');
  60. },
  61. // 列表点击
  62. detailsClick(e) {
  63. const routeUrl = this.$router.resolve(`/templates/ztjy/details/${e._id}?code=${this.code}`);
  64. window.open(routeUrl.href, '_blank');
  65. },
  66. // 点击更过
  67. more(code) {
  68. const routeUrl = this.$router.resolve(`/templates/ztjy/list/${code}`);
  69. window.open(routeUrl.href, '_blank');
  70. }
  71. },
  72. filters: {
  73. dates(e) {
  74. return moment(e).format('YYYY-MM-DD');
  75. }
  76. }
  77. };
  78. </script>
  79. <style lang="scss" scoped>
  80. .topimg {
  81. width: 100%;
  82. }
  83. .title {
  84. width: 75%;
  85. margin: 0 auto;
  86. height: auto;
  87. overflow: hidden;
  88. padding: 2% 0;
  89. color: #ba0612;
  90. font-size: 3em;
  91. font-weight: bold;
  92. text-align: center;
  93. cursor: pointer;
  94. }
  95. .listBox {
  96. width: 75%;
  97. height: auto;
  98. overflow: hidden;
  99. margin: 5vh auto;
  100. border: #e4e4e4 1px solid;
  101. }
  102. .ListHedir {
  103. display: flex;
  104. width: 100%;
  105. height: auto;
  106. overflow: hidden;
  107. padding: 1% 2%;
  108. background-color: #ededed;
  109. font-size: 1.125em;
  110. color: #bb0f0f;
  111. font-weight: bold;
  112. }
  113. .listtitle {
  114. width: 90%;
  115. text-align: left;
  116. }
  117. .listMore {
  118. width: 10%;
  119. text-align: right;
  120. font-weight: normal;
  121. color: #7d7d7d;
  122. font-size: 0.8888em;
  123. cursor: pointer;
  124. }
  125. .listBody {
  126. overflow: hidden;
  127. padding: 0;
  128. width: 90%;
  129. margin: 0 auto;
  130. padding-bottom: 5vh;
  131. }
  132. .listItem {
  133. line-height: 3em;
  134. width: 100%;
  135. background: url('../../../assets/an.png') left center no-repeat;
  136. padding-left: 3%;
  137. border-bottom: #CCC 1px dashed;
  138. margin-right: 3%;
  139. cursor: pointer;
  140. }
  141. .listname {
  142. width: 90%;
  143. text-align: left;
  144. float: left;
  145. }
  146. .listtime {
  147. width: 10%;
  148. text-align: right;
  149. float: right;
  150. }
  151. </style>