whj 1 рік тому
батько
коміт
50321c6954

+ 32 - 0
src/api/purchase/purchase-order.js

@@ -284,3 +284,35 @@ export function exportPurchaseOrder (parameter) {
     responseType: 'blob'
   })
 }
+/**
+ * export file
+ * parameter: { }
+ * @param parameter :
+ * @returns {*}
+ */
+export function exportOrder (parameter) {
+  return axios({
+    url: '/longyanpurchaseorder/order/byType/export?' + stringify(parameter),
+    method: 'get',
+    headers: {
+      'Content-Type': 'application/json;charset=UTF-8'
+    },
+    responseType: 'blob'
+  })
+}
+/**
+ * export file
+ * parameter: { }
+ * @param parameter :
+ * @returns {*}
+ */
+export function exportOrderDetail (parameter) {
+  return axios({
+    url: '/longyanpurchaseorder/order/byType/detail/export?' + stringify(parameter),
+    method: 'get',
+    headers: {
+      'Content-Type': 'application/json;charset=UTF-8'
+    },
+    responseType: 'blob'
+  })
+}

+ 83 - 37
src/views/purchase/purchase-order-report/PurchaseOrderReport.vue

@@ -27,9 +27,7 @@
           <a-tab-pane loading="true" tab="图形统计" key="1">
             <a-row>
               <a-col :xl="24" :lg="24" :md="24" :sm="24" :xs="24">
-                <div style="padding: 10px">
-                  <div id="container" style="width: 100%;overflow-x:auto"></div>
-                </div>
+                <chart-view :chartOption="chartOption1" width="100%" height="600px" />
               </a-col>
             </a-row>
           </a-tab-pane>
@@ -65,12 +63,11 @@
 </template>
 
 <script>
-import { getMonthReportBig24, exportMonthReportBig24, exportMonthReportBig24Month } from '@/api/report/application-form'
 import { Chart } from '@antv/g2'
 import PrintInRepairReport from '@/views/dashboard/modules/PrintInRepairReport'
 import DetailRepairReport from '@/views/dashboard/modules/DetailRepairReport'
 import moment from 'moment'
-import { getPurchaseReport } from '@/api/purchase/purchase-order'
+import { getPurchaseReport, exportOrder, exportOrderDetail } from '@/api/purchase/purchase-order'
 
 export default {
   name: 'Analysis',
@@ -110,14 +107,22 @@ export default {
       // 表头
       columns: [
         {
-          title: '月份',
+          title: '采购单状态',
           width: 180,
-          dataIndex: 'month'
+          dataIndex: 'purchaseType',
+          customRender: (text, record, index) => {
+            return this.BaseTool.Table.getMapText(this.typeMap, text)
+          }
+        },
+        {
+          title: '采购单总数',
+          width: 120,
+          dataIndex: 'orderTotalNum'
         },
         {
-          title: '数量',
+          title: '备件总数',
           width: 120,
-          dataIndex: 'num'
+          dataIndex: 'spareTotalNum'
         },
         {
           title: '操作',
@@ -126,10 +131,75 @@ export default {
           align: 'center',
           scopedSlots: { customRender: 'action' }
         }
-      ]
+      ],
+      typeMap: {}
+    }
+  },
+  computed: {
+    chartOption1 () {
+      return {
+        // tooltip: {
+        //   trigger: 'axis',
+        //   axisPointer: {
+        //     type: 'shadow'
+        //   }
+        // },
+        legend: {},
+        grid: {
+          left: '3%',
+          right: '4%',
+          bottom: '3%',
+          containLabel: true
+        },
+        yAxis: {
+          type: 'value',
+          boundaryGap: [0, 0.01]
+        },
+        xAxis: {
+          type: 'category',
+          data: this.chartsData.map(item => this.BaseTool.Table.getMapText(this.typeMap, item.purchaseType))
+        },
+        series: [
+          {
+            name: '采购单总数',
+            type: 'bar',
+            data: this.chartsData.map(item => item.orderTotalNum),
+            itemStyle: {
+              normal: {
+                label: {
+                  show: true, // 开启显示
+                  position: 'top', // 在上方显示
+                  textStyle: { // 数值样式
+                    color: 'black',
+                    fontSize: 16
+                  }
+                }
+              }
+            }
+          },
+          {
+            name: '备件总数',
+            type: 'bar',
+            data: this.chartsData.map(item => item.spareTotalNum),
+            itemStyle: {
+              normal: {
+                label: {
+                  show: true, // 开启显示
+                  position: 'top', // 在上方显示
+                  textStyle: { // 数值样式
+                    color: 'black',
+                    fontSize: 16
+                  }
+                }
+              }
+            }
+          }
+        ]
+      }
     }
   },
   created () {
+    this.typeMap = this.DictCache.getLabelByValueMapByType(this.DictCache.TYPE.LONG_YAN_PURCHASE_TYPE)
   },
   mounted () {
     this.$nextTick(function () {
@@ -149,46 +219,22 @@ export default {
       getPurchaseReport(this.queryParam)
         .then(res => {
           this.chartsData = res.data
-          this.getCharts('container', this.chartsData)// 调用统计图
         })
     },
-    getCharts (id, data) {
-      this.chart && this.chart.destroy()// 防止点击搜索按钮新增一个
-      this.chart = new Chart({
-        container: 'container',
-        autoFit: true,
-        height: 400
-      })
-      this.chart.data(data)
-      this.chart.scale('num', {
-        nice: true
-      })
-      this.chart.tooltip({
-        showMarkers: true,
-        shared: true
-      })
-      this.chart.interval().position('month*num')
-      this.chart.interaction('active-region')
-      this.chart.legend({
-        position: 'bottom'
-      })
-      this.chart.render()
-    },
     doExport () {
       const parameter = {
         ...this.queryParam
       }
-      exportMonthReportBig24(parameter).then(file => {
+      exportOrder(parameter).then(file => {
         this.BaseTool.UPLOAD.downLoadExportExcel(file)
       })
     },
     doExportDetail (record) {
       const parameter = {
         ...this.queryParam,
-        month: record.month,
-        year: record.year
+        type: record.purchaseType
       }
-      exportMonthReportBig24Month(parameter).then(file => {
+      exportOrderDetail(parameter).then(file => {
         this.BaseTool.UPLOAD.downLoadExportExcel(file)
       })
     },