Răsfoiți Sursa

同步代码

lucw 7 luni în urmă
părinte
comite
6fe8899d65

+ 24 - 0
src/api/producetaskrecordrulesrecord/index.js

@@ -76,3 +76,27 @@ export async function getCategoryAndLevelByCategoryId(categoryId) {
   }
   return Promise.reject(new Error(res.data.message));
 }
+
+// POST /main/producerouting/taskinstance/getAllList
+export async function getAllRoutingTaskList(params) {
+  const res = await request.get(
+    '/main/producerouting/taskinstance/getAllList',
+    { params }
+  );
+  if (res.data.code == 0) {
+    return res.data.data;
+  }
+  return Promise.reject(new Error(res.data.message));
+}
+
+//  /mes/producetaskrulerecordpickdetail/getPickAndFeed 参数:workOrderId produceTaskId或produceTaskInstanceId
+export async function getPickAndFeed(body) {
+  const res = await request.post(
+    '/mes/producetaskrulerecordpickdetail/getPickAndFeed',
+    body
+  );
+  if (res.data.code == 0) {
+    return res.data.data;
+  }
+  return Promise.reject(new Error(res.data.message));
+}

+ 44 - 17
src/views/produce/components/prenatalExamination/releaseRulesDialog.vue

@@ -227,7 +227,7 @@
     </el-form>
 
     <material
-      v-if="addForm.produceTaskId"
+      v-if="addForm.produceTaskId && addForm.reportWorkType == 2"
       ref="materialRef"
       :pickDetails.sync="addForm.pickDetails"
       :outputDetails.sync="addForm.outputDetails"
@@ -243,14 +243,29 @@
       @refresh="getListByWorkOrderId"
     ></material>
 
