deductionRecord.vue 15 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683
  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. return `起止码${obj.startMeter}-${obj.endMeter};<br/>合计${obj.kwh}度`
  278. },
  279. selector2confirm(e){
  280. this.tabsFrom.show2Text=e.year+"年"+e.month+"月"
  281. this.tabsFrom.show2Index=e.year+"-"+e.month
  282. if(e.day){
  283. this.tabsFrom.show2Text+=e.day+"日"
  284. this.tabsFrom.show2Index+='-'+e.day
  285. }
  286. //this.tabsFrom.show2Index=this.tabsFrom.show2Text
  287. if(e.day){
  288. this.formData.startDate=e.year+"-"+e.month +"-"+e.day
  289. this.queryMonth=e.year+"年"+e.month+"月"+e.day+"日"
  290. this.formData.endDate=this.formData.startDate
  291. //nextDay(e.year,e.month, e.day)
  292. }else{
  293. this.queryMonth=e.year+"年"+e.month+"月"
  294. this.formData.startDate=e.year+"-"+e.month +"-1"
  295. this.formData.endDate=nextMonth(e.year,e.month, 1,1)
  296. }
  297. this.deductionRecord()
  298. },
  299. selector2reset(e){
  300. this.tabsFrom.show2Text='全部时间'
  301. this.tabsFrom.show2Index='';
  302. var date=new Date()
  303. this.formData.startDate=date.getFullYear()+"-"+(date.getMonth() + 1) +"-1"
  304. this.formData.endDate=""
  305. this.queryMonth=date.getFullYear()+"年"+(date.getMonth() + 1)+"月"
  306. this.deductionRecord()
  307. },
  308. selector1confirm(e){
  309. var index=e[0]
  310. this.tabsFrom.show1Index=index
  311. this.tabsFrom.show1Text=this.tabsFrom.selector1[index].label
  312. this.formData.contractItemId=this.tabsFrom.selector1[index].value
  313. this.deductionRecord()
  314. },
  315. deductionRecordGraph(){
  316. API.deductionRecordGraph({
  317. tenantId:this.formData.tenantId
  318. }).then((response) => {
  319. this.balance=response.data.balance
  320. var list=response.data.monthRecordList;
  321. this.monthAmount=list[list.length-1].monthAmount
  322. // uni.getSystemInfo({
  323. // success: (res) => {
  324. // const screenWidth = res.windowWidth; // 屏幕宽度,单位为px
  325. // console.log('屏幕宽度:', screenWidth);
  326. // },
  327. // });
  328. this.getPle(list)
  329. //uni.upx2px(600)
  330. }).catch(error => {
  331. uni.hideLoading();
  332. uni.showToast({
  333. icon: "none",
  334. title: error
  335. })
  336. })
  337. },
  338. getPle(list){
  339. if (!this.myChart) {
  340. this.myChart = echarts.init(document.getElementById('pieEcharts'),null,{
  341. width:uni.upx2px(700),height:uni.upx2px(280)
  342. });
  343. }
  344. this.myChart.clear();
  345. var data1=list.map(item=>{
  346. return item.month.replace("-", "年")+"月"
  347. });
  348. var data2=list.map(item=>{
  349. return item.monthAmount
  350. });
  351. var headitemby=""
  352. var showkey = "";
  353. var option = {
  354. tooltip: {
  355. trigger: 'axis'
  356. },
  357. grid: {
  358. top: '6%',
  359. left: '3%',
  360. right: '8%',
  361. bottom: '8%',
  362. containLabel: true
  363. },
  364. xAxis: {
  365. type: 'category',
  366. data: data1,
  367. axisLabel: {
  368. formatter: (value) => {
  369. if (headitemby == "") {
  370. headitemby = value
  371. }
  372. var i = 0
  373. var showvalue = "";
  374. var key = value.substring(0, 5);
  375. if (showkey == "" || value == headitemby) {
  376. showkey = key
  377. showvalue = value
  378. showvalue = value.substring(2)
  379. } else {
  380. if (key != showkey) {
  381. showkey = key
  382. showvalue = value
  383. showvalue = value.substring(2)
  384. } else {
  385. showvalue = value.substring(5)
  386. }
  387. }
  388. return showvalue.replace("年", ".").replace("月", "");
  389. },
  390. textStyle: {
  391. color: "#333"
  392. }
  393. },
  394. },
  395. yAxis: {
  396. type: 'value'
  397. },
  398. series: [
  399. {
  400. name: '合计',
  401. data: data2,
  402. type: 'line'
  403. }
  404. ]
  405. }
  406. console.log(option)
  407. this.myChart.setOption(option);
  408. },
  409. deductionRecord(){
  410. uni.showLoading({
  411. mask:true,title:'加载中...'
  412. })
  413. API.tenantDeductionRecords(this.formData).then((response) => {
  414. uni.hideLoading();
  415. this.list=response.data.data;
  416. }).catch(error => {
  417. uni.hideLoading();
  418. uni.showToast({
  419. icon: "none",
  420. title: error
  421. })
  422. })
  423. },
  424. contractItemList(){
  425. API.contractItemList(this.formData).then((response) => {
  426. //uni.hideLoading();
  427. var contractItemList=response.data.contractItemList
  428. this.tabsFrom.selector1=[{
  429. label: "全部类型",
  430. value: '',
  431. }]
  432. contractItemList.forEach(item=>{
  433. this.tabsFrom.selector1.push({
  434. label: item.name,
  435. value: item.id,
  436. })
  437. })
  438. }).catch(error => {
  439. //uni.hideLoading();
  440. uni.hideLoading();
  441. uni.showToast({
  442. icon: "none",
  443. title: error
  444. })
  445. })
  446. },
  447. change1(index) {
  448. this.current = index;
  449. },
  450. }
  451. }
  452. </script>
  453. <style lang="scss" scoped>
  454. .slot{
  455. color: rgba(16,16,16,1);
  456. font-size: 32rpx;
  457. margin-right: 32rpx;
  458. }
  459. .tabs-box{
  460. background-color: #fff;
  461. display: flex;
  462. align-items: center;
  463. justify-content: space-between;
  464. padding: 16rpx 32rpx 16rpx 32rpx;
  465. .tabs1{
  466. width: 96%;
  467. }
  468. }
  469. // 折线图
  470. .chart-box {
  471. padding: 24rpx 32rpx;
  472. background: linear-gradient(180deg, rgba(203, 234, 255, 1) 0%, rgba(255, 255, 255, 1) 100%);
  473. .infos{
  474. display: flex;
  475. align-items: center;
  476. .item{
  477. width: 50%;
  478. }
  479. }
  480. .title {
  481. color: rgb(16, 16, 16);
  482. }
  483. .sum {
  484. color: rgb(51, 51, 51);
  485. font-size: 64rpx;
  486. margin-top: 16rpx;
  487. .unit {
  488. color: rgb(16, 16, 16);
  489. font-size: 28rpx;
  490. margin-left: 8rpx;
  491. }
  492. }
  493. .chart {
  494. width: 100%;
  495. height: 240rpx;
  496. margin-top: 8rpx;
  497. .img {
  498. width: 100%;
  499. height: 100%;
  500. }
  501. }
  502. }
  503. .tabs{
  504. height: 96rpx;
  505. line-height: 96rpx;
  506. background-color: #fff;
  507. border-top: 1px solid rgba(241,241,241,1);
  508. display: flex;
  509. justify-content: space-around;
  510. }
  511. // 记录
  512. .records-item{
  513. .time{
  514. padding: 24rpx 32rpx;
  515. color: rgba(119,119,119,1);
  516. font-size: 32rpx;
  517. }
  518. .details{
  519. background-color: #fff;
  520. padding: 32rpx;
  521. display: flex;
  522. align-items: center;
  523. border-bottom: 1px solid rgba(244,244,244,1);
  524. .img{
  525. width: 80rpx;
  526. height: 80rpx;
  527. }
  528. .details-title{
  529. margin-left: 24rpx;
  530. .title{
  531. color: rgba(51,51,51,1);
  532. font-size: 32rpx;
  533. }
  534. .record-time{
  535. color: rgb(153,153,153);
  536. font-size: 24rpx;
  537. margin-top: 8rpx;
  538. }
  539. }
  540. .sum{
  541. color: rgb(16,16,16);
  542. font-size: 40rpx;
  543. margin-left: auto;
  544. white-space: pre;
  545. }
  546. }
  547. }
  548. .popup-tabs {
  549. background-color: #fff;
  550. display: flex;
  551. align-items: center;
  552. justify-content: space-between;
  553. padding-top: 32rpx;
  554. padding-right: 32rpx;
  555. color: rgba(51, 51, 51, 1);
  556. font-size: 32rpx;
  557. .tabs1 {
  558. width: 88%;
  559. }
  560. }
  561. /deep/.u-tab-item {
  562. width: 25% !important;
  563. flex: none !important;
  564. }
  565. .tabs-options {
  566. //display: flex;
  567. padding: 24rpx 32rpx ;
  568. flex-wrap: wrap;
  569. .item {
  570. //width: 25%;
  571. color:rgb(119, 119, 119);
  572. margin-bottom: 24rpx;
  573. font-size: 32rpx;
  574. }
  575. .item-index{
  576. color: rgb(51, 51, 51);
  577. font-weight: bold;
  578. }
  579. }
  580. .head-head{
  581. background: #fff;
  582. padding:24rpx;
  583. position: fixed;
  584. left: 0;
  585. right: 0;
  586. top: 80rpx;
  587. z-index: 991;
  588. }
  589. .head-head-placeholder{
  590. height: 112rpx;
  591. }
  592. </style>