index.vue 7.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296
  1. <!--
  2. * @Description: 运营分析停车场模块
  3. * @Author: 空白格
  4. * @Date: 2022-08-02 15:32:15
  5. * @LastEditors: 空白格
  6. * @LastEditTime: 2022-08-04 11:43:11
  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">
  14. <view class="tab">
  15. <view
  16. class="tab-item"
  17. v-for="(item, index) in tabList"
  18. :key="index"
  19. :class="{ active: tabCur === item.value }"
  20. @click="tabClick(item)"
  21. >{{ item.label }}</view>
  22. </view>
  23. </view>
  24. <view class="analysis-header-right">{{ currentDate }}</view>
  25. </view>
  26. <view class="analysis-main">
  27. <template v-if="templateKey === 'parkingLotAnalysis'">
  28. <parking-lot-analysis ref="parkingLotAnalysis" />
  29. </template>
  30. <template v-else-if="templateKey === 'arrearsAnalysis'">
  31. <arrears-analysis ref="arrearsAnalysis" />
  32. </template>
  33. <template v-else-if="templateKey === 'revenueAnalysis'">
  34. <revenue-analysis ref="revenueAnalysis" />
  35. </template>
  36. <template v-else-if="templateKey === 'incomeAnalysis'">
  37. <income-analysis ref="incomeAnalysis" />
  38. </template>
  39. <template v-else-if="templateKey === 'paymentMethod'">
  40. <payment-method ref="paymentMethod" />
  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. />
  51. <!-- 月 -->
  52. <u-picker
  53. :show="monthPicker"
  54. :columns="monthList"
  55. :defaultIndex="defaultMonth"
  56. @confirm="monthConfirm"
  57. @cancel="monthPicker = false"
  58. />
  59. <!-- 日 -->
  60. <u-picker
  61. :show="dayPicker"
  62. :columns="dayList"
  63. :defaultIndex="defaultDay"
  64. @confirm="dayConfirm"
  65. @cancel="dayPicker = false"
  66. />
  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. currentDate: '',
  103. // 参数
  104. params: {
  105. reportType: 2,
  106. queryDate: ''
  107. },
  108. // 年
  109. yearPicker: false,
  110. yearList: this.getYearList(),
  111. defaultYear: [4],
  112. currentYear: '',
  113. yearObj: {},
  114. // 月
  115. monthPicker: false,
  116. monthList: this.getMonthList(),
  117. defaultMonth: [],
  118. currentMonth: '01',
  119. monthObj: {},
  120. // 日
  121. dayPicker: false,
  122. dayList: this.getDayList(),
  123. defaultDay: [],
  124. currentDay: '01',
  125. dayObj: {}
  126. };
  127. },
  128. watch: {
  129. title(val) {
  130. if (val) {
  131. const dateArr = val.split('-');
  132. switch (this.tabCur) {
  133. case 0:
  134. this.currentDate = `${Number(dateArr[0])}年${Number(
  135. dateArr[1]
  136. )}月${Number(dateArr[2])}日`;
  137. break;
  138. case 1:
  139. this.currentDate = `${Number(dateArr[0])}年${Number(dateArr[1])}月`;
  140. break;
  141. case 2:
  142. this.currentDate = `${Number(dateArr[0])}年`;
  143. break;
  144. default:
  145. this.currentDate = '--';
  146. break;
  147. }
  148. }
  149. }
  150. },
  151. onLoad(options) {
  152. uni.setNavigationBarTitle({
  153. title: options.title || '停车场分析'
  154. });
  155. this.templateKey = options.key;
  156. },
  157. onShow() {
  158. this.defaultSetVal();
  159. },
  160. methods: {
  161. defaultSetVal() {
  162. this.currentYear = this.yearList[0][4].value;
  163. this.title = this.yearList[0][4].text;
  164. this.yearObj = this.yearList[0][4];
  165. this.params.queryDate = `${this.currentYear}-${this.currentMonth}-${this.currentDay}`;
  166. this.$nextTick(() => {
  167. this.$refs[this.templateKey].getData(this.params);
  168. });
  169. },
  170. getYearList() {
  171. const date = new Date();
  172. const year = date.getFullYear();
  173. const list = [[]];
  174. for (let i = year - 4; i < year + 1; i++) {
  175. const obj = {
  176. text: String(i),
  177. value: String(i)
  178. };
  179. list[0].push(obj);
  180. }
  181. return list;
  182. },
  183. getMonthList() {
  184. const date = new Date();
  185. const month = date.getMonth();
  186. const list = [[]];
  187. for (let i = 1; i < 13; i++) {
  188. const obj = {
  189. text: String(i),
  190. value: String(i)
  191. };
  192. if (i < 10) {
  193. obj.text = '0' + i;
  194. obj.value = '0' + i;
  195. }
  196. list[0].push(obj);
  197. }
  198. setTimeout(() => {
  199. this.defaultMonth = [0];
  200. }, 1000);
  201. return list;
  202. },
  203. getDayList() {
  204. const date = new Date();
  205. const year = date.getFullYear();
  206. let month = date.getMonth();
  207. if (this.monthObj) {
  208. month = parseInt(this.monthObj.value);
  209. }
  210. const day = date.getDate();
  211. const dayLen = new Date(year, month, 0).getDate();
  212. const list = [[]];
  213. for (let i = 1; i < dayLen + 1; i++) {
  214. const obj = {
  215. text: String(i),
  216. value: String(i)
  217. };
  218. if (i < 10) {
  219. obj.text = '0' + i;
  220. obj.value = '0' + i;
  221. }
  222. list[0].push(obj);
  223. }
  224. setTimeout(() => {
  225. this.defaultDay = [0];
  226. }, 1000);
  227. return list;
  228. },
  229. /**
  230. * 点击tab
  231. * @param {Object} item
  232. */
  233. tabClick(item) {
  234. this.tabCur = item.value;
  235. switch (item.value) {
  236. case 0:
  237. this.dayPicker = true;
  238. break;
  239. case 1:
  240. this.monthPicker = true;
  241. break;
  242. case 2:
  243. this.yearPicker = true;
  244. break;
  245. }
  246. this.params.reportType = this.tabCur;
  247. },
  248. yearConfirm(e) {
  249. this.defaultYear = [e.indexs[0]];
  250. this.title = e.value[0].text;
  251. this.currentYear = e.value[0].value;
  252. this.yearObj = e.value[0];
  253. this.params.queryDate = `${this.currentYear}-${this.currentMonth}-${this.currentDay}`;
  254. this.$nextTick(() => {
  255. this.$refs[this.templateKey].getData(this.params);
  256. });
  257. this.yearPicker = false;
  258. },
  259. monthConfirm(e) {
  260. this.defaultMonth = [e.indexs[0]];
  261. this.currentMonth = e.value[0].value;
  262. this.monthObj = e.value[0];
  263. this.title = `${this.yearObj.text}-${this.monthObj.text}`;
  264. this.params.queryDate = `${this.currentYear}-${this.currentMonth}-${this.currentDay}`;
  265. this.$nextTick(() => {
  266. this.$refs[this.templateKey].getData(this.params);
  267. });
  268. this.monthPicker = false;
  269. this.dayList = this.getDayList();
  270. },
  271. dayConfirm(e) {
  272. this.defaultDay = [e.indexs[0]];
  273. this.title = e.value[0].text;
  274. this.currentDay = e.value[0].value;
  275. this.dayObj = e.value[0];
  276. this.title = `${this.yearObj.text}-${this.monthObj.text}-${this.dayObj.text}`;
  277. this.params.queryDate = `${this.currentYear}-${this.currentMonth}-${this.currentDay}`;
  278. this.$nextTick(() => {
  279. this.$refs[this.templateKey].getData(this.params);
  280. });
  281. this.dayPicker = false;
  282. }
  283. }
  284. };
  285. </script>
  286. <style lang="scss">
  287. page {
  288. background-color: #1767f2;
  289. min-height: calc(100vh - 44px);
  290. }
  291. </style>
  292. <style lang="scss" scoped>
  293. @import './../styles/analysis.scss';
  294. </style>