Bläddra i källkod

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

lucw 5 dagar sedan
förälder
incheckning
0272ab907f

+ 11 - 0
src/api/purchasingManage/purchaseOrder.js

@@ -42,6 +42,17 @@ export async function getByIdForEdit(id) {
   return Promise.reject(new Error(res.data.message));
 }
 
+/**
+ * 获取复制采购订单信息(已脱敏,用于复制新增)
+ */
+export async function getPurchaseOrderCopyInfo(id) {
+  const res = await request.get(`/eom/purchaseorder/copy/${id}`, {});
+  if (res.data.code == 0) {
+    return res.data.data;
+  }
+  return Promise.reject(new Error(res.data.message));
+}
+
 /**
  * 更新信息
  */

+ 52 - 67
src/views/purchasingManage/purchaseOrder/components/addDialogNew.vue

@@ -18,6 +18,8 @@
       :rules="rules"
       class="el-form-box"
       label-width="120px"
+      v-loading="copyLoading"
+      element-loading-text="正在加载复制数据…"
     >
       <headerTitle title="订单信息"></headerTitle>
       <el-row>
@@ -795,7 +797,8 @@
     getPurchasePlanByContractIdAPI,
     UpdateInformation,
     getSupplierInfo,
-    getByIdForEdit
+    getByIdForEdit,
+    getPurchaseOrderCopyInfo
   } from '@/api/purchasingManage/purchaseOrder';
   import { getplanDetail } from '@/api/purchasingManage/purchasePlanManage';
   import { getpurchaseinquiry } from '@/api/purchasingManage/inquiryManage';
@@ -982,6 +985,8 @@
 
         // 提交状态
         loading: false,
+        // 复制/历史记录取数遮罩:数据回来(含物品清单分批入表)后才撤
+        copyLoading: false,
         // 是否是修改
         isUpdate: false,
         businessId: '',
