deductionRecord.vue 12 KB

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