deviceData.vue 32 KB

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