deductionRecord.vue 9.5 KB

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