Quellcode durchsuchen

临时添加过程监测物料逻辑完善

lucw vor 7 Monaten
Ursprung
Commit
b974baeb71

+ 76 - 207
src/views/batchRecord/components/editModal.vue

@@ -311,6 +311,23 @@
                 ></el-input>
               </el-form-item>
             </el-col>
+            <el-col :span="8">
+              <el-form-item label="产出物">
+                <el-select
+                  v-model="form.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="form.conclusion">
@@ -453,75 +470,24 @@
           </el-col>
         </el-row>
 
-        <header-title
+        <material
           v-if="
-            form.reportWorkType == '2' &&
-            form.produceTaskId &&
-            reportWorkType == 2 &&
-            form.itemType == 2
+            form.produceTaskId && form.produceTaskInstanceId && workOrderInfo
           "
-          title="物品清单"
-          style="margin-top: 20px"
-        ></header-title>
-
-        <ele-pro-table
-          v-if="
-            form.reportWorkType == '2' &&
-            form.produceTaskId &&
-            reportWorkType == 2 &&
-            form.itemType == 2
-          "
-          ref="table"
-          row-key="id"
-          :columns="materialColumns"
-          :datasource="form.pickDetails"
-          cache-key="prenatal-examination-material-list-table-2510231107"
-          autoAmendPage
-          :needPage="false"
+          ref="materialRef"
+          :pickDetails.sync="form.pickDetails"
+          :outputDetails.sync="form.outputDetails"
+          :preOutputDetails="preOutputDetails"
+          :workOrderId="form.workOrderId"
+          :ruleId="form.ruleId"
+          :produceTaskId="form.produceTaskId"
+          :produceTaskName="form.produceTaskName"
+          :produceTaskInstanceId="form.produceTaskInstanceId"
+          :bomCategoryId="workOrderInfo.bomCategoryId"
+          :outputType="form.outputType"
+          :categoryId="workOrderInfo.categoryId"
           @refresh="getListByWorkOrderId"
-        >
-          <!-- <template v-slot:toolbar>
-            <el-button type="primary" @click="openMaterialModal"
-              >添加物料</el-button
-            >
-          </template> -->
-
-          <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>
+        ></material>
 
         <header-title
           v-if="form.itemType == 2"
@@ -779,6 +745,7 @@
   import bpmTask from '@/components/bpmTask/bpmTask.vue';
   import { getFactoryarea } from '@/api/aps/index';
   import { getTeam } from '@/api/produce/job.js';
+  import material from '@/views/produce/components/prenatalExamination/material.vue';
 
   export default {
     name: 'editModal',
@@ -795,7 +762,8 @@
       SelectUser,
       toolModal,
       bpmDetail,
-      bpmTask
+      bpmTask,
+      material
     },
     props: {
       // 1-产前准备,2-过程监测,3-产后检查
@@ -876,6 +844,8 @@
         details: [],
         // 物品清单
         pickDetails: [],
+        // 本次产出明细
+        outputDetails: [],
         executeUsersIds: [],
         workshopAreaId: null,
         workshopArea: '',
@@ -889,7 +859,8 @@
         checkValidityUnit: '',
         recordRulesExecuteMethodName: '',
         recordRulesExecuteMethodId: null,
-        conclusion: null
+        conclusion: null,
+        outputType: 1
       };
 
       return {
@@ -1039,144 +1010,17 @@
           { key: 'bpm', name: '流程详情' }
         ],
         activeComp: 'main',
