3PhaseCurrentDetails.vue 9.8 KB

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