3PhaseCurrentDetails.vue 9.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453
  1. <template>
  2. <view>
  3. <u-navbar :title="typeName+'监测'" title-color="#101010" >
  4. <view class="slot" slot="right" @click="show=true">
  5. <image class="img" src="@/assets/img/riLine-calendar-todo-line 2.svg" mode=""></image>
  6. </view>
  7. </u-navbar>
  8. <u-picker-select :noselect="true"
  9. @confirm="selector2confirm" @reset="selector2reset" :defaultTime="queryDate"
  10. title="日期选择" v-model="show" mode="time" :params="params" ></u-picker-select>
  11. <view class="main">
  12. <view class="title">
  13. <view class="text">
  14. <view class="icon">
  15. </view>
  16. <span>
  17. {{typeKey}}监测 <span v-if="typeN">(单位{{typeN}})</span>
  18. </span>
  19. </view>
  20. </view>
  21. <view class="chat">
  22. <view id="barEcharts" style="min-height:440rpx;" >
  23. </view>
  24. </view>
  25. <!-- 表格 -->
  26. <view class="table">
  27. <table bg-color="#f1f2f5" border-color="#f1f2f5" color="#101010" padding="20rpx 0">
  28. <tr>
  29. <th></th>
  30. <th>实时{{typeKey}}</th>
  31. <th>最大{{typeKey}}</th>
  32. <th>最小{{typeKey}}</th>
  33. </tr>
  34. <template v-if="type=='AF'">
  35. <tr>
  36. <td></td>
  37. <td>{{currentMap.AL1}}</td>
  38. <td>{{currentMap.AL2}}</td>
  39. <td>{{currentMap.AL3}}</td>
  40. </tr>
  41. </template>
  42. <template v-else >
  43. <tr v-if="type=='P'">
  44. <td class="tableft">总功率</td>
  45. <td>{{queryDate==nowDate?currentMap.AL1:'\\'}}</td>
  46. <td>{{currentMap.AL2}}</td>
  47. <td>{{currentMap.AL3}}</td>
  48. </tr>
  49. <tr>
  50. <td>A相</td>
  51. <td>{{queryDate==nowDate?currentMap.A1:'\\'}}</td>
  52. <td>{{currentMap.A2}}</td>
  53. <td>{{currentMap.A3}}</td>
  54. </tr>
  55. <tr>
  56. <td>B相</td>
  57. <td>{{queryDate==nowDate?currentMap.B1:'\\'}}</td>
  58. <td>{{currentMap.B2}}</td>
  59. <td>{{currentMap.B3}}</td>
  60. </tr>
  61. <tr>
  62. <td>C相</td>
  63. <td>{{queryDate==nowDate?currentMap.C1:'\\'}}</td>
  64. <td>{{currentMap.C2}}</td>
  65. <td>{{currentMap.C3}}</td>
  66. </tr>
  67. </template>
  68. </table>
  69. <view class="text2" style="text-align: center;padding-top: 8rpx;" >
  70. {{queryDate}}
  71. </view>
  72. </view>
  73. </view>
  74. </view>
  75. </template>
  76. <script>
  77. import * as API from '@/apis/pagejs/electricityMeter.js'
  78. import * as echarts from 'echarts';
  79. import {
  80. currentTimeStamp,
  81. parseUnixTime,
  82. beforeTimeStamp
  83. } from '@/apis/utils'
  84. export default {
  85. data() {
  86. return {
  87. params: {
  88. year: true,
  89. month: true,
  90. day: true,
  91. hour: false,
  92. minute: false,
  93. second: false
  94. },
  95. show: false,
  96. meterNo:'',
  97. type:'',
  98. isLoading: true,
  99. nowDate:"",
  100. queryDate:"",
  101. graphMap:{},
  102. currentMap:{},
  103. timeList:[],
  104. typeName:'',
  105. typeN:'',
  106. typeKey:'',
  107. }
  108. },
  109. computed:{
  110. },
  111. onLoad(op){
  112. this.meterNo=op.id
  113. this.type=op.type
  114. this.typeName=op.typeName
  115. if(this.type=='P'){
  116. this.typeKey='功率'
  117. this.typeN='kW'
  118. }else if(this.type=='A'){
  119. this.typeKey='电流'
  120. this.typeN='A'
  121. }else if(this.type=='V'){
  122. this.typeKey='电压'
  123. this.typeN='V'
  124. }else if(this.type=='T'){
  125. this.typeKey='温度'
  126. this.typeN=''
  127. }else if(this.type=='F'){
  128. this.typeKey='功率因数'
  129. this.typeN=''
  130. }else if(this.type=='AF'){
  131. this.typeKey='功率因数'
  132. this.typeN=''
  133. }
  134. this.nowDate=parseUnixTime(currentTimeStamp(), '{y}-{m}-{d}');
  135. this.queryDate=parseUnixTime(beforeTimeStamp(0), '{y}-{m}-{d}');
  136. this.getPowerDetection()
  137. },
  138. methods: {
  139. selector2confirm(e){
  140. this.queryDate=e.year+"-"+e.month+'-'+e.day
  141. this.getPowerDetection()
  142. },
  143. getPowerDetection(){
  144. uni.showLoading({
  145. title: "加载中",
  146. mask: true,
  147. })
  148. API.powerDetection({
  149. queryDate:this.queryDate,
  150. meterId:this.meterNo,
  151. type:this.type
  152. }).then(response => {
  153. uni.hideLoading();
  154. this.currentMap = response.data.currentMap;
  155. this.graphMap= response.data.graphMap
  156. this.setMap();
  157. }).catch(error => {
  158. uni.showToast({
  159. title: error,
  160. icon: "none"
  161. })
  162. })
  163. },
  164. setMap(){
  165. this.timeList=[]
  166. for(var i in this.graphMap){
  167. var mod=this.graphMap[i];
  168. var time=mod.createTime
  169. mod.createTime=time.replace("-","/").replace("-","/")
  170. this.timeList.push(i)
  171. }
  172. // sz1=['总功率','A相功率','B相功率','C相功率'];
  173. // sz2=['A相电流','B相电流','C相电流'];
  174. // sz3=['A相电压','B相电压','C相电压'];
  175. // sz4=['A相功率因数','B相功率因数','C相功率因数'];
  176. // sz5=['平均功率因数'];
  177. var sz1=['总功率','A相功率','B相功率','C相功率'];
  178. var sz2=['A相电流','B相电流','C相电流'];
  179. var sz3=['A相电压','B相电压','C相电压'];
  180. var sz4=['A相功率因数','B相功率因数','C相功率因数'];
  181. var sz5=['平均功率因数'];
  182. var sz6=['A相温度','B相温度','C相温度'];
  183. var list=[];
  184. if(this.type=='T'){
  185. //this.typeName='功率'
  186. this.setSz(sz6,['temperature1','temperature2','temperature3'],list,this.graphMap)
  187. this.echarts('barEcharts',1,sz6,list);
  188. }
  189. if(this.type=='AF'){
  190. //this.typeName='功率'
  191. this.setSz(sz5,['averPowerFactor'],list,this.graphMap)
  192. this.echarts('barEcharts',1,sz5,list);
  193. }
  194. if(this.type=='F'){
  195. //this.typeName='功率'
  196. this.setSz(sz4,['af','bf','cf'],list,this.graphMap,1)
  197. this.echarts('barEcharts',1,sz4,list);
  198. }if(this.type=='P'){
  199. //this.typeName='功率'
  200. this.setSz(sz4,['totalPower','ap','bp','cp'],list,this.graphMap)
  201. this.echarts('barEcharts',1,sz1,list);
  202. }else if(this.type=='A'){
  203. //this.typeName='电流'
  204. this.setSz(sz2,['aa','ba','ca'],list,this.graphMap)
  205. this.echarts('barEcharts',0,sz2,list);
  206. }else if(this.type=='V'){
  207. //this.typeName='电压'
  208. this.setSz(sz3,['av','bv','cv'],list,this.graphMap)
  209. this.echarts('barEcharts',0,sz3,list);
  210. }
  211. },
  212. setSz(sz1,sz2,list,energyCenterMapObj,k){
  213. for(var j in sz1){
  214. var ap={
  215. name: sz1[j],
  216. type: 'line',
  217. symbol: 'none',
  218. // sampling: 'lttb',
  219. // stack: 'Total',
  220. data:[]
  221. }
  222. list.push(ap)
  223. for(var i in energyCenterMapObj){
  224. var time=this.queryDate.replace("-","/").replace("-","/")
  225. var obj=energyCenterMapObj[i][sz2[j]];
  226. var time = new Date(time+' '+i).getTime()
  227. if(k){
  228. ap.data.push([time,obj?(obj).toFixed(2):0]);
  229. }else{
  230. ap.data.push([time,parseInt(obj)]);
  231. }
  232. }
  233. }
  234. }, echarts(className,color,legenddata,seriesdata){
  235. var colorName="#333"
  236. // if(color=='1'){
  237. // colorName="#ECEDF0"
  238. // }else{
  239. // colorName="#333"
  240. // }
  241. var myChart = echarts.init(document.getElementById(className), 'light');
  242. myChart.clear()
  243. var option = {
  244. tooltip: {
  245. trigger: 'axis',
  246. borderColor:"#F0F0F0",
  247. borderWidth:1,
  248. backgroundColor:"#ffffff",
  249. textStyle:{
  250. color:"#333"
  251. }
  252. },
  253. legend: {
  254. data: legenddata,
  255. textStyle: {
  256. color: colorName
  257. }
  258. },
  259. grid: {
  260. top: 40,
  261. left: 8,
  262. right: 8,
  263. bottom: 10,
  264. containLabel: true
  265. },
  266. xAxis: {
  267. type: 'time',
  268. splitNumber: 4,
  269. boundaryGap: false,
  270. axisLabel:{
  271. textStyle:{
  272. color:colorName
  273. }
  274. },
  275. axisLine:{
  276. show:true,
  277. lineStyle:{
  278. color:colorName
  279. }
  280. },
  281. },
  282. yAxis: {
  283. type: 'value',
  284. //name: '单位('+this.typeN+')',
  285. axisLabel:{
  286. textStyle:{
  287. color:colorName
  288. }
  289. }, axisLine:{
  290. show:true,
  291. lineStyle:{
  292. color:colorName
  293. }
  294. },
  295. },
  296. dataZoom: [
  297. {
  298. type: 'inside',
  299. start: 0,
  300. end: 100
  301. },
  302. {
  303. start: 0,
  304. end: 100
  305. }
  306. ],
  307. series: seriesdata
  308. };
  309. console.log(option);
  310. myChart.setOption(option);
  311. }
  312. }
  313. }
  314. </script>
  315. <style lang="scss" scoped>
  316. page{
  317. background-color: #fff;
  318. }
  319. .slot{
  320. display: flex;
  321. align-items: center;
  322. .img{
  323. width: 48rpx;
  324. height: 48rpx;
  325. margin-right: 4rpx;
  326. }
  327. }
  328. .main{
  329. padding: 32rpx;
  330. .title{
  331. .icon{
  332. width: 8rpx;
  333. height: 32rpx;
  334. background-color: rgba(22,119,255,1);
  335. }
  336. .text{
  337. display: flex;
  338. align-items: center;
  339. color: rgb(16,16,16);
  340. font-size: 36rpx;
  341. margin-left: 12rpx;
  342. font-weight: bold;
  343. }
  344. }
  345. .chat{
  346. width: 100%;
  347. height: 480rpx;
  348. margin-top: 32rpx;
  349. .img{
  350. width: 100%;
  351. height: 100%;
  352. }
  353. }
  354. // 表格
  355. .table{
  356. margin-top: 60rpx;
  357. border-radius: 8px;
  358. z-index: 999;
  359. table{
  360. background-color:#f1f2f5 ;
  361. color: #101010;
  362. padding:20rpx 10rpx;
  363. width: 100%;
  364. td{
  365. text-align: right;
  366. }
  367. }
  368. }
  369. }
  370. </style>