index.vue 7.8 KB

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