zhangqing hace 1 año
padre
commit
ddc5b3d42d
Se han modificado 3 ficheros con 145 adiciones y 54 borrados
  1. 42 1
      src/api/mes/index.js
  2. 42 39
      src/views/home/data.js
  3. 61 14
      src/views/home/index.vue

+ 42 - 1
src/api/mes/index.js

@@ -34,4 +34,45 @@ export async function getCaptcha() {
     return res.data.data;
   }
   return Promise.reject(new Error(res.data.message));
-}
+}
+
+/** 
+ * 查询首页头部统计 
+ */
+export async function getCount(params) {
+  const res = await request.get(`/mes/index/count`, {
+    params
+  });
+  if (res.data.code == 0) {
+    return res.data.data;
+  }
+  return Promise.reject(new Error(res.data.message));
+}
+
+/**
+ * 查询工单完成统计 
+ */
+export async function getCompletionCount(params) {
+  const res = await request.get(`/mes/index/completionCount`, {
+    params
+  });
+  if (res.data.code == 0) {
+    return res.data.data;
+  }
+  return Promise.reject(new Error(res.data.message));
+}
+
+
+/**
+ * 查询工单列表 
+ */
+
+export async function getOrderList(params) {
+  const res = await request.get(`/mes/index/getOrderList`, {
+    params
+  });
+  if (res.data.code == 0) {
+    return res.data.data;
+  }
+  return Promise.reject(new Error(res.data.message));
+}

+ 42 - 39
src/views/home/data.js

@@ -14,6 +14,18 @@ function getDatesInMonth() {
     }
     return dates;
 }
