index.vue 9.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301
  1. <!--
  2. * @Description: 统计报表 => 停车场模块
  3. * @Author: 空白格
  4. * @Date: 2022-08-03 11:55:13
  5. * @LastEditors: 空白格
  6. * @LastEditTime: 2022-11-16 09:38:11
  7. * @FilePath: \parking_operation\pages\statisticalReport\parkModel\index.vue
  8. * @Copyright: Copyright (c) 2016~2022 by 空白格, All Rights Reserved.
  9. -->
  10. <template>
  11. <view class="report">
  12. <view class="report-header">
  13. <view class="report-header-left">
  14. <template v-if="templateKey === 'reallyReceivable'">
  15. <view class="tab">
  16. <view class="tab-item" v-for="(item, index) in tabList" :key="index" :class="{ active: tabCur === item.value }" @click="tabClick(item)">{{
  17. item.label
  18. }}</view>
  19. </view>
  20. </template>
  21. <template v-else>
  22. <uni-datetime-picker v-model="curDate" type="daterange" @change="dateChange">
  23. <u--text text="日期查询" color="#1767F2"></u--text>
  24. </uni-datetime-picker>
  25. </template>
  26. </view>
  27. <view class="report-header-right">{{ currentDate }}</view>
  28. </view>
  29. <view class="report-content">
  30. <template v-if="templateKey === 'parkingReallyIncome'">
  31. <ParkingReallyIncome ref="parkingReallyIncome" />
  32. </template>
  33. <template v-else-if="templateKey === 'arrearsReport'">
  34. <ArrearsReport ref="arrearsReport" />
  35. </template>
  36. <template v-else-if="templateKey === 'revenueReport'">
  37. <RevenueReport ref="revenueReport" />
  38. </template>
  39. <template v-else-if="templateKey === 'reallyReceivable'">
  40. <ReallyReceivable ref="reallyReceivable" />
  41. </template>
  42. </view>
  43. <!-- 年 -->
  44. <u-picker :show="yearPicker" :columns="yearList" :defaultIndex="defaultYear" @confirm="yearConfirm" @cancel="yearPicker = false" />
  45. <!-- 月 -->
  46. <u-picker :show="monthPicker" :columns="monthList" :defaultIndex="defaultMonth" @confirm="monthConfirm" @cancel="monthPicker = false" />
  47. <!-- 日 -->
  48. <u-picker :show="dayPicker" :columns="dayList" :defaultIndex="defaultDay" @confirm="dayConfirm" @cancel="dayPicker = false" />
  49. </view>
  50. </template>
  51. <script>
  52. import ParkingReallyIncome from './components/parkingReallyIncome.vue';
  53. import ArrearsReport from './components/arrearsReport.vue';
  54. import RevenueReport from './components/revenueReport.vue';
  55. import ReallyReceivable from './components/reallyReceivable.vue';
  56. export default {
  57. components: {
  58. ParkingReallyIncome,
  59. ArrearsReport,
  60. RevenueReport,
  61. ReallyReceivable
  62. },
  63. data() {
  64. return {
  65. tabList: [
  66. {
  67. label: '年',
  68. value: 2
  69. },
  70. {
  71. label: '月',
  72. value: 1
  73. },
  74. {
  75. label: '日',
  76. value: 0
  77. }
  78. ],
  79. templateKey: '',
  80. // 日期
  81. curDate: [],
  82. tabCur: 2,
  83. // 参数
  84. params: {
  85. reportType: 2,
  86. queryDate: ''
  87. },
  88. title: '',
  89. currentDate: '',
  90. // 年
  91. yearPicker: false,
  92. yearList: this.getYearList(),
  93. defaultYear: [4],
  94. currentYear: '',
  95. yearObj: {},
  96. // 月
  97. monthPicker: false,
  98. monthList: this.getMonthList(),
  99. defaultMonth: [],
  100. currentMonth: '01',
  101. monthObj: {},
  102. // 日
  103. dayPicker: false,
  104. dayList: this.getDayList(),
  105. defaultDay: [],
  106. currentDay: '01',
  107. dayObj: {}
  108. };
  109. },
  110. watch: {
  111. title(val) {
  112. if (val) {
  113. if (typeof val === 'object') {
  114. if (val.length) {
  115. let startDateList = val[0].split('-'),
  116. endDateList = val[1].split('-');
  117. this.currentDate = `${Number(startDateList[0])}年${Number(startDateList[1])}月${Number(startDateList[2])}日至${Number(
  118. endDateList[0]
  119. )}年${Number(endDateList[1])}月${Number(endDateList[2])}日`;
  120. }
  121. } else {
  122. const dateArr = val.split('-');
  123. switch (this.tabCur) {
  124. case 0:
  125. this.currentDate = `${Number(dateArr[0])}年${Number(dateArr[1])}月${Number(dateArr[2])}日`;
  126. break;
  127. case 1:
  128. this.currentDate = `${Number(dateArr[0])}年${Number(dateArr[1])}月`;
  129. break;
  130. case 2:
  131. this.currentDate = `${Number(dateArr[0])}年`;
  132. break;
  133. default:
  134. this.currentDate = '--';
  135. break;
  136. }
  137. }
  138. }
  139. }
  140. },
  141. onLoad(options) {
  142. uni.setNavigationBarTitle({
  143. title: options.title || '路段报表'
  144. });
  145. this.templateKey = options.key;
  146. },
  147. onShow() {
  148. let today = uni.$u.timeFormat(new Date(), 'yyyy-mm-dd');
  149. this.curDate = [today, today];
  150. // if (
  151. // this.templateKey === 'revenueReport' ||
  152. // this.templateKey === 'reallyReceivable'
  153. // ) {
  154. // let today = uni.$u.timeFormat(new Date(), 'yyyy-mm-dd');
  155. // this.curDate = [today, today];
  156. // } else {
  157. // this.curDate = [];
  158. // }
  159. this.$nextTick(() => {
  160. if (this.templateKey === 'reallyReceivable') {
  161. this.tabCur = 0;
  162. this.params.reportType = 0;
  163. this.currentYear = this.yearList[0][4].value;
  164. this.yearObj = this.yearList[0][4];
  165. this.currentMonth = uni.$u.timeFormat(new Date(), 'mm');
  166. this.currentDay = uni.$u.timeFormat(new Date(), 'dd');
  167. this.params.queryDate = `${this.currentYear}-${this.currentMonth}-${this.currentDay}`;
  168. const dateArr = this.params.queryDate.split('-');
  169. this.currentDate = `${Number(dateArr[0])}年${Number(dateArr[1])}月${Number(dateArr[2])}日`;
  170. this.$refs[this.templateKey].getData(this.params);
  171. } else {
  172. this.title = this.curDate;
  173. this.$refs[this.templateKey].getData(this.curDate);
  174. }
  175. });
  176. },
  177. methods: {
  178. getYearList() {
  179. const date = new Date();
  180. const year = date.getFullYear();
  181. const list = [[]];
  182. for (let i = year - 4; i < year + 1; i++) {
  183. const obj = {
  184. text: String(i),
  185. value: String(i)
  186. };
  187. list[0].push(obj);
  188. }
  189. return list;
  190. },
  191. getMonthList() {
  192. const date = new Date();
  193. const month = date.getMonth();
  194. const list = [[]];
  195. for (let i = 1; i < 13; i++) {
  196. const obj = {
  197. text: String(i),
  198. value: String(i)
  199. };
  200. if (i < 10) {
  201. obj.text = '0' + i;
  202. obj.value = '0' + i;
  203. }
  204. list[0].push(obj);
  205. }
  206. setTimeout(() => {
  207. this.defaultMonth = [0];
  208. }, 1000);
  209. return list;
  210. },
  211. getDayList() {
  212. const date = new Date();
  213. const year = date.getFullYear();
  214. let month = date.getMonth();
  215. if (this.monthObj) {
  216. month = parseInt(this.monthObj.value);
  217. month = String(month);
  218. }
  219. const day = date.getDate();
  220. const dayLen = new Date(year, month, 0).getDate();
  221. const list = [[]];
  222. for (let i = 1; i < dayLen + 1; i++) {
  223. const obj = {
  224. text: String(i),
  225. value: String(i)
  226. };
  227. if (i < 10) {
  228. obj.text = '0' + i;
  229. obj.value = '0' + i;
  230. }
  231. list[0].push(obj);
  232. }
  233. setTimeout(() => {
  234. this.defaultDay = [0];
  235. }, 1000);
  236. return list;
  237. },
  238. tabClick(item) {
  239. this.tabCur = item.value;
  240. switch (item.value) {
  241. case 2:
  242. this.yearPicker = true;
  243. break;
  244. case 1:
  245. this.monthPicker = true;
  246. break;
  247. case 0:
  248. this.dayPicker = true;
  249. break;
  250. }
  251. this.params.reportType = this.tabCur;
  252. },
  253. dateChange(e) {
  254. this.curDate = e;
  255. this.title = this.curDate;
  256. this.$refs[this.templateKey].getData(this.curDate);
  257. },
  258. yearConfirm(e) {
  259. this.defaultYear = [e.indexs[0]];
  260. this.currentYear = e.value[0].value;
  261. this.title = e.value[0].text;
  262. this.yearObj = e.value[0];
  263. this.params.queryDate = `${this.currentYear}-${this.currentMonth}-${this.currentDay}`;
  264. this.$refs[this.templateKey].getData(this.params);
  265. this.yearPicker = false;
  266. },
  267. monthConfirm(e) {
  268. this.defaultMonth = [e.indexs[0]];
  269. this.currentMonth = e.value[0].value;
  270. this.monthObj = e.value[0];
  271. this.title = `${this.yearObj.text}-${this.monthObj.text}`;
  272. this.params.queryDate = `${this.currentYear}-${this.currentMonth}-${this.currentDay}`;
  273. this.$refs[this.templateKey].getData(this.params);
  274. this.monthPicker = false;
  275. this.dayList = this.getDayList();
  276. },
  277. dayConfirm(e) {
  278. this.defaultDay = [e.indexs[0]];
  279. this.title = e.value[0].text;
  280. this.currentDay = e.value[0].value;
  281. this.dayObj = e.value[0];
  282. this.params.title = `${this.yearObj.text}-${this.monthObj.text}-${this.dayObj.text}`;
  283. this.params.queryDate = `${this.currentYear}-${this.currentMonth}-${this.currentDay}`;
  284. this.$refs[this.templateKey].getData(this.params);
  285. this.dayPicker = false;
  286. }
  287. }
  288. };
  289. </script>
  290. <style lang="scss">
  291. page {
  292. background-color: #1767f2;
  293. min-height: calc(100vh - 44px);
  294. }
  295. </style>
  296. <style lang="scss" scoped>
  297. @import './../styles/report.scss';
  298. </style>