deviceData.vue 31 KB

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