-    <header-title
-      title="检查项目"
-      :style="`margin-top: ${
-        addForm.reportWorkType == '2' && addForm.produceTaskId ? '20px' : '0px'
-      }`"
-    ></header-title>
+    <header-title title="检查项目" :style="`margin-top: 20px`"></header-title>
+
+    <template v-if="addForm.recordRulesClassify == 10">
+      <el-tabs v-model="statisticsType" type="card">
+        <el-tab-pane
+          v-for="i in statisticsTypeList"
+          :label="i.label"
+          :name="i.value"
+          :key="i.value"
+        >
+        </el-tab-pane>
+      </el-tabs>
+      <statistics
+        :details="addForm.details"
+        :statisticsType="statisticsType"
+        :produceTaskId="addForm.produceTaskId"
+        :workOrderId="addForm.workOrderId"
+        :routingId="addForm.produceRoutingId"
+      ></statistics>
+    </template>
 
     <ele-pro-table
+      v-else
       v-loading="loading"
       ref="table"
       row-key="id"
@@ -421,9 +436,10 @@
   import dictMixins from '@/mixins/dictMixins';
   import tableColumnsMixin from '@/mixins/tableColumnsMixin';
   import material from './material.vue';
+  import statistics from './statistics.vue';
 
   export default {
-    components: { SelectUser, toolModal, material },
+    components: { SelectUser, toolModal, material, statistics },
     mixins: [dictMixins, tableColumnsMixin],
     emits: ['reload'],
     props: {
@@ -593,6 +609,13 @@
           { label: '原材料', value: 1 },
           { label: '在制品', value: 2 },
           { label: 'BOM标准产出', value: 3 }
+        ],
+        // 1-成品统计,2-物料统计,3-工序统计"
+        statisticsType: '1',
+        statisticsTypeList: [
+          { label: '成品统计', value: '1' },
+          { label: '物料统计', value: '2' },
+          { label: '工序统计', value: '3' }
         ]
       };
     },
@@ -866,10 +889,12 @@
       submit(type) {
         console.log('this.addForm', this.addForm);
         if (type == 'submit') {
-          // 验证产出物数量
-          const valid = this.$refs.materialRef.validateOutputQuantities();
-          if (!valid) {
-            return;
+          if (this.$refs.materialRef) {
+            // 验证产出物数量
+            const valid = this.$refs.materialRef.validateOutputQuantities();
+            if (!valid) {
+              return;
+            }
           }
         }
         // 验证表单
@@ -912,11 +937,13 @@
           body.duration = Number(body.duration);
           body.duration = body.duration * 60 * 60 * 1000;
 
-          // 验证产出物数量
-          const materialValid =
-            await this.$refs.materialRef.validateOutputQuantities();
-          if (!materialValid) {
-            return;
+          if (this.$refs.materialRef) {
+            // 验证产出物数量
+            const materialValid =
+              await this.$refs.materialRef.validateOutputQuantities();
+            if (!materialValid) {
+              return;
+            }
           }
 
           // 提交

+ 256 - 0
src/views/produce/components/prenatalExamination/statistics.vue

@@ -0,0 +1,256 @@
+<template>
+  <div>
+    <ele-pro-table
+      v-if="
+        statisticsType == 1 &&
+        localDetails[0] &&
+        localDetails[0].statisticsValues
+      "
+      ref="table"
+      :columns="typeOneColumns"
+      :datasource="localDetails[0].statisticsValues"
+      cacheKey="mes-statistics-type-2511041946"
+      :needPage="false"
+    >
+      <template
+        v-for="(item, index) in localDetails[0].statisticsValues[0]"
+        v-slot:[`column_${index}`]="{ row }"
+      >
+        <div :key="`column_${index}`">
+          {{ `column_${index}` }}
+
+          <el-input
+            v-model="row.value"
+            :placeholder="`请输入${row.title}`"
+          ></el-input>
+        </div>
+      </template>
+    </ele-pro-table>
+    <ele-pro-table
+      v-if="
+        statisticsType == 2 &&
+        localDetails[1] &&
+        localDetails[1].statisticsValues
+      "
+      ref="table"
+      :columns="typeTwoColumns"
+      :datasource="localDetails[1].statisticsValues"
+      cacheKey="mes-statistics-type-2511041946"
+      :needPage="false"
+    >
+      <template
+        v-for="(item, index) in localDetails[0].statisticsValues[0]"
+        v-slot:[`column_${index}`]="{ row }"
+      >
+        <div :key="`column_${index}`"> {{ `column_${index}` }}</div>
+      </template>
+    </ele-pro-table>
+  </div>
+</template>
+
+<script>
+  import {
+    getAllRoutingTaskList,
+    getPickAndFeed
+  } from '@/api/producetaskrecordrulesrecord/index';
+
+  export default {
+    props: {
+      details: {
+        type: Array,
+        default: () => []
+      },
+      statisticsType: {
+        type: String,
+        default: '1' // 1-成品统计,2-物料统计,3-工序统计
+      },
+      // 工艺路线id 必填
+      routingId: {
+        type: [String, Number],
+        required: true
+      },
+      // workOrderId 工单id 必填
+      workOrderId: {
+        type: [String, Number],
+        required: true
+      },
+      // produceTaskId 工序id
+      produceTaskId: {
+        type: [String, Number],
+        required: true
+      }
+    },
+    watch: {
+      details: {
+        deep: true,
+        immediate: true,
+        handler(val) {
+          // const details = JSON.parse(JSON.stringify(val));
+          this.buildDetials(val);
+        }
+      }
+    },
+    computed: {
+      // 成品统计表头
+      typeOneColumns() {
+        if (
+          this.localDetails.length > 0 &&
+          this.localDetails[0].statisticsValues &&
+          this.localDetails[0].statisticsType == 1
+        ) {
+          return this.localDetails[0].statisticsValues[0].map((item, index) => {
+            return {
+              label: item.title,
+              slot: `column_${index}`,
+              align: 'center'
+            };
+          });
+        } else {
+          return [];
+        }
+      },
+      // 物料统计表头
+      typeTwoColumns() {
+        if (
+          this.localDetails.length > 1 &&
+          this.localDetails[1].statisticsValues &&
+          this.localDetails[1].statisticsType == 2
+        ) {
+          return this.localDetails[1].statisticsValues[0].map((item, index) => {
+            return {
+              label: item.title,
+              slot: `column_${index}`,
+              align: 'center'
+            };
+          });
+        } else {
+          return [];
+        }
+      },
+      // 工序统计表头
+      typeThreeColumns() {
+        if (
+          this.localDetails.length > 2 &&
+          this.localDetails[2].statisticsValues &&
+          this.localDetails[2].statisticsType == 3
+        ) {
+          return this.localDetails[2].statisticsValues[0].map((item, index) => {
+            return {
+              label: item.title,
+              slot: `column_${index}`,
+              align: 'center'
+            };
+          });
+        } else {
+          return [];
+        }
+      }
+    },
+    data() {
+      return {
+        localDetails: []
+      };
+    },
+
+    methods: {
+      // 通知父组件数据变更
+      emitChange() {
+        this.$emit('update:details', this.localDetails);
+      },
+      // 构建统计数据
+      async buildDetials(detials) {
+        if (detials.length === 0) {
+          this.localDetails = [];
+          return;
+        }
+        // 已构建过统计数据
+        if (detials[0].statisticsValues) {
+          return (this.localDetails = JSON.parse(JSON.stringify(detials)));
+        }
+        // 构建统计数据
+        const list = JSON.parse(JSON.stringify(detials));
+
+        const ruleId = list.map((i) => i.ruleId)[0];
+
+        // 工序任务列表
+        const routingTaskList = await getAllRoutingTaskList({
+          routingId: this.routingId
+        });
+
+        // 物料获取
+        const pickAndFeed = await getPickAndFeed({
+          workOrderId: this.workOrderId,
+          produceTaskId: this.produceTaskId
+        });
+        console.log('routingTaskList 工序数据', routingTaskList);
+        console.log('物料数据 pickAndFeed', pickAndFeed);
+
+        this.localDetails = [
+          {
+            ruleId,
+            statisticsType: 1,
+            statisticsValues: [
+              list
+                .filter((i) => i.statisticsType == 1)
+                .map((i) => {
+                  return {
+                    title: i.paramValue,
+                    value: '',
+                    formula: i.formula,
+                    unit: ''
+                  };
+                })
+            ]
+          },
+          // 物料统计
+          {
+            ruleId,
+            statisticsType: 2,
+            statisticsValues: pickAndFeed.map((pick) => {
+              const data = list
+                .filter((i) => i.statisticsType == 2)
+                .map((i) => {
+                  return {
+                    title: i.paramValue,
+                    value: '',
+                    formula: i.formula,
+                    unit: ''
+                  };
+                });
+
+              data.unshift({
+                title: '物料编码',
+                value: pick.categoryCode,
+                formula: '',
+                unit: '',
+                // 仅展示不计算和输入
+                isOnlyShow: true
+              });
+
+              data.unshift({
+                title: '物料名称',
+                value: pick.categoryName,
+                formula: '',
+                unit: '',
+                // 仅展示不计算和输入
+                isOnlyShow: true
+              });
+
+              return data;
+            })
+          },
+          // 工序统计
+          {
+            ruleId,
+            statisticsType: 3,
+            statisticsValues: []
+          }
+        ];
+        console.log('this.localDetails', this.localDetails);
+
+        // 通知父组件数据变更
+        this.emitChange();
+      }
+    }
+  };
+</script>