deviceData.vue 35 KB

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