saveUtilityIncome.vue 9.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484
  1. <template>
  2. <view>
  3. <u-navbar :title="typeName+'电费收入'" 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 class="tabsItem" v-if="!companyIdSet" @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. {{tabsFrom.show1Text}}
  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="total-group">
  22. <view class="statistics-total1">
  23. <view class="total-title">
  24. {{typeName}}电费(100%)
  25. </view>
  26. <view class="total-number">
  27. {{info.totalFee}}元
  28. </view>
  29. </view>
  30. <view class="statistics-total2">
  31. <view class="total-title">
  32. {{typeName}}电量
  33. </view>
  34. <view class="total-number">
  35. {{info.totalKwh}}度
  36. </view>
  37. </view>
  38. </view>
  39. <view class="statistics-group">
  40. <view class="statistics-item" v-for="(item,i) in info.list" :key="i"
  41. @click="showBtn(item)" >
  42. <view class="item-top">
  43. <view class="content">
  44. <!-- 电费 -->
  45. <view class="electricity">
  46. <view class="electricity-title">
  47. {{item.tenantName}}
  48. </view>
  49. <view class="electricity-number">
  50. {{item.fee}}元
  51. </view>
  52. </view>
  53. <!-- 节省度数 -->
  54. <view class="electric-quantity">
  55. <view class="electric-quantity-title">
  56. {{typeName}}度数
  57. </view>
  58. <view class="electric-quantity-number">
  59. {{item.kwh}}度
  60. </view>
  61. </view>
  62. </view>
  63. <view class="icon" >
  64. <u-icon name="arrow-up" v-if="item.show" color="#acacac" size="24"></u-icon>
  65. <u-icon name="arrow-down" v-else color="#acacac" size="24"></u-icon>
  66. </view>
  67. </view>
  68. <!-- 详情 -->
  69. <view class="detail" v-show="item.show">
  70. <view class="item" v-for="(it,j) in item.recordList" :key="j" >
  71. <!-- 时间段 -->
  72. <view class="time-slot">
  73. <view class="title">
  74. {{get(it.createTime,0)}}
  75. </view>
  76. <view class="value">
  77. {{it.fee}}元
  78. </view>
  79. </view>
  80. <!-- 总计 -->
  81. <view class="total">
  82. <view class="total-time">
  83. {{get(it.createTime,1)}}
  84. </view>
  85. <view class="total-degrees">
  86. {{it.kwh}}度
  87. </view>
  88. </view>
  89. </view>
  90. </view>
  91. </view>
  92. <u-divider :isnone="info.list.length==0" nonetext="没有找到相关内容"
  93. border-color="#CFD2D5">已经到底了</u-divider>
  94. </view>
  95. </view>
  96. </view>
  97. </template>
  98. <script>
  99. import * as API from '@/apis/pagejs/revenue.js'
  100. import {
  101. newDate,hourDistance
  102. } from '@/apis/utils'
  103. export default {
  104. data() {
  105. return {
  106. tabShow1: false,
  107. tabShow2: false,
  108. detail:true,
  109. selector: [1, 2, 3],
  110. id: "",
  111. companyId: "",
  112. companyIdSet: "",
  113. info: {
  114. list:[]
  115. },
  116. list: [],
  117. queryDate: "",
  118. queryMonth: "",
  119. monthQuery: "",
  120. params: {
  121. year: true,
  122. month: true,
  123. day: false,
  124. hour: false,
  125. minute: false,
  126. second: false
  127. },
  128. tabsFrom: {
  129. show1: false,
  130. show1Index: 0,
  131. show2Index: '',
  132. show2: false,
  133. show1Text: "全部",
  134. show2Text: "全部时间",
  135. selector1: [
  136. ]
  137. },
  138. endYear: "",
  139. type:0,
  140. }
  141. },
  142. computed:{
  143. typeName(){
  144. //type 1分摊2线损3停电
  145. if(this.type==1){
  146. return '分摊'
  147. }
  148. if(this.type==2){
  149. return '线损'
  150. }
  151. if(this.type==3){
  152. return '节约'
  153. }
  154. return ''
  155. }
  156. },
  157. onLoad(op) {
  158. this.endYear = new Date().getFullYear()
  159. this.id = op.id
  160. this.companyId = op.companyId
  161. this.companyIdSet = op.companyId
  162. this.type = op.type
  163. var date = newDate(op.query)
  164. this.queryDate = date.getFullYear() + "-" + (date.getMonth() + 1) + "-1"
  165. this.queryMonth = date.getFullYear() + "年" + (date.getMonth() + 1) + "月"
  166. this.tabsFrom.show2Index = date.getFullYear() + "-" + (date.getMonth() + 1)
  167. this.tabsFrom.show2Text = this.queryMonth
  168. this.monthQuery = (date.getMonth() + 1)
  169. //this.getInfo()
  170. this.getCompanyList()
  171. },
  172. methods: {
  173. showBtn(item){
  174. console.log(1)
  175. if(item.show==null){
  176. item.show=false
  177. }
  178. item.show=!item.show
  179. this.$forceUpdate()
  180. },
  181. get(time,t){
  182. //time="2024-08-01 11:11-2024-08-03 12:21"
  183. var str=''
  184. try{
  185. var sz1=time.substring(0,16)
  186. var sz2=time.substring(17)
  187. var time1=newDate(sz1)
  188. var time2=newDate(sz2)
  189. if(time1.getFullYear()!=time2.getFullYear()){
  190. if(!t){
  191. str='开始时间:'+sz1
  192. }else{
  193. str='结束时间:'+sz2
  194. }
  195. }else if(time1.getMonth()!=time2.getMonth()){
  196. if(!t){
  197. str=sz1+"至"+sz2.substring(5)
  198. }else{
  199. str=hourDistance(time1,time2,1)
  200. }
  201. }else {
  202. if(!t){
  203. str=sz1.substring(5)+"至"+sz2.substring(5)
  204. }else{
  205. str=hourDistance(time1,time2,1)
  206. }
  207. }
  208. }catch(e){
  209. //TODO handle the exception
  210. if(!t){
  211. str=time
  212. }else{
  213. str=''
  214. }
  215. }
  216. return str
  217. },
  218. selector2confirm(e) {
  219. this.tabsFrom.show2Text = e.year + "年" + e.month + "月"
  220. this.tabsFrom.show2Index = e.year + "-" + e.month
  221. this.queryMonth = e.year + "年" + e.month + "月"
  222. this.queryDate = e.year + "-" + e.month + "-1"
  223. this.getInfo()
  224. },
  225. selector1confirm(e, b) {
  226. var index = e[0]
  227. this.tabsFrom.show1Index = index
  228. this.tabsFrom.show1Text = this.tabsFrom.selector1[index].label
  229. this.companyId = this.tabsFrom.selector1[index].value;
  230. if (!b) {
  231. this.getInfo()
  232. }
  233. },
  234. getInfo() {
  235. uni.showLoading({
  236. title: "加载中",
  237. mask: true,
  238. })
  239. API.platformRevenueTypeList({
  240. companyId: this.companyId,
  241. queryDate: this.queryDate,
  242. type:this.type
  243. }).then((response) => {
  244. uni.hideLoading();
  245. var list = response.data.incomeList
  246. if (list.length) {
  247. this.info = list[0]
  248. }else{
  249. this.info = {}
  250. }
  251. }).catch(error => {
  252. uni.showToast({
  253. title: error,
  254. icon: "none"
  255. })
  256. })
  257. },
  258. getCompanyList() {
  259. API.platformCompanyList({
  260. parentId:this.id
  261. }).then((response) => {
  262. //uni.hideLoading();
  263. var list = response.data.companyInfoList;
  264. if(list.length){
  265. this.companyId=list[0].id
  266. var i = 0;
  267. var k = 0
  268. this.tabsFrom.selector1 = list.map((item) => {
  269. if (item.id == this.companyIdSet) {
  270. k = i
  271. }
  272. i++;
  273. return {
  274. label: item.name,
  275. value: item.id
  276. }
  277. })
  278. this.selector1confirm([k], true)
  279. this.getInfo()
  280. }
  281. }).catch(error => {
  282. uni.showToast({
  283. title: error,
  284. icon: "none"
  285. })
  286. })
  287. }
  288. }
  289. }
  290. </script>
  291. <style>
  292. page {
  293. padding-bottom: 100px;
  294. background-color: #fff;
  295. }
  296. </style>
  297. <style lang="scss" scoped>
  298. // 标签
  299. .tabs {
  300. height: 96rpx;
  301. line-height: 96rpx;
  302. background-color: #fff;
  303. border-top: 1px solid rgba(241, 241, 241, 1);
  304. display: flex;
  305. justify-content: space-around;
  306. }
  307. // 统计
  308. .statistics {
  309. .total-group {
  310. background-color: rgba(22, 119, 255, 1);
  311. padding: 24rpx 32rpx
  312. }
  313. .statistics-total1 {
  314. display: flex;
  315. align-items: center;
  316. justify-content: space-between;
  317. color: rgba(255, 255, 255, 1);
  318. font-size: 32rpx;
  319. font-weight: bold;
  320. margin-bottom: 4rpx;
  321. }
  322. .statistics-total2 {
  323. display: flex;
  324. align-items: center;
  325. justify-content: space-between;
  326. color: rgba(255, 255, 255, 1);
  327. font-size: 24rpx;
  328. font-weight: bold;
  329. }
  330. .statistics-group {
  331. .statistics-item {
  332. border-bottom: 1px solid rgba(245, 245, 245, 1);
  333. .item-top {
  334. display: flex;
  335. align-items: center;
  336. justify-content: space-between;
  337. padding: 24rpx 32rpx;
  338. }
  339. .content {
  340. flex: 0.99;
  341. // 电费
  342. .electricity {
  343. display: flex;
  344. align-items: center;
  345. justify-content: space-between;
  346. font-size: 32rpx;
  347. font-weight: bold;
  348. .electricity-title {
  349. color: rgba(51, 51, 51, 1);
  350. }
  351. .electricity-number {
  352. color: rgba(22, 119, 255, 1);
  353. white-space: pre;
  354. }
  355. }
  356. // 电量
  357. .electric-quantity {
  358. display: flex;
  359. align-items: center;
  360. justify-content: space-between;
  361. font-size: 24rpx;
  362. color: rgba(119, 119, 119, 1);
  363. }
  364. }
  365. }
  366. }
  367. .detail {
  368. background-color: rgba(242, 242, 242, 1);
  369. .item {
  370. padding: 24rpx 48rpx 24rpx 76rpx;
  371. border-bottom: 1px solid rgba(234,234,234,1);
  372. // 时间段
  373. .time-slot{
  374. display: flex;
  375. align-items: center;
  376. justify-content: space-between;
  377. font-size: 32rpx;
  378. font-weight: bold;
  379. .title{
  380. color: rgba(51,51,51,1);
  381. }
  382. .value{
  383. color: rgba(22,119,255,1);
  384. }
  385. }
  386. // 总计
  387. .total{
  388. font-size: 24rpx;
  389. display: flex;
  390. align-items: center;
  391. justify-content: space-between;
  392. .total-time{
  393. font-size: 32rpx;
  394. color: rgba(51,51,51,1);
  395. //color: rgba(119,119,119,1);
  396. }
  397. .total-degrees{
  398. color: rgba(119,119,119,1);
  399. }
  400. }
  401. }
  402. }
  403. }
  404. </style>