PurchaseOrderReport.vue 7.7 KB

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