quwangxin 2 years ago
parent
commit
d217106678

+ 22 - 16
src/api/saleOrder/index.js

@@ -2,7 +2,7 @@ import request from '@/utils/request';
 import store from '@/store';
 import Vue from 'vue';
 // 批量导入文件
-export async function importFile (data) {
+export async function importFile(data) {
   const res = await request.post('/aps/salesorder/importFile', data);
   if (res.data.code == 0) {
     return res.data.data;
@@ -11,7 +11,7 @@ export async function importFile (data) {
 }
 
 // 获取销售订单列表
-export async function getPageList (data) {
+export async function getPageList(data) {
   const res = await request.post(`/aps/salesorder/page`, data);
   if (res.data.code == 0) {
     if (data.status.length == 1 && data.status[0] == 1) {
@@ -56,7 +56,7 @@ export async function getPageList (data) {
 }
 
 // 销售订单转生产计划
-export async function productionToPlan (data) {
+export async function productionToPlan(data) {
   const res = await request.post(
     `/aps/salesorder/productionPlanGenerator`,
     data
@@ -78,7 +78,7 @@ export async function productionToPlan (data) {
 // }
 
 // 刷新销售订单
-export async function pullSalesOrder (params) {
+export async function pullSalesOrder(params) {
   const res = await request.get(`/aps/salesorder/pullSalesOrder`);
   if (res.data.code == 0) {
     return res.data.data;
@@ -86,8 +86,16 @@ export async function pullSalesOrder (params) {
   return Promise.reject(new Error(res.data.message));
 }
 
+// 销售订单转生产计划 直接发布
+export async function releaseSave(data) {
+  const res = await request.post(`/aps/productionplan/releaseSave`, data);
+  if (res.data.code == 0) {
+    return res.data.data;
+  }
+  return Promise.reject(new Error(res.data.message));
+}
 // 销售订单转生产计划保存
-export async function saveSaleToPlan (data) {
+export async function saveSaleToPlan(data) {
   const res = await request.post(`/aps/productionplan/save`, data);
   if (res.data.code == 0) {
     return res.data.data;
@@ -95,7 +103,7 @@ export async function saveSaleToPlan (data) {
   return Promise.reject(new Error(res.data.message));
 }
 // 销售订单转生产计划更新
-export async function updateSaleToPlan (data) {
+export async function updateSaleToPlan(data) {
   const res = await request.put(`/aps/productionplan/update`, data);
   if (res.data.code == 0) {
     return res.data.data;
@@ -104,7 +112,7 @@ export async function updateSaleToPlan (data) {
 }
 
 //创建更新销售订单
-export async function createOrUpdate (data) {
+export async function createOrUpdate(data) {
   const res = await request.post(`/aps/salesorder/createOrUpdate`, data);
   if (res.data.code == 0) {
     return res.data.data;
@@ -113,7 +121,7 @@ export async function createOrUpdate (data) {
 }
 
 // 销售订单获取生产版本
-export async function getProductVersion (code) {
+export async function getProductVersion(code) {
   const res = await request.get(
     `/aps/productionplan/getProductVersion/${code}`
   );
@@ -124,10 +132,8 @@ export async function getProductVersion (code) {
 }
 
 // 配料计划获取生产版本
-export async function getPlanProductVersion (code) {
-  const res = await request.get(
-    `/aps/batchingplan/getProductVersion/${code}`
-  );
+export async function getPlanProductVersion(code) {
+  const res = await request.get(`/aps/batchingplan/getProductVersion/${code}`);
   if (res.data.code == 0) {
     return res.data.data || [];
   }
@@ -135,7 +141,7 @@ export async function getPlanProductVersion (code) {
 }
 
 // 获取订单详情
-export async function getOrderDetail (code) {
+export async function getOrderDetail(code) {
   const res = await request.get(`/aps/salesorder/getByCode/${code}`);
   if (res.data.code == 0) {
     return res.data.data;
@@ -143,7 +149,7 @@ export async function getOrderDetail (code) {
   return Promise.reject(new Error(res.data.message));
 }
 // 获取计划详情
-export async function getUpdateInfoById (id) {
+export async function getUpdateInfoById(id) {
   const res = await request.get(`/aps/productionplan/getUpdateInfoById/${id}`);
   if (res.data.code == 0) {
     return res.data.data;
@@ -152,7 +158,7 @@ export async function getUpdateInfoById (id) {
 }
 
 // 删除
-export async function deleteOrder (data) {
+export async function deleteOrder(data) {
   const res = await request.delete('/aps/salesorder/delete', { data });
   if (res.data.code == 0) {
     return res.data.message;
@@ -161,7 +167,7 @@ export async function deleteOrder (data) {
 }
 
 // 获取详情
-export async function getSalesDetail (id) {
+export async function getSalesDetail(id) {
   const res = await request.get(`/aps/salesorder/getSalesOrderById/${id}`);
   if (res.data.code == 0) {
     return res.data.data;

+ 2 - 2
src/views/productionPlan/index.vue

@@ -35,7 +35,7 @@
         </template>
         <!-- 操作列 -->
         <template v-slot:action="{ row }">
-          <el-link
+          <!-- <el-link
             type="primary"
             :underline="false"
             icon="el-icon-truck"
@@ -43,7 +43,7 @@
             @click="handleOrderPublish(1, row)"
           >
             发布工单
-          </el-link>
+          </el-link> -->
           <el-link
             type="primary"
             v-if="row.status == 3"

+ 11 - 9
src/views/saleOrder/components/plan-submit.vue

@@ -64,10 +64,12 @@
     <div slot="footer" class="footer">
       <div>
         <el-button @click="cancel">取消</el-button>
-        <el-button @click="submit(2)" :loading="loading">提交并发布</el-button>
-        <el-button type="primary" @click="submit(1)" :loading="loading"
-          >提交</el-button
+        <el-button @click="submit(2)" type="primary" :loading="loading"
+          >提交并发布</el-button
         >
+        <!-- <el-button type="primary" @click="submit(1)" :loading="loading"
+          >提交</el-button
+        > -->
       </div>
     </div>
   </el-dialog>
@@ -82,7 +84,7 @@
       info: Object,
       type: String
     },
-    data () {
+    data() {
       return {
         visible: false,
         loading: false,
@@ -90,20 +92,20 @@
       };
     },
     computed: {},
-    created () {
+    created() {
       this.requestDict('订单计划类型');
     },
     methods: {
-      open () {
+      open() {
         this.visible = true;
         if (this.type != 'edit') {
           this.getPlanCode();
         }
       },
-      cancel () {
+      cancel() {
         this.visible = false;
       },
-      async getPlanCode () {
+      async getPlanCode() {
         this.loading = true;
         try {
           const code = await getCode('product_code');
@@ -111,7 +113,7 @@
         } catch (err) {}
         this.loading = false;
       },
-      submit (type) {
+      submit(type) {
         this.$emit('publish', type);
         this.visible = false;
       }

+ 79 - 23
src/views/saleOrder/salesToProduction.vue

@@ -318,12 +318,15 @@
     productionToPlan,
     saveSaleToPlan,
     updateSaleToPlan,
+    releaseSave,
     getUpdateInfoById,
     getProductVersion
   } from '@/api/saleOrder';
   import dictMixins from '@/mixins/dictMixins';
   import { deepClone } from '@/utils/index';
   import { getRouteTabKey, removePageTab } from '@/utils/page-tab-util';
+  import { getCode } from '@/api/codeManagement';
+  import { release } from '@/api/productionPlan/order.js';
   import dayjs from 'dayjs';
   export default {
     mixins: [dictMixins],
@@ -334,6 +337,7 @@
     },
     data() {
       return {
+        type: this.$route.query.type,
         form: {
           planType: 1,
           produceVersionId: '',
@@ -362,7 +366,7 @@
       this.requestDict('按单按库');
       this.requestDict('订单类型');
       this.requestDict('交付要求');
-      if (this.$route.query.type == 'edit') {
+      if (this.type == 'edit') {
         this.getPlanInfo(this.$route.query.id);
       } else {
         const list = JSON.parse(this.$route.query.selection);
@@ -551,38 +555,90 @@
         this.$set(this.form, 'sumOrderWeight', productWeight.toFixed(2));
       },
 
-      publishData(type) {
+      async publishData(type) {
         let params = deepClone(this.form);
         params.categoryId = params.salesOrders[0]?.categoryId;
 
-        let request =
-          this.$route.query.type == 'edit' ? updateSaleToPlan : saveSaleToPlan;
-        if (this.$route.query.type != 'edit') {
-          delete params.id;
+        const code = await getCode('product_order_code');
+        const data = {
+          productionPlan: params,
+          workOrder: {
+            productionPlanCode: params.code,
+            code: code,
+            formingNum: params.contractNum,
+            formingWeight: params.sumOrderWeight,
+            produceVersionId: params.produceVersionId,
+            status: 4,
+            model: params.model,
+            brandNo: params.brandNo,
+            categoryId: params.categoryId
+          }
+        };
+        if (this.$route.query.type == 'edit') {
+          data.workOrder.productionPlanId = params.id;
         }
 
         const key = getRouteTabKey();
-        request(params).then((res) => {
-          // reloadPageTab({ fullPath: '/saleOrder' });
-          if (type == 1) {
-            // 提交
+        releaseSave(data)
+          .then(() => {
+            this.$message.success('发布成功!');
             this.$router.push({
               path: '/productionPlan'
             });
-          } else {
-            // 提交并发布
-            this.$router.push({
-              path: '/productionPlan/workOrderPublish',
-              query: {
-                type: 2,
-                id: res
-              }
-            });
-          }
-          setTimeout(() => {
             removePageTab({ key });
-          }, 0);
-        });
+          })
+          .catch(() => {
+            this.$message.error('发布失败,请重新发布!');
+          });
+
+        // let request =
+        //   this.$route.query.type == 'edit' ? updateSaleToPlan : saveSaleToPlan;
+        // if (this.$route.query.type != 'edit') {
+        //   delete params.id;
+        // }
+
+        // request(params)
+        //   .then(async (res) => {
+        //     // reloadPageTab({ fullPath: '/saleOrder' });
+        //     // if (type == 1) {
+        //     //   // 提交
+        //     //   this.$router.push({
+        //     //     path: '/productionPlan'
+        //     //   });
+        //     // } else {
+        //     //   // 提交并发布
+        //     //   this.$router.push({
+        //     //     path: '/productionPlan/workOrderPublish',
+        //     //     query: {
+        //     //       type: 2,
+        //     //       id: res
+        //     //     }
+        //     //   });
+        //     // }
+        //     const code = await getCode('product_order_code');
+        //     const params = [
+        //       {
+        //         productionPlanCode: params.code,
+        //         productionPlanId: res,
+        //         code: code,
+        //         formingNum: this.form.contractNum,
+        //         formingWeight: this.form.sumOrderWeight
+        //       }
+        //     ];
+        //     const data = await release(params);
+        //     if (data) {
+        //       this.$message.success('发布成功!');
+        //     } else {
+        //       this.$message.error('发布失败,请重新发布!');
+        //     }
+        //     this.$router.push({
+        //       path: '/productionPlan'
+        //     });
+        //     removePageTab({ key });
+        //   })
+        //   .catch(() => {
+        //     this.$message.error('发布失败,请重新发布!');
+        //   });
       }
     }
   };

+ 2 - 2
vue.config.js

@@ -31,12 +31,12 @@ module.exports = {
     proxy: {
       // 当我们的本地的请求 有/api的时候,就会代理我们的请求地址向另外一个服务器发出请求
       '/api': {
-        // target: 'http://192.168.3.35:8080', // kang杨威
+        target: 'http://192.168.3.35:8080', // kang杨威
         // target: 'http://192.168.3.38:8080', // 陈潇
         // target: 'http://192.168.3.25:8080', // 黄峥嵘
         // target: 'http://192.168.3.41:8080', // 何江鹏
         // target: 'http://192.168.3.33:8080', // 谢一平
-        target: 'http://192.168.3.51:18086', // 测试环境
+        // target: 'http://192.168.3.51:18086', // 测试环境
 
         changeOrigin: true, // 只有这个值为true的情况下 才表示开启跨域
         pathRewrite: {