incomeAnalysis.vue 3.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170
  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="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: false
  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. name: '',
  77. data: []
  78. }]
  79. },
  80. searchContent: {
  81. text: '',
  82. value: ''
  83. },
  84. dictList: [[]],
  85. incomeTypePicker: false,
  86. reportType: '',
  87. queryDate: ''
  88. }
  89. },
  90. created() {
  91. this.getDict();
  92. },
  93. methods: {
  94. getData({ reportType, queryDate }) {
  95. this.reportType = reportType
  96. this.queryDate = queryDate
  97. this.getIncomeData()
  98. },
  99. getDict() {
  100. uni.$u.api.getDictApi({ type: 'income_type'}).then(res => {
  101. console.log(res)
  102. if (res.code === 200) {
  103. let list = res.data.map((item => {
  104. return {
  105. text: item.dictLabel,
  106. value: item.dictValue
  107. }
  108. }))
  109. this.dictList = [list]
  110. this.searchContent = this.dictList[0][0]
  111. }
  112. })
  113. },
  114. getIncomeData() {
  115. uni.$u.api.operationalAnalysisApi.getIncomeDataApi({
  116. reportType: this.reportType,
  117. queryDate: this.queryDate,
  118. incomeType: this.searchContent.value
  119. }).then(res => {
  120. console.log(res)
  121. if (res.code === 200) {
  122. if (res.data.itemList && res.data.itemList.length) {
  123. this.chartData.categories = res.data.itemList.map(item => {
  124. return item.statisTime
  125. })
  126. this.chartData.series[0].data = res.data.itemList.map(item => {
  127. return item.amt
  128. })
  129. } else {
  130. this.chartData.categories = []
  131. this.chartData.series[0].data = []
  132. }
  133. }
  134. })
  135. },
  136. incomeTypeConfirm(e) {
  137. this.searchContent = e.value[0]
  138. this.getIncomeData()
  139. this.incomeTypePicker = false
  140. },
  141. searchClick() {
  142. // this.getIncomeData()
  143. }
  144. }
  145. }
  146. </script>
  147. <style lang="scss" scoped>
  148. .revenue {
  149. background-color: #fff;
  150. border-radius: 5px;
  151. &-search {
  152. margin-bottom: 12px;
  153. padding: 19px 15px 0 15px;
  154. display: flex;
  155. &-item {
  156. width: 48%;
  157. margin-right: 2%;
  158. &-btn {
  159. width: 50%;
  160. height: 38px;
  161. }
  162. }
  163. }
  164. }
  165. .empty {
  166. padding: 15px;
  167. }
  168. </style>