deviceData.vue 35 KB

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