-        // 物料清单表头
-        materialColumns: [
-          {
-            width: 45,
-            type: 'index',
-            columnKey: 'index',
-            align: 'center'
-          },
-          {
-            label: '类型',
-            prop: 'categoryLevelNamePath',
-            minWidth: 120
-          },
-          {
-            label: '编码',
-            prop: 'categoryCode',
-            minWidth: 120
-          },
-          {
-            label: '名称',
-            prop: 'categoryName',
-            minWidth: 120
-          },
-          {
-            prop: 'modelType',
-            label: '型号',
-            align: 'center',
-            showOverflowTooltip: true
-          },
-          {
-            prop: 'specification',
-            label: '规格',
-            align: 'center',
-            width: 160,
-            showOverflowTooltip: true
-          },
-          {
-            prop: 'brandNum',
-            label: '牌号',
-            align: 'center'
-          },
-          {
-            label: '工序名称',
-            prop: 'produceTaskName',
-            minWidth: 120
-          },
-          {
-            label: '数量',
-            prop: 'feedQuantity',
-            minWidth: 120,
-            formatter: (row) => {
-              return (row.feedQuantity || 0) + (row.feedUnit || '');
-            }
-          },
-          {
-            label: '当次报工数量',
-            prop: 'reportQuantity',
-            minWidth: 160,
-            slot: 'reportQuantity',
-            formatter: (row) => {
-              return (
-                (row.reportQuantity == null ? '' : row.reportQuantity) +
-                (row.feedUnit || '')
-              );
-            }
-          },
-          {
-            label: '当次合格数量',
-            prop: 'qualifiedQuantity',
-            minWidth: 160,
-            slot: 'qualifiedQuantity',
-            formatter: (row) => {
-              return (
-                (row.qualifiedQuantity == null ? '' : row.qualifiedQuantity) +
-                (row.feedUnit || '')
-              );
-            }
-          },
-          {
-            label: '当次不合格数量',
-            prop: 'noQualifiedQuantity',
-            minWidth: 160,
-            slot: 'noQualifiedQuantity',
-            formatter: (row) => {
-              return (
-                (row.noQualifiedQuantity == null
-                  ? ''
-                  : row.noQualifiedQuantity) + (row.feedUnit || '')
-              );
-            }
-          },
-          {
-            label: '不合格原因',
-            prop: 'msg',
-            minWidth: 160,
-            slot: 'msg'
-          },
-          {
-            label: '已报工数量',
-            prop: 'sumReportQuantity',
-            minWidth: 120,
-            formatter(row) {
-              return (row.sumReportQuantity || 0) + row.feedUnit;
-            }
-          },
-          {
-            label: '未报工数量',
-            prop: 'noReportQuantity',
-            minWidth: 120,
-            formatter(row) {
-              if (row.sumReportQuantity != null) {
-                return row.feedQuantity - row.sumReportQuantity + row.feedUnit;
-              }
-              return `${row.feedQuantity}${row.feedUnit || ''}`;
-            }
-          },
-          {
-            label: '合格总数',
-            prop: 'sumQualifiedQuantity',
-            minWidth: 120,
-            formatter(row) {
-              return (row.sumQualifiedQuantity || 0) + (row.feedUnit || '');
-            }
-          },
-          {
-            label: '不合格总数',
-            prop: 'sumNoQualifiedQuantity',
-            minWidth: 120,
-            formatter(row) {
-              return (row.sumNoQualifiedQuantity || 0) + (row.feedUnit || '');
-            }
-          }
-        ],
         workshopAreaList: [],
         checked: false,
         teamUserList: [],
         teamList: [],
