details.vue 2.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105
  1. <template>
  2. <div class="details">
  3. <breadcrumb ref="breadcrumb"></breadcrumb>
  4. <div ref="detailsHome" class="detailsHome" v-if="contentsItem">
  5. <img class="thumbnail" v-if="isshow" :src="contentsItem.thumbnail">
  6. <h3 class="title">{{ contentsItem.title }}</h3>
  7. <h4 class="title" v-if="contentsItem && contentsItem.curtTitle">{{ contentsItem.curtTitle }}</h4>
  8. <!-- <span class="describe">{{ contentsItem.describe }}</span> -->
  9. <span class="date">发表时间: {{ contentsItem.date | dates }}<span class="visit">访问量: {{ contentsItem.visit }}</span></span>
  10. <div class="content" v-html="contentsItem.content"></div>
  11. <div v-if="contentsItem && contentsItem.annex">
  12. <a v-for="(item, index) in contentsItem.annex" :key="index" :href="item.url" :download="item.url" target="view_window">下载附件:{{ item.name }}<br/></a>
  13. </div>
  14. </div>
  15. <el-divider class="divider" v-else>暂无数据</el-divider>
  16. </div>
  17. </template>
  18. <script>
  19. import moment from 'moment';
  20. import breadcrumb from '../components/breadcrumb/index.vue';
  21. import { mapState, mapActions } from 'vuex';
  22. export default {
  23. name: 'detailsHome',
  24. components: {
  25. breadcrumb
  26. },
  27. computed: {
  28. ...mapState(['contentsItem']),
  29. isshow() {
  30. if (this.contentsItem.bind.includes('012')) return true;
  31. return false;
  32. }
  33. },
  34. data() {
  35. return {
  36. id: ''
  37. };
  38. },
  39. async mounted() {
  40. this.id = this.$route.params.id;
  41. const type = this.$route.query.type;
  42. if (type) {
  43. await this.imgNewsFetch({ id: this.id });
  44. return;
  45. }
  46. await this.contentsFetch({ id: this.id });
  47. this.$refs.detailsHome.scrollIntoView(true);
  48. },
  49. methods: {
  50. ...mapActions(['contentsFetch', 'imgNewsFetch'])
  51. },
  52. filters: {
  53. dates(e) {
  54. return moment(e).format('YYYY-MM-DD');
  55. }
  56. }
  57. };
  58. </script>
  59. <style lang="scss" scoped>
  60. .details {
  61. width: 60%;
  62. margin: 0 auto;
  63. }
  64. .detailsHome {
  65. width: 100%;
  66. background-color: #f5f9ff;
  67. padding: 0 5%;
  68. padding-top: 3%;
  69. margin-top: 2%;
  70. .thumbnail {
  71. width: 20%;
  72. display: block;
  73. margin: 5% auto;
  74. }
  75. .title, .describe, .content, .date {
  76. width: 100%;
  77. text-align: center;
  78. }
  79. .describe, .date {
  80. display: block;
  81. color: #999;
  82. line-height: 2em;
  83. .visit {
  84. margin-left: 30px;
  85. }
  86. }
  87. .date {
  88. border-bottom: 1px solid #004ef5;
  89. margin-bottom: 5%;
  90. padding-bottom: 10px;
  91. }
  92. .content {
  93. text-align: left;
  94. white-space: pre-wrap;
  95. word-wrap: break-word;
  96. ::v-deep iframe {
  97. width: 70%;
  98. height: 500px;
  99. display: block;
  100. margin: 0 auto;
  101. }
  102. }
  103. }
  104. </style>