deductionRecord.vue 12 KB

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