incomeAnalysis.vue 4.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181
  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. chartData: {
  82. categories: [[]],
  83. series: [
  84. {
  85. name: '路段',
  86. data: []
  87. }
  88. ]
  89. },
  90. searchContent: {
  91. text: '',
  92. value: ''
  93. },
  94. dictList: [[]],
  95. incomeTypePicker: false,
  96. reportType: '',
  97. queryDate: '',
  98. loading: false
  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. .getIncomeDataApi({
  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. }
  156. };
  157. </script>
  158. <style lang="scss" scoped>
  159. .revenue {
  160. background-color: #fff;
  161. border-radius: 5px;
  162. &-search {
  163. margin-bottom: 12px;
  164. padding: 19px 15px 0 15px;
  165. display: flex;
  166. &-item {
  167. width: 48%;
  168. margin-right: 2%;
  169. &-btn {
  170. width: 50%;
  171. height: 38px;
  172. }
  173. }
  174. }
  175. }
  176. .empty {
  177. padding: 15px;
  178. }
  179. </style>