ysy пре 1 година
родитељ
комит
74e42fe72a

+ 10 - 0
src/api/productionPlan/index.js

@@ -82,6 +82,16 @@ export async function splitWork (params) {
   return Promise.reject(new Error(res.data.message));
 }
 
+
+// 计划合批
+export async function mergeBatch (params) {
+  const res = await request.post(`/aps/productionplan/mergeBatch`, params);
+  if (res.data.code == 0) {
+    return res.data.data;
+  }
+  return Promise.reject(new Error(res.data.message));
+}
+
 // 修改优先级
 export async function updatePriority(data) {
   const res = await request.post(`/aps/productionplan/updatePriority`,  data);

+ 195 - 0
src/views/productionPlan/components/mergeDialog.vue

@@ -0,0 +1,195 @@
+<template>
+  <ele-modal
+    width="60vw"
+    :visible.sync="visible"
+    :close-on-click-modal="false"
+    custom-class="ele-dialog-form"
+    :title="'合并计划'"
+  >
+    <div class="form-wrapper">
+      <headerTitle title="需要合并计划"> </headerTitle>
+      <ele-pro-table
+        ref="table"
+        :needPage="false"
+        :columns="columns"
+        :datasource="mergeList"
+      >
+        <template v-slot:action="{ $index }">
+          <el-popconfirm
+            class="ele-action"
+            title="确定要删除此子单吗?"
+            @confirm="remove($index)"
+          >
+            <template v-slot:reference>
+              <el-link type="danger" :underline="false" icon="el-icon-delete">
+                删除
+              </el-link>
+            </template>
+          </el-popconfirm>
+        </template>
+      </ele-pro-table>
+
+      <el-form
+        :model="formData"
+        ref="form"
+        label-width="140px"
+        class="mt20"
+        :rules="rules"
+      >
+        <el-row>
+          <el-col :span="8">
+            <el-form-item label="要求生产数量" prop="requiredFormingNum">
+              {{ mTotal }}
+            </el-form-item>
+          </el-col>
+
+          <el-col :span="8">
+            <el-form-item label="要求生产日期" prop="reqMoldTime">
+              <el-date-picker
+                v-model="formData.reqMoldTime"
+                type="date"
+                value-format="yyyy-MM-dd"
+              ></el-date-picker>
+            </el-form-item>
+          </el-col>
+
+          <el-col :span="8">
+            <el-form-item label="批次号" prop="batchNo">
+              <el-input
+                v-model="formData.batchNo"
+                style="width: 220px"
+                placeholder="请输入批次号"
+              ></el-input>
+            </el-form-item>
+          </el-col>
+        </el-row>
+      </el-form>
+    </div>
+    <div slot="footer">
+      <el-button plain @click="cancel">取消</el-button>
+      <el-button type="primary" @click="confirm">确定</el-button>
+    </div>
+  </ele-modal>
+</template>
+
+<script>
+  import { mergeBatch } from '@/api/productionPlan/index.js';
+  export default {
+    components: {},
+    data() {
+      return {
+        visible: false,
+
+        mergeList: [],
+
+        formData: {},
+
+        rules: {
+          reqMoldTime: [
+            { required: true, message: '请要求生产日期', trigger: 'change' }
+          ],
+          batchNo: [
+            { required: true, message: '请输入批次号', trigger: 'blur' }
+          ]
+        },
+        mTotal: 0,
+
+        columns: [
+          {
+            prop: 'batchNo',
+            label: '批次号',
+            align: 'center',
+            minWidth: 100,
+            showOverflowTooltip: true
+          },
+
+          {
+            prop: 'code',
+            label: '计划编号',
+            align: 'center',
+            minWidth: 200
+          },
+
+          {
+            prop: 'produceRoutingName',
+            label: '工艺路线',
+            align: 'center',
+            minWidth: 120
+          },
+          {
+            prop: 'requiredFormingNum',
+            label: '要求生产数量',
+            align: 'center',
+            minWidth: 200
+          },
+
+          {
+            prop: 'reqMoldTime',
+            label: '要求生产日期',
+            align: 'center',
+            minWidth: 200
+          },
+          {
+            prop: 'action',
+            slot: 'action',
+            label: '操作',
+            align: 'center',
+            minWidth: 100
+          }
+        ]
+      };
+    },
+    methods: {
+      open(list) {
+        this.mergeList = list;
+        this.changeNum();
+        this.visible = true;
+      },
+
+      remove(index) {
+        if(this.mergeList.length <= 2) return this.$message.warning('至少保留二个计划')
+        this.mergeList.splice(index, 1);
+        this.changeNum();
+      },
+
+      changeNum() {
+        this.mTotal = 0;
+        this.mergeList.forEach((item) => {
+          this.mTotal += item.requiredFormingNum;
+        });
+      },
+
+      cancel() {
+        this.formData = {};
+        this.visible = false;
+        this.$refs.form.resetFields();
+      },
+
+      confirm() {
+        this.$refs.form.validate(async (value) => {
+          if (value) {
+            const params = {
+              ids: this.mergeList.map((item) => item.id),
+              reqMoldTime: this.formData.reqMoldTime,
+              batchNo: this.formData.batchNo,
+              requiredFormingNum: this.mTotal
+            };
+
+            const res = await mergeBatch(params);
+            if (res) {
+              this.$message.success('计划合并成功!');
+              this.$emit('success');
+              this.cancel();
+            }
+          }
+        });
+      }
+    }
+  };
+</script>
+
+<style lang="scss" scoped>
+  .mt20 {
+    margin-top: 20px;
+  }
+</style>

+ 30 - 9
src/views/productionPlan/components/unpackDialog.vue

@@ -25,7 +25,7 @@
             {{ formData.brandNo }}|{{ formData.model }}</el-descriptions-item
           >
 
-          <el-descriptions-item label="批号">{{
+          <el-descriptions-item label="批号">{{
             formData.batchNo
           }}</el-descriptions-item>
 
@@ -108,7 +108,6 @@
               ></el-date-picker>
             </el-form-item>
           </template>
-
         </ele-pro-table>
 
         <headerTitle title="拆单" class="mt20"> </headerTitle>
@@ -204,12 +203,21 @@
         rules: {},
 
         columns: [
+          {
+            prop: 'batchNo',
+            label: '批次号',
+            align: 'center',
+            minWidth: 100,
+            showOverflowTooltip: true
+          },
+
           {
             prop: 'joinPlanCode',
             label: '计划编号',
             align: 'center',
             minWidth: 200
           },
+
           {
             prop: 'requiredFormingNum',
             label: '要求生产数量',
@@ -223,11 +231,17 @@
             align: 'center',
             slot: 'reqMoldTime',
             minWidth: 200
-          },
-     
+          }
         ],
 
         columns2: [
+          {
+            prop: 'batchNo',
+            label: '批次号',
+            align: 'center',
+            minWidth: 100,
+            showOverflowTooltip: true
+          },
           {
             prop: 'joinPlanCode',
             label: '计划编号',
@@ -248,7 +262,7 @@
             slot: 'reqMoldTime',
             minWidth: 200
           },
-   
+
           {
             columnKey: 'action',
             label: '操作',
@@ -277,6 +291,7 @@
         this.form.surplusUnpack.push({
           joinPlanCode: this.formData.code,
           requiredFormingNum: this.formData.requiredFormingNum,
+          batchNo: this.formData.batchNo,
           reqMoldTime: '',
           isCopy: 1
         });
@@ -285,15 +300,19 @@
       openUnpack() {
         this.form.unpackList.push({
           joinPlanCode: this.formData.code,
+          batchNo: this.formData.batchNo,
           requiredFormingNum: '',
-          reqMoldTime: '',
+          reqMoldTime: ''
         });
       },
 
       changeNum(index) {
         let num = this.formData.requiredFormingNum;
         this.form.unpackList.forEach((e) => {
-          if (e.requiredFormingNum != null && e.requiredFormingNum != undefined) {
+          if (
+            e.requiredFormingNum != null &&
+            e.requiredFormingNum != undefined
+          ) {
             num = num - Number(e.requiredFormingNum);
             if (num >= 0) {
               this.requiredFormingNum = num;
@@ -329,7 +348,8 @@
           if (value) {
             if (
               this.form.unpackList.length == 1 &&
-              this.form.unpackList[0].requiredFormingNum == this.formData.requiredFormingNum
+              this.form.unpackList[0].requiredFormingNum ==
+                this.formData.requiredFormingNum
             ) {
               this.$message.info('拆单数要大于1');
               return false;
@@ -345,7 +365,8 @@
 
             let params = [];
             if (this.requiredFormingNum != 0) {
-              this.form.surplusUnpack[0].requiredFormingNum = this.requiredFormingNum;
+              this.form.surplusUnpack[0].requiredFormingNum =
+                this.requiredFormingNum;
               params = [...this.form.unpackList, ...this.form.surplusUnpack];
             } else {
               params = this.form.unpackList;

+ 55 - 17
src/views/productionPlan/index.vue

@@ -29,14 +29,24 @@
         @sort-change="onSortChange"
       >
         <template v-slot:toolbar>
-          <el-button type="primary" size="mini" @click="handleMerge">合并计划</el-button>
+          <el-button type="primary" size="mini" @click="handleMerge"
+            >合并计划</el-button
+          >
+        </template>
+
+        <template v-slot:batchNo="{ row }">
+          <el-link type="primary" :underline="false">
+            {{ row.batchNo }}
+            <el-tag type="success" size="mini" v-if="row.joinPlanCode"
+              >拆</el-tag
+            >
+            <el-tag type="danger" v-if="row.splitBatch == 2"> 和</el-tag>
+          </el-link>
         </template>
 
         <template v-slot:code="{ row }">
           <el-link type="primary" :underline="false" @click="goDetail(row)">
             {{ row.code }}
-            <el-tag type="success" size="mini" v-if="row.joinPlanCode">拆</el-tag>
-            <el-tag type="danger" v-if="row.splitBatch == 2"> 和</el-tag>
           </el-link>
         </template>
 
@@ -127,6 +137,8 @@
     </el-card>
 
     <unpackDialog ref="unpackRef" @success="reload" />
+
+    <mergeDialog ref="mergeRef" @success="reload"></mergeDialog>
   </div>
 </template>
 
@@ -134,6 +146,7 @@
   import { getList, del, updatePriority } from '@/api/productionPlan/index.js';
   import productionPlanSearch from './components/productionPlan-search.vue';
   import unpackDialog from './components/unpackDialog.vue';
+  import mergeDialog from './components/mergeDialog.vue';
   import { release } from '@/api/productionPlan/order.js';
 
   import { getCode } from '@/api/codeManagement';
@@ -144,7 +157,8 @@
   export default {
     components: {
       productionPlanSearch,
-      unpackDialog
+      unpackDialog,
+      mergeDialog
     },
     data() {
       return {
@@ -244,7 +258,11 @@
             columnKey: 'selection',
             align: 'center',
             selectable: (row, index) => {
-              return this.activeName == 'first' && row.splitBatch != 2  && !row.joinPlanCode;
+              return (
+                this.activeName == 'first' &&
+                row.splitBatch != 2 &&
+                !row.joinPlanCode
+              );
             },
             reserveSelection: true,
             fixed: 'left'
@@ -255,8 +273,16 @@
             type: 'index',
             width: 55,
             align: 'center',
-            showOverflowTooltip: true,
+            showOverflowTooltip: true
+          },
 
+          {
+            slot: 'batchNo',
+            prop: 'batchNo',
+            label: '批次号',
+            align: 'center',
+            minWidth: 120,
+            showOverflowTooltip: true
           },
           {
             slot: 'code',
@@ -265,7 +291,7 @@
             label: '计划编号',
             align: 'center',
             showOverflowTooltip: true,
-            minWidth: 200
+            minWidth: 160
           },
           {
             prop: 'productCode',
@@ -288,13 +314,7 @@
             align: 'center',
             showOverflowTooltip: true
           },
-          {
-            prop: 'batchNo',
-            label: '批号',
-            align: 'center',
-            minWidth: 100,
-            showOverflowTooltip: true
-          },
+
           {
             prop: 'specification',
             label: '规格',
@@ -561,14 +581,32 @@
 
       // 拆批
       toUnpack(row) {
-        if(!row.batchNo) {
-          return this.$message.error('请先填写批次号!')
+        if (!row.batchNo) {
+          return this.$message.error('请先填写批次号!');
         }
         this.$refs.unpackRef.open(row);
       },
       // 合并
       handleMerge() {
-       console.log( this.selection)
+        if (this.selection.length <= 1) {
+          return this.$message.warning('请先勾选二个或多个计划!');
+        }
+        const productCode = this.selection[0].productCode;
+        const produceRoutingId = this.selection[0].produceRoutingId;
+
+        for (var i = 0; i < this.selection.length; i++) {
+          if (productCode != this.selection[i].productCode) {
+            return this.$message.warning('产品编码不一致!');
+          }
+
+          if (produceRoutingId != this.selection[i].produceRoutingId) {
+            return this.$message.warning('工艺路线不一致!');
+          }
+        }
+
+        this.$refs.mergeRef.open(this.selection);
+
+        console.log(this.selection);
       },
 
       handleDelete({ id }) {

+ 1 - 1
src/views/saleOrder/components/plan-submit.vue

@@ -63,7 +63,7 @@
         </el-descriptions-item>
 
         <el-descriptions-item>
-          <template slot="label"> 批号 </template>
+          <template slot="label"> 批号 </template>
           {{ info.batchNo }}
         </el-descriptions-item>
 

+ 2 - 2
src/views/saleOrder/salesToProduction.vue

@@ -68,9 +68,9 @@
           </el-col>
 
           <el-col v-bind="styleResponsive ? { lg: 4, md: 8 } : { span: 4 }">
-            <el-form-item label="批号:" prop="batchNo">
+            <el-form-item label="批号:" prop="batchNo">
               <el-input
-                placeholder="请输入批号"
+                placeholder="请输入批号"
                 v-model="form.batchNo"
               ></el-input>
             </el-form-item>

+ 1 - 1
src/views/workOrder/index.vue

@@ -182,7 +182,7 @@
 
           {
             prop: 'batchNo',
-            label: '批号',
+            label: '批号',
             align: 'center',
             minWidth: 100,
             showOverflowTooltip: true