data-service.vue 11 KB

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