notice.vue 3.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122
  1. <template>
  2. <div id="notice">
  3. <el-row>
  4. <el-col :span="24" class="notice">
  5. <el-col :span="24" class="search">
  6. <van-search v-model="value" placeholder="请输入信息标题" @search="onSearch" />
  7. </el-col>
  8. <el-col :span="24" class="mess">
  9. <el-col :span="24" v-for="(item, index) in list" :key="index" class="list">
  10. <p class="title textOver">{{ item.title }}</p>
  11. <p>
  12. <span class="textOver">发布时间:{{ item.publish_time }}</span>
  13. <span class="textOver">来源:{{ item.orgin || '暂无' }}</span>
  14. </p>
  15. </el-col>
  16. </el-col>
  17. </el-col>
  18. <el-backtop :bottom="50" :right="10"> </el-backtop>
  19. </el-row>
  20. </div>
  21. </template>
  22. <script>
  23. const { mapActions: journcolumn } = createNamespacedHelpers('journcolumn');
  24. const { mapActions: journnews } = createNamespacedHelpers('journnews');
  25. import { mapState, createNamespacedHelpers } from 'vuex';
  26. export default {
  27. metaInfo() {
  28. return { title: this.$route.meta.title };
  29. },
  30. name: 'notice',
  31. props: {},
  32. components: {},
  33. data: function() {
  34. return {
  35. columnList: [],
  36. colId: '',
  37. list: [],
  38. value: '',
  39. };
  40. },
  41. async created() {
  42. await this.search();
  43. await this.searchList();
  44. },
  45. methods: {
  46. ...journcolumn(['query', 'delete', 'update', 'create']),
  47. ...journnews({ newQuery: 'query' }),
  48. //查栏目
  49. async search() {
  50. const res = await this.query();
  51. if (this.$checkRes(res)) {
  52. this.$set(this, `columnList`, res.data);
  53. const colData = this.columnList.find(i => i.site == 'tztg');
  54. this.colId = colData.id;
  55. }
  56. },
  57. //查列表
  58. async searchList() {
  59. const res = await this.newQuery({ column_id: this.colId });
  60. if (this.$checkRes(res)) {
  61. this.$set(this, `list`, res.data);
  62. }
  63. },
  64. //搜索
  65. async onSearch({ ...info } = {}) {
  66. if (this.value) {
  67. info.title = this.value;
  68. info.column_id = this.colId;
  69. const res = await this.newQuery({ ...info });
  70. if (this.$checkRes(res)) {
  71. this.$set(this, `list`, res.data);
  72. }
  73. } else {
  74. this.searchList();
  75. }
  76. },
  77. },
  78. computed: {
  79. ...mapState(['user']),
  80. },
  81. watch: {},
  82. };
  83. </script>
  84. <style lang="less" scoped>
  85. .notice {
  86. position: relative;
  87. .search {
  88. position: fixed;
  89. width: 100%;
  90. z-index: 999;
  91. border-bottom: 1px solid #ccc;
  92. background-color: #fff;
  93. .van-search {
  94. padding: 10px 12px 10px 12px;
  95. }
  96. }
  97. .mess {
  98. padding: 0px 10px;
  99. margin-top: 55px;
  100. .list {
  101. padding: 10px 0px;
  102. border-bottom: 1px dashed #ccc;
  103. .title {
  104. font-size: 18px;
  105. font-weight: bold;
  106. }
  107. p:nth-child(2) {
  108. margin-top: 5px;
  109. span {
  110. display: inline-block;
  111. width: 50%;
  112. height: 42px;
  113. line-height: 42px;
  114. color: #666;
  115. }
  116. }
  117. }
  118. }
  119. }
  120. </style>