index.vue 7.8 KB

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