3PhaseCurrentDetails.vue 10 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472
  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. var sz1c=['#ceba07','#32CD32','#FF5733']
  223. var sz2c=['#54a1d5','#ceba07','#32CD32','#FF5733']
  224. for(var j in sz1){
  225. var ap={
  226. name: sz1[j],
  227. type: 'line',
  228. symbol: 'none',
  229. // sampling: 'lttb',
  230. // stack: 'Total',
  231. data:[]
  232. }
  233. if(sz1.length==3){
  234. ap.itemStyle={
  235. color:sz1c[j]
  236. }
  237. }
  238. if(sz1.length==4){
  239. ap.itemStyle={
  240. color:sz2c[j]
  241. }
  242. }
  243. list.push(ap)
  244. for(var i in energyCenterMapObj){
  245. var time=this.queryDate.replace("-","/").replace("-","/")
  246. var obj=energyCenterMapObj[i][sz2[j]];
  247. var time = new Date(time+' '+i).getTime()
  248. ap.data.push([time,obj]);
  249. }
  250. }
  251. }, echarts(className,color,legenddata,seriesdata){
  252. var colorName="#333"
  253. // if(color=='1'){
  254. // colorName="#ECEDF0"
  255. // }else{
  256. // colorName="#333"
  257. // }
  258. var myChart = echarts.init(document.getElementById(className), 'light');
  259. myChart.clear()
  260. var option = {
  261. tooltip: {
  262. trigger: 'axis',
  263. borderColor:"#F0F0F0",
  264. borderWidth:1,
  265. backgroundColor:"#ffffff",
  266. textStyle:{
  267. color:"#333"
  268. }
  269. },
  270. legend: {
  271. data: legenddata,
  272. textStyle: {
  273. color: colorName
  274. }
  275. },
  276. grid: {
  277. top: 40,
  278. left: 8,
  279. right: 8,
  280. bottom: 10,
  281. containLabel: true
  282. },
  283. xAxis: {
  284. type: 'time',
  285. splitNumber: 4,
  286. boundaryGap: false,
  287. axisLabel:{
  288. textStyle:{
  289. color:colorName
  290. }
  291. },
  292. axisLine:{
  293. show:true,
  294. lineStyle:{
  295. color:colorName
  296. }
  297. },
  298. },
  299. yAxis: {
  300. type: 'value',
  301. //name: '单位('+this.typeN+')',
  302. axisLabel:{
  303. textStyle:{
  304. color:colorName
  305. }
  306. }, axisLine:{
  307. show:true,
  308. lineStyle:{
  309. color:colorName
  310. }
  311. },
  312. },
  313. // dataZoom: [
  314. // {
  315. // type: 'inside',
  316. // start: 0,
  317. // end: 100
  318. // },
  319. // {
  320. // start: 0,
  321. // end: 100
  322. // }
  323. // ],
  324. series: seriesdata
  325. };
  326. console.log(option);
  327. myChart.setOption(option);
  328. }
  329. }
  330. }
  331. </script>
  332. <style lang="scss" scoped>
  333. page{
  334. background-color: #fff;
  335. }
  336. .slot{
  337. background: #fff;
  338. display: flex;
  339. align-items: center;
  340. .img{
  341. width: 48rpx;
  342. height: 48rpx;
  343. margin-right: 4rpx;
  344. }
  345. }
  346. .main{
  347. padding: 32rpx;
  348. .title{
  349. display: flex;
  350. justify-content: space-between;
  351. .icon{
  352. width: 8rpx;
  353. height: 32rpx;
  354. margin-right: 8rpx;
  355. background-color: rgba(22,119,255,1);
  356. }
  357. .text{
  358. display: flex;
  359. align-items: center;
  360. color: rgb(16,16,16);
  361. font-size: 36rpx;
  362. margin-left: 12rpx;
  363. font-weight: bold;
  364. }
  365. }
  366. .chat{
  367. width: 100%;
  368. height: 480rpx;
  369. margin-top: 32rpx;
  370. .img{
  371. width: 100%;
  372. height: 100%;
  373. }
  374. }
  375. // 表格
  376. .table{
  377. margin-top: 60rpx;
  378. border-radius: 8px;
  379. z-index: 999;
  380. table{
  381. background-color:#f1f2f5 ;
  382. color: #101010;
  383. padding:20rpx 10rpx;
  384. width: 100%;
  385. td{
  386. text-align: right;
  387. }
  388. }
  389. }
  390. }
  391. </style>