dashboard.vue 23 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699
  1. <template>
  2. <div class="wrapper">
  3. <div class="main">
  4. <el-row class="main-top" :gutter="20">
  5. <!-- 仪器总数 -->
  6. <el-col :sm="12" :lg="6">
  7. <el-card class="top-card" shadow="hover">
  8. <el-row justify="start">
  9. <el-col :span="15" class="title-box">
  10. <div class="title-top">{{ t('dashboard.Member registration') }}</div>
  11. <div class="title-center">{{ dbdata.count }} <i class="fa fa-level-up"
  12. aria-hidden="true"></i></div>
  13. </el-col>
  14. <el-col :span="6" class="top-progress" :push="3">
  15. <el-progress type="dashboard" :percentage=dbdata.count :format="format" :width="60"
  16. :color="colors"/>
  17. </el-col>
  18. </el-row>
  19. </el-card>
  20. </el-col>
  21. <!-- 总价值 -->
  22. <el-col :sm="12" :lg="6">
  23. <el-card class="top-card" shadow="hover">
  24. <el-row justify="start">
  25. <el-col :span="15" class="title-box">
  26. <div class="title-top">{{ t('dashboard.Attachment uploading') }}</div>
  27. <div class="title-center">{{ dbdata.value }}<i class="fa fa-level-up"
  28. aria-hidden="true"></i></div>
  29. </el-col>
  30. <el-col :span="6" class="top-progress" :push="3">
  31. <el-progress type="dashboard" :percentage="83" :format="format" :width="60"
  32. :color="colors"/>
  33. </el-col>
  34. </el-row>
  35. </el-card>
  36. </el-col>
  37. <!-- 借出数量 -->
  38. <el-col :sm="12" :lg="6">
  39. <el-card class="top-card" shadow="hover">
  40. <el-row justify="start">
  41. <el-col :span="15" class="title-box">
  42. <div class="title-top">{{ t('dashboard.Total number of members') }}</div>
  43. <div class="title-center">{{ dbdata.lent_number }} <i class="fa fa-level-up"
  44. aria-hidden="true"></i></div>
  45. </el-col>
  46. <el-col :span="6" class="top-progress" :push="3">
  47. <el-progress type="dashboard" :percentage=dbdata.lent_number :format="format"
  48. :width="60" :color="colors"/>
  49. </el-col>
  50. </el-row>
  51. </el-card>
  52. </el-col>
  53. <!-- 维修数量 -->
  54. <el-col :sm="12" :lg="6">
  55. <el-card class="top-card" shadow="hover">
  56. <el-row justify="start">
  57. <el-col :span="15" class="title-box">
  58. <div class="title-top">{{ t('dashboard.Module downloads') }}</div>
  59. <div class="title-center">{{ dbdata.repair_number }} <i class="fa fa-level-up"
  60. aria-hidden="true"></i></div>
  61. </el-col>
  62. <el-col :span="6" class="top-progress" :push="3">
  63. <el-progress type="dashboard" :percentage=dbdata.repair_number :format="format"
  64. :width="60" :color="colors"/>
  65. </el-col>
  66. </el-row>
  67. </el-card>
  68. </el-col>
  69. </el-row>
  70. <el-row class="main-center" :gutter="20">
  71. <!-- 欢迎区 -->
  72. <el-col :xs="24" :sm="24" :md="24" :lg="6">
  73. <el-card class="card-message" shadow="hover">
  74. <div class="msg-title-box">
  75. <h4 class="title">{{ t('dashboard.Wellcom Back') }}, {{ adminInfo.nickname }}!!</h4>
  76. <p class="msg">
  77. {{ t('dashboard.Notice') }}
  78. </p>
  79. </div>
  80. <div class="wellcom-div"></div>
  81. </el-card>
  82. </el-col>
  83. <!-- 仪器借取数量 -->
  84. <el-col :xs="24" :sm="24" :md="24" :lg="12">
  85. <el-card class="center-card" shadow="hover">
  86. <h6>{{ t('dashboard.Attachment Downloads') }}</h6>
  87. <div class="view-column" :ref="chartRefs.set"></div>
  88. </el-card>
  89. </el-col>
  90. <!-- 仪器类型比例 -->
  91. <el-col :xs="24" :sm="24" :md="24" :lg="6">
  92. <el-card class="center-card" shadow="hover">
  93. <h6 class="user-source">{{ t('dashboard.Source Of User') }}</h6>
  94. <div class="view-pie" :ref="chartRefs.set"></div>
  95. </el-card>
  96. </el-col>
  97. </el-row>
  98. ` <!-- <el-row class="main-slide" :gutter="20">
  99. <el-col :xs="24" :sm="24" :md="24" :lg="12">
  100. <el-card shadow="hover">
  101. <div class="slide-box">
  102. <el-col :span="12">
  103. <div class="slide-box-title">
  104. <i class="fa fa-file-archive-o" aria-hidden="true"></i> ZIP{{ t('dashboard.Export') }}
  105. </div>
  106. <h5>1,245</h5>
  107. </el-col>
  108. <el-col :span="12"
  109. ><el-progress :text-inside="true" :stroke-width="24" :percentage="52" status="success" color="#188df0"
  110. /></el-col>
  111. </div>
  112. </el-card>
  113. </el-col>
  114. <el-col :xs="24" :sm="24" :md="24" :lg="12">
  115. <el-card shadow="hover">
  116. <div class="slide-box">
  117. <el-col :span="12">
  118. <div class="slide-box-title"><i class="fa fa-file-pdf-o" aria-hidden="true"></i> PDF{{ t('dashboard.Export') }}</div>
  119. <h5>1,872</h5>
  120. </el-col>
  121. <el-col :span="12"><el-progress :text-inside="true" :stroke-width="24" :percentage="73" status="success" /></el-col>
  122. </div>
  123. </el-card>
  124. </el-col>
  125. </el-row>` -->
  126. <el-row class="main-bottom" :gutter="20">
  127. <!-- 用户信息-->
  128. <el-col :xs="24" :sm="24" :md="12" :lg="6">
  129. <el-card class="bottom-card" shadow="hover">
  130. <h6>{{ t('dashboard.Trading Volume Report') }}</h6>
  131. <div class="bottom-reports">
  132. <div>{{ t('dashboard.Available balance') }}</div>
  133. <h3>{{ dbdata.userinfo['用户总数'] }} </h3>
  134. <div class="reports-more">
  135. <div class="color-info">{{ t('dashboard.BUY THIS MONTH') }}</div>
  136. <h5>{{ dbdata.userinfo['教职工'] }}</h5>
  137. <div class="color-info">{{ t('dashboard.SELL THIS MONTH') }}</div>
  138. <h5>{{ dbdata.userinfo['学生'] }}</h5>
  139. </div>
  140. <el-button class="button-more" type="primary" @click="toadmin">{{
  141. t('dashboard.See More')
  142. }}
  143. </el-button>
  144. </div>
  145. </el-card>
  146. </el-col>
  147. <!-- 仪器借用排行 -->
  148. <el-col :xs="24" :sm="24" :md="12" :lg="6">
  149. <el-card class="bottom-card" shadow="hover">
  150. <h6>{{ t('dashboard.Membership Growth') }}</h6>
  151. <div class="bottom-content">
  152. <div v-for="(data, index) in dbdata.q">
  153. <el-row class="content-info" align="middle" justify="space-between">
  154. <el-col :span="15">
  155. <div class="info-circle circle-orange"></div>
  156. <span class="info-title">{{ index }}</span></el-col
  157. >
  158. <el-col :span="9">
  159. <el-progress :percentage=data :format="format"/>
  160. </el-col>
  161. <el-divider/>
  162. </el-row>
  163. </div>
  164. </div>
  165. </el-card>
  166. </el-col>
  167. <!-- 访问增长量 -->
  168. <el-col :xs="24" :sm="24" :md="24" :lg="12"
  169. >
  170. <el-card class="bottom-card" shadow="hover">
  171. <h6>{{ t('dashboard.Access Growth') }}</h6>
  172. <div class="visitor-box" :ref="chartRefs.set"></div
  173. >
  174. </el-card>
  175. </el-col>
  176. </el-row>
  177. </div>
  178. </div>
  179. </template>
  180. <script setup lang="ts">
  181. import {useTemplateRefsList} from '@vueuse/core'
  182. import * as echarts from 'echarts'
  183. import {onMounted, nextTick, reactive, onActivated, onBeforeMount, watch} from 'vue'
  184. import {useNavTabs} from '/@/stores/navTabs'
  185. import {useAdminInfo} from '/@/stores/adminInfo'
  186. import {useI18n} from 'vue-i18n'
  187. import {ref} from 'vue'
  188. import {useRouter} from 'vue-router'
  189. import createAxios from '/@/utils/axios'
  190. var dbdata = ref('')
  191. await createAxios({
  192. url: '/api/ScreenData/getdata',
  193. method: 'get',
  194. },
  195. {
  196. loading: true,
  197. }
  198. ).then(async (val: any) => {
  199. dbdata.value = val.data
  200. })
  201. const router = useRouter()
  202. const toadmin = () =>{
  203. router .push('/admin/auth/admin');
  204. }
  205. const format = (percentage) => (percentage === 10000 ? 'Full' : `${percentage}`)
  206. const navTabs = useNavTabs()
  207. const adminInfo = useAdminInfo()
  208. const {t} = useI18n()
  209. const state: {
  210. charts: any[]
  211. } = reactive({
  212. charts: [],
  213. })
  214. const chartRefs = useTemplateRefsList<HTMLDivElement>()
  215. const colors = [
  216. {color: '#f56c6c', percentage: 20},
  217. {color: '#e6a23c', percentage: 40},
  218. {color: '#5cb87a', percentage: 60},
  219. {color: '#1989fa', percentage: 80},
  220. {color: '#6f7ad3', percentage: 100},
  221. ]
  222. const initUserGrowthChart = () => {
  223. const userGrowthChart = echarts.init(chartRefs.value[0] as HTMLElement)
  224. // prettier-ignore
  225. let dataAxis = [
  226. t('dashboard.Jan'), t('dashboard.Feb'), t('dashboard.Mar'), t('dashboard.Apr'), t('dashboard.May'), t('dashboard.Jun')
  227. , t('dashboard.Jul'), t('dashboard.Aug'), t('dashboard.Sept'), t('dashboard.Oct'), t('dashboard.Nov'), t('dashboard.Jan'),];
  228. // prettier-ignore
  229. let data = [dbdata.value.mq['01'], dbdata.value.mq['02'], dbdata.value.mq['03'], dbdata.value.mq['04'], dbdata.value.mq['05'],
  230. dbdata.value.mq['06'], dbdata.value.mq['07'], dbdata.value.mq['08'], dbdata.value.mq['09'], dbdata.value.mq['10'], dbdata.value.mq['11'], dbdata.value.mq['12']];
  231. let yMax = 500
  232. let dataShadow = []
  233. for (let i = 0; i < data.length; i++) {
  234. dataShadow.push(yMax)
  235. }
  236. const option = {
  237. xAxis: {
  238. data: dataAxis,
  239. axisLabel: {
  240. inside: true,
  241. color: '#fff',
  242. },
  243. axisTick: {
  244. show: false,
  245. },
  246. axisLine: {
  247. show: false,
  248. },
  249. z: 10,
  250. },
  251. yAxis: {
  252. axisLine: {
  253. show: false,
  254. },
  255. axisTick: {
  256. show: false,
  257. },
  258. axisLabel: {
  259. color: '#999',
  260. },
  261. },
  262. dataZoom: [
  263. {
  264. type: 'inside',
  265. },
  266. ],
  267. series: [
  268. {
  269. type: 'bar',
  270. showBackground: true,
  271. itemStyle: {
  272. color: new echarts.graphic.LinearGradient(0, 0, 0, 1, [
  273. {offset: 0, color: '#83bff6'},
  274. {offset: 0.5, color: '#188df0'},
  275. {offset: 1, color: '#188df0'},
  276. ]),
  277. },
  278. emphasis: {
  279. itemStyle: {
  280. color: new echarts.graphic.LinearGradient(0, 0, 0, 1, [
  281. {offset: 0, color: '#2378f7'},
  282. {offset: 0.7, color: '#2378f7'},
  283. {offset: 1, color: '#83bff6'},
  284. ]),
  285. },
  286. },
  287. data: data,
  288. },
  289. ],
  290. }
  291. // Enable data zoom when user click bar.
  292. const zoomSize = 6
  293. userGrowthChart.on('click', function (params) {
  294. // console.log(dataAxis[Math.max(params.dataIndex - zoomSize / 2, 0)])
  295. userGrowthChart.dispatchAction({
  296. type: 'dataZoom',
  297. startValue: dataAxis[Math.max(params.dataIndex - zoomSize / 2, 0)],
  298. endValue: dataAxis[Math.min(params.dataIndex + zoomSize / 2, data.length - 1)],
  299. })
  300. })
  301. userGrowthChart.setOption(option)
  302. state.charts.push(userGrowthChart)
  303. }
  304. const initUserSource = () => {
  305. const userSource = echarts.init(chartRefs.value[1] as HTMLElement)
  306. const option = {
  307. tooltip: {
  308. trigger: 'item',
  309. },
  310. legend: {
  311. top: '5%',
  312. left: 'center',
  313. textStyle: {
  314. color: '#73767a',
  315. },
  316. },
  317. series: [
  318. {
  319. name: t('dashboard.Source details'),
  320. type: 'pie',
  321. radius: ['40%', '70%'],
  322. avoidLabelOverlap: false,
  323. label: {
  324. show: false,
  325. position: 'center',
  326. color: '#73767a',
  327. },
  328. emphasis: {
  329. label: {
  330. show: true,
  331. fontSize: '15',
  332. fontWeight: 'bold',
  333. },
  334. },
  335. labelLine: {
  336. show: false,
  337. },
  338. data: [
  339. {value: dbdata.value.a['水准仪'], name: t('dashboard.sz')},
  340. {value: dbdata.value.a['RTK'], name: t('dashboard.rtk')},
  341. {value: dbdata.value.a['全站仪'], name: t('dashboard.qzy')},
  342. {value: dbdata.value.a['无人机'], name: t('dashboard.wrj')},
  343. {value: dbdata.value.a['配件及其他'], name: t('dashboard.Other')},
  344. ],
  345. },
  346. ],
  347. }
  348. userSource.setOption(option)
  349. state.charts.push(userSource)
  350. }
  351. const initUserAdd = () => {
  352. const userAdd = echarts.init(chartRefs.value[2] as HTMLElement)
  353. const option = {
  354. xAxis: {
  355. type: 'category',
  356. data: [
  357. t('dashboard.Monday'),
  358. t('dashboard.Tuesday'),
  359. t('dashboard.Wednesday'),
  360. t('dashboard.Thursday'),
  361. t('dashboard.Friday'),
  362. t('dashboard.Saturday'),
  363. t('dashboard.Sunday'),
  364. ],
  365. },
  366. yAxis: {
  367. type: 'value',
  368. },
  369. series: [
  370. {
  371. data: [150, 230, 224, 218, 135, 147, 260],
  372. type: 'line',
  373. },
  374. ],
  375. }
  376. userAdd.setOption(option)
  377. state.charts.push(userAdd)
  378. }
  379. const echartsResize = () => {
  380. nextTick(() => {
  381. for (const key in state.charts) {
  382. state.charts[key].resize()
  383. }
  384. })
  385. }
  386. onMounted(() => {
  387. initUserGrowthChart()
  388. initUserSource()
  389. initUserAdd()
  390. window.addEventListener('resize', echartsResize)
  391. })
  392. onBeforeMount(() => {
  393. for (const key in state.charts) {
  394. state.charts[key].dispose()
  395. }
  396. window.removeEventListener('resize', echartsResize)
  397. })
  398. onActivated(() => {
  399. echartsResize()
  400. })
  401. watch(
  402. () => navTabs.state.tabFullScreen,
  403. () => {
  404. echartsResize()
  405. }
  406. )
  407. </script>
  408. <style scoped lang="scss">
  409. .wrapper {
  410. margin: 30px;
  411. .ba-card-border {
  412. // border style
  413. border: 1px;
  414. border-style: dashed;
  415. border-color: #e9e6e1;
  416. border-radius: 0.75rem;
  417. }
  418. .main {
  419. .main-top {
  420. > * {
  421. margin-top: 1rem;
  422. max-width: 100%;
  423. }
  424. .top-card {
  425. @extend .ba-card-border;
  426. --el-card-padding: 2rem;
  427. display: flex;
  428. flex-direction: column;
  429. .title-box {
  430. display: flex;
  431. flex-direction: column;
  432. justify-content: space-evenly;
  433. .title-top {
  434. font-size: var(--el-font-size-extra-small);
  435. }
  436. .title-center {
  437. font-size: 2rem;
  438. font-weight: bold;
  439. i {
  440. color: #9399a1;
  441. font-size: var(--el-font-size-extra-small);
  442. }
  443. }
  444. }
  445. .top-progress {
  446. display: flex;
  447. justify-content: start;
  448. }
  449. }
  450. }
  451. .main-center {
  452. margin-top: 1rem;
  453. > * {
  454. margin-top: 1rem;
  455. }
  456. .card-message {
  457. height: 100%;
  458. @extend .ba-card-border;
  459. display: flex;
  460. flex-direction: column;
  461. align-items: center;
  462. justify-content: end;
  463. :deep(.el-card__body) {
  464. padding: 0;
  465. }
  466. .msg-title-box {
  467. margin-bottom: 8rem;
  468. padding: 2rem 4rem 0rem 3rem;
  469. .title {
  470. color: var(--el-text-color-primary);
  471. font-size: 2rem;
  472. text-align: center;
  473. }
  474. .msg {
  475. color: var(--el-text-color-primary);
  476. text-align: center;
  477. margin-top: 1rem;
  478. }
  479. }
  480. .wellcom-div {
  481. margin-top: 2rem;
  482. width: 100%;
  483. position: relative;
  484. text-align: center;
  485. background: url('/@/assets/ripple.gif') 100% 40% no-repeat;
  486. height: 50px;
  487. }
  488. }
  489. .center-card {
  490. @extend .ba-card-border;
  491. --el-card-padding: 25px 15px 15px 20px;
  492. font-weight: 600;
  493. height: 100%;
  494. .user-source {
  495. margin-bottom: 20px;
  496. }
  497. .view-column {
  498. height: 30rem;
  499. }
  500. .view-pie {
  501. height: 30rem;
  502. }
  503. }
  504. }
  505. .main-slide {
  506. margin-top: 1rem;
  507. > * {
  508. margin-top: 1rem;
  509. }
  510. .el-card {
  511. @extend .ba-card-border;
  512. height: 8rem;
  513. height: 100%;
  514. }
  515. :deep(.el-card__body) {
  516. height: 100%;
  517. }
  518. .slide-box {
  519. display: flex;
  520. align-items: center;
  521. height: 100%;
  522. text-align: center;
  523. .slide-box-title {
  524. display: inline;
  525. font-size: var(--el-font-size-medium);
  526. margin-right: 0.5rem;
  527. }
  528. }
  529. }
  530. .main-bottom {
  531. margin-top: 1rem;
  532. > * {
  533. margin-top: 1rem;
  534. }
  535. .bottom-card {
  536. height: 100%;
  537. @extend .ba-card-border;
  538. --el-card-padding: 25px 15px 15px 20px;
  539. :deep(.el-card__body) {
  540. height: 100%;
  541. }
  542. .bottom-reports {
  543. margin: 4rem 1.5rem 0 1.5rem;
  544. font-size: var(--el-font-size-medium);
  545. h3 {
  546. margin-top: 1rem;
  547. }
  548. h5 {
  549. margin: 0.5rem 0 1rem 0;
  550. }
  551. .reports-more {
  552. margin-top: 2rem;
  553. .color-info {
  554. color: var(--el-color-info);
  555. font-size: var(--el-font-size-medium);
  556. }
  557. }
  558. .button-more {
  559. width: 100%;
  560. margin-top: 1rem;
  561. }
  562. }
  563. .bottom-content {
  564. margin: 4rem 1.5rem 0 1.5rem;
  565. .content-info {
  566. .info-circle {
  567. width: 0.8rem;
  568. height: 0.8rem;
  569. border-radius: 50%;
  570. display: inline-block;
  571. }
  572. .info-title {
  573. margin-left: 0.5rem;
  574. }
  575. :deep(.el-progress__text) {
  576. min-width: 0;
  577. }
  578. .circle-orange {
  579. background-color: orange;
  580. }
  581. .circle-violet {
  582. background-color: #c507f5;
  583. }
  584. .circle-blue {
  585. background-color: blue;
  586. }
  587. .circle-green {
  588. background-color: green;
  589. }
  590. .circle-silver {
  591. background-color: silver;
  592. }
  593. }
  594. }
  595. .visitor-box {
  596. height: 400px;
  597. }
  598. }
  599. }
  600. }
  601. }
  602. h3 {
  603. display: inline-block;
  604. font-size: 2.5rem;
  605. line-height: 1.2;
  606. font-weight: 500;
  607. }
  608. h5 {
  609. display: inline-block;
  610. font-size: 1.7rem;
  611. font-weight: 500;
  612. line-height: 1.2;
  613. }
  614. h6 {
  615. display: inline-block;
  616. font-size: 1.2rem;
  617. line-height: 1.2;
  618. font-weight: 600;
  619. }
  620. // 暗黑样式
  621. @at-root .dark {
  622. .ba-card-border {
  623. border-color: #353535;
  624. }
  625. .wellcom-div {
  626. background: none !important;
  627. }
  628. }
  629. </style>