data-service.vue 8.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328
  1. <template>
  2. <view class="">
  3. <!-- 园区数据统计 -->
  4. <view class="">
  5. <view class="title">
  6. <image src="../../../static/icon/tag1.png" mode=""></image>
  7. <text>园区数据统计</text>
  8. </view>
  9. <view class="data-statistics" v-if="loading">
  10. <view class="item" v-for="(item,index) in agencyStatistical" :key="index">
  11. <view class="data">
  12. <text>{{item.num}}</text>
  13. <text>{{item.title}}</text>
  14. </view>
  15. </view>
  16. </view>
  17. <view v-else class="flex justify-center align-center padding-50">
  18. <u-loading mode="flower" size="150"></u-loading>
  19. </view>
  20. </view>
  21. <!-- 分割线 -->
  22. <view class="" style="background-color: #F1F1F1;height: 20rpx;"></view>
  23. <!-- 园区当日动态 begin-->
  24. <!-- <view class="title">
  25. <image src="../../../static/icon/tag1.png" mode=""></image>
  26. <text>园区当日动态</text>
  27. </view>
  28. <view class="desc">
  29. <view class="flex">
  30. <view class="bg-green progress"></view>
  31. <text class="padding-left-10">内部(人)</text>
  32. </view>
  33. </view>
  34. <view class="desc">
  35. <view class="flex">
  36. <view class="bg-red progress"></view>
  37. <text class="padding-left-10">外部(人)</text>
  38. </view>
  39. </view>
  40. <view class="today-statistics margin-top-20">
  41. <view style="width: 30%;margin-top: 5rpx;">
  42. <text>驶入车辆:</text>
  43. </view>
  44. <view class="cu-progress radius striped active margin-top-10">
  45. <view class="bg-green" :style="[{ width:loading?todayData.enterCarOfInsidePercen+'%':''}]">
  46. {{todayData.enterCarOfInside}}</view>
  47. <view v-if="todayData.enterCarOfOutside!=0" class="bg-red"
  48. :style="[{ width:loading?todayData.enterCarOfOutsidePercen+'%':''}]">{{todayData.enterCarOfOutside}}
  49. </view>
  50. </view>
  51. </view>
  52. <view class="today-statistics">
  53. <view style="width: 30%;margin-top: 5rpx;">
  54. <text>驶出车辆:</text>
  55. </view>
  56. <view class="cu-progress radius striped active margin-top-10">
  57. <view class="bg-green" :style="[{ width:loading?todayData.departCarOfInsidePercen+'%':''}]">
  58. {{todayData.departCarOfInside}}</view>
  59. <view v-if="todayData.departCarOfOutside!=0" class="bg-red"
  60. :style="[{ width:loading?todayData.departCarOfOutsidePercen+'%':''}]">
  61. {{todayData.departCarOfOutside}}</view>
  62. </view>
  63. </view>
  64. <view class="today-statistics">
  65. <view style="width: 30%;margin-top: 5rpx;">
  66. <text>人员统计:</text>
  67. </view>
  68. <view class="cu-progress radius striped active margin-top-10">
  69. <view class="bg-green" :style="[{ width:loading?'100%':''}]">{{todayData.peopleNum}}</view>
  70. </view>
  71. </view>
  72. <pie :pieData="pieData" v-if="!$isEmpty(pieData)"></pie> -->
  73. <!-- 园区当日动态 begin-->
  74. <!-- 分割线 -->
  75. <!-- <view class="" style="background-color: #F1F1F1;height: 20rpx;"></view> -->
  76. <view class="title">
  77. <image src="../../../static/icon/tag1.png" mode=""></image>
  78. <text>近10天用电量</text>
  79. </view>
  80. <line :lineJson="lineJson" v-if="!$isEmpty(lineJson)"></line>
  81. <!-- 分割线 -->
  82. <view class="" style="background-color: #F1F1F1;height: 20rpx;"></view>
  83. <view class="title">
  84. <image src="../../../static/icon/tag1.png" mode=""></image>
  85. <text>人员进出记录</text>
  86. </view>
  87. <in-out-records></in-out-records>
  88. </view>
  89. </template>
  90. <script>
  91. import pie from "./canvas/pie.vue"
  92. import inOutRecords from "./canvas/in-out-records.vue"
  93. import line from "./canvas/Line.vue"
  94. var that;
  95. export default {
  96. components: {
  97. pie,
  98. inOutRecords,
  99. line
  100. },
  101. data() {
  102. return {
  103. //园区
  104. agencyId: '',
  105. tenantId: '',
  106. loading: false,
  107. //园区数据统计
  108. agencyStatistical: [],
  109. //园区当日动态
  110. todayData: {},
  111. lineJson: {},
  112. pieData: {}
  113. };
  114. },
  115. created() {
  116. that = this;
  117. this.agencyId = this.$cache.get('agencyId')
  118. this.tenantId = this.$cache.get('agencyTenantId')
  119. //园区数据统计
  120. this.fetchAgencyData()
  121. this.fetchTodayData()
  122. this.fetchElectricMeter()
  123. setTimeout(function() {
  124. that.loading = true
  125. }, 500)
  126. },
  127. methods: {
  128. async fetchElectricMeter() {
  129. let aelectricMeterStaticgencyId = this.$cache.get('agencyId')
  130. let res = await this.$api.statistical.electricMeterStatic({
  131. agencyId: this.agencyId
  132. })
  133. this.lineJson = {
  134. "categories": res.data.dates.slice(0, 10),
  135. series: [{
  136. name: '电表用量(Kwh)',
  137. data: res.data.values.slice(0, 10),
  138. color: '#5064eb'
  139. }]
  140. }
  141. },
  142. // 园区数据统计
  143. fetchAgencyData() {
  144. this.$api.statistical.agencyStatistical({
  145. id: this.agencyId
  146. }).then(res => {
  147. this.agencyStatistical = [{
  148. title: '园区分区',
  149. num: res.residentials.length
  150. },
  151. {
  152. title: '楼宇总数',
  153. num: res.buildingCount
  154. },
  155. {
  156. title: '企业总数',
  157. num: res.enterpriseCount
  158. },
  159. {
  160. title: '员工总数',
  161. num: res.staffCount
  162. },
  163. {
  164. title: '正常设备',
  165. num: res.safetyDeviceCount
  166. },
  167. {
  168. title: '告警总数',
  169. num: res.warningDeviceCount
  170. },
  171. ]
  172. })
  173. },
  174. //今日动态
  175. fetchTodayData() {
  176. let params = {
  177. agencyId: this.agencyId,
  178. tenantId: this.tenantId
  179. }
  180. this.$api.statistical.todayData(params).then(res => {
  181. this.todayData = res.data
  182. //驶入车辆总数
  183. let enterTotal = this.todayData.enterCarOfInside + this.todayData.enterCarOfOutside
  184. //内部驶入车辆百分比
  185. this.todayData.enterCarOfInsidePercen = this.$util.keepTwoDecimalFull(this.todayData
  186. .enterCarOfInside / enterTotal) * 100
  187. //外部驶入车辆百分比
  188. this.todayData.enterCarOfOutsidePercen = 100 - this.todayData.enterCarOfInsidePercen
  189. //驶出车辆总数
  190. let departTotal = this.todayData.departCarOfOutside + this.todayData.departCarOfInside
  191. //内部驶出车辆百分比
  192. this.todayData.departCarOfInsidePercen = this.$util.keepTwoDecimalFull(this.todayData
  193. .departCarOfInside / departTotal) * 100
  194. //外部驶出车辆百分比
  195. this.todayData.departCarOfOutsidePercen = 100 - this.todayData.departCarOfInsidePercen
  196. //内部与外部人车辆进出的比例
  197. let insideTotal = this.todayData.departCarOfInside + this.todayData.enterCarOfInside
  198. let outsideTotal = this.todayData.departCarOfOutside + this.todayData.enterCarOfOutside
  199. let carTotal = this.todayData.departCarOfInside + this.todayData.departCarOfOutside +
  200. this.todayData.enterCarOfInside + this.todayData.enterCarOfOutside
  201. this.pieData = {
  202. insideTotal,
  203. outsideTotal,
  204. carTotal,
  205. peopleNum: this.todayData.peopleNum
  206. }
  207. console.log(this.pieData);
  208. })
  209. },
  210. }
  211. };
  212. </script>
  213. <style lang="scss">
  214. .bg-red {
  215. background-color: #d10000;
  216. color: #FFFFFF;
  217. }
  218. .bg-green {
  219. background-color: #11914d;
  220. color: #FFFFFF;
  221. }
  222. //描述
  223. .desc {
  224. display: flex;
  225. justify-content: flex-end;
  226. align-items: center;
  227. padding: 0 30rpx 0 50rpx;
  228. .progress {
  229. margin-top: 15rpx;
  230. margin-right: 10rpx;
  231. width: 40rpx;
  232. height: 10rpx;
  233. }
  234. }
  235. //当日统计
  236. .today-statistics {
  237. padding: 20rpx 40rpx;
  238. display: flex;
  239. }
  240. //描述
  241. .title {
  242. padding: 30rpx;
  243. display: flex;
  244. image {
  245. width: 45rpx;
  246. height: 45rpx;
  247. display: block;
  248. padding-top: 10rpx;
  249. padding-right: 10rpx;
  250. }
  251. text {
  252. font-size: 36rpx;
  253. font-weight: 800;
  254. }
  255. }
  256. //园区数据统计
  257. .data-statistics {
  258. display: flex;
  259. flex-wrap: wrap;
  260. justify-content: space-around;
  261. .item {
  262. box-shadow: 10rpx 10rpx 10rpx #d1d1d1;
  263. width: 28%;
  264. height: 140rpx;
  265. margin: 20rpx 15rpx;
  266. background-image: linear-gradient(to top right, #55aaff, #4759d0);
  267. border-radius: 10rpx;
  268. color: #FFFFFF;
  269. .data {
  270. display: flex;
  271. justify-content: center;
  272. align-items: center;
  273. flex-direction: column;
  274. font-size: 28rpx;
  275. height: 100%;
  276. text:first-child {
  277. margin-bottom: 10rpx;
  278. font-size: 45rpx;
  279. }
  280. }
  281. }
  282. .item:hover {
  283. box-shadow: 0rpx 0rpx 0rpx #d1d1d1;
  284. background-color: $base-color;
  285. }
  286. .item:active {
  287. background-image: linear-gradient(to top right, #55aaff, #4759d0);
  288. box-shadow: 10rpx 10rpx 10rpx #d1d1d1;
  289. transform: translateY(4px);
  290. }
  291. }
  292. </style>