index.vue 7.7 KB

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