deviceData.vue 33 KB

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