analysis_list.vue 3.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169
  1. <template>
  2. <div class="mainTitle">
  3. <div class="mainTitleTool" v-if="selectlist.length">
  4. <el-select
  5. v-model="selectValue"
  6. class="m-2"
  7. placeholder="Select"
  8. @change="changeSelect"
  9. >
  10. <el-option
  11. v-for="item in selectlist"
  12. :key="item.value"
  13. :label="item.label"
  14. :value="item.value"
  15. />
  16. </el-select>
  17. </div>
  18. 文章列表
  19. </div>
  20. <br />
  21. <div class="lists">
  22. <div
  23. class="list"
  24. v-for="item in listTable"
  25. :key="item.title"
  26. @click="() => toDetail(item)"
  27. >
  28. <div class="listHead" v-text="item ? item.title || '' : ''"></div>
  29. <div class="listSubtitle" v-html="item ? item.summary || '' : ''"></div>
  30. <el-row>
  31. <el-col :span="12" style="color: #9aa8c4">
  32. <el-icon><Clock /></el-icon>
  33. <span v-text="item.publishTime"></span>
  34. </el-col>
  35. <el-col :span="12" style="text-align: right">
  36. 来源:
  37. <span class="source" v-text="item.sourceWebsite"></span>
  38. </el-col>
  39. </el-row>
  40. </div>
  41. </div>
  42. </template>
  43. <script setup>
  44. import { ref, defineExpose, defineProps } from 'vue';
  45. import { useRouter } from 'vue-router';
  46. import { searchData, getreporting } from '../../../api/index';
  47. import { split } from 'lodash';
  48. let T = undefined;
  49. let total = -1;
  50. const selectValue = ref(0);
  51. const router = useRouter();
  52. const listTable = ref([]);
  53. const props = defineProps({
  54. apiKey: String,
  55. });
  56. const selectlist = [
  57. // {
  58. // label: '按发布时间降序',
  59. // value: 0,
  60. // },
  61. // {
  62. // label: '按发布时间升序',
  63. // value: 1,
  64. // },
  65. // {
  66. // label: '按发情感值升序',
  67. // value: 2,
  68. // },
  69. // {
  70. // label: '按发情感值降序',
  71. // value: 3,
  72. // },
  73. ];
  74. const api = {
  75. getreporting,
  76. searchData,
  77. };
  78. const changeSelect = () => {
  79. // 更改排序
  80. console.log(selectValue.value);
  81. };
  82. const toDetail = item => {
  83. // router.push({
  84. // path: '/analysis_detail',
  85. // query: {
  86. // detail: JSON.stringify(item),
  87. // },
  88. // });
  89. const url = location.href.split("#")[0] +'#/analysis_detail';
  90. localStorage.setItem('analysis_detail', JSON.stringify({
  91. publishTime: item.publishTime,
  92. sourceWebsite: item.sourceWebsite,
  93. title: item.title,
  94. content: item.content
  95. }));
  96. window.open(url, '_blank');
  97. };
  98. const getlist = search => {
  99. if (search.page === 1) {
  100. listTable.value = [];
  101. total = -1;
  102. } else if ((search.page - 1) * search.pageSize >= total) return;
  103. if (T) T = window.clearTimeout(T);
  104. T = window.setTimeout(() => {
  105. api[props.apiKey || 'searchData']({
  106. data: search,
  107. })
  108. .then(res => {
  109. const li = res.records || [];
  110. listTable.value.push(...li);
  111. total = res.total || 0;
  112. if (T) T = window.clearTimeout(T);
  113. })
  114. .catch(() => {
  115. if (T) T = window.clearTimeout(T);
  116. });
  117. }, 200);
  118. };
  119. defineExpose({
  120. getlist,
  121. });
  122. </script>
  123. <style scoped>
  124. .mainTitle {
  125. padding: 0 20px;
  126. position: relative;
  127. line-height: 60px;
  128. border-bottom: 1px solid #f5f5f5;
  129. }
  130. .mainTitleTool {
  131. position: absolute;
  132. right: 20px;
  133. line-height: 60px;
  134. top: 0;
  135. text-align: right;
  136. }
  137. .listHead,
  138. .listSubtitle {
  139. overflow: hidden;
  140. text-overflow: ellipsis;
  141. }
  142. .lists {
  143. padding: 0.5em;
  144. }
  145. .list {
  146. border-radius: 5px;
  147. padding: 0.5em;
  148. cursor: pointer;
  149. line-height: 1.8em;
  150. font-size: 14px;
  151. }
  152. .list:hover {
  153. background-color: rgba(64, 158, 255, 0.1);
  154. }
  155. .list:not(:last-child) {
  156. border-bottom: 1px dashed #b9c0d3;
  157. }
  158. .listSubtitle {
  159. color: #b9c0d3;
  160. }
  161. </style>