incomeAnalysis.vue 4.1 KB

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