@@ -1187,70 +1192,23 @@
         this.$refs.orderListDialogRef.open();
       },
       async changeHistoryOrder(item) {
-        console.log('item~~~~', item)
-        const data = await getpurchaseorderDetail(item.id);
-        console.log('data~~~~', data);
-        [
-          'id',
-          'orderId',
-          'createTime',
-          'createUserId',
-          'createUserName',
-          'createDept',
-          'orderNo',
-          'orderStatus',
-          'outboundStatus',
-          'payStatus',
-          'preOrderNo',
-          'progress',
-          'processInstanceId',
-          'orderBomList'
-        ].forEach((key) => {
-          delete data[key];
-          data.productList.forEach((item) => {
-            if (['id', 'createTime', 'createUserId', 'orderId'].includes(key)) {
-              delete item[key];
-            }
-          });
-          data.rawList.forEach((item) => {
-            if (['id', 'createTime', 'createUserId', 'orderId'].includes(key)) {
-              delete item[key];
-            }
-          });
-
-          data.outputList.forEach((item) => {
-            if (['id', 'createTime', 'createUserId', 'orderId'].includes(key)) {
-              delete item[key];
-            }
-          });
-
-          data.receiptPaymentList.forEach((item) => {
-            if (['id', 'createTime', 'createUserId', 'orderId'].includes(key)) {
-              delete item[key];
-            }
-          });
-        });
-
-        this.form = data;
-        if (data) {
-          // data.relationType = +data.relationType;
-          this.$nextTick(() => {
-            this.$store.commit('order/setAllcountAmount', data.totalAmount);
-            this.$refs.inventoryTable &&
-              this.$refs.inventoryTable.putTableValue(data.productList);
-            this.$refs.rawDetailListRef &&
-              this.$refs.rawDetailListRef.putTableValue(data.rawList); //原料
-            this.$refs.outputDetailListRef &&
-              this.$refs.outputDetailListRef.putTableValue(data.outputList); //产成品
-            this.getLinkInfo(data.partaId);
-            
-            this.$refs.paymentCollectionPlanRef && this.$refs.paymentCollectionPlanRef.putTableValue(data);
-            this.getrequireUser(data.requireDeptId);
-            if(data.purchaseDeptId) {
-              this.getPurchaseUser(data.purchaseDeptId);
-            }
-            this.$store.commit('order/setContractId', data.contractId);
-          });
+        this.copyLoading = true;
+        try {
+          const data = await getPurchaseOrderCopyInfo(item.id);
+          this.fillForm(data);
+          await this.waitCopyFillDone();
+        } catch (e) {
+          this.$message.error(e?.message || '历史订单数据加载失败');
+        } finally {
+          this.copyLoading = false;
+        }
+      },
+      // 回填后物品清单是分批入表的,等它落完再撤遮罩(15 秒兜底,避免异常时遮罩不消失)
+      async waitCopyFillDone() {
+        await this.$nextTick();
+        const deadline = Date.now() + 15000;
+        while (this.$refs?.inventoryTable?.tableBusy && Date.now() < deadline) {
+          await new Promise((resolve) => setTimeout(resolve, 100));
         }
       },
       setIssueNumber(len) {
@@ -1963,6 +1921,12 @@
           ? await getByIdForEdit(id)
           : await getpurchaseorderDetail(id);
         this.loading = false;
+        this.fillForm(data);
+      },
+
+      //回填订单详情数据(修改、复制共用),保持原有回填顺序
+      fillForm(data) {
+        if (!data) return;
         data.settlementDate = data.startSettlementDate ? [data.startSettlementDate, data.endSettlementDate] : [];
         this.form = data;
         console.log('data~~~~~~~000', data);
@@ -1976,7 +1940,6 @@
             this.$refs.outputDetailListRef &&
               this.$refs.outputDetailListRef.putTableValue(data.outputList); //产成品
             this.getLinkInfo(data.partaId);
-            
             this.$refs.paymentCollectionPlanRef && this.$refs.paymentCollectionPlanRef.putTableValue(data);
             this.getrequireUser(this.form.requireDeptId);
             if(data.purchaseDeptId) {
@@ -2247,13 +2210,19 @@
       },
       //打开新增编辑弹框
       async open(type, row, contactCategoryId) {
-        this.title = type === 'add' ? '新增' : '修改';
+        this.title =
+          type === 'add' ? '新增' : type === 'copy' ? '复制' : '修改';
         this.activeName = '1';
 
         this.row = row;
+        // 重置提交对象,避免上一次打开(修改/复制)残留的 businessId 串单
+        this.businessId = '';
         // 打开弹框前先清空缓存,避免残留上次数据
         this.rawDetailListCache = [];
         this.outputDetailListCache = [];
+        // 复制是异步取数:进分支就先开遮罩,避免弹窗先出一段时间的空壳
+        // 先复位,避免上一次异常中断残留的遮罩影响新增/修改
+        this.copyLoading = type === 'copy';
         this.visible = true;
         if (this.groupData.length == 0) {
           await this.getGroupAll();
@@ -2282,6 +2251,18 @@
           });
           this.form.contractStartDate = formatDate(new Date(), 'yyyy-MM-dd');
           this.form.isGeneratePaymentPlan = +this.isGenReceiptPlan;
+        } else if (type == 'copy') {
+          this.isUpdate = false;
+          try {
+            const data = await getPurchaseOrderCopyInfo(row.id);
+            this.fillForm(data);
+            await this.waitCopyFillDone();
+          } catch (e) {
+            this.visible = false;
+            this.$message.error(e?.message || '复制数据加载失败');
+          } finally {
+            this.copyLoading = false;
+          }
         } else {
           this.isUpdate = true;
           await this.getpurchaseorderDetail(row.id, true);
@@ -2325,6 +2306,8 @@
       //从合同页面新增订单
       contractOpen(row) {
         this.title = '新增';
+        // 重置提交对象,避免上一次打开(修改/复制)残留的 businessId 串单
+        this.businessId = '';
         this.visible = true;
         this.isUpdate = false;
         this.form.relationType = 4;
@@ -2430,6 +2413,8 @@
 
           if (!this.isUpdate) {
             delete this.form.id;
+            // 新增/复制不提交订单编号,一律由后端按编码规则生成,避免空号或旧号落库
+            delete this.form.orderNo;
           }
           // if (!this.form.contractId) { //如果来源是合同 金额不变这个逻辑有问题 先注释
             this.form.totalAmount = this.allcountAmount;

+ 27 - 1
src/views/purchasingManage/purchaseOrder/index.vue

@@ -115,6 +115,20 @@
                 </template>
                 <!-- 操作列 -->
                 <template v-slot:action="{ row }">
+                  <el-tooltip
+                    content="已关联来源单据,不能复制"
+                    :disabled="!isCannotCopy(row)"
+                  >
+                    <el-link
+                      type="primary"
+                      :underline="false"
+                      icon="el-icon-document-copy"
+                      :disabled="isCannotCopy(row)"
+                      @click="openEditNew('copy', row)"
+                    >
+                      复制
+                    </el-link>
+                  </el-tooltip>
                   <el-link
                     type="primary"
                     :underline="false"
@@ -690,7 +704,7 @@
           {
             columnKey: 'action',
             label: '操作',
-            width: 260,
+            width: 340,
             align: 'center',
             resizable: false,
             slot: 'action',
@@ -895,6 +909,18 @@
           this.$refs.addDialogNewRef.$refs.form.clearValidate();
       },
 
+      //是否不可复制(来源单据类型/来源单据有值,或已关联采购计划/合同)
+      isCannotCopy(row) {
+        return (
+          !!row.purchasePlanId ||
+          !!row.contractId ||
+          !!row.relationType ||
+          !!row.relationId ||
+          !!row.relationCode ||
+          !!row.relationName
+        );
+      },
+
       uploadFile() {
         this.$refs.importDialogRef.open();
       },

+ 3 - 3
src/views/saleManage/saleOrder/components/addDialogNew.vue

@@ -1809,9 +1809,9 @@
       },
 
       saleTypeChange() {
-        if (this.getSaleTypeName()) {
-          this.$set(this.form, 'settlementMode', '');
-        }
+        // 只刷新销售类型名称:技改/三包/补发 仅放开"结算方式"必填,
+        // 不再清空已选结算方式,否则重新选择会重置期数并清掉合同带出的收付款比例
+        this.getSaleTypeName();
       },
       getSaleTypeName() {
         let saleTypeName =

+ 3 - 3
vue.config.js

@@ -2,7 +2,7 @@
  * @Author: mlchen 374826075@qq.com
  * @Date: 2026-07-22 15:43:30
  * @LastEditors: mlchen 374826075@qq.com
- * @LastEditTime: 2026-11-12 09:50:52
+ * @LastEditTime: 2026-11-17 15:45:12
  * @FilePath: /kd-aiot-frontend-eom/vue.config.js
  * @Description: 这是默认设置,请设置`customMade`, 打开koroFileHeader查看配置 进行设置: https://github.com/OBKoro1/koro1FileHeader/wiki/%E9%85%8D%E7%BD%AE
  */
@@ -45,12 +45,12 @@ module.exports = {
       // 当我们的本地的请求 有/api的时候,就会代理我们的请求地址向另外一个服务器发出请求
       '/api': {
         // target: 'http://192.168.1.251:18086', //开发
-        // target: 'http://localhost:18086', //开发 // 本地联调临时指向本机后端(2026-11-05,联调后还原)
+        target: 'http://localhost:18086', //开发 // 本地联调临时指向本机后端(2026-11-05,联调后还原)
         // target: 'http://192.168.1.251:18186', //测试
         // target: 'http://192.168.1.15:18086',//罗
         // target: 'http://192.168.1.144:18086',//付
         // target: 'http://192.168.1.9:18086', //c
-        target: 'https://aiot.zoomwin.com.cn:51001/api',
+        // target: 'https://aiot.zoomwin.com.cn:51001/api',
         changeOrigin: true, // 只有这个值为true的情况下 才表示开启跨域
         pathRewrite: {
           '^/api': ''