3PhaseCurrentDetails.vue 9.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455
  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>
  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. title:"",
  108. }
  109. },
  110. computed:{
  111. },
  112. onLoad(op){
  113. this.meterNo=op.id
  114. this.type=op.type
  115. this.typeName=op.typeName
  116. this.title=op.title
  117. if(this.type=='P'){
  118. this.typeKey='功率'
  119. this.typeN='kW'
  120. }else if(this.type=='A'){
  121. this.typeKey='电流'
  122. this.typeN='A'
  123. }else if(this.type=='V'){
  124. this.typeKey='电压'
  125. this.typeN='V'
  126. }else if(this.type=='T'){
  127. this.typeKey='温度'
  128. this.typeN='℃'
  129. }else if(this.type=='F'){
  130. this.typeKey='功率因数'
  131. this.typeN=''
  132. }else if(this.type=='AF'){
  133. this.typeKey='功率因数'
  134. this.typeN=''
  135. }
  136. this.nowDate=parseUnixTime(currentTimeStamp(), '{y}-{m}-{d}');
  137. this.queryDate=parseUnixTime(beforeTimeStamp(0), '{y}-{m}-{d}');
  138. this.getPowerDetection()
  139. },
  140. methods: {
  141. selector2reset(e){
  142. this.queryDate=parseUnixTime(beforeTimeStamp(0), '{y}-{m}-{d}');
  143. this.getPowerDetection()
  144. },
  145. selector2confirm(e){
  146. this.queryDate=e.year+"-"+e.month+'-'+e.day
  147. this.getPowerDetection()
  148. },
  149. getPowerDetection(){
  150. uni.showLoading({
  151. title: "加载中",
  152. mask: true,
  153. })
  154. API.powerDetection({
  155. queryDate:this.queryDate,
  156. meterId:this.meterNo,
  157. type:this.type
  158. }).then(response => {
  159. uni.hideLoading();
  160. this.currentMap = response.data.currentMap;
  161. this.graphMap= response.data.graphMap
  162. this.setMap();
  163. }).catch(error => {
  164. uni.showToast({
  165. title: error,
  166. icon: "none"
  167. })
  168. })
  169. },
  170. setMap(){
  171. this.timeList=[]
  172. for(var i in this.graphMap){
  173. var mod=this.graphMap[i];
  174. var time=mod.createTime
  175. mod.createTime=time.replace("-","/").replace("-","/")
  176. this.timeList.push(i)
  177. }
  178. // sz1=['总功率','A相功率','B相功率','C相功率'];
  179. // sz2=['A相电流','B相电流','C相电流'];
  180. // sz3=['A相电压','B相电压','C相电压'];
  181. // sz4=['A相功率因数','B相功率因数','C相功率因数'];
  182. // sz5=['平均功率因数'];
  183. var sz1=['总功率','A相功率','B相功率','C相功率'];
  184. var sz2=['A相电流','B相电流','C相电流'];
  185. var sz3=['A相电压','B相电压','C相电压'];
  186. var sz4=['A相功率因数','B相功率因数','C相功率因数'];
  187. var sz5=['平均功率因数'];
  188. var sz6=['A相温度','B相温度','C相温度'];
  189. var list=[];
  190. if(this.type=='T'){
  191. //this.typeName='功率'
  192. this.setSz(sz6,['temperature1','temperature2','temperature3'],list,this.graphMap)
  193. this.echarts('barEcharts',1,sz6,list);
  194. }
  195. if(this.type=='AF'){
  196. //this.typeName='功率'
  197. this.setSz(sz5,['averPowerFactor'],list,this.graphMap)
  198. this.echarts('barEcharts',1,sz5,list);
  199. }
  200. if(this.type=='F'){
  201. //this.typeName='功率'
  202. this.setSz(sz4,['af','bf','cf'],list,this.graphMap)
  203. this.echarts('barEcharts',1,sz4,list);
  204. }if(this.type=='P'){
  205. //this.typeName='功率'
  206. this.setSz(sz1,['totalPower','ap','bp','cp'],list,this.graphMap)
  207. this.echarts('barEcharts',1,sz1,list);
  208. }else if(this.type=='A'){
  209. //this.typeName='电流'
  210. this.setSz(sz2,['aa','ba','ca'],list,this.graphMap)
  211. this.echarts('barEcharts',0,sz2,list);
  212. }else if(this.type=='V'){
  213. //this.typeName='电压'
  214. this.setSz(sz3,['av','bv','cv'],list,this.graphMap)
  215. this.echarts('barEcharts',0,sz3,list);
  216. }
  217. },
  218. setSz(sz1,sz2,list,energyCenterMapObj,k){
  219. for(var j in sz1){
  220. var ap={
  221. name: sz1[j],
  222. type: 'line',
  223. symbol: 'none',
  224. // sampling: 'lttb',
  225. // stack: 'Total',
  226. data:[]
  227. }
  228. list.push(ap)
  229. for(var i in energyCenterMapObj){
  230. var time=this.queryDate.replace("-","/").replace("-","/")
  231. var obj=energyCenterMapObj[i][sz2[j]];
  232. var time = new Date(time+' '+i).getTime()
  233. ap.data.push([time,obj]);
  234. }
  235. }
  236. }, echarts(className,color,legenddata,seriesdata){
  237. var colorName="#333"
  238. // if(color=='1'){
  239. // colorName="#ECEDF0"
  240. // }else{
  241. // colorName="#333"
  242. // }
  243. var myChart = echarts.init(document.getElementById(className), 'light');
  244. myChart.clear()
  245. var option = {
  246. tooltip: {
  247. trigger: 'axis',
  248. borderColor:"#F0F0F0",
  249. borderWidth:1,
  250. backgroundColor:"#ffffff",
  251. textStyle:{
  252. color:"#333"
  253. }
  254. },
  255. legend: {
  256. data: legenddata,
  257. textStyle: {
  258. color: colorName
  259. }
  260. },
  261. grid: {
  262. top: 40,
  263. left: 8,
  264. right: 8,
  265. bottom: 10,
  266. containLabel: true
  267. },
  268. xAxis: {
  269. type: 'time',
  270. splitNumber: 4,
  271. boundaryGap: false,
  272. axisLabel:{
  273. textStyle:{
  274. color:colorName
  275. }
  276. },
  277. axisLine:{
  278. show:true,
  279. lineStyle:{
  280. color:colorName
  281. }
  282. },
  283. },
  284. yAxis: {
  285. type: 'value',
  286. //name: '单位('+this.typeN+')',
  287. axisLabel:{
  288. textStyle:{
  289. color:colorName
  290. }
  291. }, axisLine:{
  292. show:true,
  293. lineStyle:{
  294. color:colorName
  295. }
  296. },
  297. },
  298. // dataZoom: [
  299. // {
  300. // type: 'inside',
  301. // start: 0,
  302. // end: 100
  303. // },
  304. // {
  305. // start: 0,
  306. // end: 100
  307. // }
  308. // ],
  309. series: seriesdata
  310. };
  311. console.log(option);
  312. myChart.setOption(option);
  313. }
  314. }
  315. }
  316. </script>
  317. <style lang="scss" scoped>
  318. page{
  319. background-color: #fff;
  320. }
  321. .slot{
  322. display: flex;
  323. align-items: center;
  324. .img{
  325. width: 48rpx;
  326. height: 48rpx;
  327. margin-right: 4rpx;
  328. }
  329. }
  330. .main{
  331. padding: 32rpx;
  332. .title{
  333. .icon{
  334. width: 8rpx;
  335. height: 32rpx;
  336. margin-right: 8rpx;
  337. background-color: rgba(22,119,255,1);
  338. }
  339. .text{
  340. display: flex;
  341. align-items: center;
  342. color: rgb(16,16,16);
  343. font-size: 36rpx;
  344. margin-left: 12rpx;
  345. font-weight: bold;
  346. }
  347. }
  348. .chat{
  349. width: 100%;
  350. height: 480rpx;
  351. margin-top: 32rpx;
  352. .img{
  353. width: 100%;
  354. height: 100%;
  355. }
  356. }
  357. // 表格
  358. .table{
  359. margin-top: 60rpx;
  360. border-radius: 8px;
  361. z-index: 999;
  362. table{
  363. background-color:#f1f2f5 ;
  364. color: #101010;
  365. padding:20rpx 10rpx;
  366. width: 100%;
  367. td{
  368. text-align: right;
  369. }
  370. }
  371. }
  372. }
  373. </style>