deductionRecord.vue 15 KB

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