analysis.vue 6.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295
  1. <template>
  2. <el-scrollbar ref="scrollbar" class="analysis" @scroll="scroll">
  3. <div class="head">
  4. <div class="title">账号分析</div>
  5. <div class="searchRow">
  6. <div class="searchCol searchTitle">分类:</div>
  7. <div
  8. :class="{
  9. searchCol: true,
  10. searchActive: searchActive.classification === optionindex,
  11. }"
  12. v-for="(optionitem, optionindex) in classification"
  13. :key="optionindex + 'option'"
  14. v-text="optionitem.name"
  15. @click="() => clickSelect('classification', optionindex)"
  16. ></div>
  17. </div>
  18. <div class="searchRow">
  19. <div class="searchCol searchTitle">时间:</div>
  20. <div
  21. :class="{
  22. searchCol: true,
  23. searchActive: searchActive.time === optionindex,
  24. }"
  25. v-for="(optionitem, optionindex) in time"
  26. :key="optionindex + 'option'"
  27. v-text="optionitem.name"
  28. @click="() => clickSelect('time', optionindex)"
  29. ></div>
  30. <div
  31. :class="{
  32. searchCol: true,
  33. searchActive: searchActive.time === -1,
  34. }"
  35. @click="() => clickSelect('time', -1)"
  36. >
  37. 自定义
  38. </div>
  39. <div class="searchCol">
  40. <el-date-picker
  41. v-model="date"
  42. :disabled="searchActive.time !== -1"
  43. @change="change"
  44. :disabled-date="disDate"
  45. type="daterange"
  46. :clearable="false"
  47. value-format="YYYY-MM-DD"
  48. range-separator="-"
  49. start-placeholder="开始时间"
  50. end-placeholder="结束时间"
  51. />
  52. </div>
  53. </div>
  54. <div class="searchRow">
  55. <div class="searchCol searchTitle">搜索:</div>
  56. <div class="searchCol">
  57. <el-input v-model="searchText" placeholder="搜索文章">
  58. <template #suffix>
  59. <el-icon @click="search"><Search /></el-icon>
  60. </template>
  61. </el-input>
  62. </div>
  63. </div>
  64. </div>
  65. <div class="body">
  66. <analysisList ref="analysisListEle" />
  67. </div>
  68. <analysisHotList @changeSearch="hotList" province="" />
  69. <el-icon :size="45" class="upload" v-show="showUpload" @click="upload"
  70. ><Upload
  71. /></el-icon>
  72. </el-scrollbar>
  73. </template>
  74. <script setup>
  75. import dayjs from 'dayjs';
  76. import { ref, onMounted } from 'vue';
  77. import { getClass } from '../../api/index';
  78. import analysisList from './components/analysis_list.vue';
  79. import analysisHotList from './components/analysis_hot_list.vue';
  80. const nowTime = Date.now();
  81. const scrollbar = ref();
  82. const analysisListEle = ref();
  83. const showUpload = ref(false);
  84. const searchActive = ref({
  85. classification: 0,
  86. time: 0,
  87. area: 0,
  88. areaSon: 0,
  89. });
  90. const defaultOption = {
  91. type: 'option',
  92. name: '全部',
  93. id: 0,
  94. };
  95. const classification = ref([defaultOption]);
  96. const time = [
  97. {
  98. type: 'option',
  99. time: nowTime - 86400000,
  100. name: '24小时',
  101. id: 1,
  102. },
  103. {
  104. type: 'option',
  105. time: nowTime - 172800000,
  106. name: '48小时',
  107. id: 2,
  108. },
  109. {
  110. type: 'option',
  111. time: nowTime - 604800000,
  112. name: '近7天',
  113. id: 3,
  114. },
  115. {
  116. type: 'option',
  117. time: nowTime - 2592000000,
  118. name: '近30天',
  119. id: 4,
  120. },
  121. ];
  122. const searchText = ref('');
  123. const date = ref([]);
  124. const pageSize = 10;
  125. let page = 1;
  126. onMounted(() => {
  127. getList();
  128. });
  129. getClass({}).then(res => {
  130. const li = res || [];
  131. const l = [];
  132. for (let i = 0; i < li.length; i++) {
  133. const v = li[i];
  134. l.push({
  135. type: 'option',
  136. name: v,
  137. });
  138. }
  139. classification.value.push(...l);
  140. });
  141. const getList = () => {
  142. const search = {
  143. category:
  144. classification.value[searchActive.value.classification].name || undefined,
  145. keywords: searchText.value,
  146. page: page++,
  147. pageSize,
  148. };
  149. search.category === '全部' ? (search.category = '') : '';
  150. search.city === '全部' ? (search.city = '') : '';
  151. // 时间区间
  152. if (searchActive.value['time'] === -1) {
  153. search.start = date.value[0];
  154. search.end = date.value[1];
  155. } else {
  156. search.start = dayjs(time[searchActive.value['time']].time).format(
  157. 'YYYY-MM-DD HH:mm:ss'
  158. );
  159. search.end = dayjs(nowTime).format('YYYY-MM-DD HH:mm:ss');
  160. }
  161. analysisListEle.value.getlist(search);
  162. };
  163. const clickSelect = (select, index) => {
  164. searchActive.value[select] = index;
  165. if (index === -1) return;
  166. page = 1;
  167. getList();
  168. };
  169. const change = () => {
  170. date.value = [date.value[0] + ' 00:00:00', date.value[1] + ' 23:59:59'];
  171. page = 1;
  172. getList();
  173. };
  174. const search = () => {
  175. page = 1;
  176. getList();
  177. };
  178. const hotList = searchTextHot => {
  179. if (!searchTextHot) return;
  180. page = 1;
  181. searchText.value = searchTextHot;
  182. getList();
  183. };
  184. const scroll = e => {
  185. const height =
  186. document.querySelector('.analysis .head').offsetHeight +
  187. document.querySelector('.analysis .body').offsetHeight -
  188. document.querySelector('.analysis').offsetHeight;
  189. const scrollNum = e.scrollTop.toFixed(2) - 0;
  190. if (!showUpload.value && scrollNum > 180) showUpload.value = true;
  191. else if (scrollNum <= 180) showUpload.value = false;
  192. if (height - scrollNum > 0) return;
  193. getList();
  194. };
  195. const upload = () => {
  196. scrollbar.value.setScrollTop(0);
  197. };
  198. const nowT = Date.now();
  199. const disDate = date => {
  200. return date.getTime() > nowT;
  201. }
  202. </script>
  203. <style scoped>
  204. .analysis {
  205. height: 100%;
  206. /* min-width: 1305px; */
  207. position: relative;
  208. }
  209. .analysis .head,
  210. .analysis .body {
  211. margin: 0 1em;
  212. width: calc(100% - 400px);
  213. min-width: 855px;
  214. }
  215. .analysis .body {
  216. border: 1px solid #f3f3f3;
  217. margin: 1em;
  218. }
  219. .title {
  220. font-size: 16px;
  221. font-weight: 600;
  222. height: 49px;
  223. line-height: 49px;
  224. padding-left: 8px;
  225. border-bottom: 1px solid #f5f5f5;
  226. }
  227. .searchRow {
  228. margin: 0.5em 0;
  229. }
  230. .searchCol {
  231. display: inline-block;
  232. margin: 0 0.5em;
  233. padding: 0 0.5em;
  234. height: 35px;
  235. line-height: 35px;
  236. cursor: pointer;
  237. }
  238. .searchCol:hover {
  239. color: rgb(64, 158, 255);
  240. }
  241. .searchActive {
  242. font-weight: 600;
  243. color: rgb(64, 158, 255);
  244. border-radius: 5px;
  245. background-color: rgba(64, 158, 255, 0.1);
  246. border-bottom: none;
  247. }
  248. .searchRow .searchTitle {
  249. color: #b9c0d3;
  250. }
  251. .body .el-checkbox {
  252. margin-right: 15px;
  253. }
  254. .source {
  255. color: #22ac38;
  256. }
  257. .upload {
  258. position: absolute;
  259. right: 25px;
  260. bottom: 25px;
  261. background-color: #e9e9e990;
  262. border-radius: 50%;
  263. padding: 5px;
  264. cursor: pointer;
  265. }
  266. </style>