deviceData.vue 33 KB

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