deviceData.vue 35 KB

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