index.vue 7.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272
  1. <!--
  2. * @Description: 运营分析停车场模块
  3. * @Author: 空白格
  4. * @Date: 2022-08-02 15:32:15
  5. * @LastEditors: 空白格
  6. * @LastEditTime: 2022-08-03 13:53:18
  7. * @FilePath: \parking_operation\pages\operationalAnalysis\parkModel\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">&nbsp;</view>
  14. <view class="analysis-header-right">
  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>
  26. <view class="analysis-main">
  27. <template v-if="templateKey === 'parkingLotAnalysis'">
  28. <parking-lot-analysis ref="parkingLotAnalysis" :title="title" />
  29. </template>
  30. <template v-else-if="templateKey === 'arrearsAnalysis'">
  31. <arrears-analysis ref="arrearsAnalysis" :title="title" />
  32. </template>
  33. <template v-else-if="templateKey === 'revenueAnalysis'">
  34. <revenue-analysis ref="revenueAnalysis" :title="title" />
  35. </template>
  36. <template v-else-if="templateKey === 'incomeAnalysis'">
  37. <income-analysis ref="incomeAnalysis" :title="title" />
  38. </template>
  39. <template v-else-if="templateKey === 'paymentMethod'">
  40. <payment-method ref="paymentMethod" :title="title" />
  41. </template>
  42. </view>
  43. <!-- 年 -->
  44. <u-picker
  45. :show="yearPicker"
  46. :columns="yearList"
  47. :defaultIndex="defaultYear"
  48. @confirm="yearConfirm"
  49. @cancel="yearPicker = false"
  50. ></u-picker>
  51. <!-- 月 -->
  52. <u-picker
  53. :show="monthPicker"
  54. :columns="monthList"
  55. :defaultIndex="defaultMonth"
  56. @confirm="monthConfirm"
  57. @cancel="monthPicker = false"
  58. ></u-picker>
  59. <!-- 日 -->
  60. <u-picker
  61. :show="dayPicker"
  62. :columns="dayList"
  63. :defaultIndex="defaultDay"
  64. @confirm="dayConfirm"
  65. @cancel="dayPicker = false"
  66. ></u-picker>
  67. </view>
  68. </template>
  69. <script>
  70. import ParkingLotAnalysis from './components/parkingLotAnalysis.vue';
  71. import ArrearsAnalysis from './components/arrearsAnalysis.vue';
  72. import RevenueAnalysis from './components/revenueAnalysis.vue';
  73. import IncomeAnalysis from './components/incomeAnalysis.vue';
  74. import PaymentMethod from './components/paymentMethod.vue';
  75. export default {
  76. components: {
  77. ParkingLotAnalysis,
  78. ArrearsAnalysis,
  79. RevenueAnalysis,
  80. IncomeAnalysis,
  81. PaymentMethod
  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. tabCur: 2,
  100. templateKey: '',
  101. title: '',
  102. // 参数
  103. params: {
  104. reportType: 2,
  105. queryDate: ''
  106. },
  107. // 年
  108. yearPicker: false,
  109. yearList: this.getYearList(),
  110. defaultYear: [4],
  111. currentYear: '',
  112. yearObj: {},
  113. // 月
  114. monthPicker: false,
  115. monthList: this.getMonthList(),
  116. defaultMonth: [],
  117. currentMonth: '01',
  118. monthObj: {},
  119. // 日
  120. dayPicker: false,
  121. dayList: this.getDayList(),
  122. defaultDay: [],
  123. currentDay: '01',
  124. dayObj: {}
  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 = this.yearList[0][4].text;
  140. this.yearObj = this.yearList[0][4];
  141. this.params.queryDate = `${this.currentYear}-${this.currentMonth}-${this.currentDay}`;
  142. this.$nextTick(() => {
  143. this.$refs[this.templateKey].getData(this.params);
  144. });
  145. },
  146. getYearList() {
  147. const date = new Date();
  148. const year = date.getFullYear();
  149. const list = [[]];
  150. for (let i = year - 4; i < year + 1; i++) {
  151. const obj = {
  152. text: String(i),
  153. value: String(i)
  154. };
  155. list[0].push(obj);
  156. }
  157. return list;
  158. },
  159. getMonthList() {
  160. const date = new Date();
  161. const month = date.getMonth();
  162. const list = [[]];
  163. for (let i = 1; i < 13; i++) {
  164. const obj = {
  165. text: String(i),
  166. value: String(i)
  167. };
  168. if (i < 10) {
  169. obj.text = '0' + i;
  170. obj.value = '0' + i;
  171. }
  172. list[0].push(obj);
  173. }
  174. setTimeout(() => {
  175. this.defaultMonth = [0];
  176. }, 1000);
  177. return list;
  178. },
  179. getDayList() {
  180. const date = new Date();
  181. const year = date.getFullYear();
  182. let month = date.getMonth();
  183. if (this.monthObj) {
  184. month = parseInt(this.monthObj.value);
  185. }
  186. const day = date.getDate();
  187. const dayLen = new Date(year, month, 0).getDate();
  188. const list = [[]];
  189. for (let i = 1; i < dayLen + 1; i++) {
  190. const obj = {
  191. text: String(i),
  192. value: String(i)
  193. };
  194. if (i < 10) {
  195. obj.text = '0' + i;
  196. obj.value = '0' + i;
  197. }
  198. list[0].push(obj);
  199. }
  200. setTimeout(() => {
  201. this.defaultDay = [0];
  202. }, 1000);
  203. return list;
  204. },
  205. /**
  206. * 点击tab
  207. * @param {Object} item
  208. */
  209. tabClick(item) {
  210. this.tabCur = item.value;
  211. switch (item.value) {
  212. case 0:
  213. this.dayPicker = true;
  214. break;
  215. case 1:
  216. this.monthPicker = true;
  217. break;
  218. case 2:
  219. this.yearPicker = true;
  220. break;
  221. }
  222. this.params.reportType = this.tabCur;
  223. },
  224. yearConfirm(e) {
  225. this.defaultYear = [e.indexs[0]];
  226. this.title = e.value[0].text;
  227. this.currentYear = e.value[0].value;
  228. this.yearObj = e.value[0];
  229. this.params.queryDate = `${this.currentYear}-${this.currentMonth}-${this.currentDay}`;
  230. this.$nextTick(() => {
  231. this.$refs[this.templateKey].getData(this.params);
  232. });
  233. this.yearPicker = false;
  234. },
  235. monthConfirm(e) {
  236. this.defaultMonth = [e.indexs[0]];
  237. this.currentMonth = e.value[0].value;
  238. this.monthObj = e.value[0];
  239. this.title = `${this.yearObj.text}-${this.monthObj.text}`;
  240. this.params.queryDate = `${this.currentYear}-${this.currentMonth}-${this.currentDay}`;
  241. this.$nextTick(() => {
  242. this.$refs[this.templateKey].getData(this.params);
  243. });
  244. this.monthPicker = false;
  245. this.dayList = this.getDayList();
  246. },
  247. dayConfirm(e) {
  248. this.defaultDay = [e.indexs[0]];
  249. this.title = e.value[0].text;
  250. this.currentDay = e.value[0].value;
  251. this.dayObj = e.value[0];
  252. this.title = `${this.yearObj.text}-${this.monthObj.text}-${this.dayObj.text}`;
  253. this.params.queryDate = `${this.currentYear}-${this.currentMonth}-${this.currentDay}`;
  254. this.$nextTick(() => {
  255. this.$refs[this.templateKey].getData(this.params);
  256. });
  257. this.dayPicker = false;
  258. }
  259. }
  260. };
  261. </script>
  262. <style lang="scss">
  263. page {
  264. background-color: #1767f2;
  265. min-height: calc(100vh - 44px);
  266. }
  267. </style>
  268. <style lang="scss" scoped>
  269. @import './../styles/analysis.scss';
  270. </style>