deviceData.vue 34 KB

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