Przeglądaj źródła

物料清单部分完善

lucw 7 miesięcy temu
rodzic
commit
518d458d4e

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

@@ -54,3 +54,25 @@ export async function queryListByWorkOrderId(body) {
   }
   return Promise.reject(new Error(res.data.message));
 }
+
+// /main/categoryparam/getMaterialQuotaInfo/{bomCategoryId}/{produceTaskId}
+export async function getMaterialQuotaInfo(bomCategoryId, produceTaskId) {
+  const res = await request.get(
+    `/main/categoryparam/getMaterialQuotaInfo/${bomCategoryId}/${produceTaskId}`
+  );
+  if (res.data.code == 0) {
+    return res.data.data;
+  }
+  return Promise.reject(new Error(res.data.message));
+}
+
+// /main/category/getCategoryAndLevelByCategoryId/{categoryId}
+export async function getCategoryAndLevelByCategoryId(categoryId) {
+  const res = await request.get(
+    `/main/category/getCategoryAndLevelByCategoryId/${categoryId}`
+  );
+  if (res.data.code == 0) {
+    return res.data.data;
+  }
+  return Promise.reject(new Error(res.data.message));
+}

+ 338 - 10
src/views/produce/components/prenatalExamination/material.vue

@@ -7,26 +7,84 @@
       row-key="id"
       :columns="materialColumns"
       :datasource="materialList"
-      cache-key="prenatal-examination-material-list-table-2510231107"
+      cache-key="prenatal-examination-material-list-table-2511031522"
       autoAmendPage
       :needPage="false"
-      @refresh="$emit('refresh')"
+      @refresh="$emit('refresh', 'material')"
     >
       <template v-slot:toolbar>
         <el-button type="primary" @click="openMaterialModal"
           >添加物料</el-button
         >
       </template>
+
+      <template v-slot:selectColumn="{ row }">
+        <el-checkbox
+          v-model="row.selected"
+          @change="selectedChange(row)"
+        ></el-checkbox>
+      </template>
     </ele-pro-table>
 
     <header-title title="产出清单" style="margin-top: 20px"></header-title>
 
+    <ele-pro-table
+      ref="table"
+      row-key="id"
+      :columns="outputDetailsColumns"
+      :datasource="localOutputDetails"
+      cache-key="prenatal-examination-output-list-table-2511031523"
+      autoAmendPage
+      :needPage="false"
+      @refresh="$emit('refresh', 'output')"
+    >
+      <template v-slot:reportQuantity="{ row }">
+        <el-input-number
+          size="small"
+          v-model.number="row.reportQuantity"
+          controls-position="right"
+          :min="0"
+          :max="row.feedQuantity"
+        ></el-input-number>
+      </template>
+      <template v-slot:qualifiedQuantity="{ row }">
+        <el-input-number
+          size="small"
+          v-model.number="row.qualifiedQuantity"
+          controls-position="right"
+          :min="0"
+          :max="qualifiedQuantityMax(row)"
+        ></el-input-number>
+      </template>
+      <template v-slot:noQualifiedQuantity="{ row }">
+        <el-input-number
+          size="small"
+          v-model.number="row.noQualifiedQuantity"
+          controls-position="right"
+          :min="0"
+          :max="noQualifiedQuantityMax(row)"
+        ></el-input-number>
+      </template>
+      <template v-slot:msg="{ row }">
+        <el-input
+          v-model="row.msg"
+          type="textarea"
+          rows="1"
+          autosize
+        ></el-input>
+      </template>
+    </ele-pro-table>
+
     <materialModal ref="materialModalRef" @confirm="materialConfirm" />
   </div>
 </template>
 
 <script>
   import materialModal from './materialModal.vue';
