PurchaseOrderReportByFifity.vue 8.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279
  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.startTime"
  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.endTime"
  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. <chart-view :chartOption="chartOption1" width="100%" height="600px" />
  31. </a-col>
  32. </a-row>
  33. </a-tab-pane> -->
  34. <a-tab-pane loading="true" tab="表格统计" key="1">
  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. <detail ref="detailModal" @ok="handleOk"/>
  62. </div>
  63. </template>
  64. <script>
  65. import { Chart } from '@antv/g2'
  66. import PrintInRepairReport from '@/views/dashboard/modules/PrintInRepairReport'
  67. import Detail from './modules/Detail'
  68. import moment from 'moment'
  69. import { getPurchaseFifityReportQuery, exportOrderByTime, exportOrderDetailByTime } from '@/api/purchase/purchase-order'
  70. export default {
  71. name: 'Analysis',
  72. components: {
  73. PrintInRepairReport,
  74. Chart,
  75. Detail
  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: '大于24小时非计划性维修'
  88. }
  89. },
  90. data () {
  91. return {
  92. loading: false,
  93. serverData: [],
  94. monthFormat: 'YYYY-MM-DD',
  95. defaultStartMonth: this.BaseTool.Date.formatter(new Date(), this.BaseTool.Date.PICKER_NORM_YEAR) + '-01-01',
  96. defaultEndMonth: this.BaseTool.Moment().format(this.BaseTool.Date.PICKER_NORM_DATE_PATTERN),
  97. queryParam: {
  98. // year: 2021,
  99. pageSize: 10,
  100. startTime: this.BaseTool.Date.formatter(new Date(), this.BaseTool.Date.PICKER_NORM_YEAR) + '-01-01',
  101. endTime: this.BaseTool.Moment().format(this.BaseTool.Date.PICKER_NORM_DATE_PATTERN)
  102. },
  103. visible: true,
  104. chart: null, // 创建一个chart变量
  105. chartsData: [],
  106. // 表头
  107. columns: [
  108. {
  109. title: '备件名称',
  110. width: 180,
  111. dataIndex: 'spareName'
  112. },
  113. {
  114. title: '总数',
  115. width: 120,
  116. dataIndex: 'totalNum'
  117. }
  118. // {
  119. // title: '操作',
  120. // key: 'action',
  121. // width: '200px',
  122. // align: 'center',
  123. // scopedSlots: { customRender: 'action' }
  124. // }
  125. ],
  126. typeMap: {}
  127. }
  128. },
  129. computed: {
  130. chartOption1 () {
  131. return {
  132. // tooltip: {
  133. // trigger: 'axis',
  134. // axisPointer: {
  135. // type: 'shadow'
  136. // }
  137. // },
  138. legend: {},
  139. grid: {
  140. left: '3%',
  141. right: '4%',
  142. bottom: '3%',
  143. containLabel: true
  144. },
  145. yAxis: {
  146. type: 'value',
  147. boundaryGap: [0, 0.01]
  148. },
  149. xAxis: {
  150. type: 'category',
  151. data: this.chartsData.map(item => item.spareName)
  152. },
  153. series: [
  154. {
  155. name: '采购单总数',
  156. type: 'bar',
  157. data: this.chartsData.map(item => item.totalNum),
  158. itemStyle: {
  159. normal: {
  160. label: {
  161. show: true, // 开启显示
  162. position: 'top', // 在上方显示
  163. textStyle: { // 数值样式
  164. color: 'black',
  165. fontSize: 16
  166. }
  167. }
  168. }
  169. }
  170. }
  171. ]
  172. }
  173. }
  174. },
  175. created () {
  176. this.typeMap = this.DictCache.getLabelByValueMapByType(this.DictCache.TYPE.LONG_YAN_PURCHASE_TYPE)
  177. },
  178. mounted () {
  179. this.$nextTick(function () {
  180. this.getData()
  181. })
  182. },
  183. methods: {
  184. moment,
  185. onStartChange (date, dateString) {
  186. this.queryParam.startTime = this.BaseTool.Date.formatter(date, this.BaseTool.Date.PICKER_NORM_DATE_PATTERN)
  187. },
  188. onEndChange (date, dateString) {
  189. console.log(date)
  190. this.queryParam.endTime = this.BaseTool.Date.formatter(date, this.BaseTool.Date.PICKER_NORM_DATE_PATTERN)
  191. },
  192. getData () {
  193. getPurchaseFifityReportQuery(this.queryParam)
  194. .then(res => {
  195. this.chartsData = res.data.rows
  196. })
  197. },
  198. doExport () {
  199. const parameter = {
  200. ...this.queryParam
  201. }
  202. exportOrderByTime(parameter).then(file => {
  203. this.BaseTool.UPLOAD.downLoadExportExcel(file)
  204. })
  205. },
  206. doExportDetail (record) {
  207. const parameter = {
  208. ...this.queryParam,
  209. yearMonth: record.year + '-' + record.month
  210. }
  211. exportOrderDetailByTime(parameter).then(file => {
  212. this.BaseTool.UPLOAD.downLoadExportExcel(file)
  213. })
  214. },
  215. handlePrint (record) {
  216. const modal = this.$refs.basePrintModal
  217. this.visible = false
  218. modal.base({ startTime: this.queryParam.startTime, endTime: this.queryParam.endTime, title: this.title, data: this.chartsData })
  219. },
  220. handleView (record) {
  221. console.log(111)
  222. console.log(record)
  223. const modal = this.$refs.detailModal
  224. modal.base(record)
  225. },
  226. handleOk () {
  227. this.visible = true
  228. }
  229. }
  230. }
  231. </script>
  232. <style lang="less" scoped>
  233. .extra-wrapper {
  234. line-height: 55px;
  235. padding-right: 24px;
  236. .extra-item {
  237. display: inline-block;
  238. margin-right: 24px;
  239. a {
  240. margin-left: 24px;
  241. }
  242. }
  243. }
  244. .antd-pro-pages-dashboard-analysis-twoColLayout {
  245. position: relative;
  246. display: flex;
  247. display: block;
  248. flex-flow: row wrap;
  249. }
  250. .antd-pro-pages-dashboard-analysis-salesCard {
  251. height: calc(100% - 24px);
  252. /deep/ .ant-card-head {
  253. position: relative;
  254. }
  255. }
  256. .dashboard-analysis-iconGroup {
  257. i {
  258. margin-left: 16px;
  259. color: rgba(0,0,0,.45);
  260. cursor: pointer;
  261. transition: color .32s;
  262. color: black;
  263. }
  264. }
  265. .analysis-salesTypeRadio {
  266. position: absolute;
  267. right: 54px;
  268. bottom: 12px;
  269. }
  270. </style>