Explorar el Código

交易:核销

owen hace 1 año
padre
commit
58b6b1ba57

+ 5 - 0
src/api/mall/trade/order/index.ts

@@ -139,3 +139,8 @@ export const updateOrderPrice = async (data: any) => {
 export const updateOrderAddress = async (data: any) => {
   return await request.put({ url: `/trade/order/update-address`, data })
 }
+
+// 订单核销
+export const pickUpOrder = async (id: number) => {
+  return await request.put({ url: `/trade/order/pick-up?id=${id}` })
+}

+ 25 - 0
src/utils/constants.ts

@@ -389,3 +389,28 @@ export const DeliveryTypeEnum = {
     name: '到店自提'
   }
 }
+/**
+ * 交易订单 - 状态
+ */
+export const TradeOrderStatusEnum = {
+  UNPAID: {
+    status: 0,
+    name: '待支付'
+  },
+  UNDELIVERED: {
+    status: 10,
+    name: '待发货'
+  },
+  DELIVERED: {
+    status: 20,
+    name: '已发货'
+  },
+  COMPLETED: {
+    status: 30,
+    name: '已完成'
+  },
+  CANCELED: {
+    status: 40,
+    name: '已取消'
+  }
+}

+ 45 - 16
src/views/mall/trade/order/detail/index.vue

@@ -27,24 +27,40 @@
         <dict-tag :type="DICT_TYPE.TRADE_ORDER_STATUS" :value="formData.status!" />
       </el-descriptions-item>
       <el-descriptions-item label-class-name="no-colon">
-        <el-button v-if="formData.status! === 0" type="primary" @click="updatePrice">
-          调整价格
-        </el-button>
-        <el-button type="primary" @click="remark">备注</el-button>
         <el-button
-          v-if="formData.status! === 10 && formData.deliveryType === DeliveryTypeEnum.EXPRESS.type"
+          v-if="formData.status! === TradeOrderStatusEnum.UNPAID.status"
           type="primary"
-          @click="delivery"
+          @click="updatePrice"
         >
-          发货
-        </el-button>
-        <el-button
-          v-if="formData.status! === 10 && formData.deliveryType === DeliveryTypeEnum.EXPRESS.type"
-          type="primary"
-          @click="updateAddress"
-        >
-          修改地址
+          调整价格
         </el-button>
+        <el-button type="primary" @click="remark">备注</el-button>
+        <!-- 待发货 -->
+        <template v-if="formData.status! === TradeOrderStatusEnum.UNDELIVERED.status">
+          <!-- 快递发货 -->
+          <el-button
+            v-if="formData.deliveryType === DeliveryTypeEnum.EXPRESS.type"
+            type="primary"
+            @click="delivery"
+          >
+            发货
+          </el-button>
+          <el-button
+            v-if="formData.deliveryType === DeliveryTypeEnum.EXPRESS.type"
+            type="primary"
+            @click="updateAddress"
+          >
+            修改地址
+          </el-button>
+          <!-- 到店自提 -->
+          <el-button
+            v-if="formData.deliveryType === DeliveryTypeEnum.PICK_UP.type"
+            type="primary"
+            @click="handlePickUp"
+          >
+            核销
+          </el-button>
+        </template>
       </el-descriptions-item>
       <el-descriptions-item>
         <template #label><span style="color: red">提醒: </span></template>
@@ -168,7 +184,7 @@
       <!-- 自提门店 -->
       <div v-if="formData.deliveryType === DeliveryTypeEnum.PICK_UP.type">
         <el-descriptions-item label="自提门店: " v-if="formData.pickUpStoreId">
-          {{ pickUpStore.name }}
+          {{ pickUpStore?.name }}
         </el-descriptions-item>
       </div>
     </el-descriptions>
@@ -217,7 +233,7 @@ import OrderUpdateAddressForm from '@/views/mall/trade/order/form/OrderUpdateAdd
 import OrderUpdatePriceForm from '@/views/mall/trade/order/form/OrderUpdatePriceForm.vue'
 import * as DeliveryExpressApi from '@/api/mall/trade/delivery/express'
 import { useTagsViewStore } from '@/store/modules/tagsView'
-import { DeliveryTypeEnum } from '@/utils/constants'
+import { DeliveryTypeEnum, TradeOrderStatusEnum } from '@/utils/constants'
 import * as DeliveryPickUpStoreApi from '@/api/mall/trade/delivery/pickUpStore'
 
 defineOptions({ name: 'TradeOrderDetail' })
@@ -263,6 +279,19 @@ const updatePrice = () => {
   updatePriceFormRef.value?.open(formData.value)
 }
 