+  import {
+    getMaterialQuotaInfo,
+    getCategoryAndLevelByCategoryId
+  } from '@/api/producetaskrecordrulesrecord/index';
 
   export default {
     components: {
@@ -38,8 +96,13 @@
         type: Array,
         default: () => []
       },
+      // 本次产出明细
+      outputDetails: {
+        type: Array,
+        default: () => []
+      },
       // 上到工序产出明细
-      previousOutputDetails: {
+      preOutputDetails: {
         type: Array,
         default: () => []
       },
@@ -57,6 +120,21 @@
       produceTaskId: {
         type: [String, Number],
         required: true
+      },
+      // BOM产品分类id
+      bomCategoryId: {
+        type: [String, Number],
+        required: true
+      },
+      // 产出类型 1-物料本身 2-在制品 3-BOM标准产出
+      outputType: {
+        type: [Number],
+        required: true
+      },
+      // 产品分类id
+      categoryId: {
+        type: [String, Number],
+        required: false
       }
     },
     watch: {
@@ -65,19 +143,123 @@
           this.localPickDetails = JSON.parse(JSON.stringify(newVal));
         },
         deep: true
+      },
+      outputDetails: {
+        handler(newVal) {
+          this.localOutputDetails = JSON.parse(JSON.stringify(newVal));
+        },
+        deep: true
+      },
+      bomCategoryId: {
+        handler() {
+          this.getMaterialQuotaInfo();
+        }
+      },
+      produceTaskId: {
+        handler() {
+          this.getMaterialQuotaInfo();
+        }
+      },
+      outputType: {
+        handler() {
+          // 重置产出明细
+          this.localOutputDetails = [];
+
+          // 根据不同的类型,重置物料明细
+          if (this.outputType == 1) {
+            this.$emit('update:outputDetails', this.localOutputDetails);
+            // 1-物料本身
+          } else if (this.outputType == 2) {
+            // 2-在制品
+            this.getCategoryAndLevelByCategoryId();
+          } else {
+            // 3 BOM标准产出
+            this.getMaterialQuotaInfo();
+          }
+        }
       }
     },
     computed: {
       // 物料清单(包含上到工序产出明细)
       materialList() {
-        return [...this.previousOutputDetails, ...this.localPickDetails];
+        return [...this.preOutputDetails, ...this.localPickDetails];
+      },
+      // 物料清单表头
+      materialColumns() {
+        const list = [
+          {
+            width: 45,
+            type: 'index',
+            columnKey: 'index',
+            align: 'center'
+          },
+          {
+            label: '类型',
+            prop: 'categoryLevelNamePath',
+            minWidth: 120
+          },
+          {
+            label: '编码',
+            prop: 'categoryCode',
+            minWidth: 120
+          },
+          {
+            label: '名称',
+            prop: 'categoryName',
+            minWidth: 120
+          },
+          {
+            prop: 'model',
+            label: '型号',
+            align: 'center',
+            showOverflowTooltip: true
+          },
+          {
+            prop: 'specifications',
+            label: '规格',
+            align: 'center',
+            width: 160,
+            showOverflowTooltip: true
+          },
+          {
+            prop: 'brandNo',
+            label: '牌号',
+            align: 'center'
+          },
+          {
+            label: '工序名称',
+            prop: 'produceTaskName',
+            minWidth: 120
+          },
+          {
+            label: '数量',
+            prop: 'feedQuantity',
+            minWidth: 120,
+            formatter: (row) => {
+              return (row.quantity || '') + (row.unit || '');
+            }
+          }
+        ];
+        if (this.outputType == 1) {
+          list.push({
+            prop: '',
+            label: '选择',
+            slot: 'selectColumn',
+            align: 'center',
+            fixed: 'right'
+          });
+        }
+        return list;
       }
     },
