index.vue 12 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406
  1. <template>
  2. <div class="container">
  3. <div class="flex">
  4. <div class="card2">
  5. <div class="card-header">
  6. <i class="icon-line" />
  7. <div class="card-title">知识类型统计</div>
  8. </div>
  9. <div class="card-content">
  10. <Chart :option="chartOption1" rotation style="flex: 1" />
  11. </div>
  12. </div>
  13. <div class="card2">
  14. <div class="card-header">
  15. <i class="icon-line" />
  16. <div class="card-title">来源单位统计</div>
  17. </div>
  18. <div class="card-content">
  19. <div class="box2">
  20. <Chart :option="chartOption2" rotation style="flex: 1" />
  21. <div class="box3">
  22. <div v-for="(item, index) in legendData" :key="index" class="box-item">
  23. <i class="icon" :style="{ background: item.itemStyle.color }" />
  24. <div class="text1">{{ item.name }}</div>
  25. </div>
  26. </div>
  27. </div>
  28. </div>
  29. </div>
  30. </div>
  31. <div class="flex" style="margin-top: 15px">
  32. <div class="card2">
  33. <div class="card-header">
  34. <i class="icon-line" />
  35. <div class="card-title">发布时间统计</div>
  36. </div>
  37. <div class="card-content">
  38. <div class="box1">
  39. <div class="date-box">
  40. <div
  41. v-for="(item, index) in dateOption"
  42. :key="index"
  43. :class="item.value === dateType ? 'date-tag tag-active' : 'date-tag'"
  44. @click="handleChangeDate(item.value)"
  45. >
  46. {{ item.name }}
  47. </div>
  48. </div>
  49. <el-date-picker
  50. v-model="dateRange"
  51. value-format="YYYY-MM-DD"
  52. type="daterange"
  53. range-separator="至"
  54. start-placeholder="开始日期"
  55. end-placeholder="结束日期"
  56. clearable
  57. class="date-picker"
  58. />
  59. </div>
  60. <Chart :option="chartOption3" rotation style="flex: 1" />
  61. </div>
  62. </div>
  63. <div class="card2">
  64. <div class="card-header" style="justify-content: space-between">
  65. <div class="title-box1">
  66. <i class="icon-line" />
  67. <div class="card-title">知识查阅TOP5</div>
  68. </div>
  69. <div class="text1" style="padding-right: 8px;">统计时间:{{ statisticsDate }}</div>
  70. </div>
  71. <div class="card-content" style="padding: 0 8px">
  72. <div class="data-list">
  73. <div v-for="(item, index) in dataList" :key="index" class="data-list-item">
  74. <i :class="getIconClass(index)" />
  75. <div class="td1" :title="item.reportName">{{ item.reportName }}</div>
  76. <div class="td2">来源单位:{{ item.publishingUnit }}</div>
  77. <div class="td3">
  78. <i class="icon-eye" />
  79. {{ item.time }}次
  80. </div>
  81. </div>
  82. </div>
  83. </div>
  84. </div>
  85. </div>
  86. </div>
  87. </template>
  88. <script lang="ts" setup name="knowledgeAnalysis">
  89. import { option1, option2, option3 } from './options';
  90. import { deepClone } from '@/utils';
  91. import { toRefs } from 'vue';
  92. import { fetchReports } from '@/api/knowledge';
  93. const proxy = getCurrentInstance()?.proxy;
  94. // 事件类型统计
  95. const dateOption = ref([
  96. { name: '今日', value: '1' },
  97. { name: '本周', value: '2' },
  98. { name: '本月', value: '3' },
  99. { name: '全年', value: '4' }
  100. ]);
  101. let dateType = ref('1');
  102. let dateRange = ref([]);
  103. let chartOption1 = reactive(deepClone(option1));
  104. const handleChangeDate = (type: string) => {
  105. dateType.value = type;
  106. getEventTypeData();
  107. };
  108. const getEventTypeData = () => {
  109. chartOption1.xAxis.data = ['自然灾害', '事故灾害', '突发卫生公\n共事件', '突发社会安\n全事件'];
  110. chartOption1.series[0].data = [45, 123, 87, 83];
  111. };
  112. let chartOption2 = reactive(option2);
  113. let legendData = ref([]);
  114. let chartOption3 = reactive(deepClone(option3));
  115. // 知识查询
  116. let loading = ref(false);
  117. let statisticsDate = ref('');
  118. let queryParams = reactive({
  119. pageNum: 1,
  120. pageSize: 5,
  121. sortBy: 'publishDate',
  122. sortOrder: 'asc'
  123. });
  124. let dataList = ref([]);
  125. const getDataList = () => {
  126. loading.value = true;
  127. fetchReports(queryParams)
  128. .then((res) => {
  129. let arr = [263, 231, 198, 167, 123];
  130. res.data.forEach((item, index) => {
  131. item.time = arr[index];
  132. });
  133. dataList.value = res.data;
  134. })
  135. .finally(() => {
  136. loading.value = false;
  137. });
  138. };
  139. const getIconClass = (index) => {
  140. let classList = ['icon-top1', 'icon-top2', 'icon-top3', 'icon-top4', 'icon-top5'];
  141. return classList[index];
  142. };
  143. const initData = () => {
  144. getEventTypeData();
  145. const data1 = [
  146. { value: 154, name: '市应急管理局', percent: '45.56%', itemStyle: { color: '#2c81ff' } },
  147. { value: 45, name: '市自然资源局', percent: '13.31%', itemStyle: { color: '#62d9ab' } },
  148. { value: 62, name: '市医疗保障局', percent: '18.34%', itemStyle: { color: '#feb20d' } },
  149. { value: 77, name: '市教育局', percent: '22.79%', itemStyle: { color: '#fe6a6a' } }
  150. ];
  151. legendData.value = data1;
  152. chartOption2.series[0].data = data1;
  153. chartOption3.xAxis[0].data = ['2020年', '2021年', '2022年', '2023年', '2024年'];
  154. chartOption3.series[0].data = [48, 64, 79, 63, 84];
  155. getDataList();
  156. const date = new Date();
  157. const year = date.getFullYear();
  158. let month = date.getMonth() + 1; // 月份从0开始,需要加1
  159. let day = date.getDate();
  160. month = month < 10 ? '0' + month : month;
  161. day = day < 10 ? '0' + day : day;
  162. statisticsDate.value = `${year}年${month}月${day}日`;
  163. };
  164. onMounted(() => {
  165. initData();
  166. });
  167. </script>
  168. <style lang="scss" scoped>
  169. .container {
  170. padding: 15px 0;
  171. .flex {
  172. display: flex;
  173. justify-content: space-between;
  174. padding: 0 17px;
  175. }
  176. .card2 {
  177. flex: 1;
  178. height: 367px;
  179. border: 1px solid #e6f2ff;
  180. background-image: linear-gradient(to bottom, #ffffff 0%, #ebf4ff 100%);
  181. overflow-y: auto;
  182. display: flex;
  183. flex-direction: column;
  184. padding-bottom: 10px;
  185. &:nth-child(2) {
  186. margin-left: 20px;
  187. }
  188. .card-header {
  189. flex-shrink: 0;
  190. display: flex;
  191. align-items: center;
  192. height: 40px;
  193. padding: 10px 5px 16px;
  194. .icon-line {
  195. display: inline-block;
  196. width: 6px;
  197. height: 17px;
  198. background-image: linear-gradient(180deg, #00fce7 0%, #2c81ff 100%);
  199. border-radius: 0 3px 0 0;
  200. margin-right: 7px;
  201. }
  202. .card-title {
  203. font-size: 16px;
  204. color: rgba(0, 0, 0, 0.85);
  205. }
  206. .title-box1 {
  207. display: flex;
  208. align-items: center;
  209. }
  210. .text1 {
  211. font-size: 14px;
  212. color: rgba(0, 0, 0, 0.85);
  213. }
  214. }
  215. .card-content {
  216. flex: 1;
  217. display: flex;
  218. flex-direction: column;
  219. padding: 0 22px;
  220. overflow: hidden;
  221. .box1 {
  222. flex-shrink: 0;
  223. display: flex;
  224. align-items: center;
  225. flex-wrap: wrap;
  226. .date-box {
  227. width: 289px;
  228. height: 40px;
  229. background-color: #edf1f8;
  230. border-radius: 4px;
  231. display: flex;
  232. align-items: center;
  233. padding: 0 4px;
  234. .date-tag {
  235. height: 32px;
  236. width: 60px;
  237. font-size: 14px;
  238. color: #7a8293;
  239. display: flex;
  240. align-items: center;
  241. justify-content: center;
  242. cursor: pointer;
  243. margin-left: 13px;
  244. &:first-child {
  245. margin-left: 0;
  246. }
  247. &:hover {
  248. color: #2c81ff;
  249. background: #ffffff;
  250. box-shadow: 0 2px 1px 0 rgba(36, 41, 51, 0.04);
  251. border-radius: 3px;
  252. }
  253. }
  254. .tag-active {
  255. color: #2c81ff;
  256. background: #ffffff;
  257. box-shadow: 0 2px 1px 0 rgba(36, 41, 51, 0.04);
  258. border-radius: 3px;
  259. }
  260. }
  261. :deep(.date-picker) {
  262. margin-left: 29px;
  263. width: 242px;
  264. height: 40px;
  265. border-radius: 3px;
  266. }
  267. }
  268. .box2 {
  269. height: 100%;
  270. display: flex;
  271. overflow: hidden;
  272. .box3 {
  273. display: flex;
  274. flex-direction: column;
  275. justify-content: center;
  276. width: 200px;
  277. .box-item {
  278. display: flex;
  279. align-items: center;
  280. padding: 11px 0;
  281. .icon {
  282. width: 8px;
  283. height: 8px;
  284. border-radius: 50%;
  285. margin-right: 10px;
  286. }
  287. .text1 {
  288. font-size: 14px;
  289. color: rgba(0, 0, 0, 0.65);
  290. margin-right: 23px;
  291. }
  292. .text2 {
  293. font-size: 14px;
  294. color: rgba(0, 0, 0, 0.65);
  295. width: 35px;
  296. margin-right: 35px;
  297. }
  298. .text3 {
  299. font-size: 14px;
  300. color: rgba(0, 0, 0, 0.65);
  301. }
  302. }
  303. }
  304. }
  305. .data-list {
  306. .data-list-item {
  307. display: flex;
  308. align-items: center;
  309. width: 100%;
  310. height: 48px;
  311. border-radius: 0 4px 4px 0;
  312. margin-top: 14px;
  313. background-image: linear-gradient(270deg, rgba(36, 104, 242, 0.08) 0%, rgba(119, 161, 246, 0) 100%);
  314. &:nth-child(1) {
  315. background-image: linear-gradient(270deg, rgba(249, 74, 61, 0.08) 0%, rgba(253, 129, 112, 0) 100%);
  316. }
  317. &:nth-child(2) {
  318. background-image: linear-gradient(270deg, rgba(242, 117, 12, 0.08) 0%, rgba(246, 169, 104, 0) 100%);
  319. }
  320. &:nth-child(3) {
  321. background-image: linear-gradient(270deg, rgba(242, 186, 0, 0.08) 0%, rgba(249, 225, 146, 0) 100%);
  322. }
  323. .icon-top1 {
  324. background: url('@/assets/images/top1.png') no-repeat;
  325. }
  326. .icon-top2 {
  327. background: url('@/assets/images/top2.png') no-repeat;
  328. }
  329. .icon-top3 {
  330. background: url('@/assets/images/top3.png') no-repeat;
  331. }
  332. .icon-top4 {
  333. background: url('@/assets/images/top4.png') no-repeat;
  334. }
  335. .icon-top5 {
  336. background: url('@/assets/images/top5.png') no-repeat;
  337. }
  338. .icon-top1,
  339. .icon-top2,
  340. .icon-top3,
  341. .icon-top4,
  342. .icon-top5 {
  343. width: 28px;
  344. height: 34px;
  345. background-size: 100% 100%;
  346. margin-right: 5px;
  347. flex-shrink: 0;
  348. }
  349. .td1 {
  350. flex: 3;
  351. overflow: hidden;
  352. white-space: nowrap;
  353. text-overflow: ellipsis;
  354. padding: 0 5px;
  355. font-size: 14px;
  356. color: rgba(0, 0, 0, 0.65);
  357. }
  358. .td2 {
  359. flex: 2;
  360. padding: 0 5px;
  361. font-size: 12px;
  362. color: rgba(0, 0, 0, 0.45);
  363. }
  364. .td3 {
  365. flex-shrink: 0;
  366. width: 100px;
  367. padding: 0 20px 0 5px;
  368. font-size: 12px;
  369. color: rgba(0, 0, 0, 0.65);
  370. display: flex;
  371. align-items: center;
  372. }
  373. .icon-eye {
  374. width: 16px;
  375. height: 12px;
  376. background: url('@/assets/images/eye.png') no-repeat;
  377. background-size: 100% 100%;
  378. margin-right: 4px;
  379. }
  380. }
  381. }
  382. }
  383. }
  384. .table {
  385. margin-top: 10px;
  386. :deep(.el-table__inner-wrapper) {
  387. .el-table__header-wrapper th {
  388. height: 35px !important;
  389. }
  390. }
  391. :deep(.el-table__body) {
  392. td.el-table__cell {
  393. height: 35px !important;
  394. padding: 0 !important;
  395. }
  396. }
  397. }
  398. }
  399. </style>