hurx 1 dia atrás
pai
commit
26590feef8
1 arquivos alterados com 13 adições e 3 exclusões
  1. 13 3
      src/views/order/saleOrder/orderAffirm.vue

+ 13 - 3
src/views/order/saleOrder/orderAffirm.vue

@@ -261,14 +261,16 @@ import { getCompany } from '@/api/company/company';
 import { getWarehouse } from '@/api/company/warehouse';
 import { getCustomerInfo } from '@/api/customer/customerFile/customerInfo';
 import { getDept } from '@/api/system/dept';
+import { useRoute, useRouter } from 'vue-router';
 
 const { proxy } = getCurrentInstance() as ComponentInternalInstance;
 const { pay_method, fee_type } = toRefs<any>(proxy?.useDict('pay_method', 'fee_type'));
-const router = useRouter();
 
 const buttonLoading = ref(false);
 const loading = ref(true);
-
+// 获取路由和 router 实例
+const route = useRoute();
+const router = useRouter();
 // 订单信息
 const orderInfo = ref<any>({});
 // 收货地址信息
@@ -505,7 +507,6 @@ const goBack = () => {
 
 // 页面加载时获取订单ID并加载订单详情
 onMounted(() => {
-  const route = useRoute();
   const orderId = route.query.id;
   if (orderId) {
     getOrderDetail(orderId as string);
@@ -514,6 +515,15 @@ onMounted(() => {
     router.back();
   }
 });
+// 监听路由 query 中的 id 变化
+watch(
+  () => route.query.id, // 监听 id 的变化
+  (newOrderId) => {
+    if (newOrderId) {
+      getOrderDetail(newOrderId as string);
+    }
+  }
+);
 </script>
 
 <style scoped lang="scss">