deviceData.vue 32 KB

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