deviceData.vue 34 KB

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