index.vue 8.8 KB

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