deviceData.vue 32 KB

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