ysy 1 год назад
Родитель
Сommit
cac6f57fd2

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

@@ -73,6 +73,15 @@ export async function del (id) {
   return Promise.reject(new Error(res.data.message));
 }
 
+// 拆分
+export async function splitWork (params) {
+  const res = await request.post(`/aps/productionplan/splitBatch`, 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);

+ 54 - 57
src/views/productionPlan/components/unpackDialog.vue

@@ -10,7 +10,7 @@
       <el-form :model="requestData" label-width="0" :show-message="false">
         <el-descriptions title="" :column="2" border>
           <el-descriptions-item label="计划编号">
-            {{ formData.code }}</el-descriptions-item
+            {{ formData.joinPlanCode }}</el-descriptions-item
           >
 
           <el-descriptions-item label="产品编码">{{
@@ -56,17 +56,17 @@
               type="primary"
               icon="el-icon-plus"
               class="ele-btn-icon"
-              :disabled="formingNum == 0 ? true : false"
+              :disabled="requiredFormingNum == 0 ? true : false"
               @click="openUnpack"
             >
               拆单
             </el-button>
           </template>
 
-          <template v-slot:formingNum="scope">
+          <template v-slot:requiredFormingNum="scope">
             <el-form-item
-              v-if="formingNum != 0"
-              :prop="'surplusUnpack.' + scope.$index + '.formingNum'"
+              v-if="requiredFormingNum != 0"
+              :prop="'surplusUnpack.' + scope.$index + '.requiredFormingNum'"
               :rules="[
                 {
                   required: true,
@@ -82,7 +82,7 @@
             >
               <el-input
                 disabled
-                v-model="formingNum"
+                v-model="requiredFormingNum"
                 placeholder="请输入"
               ></el-input>
             </el-form-item>
@@ -90,10 +90,10 @@
             <el-form-item v-else> 工单已全部拆完 </el-form-item>
           </template>
 
-          <template v-slot:planStartTime="scope">
+          <template v-slot:reqMoldTime="scope">
             <el-form-item
-              v-if="formingNum != 0"
-              :prop="'surplusUnpack.' + scope.$index + '.planStartTime'"
+              v-if="requiredFormingNum != 0"
+              :prop="'surplusUnpack.' + scope.$index + '.reqMoldTime'"
               :rules="{
                 required: true,
                 message: '请选择开始计划时间',
@@ -102,16 +102,13 @@
             >
               <el-date-picker
                 class="w100"
-                v-model="scope.row.planStartTime"
+                v-model="scope.row.reqMoldTime"
                 type="date"
                 value-format="yyyy-MM-dd"
               ></el-date-picker>
             </el-form-item>
           </template>
 
-          <template v-slot:classeId="scope">
-      
-          </template>
         </ele-pro-table>
 
         <headerTitle title="拆单" class="mt20"> </headerTitle>
@@ -122,9 +119,9 @@
           :columns="columns2"
           :datasource="form.unpackList"
         >
-          <template v-slot:formingNum="scope">
+          <template v-slot:requiredFormingNum="scope">
             <el-form-item
-              :prop="'unpackList.' + scope.$index + '.formingNum'"
+              :prop="'unpackList.' + scope.$index + '.requiredFormingNum'"
               :rules="{
                 required: true,
                 message: '请输入要求生产数量',
@@ -135,15 +132,15 @@
                 type="number"
                 @change="changeNum(scope.$index)"
                 :min="0"
-                v-model="scope.row.formingNum"
+                v-model="scope.row.requiredFormingNum"
                 placeholder="请输入"
               ></el-input-number>
             </el-form-item>
           </template>
 
-          <template v-slot:planStartTime="scope">
+          <template v-slot:reqMoldTime="scope">
             <el-form-item
-              :prop="'unpackList.' + scope.$index + '.planStartTime'"
+              :prop="'unpackList.' + scope.$index + '.reqMoldTime'"
               :rules="{
                 required: true,
                 message: '请选择开始计划时间',
@@ -152,7 +149,7 @@
             >
               <el-date-picker
                 class="w100"
-                v-model="scope.row.planStartTime"
+                v-model="scope.row.reqMoldTime"
                 type="date"
                 value-format="yyyy-MM-dd"
               ></el-date-picker>
@@ -184,6 +181,7 @@
 
 <script>
   import { deepClone } from '@/utils';
+  import { splitWork } from '@/api/productionPlan/index.js';
   export default {
     components: {},
     data() {
@@ -196,7 +194,7 @@
           deviceName: '',
           deviceId: ''
         },
-        formingNum: 0,
+        requiredFormingNum: 0,
 
         form: {
           surplusUnpack: [],
@@ -207,23 +205,23 @@
 
         columns: [
           {
-            prop: 'originalCode',
+            prop: 'joinPlanCode',
             label: '计划编号',
             align: 'center',
             minWidth: 200
           },
           {
-            prop: 'formingNum',
+            prop: 'requiredFormingNum',
             label: '要求生产数量',
             align: 'center',
-            slot: 'formingNum',
+            slot: 'requiredFormingNum',
             minWidth: 200
           },
           {
-            prop: 'planStartTime',
-            label: '计划开始时间',
+            prop: 'reqMoldTime',
+            label: '要求生产日期',
             align: 'center',
-            slot: 'planStartTime',
+            slot: 'reqMoldTime',
             minWidth: 200
           },
      
@@ -231,23 +229,23 @@
 
         columns2: [
           {
-            prop: 'originalCode',
-            label: '工单号',
+            prop: 'joinPlanCode',
+            label: '计划编号',
             align: 'center',
             minWidth: 200
           },
           {
-            prop: 'formingNum',
+            prop: 'requiredFormingNum',
             label: '要求生产数量',
             align: 'center',
-            slot: 'formingNum',
+            slot: 'requiredFormingNum',
             minWidth: 200
           },
           {
-            prop: 'planStartTime',
-            label: '计划开始时间',
+            prop: 'reqMoldTime',
+            label: '要求生产日期',
             align: 'center',
-            slot: 'planStartTime',
+            slot: 'reqMoldTime',
             minWidth: 200
           },
    
@@ -268,7 +266,7 @@
       open(row) {
         this.visible = true;
         this.formData = deepClone(row);
-        this.formingNum = this.formData.formingNum;
+        this.requiredFormingNum = this.formData.requiredFormingNum;
 
         this.form.surplusUnpack = [];
         this.form.unpackList = [];
@@ -277,33 +275,31 @@
 
       setSurplus() {
         this.form.surplusUnpack.push({
-          originalCode: this.formData.code,
-          formingNum: this.formData.formingNum,
-          planStartTime: '',
-          classeId: '',
+          joinPlanCode: this.formData.code,
+          requiredFormingNum: this.formData.requiredFormingNum,
+          reqMoldTime: '',
           isCopy: 1
         });
       },
 
       openUnpack() {
         this.form.unpackList.push({
-          originalCode: this.formData.code,
-          formingNum: '',
-          planStartTime: '',
-          classeId: ''
+          joinPlanCode: this.formData.code,
+          requiredFormingNum: '',
+          reqMoldTime: '',
         });
       },
 
       changeNum(index) {
-        let num = this.formData.formingNum;
+        let num = this.formData.requiredFormingNum;
         this.form.unpackList.forEach((e) => {
-          if (e.formingNum != null && e.formingNum != undefined) {
-            num = num - Number(e.formingNum);
+          if (e.requiredFormingNum != null && e.requiredFormingNum != undefined) {
+            num = num - Number(e.requiredFormingNum);
             if (num >= 0) {
-              this.formingNum = num;
+              this.requiredFormingNum = num;
             } else {
               this.$nextTick(() => {
-                this.$set(this.form.unpackList[index], 'formingNum', 0);
+                this.$set(this.form.unpackList[index], 'requiredFormingNum', 0);
               });
               this.$message.error('拆单数超过生产数量');
 
@@ -316,7 +312,7 @@
       remove(index) {
         this.form.unpackList.splice(index, 1);
         if (this.form.unpackList.length == 0) {
-          this.formingNum = this.formData.formingNum;
+          this.requiredFormingNum = this.formData.requiredFormingNum;
         } else {
           this.changeNum(index);
         }
@@ -333,7 +329,7 @@
           if (value) {
             if (
               this.form.unpackList.length == 1 &&
-              this.form.unpackList[0].formingNum == this.formData.formingNum
+              this.form.unpackList[0].requiredFormingNum == this.formData.requiredFormingNum
             ) {
               this.$message.info('拆单数要大于1');
               return false;
@@ -348,19 +344,20 @@
             }
 
             let params = [];
-            if (this.formingNum != 0) {
-              this.form.surplusUnpack[0].formingNum = this.formingNum;
+            if (this.requiredFormingNum != 0) {
+              this.form.surplusUnpack[0].requiredFormingNum = this.requiredFormingNum;
               params = [...this.form.unpackList, ...this.form.surplusUnpack];
             } else {
               params = this.form.unpackList;
             }
 
-            // const res = await splitWork(params);
-            // if (res) {
-            //   this.$message.success('拆分成功!');
-            //   this.$emit('success');
-            //   this.cancel();
-            // }
+            const res = await splitWork(params);
+            console.log(res, 55);
+            if (res) {
+              this.$message.success('拆分成功!');
+              this.$emit('success');
+              this.cancel();
+            }
           }
         });
       }

+ 216 - 188
src/views/productionPlan/index.vue

@@ -9,6 +9,7 @@
         :activeName="activeName"
       >
       </productionPlan-search>
+
       <el-tabs v-model="activeName" type="card">
         <el-tab-pane label="未发布" name="first"></el-tab-pane>
         <el-tab-pane label="已发布" name="second"></el-tab-pane>
@@ -22,12 +23,20 @@
         :columns="newColumns"
         :datasource="datasource"
         height="calc(100vh - 335px)"
+        row-key="code"
+        :selection.sync="selection"
         :cache-key="`${activeName}ProductionPlanTable`"
         @sort-change="onSortChange"
       >
+        <template v-slot:toolbar>
+          <el-button type="primary" size="mini" @click="handleMerge">合并计划</el-button>
+        </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>
 
@@ -97,18 +106,19 @@
           </el-link>
 
           <el-link
-              type="primary"
-              :underline="false"
-             @click="toUnpack(row)"
-            >
-              拆批
-            </el-link>
+            v-if="clientEnvironmentId != 4 && activeName == 'first'"
+            type="primary"
+            :underline="false"
+            @click="toUnpack(row)"
+          >
+            拆批
+          </el-link>
 
           <el-link
             type="danger"
             :underline="false"
             @click="handleDelete(row)"
-           icon="el-icon-delete"
+            icon="el-icon-delete"
           >
             删除
           </el-link>
@@ -117,149 +127,160 @@
     </el-card>
 
     <unpackDialog ref="unpackRef" @success="reload" />
-
   </div>
 </template>
 
 <script>
-import { getList, del, updatePriority } from '@/api/productionPlan/index.js';
-import productionPlanSearch from './components/productionPlan-search.vue';
-import unpackDialog from './components/unpackDialog.vue';
-import { release } from '@/api/productionPlan/order.js';
-
-import { getCode } from '@/api/codeManagement';
-
-import { fieldModel } from '@/api/saleOrder';
-
-import { debounce } from 'lodash';
-export default {
-  components: {
-    productionPlanSearch,
-    unpackDialog
-  },
-  data() {
-    return {
-      activeName: 'first',
-
-      // 加载状态
-      loading: false,
-      pageType: 'add',
-      dialogTitle: '',
-      isBindPlan: false,
-      statusOpt: {
-        first: [
-          { label: '所有状态', value: '3,2' },
-          { label: '待发布', value: '2' },
-          { label: '发布失败', value: '3' }
-        ],
-        second: [
-          { label: '所有状态', value: '7,4,5,6' },
-          { label: '待生产', value: '4' },
-          { label: '生产中', value: '5' },
-          { label: '已完成', value: '6' },
-          { label: '已延期', value: '7' }
-        ], change: [
-          { label: '已变更', value: '9' },
-     
-        ]
-      },
-      planType: [
-        { label: '所有计划类型', value: null },
-        { label: '内销计划', value: '1' },
-        { label: '外销计划', value: '2' },
-        { label: '预制计划', value: '3' }
-      ],   newColumns: []
-    };
-  },
-  computed: {
-    clientEnvironmentId() {
-      return this.$store.state.user.info.clientEnvironmentId;
+  import { getList, del, updatePriority } from '@/api/productionPlan/index.js';
+  import productionPlanSearch from './components/productionPlan-search.vue';
+  import unpackDialog from './components/unpackDialog.vue';
+  import { release } from '@/api/productionPlan/order.js';
+
+  import { getCode } from '@/api/codeManagement';
+
+  import { fieldModel } from '@/api/saleOrder';
+
+  import { debounce } from 'lodash';
+  export default {
+    components: {
+      productionPlanSearch,
+      unpackDialog
     },
-    // 表格列配置
-    columns() {
-      const opt = {
-        first: [
-          // {
-          //   prop: 'deliveryTime',
-          //   label: '预测交货日期',
-          //   align: 'center',
-          //   showOverflowTooltip: true,
-          //   minWidth: 110
-          // }
+    data() {
+      return {
+        activeName: 'first',
+
+        // 加载状态
+        loading: false,
+        pageType: 'add',
+        dialogTitle: '',
+        isBindPlan: false,
+        statusOpt: {
+          first: [
+            { label: '所有状态', value: '3,2' },
+            { label: '待发布', value: '2' },
+            { label: '发布失败', value: '3' }
+          ],
+          second: [
+            { label: '所有状态', value: '7,4,5,6' },
+            { label: '待生产', value: '4' },
+            { label: '生产中', value: '5' },
+            { label: '已完成', value: '6' },
+            { label: '已延期', value: '7' }
+          ],
+          change: [{ label: '已变更', value: '9' }]
+        },
+        planType: [
+          { label: '所有计划类型', value: null },
+          { label: '内销计划', value: '1' },
+          { label: '外销计划', value: '2' },
+          { label: '预制计划', value: '3' }
         ],
-        second: [
-          // {
-          //   prop: 'formingTime',
-          //   label: '实际生产日期',
-          //   align: 'center',
-          //   showOverflowTooltip: true,
-          //   minWidth: 110
-          // },
+        newColumns: [],
+
+        selection: []
+      };
+    },
+    computed: {
+      clientEnvironmentId() {
+        return this.$store.state.user.info.clientEnvironmentId;
+      },
+      // 表格列配置
+      columns() {
+        const opt = {
+          first: [
+            // {
+            //   prop: 'deliveryTime',
+            //   label: '预测交货日期',
+            //   align: 'center',
+            //   showOverflowTooltip: true,
+            //   minWidth: 110
+            // }
+          ],
+          second: [
+            // {
+            //   prop: 'formingTime',
+            //   label: '实际生产日期',
+            //   align: 'center',
+            //   showOverflowTooltip: true,
+            //   minWidth: 110
+            // },
+            {
+              prop: 'releaseTime',
+              label: '工单发布日期',
+              align: 'center',
+              showOverflowTooltip: true,
+              minWidth: 110
+            },
+            {
+              prop: 'planFormingTime',
+              label: '预测生产日期',
+              align: 'center',
+              showOverflowTooltip: true,
+              minWidth: 110
+            },
+            {
+              prop: 'deliveryTime',
+              label: '预测交货日期',
+              align: 'center',
+              showOverflowTooltip: true,
+              minWidth: 110
+            },
+            {
+              prop: 'formingTime',
+              label: '实际交货日期',
+              align: 'center',
+              showOverflowTooltip: true,
+              minWidth: 110
+            }
+          ],
+          change: []
+        };
+
+        return [
           {
-            prop: 'releaseTime',
-            label: '工单发布日期',
+            width: 45,
+            type: 'selection',
+            columnKey: 'selection',
+            align: 'center',
+            selectable: (row, index) => {
+              return this.activeName == 'first' && row.splitBatch != 2  && !row.joinPlanCode;
+            },
+            reserveSelection: true,
+            fixed: 'left'
+          },
+          {
+            columnKey: 'index',
+            label: '序号',
+            type: 'index',
+            width: 55,
             align: 'center',
             showOverflowTooltip: true,
-            minWidth: 110
+
           },
           {
-            prop: 'planFormingTime',
-            label: '预测生产日期',
+            slot: 'code',
+            prop: 'code',
+            action: 'code',
+            label: '计划编号',
             align: 'center',
             showOverflowTooltip: true,
-            minWidth: 110
+            minWidth: 200
           },
           {
-            prop: 'deliveryTime',
-            label: '预测交货日期',
+            prop: 'productCode',
+            label: '产品编码',
             align: 'center',
             showOverflowTooltip: true,
-            minWidth: 110
+            minWidth: 140
           },
           {
-            prop: 'formingTime',
-            label: '实际交货日期',
+            prop: 'productName',
+            label: '产品名称',
             align: 'center',
             showOverflowTooltip: true,
-            minWidth: 110
-          }
-        ],
-        change:[]
-      };
-
-      return [
-        {
-          columnKey: 'index',
-          label: '序号',
-          type: 'index',
-          width: 55,
-          align: 'center',
-          showOverflowTooltip: true,
-          fixed: 'left'
-        },
-        {
-          slot: 'code',
-          prop: 'code',
-          action: 'code',
-          label: '计划编号',
-          align: 'center',
-          showOverflowTooltip: true,
-          minWidth: 180
-        },
-        {
-          prop: 'productCode',
-          label: '产品编码',
-          align: 'center',
-          showOverflowTooltip: true,
-          minWidth: 140
-        },
-        {
-          prop: 'productName',
-          label: '产品名称',
-          align: 'center',
-          showOverflowTooltip: true,
-          minWidth: 140
-        },
+            minWidth: 140
+          },
 
           {
             prop: 'brandNo',
@@ -363,65 +384,66 @@ export default {
             minWidth: 110
           },
 
-        ...opt[this.activeName],
+          ...opt[this.activeName],
 
-        {
-          prop: 'orderType',
-          label: '计划类型',
-          align: 'center',
-          showOverflowTooltip: true,
-          formatter: (row) => {
-            const obj = this.planType.find((i) => i.value == row.planType);
-            return obj && obj.label;
-          }
-        },{
-          prop: 'version',
-          label: '版本',
-          align: 'center',
-          showOverflowTooltip: true,
-          minWidth: 80
-        },
-        {
-          prop: 'createTime',
-          label: '创建时间',
-          align: 'center',
-          showOverflowTooltip: true,
-          minWidth: 110
-        },
-        {
-          columnKey: 'status',
-          slot: 'status',
-          label: '状态',
-          align: 'center',
-          formatter: (row) => {
-            const obj = this.statusOpt[this.activeName].find(
-              (i) => i.value == row.status
-            );
-            return obj && obj.label;
+          {
+            prop: 'orderType',
+            label: '计划类型',
+            align: 'center',
+            showOverflowTooltip: true,
+            formatter: (row) => {
+              const obj = this.planType.find((i) => i.value == row.planType);
+              return obj && obj.label;
+            }
+          },
+          {
+            prop: 'version',
+            label: '版本',
+            align: 'center',
+            showOverflowTooltip: true,
+            minWidth: 80
+          },
+          {
+            prop: 'createTime',
+            label: '创建时间',
+            align: 'center',
+            showOverflowTooltip: true,
+            minWidth: 110
+          },
+          {
+            columnKey: 'status',
+            slot: 'status',
+            label: '状态',
+            align: 'center',
+            formatter: (row) => {
+              const obj = this.statusOpt[this.activeName].find(
+                (i) => i.value == row.status
+              );
+              return obj && obj.label;
+            }
           }
-        },
-        // ...(this.activeName === 'second'
-        //   ? [
-        //       {
-        //         prop: 'releaseTime',
-        //         label: '发布时间',
-        //         align: 'center',
-        //         showOverflowTooltip: true,
-        //         minWidth: 110
-        //       }
-        //     ]
-        //   : []),
-      ];
-    }
-  },
-  created() {
+          // ...(this.activeName === 'second'
+          //   ? [
+          //       {
+          //         prop: 'releaseTime',
+          //         label: '发布时间',
+          //         align: 'center',
+          //         showOverflowTooltip: true,
+          //         minWidth: 110
+          //       }
+          //     ]
+          //   : []),
+        ];
+      }
+    },
+    created() {
       this.getFieldModel();
     },
-  methods: {
-    statusFormatter(status) {
-      const obj = this.statusOpt[this.activeName].find(
-        (i) => i.value == status
-      );
+    methods: {
+      statusFormatter(status) {
+        const obj = this.statusOpt[this.activeName].find(
+          (i) => i.value == status
+        );
 
         return obj && obj.label;
       },
@@ -499,7 +521,7 @@ export default {
               align: 'center',
               resizable: false,
               fixed: 'right',
-              slot: 'action',
+              slot: 'action'
             });
           } else {
             privateColumn = [];
@@ -537,11 +559,17 @@ export default {
         });
       },
 
-            // 拆批
-            toUnpack(row) {
+      // 拆批
+      toUnpack(row) {
+        if(!row.batchNo) {
+          return this.$message.error('请先填写批次号!')
+        }
         this.$refs.unpackRef.open(row);
       },
-
+      // 合并
+      handleMerge() {
+       console.log( this.selection)
+      },
 
       handleDelete({ id }) {
         this.$confirm('确定删除当前数据?', '提示')