index.vue 7.6 KB

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