update customer package
This commit is contained in:
@@ -1,6 +1,10 @@
|
||||
<template>
|
||||
<div v-can="permissionCodes.salesOrder.cancel" class="sales-order-operation">
|
||||
<t-cell-group v-if="order" title="销售订单" theme="card"><t-cell title="订单号" :note="order.orderNo || order.id" /><t-cell title="当前状态" :note="order.status || '未知'" /></t-cell-group>
|
||||
<t-cell-group v-if="order" title="销售订单" theme="card">
|
||||
<t-cell title="订单号" :note="order.orderNo || order.id" />
|
||||
<t-cell title="当前状态" :note="getSalesOrderStatusText(order.status)" />
|
||||
<t-cell v-if="hasPendingFulfillment" title="履约提示" note="存在待处理履约,暂不能取消订单" />
|
||||
</t-cell-group>
|
||||
<div v-if="order" class="revoke-tip">取消订单会立即撤销本单有效消费;受影响的订单积分和签到消费条件积分将由系统自动追加撤销流水。退款仍需按资金流程处理。</div>
|
||||
<t-form v-if="order" class="form" label-align="left" label-width="6rem">
|
||||
<t-form-item label="取消原因" required-mark><t-textarea v-model.trim="reason" borderless autosize maxlength="500" placeholder="请输入取消原因" /></t-form-item>
|
||||
@@ -11,26 +15,45 @@
|
||||
|
||||
<script setup lang="ts">
|
||||
import { useUserStore } from "timi-web-api";
|
||||
import FulfillmentAPI from "@/api/FulfillmentAPI";
|
||||
import SalesOrderAPI from "@/api/SalesOrderAPI";
|
||||
import { useNavBarStore } from "@/store/navBarStore";
|
||||
import type { SalesOrder } from "@/types/SalesOrder";
|
||||
import { getErrorMessage } from "@/utils/error";
|
||||
import { Message } from "@/utils/message";
|
||||
import { permissionCodes } from "@/utils/permission";
|
||||
import { getSalesOrderStatusText } from "@/utils/salesOrder";
|
||||
|
||||
defineOptions({ name: "SalesOrderCancel" });
|
||||
const route = useRoute(); const router = useRouter(); const navBarStore = useNavBarStore(); const userStore = useUserStore();
|
||||
const order = ref<SalesOrder>(); const loading = ref(false); const saving = ref(false); const reason = ref("");
|
||||
const order = ref<SalesOrder>(); const loading = ref(false); const saving = ref(false); const reason = ref(""); const hasPendingFulfillment = ref(false);
|
||||
async function loadData(): Promise<void> {
|
||||
const id = String(route.params.id || "");
|
||||
if (!id) return;
|
||||
loading.value = true;
|
||||
try { order.value = await SalesOrderAPI.detail(id); }
|
||||
try {
|
||||
order.value = await SalesOrderAPI.detail(id);
|
||||
if (userStore.hasPermissions(permissionCodes.orderFulfillment.read)) {
|
||||
const [pendingResult, waitingStockResult] = await Promise.all([
|
||||
FulfillmentAPI.list({ salesOrderId: id, status: "PENDING", index: 0, size: 1 }),
|
||||
FulfillmentAPI.list({ salesOrderId: id, status: "WAITING_STOCK", index: 0, size: 1 })
|
||||
]);
|
||||
hasPendingFulfillment.value = !!pendingResult.list?.length || !!waitingStockResult.list?.length;
|
||||
}
|
||||
}
|
||||
catch (error) { Message.error(getErrorMessage(error, "订单加载失败")); }
|
||||
finally { loading.value = false; }
|
||||
}
|
||||
async function save(): Promise<void> {
|
||||
if (!order.value?.id || !reason.value || saving.value) return;
|
||||
if (order.value.status !== "ACTIVE") {
|
||||
Message.warning("只有进行中的订单可以取消");
|
||||
return;
|
||||
}
|
||||
if (hasPendingFulfillment.value) {
|
||||
Message.warning("存在待处理履约,暂不能取消订单");
|
||||
return;
|
||||
}
|
||||
saving.value = true;
|
||||
try {
|
||||
await SalesOrderAPI.cancel({ salesOrderId: order.value.id, reason: reason.value.trim() });
|
||||
|
||||
Reference in New Issue
Block a user