deviceData.vue 32 KB

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