index.vue 18 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721
  1. <template>
  2. <div class="app-container home">
  3. <el-row :gutter="10" class="top_row">
  4. <el-col :span="8" class="box-card_bg" v-for="(item, index) in state.deviceListData" :key="index">
  5. <el-card :style="{ background: item.bgColor }" class="box-card-num">
  6. <el-row class="box-card-row" style="margin:0">
  7. <el-col :span="16" class="box_left">
  8. <p>{{ item.name }}</p>
  9. <p>{{ item.value }}</p>
  10. </el-col>
  11. <el-col :span="8">
  12. <el-image style="width:125px;height:80px" :src="item.icon" fit="cover"></el-image>
  13. </el-col>
  14. </el-row>
  15. <el-divider />
  16. <el-row class="add_bg">
  17. <div>
  18. <span>今日新增</span>
  19. <el-image style="width:9px;height:9px;" :src="item.addIcon"></el-image>
  20. <span>{{ item.addValue }}</span>
  21. </div>
  22. </el-row>
  23. </el-card>
  24. </el-col>
  25. </el-row>
  26. <el-row :gutter="10">
  27. <el-col :span="12" v-for="(item, index) in state.barList" :key="index">
  28. <el-card class="pie_bg">
  29. <p>{{ item.name }}</p>
  30. <el-divider />
  31. <div v-if="index == 0">
  32. <div ref="deviceNum_ref" id="deviceNum" />
  33. </div>
  34. <div v-else class="device_bg">
  35. <div class="device_item" v-for="(item, index) in state.deviceTypeList" :key="index">
  36. <div class="icon_bg" :id="'devicechart' + index"></div>
  37. <div class="title">{{ item.title }}</div>
  38. <div class="num" :style="{'--color':state.deviceColor[index]}">{{ item.rate }}%</div>
  39. </div>
  40. <div class="legend_bg">
  41. <div class="device_legend" v-for="(itemL, index) in state.deviceTypeList" :key="index">
  42. <span :style="{'--color':state.deviceColor[index]}"></span>
  43. <span>{{ itemL.title }}:</span>
  44. <span>{{ itemL.num}}</span>
  45. </div>
  46. </div>
  47. </div>
  48. </el-card>
  49. </el-col>
  50. </el-row>
  51. <el-row :gutter="10" class="top_row">
  52. <el-col :span="8" class="box-card_bg" v-for="(item, index) in state.jumpListData" :key="index">
  53. <el-card @click="jumpweb(item.type)" :style="{ background: item.bgColor }" class="box-card-num">
  54. <el-row class="box-card-row" style="margin:0">
  55. <el-col :span="16" class="box_left">
  56. <p class="jump_title">{{ item.name }}</p>
  57. </el-col>
  58. <el-col :span="8">
  59. <el-image style="width:125px;height:80px" :src="item.icon" fit="cover"></el-image>
  60. </el-col>
  61. </el-row>
  62. </el-card>
  63. </el-col>
  64. </el-row>
  65. <el-row :gutter="10">
  66. <el-col :span="24">
  67. <el-card class="box-bottom_bg">
  68. <p>平台架构图</p>
  69. <el-divider />
  70. <el-image class="framework" :src="home_5" fit="contain"></el-image>
  71. </el-card>
  72. </el-col>
  73. </el-row>
  74. </div>
  75. </template>
  76. <script setup name="Index" lang="ts">
  77. import { categoryList, productList, deviceList, deviceCategory,deviceStates } from '@/api/home'
  78. import * as echarts from 'echarts'
  79. import { md5Encrypt } from '@/utils/jsencrypt'
  80. import home_1 from '@/assets/images/home/home_1.png'
  81. import home_2 from '@/assets/images/home/home_2.png'
  82. import home_3 from '@/assets/images/home/home_3.png'
  83. import home_4 from '@/assets/images/home/home_4.png'
  84. import home_5 from '@/assets/images/home/home_5.png'
  85. import { getName } from '@/utils/auth'
  86. enum TypeApi {
  87. tend = 'tend',
  88. health = 'health',
  89. bed = 'bed'
  90. }
  91. const deviceNum_ref = ref()
  92. const state = reactive({
  93. deviceListData: [
  94. {
  95. name: '品类数量',
  96. value: 0,
  97. addValue: 0,
  98. bgColor: 'linear-gradient(225deg, #F1F7FF 0%, #FFFFFF 36%, #FFFFFF 100%)',
  99. icon: home_1,
  100. addIcon: home_4
  101. },
  102. {
  103. name: '产品数量',
  104. value: 11,
  105. addValue: 4,
  106. bgColor: 'linear-gradient(225deg, #FFF6EE 0%, #FFFFFF 36%, #FFFFFF 100%)',
  107. icon: home_2,
  108. addIcon: home_4
  109. },
  110. {
  111. name: '设备数量',
  112. value: 12,
  113. addValue: 5,
  114. bgColor: 'linear-gradient(225deg, #EEFFF5 0%, #FFFFFF 36%, #FFFFFF 100%)',
  115. icon: home_3,
  116. addIcon: home_4
  117. }
  118. ],
  119. barList: [
  120. {
  121. name: '设备数量统计'
  122. },
  123. {
  124. name: '设备状态统计'
  125. }
  126. ],
  127. jumpListData: [
  128. {
  129. type:TypeApi.tend,
  130. name: '安全照护',
  131. bgColor: 'linear-gradient(225deg, #F1F7FF 0%, #FFFFFF 36%, #FFFFFF 100%)',
  132. icon: home_1
  133. },
  134. {
  135. type:TypeApi.health,
  136. name: '健康监测',
  137. bgColor: 'linear-gradient(225deg, #FFF6EE 0%, #FFFFFF 36%, #FFFFFF 100%)',
  138. icon: home_2
  139. },
  140. {
  141. type:TypeApi.bed,
  142. name: '数字家床',
  143. bgColor: 'linear-gradient(225deg, #EEFFF5 0%, #FFFFFF 36%, #FFFFFF 100%)',
  144. icon: home_3
  145. }
  146. ],
  147. pieOptionData: [],
  148. pieColor: [
  149. 'rgba(255, 162, 23, 1)',
  150. 'rgba(255, 119, 106, 1)',
  151. 'rgba(108, 201, 255, 1)',
  152. 'rgba(108, 158, 254, 1)',
  153. 'rgba(85, 116, 251, 1)',
  154. 'rgba(139, 126, 255, 1)',
  155. 'rgba(95, 208, 164, 1)',
  156. 'rgba(250, 204, 62, 1)'
  157. ],
  158. // 设备状态统计
  159. deviceColor:[
  160. 'rgba(96, 208, 164, 1)',
  161. 'rgba(254, 103, 86, 1)',
  162. 'rgba(103, 154, 255, 1)'
  163. ],
  164. deviceTypeList: [
  165. { title: '在线设备', num: 0, rate: 0 },
  166. { title: '离线设备', num: 0, rate: 0 },
  167. { title: '待激活设备', num: 0, rate: 0 },
  168. ]
  169. })
  170. // 设备数量统计图表
  171. const setBar1 = (dataObj:object) => {
  172. if (typeof dataObj === 'object' && Object.keys(dataObj).length === 0) {
  173. dataObj = {'设备总数': 0}
  174. }
  175. const keys = Object.keys(dataObj)
  176. const values = Object.values(dataObj)
  177. let totlaNum = 0
  178. const pieDataT = values.map((item,index)=>{
  179. totlaNum += item
  180. return {
  181. name: keys[index],
  182. value: item
  183. }
  184. })
  185. const chartDom: any = document.getElementById('deviceNum')
  186. const myChart: any = echarts.init(chartDom)
  187. // const deviceNum_refIntance = echarts.init(deviceNum_ref.value)
  188. myChart.setOption({
  189. legend: {
  190. backgroundColor: 'transparent',
  191. type: 'plain',
  192. show: 'true',
  193. height: '100%',
  194. left:'45%',
  195. // right: '1%',
  196. top: 0,
  197. bottom: 0,
  198. orient: 'vertical',
  199. itemGap: 10,
  200. itemWidth: 12,
  201. itemHeight: 12,
  202. icon: 'circle',
  203. borderRadius: 0,
  204. formatter: function (name) {
  205. // let titleList = name.split('|')
  206. // return `{a|${titleList[0]}}{b|${titleList[1]}}`
  207. const pieItem = pieDataT.find(item => item.name == name)
  208. return `{a|${name}:}{b|${pieItem?.value}}`
  209. },
  210. textStyle: {
  211. color: 'rgba(175, 187, 206, 1)',
  212. fontSize: 10,
  213. rich: {
  214. a: {
  215. minWidth: 30,
  216. align: 'left',
  217. color: 'rgba(0, 11, 25, 1)',
  218. fontSize: 14,
  219. fontWeight: 500,
  220. padding: [0, 0, 0, 5]
  221. },
  222. b: {
  223. width: 70,
  224. color: 'rgba(0, 11, 25, 1)',
  225. align: 'left',
  226. fontSize: 18,
  227. fontWeight: 'bold',
  228. backgroundColor: 'transparent',
  229. padding: [0, 0, 0, 8]
  230. }
  231. }
  232. }
  233. },
  234. tooltip: {
  235. trigger: 'item',
  236. formatter: '{a} <br/>{b} : {c} ({d}%)'
  237. },
  238. graphic: [
  239. {
  240. z: 9,
  241. type: 'text',
  242. left: '18%',
  243. top: '40%',
  244. background: 'red',
  245. style: {
  246. text: totlaNum,
  247. fontSize: 18,
  248. textAlign: 'right',
  249. fill: 'rgba(0, 11, 25, 1)',
  250. font: 'OPPOSans-B,OPPOSans',
  251. width: 100,
  252. height: 20,
  253. }
  254. },
  255. {
  256. z: 9,
  257. type: 'text',
  258. left: '17%',
  259. top: '52%',
  260. style: {
  261. text: '设备总数',
  262. fontSize: 12,
  263. textAlign: 'left',
  264. fill: 'rgba(0, 11, 25, 1)',
  265. width: 100,
  266. height: 30,
  267. }
  268. },
  269. ],
  270. series: [
  271. {
  272. name: '设备总数',
  273. type: 'pie',
  274. // roseType: 'radius',
  275. radius: ['55%', '95%'],
  276. center: ['20%', '50%'],
  277. label: {
  278. show: false,
  279. position: 'center',
  280. },
  281. // 数据引线
  282. labelLine: {
  283. show: false
  284. },
  285. data: pieDataT,
  286. animationEasing: 'cubicInOut',
  287. animationDuration: 100
  288. }
  289. ]
  290. }, true)
  291. }
  292. // 设备状态统计
  293. const setCommonOption = (serveRate: number,deviceNum:number, barColor: string) => {
  294. let option = {
  295. graphic: [
  296. {
  297. z: 9,
  298. type: 'text',
  299. left: '41%',
  300. top: '42%',
  301. style: {
  302. text: deviceNum+'个',
  303. fontSize: 18,
  304. textAlign: 'center',
  305. fill: 'rgba(0, 11, 25, 1)',
  306. font: 'OPPOSans-B,OPPOSans',
  307. width: 100,
  308. height: 20,
  309. }
  310. }
  311. ],
  312. series: [
  313. {
  314. name: '服务覆盖率',
  315. type: 'pie',
  316. radius: ['72%', '72%'],
  317. center: ['50%', '50%'],
  318. startAngle: 270,
  319. avoidLabelOverlap: false,
  320. label: {
  321. show: false
  322. },
  323. z: 3,
  324. data: [
  325. {
  326. value: serveRate,
  327. name: '服务覆盖率',
  328. itemStyle: {
  329. borderWidth: 15,
  330. borderCap: 'round',
  331. borderColor: barColor
  332. },
  333. },
  334. {
  335. value: 100 - serveRate,
  336. name: '占位背景',
  337. },
  338. ]
  339. },
  340. {
  341. name: '占位背景',
  342. type: 'pie',
  343. radius: ['72%', '72%'],
  344. center: ['50%', '50%'],
  345. startAngle: 270,
  346. avoidLabelOverlap: false,
  347. label: {
  348. show: false
  349. },
  350. data: [
  351. {
  352. value: 1,
  353. name: '占位背景',
  354. itemStyle: {
  355. borderWidth: 15,
  356. borderColor: 'rgba(230, 230, 230, 1)'
  357. },
  358. }
  359. ]
  360. },
  361. ]
  362. }
  363. return option
  364. }
  365. interface deviceObj {
  366. offline: number
  367. online: number
  368. unactivated: number
  369. }
  370. const setBar2 = (dataObj:deviceObj) => {
  371. setTimeout(() => {
  372. let deviceTotalNum = dataObj.offline + dataObj.online +dataObj.unactivated
  373. const unactivatedRate = ((dataObj.unactivated / deviceTotalNum)*100).toFixed(2)
  374. state.deviceTypeList[0].num = dataObj.online
  375. state.deviceTypeList[0].rate = parseFloat(((dataObj.online / deviceTotalNum)*100).toFixed(2)) || 0
  376. state.deviceTypeList[1].num = dataObj.offline
  377. state.deviceTypeList[1].rate = parseFloat(((dataObj.offline / deviceTotalNum)*100).toFixed(1)) || 0
  378. state.deviceTypeList[2].num = dataObj.unactivated
  379. state.deviceTypeList[2].rate = parseFloat(unactivatedRate) || 0
  380. console.log('state.deviceTypeList:')
  381. console.log(state.deviceTypeList)
  382. const chartDom1: any = document.getElementById('devicechart0')
  383. const chartDom2: any = document.getElementById('devicechart1')
  384. const chartDom3: any = document.getElementById('devicechart2')
  385. const myChart1: any = echarts.init(chartDom1)
  386. const myChart2: any = echarts.init(chartDom2)
  387. const myChart3: any = echarts.init(chartDom3)
  388. myChart1.setOption(setCommonOption(state.deviceTypeList[0].rate,state.deviceTypeList[0].num,state.deviceColor[0]))
  389. myChart2.setOption(setCommonOption(state.deviceTypeList[1].rate,state.deviceTypeList[1].num,state.deviceColor[1]))
  390. myChart3.setOption(setCommonOption(state.deviceTypeList[2].rate,state.deviceTypeList[2].num,state.deviceColor[2]))
  391. }, 100)
  392. }
  393. const getDataList = async () => {
  394. const categoryData = await categoryList({
  395. data:{},
  396. requestId:''
  397. })
  398. const productData = await productList({
  399. data:{},
  400. requestId:''
  401. })
  402. const deviceData = await deviceList({
  403. data:{},
  404. requestId:''
  405. })
  406. state.deviceListData[0].value = categoryData.data && categoryData.data.categoryAllNum
  407. state.deviceListData[0].addValue = categoryData.data && categoryData.data.categoryTodayNum
  408. state.deviceListData[1].value = productData.data && productData.data.productAllNum
  409. state.deviceListData[1].addValue = productData.data && productData.data.productTodayNum
  410. state.deviceListData[2].value = deviceData.data && deviceData.data.viceAllNum
  411. state.deviceListData[2].addValue = deviceData.data && deviceData.data.deviceTodayNum
  412. const deviceCategoryData = await deviceCategory({
  413. data:{},
  414. requestId:''
  415. })
  416. const deviceStatesData = await deviceStates({
  417. data:{},
  418. requestId:''
  419. })
  420. setTimeout(() => {
  421. setBar1(deviceCategoryData.data)
  422. setBar2(deviceStatesData.data)
  423. }, 200)
  424. }
  425. const goTarget = (url: string) => {
  426. window.open(url, '__blank')
  427. }
  428. const jumpweb =(type) => {
  429. let md5Txt = md5Encrypt(String(getName()).toLowerCase())
  430. let paraStr = `user=${getName()}&token=${md5Txt}`
  431. switch (type) {
  432. case TypeApi.tend:
  433. {
  434. window.open(`https://web.poteviohealth.com/zhylsafecase/index.html?${paraStr}`,'_blank')
  435. }
  436. break
  437. case TypeApi.health:
  438. {
  439. window.open(`https://web.poteviohealth.com/r/daping/health/index.html?${paraStr}`,'_blank')
  440. }
  441. break
  442. case TypeApi.bed:
  443. {
  444. window.open(`https://web.poteviohealth.com/boss/daping/data.html?${paraStr}`,'_blank')
  445. }
  446. break
  447. default:
  448. break
  449. }
  450. }
  451. onMounted(() => {
  452. getDataList()
  453. })
  454. </script>
  455. <style scoped lang="scss">
  456. .home {
  457. font-family: "open sans", "Helvetica Neue", Helvetica, Arial, sans-serif;
  458. font-size: 13px;
  459. color: #676a6c;
  460. overflow-x: hidden;
  461. .top_row {
  462. margin-bottom: 15px;
  463. }
  464. .box-card-num {
  465. width: 100%;
  466. height: 154px;
  467. .box-card-row {
  468. width: 100%;
  469. height: 80px;
  470. .box_left {
  471. width: 100%;
  472. height: 100%;
  473. p:nth-of-type(1) {
  474. height: 10px;
  475. font-size: 16px;
  476. font-family: SourceHanSansCN, SourceHanSansCN;
  477. font-weight: 500;
  478. color: #A4ACB4;
  479. }
  480. p:nth-of-type(2) {
  481. font-size: 34px;
  482. font-family: PingFangSC, PingFang SC;
  483. font-weight: 600;
  484. color: #000B19;
  485. }
  486. .jump_title {
  487. margin-top: 40px;
  488. color: #636363 !important;
  489. }
  490. }
  491. }
  492. .el-divider--horizontal {
  493. margin: 12px 0;
  494. }
  495. .add_bg {
  496. width: 100%;
  497. height: 65px;
  498. span:nth-of-type(1) {
  499. font-size: 14px;
  500. font-family: SourceHanSansCN, SourceHanSansCN;
  501. font-weight: 500;
  502. color: #A4ACB4;
  503. margin-right: 3px;
  504. }
  505. span:nth-of-type(2) {
  506. font-size: 14px;
  507. font-family: SourceHanSansCN, SourceHanSansCN;
  508. font-weight: 500;
  509. color: #03B32A;
  510. margin-left: 3px;
  511. }
  512. }
  513. }
  514. .pie_bg {
  515. width: 100%;
  516. height: 255px;
  517. p {
  518. font-size: 16px;
  519. font-family: SourceHanSansCN, SourceHanSansCN;
  520. font-weight: 500;
  521. color: #000B19;
  522. }
  523. .el-divider--horizontal {
  524. margin: 12px 0;
  525. }
  526. #deviceNum {
  527. width: 100%;
  528. height: 170px;
  529. }
  530. .device_bg {
  531. width: 100%;
  532. height: 170px;
  533. display: flex;
  534. .device_item {
  535. width: 25%;
  536. height: 100%;
  537. display: flex;
  538. flex-direction: column;
  539. justify-content: center;
  540. align-items: center;
  541. .icon_bg {
  542. width: 100%;
  543. height: 75%;
  544. }
  545. .title {
  546. font-size: 12px;
  547. font-family: SourceHanSansCN, SourceHanSansCN;
  548. font-weight: 500;
  549. color: #000B19;
  550. }
  551. .num {
  552. font-size: 13px;
  553. font-family: SourceHanSansCN, SourceHanSansCN;
  554. font-weight: bolder;
  555. color: var(--color);
  556. }
  557. }
  558. .legend_bg {
  559. width: 25%;
  560. height: 100%;
  561. display: flex;
  562. flex-direction: column;
  563. justify-content: center;
  564. align-items: center;
  565. .device_legend {
  566. width: 100%;
  567. height: 23%;
  568. span:nth-of-type(1) {
  569. display: inline-block;
  570. width: 12px;
  571. height: 12px;
  572. border-radius: 6px;
  573. background-color: var(--color);
  574. margin-right: 8px;
  575. }
  576. span:nth-of-type(2) {
  577. font-size: 14px;
  578. font-family: SourceHanSansCN, SourceHanSansCN;
  579. font-weight: 500;
  580. color: #000B19;
  581. margin-right: 8px;
  582. }
  583. span:nth-of-type(3) {
  584. font-size: 18px;
  585. font-family: SourceHanSansCN, SourceHanSansCN;
  586. font-weight: bold;
  587. color: #000B19;
  588. }
  589. }
  590. }
  591. }
  592. }
  593. .el-row:nth-of-type(3) {
  594. margin-top: 15px;
  595. }
  596. .el-row:nth-of-type(4) {
  597. margin-top: 15px;
  598. .box-bottom_bg {
  599. width: 100%;
  600. min-height: 337px;
  601. p {
  602. font-size: 16px;
  603. font-family: SourceHanSansCN, SourceHanSansCN;
  604. font-weight: 500;
  605. color: #000B19;
  606. }
  607. .el-divider--horizontal {
  608. margin: 12px 0;
  609. }
  610. .el-image {
  611. width: 100%;
  612. height: 400px;
  613. }
  614. }
  615. }
  616. blockquote {
  617. padding: 10px 20px;
  618. margin: 0 0 20px;
  619. font-size: 17.5px;
  620. border-left: 5px solid #eee;
  621. }
  622. hr {
  623. margin-top: 20px;
  624. margin-bottom: 20px;
  625. border: 0;
  626. border-top: 1px solid #eee;
  627. }
  628. .col-item {
  629. margin-bottom: 20px;
  630. }
  631. ul {
  632. padding: 0;
  633. margin: 0;
  634. }
  635. ul {
  636. list-style-type: none;
  637. }
  638. h4 {
  639. margin-top: 0px;
  640. }
  641. h2 {
  642. margin-top: 10px;
  643. font-size: 26px;
  644. font-weight: 100;
  645. }
  646. p {
  647. margin-top: 10px;
  648. b {
  649. font-weight: 700;
  650. }
  651. }
  652. .update-log {
  653. ol {
  654. display: block;
  655. list-style-type: decimal;
  656. margin-block-start: 1em;
  657. margin-block-end: 1em;
  658. margin-inline-start: 0;
  659. margin-inline-end: 0;
  660. padding-inline-start: 40px;
  661. }
  662. }
  663. }</style>