+
     data() {
       return {
         localPickDetails: JSON.parse(JSON.stringify(this.pickDetails)),
-        // 物料清单表头
-        materialColumns: [
+        localOutputDetails: JSON.parse(JSON.stringify(this.outputDetails)),
+        materialQuotaInfo: null,
+        // 产出清单表头
+        outputDetailsColumns: [
           {
             width: 45,
             type: 'index',
@@ -123,16 +305,79 @@
             minWidth: 120
           },
           {
-            label: '数量',
-            prop: 'feedQuantity',
-            minWidth: 120,
+            label: '当次报工数量',
+            prop: 'reportQuantity',
+            minWidth: 160,
+            slot: 'reportQuantity',
             formatter: (row) => {
-              return (row.quantity || '') + (row.unit || '');
+              return (
+                (row.reportQuantity == null ? '' : row.unit) +
+                (row.feedUnit || '')
+              );
+            }
+          },
+          {
+            label: '当次合格数量',
+            prop: 'qualifiedQuantity',
+            minWidth: 160,
+            slot: 'qualifiedQuantity',
+            formatter: (row) => {
+              return (
+                (row.qualifiedQuantity == null ? '' : row.unit) +
+                (row.feedUnit || '')
+              );
+            }
+          },
+          {
+            label: '当次不合格数量',
+            prop: 'noQualifiedQuantity',
+            minWidth: 160,
+            slot: 'noQualifiedQuantity',
+            formatter: (row) => {
+              return (row.noQualifiedQuantity || 0) + (row.unit || '');
+            }
+          },
+          {
+            label: '不合格原因',
+            prop: 'msg',
+            minWidth: 160,
+            slot: 'msg'
+          },
+          {
+            label: '已报工数量',
+            prop: 'sumReportQuantity',
+            minWidth: 120,
+            formatter(row) {
+              return (row.sumReportQuantity || 0) + row.unit;
+            }
+          },
+          {
+            label: '合格总数',
+            prop: 'sumQualifiedQuantity',
+            minWidth: 120,
+            formatter(row) {
+              return (row.sumQualifiedQuantity || 0) + (row.unit || '');
+            }
+          },
+          {
+            label: '不合格总数',
+            prop: 'sumNoQualifiedQuantity',
+            minWidth: 120,
+            formatter(row) {
+              return (row.sumNoQualifiedQuantity || 0) + (row.unit || '');
             }
           }
         ]
       };
     },
+    mounted() {
+      if (this.outputType == 2) {
+        this.getCategoryAndLevelByCategoryId();
+      }
+      if (this.outputType == 3) {
+        this.getMaterialQuotaInfo();
+      }
+    },
     methods: {
       // 选择物料
       openMaterialModal() {
@@ -165,6 +410,89 @@
         });
 
         this.$emit('update:pickDetails', this.localPickDetails);
+      },
+      // 获取bom的产出
+      async getMaterialQuotaInfo() {
+        if (this.bomCategoryId && this.produceTaskId) {
+          const data = await getMaterialQuotaInfo(
+            this.bomCategoryId,
+            this.produceTaskId
+          );
+          console.log('this.materialQuotaInfo', data);
+          if (!data.standardOutput) {
+            return this.$message.warning('未配置标准产出物料');
+          }
+          // 赋值产出
+          this.localOutputDetails = [
+            {
+              ...data.standardOutput,
+              reportQuantity: 0,
+              qualifiedQuantity: 0,
+              noQualifiedQuantity: 0,
+              msg: '',
+              sumReportQuantity: 0,
+              sumQualifiedQuantity: 0,
+              sumNoQualifiedQuantity: 0
+            }
+          ];
+          this.$emit('update:outputDetails', this.localOutputDetails);
+          console.log('this.localOutputDetails', this.localOutputDetails);
+        }
+      },
+      // qualifiedQuantityMax 最大合格数量
+      qualifiedQuantityMax(row) {
+        return row.reportQuantity - row.noQualifiedQuantity;
+      },
+      noQualifiedQuantityMax(row) {
+        return row.reportQuantity - row.qualifiedQuantity;
+      },
+      selectedChange(row) {
+        console.log('row', row);
+
+        if (row.selected) {
+          // 判断是否存在
+          const index = this.localOutputDetails.findIndex(
+            (item) =>
+              item.categoryId === row.categoryId &&
+              item.produceTaskInstanceId === row.produceTaskInstanceId
+          );
+
+          if (index === -1) {
+            // 不存在则添加
+            this.localOutputDetails.push({
+              ...row,
+              reportQuantity: 0,
+              qualifiedQuantity: 0,
+              noQualifiedQuantity: 0,
+              msg: '',
+              sumReportQuantity: 0,
+              sumQualifiedQuantity: 0,
+              sumNoQualifiedQuantity: 0
+            });
+          } else {
+            this.$message.warning('该物料已存在于产出清单中');
+          }
+
+          this.$emit('update:outputDetails', this.localOutputDetails);
+        }
+      },
+      // getCategoryAndLevelByCategoryId 获取产品
+      async getCategoryAndLevelByCategoryId() {
+        const data = await getCategoryAndLevelByCategoryId(this.categoryId);
+        this.localOutputDetails = [
+          {
+            ...data,
+            reportQuantity: 0,
+            qualifiedQuantity: 0,
+            noQualifiedQuantity: 0,
+            msg: '',
+            sumReportQuantity: 0,
+            sumQualifiedQuantity: 0,
+            sumNoQualifiedQuantity: 0
+          }
+        ];
+        this.$emit('update:outputDetails', this.localOutputDetails);
+        console.log('this.localOutputDetails', this.localOutputDetails);
       }
     }
   };

