deviceData.vue 33 KB

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