incomeAnalysis.vue 4.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184
  1. <!-- 收入分析 -->
  2. <template>
  3. <view class="revenue">
  4. <view class="revenue-search">
  5. <view class="revenue-search-item" @click="incomeTypePicker = true">
  6. <u--input
  7. placeholder="请输入内容"
  8. v-model="searchContent.text"
  9. suffixIcon="arrow-down"
  10. :readonly="true"
  11. />
  12. </view>
  13. </view>
  14. <view class="revenue-line">
  15. <ColumnChart
  16. v-if="chartData.series[0].data.length"
  17. :chartData="chartData"
  18. :title="title"
  19. :opts="opts"
  20. />
  21. <view class="empty" v-else>
  22. <u-empty></u-empty>
  23. </view>
  24. </view>
  25. <u-picker
  26. :show="incomeTypePicker"
  27. :columns="dictList"
  28. @confirm="incomeTypeConfirm"
  29. @cancel="incomeTypePicker = false"
  30. />
  31. <u-loading-page :loading="loading" loading-text="loading..." />
  32. </view>
  33. </template>
  34. <script>
  35. import ColumnChart from '@/components/columnChart.vue';
  36. export default {
  37. components: {
  38. ColumnChart
  39. },
  40. props: {
  41. title: {
  42. type: String,
  43. default: ''
  44. },
  45. opts: {
  46. type: Object,
  47. default: () => {
  48. return {
  49. enableScroll: true,
  50. xAxis: {
  51. rotateLabel: false,
  52. scrollShow: true,
  53. itemCount: 8
  54. },
  55. yAxis: {
  56. showTitle: true,
  57. splitNumber: 5,
  58. data: [
  59. {
  60. title: '元',
  61. titleOffsetY: -3
  62. }
  63. ]
  64. },
  65. legend: {
  66. show: false
  67. },
  68. dataLabel: false,
  69. padding: [20, 0, 10, 0],
  70. extra: {
  71. column: {
  72. width: 20
  73. }
  74. }
  75. };
  76. }
  77. }
  78. },
  79. data() {
  80. return {
  81. loading: false,
  82. chartData: {
  83. categories: [],
  84. series: [
  85. {
  86. name: '收入',
  87. data: []
  88. }
  89. ]
  90. },
  91. searchContent: {
  92. text: '',
  93. value: ''
  94. },
  95. dictList: [[]],
  96. incomeTypePicker: false,
  97. reportType: '',
  98. queryDate: ''
  99. };
  100. },
  101. methods: {
  102. getData({ reportType, queryDate }) {
  103. this.reportType = reportType;
  104. this.queryDate = queryDate;
  105. this.getDict();
  106. },
  107. getDict() {
  108. this.loading = true;
  109. uni.$u.api.getDictApi({ type: 'income_type' }).then((res) => {
  110. if (res.code === 200) {
  111. let list = res.data.map((item) => {
  112. return {
  113. text: item.dictLabel,
  114. value: item.dictValue
  115. };
  116. });
  117. this.dictList = [list];
  118. if (!this.searchContent.value) {
  119. this.searchContent = this.dictList[0][0];
  120. }
  121. this.getIncomeData();
  122. }
  123. });
  124. },
  125. getIncomeData() {
  126. this.loading = true;
  127. this.chartData.categories = [];
  128. this.chartData.series[0].data = [];
  129. this.chartData.series[0].name = this.searchContent.text;
  130. uni.$u.api.operationalAnalysisApi
  131. .getParkingIncomeDataApi({
  132. reportType: this.reportType,
  133. queryDate: this.queryDate,
  134. incomeType: this.searchContent.value
  135. })
  136. .then((res) => {
  137. if (res.code === 200) {
  138. if (res.data.itemList && res.data.itemList.length) {
  139. this.chartData.categories = res.data.itemList.map((item) => {
  140. return item.statisTime;
  141. });
  142. this.chartData.series[0].data = res.data.itemList.map((item) => {
  143. return item.amt;
  144. });
  145. }
  146. }
  147. this.loading = false;
  148. });
  149. },
  150. incomeTypeConfirm(e) {
  151. this.searchContent = e.value[0];
  152. this.getIncomeData();
  153. this.incomeTypePicker = false;
  154. },
  155. searchClick() {
  156. // this.getIncomeData()
  157. }
  158. }
  159. };
  160. </script>
  161. <style lang="scss" scoped>
  162. .revenue {
  163. background-color: #fff;
  164. border-radius: 5px;
  165. &-search {
  166. margin-bottom: 12px;
  167. padding: 19px 15px 0 15px;
  168. display: flex;
  169. &-item {
  170. width: 48%;
  171. margin-right: 2%;
  172. &-btn {
  173. width: 50%;
  174. height: 38px;
  175. }
  176. }
  177. }
  178. }
  179. .empty {
  180. padding: 15px;
  181. }
  182. </style>