Преглед на файлове

修改下单收获地址选择

hurx преди 2 месеца
родител
ревизия
c3b85eedc7
променени са 3 файла, в които са добавени 54 реда и са изтрити 12 реда
  1. 22 0
      src/api/order/orderMain/index.ts
  2. 8 3
      src/views/order/orderMain/index.vue
  3. 24 9
      src/views/order/saleOrder/index.vue

+ 22 - 0
src/api/order/orderMain/index.ts

@@ -89,6 +89,11 @@ export const queryOrderStatusStats = () => {
   });
 };
 
+/**
+ * 修改审核状态
+ * @param id
+ * @param checkStatus
+ */
 export function changeCheckStatus(id: string | number, checkStatus: string) {
   const data = {
     id,
@@ -100,3 +105,20 @@ export function changeCheckStatus(id: string | number, checkStatus: string) {
     data: data
   });
 }
+
+/**
+ * 修改订单状态
+ * @param id
+ * @param orderStatus
+ */
+export function changeStatus(id: string | number, orderStatus: string) {
+  const data = {
+    id,
+    orderStatus
+  };
+  return request({
+    url: '/order/orderMain/changeStatus',
+    method: 'put',
+    data: data
+  });
+}

+ 8 - 3
src/views/order/orderMain/index.vue

@@ -619,6 +619,12 @@ const submitForm = () => {
         return;
       }
 
+      // 验证是否有商品
+      if (!form.value.shippingAddressId) {
+        proxy?.$modal.msgWarning('收货地址不能为空');
+        return;
+      }
+
       buttonLoading.value = true;
 
       try {
@@ -665,7 +671,7 @@ const submitForm = () => {
         reset();
         proxy?.$modal.msgSuccess('操作成功');
         // 可以在这里添加跳转逻辑,比如返回列表页
-        router.push('/order-manage/order-list');
+        router.push('/order-center/order-list');
       } catch (error) {
         console.error('提交订单失败:', error);
         proxy?.$modal.msgError('提交订单失败,请检查数据后重试');
@@ -687,7 +693,7 @@ const handleDelete = async (row?: OrderMainVO) => {
 /** 导出按钮操作 */
 const handleExport = () => {
   proxy?.download(
-    'order/orderMain/export',
+    'system/orderMain/export',
     {
       ...queryParams.value
     },
@@ -745,7 +751,6 @@ const handleProductConfirm = (product: any) => {
     amount: ((product.memberPrice || 0) * (product.minOrderQuantity || 1)).toFixed(2) // 小计 = 含税单价 × 数量
   };
   productList.value.push(newProduct);
-  proxy?.$modal.msgSuccess('添加商品成功');
 };
 
 /** 删除商品 */

+ 24 - 9
src/views/order/saleOrder/index.vue

@@ -45,7 +45,7 @@
             <el-button type="primary" plain>关闭订单</el-button>
           </el-col>
           <el-col :span="1.5">
-            <el-button type="primary" plain>删除订单</el-button>
+            <el-button type="primary" @click="handleDelete()" plain>删除订单</el-button>
           </el-col>
           <el-col :span="1.5">
             <el-button type="primary" plain>导出订单</el-button>
@@ -131,12 +131,7 @@
               >查看订单信息</el-button
             >
             <el-button link type="primary" v-if="scope.row.orderStatus === '4' || scope.row.orderStatus === '5'">查看物流</el-button>
-            <el-button
-              link
-              type="primary"
-              v-if="scope.row.orderStatus === '0' || scope.row.orderStatus === '3' || scope.row.orderStatus === '4' || scope.row.orderStatus === '5'"
-              >取消订单</el-button
-            >
+            <el-button link type="primary" @click="handleCancel(scope.row)" v-if="scope.row.orderStatus != '7'">取消订单</el-button>
           </template>
         </el-table-column>
       </el-table>
@@ -157,6 +152,7 @@ import {
   addOrderMain,
   updateOrderMain,
   queryOrderStatusStats,
+  changeStatus,
   changeCheckStatus
 } from '@/api/order/orderMain';
 import { OrderMainVO, OrderMainQuery, OrderMainForm } from '@/api/order/orderMain/types';
@@ -205,12 +201,12 @@ const orderStatusStats = ref({
 const initFormData: OrderMainForm = {
   id: undefined,
   orderNo: undefined,
-  isSplitChild: undefined,
   shipmentNo: undefined,
   subOrderNo: undefined,
   companyId: undefined,
   customerId: undefined,
   customerCode: undefined,
+  isSplitChild: undefined,
   userId: undefined,
   shippingAddressId: undefined,
   purchaseReason: undefined,
@@ -376,7 +372,7 @@ const handleSelectionChange = (selection: OrderMainVO[]) => {
 
 const handleReview = (row?: OrderMainVO) => {
   router.push({
-    path: '/order-manage/order-sendDetail',
+    path: '/order-center/order-sendDetail',
     query: { id: row.id }
   });
 };
@@ -466,6 +462,25 @@ const handleCheck = async (row?: OrderMainVO) => {
   }
 };
 
+/** 审核按钮操作 */
+const handleCancel = async (row?: OrderMainVO) => {
+  const oldValue = row.checkStatus; // 保存旧值
+
+  // 弹出审核选择对话框
+  try {
+    // 调用接口,传入用户选择的值
+    await changeStatus(row.id, '7');
+    getList();
+    proxy?.$modal.msgSuccess('操作成功');
+  } catch (error) {
+    // 用户取消或操作失败
+    if (error !== 'cancel' && error !== 'close') {
+      row.checkStatus = oldValue; // 失败回滚
+      proxy?.$modal.msgError('操作失败,请重试');
+    }
+  }
+};
+
 /** 发货按钮操作 */
 const handleDeliver = (row?: OrderMainVO) => {
   if (!row?.id) {