Просмотр исходного кода

Merge branch 'dev' of http://110.41.163.243:9980/kd-aiot/kd-aiot-frontend-aps into dev

yusheng 9 месяцев назад
Родитель
Сommit
0ee9d70447

+ 12 - 0
src/api/materialPlan/index.js

@@ -32,6 +32,18 @@ export async function saveAndSubmit(data) {
   return Promise.reject(new Error(res.data.message));
 }
 
+
+/**
+ * 保存并发布
+ */
+export async function submitAndPublish(data) {
+  const res = await request.post('/aps/batchingplan/submitAndPublish', data);
+  if (res.data.code == 0) {
+    return res.data.data;
+  }
+  return Promise.reject(new Error(res.data.message));
+}
+
 /**
  * 修改
  */

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

@@ -345,3 +345,13 @@ export async function getUpdateInfoByCode(code) {
   return Promise.reject(new Error(res.data.message));
 }
 
+/**
+ * 企业信息
+ */
+export async function enterprisePage(params) {
+  const res = await request.get(`/main/enterprise/page`, { params });
+  if (res.data.code == 0) {
+    return res.data.data;
+  }
+  return Promise.reject(new Error(res.data.message));
+}

+ 13 - 8
src/api/workOrder/index.js

@@ -15,37 +15,33 @@ export async function getList(params) {
 
 // 下达
 export async function releaseWorkOrder(data) {
-  const res = await request.post(
-    `/aps/workorder/releaseWorkOrder`, data
-  );
+  const res = await request.post(`/aps/workorder/releaseWorkOrder`, data);
   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/workorder/updatePriority`,  data);
+  const res = await request.post(`/aps/workorder/updatePriority`, data);
   if (res.data.code == 0) {
     return res.data.data;
   }
   return Promise.reject(new Error(res.data.message));
 }
 
-
 // 订单拆单
 
 export async function splitBatch(data) {
-  const res = await request.post(`/aps/workorder/splitBatch`,  data);
+  const res = await request.post(`/aps/workorder/splitBatch`, data);
   if (res.data.code == 0) {
     return res.data.data;
   }
   return Promise.reject(new Error(res.data.message));
 }
 
-// 删除拆单数据 
+// 删除拆单数据
 export async function unpackDel(id) {
   const res = await request.delete(`/aps/workorder/delById/${id}`);
   if (res.data.code == 0) {
@@ -53,3 +49,12 @@ export async function unpackDel(id) {
   }
   return Promise.reject(new Error(res.data.message));
 }
+
+//获取用户的工厂,所属工作中中心,班组等信息
+export async function getUserInfo(id) {
+  const res = await request.get(`/main/user/getUserWindow/${id}`);
+  if (res.data.code == 0) {
+    return res.data.data;
+  }
+  return Promise.reject(new Error(res.data.message));
+}

+ 27 - 3
src/views/materialPlan/components/plan-edit-dialog.vue

@@ -349,8 +349,26 @@
 
     <div slot="footer" v-if="type != 'detail'">
       <el-button @click="cancel">取消</el-button>
-      <el-button type="primary" @click="confirm('save')">保存</el-button>
-      <el-button type="primary" @click="confirm('submit')">提交</el-button>
+      <el-button
+        v-if="$hasPermission('aps:batchingplan:save')"
+        type="primary"
+        @click="confirm('save')"
+        >保存</el-button
+      >
+
+      <el-button
+        v-if="$hasPermission('aps:batchingplan:saveAndSubmit')"
+        type="primary"
+        @click="confirm('submit')"
+        >提交</el-button
+      >
+      <el-button
+        v-if="$hasPermission('aps:batchingplan:submitAndPublish')"
+        type="primary"
+        @click="confirm('publish')"
+      >
+        提交并发布
+      </el-button>
     </div>
 
     <saleOrderPop ref="saleOrderRef" @chooseOrder="chooseOrder"></saleOrderPop>
@@ -429,6 +447,7 @@
     listBomBySalesOrderId,
     save,
     saveAndSubmit,
+    submitAndPublish,
     getById,
     contactList
   } from '@/api/materialPlan/index';
@@ -1009,7 +1028,9 @@
         console.log(row, 'row 1');
         data.forEach((e) => {
           if (row.detailId == e.id) {
-            e.materialList = e.materialList.filter((d) => d.categoryId !== row.categoryId);
+            e.materialList = e.materialList.filter(
+              (d) => d.categoryId !== row.categoryId
+            );
             // e.materialList.splice(idx, 1);
           }
         });
@@ -1235,6 +1256,9 @@
             if (type == 'submit') {
               await saveAndSubmit(this.formData);
               this.$message.success('保存并提交成功!');
+            } else if (type == 'publish') {
+              await submitAndPublish(this.formData);
+              this.$message.success('保存并发布成功!');
             } else {
               await save(this.formData);
               this.$message.success('保存成功!');

+ 36 - 5
src/views/materialPlan/components/producePlan.vue

@@ -394,7 +394,25 @@
 
     <div slot="footer" v-if="type != 'detail'">
       <el-button @click="cancel">取消</el-button>
-      <el-button type="primary" @click="confirm">保存</el-button>
+      <el-button
+        v-if="$hasPermission('aps:batchingplan:save')"
+        type="primary"
+        @click="confirm('save')"
+        >保存</el-button
+      >
+      <el-button
+        v-if="$hasPermission('aps:batchingplan:saveAndSubmit')"
+        type="primary"
+        @click="confirm('submit')"
+        >提交</el-button
+      >
+      <el-button
+        v-if="$hasPermission('aps:batchingplan:submitAndPublish')"
+        type="primary"
+        @click="confirm('publish')"
+      >
+        提交并发布
+      </el-button>
     </div>
 
     <produceOrder
@@ -475,6 +493,8 @@
     listBomBySalesOrderId,
     listBomByBomVersionId,
     save,
+    saveAndSubmit,
+    submitAndPublish,
     getById,
     contactList
   } from '@/api/materialPlan/index';
@@ -948,7 +968,7 @@
         this.$refs.produceOrderRef.open(this.tableData);
       },
       async chooseOrder(list) {
-        console.log(list, 'list222');
+        console.log('所选生产计划列表', list);
         let planIds = [];
         const tableList = this.$refs.table.getData() || [];
         const existingIds = tableList.map((item) => item.id);
@@ -1101,6 +1121,7 @@
         this.$refs.versionRefs.open();
       },
       changeProduct(data) {
+        console.log('data xsid', data, this.xsId);
         let param = {
           planIds: [this.xsId],
           produceRoutingId: data.id
@@ -1237,7 +1258,7 @@
         this.$refs.table.setData([...tableData]);
         this.batchVisible = false;
       },
-      confirm() {
+      confirm(type) {
         this.$refs.formRef.validate(async (value) => {
           if (value) {
             let _arr = this.$refs.table.getData() ?? [];
@@ -1246,6 +1267,7 @@
               this.$message.info('请添加生产计划');
               return false;
             }
+
             let _arr2 = [];
 
             _arr2 = _arr.map((m) => {
@@ -1269,8 +1291,17 @@
             this.formData['salesOrderList'] = _arr2;
             this.formData.baitingType = 2;
 
-            await save(this.formData);
-            this.$message.success('保存成功!');
+            if (type == 'submit') {
+              await saveAndSubmit(this.formData);
+              this.$message.success('保存并提交成功!');
+            } else if (type == 'publish') {
+              await submitAndPublish(this.formData);
+              this.$message.success('提交并发布成功!');
+            } else {
+              await save(this.formData);
+              this.$message.success('保存成功!');
+            }
+
             this.$emit('success');
             this.cancel();
           }

+ 9 - 2
src/views/materialPlan/index.vue

@@ -99,16 +99,23 @@
             :underline="false"
             icon="el-icon-edit"
             @click="handleEdit('edit', row)"
-            v-if="row.approvalStatus != 2 && row.approvalStatus != 1"
+            v-if="
+              row.approvalStatus != 2 &&
+              row.approvalStatus != 1 &&
+              $hasPermission('aps:batchingplan:update')
+            "
           >
             修改
           </el-link>
           <el-link
+            v-if="
+              $hasPermission('aps:batchingplan:delete') &&
+              (row.approvalStatus == 0 || row.approvalStatus == 3)
+            "
             @click="handleDel(row)"
             type="danger"
             :underline="false"
             icon="el-icon-delete"
-            v-if="row.approvalStatus == 0 || row.approvalStatus == 3"
           >
             删除
           </el-link>

+ 43 - 5
src/views/productionPlan/components/factoryAdd/index.vue

@@ -118,6 +118,7 @@
                 style="width: 100%"
                 size="mini"
                 v-model="form.reqMoldTime"
+                @change="handleCompleteChange(form)"
                 type="datetime"
                 placeholder="选择日期"
                 value-format="yyyy-MM-dd HH:mm:ss"
@@ -1634,15 +1635,52 @@
         // 校验 是否 大于结束时间  wda
         this.checkEndTimeValid(row);
       },
+
+      handleCompleteChange(row) {
+        const { reqMoldTime } = row;
+
+        if (!row.startTime) {
+          row.reqMoldTime = '';
+          return this.$message.warning('请选择计划开始时间');
+        }
+
+        this.handleComplete(reqMoldTime, row);
+      },
+
+      handleComplete(reqMoldTime, row) {
+        const startTime = new Date(row.startTime).getTime();
+        const completeTime = new Date(reqMoldTime).getTime();
+
+        if (completeTime < startTime) {
+          row.reqMoldTime = ''; // 修正为开始时间
+          return this.$message.warning(
+            '要求完成时间不能早于计划开始时间, 请重新选择要求完成时间'
+          );
+        }
+      },
+
       // 时间校验
       checkEndTimeValid(row) {
         const { startTime: start, endTime: end } = row;
-        // if (!start || !end) return; // 开始/结束时间未填,跳过
-        const startTime = new Date(start); // 开始时间
-        const endTime = new Date(end); // 结束时间
+        this.handleChange(start, end, row);
+        // // if (!start || !end) return; // 开始/结束时间未填,跳过
+        // const startTime = new Date(start); // 开始时间
+        // const endTime = new Date(end); // 结束时间
+        // if (endTime < startTime) {
+        //   row.endTime = new Date(startTime); // 修正为开始时间
+        //   this.$message.info('结束时间不能早于开始时间,已自动设为开始时间');
+        // }
+      },
+
+      handleChange(start, end, row) {
+        const startTime = new Date(start).getTime();
+        const endTime = new Date(end).getTime();
+
         if (endTime < startTime) {
-          row.endTime = new Date(startTime); // 修正为开始时间
-          this.$message.info('结束时间不能早于开始时间,已自动设为开始时间');
+          row.endTime = ''; // 修正为开始时间
+          return this.$message.warning(
+            '计划结束时间不能早于计划开始时间,请重新选择计划结束时间'
+          );
         }
       }
     }

+ 19 - 1
src/views/saleOrder/components/order-search.vue

@@ -416,6 +416,14 @@
               v-if="activeName == 'first' && clientEnvironmentId == 2"
               >同步数据</el-button
             >
+            <el-button
+              v-if="$hasPermission('aps:salesorder:export')"
+              :disabled="selection.length < 1"
+              type="primary"
+              size="mini"
+              @click="handlePrint"
+              >打印</el-button
+            >
           </div>
         </el-form-item>
       </el-col>
@@ -427,6 +435,8 @@
     <create-order ref="createDialog" @refresh="search"> </create-order>
     <!-- 订单组合 -->
     <group-order ref="groupDialog"> </group-order>
+
+    <printTemplateSaleOrder :groupName="groupName" ref="printTemplateSaleOrderRef"></printTemplateSaleOrder>
   </el-form>
 </template>
 
@@ -445,6 +455,7 @@
     deleteOrder,
     synchronousDataByJDY
   } from '@/api/saleOrder';
+  import printTemplateSaleOrder from './printTemplateSaleOrder.vue';
   export default {
     props: {
       selection: Array,
@@ -453,7 +464,8 @@
     components: {
       ImportException,
       CreateOrder,
-      GroupOrder
+      GroupOrder,
+      printTemplateSaleOrder
     },
     data() {
       // 默认表单数据
@@ -796,6 +808,12 @@
       homogeneityInspect(val) {
         console.log(val, 'val');
         this.$emit('check', val);
+      },
+      handlePrint() {
+        console.log(this.selection[0]);
+        if (this.selection.length > 1)
+          return this.$message.warning('请选择一条');
+        this.$refs.printTemplateSaleOrderRef.open(this.selection[0]);
       }
     }
   };

+ 195 - 0
src/views/saleOrder/components/printTemplateSaleOrder.vue

@@ -0,0 +1,195 @@
+<template>
+  <ele-modal
+    title="销售订单"
+    :visible.sync="QRvisible"
+    v-if="QRvisible"
+    width="90%"
+  >
+    <div
+      id="printSection"
+      style="
+        display: flex;
+        align-items: center;
+        justify-content: center;
+        flex-direction: column;
+      "
+    >
+      <div>
+        <div
+          style="
+            font-size: 20px;
+            font-weight: 800;
+            padding-right: 20px;
+            width: 400px;
+            margin: 0 auto;
+          "
+          >{{ groupName }}销售订单</div
+        >
+      </div>
+      <div
+        style="
+          width: 100%;
+          font-size: 12px;
+          display: flex;
+          justify-content: space-between;
+          margin-bottom: 10px;
+        "
+      >
+        <span style="width: 25%">单据日期:{{ row.createTime }}</span>
+        <span style="width: 50%">客户简称:{{ formData.customerName }}</span>
+        <span style="width: 50%">客户经理:{{ formData.salesman }}</span>
+      </div>
+      <div
+        style="
+          width: 100%;
+          font-size: 12px;
+          display: flex;
+          justify-content: space-between;
+          margin-bottom: 10px;
+        "
+      >
+        <span style="width: 45%">交货日期:{{ formData.deliveryTime }}</span>
+        <span style="width: 45%">单据编码:{{ formData.code }}</span>
+      </div>
+      <table
+        cellspacing="0"
+        border
+        style="
+          width: 100%;
+          table-layout: fixed;
+          word-break: break-all;
+          word-wrap: break-word;
+          font-size: 12px;
+        "
+      >
+        <tbody>
+          <tr align="center">
+            <td style="padding: 5px"> 存货名称 </td>
+            <td style="padding: 5px"> 规格型号 </td>
+            <td style="padding: 5px"> 型号 </td>
+            <td style="padding: 5px"> 颜色 </td>
+            <td style="padding: 5px; width: 60px"> 单位</td>
+            <td style="padding: 5px; width: 110px"> 数量</td>
+            <!-- <td style="padding: 5px; width: 110px"> 盘具</td>
+            <td style="padding: 5px; width: 110px"> 分段</td> -->
+            <td style="padding: 5px"> 备注</td>
+          </tr>
+
+          <tr align="center" v-for="(item, index) in formData.productInfoList">
+            <td style="padding: 5px"> {{ item.productName }} </td>
+            <td style="padding: 5px">
+              {{ item.specification }}
+            </td>
+            <td style="padding: 5px"> {{ item.model }}</td>
+            <td style="padding: 5px"> {{ item.colorKey.join(',') }}</td>
+            <td style="padding: 5px"> {{ item.measuringUnit }}</td>
+            <td style="padding: 5px"> {{ item.contractNum }}</td>
+            <!-- <td style="padding: 5px"> {{ item.totalCount }}</td>
+            <td style="padding: 5px"> {{ item.totalCount }}</td> -->
+            <td style="padding: 5px"> {{ item.remark }}</td>
+          </tr>
+        </tbody>
+      </table>
+      <div
+        style="
+          width: 100%;
+          font-size: 12px;
+          display: flex;
+          justify-content: space-between;
+          margin-top: 10px;
+        "
+      >
+        <div style="flex: 1">
+          <div>制单人:{{ detail.salesOrderBasicInfo.createUserName }}</div>
+        </div>
+        <div style="flex: 1">
+          <div>审核人:{{ formData.createUserName }}</div>
+        </div>
+      </div>
+    </div>
+
+    <div slot="footer">
+      <el-button @click="print">打印预览</el-button>
+      <el-button @click="close">关闭</el-button>
+    </div>
+  </ele-modal>
+</template>
+
+<script>
+  import { getOrderDetail, getSalesDetail, enterprisePage } from '@/api/saleOrder';
+  import { mapGetters } from 'vuex';
+  export default {
+    name: 'print',
+    computed: {
+      ...mapGetters(['user'])
+    },
+    props: {
+      
+    },
+    data() {
+      return {
+        checked: '',
+        QRvisible: false,
+        isPrintPrice: false,
+        formData: {},
+        row: {},
+        detail: {},
+        groupName: ''
+      };
+    },
+    methods: {
+      async open(row) {
+        this.row = row;
+        enterprisePage({
+        pageNum: 1,
+        size: 200
+      }).then((res) => {
+        if (res.list?.length > 0) {
+          this.groupName = res.list[0].name;
+        }
+      });
+        this.formData = await getOrderDetail(row.code);
+        this.detail = await getSalesDetail(row.id);
+        console.log('formData~~~', this.formData, this.detail);
+        this.QRvisible = true;
+
+        //包装维度
+      },
+      close() {
+        this.QRvisible = false;
+      },
+      getTotalValue(key, num) {
+        let val = this.formData?.productList?.reduce((total, item) => {
+          return (total += Number(item[key]));
+        }, 0);
+
+        return (
+          (val &&
+            parseFloat(val)
+              .toFixed(num)
+              .replace(/\.?0+$/, '')) ||
+          0
+        );
+      },
+      print() {
+        const printSection = document.getElementById('printSection');
+        // 创建打印任务
+        const printWindow = window.open('', '_blank');
+        printWindow.document.open();
+        printWindow.document.write('<html><head><title>打印预览</title>');
+        printWindow.document.write(
+          '<link rel="stylesheet" href="your-stylesheet-url.css" type="text/css" />'
+        );
+        printWindow.document.write('</head><body>');
+        printWindow.document.write(printSection.innerHTML);
+        printWindow.document.write('</body></html>');
+        printWindow.document.close();
+        printWindow.onload = function () {
+          printWindow.print();
+        };
+      }
+    }
+  };
+</script>
+
+<style lang="scss"></style>

+ 76 - 3
src/views/workOrder/components/unpackDialog.vue

@@ -431,13 +431,86 @@
 
       checkEndTimeValid(row) {
         const { planStartTime: start, planCompleteTime: end } = row;
+        // console.log(start, end, '时间1111');
         if (!start || !end) return; // 开始/结束时间未填,跳过
-        const startTime = new Date(start);
-        const endTime = new Date(end);
+        this.handleChange(start, end, row);
+        // const startTime = new Date(start);
+        // const endTime = new Date(end);
+        // if (endTime < startTime) {
+        //   row.planCompleteTime = new Date(startTime); // 修正为开始时间
+        //   this.$message.info('结束时间不能早于开始时间,已自动设为开始时间');
+        // }
+      },
+
+      handleChange(start, end, row) {
+        const startTime = new Date(start).getTime();
+        const endTime = new Date(end).getTime();
+        const planStartTime = new Date(this.formData.planStartTime).getTime();
+        const planEndTime = new Date(this.formData.planCompleteTime).getTime();
+
+        console.log(startTime, endTime, '1231');
+
         if (endTime < startTime) {
           row.planCompleteTime = new Date(startTime); // 修正为开始时间
-          this.$message.info('结束时间不能早于开始时间,已自动设为开始时间');
+          return this.$message.info(
+            '结束时间不能早于开始时间,已自动设为开始时间'
+          );
         }
+
+        if (planStartTime > startTime) {
+          this.$confirm('所选的开始时间小于计划开始时间, 是否继续?', '提示', {
+            confirmButtonText: '确定',
+            cancelButtonText: '取消',
+            type: 'warning'
+          })
+            .then(() => {
+              // this.$message({
+              //   type: 'success',
+              //   message: '删除成功!'
+              // });
+            })
+            .catch(() => {
+              row.planStartTime = this.formData.planStartTime;
+              // this.form.unpackList[index].reqMoldTime =
+              //   this.formData.reqMoldTime;
+              // this.$message({
+              //   type: 'info',
+              //   message: '已取消删除'
+              // });
+            });
+        }
+
+        if (endTime > planEndTime) {
+          this.$confirm('所选的结束时间大于计划完成时间, 是否继续?', '提示', {
+            confirmButtonText: '确定',
+            cancelButtonText: '取消',
+            type: 'warning'
+          })
+            .then(() => {
+              // this.$message({
+              //   type: 'success',
+              //   message: '删除成功!'
+              // });
+            })
+            .catch(() => {
+              row.planCompleteTime = this.formData.planCompleteTime;
+              // row.planStartTime = this.formData.planStartTime;
+              // this.form.unpackList[index].reqMoldTime =
+              //   this.formData.reqMoldTime;
+              // this.$message({
+              //   type: 'info',
+              //   message: '已取消删除'
+              // });
+            });
+        }
+
+        // if (startTime > base) {
+        //   this.compareResult = '选择的时间比默认值晚';
+        // } else if (startTime < base) {
+        //   this.compareResult = '选择的时间比默认值早';
+        // } else {
+        //   this.compareResult = '选择的时间等于默认值';
+        // }
       },
 
       // 【开始时间变化时】触发

+ 2 - 2
vue.config.js

@@ -35,12 +35,12 @@ module.exports = {
         // target: 'http://192.168.1.103:18086',
         // target: 'http://192.168.1.158:18086',
         // target: 'http://192.168.158:18086',
-        target: 'http://192.168.1.251:18086',
+        // target: 'http://192.168.1.251:18086',
         // target: 'http://192.168.1.144:18086',
         // target: 'http://192.168.1.211:18086',
         // target: 'http://192.168.1.251:18186',
 
-        // target: 'http://192.168.1.125:18086',
+        target: 'http://192.168.1.125:18086',
 
         // target: 'http://192.168.1.116:18086',