-        teamAllList: []
+        teamAllList: [],
+        preOutputDetails: [],
+        outputTypeList: [
+          { label: '原材料', value: 1 },
+          { label: '在制品', value: 2 },
+          { label: 'BOM标准产出', value: 3 }
+        ]
       };
     },
     computed: {
@@ -1479,7 +1323,13 @@
       async getProductTaskList(id) {
         const data = await getTaskInstanceList(id);
         console.log('data 工序列表', data);
-        this.produceTaskList = data;
+        this.produceTaskList = data.filter(
+          (i) => i.taskId != '-2' && i.taskId != '-1'
+        );
+        // 赋值工序实例id
+        this.form.produceTaskInstanceId = data.find(
+          (i) => i.sourceTaskId == this.form.produceTaskId
+        )?.taskId;
       },
       // 选择工序
       produceTaskIdChange() {
@@ -1525,6 +1375,11 @@
               }
             );
           } else if (this.form.executeMethod == 2) {
+            // 验证产出物数量;
+            const valid = this.$refs.materialRef.validateOutputQuantities();
+            if (!valid) {
+              return;
+            }
             this.releaseRulesSaveOrSubmit('submit');
           } else {
             // 任务确认
@@ -1543,6 +1398,12 @@
 
           try {
             if (this.form.itemType == 2) {
+              // 验证产出物数量;
+              const valid = this.$refs.materialRef.validateOutputQuantities();
+              if (!valid) {
+                return;
+              }
+
               // 记录规则保存
               return this.releaseRulesSaveOrSubmit('save');
             }
@@ -1699,18 +1560,26 @@
         row.tools = [];
         row.toolNames = '';
       },
-      async getListByWorkOrderId() {
+      async getListByWorkOrderId(type = '') {
         if (!this.form.produceTaskId || this.reportWorkType != 2) return;
         // 查询物料信息
-        const materialList = await queryListByWorkOrderId({
+        const materialObject = await queryListByWorkOrderId({
           workOrderId: this.form.workOrderId,
           recordId: this.form.id,
           produceTaskId: this.form.produceTaskId,
           ruleId: this.form.ruleId
         });
 
-        console.log('materialList 物料信息', materialList);
-        this.form.pickDetails = materialList || [];
+        console.log('materialObject 物料信息', materialObject);
+        if (type == '') {
+          this.form.pickDetails = materialObject.pickDetails;
+          this.form.outputDetails = materialObject.outputDetails;
+          this.preOutputDetails = materialObject.preOutputDetails;
+        }
+
+        if (type == 'output') {
+          this.form.outputDetails = materialObject.outputDetails;
+        }
       },
       // qualifiedQuantityMax 最大合格数量
       qualifiedQuantityMax(row) {

+ 10 - 2
src/views/batchRecord/components/list.vue

@@ -56,7 +56,7 @@
             编辑
           </el-link>
 
-          <el-popconfirm
+          <!-- <el-popconfirm
             v-if="
               row.executeStatus == 0 ||
               (row.executeStatus == 1 && row.itemType == 2) ||
@@ -69,7 +69,15 @@
             <template v-slot:reference>
               <el-link type="primary" :underline="false"> 报工 </el-link>
             </template>
-          </el-popconfirm>
+          </el-popconfirm> -->
+
+          <el-link
+            type="primary"
+            :underline="false"
+            @click="openEdit('edit', row)"
+          >
+            报工
+          </el-link>
 
           <el-link
             v-if="row.approvalStatus === 0"

+ 23 - 2
src/views/produce/components/prenatalExamination/material.vue

@@ -118,7 +118,7 @@
       // 规则id
       ruleId: {
         type: [String, Number],
-        required: true
+        required: false
       },
       // 工序id
       produceTaskId: {
@@ -204,6 +204,27 @@
             this.getMaterialQuotaInfo();
           }
         }
+      },
+      ruleId: {
+        handler() {
+          // 更新物料明细的ruleId
+          this.localPickDetails = this.localPickDetails.map((item) => {
+            return {
+              ...item,
+              ruleId: this.ruleId
+            };
+          });
+          // 更新产出明细的ruleId
+          this.localOutputDetails = this.localOutputDetails.map((item) => {
+            return {
+              ...item,
+              ruleId: this.ruleId
+            };
+          });
+          // 通知父组件更新
+          this.$emit('update:pickDetails', this.localPickDetails);
+          this.$emit('update:outputDetails', this.localOutputDetails);
+        }
       }
     },
     computed: {
@@ -637,7 +658,7 @@
         if (this.outputType == 2 || this.outputType == 3) {
           let val = true;
 
-          if(!this.materialQuotaInfo){
+          if (!this.materialQuotaInfo) {
             this.materialQuotaInfo = await getMaterialQuotaInfo(
               this.bomCategoryId,
               this.produceTaskId

+ 1 - 2
src/views/produce/components/prenatalExamination/releaseRulesDialog.vue

@@ -959,10 +959,9 @@
           this.addForm.checkValidityUnit = '';
           this.addForm.conclusion = null;
           this.addForm.id = null;
-          this.addForm.pickDetails = [];
           this.addForm.duration = 0;
           this.addForm.executeUsers = [];
-          thia.addForm.executeUsersIds = [];
+          this.addForm.executeUsersIds = [];
           this.addForm.pickDetails = [];
           this.addForm.outputDetails = [];