+
+let statusOpt = [
+      { label: '生产中', value: '5' },
+      { label: '已完成', value: '6' },
+      { label: '已延期', value: '7' },
+    ]
+
+let daysOpt = [
+    { label: '已延期', value: -1},
+    { label: '已完成', value: 0},
+]
+
 export const columns = [
 
     {
@@ -26,72 +38,82 @@ export const columns = [
         fixed: 'left'
     },
     {
-        prop: 'name',
+        prop: 'batchNo',
         label: '批次号',
         align: 'center',
         showOverflowTooltip: true,
     },
     {
-        prop: 'name',
+        prop: 'code',
         label: '生产工单编码',
         align: 'center',
         showOverflowTooltip: true,
     },
     {
-        prop: 'name1',
+        prop: 'status',
         label: '工单状态',
         align: 'center',
         showOverflowTooltip: true,
+        formatter: (row) => {
+            let result = statusOpt.find(item => item.value == row.status)
+            return result ? result.label : ''
+        }
     },
     {
-        prop: 'qualified',
+        prop: 'planStartTime',
         label: '计划开始时间',
         minWidth: '120',
         align: 'center',
         showOverflowTooltip: true,
     },
     {
-        prop: 'qualified',
+        prop: 'planCompleteTime',
         label: '计划完成时间',
         minWidth: '120',
         align: 'center',
         showOverflowTooltip: true,
     },
     {
-        prop: 'name12',
+        prop: 'productName',
         label: '产品名称',
         align: 'center',
         showOverflowTooltip: true,
     }, {
-        prop: 'name12',
+        prop: 'productCode',
         label: '产品编码',
         align: 'center',
         showOverflowTooltip: true,
-    }, {
-        prop: 'name12',
-        label: '规格型号',
-        align: 'center',
-        showOverflowTooltip: true,
-    }, {
-        prop: 'name12',
+    }, 
+    // {
+    //     prop: 'specification',
+    //     label: '规格型号',
+    //     align: 'center',
+    //     showOverflowTooltip: true,
+    // }, 
+    {
+        prop: 'formingNum',
         label: '数量(个)',
         align: 'center',
         showOverflowTooltip: true,
     }, {
-        prop: 'name12',
-        label: '生产单位',
+        prop: 'taskName',
+        label: '生产工序',
         align: 'center',
         showOverflowTooltip: true,
     }, {
-        prop: 'name12',
-        label: '状态',
+        prop: 'days',
+        label: '交期状态',
         align: 'center',
         showOverflowTooltip: true,
+        formatter: (row) => {
+            let result = daysOpt.find(item => item.value == row.days)
+            return result ? result.label : row.days ? '剩余' + row.days + '天' : ''
+        }
     },
 
 ];
 
-export const barOption = (data, itemStyle = {}) => {
+export const barOption = (series, itemStyle = {}) => {
     return {
         tooltip: {
             formatter: (item) => {
@@ -113,7 +135,6 @@ export const barOption = (data, itemStyle = {}) => {
             data: ['一月', '二月', '三月', '四月', '五月', '六月', '七月', '八月', '九月', '十月', '十一月', '十二月',],
             axisLabel: {
                 fontSize: window.innerHeight * 0.012,
-
             }
 
         },
@@ -129,25 +150,7 @@ export const barOption = (data, itemStyle = {}) => {
                 },
             }
         ],
-        series: [
-            {
-                name: '工单入库数量',
-                barWidth: '25%',
-                data: data,
-                type: 'bar',
-                yAxisIndex: 0 // 使用第一个Y轴
-            }, {
-                name: '工单数',
-                symbolSize: 10,
-                data: [2, 1, 4, 5, 1, 2, 3, 4, 5, 1, 2, 1],
-                type: 'line', smooth: true,
-
-                itemStyle: {
-                    color: '#ffab08'
-                },
-              
-            }
-        ]
+        series
     }
 }
 

+ 61 - 14
src/views/home/index.vue

@@ -44,10 +44,11 @@
           </div>
           <ele-pro-table
             ref="table"
+            height="calc(100%)"
             :columns="columns"
             :datasource="datasource"
-            :needPage="false"
             :toolbar="false"
+            :needPage="false"
           >
           </ele-pro-table>
         </el-card>
@@ -56,12 +57,6 @@
   </div>
 </template>
 <script>
-import {
-  queryHomePage,
-  queryFactory,
-  queryTeam,
-  queryProductionLine
-} from '@/api/qms';
 import dictMixins from '@/mixins/dictMixins';
 import { pieOption, barOption, columns } from './data';
 import { use } from 'echarts/core';
@@ -72,10 +67,10 @@ import {
   TooltipComponent,
   LegendComponent
 } from 'echarts/components';
-import EleChart from 'ele-admin/packages/ele-chart';
 
 import VChart from 'vue-echarts';
 import { echartsMixin } from '@/utils/echarts-mixin';
+import { getCount, getCompletionCount, getOrderList } from '@/api/mes/index'
 // 按需加载 echarts
 use([
   CanvasRenderer,
@@ -137,9 +132,9 @@ export default {
       { value: 10, name: '  密度检测' },
       { value: 5, name: '  重量检测' }
     ]);
-    this.barOption = barOption([
-      50, 78, 88, 76, 75, 91, 78, 87, 81, 67, 95, 73
-    ]);
+    
+    this.getCount();
+    this.getCompletionCount();
   },
   mounted(){
     setTimeout(() => {
@@ -149,13 +144,65 @@ export default {
     }, 300);
   },
   methods: {
-    datasource({ page, where, limit }) {
-      return [];
-      return getList({
+    datasource({page, where, limit}) {
+      where.factoriesId = 0;
+      return getOrderList({
         ...where,
         pageNum: page,
         size: limit
       });
+
+    },
+    
+    //首页统计
+    async getCount() {
+      let rest = await getCount({factoriesId: 0});
+      this.arr.forEach((item, index) => {
+        if (item.name === '在制工单数') {
+          item.num = rest.inProductCount || 0;
+        } else if (item.name === '在制工单生产数') {
+          item.num = rest.inProgressWorkOrderCount || 0;
+        } else if (item.name === '已入库数') {
+          item.num = rest.inWarehouseCount || 0;
+        } else if (item.name === '在制工单延期生产数') {
+          item.num = rest.postponeCount || 0;
+        }
+      })
+      // console.log(rest, 'rest');
+    },
+
+    //工单完成统计
+    async getCompletionCount() {
+      let params = {
+        startDate: new Date().getFullYear() + '-01-01',
+        endDate: new Date().getFullYear() + '-12-31',
+        factoriesId: 0,
+      }
+      let rest = await getCompletionCount(params);
+      let inWarehouseCountList = []; //入库数量
+      let inProductCountList = []; //在制工单数
+      for (let i = 0; i < rest.length; i++) {
+        inWarehouseCountList.push(rest[i].inWarehouseCount)
+        inProductCountList.push(rest[i].inProductCountList)
+      }
+      this.barOption = barOption(
+        [
+          {
+            name: '工单入库数量',
+            barWidth: '25%',
+            data: inWarehouseCountList,
+            type: 'bar',
+            yAxisIndex: 0 // 使用第一个Y轴
+          }, {
+            name: '工单数',
+            symbolSize: 10,
+            data: inProductCountList,
+            type: 'line', smooth: true,
+            itemStyle: {
+              color: '#ffab08'
+            },
+          }
+        ]);
     }
   }
 };