FillGatherReport.vue 7.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261
  1. <template>
  2. <div class="page-header-index-wide">
  3. <a-card :title="title" :loading="loading" v-show="visible" :bordered="false" :body-style="{padding: '0'}">
  4. <div class="salesCard">
  5. <a-tabs default-active-key="1" size="large" :tab-bar-style="{marginBottom: '24px', paddingLeft: '16px'}">
  6. <div class="extra-wrapper" slot="tabBarExtraContent">
  7. <a-month-picker
  8. style="margin-left: 8px"
  9. :default-value="moment(defaultStartMonth, monthFormat)"
  10. :format="monthFormat"
  11. v-model="queryParam.startMonth"
  12. placeholder="开始月份"
  13. @change="onStartChange" />
  14. <a-month-picker
  15. style="margin-left: 8px"
  16. :default-value="moment(defaultEndMonth, monthFormat)"
  17. :format="monthFormat"
  18. v-model="queryParam.endMonth"
  19. placeholder="结束月份"
  20. @change="onEndChange" />
  21. <a-button style="margin-left: 8px" type="default" @click="getData()">查询</a-button>
  22. <a-button style="margin-left: 8px" type="primary" icon="printer" @click="handlePrint()">打印</a-button>
  23. <a-button style="margin-left: 8px" type="primary" @click="doExport()">导出</a-button>
  24. </div>
  25. <a-tab-pane loading="true" tab="图形统计" key="1">
  26. <a-row>
  27. <a-col :xl="24" :lg="24" :md="24" :sm="24" :xs="24">
  28. <div style="padding: 10px">
  29. <div id="container" style="width: 100%;overflow-x:auto"></div>
  30. </div>
  31. </a-col>
  32. </a-row>
  33. </a-tab-pane>
  34. <a-tab-pane loading="true" tab="表格统计" key="2">
  35. <a-row>
  36. <a-col :xl="24" :lg="24" :md="24" :sm="24" :xs="24">
  37. <div style="padding: 10px">
  38. <a-table
  39. bordered
  40. :data-source="chartsData"
  41. :columns="columns"
  42. tableLayout="auto"
  43. :scroll="{x: 1, y: BaseTool.Constant.scrollY }"
  44. rowKey="month">
  45. <span slot="action" slot-scope="record">
  46. <template>
  47. <a @click="handleView(record)">查看明细</a>
  48. <a-divider type="vertical" />
  49. <a @click="doExportDetail(record)">导出</a>
  50. </template>
  51. </span>
  52. </a-table>
  53. </div>
  54. </a-col>
  55. </a-row>
  56. </a-tab-pane>
  57. </a-tabs>
  58. </div>
  59. </a-card>
  60. <print-in-repair-report ref="basePrintModal" @ok="handleOk"/>
  61. <fill-gather-task-detail-repair-reportir-report ref="detailModal" @ok="handleOk"/>
  62. </div>
  63. </template>
  64. <script>
  65. import { getFillGatherTaskMonthReport, exportMonthReportBig24, exportMonthReportBig24Month } from '@/api/report/application-form'
  66. import { Chart } from '@antv/g2'
  67. import PrintInRepairReport from '@/views/dashboard/modules/PrintInRepairReport'
  68. import FillGatherTaskDetailRepairReport from '@/views/dashboard/modules/FillGatherTaskDetailRepairReport'
  69. import moment from 'moment'
  70. export default {
  71. name: 'Analysis',
  72. components: {
  73. PrintInRepairReport,
  74. Chart,
  75. FillGatherTaskDetailRepairReport
  76. },
  77. props: {
  78. /**
  79. * 检查类型: 1->24小时非计划性维修 2-全部维修(不包括其他临时完善维修)
  80. */
  81. searchType: {
  82. type: Number,
  83. default: 1
  84. },
  85. title: {
  86. type: String,
  87. default: '巡检任务统计'
  88. }
  89. },
  90. data () {
  91. return {
  92. loading: false,
  93. serverData: [],
  94. monthFormat: 'YYYY-MM',
  95. defaultStartMonth: this.BaseTool.Moment().format(this.BaseTool.Date.PICKER_NORM_YEAR) + '-01',
  96. defaultEndMonth: this.BaseTool.Moment().format(this.BaseTool.Date.PICKER_NORM_YEAR) + '-12',
  97. queryParam: {
  98. // year: 2021,
  99. startMonth: this.BaseTool.Moment().format(this.BaseTool.Date.PICKER_NORM_YEAR) + '-01-01',
  100. endMonth: this.BaseTool.Moment().format(this.BaseTool.Date.PICKER_NORM_YEAR) + '-12-01',
  101. searchType: this.searchType
  102. },
  103. visible: true,
  104. chart: null, // 创建一个chart变量
  105. chartsData: [],
  106. // 表头
  107. columns: [
  108. {
  109. title: '月份',
  110. width: 180,
  111. dataIndex: 'month'
  112. },
  113. {
  114. title: '数量',
  115. width: 120,
  116. dataIndex: 'num'
  117. },
  118. {
  119. title: '操作',
  120. key: 'action',
  121. width: '200px',
  122. align: 'center',
  123. scopedSlots: { customRender: 'action' }
  124. }
  125. ]
  126. }
  127. },
  128. created () {
  129. },
  130. mounted () {
  131. this.$nextTick(function () {
  132. this.getData()
  133. })
  134. },
  135. methods: {
  136. moment,
  137. onStartChange (date, dateString) {
  138. this.queryParam.startMonth = this.BaseTool.Date.formatter(dateString + '-01', this.BaseTool.Date.PICKER_NORM_DATE_PATTERN)
  139. },
  140. onEndChange (date, dateString) {
  141. this.queryParam.endMonth = this.BaseTool.Date.formatter(dateString + '-01', this.BaseTool.Date.PICKER_NORM_DATE_PATTERN)
  142. },
  143. getData () {
  144. if (this.queryParam.startMonth == null) {
  145. this.$message.error('请选择起始月份')
  146. return
  147. }
  148. if (this.queryParam.endMonth == null) {
  149. this.$message.error('请选择结束月份')
  150. return
  151. }
  152. getFillGatherTaskMonthReport(this.queryParam)
  153. .then(res => {
  154. this.chartsData = res.data
  155. this.getCharts('container', this.chartsData)// 调用统计图
  156. })
  157. },
  158. getCharts (id, data) {
  159. this.chart && this.chart.destroy()// 防止点击搜索按钮新增一个
  160. this.chart = new Chart({
  161. container: 'container',
  162. autoFit: true,
  163. height: 400
  164. })
  165. this.chart.data(data)
  166. this.chart.scale('num', {
  167. nice: true
  168. })
  169. this.chart.tooltip({
  170. showMarkers: true,
  171. shared: true
  172. })
  173. this.chart.interval().position('month*num')
  174. this.chart.interaction('active-region')
  175. this.chart.legend({
  176. position: 'bottom'
  177. })
  178. this.chart.render()
  179. },
  180. doExport () {
  181. const parameter = {
  182. ...this.queryParam
  183. }
  184. exportMonthReportBig24(parameter).then(file => {
  185. this.BaseTool.UPLOAD.downLoadExportExcel(file)
  186. })
  187. },
  188. doExportDetail (record) {
  189. const parameter = {
  190. ...this.queryParam,
  191. month: record.month,
  192. year: record.year
  193. }
  194. exportMonthReportBig24Month(parameter).then(file => {
  195. this.BaseTool.UPLOAD.downLoadExportExcel(file)
  196. })
  197. },
  198. handlePrint (record) {
  199. const modal = this.$refs.basePrintModal
  200. this.visible = false
  201. modal.base({ startMonth: this.queryParam.startMonth, endMonth: this.queryParam.endMonth, title: this.title, data: this.chartsData })
  202. },
  203. handleView (record) {
  204. console.log(111)
  205. console.log(record)
  206. const modal = this.$refs.detailModal
  207. modal.base(record)
  208. },
  209. handleOk () {
  210. this.visible = true
  211. }
  212. }
  213. }
  214. </script>
  215. <style lang="less" scoped>
  216. .extra-wrapper {
  217. line-height: 55px;
  218. padding-right: 24px;
  219. .extra-item {
  220. display: inline-block;
  221. margin-right: 24px;
  222. a {
  223. margin-left: 24px;
  224. }
  225. }
  226. }
  227. .antd-pro-pages-dashboard-analysis-twoColLayout {
  228. position: relative;
  229. display: flex;
  230. display: block;
  231. flex-flow: row wrap;
  232. }
  233. .antd-pro-pages-dashboard-analysis-salesCard {
  234. height: calc(100% - 24px);
  235. /deep/ .ant-card-head {
  236. position: relative;
  237. }
  238. }
  239. .dashboard-analysis-iconGroup {
  240. i {
  241. margin-left: 16px;
  242. color: rgba(0,0,0,.45);
  243. cursor: pointer;
  244. transition: color .32s;
  245. color: black;
  246. }
  247. }
  248. .analysis-salesTypeRadio {
  249. position: absolute;
  250. right: 54px;
  251. bottom: 12px;
  252. }
  253. </style>