index.vue 9.0 KB

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