PreparationReportPie.vue 7.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251
  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="24">
  25. <div style="padding: 10px">
  26. <chart-view :chartOption="chartOption2" width="100%" height="600px" />
  27. </div>
  28. </a-col>
  29. </a-row>
  30. </a-tab-pane>
  31. <a-tab-pane loading="true" tab="表格统计" key="2">
  32. <a-row>
  33. <a-col :xl="24" :lg="24" :md="24" :sm="24" :xs="24">
  34. <div style="padding: 10px">
  35. <a-table
  36. bordered
  37. :data-source="chartsData2"
  38. :columns="columns2"
  39. tableLayout="auto"
  40. :scroll="{x: 1000, y: BaseTool.Constant.scrollY }"
  41. rowKey="month">
  42. <span slot="action" slot-scope="record">
  43. <a @click="handleView(record)">查看明细</a>
  44. <a-divider type="vertical" />
  45. <a @click="doExportDetail(record)">导出</a>
  46. </span>
  47. </a-table>
  48. </div>
  49. </a-col>
  50. </a-row>
  51. </a-tab-pane>
  52. </a-tabs>
  53. </div>
  54. <Detail ref="detail" />
  55. </a-card>
  56. </template>
  57. <script>
  58. import { getPreparationReportGroupByStatus, getAllPreparationReport, exportPreparationReportGroupByStatus, exportPreparationReportGroupByStatusDetail } from '@/api/preparation/preparation'
  59. import Detail from './modules/Detail.vue'
  60. export default {
  61. components: {
  62. Detail
  63. },
  64. data () {
  65. return {
  66. loading: false,
  67. queryParam: {
  68. startMonth: this.BaseTool.Date.formatter(new Date(), this.BaseTool.Date.PICKER_NORM_YEAR) + '-01-01',
  69. endMonth: this.BaseTool.Date.formatter(new Date(), this.BaseTool.Date.PICKER_NORM_DATE_PATTERN)
  70. },
  71. chartsData1: [],
  72. chartsData2: [],
  73. columns1: [
  74. {
  75. title: '时间',
  76. width: 180,
  77. dataIndex: 'month',
  78. customRender: (text, record, index) => {
  79. return record.year + '-' + text
  80. }
  81. },
  82. {
  83. title: '个数',
  84. width: 120,
  85. dataIndex: 'num'
  86. }
  87. ],
  88. columns2: [
  89. {
  90. title: '状态',
  91. width: 180,
  92. dataIndex: 'statusName'
  93. },
  94. {
  95. title: '个数',
  96. width: 120,
  97. dataIndex: 'num'
  98. },
  99. {
  100. title: '操作',
  101. key: 'action',
  102. width: '200px',
  103. align: 'center',
  104. scopedSlots: { customRender: 'action' }
  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. label: {
  173. formatter: '{b}: {c}',
  174. fontSize: 16
  175. },
  176. data: this.chartsData2.map(item => {
  177. return {
  178. value: item.num,
  179. name: item.statusName
  180. }
  181. })
  182. }
  183. ]
  184. }
  185. }
  186. },
  187. created () {
  188. this.getData()
  189. },
  190. methods: {
  191. getData () {
  192. if (this.queryParam.startMonth) {
  193. this.queryParam.startMonth = this.BaseTool.Date.formatter(this.queryParam.startMonth, this.BaseTool.Date.PICKER_NORM_DATE_PATTERN)
  194. }
  195. if (this.queryParam.endMonth) {
  196. this.queryParam.endMonth = this.BaseTool.Date.formatter(this.queryParam.endMonth, this.BaseTool.Date.PICKER_NORM_DATE_PATTERN)
  197. }
  198. Promise.all([getAllPreparationReport(this.queryParam), getPreparationReportGroupByStatus(this.queryParam)]).then(res => {
  199. console.log(res)
  200. this.chartsData1 = res[0].data
  201. this.chartsData2 = res[1].data
  202. })
  203. },
  204. handleView (record) {
  205. console.log(record)
  206. this.$refs.detail.base(record)
  207. },
  208. doExport () {
  209. if (this.queryParam.startMonth) {
  210. this.queryParam.startMonth = this.BaseTool.Date.formatter(this.queryParam.startMonth, this.BaseTool.Date.PICKER_NORM_DATE_PATTERN)
  211. }
  212. if (this.queryParam.endMonth) {
  213. this.queryParam.endMonth = this.BaseTool.Date.formatter(this.queryParam.endMonth, this.BaseTool.Date.PICKER_NORM_DATE_PATTERN)
  214. }
  215. const parameter = {
  216. ...this.queryParam
  217. }
  218. exportPreparationReportGroupByStatus(parameter).then(file => {
  219. this.BaseTool.UPLOAD.downLoadExportExcel(file)
  220. })
  221. },
  222. doExportDetail (record) {
  223. if (this.queryParam.startMonth) {
  224. this.queryParam.startMonth = this.BaseTool.Date.formatter(this.queryParam.startMonth, this.BaseTool.Date.PICKER_NORM_DATE_PATTERN)
  225. }
  226. if (this.queryParam.endMonth) {
  227. this.queryParam.endMonth = this.BaseTool.Date.formatter(this.queryParam.endMonth, this.BaseTool.Date.PICKER_NORM_DATE_PATTERN)
  228. }
  229. const parameter = {
  230. ...this.queryParam,
  231. status: record.status
  232. }
  233. exportPreparationReportGroupByStatusDetail(parameter).then(file => {
  234. this.BaseTool.UPLOAD.downLoadExportExcel(file)
  235. })
  236. }
  237. }
  238. }
  239. </script>
  240. <style>
  241. </style>