deviceData.vue 33 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992002012022032042052062072082092102112122132142152162172182192202212222232242252262272282292302312322332342352362372382392402412422432442452462472482492502512522532542552562572582592602612622632642652662672682692702712722732742752762772782792802812822832842852862872882892902912922932942952962972982993003013023033043053063073083093103113123133143153163173183193203213223233243253263273283293303313323333343353363373383393403413423433443453463473483493503513523533543553563573583593603613623633643653663673683693703713723733743753763773783793803813823833843853863873883893903913923933943953963973983994004014024034044054064074084094104114124134144154164174184194204214224234244254264274284294304314324334344354364374384394404414424434444454464474484494504514524534544554564574584594604614624634644654664674684694704714724734744754764774784794804814824834844854864874884894904914924934944954964974984995005015025035045055065075085095105115125135145155165175185195205215225235245255265275285295305315325335345355365375385395405415425435445455465475485495505515525535545555565575585595605615625635645655665675685695705715725735745755765775785795805815825835845855865875885895905915925935945955965975985996006016026036046056066076086096106116126136146156166176186196206216226236246256266276286296306316326336346356366376386396406416426436446456466476486496506516526536546556566576586596606616626636646656666676686696706716726736746756766776786796806816826836846856866876886896906916926936946956966976986997007017027037047057067077087097107117127137147157167177187197207217227237247257267277287297307317327337347357367377387397407417427437447457467477487497507517527537547557567577587597607617627637647657667677687697707717727737747757767777787797807817827837847857867877887897907917927937947957967977987998008018028038048058068078088098108118128138148158168178188198208218228238248258268278288298308318328338348358368378388398408418428438448458468478488498508518528538548558568578588598608618628638648658668678688698708718728738748758768778788798808818828838848858868878888898908918928938948958968978988999009019029039049059069079089099109119129139149159169179189199209219229239249259269279289299309319329339349359369379389399409419429439449459469479489499509519529539549559569579589599609619629639649659669679689699709719729739749759769779789799809819829839849859869879889899909919929939949959969979989991000100110021003100410051006100710081009101010111012101310141015101610171018101910201021102210231024102510261027102810291030103110321033103410351036103710381039104010411042104310441045104610471048104910501051105210531054105510561057105810591060106110621063106410651066106710681069107010711072107310741075107610771078107910801081108210831084108510861087108810891090109110921093109410951096109710981099110011011102110311041105110611071108110911101111111211131114111511161117111811191120112111221123112411251126112711281129113011311132113311341135113611371138113911401141114211431144114511461147114811491150115111521153115411551156115711581159116011611162116311641165116611671168116911701171117211731174117511761177117811791180118111821183118411851186118711881189119011911192119311941195119611971198119912001201120212031204120512061207120812091210121112121213121412151216121712181219122012211222122312241225122612271228122912301231123212331234123512361237123812391240
  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.dver }}</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.tph || '' }}℃</text>
  57. <text class="data-label">高温限值</text>
  58. </view>
  59. </view>
  60. <view class="data-column-right">
  61. <view class="device-image-container">
  62. <image class="device-image" :src="formatDevImg" mode="aspectFit"></image>
  63. </view>
  64. </view>
  65. </view>
  66. </view>
  67. <!-- 图表区域 -->
  68. <view class="chart-section">
  69. <view class="chart-header">
  70. <view class="chart-tabs">
  71. <view
  72. v-for="(tab, index) in chartTabs"
  73. :key="index"
  74. class="chart-tab-item"
  75. :class="{ active: activeChartTab === index }"
  76. @click="switchChartTab(index)"
  77. >
  78. {{ tab.name }}
  79. </view>
  80. </view>
  81. <!-- <view class="chart-dropdown">
  82. <text class="iconfont dropdown-icon">&#xe606;</text>
  83. </view> -->
  84. </view>
  85. <view class="chart-content">
  86. <view class="chart-canvas-container" v-if="!show" :key="chartKey">
  87. <!-- <div id="tempChart" class="chart-canvas"></div> -->
  88. <qiun-data-charts type="line" :chartData="chartData" :canvas2d="true" :inScrollView="true" :opts="opts" :ontouch="true" v-show="xData.length"/>
  89. </view>
  90. </view>
  91. </view>
  92. <!-- 历史数据表格 -->
  93. <view class="history-section">
  94. <view class="history-header">
  95. <text class="history-title">历史数据</text>
  96. </view>
  97. <view class="history-table">
  98. <view class="table-container">
  99. <!-- 固定列 -->
  100. <view class="fixed-column">
  101. <view class="fixed-header">
  102. <text class="header-cell fixed">上报时间</text>
  103. </view>
  104. <view class="fixed-body">
  105. <view
  106. v-for="(item, index) in historyData"
  107. :key="index"
  108. class="fixed-row"
  109. :class="{ even: index % 2 === 0 }"
  110. >
  111. <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}}</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>
  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 setting from '../assets/setting.png';
  241. import edit from '../assets/edit.png';
  242. import sim from '../assets/sim.png';
  243. import Circulation from '../../../static/js/equipState_dict.json';
  244. import floatButton from './floating-button.vue';
  245. import general from '../assets/general.png';
  246. import editBorder from '../assets/editBorder.png';
  247. import settingBorder from '../assets/settingBorder.png';
  248. import simBorder from '../assets/simBorder.png';
  249. import photoBorder from '../assets/photoBorder.png';
  250. let chartInstance = null;
  251. export default {
  252. name: 'DeviceData',
  253. props:{
  254. deviceInfo:{
  255. type:Object,
  256. default:()=>({}),
  257. },
  258. deviceStatic:{
  259. type:Object,
  260. default:()=>({}),
  261. },
  262. polylineList:{
  263. type:Array,
  264. default:()=>[],
  265. },
  266. deviceHistoryList:{
  267. type:Array,
  268. default:()=>[],
  269. },
  270. totalPage:{
  271. type:Number,
  272. default:0
  273. },
  274. currentPage:{
  275. type:Number,
  276. default:0
  277. },
  278. page_size:{
  279. type:Number,
  280. default:10
  281. },
  282. },
  283. components: {
  284. floatButton,
  285. },
  286. computed:{
  287. totalPages(){
  288. return Math.ceil(this.totalPage / this.page_size)
  289. }
  290. },
  291. data() {
  292. return {
  293. setting,
  294. general,
  295. editBorder,
  296. settingBorder,
  297. photoBorder,
  298. simBorder,
  299. devImage:'https://s3.hnyfwlw.com/webstaticimg/bigdata_app/image/cbd.png',
  300. baseDevice:'https://s3.hnyfwlw.com/webstaticimg/bigdata_app/image',
  301. devImg:'',
  302. activeTab: 0,
  303. edit,
  304. sim,
  305. show:false,
  306. isShowPhoto:false,
  307. show1:true,
  308. equipStateDict:{},
  309. chartTabs: [
  310. { name: '温度', id: 'new_tem' },
  311. { name: '湿度', id: 'new_hum' },
  312. { name: '加热仓温度', id: 'others' },
  313. ],
  314. opts: {
  315. type: 'line',
  316. xAxis: {
  317. disableGrid: true,
  318. itemCount: 3,
  319. scrollShow: true
  320. },
  321. yAxis: {
  322. disableGrid: true,
  323. gridType: 'dash',
  324. splitNumber: 5,
  325. min: 0,
  326. format: (val) => {
  327. return Math.round(val)
  328. }
  329. },
  330. extra: {
  331. line: {
  332. type: 'curve'
  333. },
  334. tooltip: {
  335. format: {
  336. name: '',
  337. value: (val) => Math.round(val)
  338. }
  339. }
  340. },
  341. legend: {
  342. },
  343. enableScroll: true
  344. },
  345. xData:[],
  346. yData:[],
  347. activeChartTab: 0,
  348. historyData: [],
  349. data_iccid:'',
  350. data_iccidInput:'',
  351. deviceInfoStatic:{},
  352. photo_iccid:'',
  353. chartData: {},
  354. chartKey: 0
  355. };
  356. },
  357. mounted(){
  358. this.equipStateDict = Circulation
  359. },
  360. computed: {
  361. formatDevImg() {
  362. return `https://s3.hnyfwlw.com/webstaticimg/bigdata_app/image/${this.devImg}.png`;
  363. },
  364. },
  365. watch:{
  366. polylineList:{
  367. handler(newVal, oldVal){
  368. this.xData = newVal.map(item => this.formatDate(new Date(item.addtime)));
  369. this.yData = newVal.map(item => Number(item.new_tem) || 0);
  370. if(this.xData.length){
  371. this.initChart();
  372. }
  373. },
  374. deep:true,
  375. immediate:true,
  376. },
  377. deviceInfo:{
  378. handler(newVal, oldVal){
  379. console.log(newVal.device_model,'device_modeldevice_modeldevice_model')
  380. if (newVal.device_model == '11'){
  381. this.devImg = 'cbd4.1'
  382. this.isShowPhoto = true
  383. } else if(newVal.device_model == '12'){
  384. this.devImg = 'cbd1'
  385. this.isShowPhoto = false
  386. } else if(newVal.device_model == '13'){
  387. this.devImg = 'cbd5'
  388. this.isShowPhoto = true
  389. } else if(newVal.device_model == '14'){
  390. this.devImg = 'cbd6'
  391. this.isShowPhoto = true
  392. } else if(newVal.device_model == '15'){
  393. this.devImg = 'gkcbd1'
  394. this.isShowPhoto = false
  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. box-shadow: 0 4px 12px rgba(0, 0, 0, 0.15);
  769. .general-icon{
  770. width: 50rpx;
  771. height: 50rpx;
  772. border-radius: 50%;
  773. }
  774. }
  775. .general-images{
  776. display: flex;
  777. align-items: center;
  778. justify-content: center;
  779. position: relative;
  780. .general-image{
  781. position: absolute;
  782. width: 80rpx;
  783. height: 80rpx;
  784. border-radius: 50%;
  785. box-shadow: 0 4px 12px rgba(0, 0, 0, 0.15);
  786. display:flex;
  787. align-items: center;
  788. justify-content: center;
  789. .image-icon{
  790. width: 45rpx;
  791. height: 45rpx;
  792. }
  793. }
  794. .edit-border{
  795. top: 45rpx;
  796. left: -110rpx;
  797. }
  798. .sim-border{
  799. top: -125rpx;
  800. left: -110rpx;
  801. }
  802. .setting-border{
  803. top: -40rpx;
  804. left: -180rpx;
  805. }
  806. .edit-border2{
  807. top: 60rpx;
  808. left: -70rpx;
  809. }
  810. .sim-border2{
  811. top: -75rpx;
  812. left: -150rpx;
  813. }
  814. .setting-border2{
  815. top: 20rpx;
  816. left: -150rpx;
  817. }
  818. .photo-border{
  819. top: -135rpx;
  820. left: -70rpx;
  821. }
  822. }
  823. /* 主要数据面板 */
  824. .main-data-panel {
  825. display: flex;
  826. background: #FFFFFF;
  827. border-radius: 16rpx;
  828. margin-bottom: 16rpx;
  829. .data-column-left {
  830. flex: 1;
  831. display: flex;
  832. flex-direction: column;
  833. gap: 24rpx;
  834. .data-item {
  835. display: flex;
  836. flex-direction: column;
  837. gap: 8rpx;
  838. .data-label {
  839. font-size: 24rpx;
  840. font-family: 'Source Han Sans CN VF', sans-serif;
  841. font-weight: 400;
  842. color: #999999;
  843. }
  844. .data-value {
  845. font-size: 24rpx;
  846. font-family: 'Source Han Sans CN VF', sans-serif;
  847. font-weight: 700;
  848. color: #042118;
  849. &.temp-value {
  850. color: #FF6B6B;
  851. }
  852. }
  853. .data-unit {
  854. font-size: 24rpx;
  855. font-family: 'Source Han Sans CN VF', sans-serif;
  856. font-weight: 400;
  857. color: #999999;
  858. }
  859. }
  860. }
  861. .data-column-right {
  862. flex: 1;
  863. display: flex;
  864. flex-direction: column;
  865. align-items: center;
  866. gap: 16rpx;
  867. .device-image-container {
  868. position: relative;
  869. width: 200rpx;
  870. height: 200rpx;
  871. display: flex;
  872. align-items: center;
  873. justify-content: center;
  874. .device-glow {
  875. position: absolute;
  876. width: 180rpx;
  877. height: 180rpx;
  878. background: radial-gradient(circle, rgba(11, 188, 88, 0.3) 0%, rgba(11, 188, 88, 0) 70%);
  879. border-radius: 50%;
  880. }
  881. .device-image {
  882. position: relative;
  883. width: 260rpx;
  884. height: 360rpx;
  885. z-index: 1;
  886. top: 60rpx;
  887. }
  888. }
  889. .device-info {
  890. display: flex;
  891. flex-direction: column;
  892. gap: 12rpx;
  893. width: 100%;
  894. .info-row {
  895. display: flex;
  896. justify-content: space-between;
  897. align-items: center;
  898. .info-label {
  899. font-size: 24rpx;
  900. font-family: 'Source Han Sans CN VF', sans-serif;
  901. font-weight: 400;
  902. color: #999999;
  903. }
  904. .info-value {
  905. font-size: 36rpx;
  906. font-family: 'Source Han Sans CN VF', sans-serif;
  907. font-weight: 700;
  908. color: #042118;
  909. }
  910. .info-version {
  911. font-size: 24rpx;
  912. font-family: 'Source Han Sans CN VF', sans-serif;
  913. font-weight: 400;
  914. color: #999999;
  915. }
  916. .info-label-small {
  917. font-size: 24rpx;
  918. font-family: 'Source Han Sans CN VF', sans-serif;
  919. font-weight: 400;
  920. color: #999999;
  921. }
  922. }
  923. }
  924. }
  925. }
  926. .tabs-container{
  927. display:flex;
  928. align-items: center;
  929. gap: 24rpx;
  930. padding: 24rpx;
  931. .tabs-item{
  932. font-size: 28rpx;
  933. font-family: 'Source Han Sans CN VF', sans-serif;
  934. font-weight: 500;
  935. color: #999999;
  936. }
  937. .tabs-item.active{
  938. color: #0BBC58;
  939. }
  940. }
  941. /* 图表区域 */
  942. .chart-section {
  943. background: #FFFFFF;
  944. border-radius: 16rpx;
  945. padding: 24rpx 32rpx 32rpx;
  946. margin: 24rpx 0;
  947. .chart-header {
  948. display: flex;
  949. justify-content: space-between;
  950. align-items: center;
  951. margin-bottom: 24rpx;
  952. .chart-tabs {
  953. display: flex;
  954. gap: 48rpx;
  955. overflow-x: auto;
  956. white-space: nowrap;
  957. .chart-tab-item {
  958. font-size: 28rpx;
  959. font-family: 'Source Han Sans CN VF', sans-serif;
  960. font-weight: 500;
  961. color: #999999;
  962. position: relative;
  963. padding-bottom: 8rpx;
  964. transition: all 0.3s;
  965. &.active {
  966. color: #0BBC58;
  967. font-weight: 700;
  968. &::after {
  969. content: '';
  970. position: absolute;
  971. bottom: 0;
  972. left: 0;
  973. right: 0;
  974. height: 4rpx;
  975. background: #0BBC58;
  976. border-radius: 2rpx;
  977. }
  978. }
  979. }
  980. }
  981. .chart-dropdown {
  982. .dropdown-icon {
  983. font-size: 28rpx;
  984. color: #999999;
  985. }
  986. }
  987. }
  988. .chart-content {
  989. .chart-legend {
  990. display: flex;
  991. justify-content: space-between;
  992. align-items: center;
  993. margin-bottom: 16rpx;
  994. .legend-item {
  995. display: flex;
  996. align-items: center;
  997. gap: 8rpx;
  998. .legend-dot {
  999. width: 16rpx;
  1000. height: 16rpx;
  1001. background: #0BBC58;
  1002. border-radius: 50%;
  1003. }
  1004. .legend-text {
  1005. font-size: 24rpx;
  1006. font-family: 'Source Han Sans CN VF', sans-serif;
  1007. font-weight: 400;
  1008. color: #042118;
  1009. }
  1010. }
  1011. .legend-average {
  1012. .average-text {
  1013. font-size: 24rpx;
  1014. font-family: 'Source Han Sans CN VF', sans-serif;
  1015. font-weight: 400;
  1016. color: #999999;
  1017. }
  1018. }
  1019. }
  1020. .chart-canvas-container {
  1021. width: 100%;
  1022. height: 400rpx;
  1023. .chart-canvas {
  1024. width: 100%;
  1025. height: 100%;
  1026. }
  1027. }
  1028. }
  1029. }
  1030. .copy-icon{
  1031. width: 40rpx;
  1032. height: 40rpx;
  1033. }
  1034. /* 历史数据表格 */
  1035. .history-section {
  1036. background: #FFFFFF;
  1037. border-radius: 16rpx;
  1038. padding: 24rpx 32rpx 32rpx;
  1039. .history-header {
  1040. margin-bottom: 24rpx;
  1041. .history-title {
  1042. font-size: 32rpx;
  1043. font-family: 'Source Han Sans CN VF', sans-serif;
  1044. font-weight: 700;
  1045. color: #042118;
  1046. }
  1047. }
  1048. .history-table {
  1049. margin-bottom: 24rpx;
  1050. .table-container {
  1051. display: flex;
  1052. position: relative;
  1053. /* 固定列 */
  1054. .fixed-column {
  1055. width: 240rpx;
  1056. position: relative;
  1057. z-index: 2;
  1058. background: #FFFFFF;
  1059. .fixed-header {
  1060. border-bottom: 2rpx solid #F0F0F0;
  1061. padding: 16rpx 0;
  1062. .header-cell.fixed {
  1063. font-size: 24rpx;
  1064. font-family: 'Source Han Sans CN VF', sans-serif;
  1065. font-weight: 500;
  1066. color: #666666;
  1067. text-align: left;
  1068. padding-left: 0;
  1069. }
  1070. }
  1071. .fixed-body {
  1072. .fixed-row {
  1073. padding: 16rpx 0;
  1074. border-bottom: 1rpx solid #F5F5F5;
  1075. height: 80rpx;
  1076. display: flex;
  1077. align-items: center;
  1078. &.even {
  1079. background: #FAFAFA;
  1080. }
  1081. .body-cell.fixed {
  1082. font-size: 24rpx;
  1083. font-family: 'Source Han Sans CN VF', sans-serif;
  1084. font-weight: 400;
  1085. color: #042118;
  1086. text-align: left;
  1087. padding-left: 0;
  1088. }
  1089. }
  1090. }
  1091. }
  1092. /* 可滑动列 */
  1093. .scrollable-column {
  1094. flex: 1;
  1095. overflow-x: auto;
  1096. white-space: nowrap;
  1097. /* 隐藏滚动条 */
  1098. &::-webkit-scrollbar {
  1099. display: none;
  1100. }
  1101. scrollbar-width: none;
  1102. .scrollable-header {
  1103. display: flex;
  1104. border-bottom: 2rpx solid #F0F0F0;
  1105. padding: 20rpx 0;
  1106. .header-cell {
  1107. min-width: 140rpx;
  1108. font-size: 24rpx;
  1109. font-family: 'Source Han Sans CN VF', sans-serif;
  1110. font-weight: 500;
  1111. color: #666666;
  1112. text-align: center;
  1113. // 超出隐藏
  1114. overflow: hidden;
  1115. text-overflow: ellipsis;
  1116. white-space: nowrap;
  1117. margin-right: 10rpx;
  1118. }
  1119. }
  1120. .scrollable-body {
  1121. .scrollable-row {
  1122. display: flex;
  1123. padding: 16rpx 0;
  1124. border-bottom: 1rpx solid #F5F5F5;
  1125. height: 80rpx;
  1126. align-items: center;
  1127. &.even {
  1128. background: #FAFAFA;
  1129. }
  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>