index.vue 9.1 KB

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