platformRevenueStatistics.vue 9.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448
  1. <template>
  2. <view>
  3. <u-navbar :title="(companyId?'园区营增':'平台')+'收入统计'" title-color="#101010"></u-navbar>
  4. <!-- 标签 -->
  5. <view class="tabs">
  6. <u-picker v-model="tabsFrom.show1" :default-selector="[tabsFrom.show1Index]" mode="selector"
  7. :range="tabsFrom.selector1" range-key="label" @confirm="selector1confirm"></u-picker>
  8. <u-picker-select title="日期选择" v-model="tabsFrom.show2" :defaultTime="tabsFrom.show2Index" :endYear="endYear"
  9. :noselect="false" mode="time" :params="params" @confirm="selector2confirm"
  10. @reset="selector2reset"></u-picker-select>
  11. <view v-if="!companyId" class="tabsItem" @click="tabsFrom.show1=!tabsFrom.show1">{{tabsFrom.show1Text}} <u-icon
  12. name="arrow-up" v-if="tabsFrom.show1"></u-icon><u-icon v-else name="arrow-down"></u-icon></view>
  13. <view v-else >
  14. {{info.companyName}}
  15. </view>
  16. <view class="tabsItem" @click="tabsFrom.show2=!tabsFrom.show2">{{tabsFrom.show2Text}} <u-icon
  17. name="arrow-up" v-if="tabsFrom.show2"></u-icon><u-icon v-else name="arrow-down"></u-icon></view>
  18. </view>
  19. <!-- 统计 -->
  20. <view class="statistics">
  21. <view class="statistics-total">
  22. <view class="total-title">
  23. {{monthQuery}}月预计收入
  24. </view>
  25. <view class="total-number">
  26. {{info.totalFee}}元
  27. </view>
  28. </view>
  29. <view class="statistics-group">
  30. <view @click="gotoInfo(2)"
  31. class="statistics-item">
  32. <view class="content">
  33. <!-- 收入 -->
  34. <view class="income">
  35. <view class="income-title">
  36. 线损电费收入({{info.ratio}}%)
  37. </view>
  38. <view class="income-number">
  39. {{info.lineLossFee}}元
  40. </view>
  41. </view>
  42. <!-- 电量 -->
  43. <view class="electric-quantity">
  44. <view class="electric-quantity-title">
  45. 线损电量
  46. </view>
  47. <view class="electric-quantity-number">
  48. {{info.lineLossKwh}}度
  49. </view>
  50. </view>
  51. </view>
  52. <view class="icon">
  53. <u-icon name="arrow-right" color="#acacac" size="24"></u-icon>
  54. </view>
  55. </view>
  56. <view @click="gotoInfo(1)" class="statistics-item">
  57. <view class="content">
  58. <!-- 收入 -->
  59. <view class="income">
  60. <view class="income-title">
  61. 分摊电费收入({{info.ratio}}%)
  62. </view>
  63. <view class="income-number">
  64. {{info.sharedFee}}元
  65. </view>
  66. </view>
  67. <!-- 电量 -->
  68. <view class="electric-quantity">
  69. <view class="electric-quantity-title">
  70. 分摊电量
  71. </view>
  72. <view class="electric-quantity-number">
  73. {{info.sharedKwh}}度
  74. </view>
  75. </view>
  76. </view>
  77. <view class="icon">
  78. <u-icon name="arrow-right" color="#acacac" size="24"></u-icon>
  79. </view>
  80. </view>
  81. <view @click="gotoInfo(3)" class="statistics-item">
  82. <view class="content">
  83. <!-- 收入 -->
  84. <view class="income">
  85. <view class="income-title">
  86. 节约电费收入({{info.ratio}}%)
  87. </view>
  88. <view class="income-number">
  89. {{info.switchFee}}元
  90. </view>
  91. </view>
  92. <!-- 电量 -->
  93. <view class="electric-quantity">
  94. <view class="electric-quantity-title">
  95. 节约电量
  96. </view>
  97. <view class="electric-quantity-number">
  98. {{info.switchKwh}}度
  99. </view>
  100. </view>
  101. </view>
  102. <view class="icon">
  103. <u-icon name="arrow-right" color="#acacac" size="24"></u-icon>
  104. </view>
  105. </view>
  106. </view>
  107. </view>
  108. <!-- 图表 -->
  109. <view class="chart">
  110. <view id="pieEcharts" >
  111. </view>
  112. </view>
  113. </view>
  114. </template>
  115. <script>
  116. import * as API from '@/apis/pagejs/revenue.js'
  117. import * as echarts from "echarts";
  118. export default {
  119. data() {
  120. return {
  121. tabShow1: false,
  122. tabShow2: false,
  123. selector: [1, 2, 3],
  124. id: "",
  125. info: {},
  126. list: [],
  127. queryDate: "",
  128. queryMonth: "",
  129. monthQuery: "",
  130. params: {
  131. year: true,
  132. month: true,
  133. day: false,
  134. hour: false,
  135. minute: false,
  136. second: false
  137. },
  138. tabsFrom: {
  139. show1: false,
  140. show1Index: 0,
  141. show2Index: '',
  142. show2: false,
  143. show1Text: "全部类型",
  144. show2Text: "全部时间",
  145. selector1: [{
  146. label: '全部类型',
  147. value: '',
  148. },
  149. {
  150. label: '线上充值',
  151. value: '1',
  152. },
  153. {
  154. label: '线下充值',
  155. value: '2',
  156. },
  157. ]
  158. },
  159. endYear: "",
  160. myChart: null,
  161. companyId:"",
  162. }
  163. },
  164. onLoad(op) {
  165. this.endYear = new Date().getFullYear()
  166. this.id = op.id
  167. this.companyId = op.companyId
  168. var date = new Date()
  169. this.queryDate = date.getFullYear() + "-" + (date.getMonth() + 1) + "-1"
  170. this.queryMonth = date.getFullYear() + "年" + (date.getMonth() + 1) + "月"
  171. this.tabsFrom.show2Text = this.queryMonth
  172. this.monthQuery = (date.getMonth() + 1)
  173. if(this.id){
  174. this.getInfo()
  175. }
  176. this.getCompanyList()
  177. },
  178. methods: {
  179. gotoInfo(i){
  180. var url="/pages/platformRevenueStatistics/saveUtilityIncome?id="+this.id+"&type="+i+"&query="+this.queryDate
  181. if(this.companyId ){
  182. url+="&companyId="+this.info.companyId
  183. }
  184. uni.navigateTo({
  185. url:url
  186. })
  187. },
  188. selector2confirm(e) {
  189. this.tabsFrom.show2Text = e.year + "年" + e.month + "月"
  190. this.tabsFrom.show2Index = e.year + "-" + e.month
  191. this.queryMonth = e.year + "年" + e.month + "月"
  192. this.queryDate = e.year + "-" + e.month + "-1"
  193. this.getInfo()
  194. },
  195. selector1confirm(e, b) {
  196. var index = e[0]
  197. this.tabsFrom.show1Index = index
  198. this.tabsFrom.show1Text = this.tabsFrom.selector1[index].label
  199. this.id = this.tabsFrom.selector1[index].value;
  200. if (!b) {
  201. this.getInfo()
  202. }
  203. },
  204. getInfo() {
  205. uni.showLoading({
  206. title: "加载中",
  207. mask: true,
  208. })
  209. API.platformRevenue({
  210. companyId: this.id,
  211. queryDate: this.queryDate
  212. }).then((response) => {
  213. uni.hideLoading();
  214. var list = response.data.incomeList
  215. if (list.length) {
  216. this.info = list[0]
  217. this.getPle()
  218. } else {
  219. this.info = {}
  220. if (this.myChart) {
  221. this.myChart.clear()
  222. }
  223. }
  224. }).catch(error => {
  225. uni.showToast({
  226. title: error,
  227. icon: "none"
  228. })
  229. })
  230. },
  231. getPle(list) {
  232. if (!this.myChart) {
  233. this.myChart = echarts.init(document.getElementById('pieEcharts'), null, {
  234. width: uni.upx2px(700),
  235. height: uni.upx2px(480)
  236. });
  237. }
  238. this.myChart.clear();
  239. var option = {
  240. tooltip: {
  241. trigger: 'item'
  242. },
  243. grid: {
  244. top: 30,
  245. left: 20,
  246. right: 30,
  247. bottom: 20,
  248. containLabel: true
  249. },
  250. series: [{
  251. type: 'pie',
  252. radius: ['40%', '70%'],
  253. avoidLabelOverlap: false,
  254. label: {
  255. show: true,
  256. formatter: '{b}\n\t{c}元'
  257. },
  258. data: [{
  259. value: this.info.lineLossFee,
  260. name: '线损电费',
  261. itemStyle:{
  262. color:"#ef8132"
  263. }
  264. },
  265. {
  266. value: this.info.sharedFee,
  267. name: '分摊电费',
  268. itemStyle:{
  269. color:"#99bd3a"
  270. }
  271. },
  272. {
  273. value: this.info.switchFee,
  274. name: '节约电费',
  275. itemStyle:{
  276. color:"#53b56b"
  277. }
  278. }
  279. ]
  280. }]
  281. };
  282. console.log(option)
  283. this.myChart.setOption(option);
  284. },
  285. getCompanyList() {
  286. API.platformCompanyList({
  287. // parentId:this.companyId
  288. }).then((response) => {
  289. //uni.hideLoading();
  290. var list = response.data.companyInfoList;
  291. if(!this.id){
  292. this.id=list[0].id
  293. this.getInfo()
  294. }
  295. var i = 0;
  296. var k = 0
  297. this.tabsFrom.selector1 = list.map((item) => {
  298. if (item.id == this.id) {
  299. k = i
  300. }
  301. i++;
  302. return {
  303. label: item.name,
  304. value: item.id
  305. }
  306. })
  307. this.selector1confirm([k], true)
  308. }).catch(error => {
  309. uni.showToast({
  310. title: error,
  311. icon: "none"
  312. })
  313. })
  314. }
  315. }
  316. }
  317. </script>
  318. <style>
  319. page {
  320. padding-bottom: 100px;
  321. background-color: #fff;
  322. }
  323. </style>
  324. <style lang="scss" scoped>
  325. // 标签
  326. .tabs {
  327. height: 96rpx;
  328. line-height: 96rpx;
  329. background-color: #fff;
  330. border-top: 1px solid rgba(241, 241, 241, 1);
  331. display: flex;
  332. justify-content: space-around;
  333. }
  334. // 统计
  335. .statistics {
  336. .statistics-total {
  337. display: flex;
  338. align-items: center;
  339. justify-content: space-between;
  340. padding: 36rpx 32rpx;
  341. //background-color: rgba(22, 119, 255, 1);
  342. background: linear-gradient(88.25deg, rgba(31,85,255,1) 0.65%,rgba(39,171,255,1) 99.34%);
  343. color: rgba(255, 255, 255, 1);
  344. font-size: 40rpx;
  345. font-weight: bold;
  346. }
  347. .statistics-group {
  348. .statistics-item {
  349. padding: 24rpx 32rpx;
  350. display: flex;
  351. align-items: center;
  352. justify-content: space-between;
  353. border-bottom: 1px solid rgba(245, 245, 245, 1);
  354. .content {
  355. flex: 0.99;
  356. // 收入
  357. .income {
  358. display: flex;
  359. align-items: center;
  360. justify-content: space-between;
  361. font-size: 32rpx;
  362. font-weight: bold;
  363. .income-title {
  364. color: rgba(51, 51, 51, 1);
  365. }
  366. .income-number {
  367. color: rgba(22, 119, 255, 1);
  368. }
  369. }
  370. // 电量
  371. .electric-quantity {
  372. display: flex;
  373. align-items: center;
  374. justify-content: space-between;
  375. font-size: 24rpx;
  376. color: rgba(119, 119, 119, 1);
  377. }
  378. }
  379. }
  380. }
  381. }
  382. // 图表
  383. .chart {
  384. margin-top: 40rpx;
  385. padding: 0 15rpx;
  386. img {
  387. width: 100%;
  388. height: 600rpx;
  389. }
  390. }
  391. </style>