index.vue 18 KB

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