deviceData.vue 33 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992002012022032042052062072082092102112122132142152162172182192202212222232242252262272282292302312322332342352362372382392402412422432442452462472482492502512522532542552562572582592602612622632642652662672682692702712722732742752762772782792802812822832842852862872882892902912922932942952962972982993003013023033043053063073083093103113123133143153163173183193203213223233243253263273283293303313323333343353363373383393403413423433443453463473483493503513523533543553563573583593603613623633643653663673683693703713723733743753763773783793803813823833843853863873883893903913923933943953963973983994004014024034044054064074084094104114124134144154164174184194204214224234244254264274284294304314324334344354364374384394404414424434444454464474484494504514524534544554564574584594604614624634644654664674684694704714724734744754764774784794804814824834844854864874884894904914924934944954964974984995005015025035045055065075085095105115125135145155165175185195205215225235245255265275285295305315325335345355365375385395405415425435445455465475485495505515525535545555565575585595605615625635645655665675685695705715725735745755765775785795805815825835845855865875885895905915925935945955965975985996006016026036046056066076086096106116126136146156166176186196206216226236246256266276286296306316326336346356366376386396406416426436446456466476486496506516526536546556566576586596606616626636646656666676686696706716726736746756766776786796806816826836846856866876886896906916926936946956966976986997007017027037047057067077087097107117127137147157167177187197207217227237247257267277287297307317327337347357367377387397407417427437447457467477487497507517527537547557567577587597607617627637647657667677687697707717727737747757767777787797807817827837847857867877887897907917927937947957967977987998008018028038048058068078088098108118128138148158168178188198208218228238248258268278288298308318328338348358368378388398408418428438448458468478488498508518528538548558568578588598608618628638648658668678688698708718728738748758768778788798808818828838848858868878888898908918928938948958968978988999009019029039049059069079089099109119129139149159169179189199209219229239249259269279289299309319329339349359369379389399409419429439449459469479489499509519529539549559569579589599609619629639649659669679689699709719729739749759769779789799809819829839849859869879889899909919929939949959969979989991000100110021003100410051006100710081009101010111012101310141015101610171018101910201021102210231024102510261027102810291030103110321033103410351036103710381039104010411042104310441045104610471048104910501051105210531054105510561057105810591060106110621063106410651066106710681069107010711072107310741075107610771078107910801081108210831084108510861087108810891090109110921093109410951096109710981099110011011102110311041105110611071108110911101111111211131114111511161117111811191120112111221123112411251126112711281129113011311132113311341135113611371138113911401141114211431144114511461147114811491150115111521153115411551156115711581159116011611162116311641165116611671168116911701171117211731174117511761177117811791180118111821183118411851186118711881189119011911192119311941195119611971198119912001201120212031204120512061207120812091210121112121213121412151216121712181219122012211222122312241225122612271228122912301231123212331234123512361237123812391240124112421243124412451246124712481249125012511252
  1. <template>
  2. <view class="device-data-container">
  3. <!-- 顶部时间戳和图标区域 -->
  4. <view class="device-data-wraper">
  5. <view class="top-bar">
  6. <view class="timestamp">
  7. {{formatDate(deviceInfo.addtime*1000)}}
  8. <u-icon name="reload" color="#0BBC58" style="margin-left: 12rpx" @click="refreshData"></u-icon>
  9. </view>
  10. <view class="icon-group">
  11. <!-- <view class="icon-item refresh-icon">
  12. <img class="copy-icon" :src="sim"/>
  13. </view>
  14. <view class="icon-item settings-icon" @click="openSettings">
  15. <img class="copy-icon" :src="setting"/>
  16. </view> -->
  17. <!-- <view class="icon-item info-icon">
  18. <img class="copy-icon" :src="edit"/>
  19. </view> -->
  20. </view>
  21. </view>
  22. <!-- 主要数据面板 -->
  23. <view class="main-data-panel" v-if="deviceInfo.type_id == 33">
  24. <view class="data-column-left">
  25. <view class="data-item">
  26. <text class="data-value">{{ deviceStatic.voltage }}</text>
  27. <text class="data-label">电压</text>
  28. </view>
  29. <view class="data-item">
  30. <text class="data-value">{{ deviceStatic.status }}</text>
  31. <text class="data-label">设备状态</text>
  32. </view>
  33. <view class="data-item">
  34. <text class="data-value">{{ deviceStatic.temperature }}</text>
  35. <text class="data-label">环境温度</text>
  36. </view>
  37. <view class="data-item">
  38. <text class="data-value">{{ deviceStatic.lightDuration }}</text>
  39. <text class="data-label">光照</text>
  40. </view>
  41. </view>
  42. <view class="data-column-left">
  43. <view class="data-item">
  44. <text class="data-value">{{ deviceStatic.ctrlMode }}</text>
  45. <text class="data-label">控制模式</text>
  46. </view>
  47. <view class="data-item">
  48. <text class="data-value">{{ deviceStatic.takePhotoIntervalMinutes }}</text>
  49. <text class="data-label">拍照上传频率</text>
  50. </view>
  51. <view class="data-item">
  52. <text class="data-value">{{ deviceStatic.humidity }}</text>
  53. <text class="data-label">环境湿度</text>
  54. </view>
  55. <view class="data-item">
  56. <text class="data-value">{{ deviceStatic.version }}</text>
  57. <text class="data-label">设备版本</text>
  58. </view>
  59. </view>
  60. <view class="data-column-right">
  61. <view class="device-image-container">
  62. <image class="device-image" :class="{'device-image2': deviceInfo.type_id == 33}" :src="formatDevImg" mode="aspectFit"></image>
  63. </view>
  64. </view>
  65. </view>
  66. <view class="main-data-panel" v-else>
  67. <view class="data-column-left">
  68. <view class="data-item">
  69. <text class="data-value">{{ deviceStatic.vbat }}</text>
  70. <text class="data-label">电量</text>
  71. </view>
  72. <view class="data-item">
  73. <text class="data-value">{{ deviceStatic.status }}</text>
  74. <text class="data-label">设备状态</text>
  75. </view>
  76. <view class="data-item">
  77. <text class="data-value">{{ deviceStatic.signal }}</text>
  78. <text class="data-label">信号强度</text>
  79. </view>
  80. </view>
  81. <view class="data-column-left">
  82. <view class="data-item">
  83. <text class="data-value">{{ deviceStatic.control }}</text>
  84. <text class="data-label">控制模式</text>
  85. </view>
  86. <view class="data-item">
  87. <text class="data-value">{{ deviceStatic.photo_fre }}min/天</text>
  88. <text class="data-label">拍照上传频率</text>
  89. </view>
  90. <view class="data-item">
  91. <text class="data-value">{{ deviceStatic.dver_num }}</text>
  92. <text class="data-label">设备版本</text>
  93. </view>
  94. </view>
  95. <view class="data-column-right">
  96. <view class="device-image-container">
  97. <image class="device-image" :src="formatDevImg" mode="aspectFit"></image>
  98. </view>
  99. </view>
  100. </view>
  101. </view>
  102. <!-- 图表区域 -->
  103. <view class="chart-section">
  104. <view class="chart-header">
  105. <view class="chart-tabs">
  106. <view
  107. v-for="(tab, index) in chartTabs"
  108. :key="index"
  109. class="chart-tab-item"
  110. :class="{ active: activeChartTab === index }"
  111. @click="switchChartTab(index)"
  112. >
  113. {{ tab.name }}
  114. </view>
  115. </view>
  116. <!-- <view class="chart-dropdown">
  117. <text class="iconfont dropdown-icon">&#xe606;</text>
  118. </view> -->
  119. </view>
  120. <view class="chart-content">
  121. <view class="chart-canvas-container" v-if="!show" :key="chartKey">
  122. <!-- <div id="tempChart" class="chart-canvas"></div> -->
  123. <qiun-data-charts type="line" :chartData="chartData" :canvas2d="true" :inScrollView="true" :opts="opts" :ontouch="true" v-show="xData.length"/>
  124. </view>
  125. </view>
  126. </view>
  127. <!-- 历史数据表格 -->
  128. <view class="history-section">
  129. <view class="history-header">
  130. <text class="history-title">历史数据</text>
  131. </view>
  132. <view class="history-table">
  133. <view class="table-container">
  134. <!-- 固定列 -->
  135. <!-- <view class="fixed-column">
  136. <view class="fixed-header">
  137. <text class="header-cell fixed">上报时间</text>
  138. </view>
  139. <view class="fixed-body">
  140. <view
  141. v-for="(item, index) in historyData"
  142. :key="index"
  143. class="fixed-row"
  144. :class="{ even: index % 2 === 0 }"
  145. >
  146. <view class="body-cell fixed">{{ item.UPDATE_DATE }}</view>
  147. </view>
  148. </view>
  149. </view> -->
  150. <!-- 可滑动列 -->
  151. <view class="scrollable-column">
  152. <view class="scrollable-header">
  153. <text class="header-cell" v-for="(item, index) in title" :key="index">{{ item.label }}</text>
  154. </view>
  155. <view class="scrollable-body">
  156. <view
  157. v-for="(item, index) in historyData"
  158. :key="index"
  159. class="scrollable-row"
  160. >
  161. <view class="body-cell" v-for="t in title" :key="t.value">{{ item[t.value] }}</view>
  162. </view>
  163. </view>
  164. </view>
  165. </view>
  166. </view>
  167. <view class="pagination">
  168. <text class="pagination-btn prev-btn" @click="prevPage">上一页</text>
  169. <text class="pagination-info">{{currentPage}}/{{totalPages}}</text>
  170. <text class="pagination-btn next-btn" @click="nextPage">下一页</text>
  171. </view>
  172. </view>
  173. <u-popup v-model="show" mode="bottom" border-radius="20">
  174. <view style="height:70vh">
  175. <view class="tabs-container">
  176. <view class="tabs-item" @click="switchTab(0)" :class="{ active: activeTab === 0 }" v-if="data_iccid">数据SIM卡流量</view>
  177. <view class="tabs-item" @click="switchTab(1)" :class="{ active: activeTab === 1 }">图片SIM卡流量</view>
  178. </view>
  179. <view class="sim-container" v-if="activeTab === 0">
  180. <view class="sim-item">
  181. <text class="sim-label">ICCID:</text>
  182. <text class="sim-value">{{ deviceInfoStatic.iccid }}</text>
  183. </view>
  184. <view class="sim-item">
  185. <text class="sim-label">总流量:</text>
  186. <text class="sim-value">{{ deviceInfoStatic.total }}</text>
  187. </view>
  188. <view class="sim-item">
  189. <text class="sim-label">状态:</text>
  190. <text class="sim-value">{{ deviceInfoStatic.status }}</text>
  191. </view>
  192. <view class="sim-item">
  193. <text class="sim-label">到期时间:</text>
  194. <text class="sim-value">{{ deviceInfoStatic.expire }}</text>
  195. </view>
  196. <view class="sim-item">
  197. <text class="sim-label">厂商名称:</text>
  198. <text class="sim-value">{{ deviceInfoStatic.company }}</text>
  199. </view>
  200. <view class="sim-item">
  201. <text class="sim-label">已使用:</text>
  202. <text class="sim-value"><text style="color: #0BBC58">{{ deviceInfoStatic.used || ''}}</text>/{{ deviceInfoStatic.total || '' }}</text>
  203. </view>
  204. <view class="sim-item">
  205. <text class="sim-value">
  206. <u-line-progress active-color="#0BBC58" :percent="deviceInfoStatic.used / deviceInfoStatic.total * 100" :show-percent="false"></u-line-progress>
  207. </text>
  208. </view>
  209. </view>
  210. <view class="sim-container" v-if="activeTab === 1">
  211. <view class="sim-item" style="display:flex;align-items: center;height:80rpx;">
  212. <text class="sim-label">ICCID:</text>
  213. <text v-if="show1" style="margin-right: 10rpx">{{ photo_iccid }}</text>
  214. <text class="sim-value" style="color: #0BBC58;" @click="changeSim" v-if="show1">
  215. 更换SIM卡
  216. </text>
  217. <view v-else class="sim-value-change">
  218. <u-input v-model="data_iccidInput" placeholder="请输入ICCID" class="sim-value"></u-input>
  219. <view class="sim-value-button" size="small" @click="changeSimHandler">确认</view>
  220. <view class="sim-value-button" size="small" @click="show1 = true">取消</view>
  221. </view>
  222. </view>
  223. </view>
  224. </view>
  225. </u-popup>
  226. <floatButton v-if="false">
  227. <view slot="icon">
  228. <view class="general-border">
  229. <image :src="general" class="general-icon"></image>
  230. </view>
  231. </view>
  232. <view slot="expanded">
  233. <view class="general-images">
  234. <view class="general-image edit-border" :class="{'edit-border2':isShowPhoto}" @click="editData">
  235. <image :src="editBorder" class="image-icon"></image>
  236. </view>
  237. <view class="general-image sim-border" :class="{'sim-border2':isShowPhoto}" @click="simData">
  238. <image :src="simBorder" class="image-icon"></image>
  239. </view>
  240. <view class="general-image setting-border" :class="{'setting-border2':isShowPhoto}" @click="openSettings">
  241. <image :src="settingBorder" class="image-icon"></image>
  242. </view>
  243. <view class="general-image photo-border" @click="openPhoto" v-if="isShowPhoto">
  244. <image :src="photoBorder" class="image-icon"></image>
  245. </view>
  246. </view>
  247. </view>
  248. </floatButton>
  249. </view>
  250. </template>
  251. <script>
  252. import Circulation from '../../../static/js/equipState_dict.json';
  253. import floatButton from './floating-button.vue';
  254. let chartInstance = null;
  255. export default {
  256. name: 'DeviceData',
  257. props:{
  258. deviceInfo:{
  259. type:Object,
  260. default:()=>({}),
  261. },
  262. deviceStatic:{
  263. type:Object,
  264. default:()=>({}),
  265. },
  266. polylineList:{
  267. type:Array,
  268. default:()=>[],
  269. },
  270. deviceHistoryList:{
  271. type:Array,
  272. default:()=>[],
  273. },
  274. totalPage:{
  275. type:Number,
  276. default:0
  277. },
  278. currentPage:{
  279. type:Number,
  280. default:0
  281. },
  282. page_size:{
  283. type:Number,
  284. default:10
  285. },
  286. title:{
  287. type:Array,
  288. default:()=>[],
  289. },
  290. },
  291. components: {
  292. floatButton,
  293. },
  294. data() {
  295. return {
  296. setting:'https://s3.hnyfwlw.com/webstaticimg/bigdata_app/newImg/home/setting.png',
  297. general:'https://s3.hnyfwlw.com/webstaticimg/bigdata_app/newImg/home/general.png',
  298. editBorder:'https://s3.hnyfwlw.com/webstaticimg/bigdata_app/newImg/home/editBorder.png',
  299. settingBorder:'https://s3.hnyfwlw.com/webstaticimg/bigdata_app/newImg/home/settingBorder.png',
  300. simBorder:'https://s3.hnyfwlw.com/webstaticimg/bigdata_app/newImg/home/simBorder.png',
  301. devImage:'https://s3.hnyfwlw.com/webstaticimg/bigdata_app/image/cbd.png',
  302. photoBorder:'https://s3.hnyfwlw.com/webstaticimg/bigdata_app/newImg/home/photoBorder.png',
  303. devImage:'https://s3.hnyfwlw.com/webstaticimg/bigdata_app/image/cbd.png',
  304. baseDevice:'https://s3.hnyfwlw.com/webstaticimg/bigdata_app/image',
  305. devImg:'',
  306. activeTab: 0,
  307. edit:'https://s3.hnyfwlw.com/webstaticimg/bigdata_app/newImg/home/edit.png',
  308. sim:'https://s3.hnyfwlw.com/webstaticimg/bigdata_app/newImg/home/sim.png',
  309. show:false,
  310. isShowPhoto:false,
  311. show1:true,
  312. equipStateDict:{},
  313. chartTabs: [
  314. { name: '温度', id: 'new_tem' },
  315. { name: '湿度', id: 'new_hum' },
  316. ],
  317. opts: {
  318. type: 'line',
  319. xAxis: {
  320. disableGrid: true,
  321. itemCount: 3,
  322. scrollShow: true
  323. },
  324. yAxis: {
  325. disableGrid: true,
  326. gridType: 'dash',
  327. splitNumber: 5,
  328. min: 0,
  329. format: (val) => {
  330. return Math.round(val)
  331. }
  332. },
  333. extra: {
  334. line: {
  335. type: 'curve'
  336. },
  337. tooltip: {
  338. format: {
  339. name: '',
  340. value: (val) => Math.round(val)
  341. }
  342. }
  343. },
  344. legend: {
  345. },
  346. enableScroll: true
  347. },
  348. xData:[],
  349. yData:[],
  350. activeChartTab: 0,
  351. historyData: [],
  352. data_iccid:'',
  353. data_iccidInput:'',
  354. deviceInfoStatic:{},
  355. photo_iccid:'',
  356. chartData: {},
  357. chartKey: 0
  358. };
  359. },
  360. mounted(){
  361. this.equipStateDict = Circulation
  362. },
  363. computed: {
  364. totalPages(){
  365. return Math.ceil(this.totalPage / this.page_size) || 1
  366. },
  367. formatDevImg() {
  368. if(this.devImg == 'lowcbd'){
  369. return 'https://s3.hnyfwlw.com/webstaticimg/bigdata_pc/menu/cbd.png';
  370. }
  371. return `https://s3.hnyfwlw.com/webstaticimg/bigdata_app/image/${this.devImg}.png`;
  372. },
  373. },
  374. watch:{
  375. polylineList:{
  376. handler(newVal, oldVal){
  377. this.xData = newVal.map(item => this.formatDate(new Date(item.addtime)));
  378. this.yData = newVal.map(item => Number(item.tem) || 0);
  379. if(this.xData.length){
  380. this.initChart();
  381. }
  382. },
  383. deep:true,
  384. immediate:true,
  385. },
  386. deviceInfo:{
  387. handler(newVal, oldVal){
  388. if (newVal.type_id == '34'){
  389. this.devImg = 'sycb1'
  390. this.isShowPhoto = true
  391. } else {
  392. this.devImg = 'sycb2'
  393. this.isShowPhoto = true
  394. }
  395. },
  396. deep:true,
  397. immediate:true,
  398. },
  399. deviceHistoryList:{
  400. handler(newVal, oldVal){
  401. this.historyData = []
  402. if(newVal.length > 0){
  403. newVal.forEach(item=>{
  404. this.historyData.push(item)
  405. })
  406. }
  407. },
  408. deep:true,
  409. immediate:true,
  410. },
  411. },
  412. methods: {
  413. async openPhoto(){
  414. const res = await this.$myRequest({
  415. url: '/api/api_gateway?method=forecast.send_control.admin_device_control',
  416. method: 'POST',
  417. data: {
  418. device_type_id: this.deviceInfo.type,
  419. d_id: this.deviceInfo.d_id,
  420. cmd: 'takephoto',
  421. },
  422. });
  423. if(res){
  424. this.$u.toast('拍照成功')
  425. }
  426. },
  427. editData(){
  428. uni.navigateTo({
  429. url: '/pages/afterSale/addafter?d_id=' + this.deviceInfo.d_id +'&device_id='+this.deviceInfo.id + '&device_type=' + this.deviceInfo.type,
  430. })
  431. },
  432. prevPage(){
  433. this.$emit('prevPage', this.currentPage)
  434. },
  435. nextPage(){
  436. this.$emit('nextPage', this.currentPage)
  437. },
  438. changeSim(){
  439. this.show1 = false
  440. },
  441. changeSimHandler(){
  442. if(this.data_iccidInput){
  443. this.changeSimAction(this.data_iccidInput);
  444. }else{
  445. this.$u.toast('请输入ICCID')
  446. }
  447. },
  448. switchTab(index){
  449. this.activeTab = index
  450. },
  451. simData(){
  452. this.show = true
  453. },
  454. async changeSimAction(simid){
  455. const res = await this.$myRequest({
  456. url: '/api/api_gateway?method=forecast.send_control.device_sim_update',
  457. method: 'POST',
  458. data: {
  459. d_id: this.deviceInfo.d_id,
  460. simid,
  461. },
  462. });
  463. if(res){
  464. this.$u.toast('更换成功')
  465. this.show1 = true
  466. this.data_iccidInput = ''
  467. this.getSimNew()
  468. }
  469. },
  470. async getSimNew(){
  471. const res = await this.$myRequest({
  472. url: '/api/api_gateway?method=forecast.send_control.device_sim_new',
  473. method: 'POST',
  474. data: {
  475. d_id: this.deviceInfo.d_id,
  476. },
  477. });
  478. if(res){
  479. const data_iccid = res.data_iccid
  480. this.data_iccid = data_iccid
  481. this.photo_iccid = res.photo_iccid
  482. if(data_iccid){
  483. this.getQueryNew(data_iccid);
  484. }else{
  485. this.activeTab = 1
  486. }
  487. }
  488. },
  489. async getQueryNew(data_iccid){
  490. const res = await this.$myRequest({
  491. url: '/api/api_gateway?method=forecast.send_control.sim_query_new',
  492. method: 'POST',
  493. data: {
  494. iccid: data_iccid,
  495. },
  496. });
  497. this.deviceInfoStatic = res
  498. },
  499. async refreshData(){
  500. const res = await this.$myRequest({
  501. url: '/api/api_gateway?method=forecast.send_control.get_device_config',
  502. method: 'POST',
  503. data: {
  504. device_type_id: this.deviceInfo.type,
  505. d_id: this.deviceInfo.d_id,
  506. control_type:'data',
  507. device_model: this.deviceInfo.device_model || 0,
  508. },
  509. });
  510. if(res){
  511. // 弹出提示
  512. this.$u.toast('刷新成功')
  513. }
  514. },
  515. getStateDict(item){
  516. return item.ws == 0 ? '待机' : this.equipStateDict.lamp.value[item.lamp]
  517. },
  518. getRpsDict(item){
  519. return this.equipStateDict.rps.value[item.rps]
  520. },
  521. getTpsDict(item){
  522. return this.equipStateDict.tps.value[item.tps]
  523. },
  524. getLpsDict(item){
  525. return this.equipStateDict.lps.value[item.lps]
  526. },
  527. openSettings(){
  528. uni.navigateTo({
  529. url: '/pages/sy/deviceControl?deviceId=' + this.deviceInfo.id + '&d_id=' + this.deviceInfo.d_id,
  530. });
  531. },
  532. initChart() {
  533. this.$nextTick(() => {
  534. this.updateChartsData();
  535. });
  536. },
  537. // 格式化时间
  538. formatDate(dateString) {
  539. const date = new Date(dateString);
  540. const year = date.getFullYear();
  541. const month = String(date.getMonth() + 1).padStart(2, '0');
  542. const day = String(date.getDate()).padStart(2, '0');
  543. return `${year}-${month}-${day}`;
  544. },
  545. drawChart() {
  546. // 销毁已有的图表实例
  547. if (chartInstance) {
  548. chartInstance.dispose();
  549. }
  550. // 初始化图表
  551. const chartDom = document.getElementById('tempChart');
  552. if (!chartDom) return;
  553. // chartInstance = echarts.init(chartDom);
  554. if(!chartInstance){
  555. return
  556. }
  557. const option = {
  558. backgroundColor: '#FFFFFF',
  559. tooltip: {
  560. trigger: 'axis'
  561. },
  562. legend: {
  563. show: false
  564. },
  565. grid: {
  566. left: '3%',
  567. right: '4%',
  568. bottom: '3%',
  569. top: '8%',
  570. containLabel: true
  571. },
  572. xAxis: {
  573. type: 'category',
  574. boundaryGap: false,
  575. data: this.xData,
  576. axisLine: {
  577. lineStyle: {
  578. color: '#CCCCCC'
  579. }
  580. },
  581. axisLabel: {
  582. fontSize: 10,
  583. color: '#999999'
  584. },
  585. splitLine: {
  586. show: false
  587. }
  588. },
  589. yAxis: {
  590. type: 'value',
  591. splitNumber: 4,
  592. axisLine: {
  593. show: true,
  594. lineStyle: {
  595. color: '#CCCCCC'
  596. }
  597. },
  598. axisLabel: {
  599. fontSize: 10,
  600. color: '#999999'
  601. },
  602. splitLine: {
  603. show: true,
  604. lineStyle: {
  605. color: '#E5E5E5',
  606. type: 'dashed'
  607. }
  608. }
  609. },
  610. series: [
  611. {
  612. name: this.chartTabs[this.activeChartTab].name,
  613. type: 'line',
  614. smooth: true,
  615. data: this.yData,
  616. lineStyle: {
  617. color: '#0BBC58',
  618. width: 2
  619. },
  620. itemStyle: {
  621. color: '#0BBC58',
  622. borderColor: '#0BBC58',
  623. borderWidth: 2
  624. },
  625. symbol: 'circle',
  626. symbolSize: 6,
  627. // areaStyle: {
  628. // color: new echarts.graphic.LinearGradient(0, 0, 0, 1, [
  629. // {
  630. // offset: 0,
  631. // color: 'rgba(11, 188, 88, 0.3)'
  632. // },
  633. // {
  634. // offset: 1,
  635. // color: 'rgba(11, 188, 88, 0)'
  636. // }
  637. // ])
  638. // }
  639. }
  640. ]
  641. };
  642. chartInstance.setOption(option);
  643. // 监听窗口大小变化,调整图表大小
  644. window.addEventListener('resize', () => {
  645. chartInstance.resize();
  646. });
  647. },
  648. switchChartTab(index) {
  649. this.activeChartTab = index;
  650. // 根据不同标签切换数据
  651. if (this.chartTabs[index].id === 'new_tem') {
  652. this.yData = this.polylineList.map(item => Number(item.hum) || 0);
  653. } else if (this.chartTabs[index].id === 'new_hum') {
  654. this.yData = this.polylineList.map(item => Number(item.tem) || 0);
  655. }
  656. this.$nextTick(() => {
  657. // this.drawChart();
  658. this.updateChartsData();
  659. });
  660. },
  661. updateChartsData(){
  662. const categories = this.xData.length ? this.xData : [];
  663. const lineData = {
  664. categories,
  665. series: [
  666. {
  667. name: this.chartTabs[this.activeChartTab].name,
  668. data: this.yData
  669. }
  670. ]
  671. };
  672. this.chartData = lineData;
  673. }
  674. }
  675. };
  676. </script>
  677. <style lang="scss" scoped>
  678. .device-data-container {
  679. width: 100%;
  680. }
  681. .device-data-wraper{
  682. padding: 16rpx;
  683. background: #ffffff;
  684. border-radius: 16rpx;
  685. }
  686. /* 顶部时间戳和图标区域 */
  687. .top-bar {
  688. display: flex;
  689. justify-content: space-between;
  690. align-items: center;
  691. padding: 16rpx 0;
  692. .timestamp {
  693. font-size: 28rpx;
  694. font-family: 'Source Han Sans CN VF', sans-serif;
  695. font-weight: 400;
  696. color: #999999;
  697. }
  698. .icon-group {
  699. display: flex;
  700. gap: 10rpx;
  701. .icon-item {
  702. width: 56rpx;
  703. height: 56rpx;
  704. display: flex;
  705. align-items: center;
  706. justify-content: center;
  707. border-radius: 50%;
  708. .iconfont {
  709. font-size: 36rpx;
  710. }
  711. &.refresh-icon .iconfont {
  712. color: #0BBC58;
  713. }
  714. &.settings-icon .iconfont {
  715. color: #999999;
  716. }
  717. &.info-icon .iconfont {
  718. color: #999999;
  719. }
  720. }
  721. }
  722. }
  723. .sim-container{
  724. padding: 0 20rpx;
  725. .sim-item{
  726. margin-bottom: 20rpx;
  727. .sim-value-change{
  728. display: flex;
  729. align-items: center;
  730. .sim-value-button{
  731. padding: 8rpx 16rpx;
  732. border-radius: 8rpx;
  733. font-size: 24rpx;
  734. font-family: 'Source Han Sans CN VF', sans-serif;
  735. font-weight: 400;
  736. color: #042118;
  737. background: #0BBC58;
  738. color: #ffffff;
  739. margin-left: 20rpx;
  740. }
  741. }
  742. }
  743. }
  744. .general-border{
  745. width: 100rpx;
  746. height: 100rpx;
  747. border-radius: 50%;
  748. display: flex;
  749. align-items: center;
  750. justify-content: center;
  751. background: #ffffff;
  752. transition: all 0.3s ease;
  753. box-shadow: 0 4px 12px rgba(0, 0, 0, 0.15);
  754. .general-icon{
  755. width: 50rpx;
  756. height: 50rpx;
  757. border-radius: 50%;
  758. }
  759. }
  760. .status-icon{
  761. width: 12rpx;
  762. height: 12rpx;
  763. border-radius: 50%;
  764. background: #B6BECA;
  765. margin-right: 8rpx;
  766. }
  767. .success-icon{
  768. background: #0BBC58;
  769. }
  770. .warning-icon{
  771. background: #F8B610;
  772. }
  773. .error-icon{
  774. background: #FF6B6B;
  775. }
  776. .general-images{
  777. display: flex;
  778. align-items: center;
  779. justify-content: center;
  780. position: relative;
  781. .general-image{
  782. position: absolute;
  783. width: 80rpx;
  784. height: 80rpx;
  785. border-radius: 50%;
  786. background: #ffffff;
  787. box-shadow: 0 4px 12px rgba(0, 0, 0, 0.15);
  788. display:flex;
  789. align-items: center;
  790. justify-content: center;
  791. .image-icon{
  792. width: 45rpx;
  793. height: 45rpx;
  794. }
  795. }
  796. .edit-border{
  797. top: 45rpx;
  798. left: -110rpx;
  799. }
  800. .sim-border{
  801. top: -125rpx;
  802. left: -110rpx;
  803. }
  804. .setting-border{
  805. top: -40rpx;
  806. left: -180rpx;
  807. }
  808. .edit-border2{
  809. top: 60rpx;
  810. left: -70rpx;
  811. }
  812. .sim-border2{
  813. top: -75rpx;
  814. left: -150rpx;
  815. }
  816. .setting-border2{
  817. top: 20rpx;
  818. left: -150rpx;
  819. }
  820. .photo-border{
  821. top: -135rpx;
  822. left: -70rpx;
  823. }
  824. }
  825. /* 主要数据面板 */
  826. .main-data-panel {
  827. display: flex;
  828. background: #FFFFFF;
  829. border-radius: 16rpx;
  830. margin-bottom: 16rpx;
  831. .data-column-left {
  832. flex: 1;
  833. display: flex;
  834. flex-direction: column;
  835. gap: 24rpx;
  836. .data-item {
  837. display: flex;
  838. flex-direction: column;
  839. gap: 8rpx;
  840. .data-label {
  841. font-size: 24rpx;
  842. font-family: 'Source Han Sans CN VF', sans-serif;
  843. font-weight: 400;
  844. color: #999999;
  845. }
  846. .data-value {
  847. font-size: 24rpx;
  848. font-family: 'Source Han Sans CN VF', sans-serif;
  849. font-weight: 700;
  850. color: #042118;
  851. &.temp-value {
  852. color: #FF6B6B;
  853. }
  854. }
  855. .data-unit {
  856. font-size: 24rpx;
  857. font-family: 'Source Han Sans CN VF', sans-serif;
  858. font-weight: 400;
  859. color: #999999;
  860. }
  861. }
  862. }
  863. .data-column-right {
  864. flex: 1;
  865. display: flex;
  866. flex-direction: column;
  867. align-items: center;
  868. gap: 16rpx;
  869. .device-image-container {
  870. position: relative;
  871. width: 200rpx;
  872. height: 200rpx;
  873. display: flex;
  874. align-items: center;
  875. justify-content: center;
  876. .device-glow {
  877. position: absolute;
  878. width: 180rpx;
  879. height: 180rpx;
  880. background: radial-gradient(circle, rgba(11, 188, 88, 0.3) 0%, rgba(11, 188, 88, 0) 70%);
  881. border-radius: 50%;
  882. }
  883. .device-image {
  884. position: relative;
  885. width: 220rpx;
  886. height: 340rpx;
  887. z-index: 1;
  888. top: 20rpx;
  889. }
  890. .device-image2 {
  891. top: 70rpx;
  892. }
  893. }
  894. .device-info {
  895. display: flex;
  896. flex-direction: column;
  897. gap: 12rpx;
  898. width: 100%;
  899. .info-row {
  900. display: flex;
  901. justify-content: space-between;
  902. align-items: center;
  903. .info-label {
  904. font-size: 24rpx;
  905. font-family: 'Source Han Sans CN VF', sans-serif;
  906. font-weight: 400;
  907. color: #999999;
  908. }
  909. .info-value {
  910. font-size: 36rpx;
  911. font-family: 'Source Han Sans CN VF', sans-serif;
  912. font-weight: 700;
  913. color: #042118;
  914. }
  915. .info-version {
  916. font-size: 24rpx;
  917. font-family: 'Source Han Sans CN VF', sans-serif;
  918. font-weight: 400;
  919. color: #999999;
  920. }
  921. .info-label-small {
  922. font-size: 24rpx;
  923. font-family: 'Source Han Sans CN VF', sans-serif;
  924. font-weight: 400;
  925. color: #999999;
  926. }
  927. }
  928. }
  929. }
  930. }
  931. .tabs-container{
  932. display:flex;
  933. align-items: center;
  934. gap: 24rpx;
  935. padding: 24rpx;
  936. .tabs-item{
  937. font-size: 28rpx;
  938. font-family: 'Source Han Sans CN VF', sans-serif;
  939. font-weight: 500;
  940. color: #999999;
  941. }
  942. .tabs-item.active{
  943. color: #0BBC58;
  944. }
  945. }
  946. /* 图表区域 */
  947. .chart-section {
  948. background: #FFFFFF;
  949. border-radius: 16rpx;
  950. padding: 24rpx 32rpx 32rpx;
  951. margin: 24rpx 0;
  952. .chart-header {
  953. display: flex;
  954. justify-content: space-between;
  955. align-items: center;
  956. margin-bottom: 24rpx;
  957. .chart-tabs {
  958. display: flex;
  959. gap: 48rpx;
  960. overflow-x: auto;
  961. white-space: nowrap;
  962. .chart-tab-item {
  963. font-size: 28rpx;
  964. font-family: 'Source Han Sans CN VF', sans-serif;
  965. font-weight: 500;
  966. color: #999999;
  967. position: relative;
  968. padding-bottom: 8rpx;
  969. transition: all 0.3s;
  970. &.active {
  971. color: #0BBC58;
  972. font-weight: 700;
  973. &::after {
  974. content: '';
  975. position: absolute;
  976. bottom: 0;
  977. left: 0;
  978. right: 0;
  979. height: 4rpx;
  980. background: #0BBC58;
  981. border-radius: 2rpx;
  982. }
  983. }
  984. }
  985. }
  986. .chart-dropdown {
  987. .dropdown-icon {
  988. font-size: 28rpx;
  989. color: #999999;
  990. }
  991. }
  992. }
  993. .chart-content {
  994. .chart-legend {
  995. display: flex;
  996. justify-content: space-between;
  997. align-items: center;
  998. margin-bottom: 16rpx;
  999. .legend-item {
  1000. display: flex;
  1001. align-items: center;
  1002. gap: 8rpx;
  1003. .legend-dot {
  1004. width: 16rpx;
  1005. height: 16rpx;
  1006. background: #0BBC58;
  1007. border-radius: 50%;
  1008. }
  1009. .legend-text {
  1010. font-size: 24rpx;
  1011. font-family: 'Source Han Sans CN VF', sans-serif;
  1012. font-weight: 400;
  1013. color: #042118;
  1014. }
  1015. }
  1016. .legend-average {
  1017. .average-text {
  1018. font-size: 24rpx;
  1019. font-family: 'Source Han Sans CN VF', sans-serif;
  1020. font-weight: 400;
  1021. color: #999999;
  1022. }
  1023. }
  1024. }
  1025. .chart-canvas-container {
  1026. width: 100%;
  1027. height: 400rpx;
  1028. .chart-canvas {
  1029. width: 100%;
  1030. height: 100%;
  1031. }
  1032. }
  1033. }
  1034. }
  1035. .copy-icon{
  1036. width: 40rpx;
  1037. height: 40rpx;
  1038. }
  1039. /* 历史数据表格 */
  1040. .history-section {
  1041. background: #FFFFFF;
  1042. border-radius: 16rpx;
  1043. padding: 24rpx 32rpx 32rpx;
  1044. .history-header {
  1045. margin-bottom: 24rpx;
  1046. .history-title {
  1047. font-size: 32rpx;
  1048. font-family: 'Source Han Sans CN VF', sans-serif;
  1049. font-weight: 700;
  1050. color: #042118;
  1051. }
  1052. }
  1053. .history-table {
  1054. margin-bottom: 24rpx;
  1055. .table-container {
  1056. display: flex;
  1057. position: relative;
  1058. /* 固定列 */
  1059. .fixed-column {
  1060. width: 250rpx;
  1061. position: relative;
  1062. z-index: 2;
  1063. background: #FFFFFF;
  1064. .fixed-header {
  1065. border-bottom: 2rpx solid #F0F0F0;
  1066. padding: 16rpx 0;
  1067. .header-cell.fixed {
  1068. font-size: 24rpx;
  1069. font-family: 'Source Han Sans CN VF', sans-serif;
  1070. font-weight: 500;
  1071. color: #666666;
  1072. text-align: left;
  1073. padding-left: 0;
  1074. }
  1075. }
  1076. .fixed-body {
  1077. .fixed-row {
  1078. padding: 16rpx 0;
  1079. border-bottom: 1rpx solid #F5F5F5;
  1080. height: 80rpx;
  1081. display: flex;
  1082. width: 260rpx;
  1083. align-items: center;
  1084. .body-cell.fixed {
  1085. font-size: 24rpx;
  1086. font-family: 'Source Han Sans CN VF', sans-serif;
  1087. font-weight: 400;
  1088. width: 260rpx;
  1089. color: #042118;
  1090. text-align: left;
  1091. padding-left: 0;
  1092. // 超出隐藏
  1093. overflow: hidden;
  1094. text-overflow: ellipsis;
  1095. white-space: nowrap;
  1096. }
  1097. }
  1098. }
  1099. }
  1100. /* 可滑动列 */
  1101. .scrollable-column {
  1102. flex: 1;
  1103. overflow-x: auto;
  1104. white-space: nowrap;
  1105. /* 隐藏滚动条 */
  1106. &::-webkit-scrollbar {
  1107. display: none;
  1108. }
  1109. scrollbar-width: none;
  1110. .scrollable-header {
  1111. display: flex;
  1112. border-bottom: 2rpx solid #F0F0F0;
  1113. padding: 20rpx 0;
  1114. .header-cell {
  1115. min-width: 160rpx;
  1116. font-size: 24rpx;
  1117. font-family: 'Source Han Sans CN VF', sans-serif;
  1118. font-weight: 500;
  1119. color: #666666;
  1120. text-align: center;
  1121. // 超出隐藏
  1122. overflow: hidden;
  1123. text-overflow: ellipsis;
  1124. white-space: nowrap;
  1125. margin-right: 10rpx;
  1126. &:first-child {
  1127. min-width: 220rpx;
  1128. }
  1129. }
  1130. }
  1131. .scrollable-body {
  1132. .scrollable-row {
  1133. display: flex;
  1134. padding: 16rpx 0;
  1135. border-bottom: 1rpx solid #F5F5F5;
  1136. height: 80rpx;
  1137. align-items: center;
  1138. .body-cell {
  1139. min-width: 160rpx;
  1140. font-size: 24rpx;
  1141. font-family: 'Source Han Sans CN VF', sans-serif;
  1142. font-weight: 400;
  1143. color: #042118;
  1144. text-align: center;
  1145. margin-right: 10rpx;
  1146. display: flex;
  1147. align-items: center;
  1148. justify-content: center;
  1149. &:first-child {
  1150. min-width: 220rpx;
  1151. }
  1152. }
  1153. }
  1154. }
  1155. }
  1156. }
  1157. }
  1158. .pagination {
  1159. display: flex;
  1160. justify-content: space-between;
  1161. align-items: center;
  1162. .pagination-btn {
  1163. font-size: 24rpx;
  1164. font-family: 'Source Han Sans CN VF', sans-serif;
  1165. font-weight: 400;
  1166. padding: 6rpx 18rpx;
  1167. border-radius: 8rpx;
  1168. transition: all 0.3s;
  1169. &.prev-btn {
  1170. color: #656565;
  1171. border: 1px solid #E4E7ED;
  1172. }
  1173. &.next-btn {
  1174. color: #0BBC58;
  1175. border: 1px solid #0BBC58;
  1176. }
  1177. }
  1178. .pagination-info {
  1179. font-size: 28rpx;
  1180. font-family: 'Source Han Sans CN VF', sans-serif;
  1181. font-weight: 400;
  1182. color: #999999;
  1183. }
  1184. }
  1185. }
  1186. </style>