PurchaseOrderReportPie.vue 12 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427
  1. <template>
  2. <div class="page-header-index-wide">
  3. <a-card 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="12" :lg="12" :md="12" :sm="24" :xs="24">
  30. <chart-view :chartOption="chartOption1" width="100%" height="600px" />
  31. </a-col>
  32. <a-col :xl="12" :lg="12" :md="12" :sm="24" :xs="24">
  33. <chart-view :chartOption="chartOption2" width="100%" height="600px" />
  34. </a-col>
  35. <a-col :xl="12" :lg="12" :md="12" :sm="24" :xs="24">
  36. <chart-view :chartOption="chartOption3" width="100%" height="600px" />
  37. </a-col>
  38. <a-col :xl="12" :lg="12" :md="12" :sm="24" :xs="24">
  39. <chart-view :chartOption="chartOption4" width="100%" height="600px" />
  40. </a-col>
  41. </a-row>
  42. </a-tab-pane>
  43. <!-- <a-tab-pane loading="true" tab="表格统计" key="2">
  44. <a-row>
  45. <a-col :xl="24" :lg="24" :md="24" :sm="24" :xs="24">
  46. <div style="padding: 10px">
  47. <a-table
  48. bordered
  49. :data-source="chartsData"
  50. :columns="columns"
  51. tableLayout="auto"
  52. :scroll="{x: 1, y: BaseTool.Constant.scrollY }"
  53. rowKey="month">
  54. <span slot="action" slot-scope="record">
  55. <template>
  56. <a @click="handleView(record)">查看明细</a>
  57. <a-divider type="vertical" />
  58. <a @click="doExportDetail(record)">导出</a>
  59. </template>
  60. </span>
  61. </a-table>
  62. </div>
  63. </a-col>
  64. </a-row>
  65. </a-tab-pane> -->
  66. </a-tabs>
  67. </div>
  68. </a-card>
  69. <print-in-repair-report ref="basePrintModal" @ok="handleOk"/>
  70. <detail ref="detailModal" @ok="handleOk"/>
  71. </div>
  72. </template>
  73. <script>
  74. import { Chart } from '@antv/g2'
  75. import PrintInRepairReport from '@/views/dashboard/modules/PrintInRepairReport'
  76. import Detail from './modules/Detail'
  77. import moment from 'moment'
  78. import { getPieByCondition, exportOrder, exportOrderDetail } from '@/api/purchase/purchase-order'
  79. export default {
  80. name: 'Analysis',
  81. components: {
  82. PrintInRepairReport,
  83. Chart,
  84. Detail
  85. },
  86. props: {
  87. /**
  88. * 检查类型: 1->24小时非计划性维修 2-全部维修(不包括其他临时完善维修)
  89. */
  90. searchType: {
  91. type: Number,
  92. default: 1
  93. },
  94. title: {
  95. type: String,
  96. default: '大于24小时非计划性维修'
  97. }
  98. },
  99. data () {
  100. return {
  101. loading: false,
  102. serverData: [],
  103. monthFormat: 'YYYY-MM-DD',
  104. defaultStartMonth: this.BaseTool.Moment().format(this.BaseTool.Date.PICKER_NORM_YEAR_MONTH) + '-01 00:00:00',
  105. defaultEndMonth: this.BaseTool.Moment().format(this.BaseTool.Date.PICKER_NORM_DATETIME_PATTERN),
  106. queryParam: {
  107. // year: 2021,
  108. createdTimeStart: this.BaseTool.Moment().format(this.BaseTool.Date.PICKER_NORM_YEAR_MONTH) + '-01 00:00:00',
  109. createdTimeEnd: this.BaseTool.Moment().format(this.BaseTool.Date.PICKER_NORM_DATETIME_PATTERN)
  110. },
  111. visible: true,
  112. chart: null, // 创建一个chart变量
  113. chartsData: [[], [], [], []],
  114. // 表头
  115. columns: [
  116. {
  117. title: '采购单状态',
  118. width: 180,
  119. dataIndex: 'purchaseType',
  120. customRender: (text, record, index) => {
  121. return this.BaseTool.Table.getMapText(this.typeMap, text)
  122. }
  123. },
  124. {
  125. title: '采购单总数',
  126. width: 120,
  127. dataIndex: 'orderTotalNum'
  128. },
  129. {
  130. title: '备件总数',
  131. width: 120,
  132. dataIndex: 'spareTotalNum'
  133. },
  134. {
  135. title: '操作',
  136. key: 'action',
  137. width: '200px',
  138. align: 'center',
  139. scopedSlots: { customRender: 'action' }
  140. }
  141. ],
  142. typeMap: {},
  143. cptcodeMap: {}
  144. }
  145. },
  146. computed: {
  147. chartOption1 () {
  148. console.log(this.chartsData)
  149. const data = this.chartsData[1].map(item => {
  150. return {
  151. value: item.num,
  152. name: this.cptcodeMap[item.type]
  153. }
  154. })
  155. return {
  156. title: {
  157. left: 'center',
  158. text: '采购类型统计'
  159. },
  160. legend: {
  161. top: '10%'
  162. },
  163. grid: {
  164. left: '3%',
  165. right: '4%',
  166. bottom: '3%',
  167. containLabel: true
  168. },
  169. series: [
  170. {
  171. type: 'pie',
  172. center: ['50%', '50%'],
  173. radius: [0, 100],
  174. label: {
  175. formatter: `{b}:{c}`,
  176. textBorderColor: '#000',
  177. textBorderWidth: 0,
  178. fontSize: 16,
  179. overflow: 'breakAll',
  180. labelLine: {
  181. length: 3
  182. }
  183. },
  184. data: data
  185. }
  186. ]
  187. }
  188. },
  189. chartOption2 () {
  190. console.log(this.chartsData)
  191. const data = this.chartsData[2].map(item => {
  192. return {
  193. value: item.num,
  194. name: item.type
  195. }
  196. })
  197. return {
  198. title: {
  199. left: 'center',
  200. text: '业务类型统计'
  201. },
  202. legend: {
  203. top: '10%'
  204. },
  205. grid: {
  206. left: '3%',
  207. right: '4%',
  208. bottom: '3%',
  209. containLabel: true
  210. },
  211. series: [
  212. {
  213. type: 'pie',
  214. center: ['50%', '50%'],
  215. radius: [0, 100],
  216. label: {
  217. formatter: `{b}:{c}`,
  218. textBorderColor: '#000',
  219. textBorderWidth: 0,
  220. fontSize: 16,
  221. overflow: 'breakAll',
  222. labelLine: {
  223. length: 3
  224. }
  225. },
  226. data: data
  227. }
  228. ]
  229. }
  230. },
  231. chartOption3 () {
  232. console.log(this.chartsData)
  233. const data = this.chartsData[3].map(item => {
  234. return {
  235. value: item.num,
  236. name: this.flagMap[item.type]
  237. }
  238. })
  239. return {
  240. title: {
  241. left: 'center',
  242. text: '采购厂区统计'
  243. },
  244. legend: {
  245. top: '10%'
  246. },
  247. grid: {
  248. left: '3%',
  249. right: '4%',
  250. bottom: '3%',
  251. containLabel: true
  252. },
  253. series: [
  254. {
  255. type: 'pie',
  256. center: ['50%', '50%'],
  257. radius: [0, 100],
  258. label: {
  259. formatter: `{b}:{c}`,
  260. textBorderColor: '#000',
  261. textBorderWidth: 0,
  262. fontSize: 16,
  263. overflow: 'breakAll',
  264. labelLine: {
  265. length: 3
  266. }
  267. },
  268. data: data
  269. }
  270. ]
  271. }
  272. },
  273. chartOption4 () {
  274. console.log(this.chartsData)
  275. const data = this.chartsData[4].map(item => {
  276. return {
  277. value: item.num,
  278. name: this.deptMap[item.type]
  279. }
  280. })
  281. return {
  282. title: {
  283. left: 'center',
  284. text: '申请部门统计'
  285. },
  286. legend: {
  287. top: '10%'
  288. },
  289. grid: {
  290. left: '3%',
  291. right: '4%',
  292. bottom: '3%',
  293. containLabel: true
  294. },
  295. series: [
  296. {
  297. type: 'pie',
  298. center: ['50%', '50%'],
  299. radius: [0, 100],
  300. label: {
  301. formatter: `{b}:{c}`,
  302. textBorderColor: '#000',
  303. textBorderWidth: 0,
  304. fontSize: 16,
  305. overflow: 'breakAll',
  306. labelLine: {
  307. length: 3
  308. }
  309. },
  310. data: data
  311. }
  312. ]
  313. }
  314. }
  315. },
  316. created () {
  317. this.typeMap = this.DictCache.getLabelByValueMapByType(this.DictCache.TYPE.LONG_YAN_PURCHASE_TYPE)
  318. this.cptcodeMap = this.DictCache.getLabelByValueMapByType(this.DictCache.TYPE.LONG_YAN_PURCHASE_ORDER_PLAN_TYPE)
  319. this.flagMap = this.DictCache.getLabelByValueMapByType(this.DictCache.TYPE.PROJECT_NEW_AND_OLD)
  320. this.deptMap = this.DictCache.getLabelByValueMapByType(this.DictCache.TYPE.YONG_YOU_DEPT)
  321. },
  322. mounted () {
  323. this.$nextTick(function () {
  324. this.getData()
  325. })
  326. },
  327. methods: {
  328. moment,
  329. onStartChange (date, dateString) {
  330. this.queryParam.createdTimeStart = this.BaseTool.Date.formatter(date, this.BaseTool.Date.PICKER_NORM_DATETIME_PATTERN)
  331. },
  332. onEndChange (date, dateString) {
  333. console.log(date)
  334. this.queryParam.createdTimeEnd = this.BaseTool.Date.formatter(date, this.BaseTool.Date.PICKER_NORM_DATETIME_PATTERN)
  335. },
  336. getData () {
  337. getPieByCondition()
  338. .then(res => {
  339. this.chartsData = res.data
  340. })
  341. },
  342. doExport () {
  343. const parameter = {
  344. ...this.queryParam
  345. }
  346. exportOrder(parameter).then(file => {
  347. this.BaseTool.UPLOAD.downLoadExportExcel(file)
  348. })
  349. },
  350. doExportDetail (record) {
  351. const parameter = {
  352. ...this.queryParam,
  353. type: record.purchaseType
  354. }
  355. exportOrderDetail(parameter).then(file => {
  356. this.BaseTool.UPLOAD.downLoadExportExcel(file)
  357. })
  358. },
  359. handlePrint (record) {
  360. const modal = this.$refs.basePrintModal
  361. this.visible = false
  362. modal.base({ createdTimeStart: this.queryParam.createdTimeStart, createdTimeEnd: this.queryParam.createdTimeEnd, title: this.title, data: this.chartsData })
  363. },
  364. handleView (record) {
  365. console.log(111)
  366. console.log(record)
  367. const modal = this.$refs.detailModal
  368. modal.base(record)
  369. },
  370. handleOk () {
  371. this.visible = true
  372. }
  373. }
  374. }
  375. </script>
  376. <style lang="less" scoped>
  377. .extra-wrapper {
  378. line-height: 55px;
  379. padding-right: 24px;
  380. .extra-item {
  381. display: inline-block;
  382. margin-right: 24px;
  383. a {
  384. margin-left: 24px;
  385. }
  386. }
  387. }
  388. .antd-pro-pages-dashboard-analysis-twoColLayout {
  389. position: relative;
  390. display: flex;
  391. display: block;
  392. flex-flow: row wrap;
  393. }
  394. .antd-pro-pages-dashboard-analysis-salesCard {
  395. height: calc(100% - 24px);
  396. /deep/ .ant-card-head {
  397. position: relative;
  398. }
  399. }
  400. .dashboard-analysis-iconGroup {
  401. i {
  402. margin-left: 16px;
  403. color: rgba(0,0,0,.45);
  404. cursor: pointer;
  405. transition: color .32s;
  406. color: black;
  407. }
  408. }
  409. .analysis-salesTypeRadio {
  410. position: absolute;
  411. right: 54px;
  412. bottom: 12px;
  413. }
  414. </style>