detail.vue 3.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173
  1. <template>
  2. <lrLayout>
  3. <maside
  4. @clktitle="$router.push({ path: '/dynamic/list/info/none' })"
  5. slot="lcon"
  6. class="lcon"
  7. :title="title"
  8. @search="handleSearch"
  9. >
  10. <ul slot="content" class="content">
  11. <li
  12. v-for="(item, i) in list"
  13. :class="{ active: id == item.id }"
  14. class="liparimary"
  15. @click="$router.push({ params: { id: item.id } })"
  16. :key="i"
  17. >
  18. <span :title="item.name">{{ item.name }}</span>
  19. </li>
  20. </ul>
  21. </maside>
  22. <div slot="rcon" class="d-body">
  23. <Article :title="currentDetail.name">
  24. <div class="info" :slot="'info'">
  25. <span class="primaryColor"
  26. >{{ currentDetail.createTime }}&emsp;&emsp;浏览次数:{{
  27. currentDetail.visit
  28. }}</span
  29. >
  30. </div>
  31. <div
  32. :slot="'content'"
  33. class="content"
  34. v-html="currentDetail.content"
  35. ></div>
  36. </Article>
  37. </div>
  38. </lrLayout>
  39. </template>
  40. <script>
  41. import Article from "@/components/Article";
  42. import { getList, getDetailById } from "@/config/api";
  43. import { title } from "./data";
  44. import lrLayout from "@/components/lrLayout";
  45. export default {
  46. components: {
  47. Article,
  48. lrLayout,
  49. },
  50. data() {
  51. return {
  52. list: [],
  53. currentDetail: {},
  54. title,
  55. searchKey: "",
  56. };
  57. },
  58. computed: {
  59. goodsModuleId(){
  60. return this.$route.params.goodsModuleId;
  61. },
  62. activeId() {
  63. return this.$route.params.type;
  64. },
  65. id() {
  66. return this.$route.params.id;
  67. },
  68. },
  69. mounted() {
  70. this.getData();
  71. console.log('-------',this.$route.params);
  72. },
  73. watch: {
  74. id(newVal) {
  75. this.getDetail(newVal);
  76. },
  77. },
  78. methods: {
  79. handleSearch(data) {
  80. this.searchKey = data;
  81. this.getData();
  82. },
  83. getDetail(id) {
  84. getDetailById(
  85. "news",
  86. {
  87. id: id || this.id,
  88. },
  89. (res) => {
  90. this.currentDetail = res.data;
  91. console.log(res);
  92. }
  93. );
  94. },
  95. async getData() {
  96. let params = {
  97. pageNum: 1,
  98. pageSize: 1000,
  99. searchKey: this.searchKey,
  100. type: this.activeId,
  101. goodsModuleId:this.goodsModuleId
  102. };
  103. getList("news", params, (res) => {
  104. res.data.list.forEach((item) => {
  105. item.time = this.formatTime(item.createTime);
  106. });
  107. this.list = res.data.list;
  108. this.getDetail(this.id);
  109. });
  110. },
  111. },
  112. };
  113. </script>
  114. <style lang="less" scoped>
  115. .lcon {
  116. .content {
  117. background: #fff;
  118. width: 100%;
  119. padding: 0 0;
  120. max-height: 50vh;
  121. overflow-y: auto;
  122. > li {
  123. min-height: 50px;
  124. line-height: 1.5;
  125. width: 100%;
  126. padding: 0 20px;
  127. cursor: pointer;
  128. text-align: left;
  129. display: flex;
  130. align-items: center;
  131. > span {
  132. overflow: hidden;
  133. text-overflow:ellipsis;
  134. white-space: nowrap;
  135. width: 100%;
  136. display: inline-block;
  137. }
  138. &.active,
  139. &:hover {
  140. background: #ebebeb;
  141. > span {
  142. &::before {
  143. display: none !important;
  144. }
  145. }
  146. }
  147. }
  148. }
  149. }
  150. .d-body {
  151. flex: 4;
  152. margin-left: 80px;
  153. text-align: center;
  154. font-size: 32px;
  155. .info {
  156. color: #9e9e9e;
  157. margin: 20px 0;
  158. > span {
  159. display: flex;
  160. align-items: center;
  161. margin-right: 30px;
  162. }
  163. }
  164. .content {
  165. text-indent: 32px;
  166. color: #333333;
  167. }
  168. }
  169. </style>