deductionRecord.vue 15 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690
  1. <template>
  2. <view>
  3. <u-navbar title="扣费记录" title-color="#101010" >
  4. </u-navbar>
  5. <view class="tabs-box" v-if="!popShow" >
  6. <view class="tabs1" v-show="tenantList.length>1" :style="{width: tenantList.length>4 ? '' : '100%'}" >
  7. <u-tabs :list="tenantList1" inactive-color="#777777" active-color="#333333 "
  8. bg-color="#fff" :is-scroll="false" :current="current" @change="change"></u-tabs>
  9. </view>
  10. <view class="icon" @click="popShow=true" v-if="tenantList.length >= 4" >
  11. <u-icon name="arrow-down" color="#777777" size="28"></u-icon>
  12. </view>
  13. </view>
  14. <!-- 标签弹出层 -->
  15. <u-popup v-model="popShow" @close="keyword=''" length="80%" duration="10" mode="top" :negative-top="188" border-radius="32">
  16. <u-navbar title="扣费记录" title-color="#101010" >
  17. </u-navbar>
  18. <view class="head-head">
  19. <u-search placeholder="请输入关键字" :show-action="false" v-model="keyword"></u-search>
  20. </view>
  21. <view class="head-head-placeholder ">
  22. </view>
  23. <view class="popup-tabs" v-if="false">
  24. <view class="tabs1">
  25. <!-- <u-tabs :list="tenantList1" inactive-color="#777777" active-color="#333333 "
  26. bg-color="#fff" :is-scroll="false" :current="current" @change="change"></u-tabs> -->
  27. <u-tabs :list="tenantList1" :is-scroll="false" :current="current" @change="change"></u-tabs >
  28. </view>
  29. <view class="more">
  30. <u-icon name="arrow-up" color="#777777" size="40" @click="popShow=false"></u-icon>
  31. </view>
  32. </view>
  33. <view class="tabs-options">
  34. <view class="item" v-for="(item, index) in tenantList"
  35. v-show="keyword==''||(item.name&&item.name.indexOf(keyword)!=-1)"
  36. :class="{
  37. 'item-index' : item.id==formData.tenantId
  38. }"
  39. :key="index"
  40. @click="merchantChange(item,index)">
  41. {{item.name}}
  42. </view>
  43. <u-divider nonetext="没有找到相关内容"
  44. border-color="#CFD2D5">已经到底了</u-divider>
  45. </view>
  46. </u-popup>
  47. <!-- 折线图-->
  48. <view class="chart-box">
  49. <view class="infos">
  50. <view class="item">
  51. <view class="title">
  52. {{monthQuery}}月 共扣费
  53. </view>
  54. <view class="sum">
  55. {{monthAmount}}<text class="unit">元</text>
  56. </view>
  57. </view>
  58. <view class="item">
  59. <view class="title">
  60. 账户余额
  61. </view>
  62. <view class="sum">
  63. {{balance}}<text class="unit">元</text>
  64. </view>
  65. </view>
  66. </view>
  67. <view class="chart">
  68. <view id="pieEcharts" >
  69. </view>
  70. </view>
  71. </view>
  72. <!-- 标签 -->
  73. <view class="tabs">
  74. <u-picker v-model="tabsFrom.show1" mode="selector" :range="tabsFrom.selector1" range-key="label" @confirm="selector1confirm" ></u-picker>
  75. <u-picker-select title="日期选择" v-model="tabsFrom.show2"
  76. :defaultTime="tabsFrom.show2Index" :endYear="endYear"
  77. mode="time" :params="params" @confirm="selector2confirm" @reset="selector2reset" ></u-picker-select>
  78. <view class="tabsItem" @click="tabsFrom.show1=!tabsFrom.show1">{{tabsFrom.show1Text}} <u-icon name="arrow-up"
  79. v-if="tabsFrom.show1"></u-icon><u-icon v-else name="arrow-down"></u-icon></view>
  80. <view class="tabsItem" @click="tabsFrom.show2=!tabsFrom.show2">{{tabsFrom.show2Text}} <u-icon name="arrow-up"
  81. v-if="tabsFrom.show2"></u-icon><u-icon v-else name="arrow-down"></u-icon></view>
  82. </view>
  83. <!-- 记录 -->
  84. <view class="records-item" >
  85. <view class="time">
  86. {{queryMonth}} 合计扣费 {{jpAmount(sumAmount)}}元
  87. </view>
  88. <view class="details" v-for="(item,i) in list"
  89. @click="gotoUrl('/pages/deductionRecord/deductionDetails?id='+item.id)"
  90. :key="i" >
  91. <view class="icon">
  92. <image class="img" v-if="item.remark.indexOf('水')>-1" src="@/assets/img/wImage@1x.png" mode=""></image>
  93. <image class="img" v-else-if="item.remark.indexOf('房')>-1||item.remark.indexOf('租')>-1" src="@/assets/img/wImage.png" mode=""></image>
  94. <image class="img" v-else-if="item.remark.indexOf('保洁')>-1" src="@/assets/img/wImage3.png" mode=""></image>
  95. <image class="img" v-else-if="item.remark.indexOf('物业')>-1" src="@/assets/img/wImage4.png" mode=""></image>
  96. <image class="img" v-else src="@/assets/img/Copy PEokWS2 Copy 1@1x.png" mode=""></image>
  97. </view>
  98. <view class="details-title">
  99. <view class="name">
  100. {{item.remark}}
  101. </view>
  102. <view class="record-time">
  103. {{item.createTime}}
  104. </view>
  105. <view class="record-time" v-if="item.extraInfo" v-html="extraInfoText(item.extraInfo)" >
  106. </view>
  107. </view>
  108. <view class="sum">
  109. {{jpAmount(item.amount)}}元
  110. <u-icon name="arrow-right" style="margin-left: 10rpx;" size="32" color="#999999"></u-icon>
  111. </view>
  112. </view>
  113. <u-divider :isnone="list.length==0" nonetext="没有找到相关内容"
  114. border-color="#CFD2D5">已经到底了</u-divider>
  115. </view>
  116. </view>
  117. </template>
  118. <script>
  119. import * as API from '@/apis/pagejs/tenantList.js'
  120. import {
  121. nextDay,
  122. nextMonth,
  123. } from '@/apis/utils'
  124. import * as echarts from "echarts";
  125. export default {
  126. data() {
  127. return {
  128. popShow:false,
  129. monthQuery:"",
  130. tenantList:[],
  131. tenantList1:[],
  132. monthAmount:0,
  133. balance:0,
  134. personInfo:{},
  135. myChart:null,
  136. list:[],
  137. list1: [{
  138. name: '格莱慧'
  139. }, {
  140. name: '楚之源'
  141. }, {
  142. name: '杜宝银',
  143. }, {
  144. name: '王玉清',
  145. }, {
  146. name: '荆州万乘',
  147. }],
  148. current:0,
  149. formData:{
  150. pageIndex:1,
  151. pageSize:9999,
  152. },
  153. endYear:'',
  154. keyword:"",
  155. queryMonth:"",
  156. params: {
  157. year: true,
  158. month: true,
  159. day: false,
  160. hour: false,
  161. minute: false,
  162. second: false
  163. },
  164. tabsFrom: {
  165. show1: false,
  166. show1Index:0,
  167. show2Index:'',
  168. show2: false,
  169. show1Text: "全部类型",
  170. show2Text: "全部时间",
  171. selector1:[
  172. {
  173. label: '全部类型',
  174. value: '',
  175. },
  176. {
  177. label: '线上充值',
  178. value: '1',
  179. },
  180. {
  181. label: '线下充值',
  182. value: '2',
  183. },
  184. ]
  185. },
  186. }
  187. },
  188. onLoad(op) {
  189. if(op.id){
  190. this.formData.tenantId=op.id
  191. }
  192. this.endYear=new Date().getFullYear()
  193. var date=new Date()
  194. this.formData.startDate=date.getFullYear()+"-"+(date.getMonth() + 1) +"-1"
  195. this.queryMonth=date.getFullYear()+"年"+(date.getMonth() + 1) +"月"
  196. this.monthQuery=(date.getMonth() + 1) +"月"
  197. },
  198. onReady() {
  199. this.getTenantList()
  200. this.merchantChangeApi()
  201. },
  202. onShow(){
  203. },
  204. computed:{
  205. sumAmount(){
  206. let totalAmount =0
  207. if(this.list){
  208. var amounts=this.list.map(item=>{
  209. return item.amount*-1
  210. })
  211. totalAmount = amounts.reduce((accumulator, currentValue) => {
  212. return accumulator + currentValue;
  213. }, 0);
  214. }
  215. return totalAmount
  216. }
  217. },
  218. methods: {
  219. merchantChangeApi(){
  220. this.contractItemList()
  221. this.deductionRecord();
  222. this.deductionRecordGraph();
  223. },
  224. change(index) {
  225. this.current = index;
  226. this.formData.tenantId = this.tenantList1[index].id;
  227. this.popShow = false;
  228. this.merchantChangeApi()
  229. },
  230. merchantChange(item, index) {
  231. // if(this.current==0){
  232. // this.current=1;
  233. // }
  234. this.formData.tenantId= item.id;
  235. //this.$forceUpdate()
  236. this.getTenantListSort(this.tenantList)
  237. this.merchantChangeApi()
  238. this.popShow = false;
  239. },
  240. getTenantListSort(list){
  241. for(var i in list){
  242. var obj=list[i]
  243. if(this.formData.tenantId==obj.id){
  244. var obj1=list[this.current];
  245. list[this.current]=obj;
  246. list[i]=obj1;
  247. }
  248. }
  249. this.tenantList=list;
  250. var mList1 = [];
  251. for (var i = 0; i < list.length; i++) {
  252. if (i >= 4) {
  253. } else {
  254. mList1.push(list[i]);
  255. }
  256. }
  257. this.tenantList1 = mList1;
  258. },
  259. getTenantList(){
  260. uni.showLoading({
  261. title: "加载中",
  262. mask: true,
  263. })
  264. API.tenantList().then((response) => {
  265. uni.hideLoading();
  266. var list=response.data.tenantInfoList;
  267. this.getTenantListSort(list)
  268. }).catch(error => {
  269. uni.showToast({
  270. title: error,
  271. icon: "none"
  272. })
  273. })
  274. },
  275. extraInfoText(extraInfo){
  276. var obj=JSON.parse(extraInfo)
  277. if(obj.sharedKwh!=null){
  278. return `租户公摊电量合计${obj.tenantSharedKwh}度`
  279. }else{
  280. return `起止码${obj.startMeter}-${obj.endMeter};<br/>合计${obj.kwh}度`
  281. }
  282. },
  283. selector2confirm(e){
  284. this.tabsFrom.show2Text=e.year+"年"+e.month+"月"
  285. this.tabsFrom.show2Index=e.year+"-"+e.month
  286. if(e.day){
  287. this.tabsFrom.show2Text+=e.day+"日"
  288. this.tabsFrom.show2Index+='-'+e.day
  289. }
  290. //this.tabsFrom.show2Index=this.tabsFrom.show2Text
  291. if(e.day){
  292. this.formData.startDate=e.year+"-"+e.month +"-"+e.day
  293. this.queryMonth=e.year+"年"+e.month+"月"+e.day+"日"
  294. this.formData.endDate=this.formData.startDate
  295. //nextDay(e.year,e.month, e.day)
  296. }else{
  297. this.queryMonth=e.year+"年"+e.month+"月"
  298. this.formData.startDate=e.year+"-"+e.month +"-1"
  299. this.formData.endDate=nextMonth(e.year,e.month, 1,1)
  300. }
  301. this.deductionRecord()
  302. },
  303. selector2reset(e){
  304. this.tabsFrom.show2Text='全部时间'
  305. this.tabsFrom.show2Index='';
  306. var date=new Date()
  307. this.formData.startDate=date.getFullYear()+"-"+(date.getMonth() + 1) +"-1"
  308. this.formData.endDate=""
  309. this.queryMonth=date.getFullYear()+"年"+(date.getMonth() + 1)+"月"
  310. this.deductionRecord()
  311. },
  312. selector1confirm(e){
  313. var index=e[0]
  314. this.tabsFrom.show1Index=index
  315. this.tabsFrom.show1Text=this.tabsFrom.selector1[index].label
  316. this.formData.contractItemId=this.tabsFrom.selector1[index].value
  317. this.deductionRecord()
  318. },
  319. deductionRecordGraph(){
  320. API.deductionRecordGraph({
  321. tenantId:this.formData.tenantId
  322. }).then((response) => {
  323. this.balance=response.data.balance
  324. var list=response.data.monthRecordList;
  325. this.monthAmount=list[list.length-1].monthAmount
  326. // uni.getSystemInfo({
  327. // success: (res) => {
  328. // const screenWidth = res.windowWidth; // 屏幕宽度,单位为px
  329. // console.log('屏幕宽度:', screenWidth);
  330. // },
  331. // });
  332. this.getPle(list)
  333. //uni.upx2px(600)
  334. }).catch(error => {
  335. uni.hideLoading();
  336. uni.showToast({
  337. icon: "none",
  338. title: error
  339. })
  340. })
  341. },
  342. getPle(list){
  343. if (!this.myChart) {
  344. this.myChart = echarts.init(document.getElementById('pieEcharts'),null,{
  345. width:uni.upx2px(700),height:uni.upx2px(280)
  346. });
  347. }
  348. this.myChart.clear();
  349. var data1=list.map(item=>{
  350. return item.month.replace("-", "年")+"月"
  351. });
  352. var data2=list.map(item=>{
  353. return item.monthAmount
  354. });
  355. var headitemby=""
  356. var showkey = "";
  357. var option = {
  358. tooltip: {
  359. trigger: 'axis'
  360. },
  361. grid: {
  362. top: '6%',
  363. left: '3%',
  364. right: '8%',
  365. bottom: '8%',
  366. containLabel: true
  367. },
  368. xAxis: {
  369. type: 'category',
  370. data: data1,
  371. axisLabel: {
  372. formatter: (value) => {
  373. if (headitemby == "") {
  374. headitemby = value
  375. }
  376. var i = 0
  377. var showvalue = "";
  378. var key = value.substring(0, 5);
  379. if (showkey == "" || value == headitemby) {
  380. showkey = key
  381. showvalue = value
  382. showvalue = value.substring(2)
  383. } else {
  384. if (key != showkey) {
  385. showkey = key
  386. showvalue = value
  387. showvalue = value.substring(2)
  388. } else {
  389. showvalue = value.substring(5)
  390. }
  391. }
  392. return showvalue.replace("年", ".").replace("月", "");
  393. },
  394. textStyle: {
  395. color: "#333"
  396. }
  397. },
  398. },
  399. yAxis: {
  400. type: 'value'
  401. },
  402. series: [
  403. {
  404. name: '合计',
  405. data: data2,
  406. type: 'line'
  407. }
  408. ]
  409. }
  410. console.log(option)
  411. this.myChart.setOption(option);
  412. },
  413. deductionRecord(){
  414. uni.showLoading({
  415. mask:true,title:'加载中...'
  416. })
  417. API.tenantDeductionRecords(this.formData).then((response) => {
  418. uni.hideLoading();
  419. this.list=response.data.data;
  420. }).catch(error => {
  421. uni.hideLoading();
  422. uni.showToast({
  423. icon: "none",
  424. title: error
  425. })
  426. })
  427. },
  428. contractItemList(){
  429. API.contractItemList(this.formData).then((response) => {
  430. //uni.hideLoading();
  431. var contractItemList=response.data.contractItemList
  432. this.tabsFrom.selector1=[{
  433. label: "全部类型",
  434. value: '',
  435. }]
  436. contractItemList.forEach(item=>{
  437. this.tabsFrom.selector1.push({
  438. label: item.name,
  439. value: item.id,
  440. })
  441. })
  442. }).catch(error => {
  443. //uni.hideLoading();
  444. uni.hideLoading();
  445. uni.showToast({
  446. icon: "none",
  447. title: error
  448. })
  449. })
  450. },
  451. change1(index) {
  452. this.current = index;
  453. },
  454. }
  455. }
  456. </script>
  457. <style lang="scss" scoped>
  458. .slot{
  459. color: rgba(16,16,16,1);
  460. font-size: 32rpx;
  461. margin-right: 32rpx;
  462. }
  463. .tabs-box{
  464. background-color: #fff;
  465. display: flex;
  466. align-items: center;
  467. justify-content: space-between;
  468. padding: 16rpx 32rpx 16rpx 32rpx;
  469. .tabs1{
  470. width: 96%;
  471. }
  472. }
  473. // 折线图
  474. .chart-box {
  475. padding: 24rpx 32rpx;
  476. background: linear-gradient(180deg, rgba(203, 234, 255, 1) 0%, rgba(255, 255, 255, 1) 100%);
  477. .infos{
  478. display: flex;
  479. align-items: center;
  480. .item{
  481. width: 50%;
  482. }
  483. }
  484. .title {
  485. color: rgb(16, 16, 16);
  486. }
  487. .sum {
  488. color: rgb(51, 51, 51);
  489. font-size: 64rpx;
  490. margin-top: 16rpx;
  491. .unit {
  492. color: rgb(16, 16, 16);
  493. font-size: 28rpx;
  494. margin-left: 8rpx;
  495. }
  496. }
  497. .chart {
  498. width: 100%;
  499. height: 240rpx;
  500. margin-top: 8rpx;
  501. .img {
  502. width: 100%;
  503. height: 100%;
  504. }
  505. }
  506. }
  507. .tabs{
  508. height: 96rpx;
  509. line-height: 96rpx;
  510. background-color: #fff;
  511. border-top: 1px solid rgba(241,241,241,1);
  512. display: flex;
  513. justify-content: space-around;
  514. }
  515. // 记录
  516. .records-item{
  517. .time{
  518. padding: 24rpx 32rpx;
  519. color: rgba(119,119,119,1);
  520. font-size: 32rpx;
  521. }
  522. .details{
  523. background-color: #fff;
  524. padding: 32rpx;
  525. display: flex;
  526. align-items: center;
  527. border-bottom: 1px solid rgba(244,244,244,1);
  528. .img{
  529. width: 80rpx;
  530. height: 80rpx;
  531. }
  532. .details-title{
  533. margin-left: 24rpx;
  534. .title{
  535. color: rgba(51,51,51,1);
  536. font-size: 32rpx;
  537. }
  538. .record-time{
  539. color: rgb(153,153,153);
  540. font-size: 24rpx;
  541. margin-top: 8rpx;
  542. }
  543. }
  544. .sum{
  545. color: rgb(16,16,16);
  546. font-size: 40rpx;
  547. margin-left: auto;
  548. white-space: pre;
  549. }
  550. }
  551. }
  552. .popup-tabs {
  553. background-color: #fff;
  554. display: flex;
  555. align-items: center;
  556. justify-content: space-between;
  557. padding-top: 32rpx;
  558. padding-right: 32rpx;
  559. color: rgba(51, 51, 51, 1);
  560. font-size: 32rpx;
  561. .tabs1 {
  562. width: 88%;
  563. }
  564. }
  565. /deep/.u-tab-item {
  566. width: 25% !important;
  567. flex: none !important;
  568. }
  569. .tabs-options {
  570. //display: flex;
  571. padding: 24rpx 32rpx ;
  572. flex-wrap: wrap;
  573. .item {
  574. //width: 25%;
  575. color:rgb(119, 119, 119);
  576. margin-bottom: 24rpx;
  577. font-size: 32rpx;
  578. }
  579. .item-index{
  580. color: rgb(51, 51, 51);
  581. font-weight: bold;
  582. }
  583. }
  584. .head-head{
  585. background: #fff;
  586. padding:24rpx;
  587. position: fixed;
  588. left: 0;
  589. right: 0;
  590. top: 80rpx;
  591. z-index: 991;
  592. }
  593. .head-head-placeholder{
  594. height: 112rpx;
  595. }
  596. </style>