+/** 核销 */
+const handlePickUp = async () => {
+  try {
+    // 二次确认
+    await message.confirm('确认核销订单吗?')
+    // 提交
+    await TradeOrderApi.pickUpOrder(formData.value.id!)
+    message.success('核销成功')
+    // 刷新列表
+    await getDetail()
+  } catch {}
+}
+
 /** 获得详情 */
 const { params } = useRoute() // 查询参数
 const getDetail = async () => {

+ 39 - 7
src/views/mall/trade/order/index.vue

@@ -74,7 +74,11 @@
           />
         </el-select>
       </el-form-item>
-      <el-form-item v-if="queryParams.deliveryType === 1" label="快递公司">
+      <el-form-item
+        v-if="queryParams.deliveryType === DeliveryTypeEnum.EXPRESS.type"
+        label="快递公司"
+        prop="logisticsId"
+      >
         <el-select v-model="queryParams.logisticsId" class="!w-280px" clearable placeholder="全部">
           <el-option
             v-for="item in deliveryExpressList"
@@ -84,7 +88,11 @@
           />
         </el-select>
       </el-form-item>
-      <el-form-item v-if="queryParams.deliveryType === 2" label="自提门店">
+      <el-form-item
+        v-if="queryParams.deliveryType === DeliveryTypeEnum.PICK_UP.type"
+        label="自提门店"
+        prop="pickUpStoreId"
+      >
         <el-select
           v-model="queryParams.pickUpStoreId"
           class="!w-280px"
@@ -100,6 +108,19 @@
           />
         </el-select>
       </el-form-item>
+      <el-form-item
+        v-if="queryParams.deliveryType === DeliveryTypeEnum.PICK_UP.type"
+        label="核销码"
+        prop="pickUpVerifyCode"
+      >
+        <el-input
+          v-model="queryParams.pickUpVerifyCode"
+          class="!w-280px"
+          clearable
+          placeholder="请输入自提核销码"
+          @keyup.enter="handleQuery"
+        />
+      </el-form-item>
       <!-- TODO puhui 聚合搜索等售后结束后实现-->
       <!-- TODO puhui999:尽量不要用 .k 这样的参数,完整拼写,有完整的业务含义 -->
       <el-form-item label="聚合搜索">
@@ -234,7 +255,10 @@
             <el-table-column label="买家/收货人" min-width="160">
               <template #default>
                 <!-- 快递发货  -->
-                <div v-if="scope.row.deliveryType === 1" class="flex flex-col">
+                <div
+                  v-if="scope.row.deliveryType === DeliveryTypeEnum.EXPRESS.type"
+                  class="flex flex-col"
+                >
                   <span>买家:{{ scope.row.user.nickname }}</span>
                   <span>
                     收货人:{{ scope.row.receiverName }} {{ scope.row.receiverMobile }}
@@ -242,7 +266,10 @@
                   </span>
                 </div>
                 <!-- 自提  -->
-                <div v-if="scope.row.deliveryType === 2" class="flex flex-col">
+                <div
+                  v-if="scope.row.deliveryType === DeliveryTypeEnum.PICK_UP.type"
+                  class="flex flex-col"
+                >
                   <span>
                     门店名称:
                     {{ pickUpStoreList.find((p) => p.id === scope.row.pickUpStoreId)?.name }}
@@ -273,7 +300,7 @@
             <el-table-column align="center" fixed="right" label="操作" width="160">
               <template #default>
                 <!-- TODO 权限后续补齐 -->
-                <div class="flex justify-center items-center">
+                <div class="flex items-center justify-center">
                   <el-button link type="primary" @click="openDetail(scope.row.id)">
                     <Icon icon="ep:notification" />
                     详情
@@ -287,7 +314,10 @@
                       <el-dropdown-menu>
                         <!-- 如果是【快递】,并且【未发货】,则展示【发货】按钮 -->
                         <el-dropdown-item
-                          v-if="scope.row.deliveryType === 1 && scope.row.status === 10"
+                          v-if="
+                            scope.row.deliveryType === DeliveryTypeEnum.EXPRESS.type &&
+                            scope.row.status === TradeOrderStatusEnum.UNDELIVERED.status
+                          "
                           command="delivery"
                         >
                           <Icon icon="ep:takeaway-box" />
@@ -332,6 +362,7 @@ import { formatDate } from '@/utils/formatTime'
 import { floatToFixed2 } from '@/utils'
 import { createImageViewer } from '@/components/ImageViewer'
 import * as DeliveryExpressApi from '@/api/mall/trade/delivery/express'
+import { DeliveryTypeEnum, TradeOrderStatusEnum } from '@/utils/constants'
 
 defineOptions({ name: 'TradeOrder' })
 
@@ -352,7 +383,8 @@ const queryParams = ref({
   type: null, // 订单类型
   deliveryType: null, // 配送方式
   logisticsId: null, // 快递公司
-  pickUpStoreId: null // 自提门店
+  pickUpStoreId: null, // 自提门店
+  pickUpVerifyCode: null // 自提核销码
 })
 const queryType = reactive({ k: '' }) // 订单搜索类型 k