deductionRecord.vue 12 KB

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