+ 46 - 13
src/views/produce/components/prenatalExamination/releaseRulesDialog.vue

@@ -198,6 +198,23 @@
             ></el-input>
           </el-form-item>
         </el-col>
+        <el-col :span="8">
+          <el-form-item label="产出物">
+            <el-select
+              v-model="addForm.outputType"
+              placeholder="请选择产出物类型"
+              filterable
+              style="width: 100%"
+            >
+              <el-option
+                v-for="item in outputTypeList"
+                :key="item.value"
+                :label="item.label"
+                :value="item.value"
+              />
+            </el-select>
+          </el-form-item>
+        </el-col>
         <el-col :span="8">
           <el-form-item label="结论" required prop="conclusion">
             <el-radio-group v-model="addForm.conclusion">
@@ -212,10 +229,15 @@
     <material
       v-if="addForm.produceTaskId"
       :pickDetails.sync="addForm.pickDetails"
-      :previousOutputDetails="previousOutputDetails"
+      :outputDetails.sync="addForm.outputDetails"
+      :preOutputDetails="preOutputDetails"
       :workOrderId="addForm.workOrderId"
       :ruleId="addForm.ruleId"
       :produceTaskId="addForm.produceTaskId"
+      :bomCategoryId="workOrderInfo.bomCategoryId"
+      :outputType="addForm.outputType"
+      :categoryId="workOrderInfo.categoryId"
+      @refresh="getListByWorkOrderId"
     ></material>
 
     <header-title
@@ -471,8 +493,12 @@
         teamId: '',
         // 物料字段name
         pickDetails: [],
+        // 本次产出明细
+        outputDetails: [],
         recordRulesExecuteMethodId: null,
-        recordRulesExecuteMethodName: ''
+        recordRulesExecuteMethodName: '',
+        // 	产出类型 1-原材料,2-在制品,3.BOM标准产出
+        outputType: 1
       };
 
       return {
@@ -559,7 +585,12 @@
         teamAllList: [],
         workshopAreaList: [],
         // 上到工序的 产出明细
-        previousOutputDetails: []
+        preOutputDetails: [],
+        outputTypeList: [
+          { label: '原材料', value: 1 },
+          { label: '在制品', value: 2 },
+          { label: 'BOM标准产出', value: 3 }
+        ]
       };
     },
     computed: {
@@ -754,7 +785,8 @@
         }
       },
       // 物料信息查询
-      async getListByWorkOrderId() {
+      async getListByWorkOrderId(type = '') {
+        console.log('type 物料信息', type);
         if (!this.productionInfo.produceTaskId) return;
         // 查询物料信息
         const materialObject = await queryListByWorkOrderId({
@@ -765,8 +797,16 @@
         });
 
         console.log('materialList 物料信息', materialObject);
-        this.addForm.pickDetails = materialObject.pickDetails;
-        this.previousOutputDetails = materialObject.outputDetails;
+
+        if (type == '') {
+          this.addForm.pickDetails = materialObject.pickDetails;
+          this.addForm.outputDetails = materialObject.outputDetails;
+          this.preOutputDetails = materialObject.preOutputDetails;
+        }
+
+        if (type == 'output') {
+          this.addForm.outputDetails = materialObject.outputDetails;
+        }
       },
       // 规则信息
       async getRuleInfo() {
@@ -1048,13 +1088,6 @@
 
         console.log('row', row);
       },
-      // qualifiedQuantityMax 最大合格数量
-      qualifiedQuantityMax(row) {
-        return row.reportQuantity - row.noQualifiedQuantity;
-      },
-      noQualifiedQuantityMax(row) {
-        return row.reportQuantity - row.qualifiedQuantity;
-      },
       // 查询车间区域
       async getWorkshopArea() {
         const data = await getFactoryarea({

+ 5 - 1
src/views/produce/index.vue

@@ -1212,7 +1212,11 @@
       },
       //是否完成 产前准备 限制按钮
       async checkProductionResult() {
-        if (this.produceTaskInfo && this.workListIds.length > 0) {
+        if (
+          this.produceTaskInfo &&
+          this.workListIds.length > 0 &&
+          this.produceTaskInfo.id != -1
+        ) {
           // 判断是否要求先完成 产前准备等事项
           const result = await checkProductionResult({
             produceTaskId: this.produceTaskInfo.id,