deviceData.vue 34 KB

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