deviceData.vue 34 KB

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