deviceData.vue 34 KB

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