deviceData.vue 34 KB

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