PreparationReport.vue 6.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214
  1. <template>
  2. <a-card :loading="loading" title="筹建报表">
  3. <div class="salesCard">
  4. <a-tabs default-active-key="1" size="large" :tab-bar-style="{marginBottom: '24px', paddingLeft: '16px'}">
  5. <div class="extra-wrapper" slot="tabBarExtraContent">
  6. <a-date-picker
  7. style="margin-left: 8px"
  8. :format="BaseTool.Date.PICKER_NORM_DATE_PATTERN"
  9. v-model="queryParam.startMonth"
  10. placeholder="开始时间"
  11. />
  12. <a-date-picker
  13. style="margin-left: 8px"
  14. :format="BaseTool.Date.PICKER_NORM_DATE_PATTERN"
  15. v-model="queryParam.endMonth"
  16. placeholder="结束时间"
  17. />
  18. <a-button style="margin-left: 8px" type="default" @click="getData()">查询</a-button>
  19. <!-- <a-button style="margin-left: 8px" type="primary" icon="printer" @click="handlePrint()">打印</a-button>
  20. <a-button style="margin-left: 8px" type="primary" @click="doExport()">导出</a-button> -->
  21. </div>
  22. <a-tab-pane loading="true" tab="图形统计" key="1">
  23. <a-row>
  24. <a-col :span="16">
  25. <div style="padding: 10px">
  26. <chart-view :chartOption="chartOption1" width="100%" height="600px" />
  27. </div>
  28. </a-col>
  29. <a-col :span="8">
  30. <div style="padding: 10px">
  31. <chart-view :chartOption="chartOption2" width="100%" height="600px" />
  32. </div>
  33. </a-col>
  34. </a-row>
  35. </a-tab-pane>
  36. <a-tab-pane loading="true" tab="表格统计" key="2">
  37. <a-row>
  38. <a-col :xl="24" :lg="24" :md="24" :sm="24" :xs="24">
  39. <div style="padding: 10px">
  40. <a-table
  41. bordered
  42. :data-source="chartsData1"
  43. :columns="columns1"
  44. tableLayout="auto"
  45. :scroll="{x: 1000, y: BaseTool.Constant.scrollY }"
  46. rowKey="month">
  47. <span slot="action" slot-scope="record">
  48. </span>
  49. </a-table>
  50. <a-table
  51. bordered
  52. :data-source="chartsData2"
  53. :columns="columns2"
  54. tableLayout="auto"
  55. :scroll="{x: 1000, y: BaseTool.Constant.scrollY }"
  56. rowKey="month">
  57. <span slot="action" slot-scope="record">
  58. </span>
  59. </a-table>
  60. </div>
  61. </a-col>
  62. </a-row>
  63. </a-tab-pane>
  64. </a-tabs>
  65. </div>
  66. </a-card>
  67. </template>
  68. <script>
  69. import { getPreparationReportGroupByStatus, getAllPreparationReport } from '@/api/preparation/preparation'
  70. export default {
  71. data () {
  72. return {
  73. loading: false,
  74. queryParam: {
  75. startMonth: this.BaseTool.Date.formatter(new Date(), this.BaseTool.Date.PICKER_NORM_YEAR) + '-01-01',
  76. endMonth: this.BaseTool.Date.formatter(new Date(), this.BaseTool.Date.PICKER_NORM_DATE_PATTERN)
  77. },
  78. chartsData1: [],
  79. chartsData2: [],
  80. columns1: [
  81. {
  82. title: '时间',
  83. width: 180,
  84. dataIndex: 'month',
  85. customRender: (text, record, index) => {
  86. return record.year + '-' + text
  87. }
  88. },
  89. {
  90. title: '个数',
  91. width: 120,
  92. dataIndex: 'num'
  93. }
  94. ],
  95. columns2: [
  96. {
  97. title: '状态',
  98. width: 180,
  99. dataIndex: 'statusName'
  100. },
  101. {
  102. title: '个数',
  103. width: 120,
  104. dataIndex: 'num'
  105. }
  106. ]
  107. }
  108. },
  109. computed: {
  110. chartOption1 () {
  111. return {
  112. // tooltip: {
  113. // trigger: 'axis',
  114. // axisPointer: {
  115. // type: 'shadow'
  116. // }
  117. // },
  118. legend: {},
  119. grid: {
  120. left: '3%',
  121. right: '4%',
  122. bottom: '3%',
  123. containLabel: true
  124. },
  125. yAxis: {
  126. type: 'value',
  127. boundaryGap: [0, 0.01]
  128. },
  129. xAxis: {
  130. type: 'category',
  131. data: this.chartsData1.map(item => (item.year + '-' + item.month))
  132. },
  133. series: [
  134. {
  135. type: 'bar',
  136. data: this.chartsData1.map(item => item.num),
  137. itemStyle: {
  138. normal: {
  139. label: {
  140. show: true, // 开启显示
  141. position: 'top', // 在上方显示
  142. textStyle: { // 数值样式
  143. color: 'black',
  144. fontSize: 16
  145. }
  146. }
  147. }
  148. }
  149. }
  150. ]
  151. }
  152. },
  153. chartOption2 () {
  154. return {
  155. tooltip: {
  156. },
  157. legend: {},
  158. grid: {
  159. left: '3%',
  160. right: '4%',
  161. bottom: '3%',
  162. containLabel: true
  163. },
  164. series: [
  165. {
  166. type: 'pie',
  167. center: ['50%', '50%'],
  168. roseType: 'area',
  169. itemStyle: {
  170. borderRadius: 8
  171. },
  172. data: this.chartsData2.map(item => {
  173. return {
  174. value: item.num,
  175. name: item.statusName
  176. }
  177. })
  178. }
  179. ]
  180. }
  181. }
  182. },
  183. created () {
  184. this.getData()
  185. },
  186. methods: {
  187. getData () {
  188. if (this.queryParam.startMonth) {
  189. this.queryParam.startMonth = this.BaseTool.Date.formatter(this.queryParam.startMonth, this.BaseTool.Date.PICKER_NORM_DATE_PATTERN)
  190. }
  191. if (this.queryParam.endMonth) {
  192. this.queryParam.endMonth = this.BaseTool.Date.formatter(this.queryParam.endMonth, this.BaseTool.Date.PICKER_NORM_DATE_PATTERN)
  193. }
  194. Promise.all([getAllPreparationReport(this.queryParam), getPreparationReportGroupByStatus(this.queryParam)]).then(res => {
  195. console.log(res)
  196. this.chartsData1 = res[0].data
  197. this.chartsData2 = res[1].data
  198. })
  199. }
  200. }
  201. }
  202. </script>
  203. <style>
  204. </style>