deviceData.vue 33 KB

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