叶静 1 долоо хоног өмнө
parent
commit
d7f1f2b1a0

+ 2 - 2
src/app/shop/admin/order/order/detail.vue

@@ -431,7 +431,7 @@ function onDispatch() {
       data: state.orderDetail,
     },
     {
-      success: () => {
+      confirm: () => {
         getOrderDetail(); // 刷新订单详情
       },
     },
@@ -512,7 +512,7 @@ function onOpenDispatch() {
       data: state.orderDetail,
     },
     {
-      success: () => {
+      close: () => {
         getOrderDetail();
       },
     },

+ 60 - 16
src/app/shop/admin/order/order/dispatch.vue

@@ -44,30 +44,30 @@
         </el-table>
         <div class="address">
           <div class="title sa-m-b-16">{{ t('modules.order.deliveryInfo') }}</div>
-          <div class="sa-m-l-16" v-if="props.modal?.params?.data?.orderAddressVO">
+          <div class="sa-m-l-16" v-if="state.addressInfo">
             <div class="sa-flex sa-m-b-8">
               <div class="label">{{ t('modules.order.recipientInfo') }}:</div>
               <div class="content">
-                {{ props.modal?.params?.data?.orderAddressVO?.realName }}&nbsp;
-                {{ props.modal?.params?.data?.orderAddressVO?.phone }}
+                {{ state.addressInfo?.realName }}&nbsp;
+                {{ state.addressInfo?.phone || state.addressInfo?.userPhone }}
               </div>
             </div>
             <div class="sa-flex sa-col-top sa-m-b-16">
               <div class="label">{{ t('modules.order.recipientAddress') }}:</div>
               <div class="content">
                 <div>
-                  {{ props.modal?.params?.data?.orderAddressVO?.province }}&nbsp;
-                  {{ props.modal?.params?.data?.orderAddressVO?.city }}&nbsp;
-                  {{ props.modal?.params?.data?.orderAddressVO?.district }}
+                  {{ state.addressInfo?.province }}&nbsp;
+                  {{ state.addressInfo?.city }}&nbsp;
+                  {{ state.addressInfo?.district }}
                 </div>
-                <div>{{ props.modal?.params?.data?.orderAddressVO?.detail }}</div>
-                <div v-if="props.modal?.params?.data?.orderAddressVO?.postCode">
-                  {{ t('modules.order.postalCode') }}:{{ props.modal?.params?.data?.orderAddressVO?.postCode }}
+                <div>{{ state.addressInfo?.detail }}</div>
+                <div v-if="state.addressInfo?.postCode">
+                  {{ t('modules.order.postalCode') }}:{{ state.addressInfo?.postCode }}
                 </div>
               </div>
             </div>
           </div>
-          <div v-if="!props.modal?.params?.data?.orderAddressVO" class="mb-20px text-14px text-red ml-20px">
+          <div v-if="!state.addressInfo" class="mb-20px text-14px text-red ml-20px">
             {{ t('modules.order.incompleteAddress') }}
           </div>
         </div>
@@ -200,10 +200,21 @@ const state = reactive({
   nosendItem: computed(() => {
     console.log('发货弹窗接收到的数据:', props.modal);
     console.log('订单详情数据:', props.modal?.params?.data);
-    console.log('商品信息数据:', props.modal?.params?.data?.orderInfoVO);
-    console.log('地址信息数据:', props.modal?.params?.data?.orderAddressVO);
-    if (!props.modal?.params?.data?.orderInfoVO) return [];
-    return props.modal.params?.data.orderInfoVO;
+
+    if (!props.modal?.params?.data) return [];
+
+    const data = props.modal.params.data;
+
+    // 判断数据来源:
+    // 1. 如果有 orderInfoVO 字段,说明是从详情页进入,使用 orderInfoVO
+    if (data.orderInfoVO && Array.isArray(data.orderInfoVO)) {
+      console.log('详情页数据结构,使用 orderInfoVO');
+      return data.orderInfoVO;
+    }
+
+    // 2. 否则是从列表进入,直接使用 data 包装成数组
+    console.log('列表页数据结构,使用 data');
+    return [data];
   }),
   method: 'input',
   expressItem: [],
@@ -220,6 +231,8 @@ const state = reactive({
   }),
   custom_type: 'text',
   custom_content: [],
+  // 地址信息 - 需要通过订单号获取
+  addressInfo: null,
 });
 
 function handleSelectionChange(val) {
@@ -231,8 +244,7 @@ const { express, deliverCompany, getDeliverCompany, onChangeExpressCode, remoteM
 // TODO
 async function onSend() {
   // 检查订单是否有收货地址信息
-  const orderAddress = props.modal?.params?.data?.orderAddressVO;
-  if (!orderAddress || !orderAddress.realName || !orderAddress.phone || !orderAddress.detail) {
+  if (!state.addressInfo || !state.addressInfo.realName || (!state.addressInfo.phone && !state.addressInfo.userPhone) || !state.addressInfo.detail) {
     ElMessage.error(t('modules.order.incompleteAddress'));
     return;
   }
@@ -257,6 +269,7 @@ async function onSend() {
             ]);
             state.sendLoading = false;
             if (code == '200') {
+              ElMessage.success(t('modules.order.sendSuccess'));
               emit('modalCallBack', { event: 'confirm' });
             }
           }
@@ -271,6 +284,7 @@ async function onSend() {
       });
       state.sendLoading = false;
       if (code == '200') {
+        ElMessage.success(t('modules.order.sendSuccess'));
         emit('modalCallBack', { event: 'confirm' });
       }
     }
@@ -322,7 +336,37 @@ watch(
   },
 );
 
+// 获取订单地址信息
+async function getOrderAddress() {
+  const data = props.modal?.params?.data;
+  if (!data) return;
+
+  // 如果已经有 orderAddressVO (从详情页进入),直接使用
+  if (data.orderAddressVO) {
+    console.log('使用详情页已有的地址信息');
+    state.addressInfo = data.orderAddressVO;
+    return;
+  }
+
+  // 否则通过订单号请求地址信息 (从列表页进入)
+  const orderId = data.orderId;
+  if (!orderId) return;
+
+  try {
+    console.log('从列表页进入,请求订单地址信息');
+    const { code, data: detailData } = await api.order.detail({ orderNo: orderId });
+    if (code == '200' && detailData?.orderAddressVO) {
+      state.addressInfo = detailData.orderAddressVO;
+    }
+  } catch (error) {
+    console.error('获取订单地址失败:', error);
+  }
+}
+
 onMounted(() => {
+  // 获取订单地址信息
+  getOrderAddress();
+
   if (state.nosendItem.length) {
     state.dispatch_type = 'express';
     // 默认选中所有快递发货商品

+ 0 - 1
src/app/shop/admin/order/order/index.vue

@@ -556,7 +556,6 @@ function onSend(row) {
     },
     {
       close: (result) => {
-        ElMessage.success(t('modules.order.sendSuccess'));
         // 如果批量发货成功,刷新当前页面数据
         getData();
       },