deviceData.vue 33 KB

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