index.vue 7.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298
  1. <!--
  2. * @Description: 运营分析停车场模块
  3. * @Author: 空白格
  4. * @Date: 2022-08-02 15:32:15
  5. * @LastEditors: 空白格
  6. * @LastEditTime: 2022-11-16 12:00:34
  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 = uni.$u.timeFormat(new Date(), 'yyyy-mm-dd');
  164. this.yearObj = this.yearList[0][4];
  165. this.tabCur = 0;
  166. this.params.reportType = 0;
  167. this.params.queryDate = uni.$u.timeFormat(new Date(), 'yyyy-mm-dd');;
  168. this.$nextTick(() => {
  169. this.$refs[this.templateKey].getData(this.params);
  170. });
  171. },
  172. getYearList() {
  173. const date = new Date();
  174. const year = date.getFullYear();
  175. const list = [[]];
  176. for (let i = year - 4; i < year + 1; i++) {
  177. const obj = {
  178. text: String(i),
  179. value: String(i)
  180. };
  181. list[0].push(obj);
  182. }
  183. return list;
  184. },
  185. getMonthList() {
  186. const date = new Date();
  187. const month = date.getMonth();
  188. const list = [[]];
  189. for (let i = 1; i < 13; 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.defaultMonth = [0];
  202. }, 1000);
  203. return list;
  204. },
  205. getDayList() {
  206. const date = new Date();
  207. const year = date.getFullYear();
  208. let month = date.getMonth();
  209. if (this.monthObj) {
  210. month = parseInt(this.monthObj.value);
  211. }
  212. const day = date.getDate();
  213. const dayLen = new Date(year, month, 0).getDate();
  214. const list = [[]];
  215. for (let i = 1; i < dayLen + 1; i++) {
  216. const obj = {
  217. text: String(i),
  218. value: String(i)
  219. };
  220. if (i < 10) {
  221. obj.text = '0' + i;
  222. obj.value = '0' + i;
  223. }
  224. list[0].push(obj);
  225. }
  226. setTimeout(() => {
  227. this.defaultDay = [0];
  228. }, 1000);
  229. return list;
  230. },
  231. /**
  232. * 点击tab
  233. * @param {Object} item
  234. */
  235. tabClick(item) {
  236. this.tabCur = item.value;
  237. switch (item.value) {
  238. case 0:
  239. this.dayPicker = true;
  240. break;
  241. case 1:
  242. this.monthPicker = true;
  243. break;
  244. case 2:
  245. this.yearPicker = true;
  246. break;
  247. }
  248. this.params.reportType = this.tabCur;
  249. },
  250. yearConfirm(e) {
  251. this.defaultYear = [e.indexs[0]];
  252. this.title = e.value[0].text;
  253. this.currentYear = e.value[0].value;
  254. this.yearObj = e.value[0];
  255. this.params.queryDate = `${this.currentYear}-${this.currentMonth}-${this.currentDay}`;
  256. this.$nextTick(() => {
  257. this.$refs[this.templateKey].getData(this.params);
  258. });
  259. this.yearPicker = false;
  260. },
  261. monthConfirm(e) {
  262. this.defaultMonth = [e.indexs[0]];
  263. this.currentMonth = e.value[0].value;
  264. this.monthObj = e.value[0];
  265. this.title = `${this.yearObj.text}-${this.monthObj.text}`;
  266. this.params.queryDate = `${this.currentYear}-${this.currentMonth}-${this.currentDay}`;
  267. this.$nextTick(() => {
  268. this.$refs[this.templateKey].getData(this.params);
  269. });
  270. this.monthPicker = false;
  271. this.dayList = this.getDayList();
  272. },
  273. dayConfirm(e) {
  274. this.defaultDay = [e.indexs[0]];
  275. this.title = e.value[0].text;
  276. this.currentDay = e.value[0].value;
  277. this.dayObj = e.value[0];
  278. this.title = `${this.yearObj.text}-${this.monthObj.text || 1}-${this.dayObj.text || 1}`;
  279. this.params.queryDate = `${this.currentYear}-${this.currentMonth}-${this.currentDay}`;
  280. this.$nextTick(() => {
  281. this.$refs[this.templateKey].getData(this.params);
  282. });
  283. this.dayPicker = false;
  284. }
  285. }
  286. };
  287. </script>
  288. <style lang="scss">
  289. page {
  290. background-color: #1767f2;
  291. min-height: calc(100vh - 44px);
  292. }
  293. </style>
  294. <style lang="scss" scoped>
  295. @import './../styles/analysis.scss';
  296. </style>