Ver código fonte

生产工单列表添加放行入口

lucw 8 meses atrás
pai
commit
14e3776e2d

+ 28 - 3
src/views/checklistManagement/components/checkAdd.vue

@@ -15,6 +15,7 @@
           clearable
           v-model="form.checklistType"
           @change="checklistTypeChange"
+          :disabled="checklistTypeDisabled"
         >
         </DictSelection>
       </el-form-item>
@@ -58,7 +59,9 @@
         // 	放行单类型,1-成品放行,2-商品放行,3-物料放行
         checklistType: '',
         templateId: null,
-        templateName: ''
+        templateName: '',
+        // 生产工单列表
+        workOrderList: []
       };
 
       return {
@@ -78,19 +81,41 @@
         },
         //模板列表
         templateIdList: [],
+        // 放行单类型是否禁用
+        checklistTypeDisabled: false
       };
     },
     created() {},
     methods: {
       // 外部调用,打开弹窗
-      open(type, data) {
-        console.log('data type', type, data);
+      open(type, checklistType, workOrderList) {
+        console.log(
+          'data checklistType workOrderList',
+          type,
+          checklistType,
+          workOrderList
+        );
 
         if (type == 'add') {
           this.title = '新增放行单';
         } else {
           this.title = '编辑放行单';
         }
+        // 固定放行单类型
+        if (checklistType) {
+          this.form.checklistType = checklistType;
+          this.checklistTypeDisabled = true;
+          this.checklistTypeChange();
+        } else {
+          this.checklistTypeDisabled = false;
+        }
+
+        if (workOrderList) {
+          this.form.workOrderList = workOrderList;
+        } else {
+          this.form.workOrderList = [];
+        }
+
         this.visible = true;
       },
       // 关闭时清理表单

+ 40 - 4
src/views/checklistManagement/components/checkDetails.vue

@@ -8,7 +8,12 @@
     maxable
     width="80%"
   >
-    <div class="switch" :maxable="true" style="margin-bottom: 20px">
+    <div
+      v-if="type == 'detail' || type == 'edit'"
+      class="switch"
+      :maxable="true"
+      style="margin-bottom: 20px"
+    >
       <div class="switch_left">
         <ul>
           <li
@@ -479,6 +484,11 @@
           this.form.templateId = data.templateId;
           this.form.templateName = data.templateName;
 
+          // 处理携带的生产工单
+          if (data.workOrderList && data.workOrderList.length) {
+            this.selectWorkOrderConfirm(data.workOrderList);
+          }
+
           // 根据模版id 查询模版详情
           this.getTemplateDetails(data.templateId);
         } else if (type == 'edit') {
@@ -512,11 +522,14 @@
             this.butLoading = true;
             try {
               if (type == 'save') {
-                if (this.type == 'edit') {
+                // 存在id 则更新
+                if (this.form.id) {
                   await checklistrecordUpdate(this.form);
                 } else {
                   this.form.createUserName = this.$store.state.user.info.name;
-                  await checklistrecordSave(this.form);
+                  const data = await checklistrecordSave(this.form);
+                  this.form.id = data;
+                  this.getCheckDetails(data);
                 }
               } else {
               }
@@ -526,7 +539,10 @@
             } catch (error) {
               this.butLoading = false;
             }
-            this.handleClose();
+
+            if (type != 'save') {
+              this.handleClose();
+            }
           } else {
             // 转换为数组
             const firstErrorField = Object.values(invalidFields);
@@ -661,6 +677,26 @@
       },
       // 规则齐套检查
       async getKitCheck() {
+        // 判断 是否有需要自动检查的项
+        const hasAutoCheck = this.form.details.some((item) => item.isAutoCheck);
+
+        if (!hasAutoCheck) {
+          console.log('this.form.details', this.form.details);
+          this.$message.warning('当前没有需要自动检查的规则');
+          return;
+        }
+
+        // 必须要有物品清单
+        if (this.form.orders.length == 0) {
+          this.$message.warning('请添加物品清单');
+          return;
+        }
+
+        if (!this.form.id) {
+          this.$message.warning('请先保存放行单');
+          return;
+        }
+
         try {
           this.butLoading = true;
           const data = await checklistrecordKitCheck(this.form.id);

+ 48 - 2
src/views/produceOrder/index.vue

@@ -54,6 +54,10 @@
           >
 
           <el-button type="success" @click="originCode()">朔源码</el-button>
+
+          <el-button v-if="tabValue == '6'" type="success" @click="batchRelease"
+            >批量放行</el-button
+          >
         </template>
 
         <template v-slot:code="{ row }">
@@ -186,6 +190,10 @@
               任务派单
             </el-link>
           </template>
+
+          <el-link v-if="tabValue == '6'" type="primary" @click="toRelease(row)"
+            >放行单</el-link
+          >
         </template>
       </ele-pro-table>
     </el-card>
@@ -213,6 +221,12 @@
     />
 
     <originCode ref="originCodeRef" />
+
+    <checkAdd
+      ref="checkAddRef"
+      @confirm="checkAddConfirm('add', $event)"
+    ></checkAdd>
+    <checkDetails ref="checkDetailsRef" @reload="reload"></checkDetails>
   </div>
 </template>
 
@@ -245,6 +259,8 @@
   import { debounce } from 'lodash';
   import tableColumnsMixin from '@/mixins/tableColumnsMixin';
   import originCode from './originCode.vue';
+  import checkAdd from '@/views/checklistManagement/components/checkAdd.vue';
+  import checkDetails from '@/views/checklistManagement/components/checkDetails.vue';
 
   export default {
     mixins: [tableColumnsMixin],
@@ -262,7 +278,9 @@
       EquipmentDialog,
       xlhView,
       workReport,
-      originCode
+      originCode,
+      checkAdd,
+      checkDetails
     },
 
     data() {
@@ -1206,7 +1224,35 @@
           priority: row.priority
         };
         updatePriority(params).then((res) => {});
-      }, 800)
+      }, 800),
+      // 批量放行
+      batchRelease() {
+        if (!this.selection.length) {
+          return this.$message.warning('请至少选择一条工单!');
+        }
+        console.log('this.selection', this.selection);
+
+        const productCode = this.selection[0].productCode;
+        const batchNo = this.selection[0].batchNo;
+        const isSame = this.selection.every(
+          (item) => item.productCode === productCode && item.batchNo === batchNo
+        );
+
+        if (!isSame) {
+          this.$message.warning('请选择同产品同批次号工单发起批量放行');
+          return;
+        }
+        // 添加
+        this.$refs.checkAddRef?.open('add', '1', this.selection);
+      },
+      // 单个放行
+      toRelease(row) {
+        this.$refs.checkAddRef?.open('add', '1', [row]);
+      },
+      // 确定放行
+      checkAddConfirm(type, data) {
+        this.$refs.checkDetailsRef?.open(type, data);
+      }
     }
   };
 </script>