deviceData.vue 31 KB

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