performanceAnalysis.vue 7.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313
  1. <!--
  2. * @Description: 业绩分析
  3. * @Author: 空白格
  4. * @Date: 2022-06-20 09:20:23
  5. * @LastEditors: 空白格
  6. * @LastEditTime: 2022-06-20 11:30:19
  7. * @FilePath: \parking_operation\pages\collectorManagement\performanceAnalysis\performanceAnalysis.vue
  8. * @Copyright: Copyright (c) 2016~2022 by 空白格, All Rights Reserved.
  9. -->
  10. <template>
  11. <view class="performance-analysis">
  12. <view class="performance-analysis-search">
  13. <view class="performance-analysis-search-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="performance-analysis-search-right">
  29. <u--input placeholder="" border="surround" v-model="currentDate" disabled inputAlign="center"/>
  30. </view>
  31. </view>
  32. <view class="performance-analysis-content">
  33. <template v-if="chartData.series[0].data.length > 0">
  34. <LineChart :chartData="chartData" :opts="opts" />
  35. </template>
  36. <template v-else>
  37. <view class="empty">
  38. <u-empty></u-empty>
  39. </view>
  40. </template>
  41. </view>
  42. <!-- 年 -->
  43. <u-picker
  44. :show="yearPicker"
  45. :columns="yearList"
  46. :defaultIndex="defaultYear"
  47. @confirm="yearConfirm"
  48. @cancel="yearPicker = false"
  49. ></u-picker>
  50. <!-- 月 -->
  51. <u-picker
  52. :show="monthPicker"
  53. :columns="monthList"
  54. :defaultIndex="defaultMonth"
  55. @confirm="monthConfirm"
  56. @cancel="monthPicker = false"
  57. ></u-picker>
  58. <!-- 日 -->
  59. <u-picker
  60. :show="dayPicker"
  61. :columns="dayList"
  62. :defaultIndex="defaultDay"
  63. @confirm="dayConfirm"
  64. @cancel="dayPicker = false"
  65. ></u-picker>
  66. </view>
  67. </template>
  68. <script>
  69. import LineChart from '@/components/lineChart.vue';
  70. export default {
  71. components: {
  72. LineChart
  73. },
  74. data() {
  75. return {
  76. tabList: [
  77. {
  78. label: '年',
  79. value: 2
  80. },
  81. {
  82. label: '月',
  83. value: 1
  84. },
  85. {
  86. label: '日',
  87. value: 0
  88. }
  89. ],
  90. tabCur: 2,
  91. params: {
  92. queryDate: '',
  93. reportType: 2
  94. },
  95. currentDate: '',
  96. // 年
  97. yearPicker: false,
  98. yearList: this.getYearList(),
  99. defaultYear: [4],
  100. currentYear: '',
  101. yearObj: {},
  102. // 月
  103. monthPicker: false,
  104. monthList: this.getMonthList(),
  105. defaultMonth: [],
  106. currentMonth: '01',
  107. monthObj: {},
  108. // 日
  109. dayPicker: false,
  110. dayList: this.getDayList(),
  111. defaultDay: [],
  112. currentDay: '01',
  113. dayObj: {},
  114. chartData: {
  115. categories: [],
  116. series: [
  117. {
  118. name: '',
  119. data: []
  120. }
  121. ]
  122. },
  123. opts: {
  124. enableScroll: true,
  125. xAxis: {
  126. rotateLabel: true,
  127. scrollShow: true,
  128. itemCount: 8
  129. },
  130. yAxis: {
  131. showTitle: true,
  132. splitNumber: 5,
  133. data: [
  134. {
  135. title: '元',
  136. titleOffsetY: -3
  137. }
  138. ]
  139. },
  140. legend: {
  141. show: false
  142. },
  143. dataLabel: false,
  144. padding: [20, 10, 10, 10],
  145. extra: {
  146. column: {
  147. width: 20
  148. }
  149. }
  150. }
  151. };
  152. },
  153. onShow() {
  154. this.defaultSetVal();
  155. },
  156. watch: {
  157. 'params.queryDate'(val) {
  158. if (val) {
  159. let timestamp = new Date(val).valueOf();
  160. switch (this.params.reportType) {
  161. case 0:
  162. this.currentDate = uni.$u.timeFormat(timestamp, 'yyyy年mm月dd日');
  163. break;
  164. case 1:
  165. this.currentDate = uni.$u.timeFormat(timestamp, 'yyyy年mm月');
  166. break;
  167. case 2:
  168. this.currentDate = uni.$u.timeFormat(timestamp, 'yyyy年');
  169. break;
  170. }
  171. }
  172. }
  173. },
  174. methods: {
  175. defaultSetVal() {
  176. this.currentYear = this.yearList[0][4].value;
  177. this.yearObj = this.yearList[0][4];
  178. this.params.queryDate = `${this.currentYear}-${this.currentMonth}-${this.currentDay}`;
  179. this.getData();
  180. },
  181. getYearList() {
  182. const date = new Date();
  183. const year = date.getFullYear();
  184. const list = [[]];
  185. for (let i = year - 4; i < year + 1; i++) {
  186. const obj = {
  187. text: String(i),
  188. value: String(i)
  189. };
  190. list[0].push(obj);
  191. }
  192. return list;
  193. },
  194. getMonthList() {
  195. const list = [[]];
  196. for (let i = 1; i < 13; i++) {
  197. const obj = {
  198. text: String(i),
  199. value: String(i)
  200. };
  201. if (i < 10) {
  202. obj.text = '0' + i;
  203. obj.value = '0' + i;
  204. }
  205. list[0].push(obj);
  206. }
  207. setTimeout(() => {
  208. this.defaultMonth = [0];
  209. }, 1000);
  210. return list;
  211. },
  212. getDayList() {
  213. const date = new Date();
  214. const year = date.getFullYear();
  215. let month = date.getMonth();
  216. if (this.monthObj) {
  217. month = parseInt(this.monthObj.value);
  218. }
  219. const day = date.getDate();
  220. const dayLen = new Date(year, month, 0).getDate();
  221. const list = [[]];
  222. for (let i = 1; i < dayLen + 1; i++) {
  223. const obj = {
  224. text: String(i),
  225. value: String(i)
  226. };
  227. if (i < 10) {
  228. obj.text = '0' + i;
  229. obj.value = '0' + i;
  230. }
  231. list[0].push(obj);
  232. }
  233. setTimeout(() => {
  234. this.defaultDay = [0];
  235. }, 1000);
  236. return list;
  237. },
  238. /**
  239. * 点击tab
  240. * @param {Object} item
  241. */
  242. tabClick(item) {
  243. this.tabCur = item.value;
  244. switch (item.value) {
  245. case 0:
  246. this.dayPicker = true;
  247. break;
  248. case 1:
  249. this.monthPicker = true;
  250. break;
  251. case 2:
  252. this.yearPicker = true;
  253. break;
  254. }
  255. this.params.reportType = this.tabCur;
  256. },
  257. yearConfirm(e) {
  258. this.defaultYear = [e.indexs[0]];
  259. this.currentYear = e.value[0].value;
  260. this.yearObj = e.value[0];
  261. this.params.queryDate = `${this.currentYear}-${this.currentMonth}-${this.currentDay}`;
  262. this.yearPicker = false;
  263. this.getData();
  264. },
  265. monthConfirm(e) {
  266. this.defaultMonth = [e.indexs[0]];
  267. this.currentMonth = e.value[0].value;
  268. this.monthObj = e.value[0];
  269. this.params.queryDate = `${this.currentYear}-${this.currentMonth}-${this.currentDay}`;
  270. this.monthPicker = false;
  271. this.dayList = this.getDayList();
  272. this.getData();
  273. },
  274. dayConfirm(e) {
  275. this.defaultDay = [e.indexs[0]];
  276. this.currentDay = e.value[0].value;
  277. this.dayObj = e.value[0];
  278. this.params.queryDate = `${this.currentYear}-${this.currentMonth}-${this.currentDay}`;
  279. this.dayPicker = false;
  280. this.getData();
  281. },
  282. getData() {
  283. uni.$u.api.operationalAnalysisApi
  284. .getTollCollectorPerformanceApi({ ...this.params })
  285. .then((res) => {
  286. if (res.code === 200) {
  287. if (res.rows && res.rows.length) {
  288. this.chartData.categories = res.rows.map((item) => {
  289. return item.payeeName;
  290. });
  291. this.chartData.series[0].data = res.rows.map((item) => {
  292. return item.amt;
  293. });
  294. } else {
  295. this.chartData.categories = [];
  296. this.chartData.series[0].data = [];
  297. }
  298. }
  299. });
  300. }
  301. }
  302. };
  303. </script>
  304. <style lang="scss">
  305. page {
  306. background-color: #1767f2;
  307. min-height: calc(100vh - 44px);
  308. }
  309. </style>
  310. <style lang="scss" scoped>
  311. @import './performanceAnalysis.scss';
  312. </style>