feat: recycle system
This commit is contained in:
@@ -1,231 +1,245 @@
|
||||
<template>
|
||||
<div class="tui-page-layout tui-navbar">
|
||||
<div class="tui-page-layout tui-navbar sales-order-detail">
|
||||
<t-navbar
|
||||
fixed
|
||||
:z-index="20"
|
||||
title="销售订单详情"
|
||||
title="交易订单详情"
|
||||
left-arrow
|
||||
@left-click="goBack"
|
||||
/>
|
||||
<main class="tui-page-content scroll column">
|
||||
<div v-can="permissionCodes.salesOrder.read" class="sales-order-detail">
|
||||
<template v-if="order">
|
||||
<customer-profile-card
|
||||
v-if="order.customer"
|
||||
class="customer"
|
||||
:customer="order.customer"
|
||||
v-entrance-transition
|
||||
@click="toCustomerDetail"
|
||||
/>
|
||||
<section class="hero" v-entrance-transition>
|
||||
<div class="header">
|
||||
<span class="eyebrow">销售订单</span>
|
||||
<div class="tags">
|
||||
<t-tag :content="getSalesOrderTypeText(order.orderType)" theme="primary" variant="light-outline" />
|
||||
<t-tag :content="getSalesOrderStatusText(order.status)" variant="light-outline" :theme="getStatusTheme(order.status)" />
|
||||
</div>
|
||||
<main v-can="permissionCodes.salesOrder.read" class="tui-page-content scroll column">
|
||||
<template v-if="order">
|
||||
<customer-profile-card
|
||||
v-if="order.customer"
|
||||
class="customer"
|
||||
:customer="order.customer"
|
||||
v-entrance-transition
|
||||
@click="toCustomerDetail"
|
||||
/>
|
||||
<section class="hero" v-entrance-transition>
|
||||
<div class="header">
|
||||
<span class="eyebrow">交易订单</span>
|
||||
<div class="tags">
|
||||
<t-tag :content="getSalesOrderTypeText(order.orderType)" theme="primary" variant="light-outline" />
|
||||
<t-tag :content="getSalesOrderStatusText(order.status)" variant="light-outline" :theme="getStatusTheme(order.status)" />
|
||||
</div>
|
||||
<h1 class="no selectable" v-text="order.orderNo" />
|
||||
<div class="meta">
|
||||
<time-label class="time" :timestamp="order.purchasedAt" underline />
|
||||
<div class="amount red text-bold">
|
||||
<span>¥</span>
|
||||
<strong class="value" v-text="formatPackageAmount(order.saleAmount)" />
|
||||
</div>
|
||||
</div>
|
||||
<h1 class="no selectable" v-text="order.orderNo" />
|
||||
<div class="meta">
|
||||
<time-label class="time" :timestamp="order.purchasedAt" underline />
|
||||
<div class="amount red text-bold">
|
||||
<span>¥</span>
|
||||
<strong class="value" v-text="formatPackageAmount(order.saleAmount)" />
|
||||
</div>
|
||||
</section>
|
||||
<t-form class="info form card" title="订单信息" @submit="saveEdit" v-entrance-transition>
|
||||
<t-form-item v-if="order.sourceEventRecord?.id" label="来源登记记录" arrow @click="toEventRecord">
|
||||
<span>查看来源记录</span>
|
||||
</t-form-item>
|
||||
<t-form-item label="备注">
|
||||
<t-textarea v-if="isEditing" v-model.trim="editRemark" class="remark-editor" borderless autosize maxlength="500" placeholder="记录本单需要注意的内容" />
|
||||
<span v-else v-text="Text.display(order.remark)" />
|
||||
</t-form-item>
|
||||
<t-form-item label-width="0">
|
||||
<div class="photo-wrap" v-entrance-transition>
|
||||
<attachment-selector :readonly="!isEditing"
|
||||
v-model:items="photoItems"
|
||||
:upload="isEditing ? uploadPhotoList : undefined"
|
||||
title="订单照片"
|
||||
/>
|
||||
</div>
|
||||
</t-form-item>
|
||||
<t-form-item v-if="canUpdate" label-width="0">
|
||||
<div class="edit-actions">
|
||||
</div>
|
||||
</section>
|
||||
<t-form class="info form card" title="订单信息" @submit="saveEdit" v-entrance-transition>
|
||||
<t-form-item v-if="order.sourceEventRecord?.id" label="来源登记记录" arrow @click="toEventRecord">
|
||||
<span>查看来源记录</span>
|
||||
</t-form-item>
|
||||
<t-form-item label="备注">
|
||||
<t-textarea v-if="isEditing" v-model.trim="editRemark" class="remark-editor" borderless autosize maxlength="500" placeholder="记录本单需要注意的内容" />
|
||||
<span v-else v-text="Text.display(order.remark)" />
|
||||
</t-form-item>
|
||||
<t-form-item label-width="0">
|
||||
<div class="photo-wrap" v-entrance-transition>
|
||||
<attachment-selector :readonly="!isEditing"
|
||||
v-model:items="photoItems"
|
||||
:upload="isEditing ? uploadPhotoList : undefined"
|
||||
title="订单照片"
|
||||
/>
|
||||
</div>
|
||||
</t-form-item>
|
||||
<t-form-item v-if="canUpdate" label-width="0">
|
||||
<div class="edit-actions">
|
||||
<t-button
|
||||
v-if="!isEditing"
|
||||
type="button"
|
||||
size="extra-small"
|
||||
theme="primary"
|
||||
@click="toEdit"
|
||||
>编辑</t-button>
|
||||
<template v-else>
|
||||
<t-button
|
||||
v-if="!isEditing"
|
||||
type="button"
|
||||
size="extra-small"
|
||||
:disabled="isSaving"
|
||||
@click="cancelEdit"
|
||||
>取消</t-button>
|
||||
<t-button
|
||||
type="submit"
|
||||
theme="primary"
|
||||
@click="toEdit"
|
||||
>编辑</t-button>
|
||||
<template v-else>
|
||||
<t-button
|
||||
type="button"
|
||||
size="extra-small"
|
||||
:disabled="isSaving"
|
||||
@click="cancelEdit"
|
||||
>取消</t-button>
|
||||
<t-button
|
||||
type="submit"
|
||||
theme="primary"
|
||||
size="extra-small"
|
||||
:loading="isSaving"
|
||||
:disabled="isSaving"
|
||||
>保存</t-button>
|
||||
</template>
|
||||
</div>
|
||||
</t-form-item>
|
||||
</t-form>
|
||||
<t-form
|
||||
v-if="order.itemList?.length"
|
||||
class="form card product"
|
||||
title="订单明细"
|
||||
theme="card"
|
||||
label-width="0"
|
||||
v-entrance-transition
|
||||
>
|
||||
<t-form-item class="form-item" v-for="item in order.itemList" :key="item.id">
|
||||
<div class="item">
|
||||
<div class="header">
|
||||
<div class="left">
|
||||
<t-image
|
||||
v-if="getProductPhotoURL(item)"
|
||||
:src="getProductPhotoURL(item)"
|
||||
:alt="item.productNameSnapshot || '产品图片'"
|
||||
fit="cover"
|
||||
class="avatar"
|
||||
/>
|
||||
<div
|
||||
v-else
|
||||
class="avatar fallback"
|
||||
v-text="(item.productNameSnapshot || '产').slice(0, 1)"
|
||||
/>
|
||||
</div>
|
||||
<div class="main">
|
||||
<div class="title">
|
||||
<div class="name-gift">
|
||||
<span class="name text-bold" v-text="item.productNameSnapshot || '未命名产品'" />
|
||||
<t-tag v-if="item.gifted" size="small" theme="success" content="赠送" />
|
||||
</div>
|
||||
<t-tag
|
||||
:content="getItemFulfillmentStatus(item).text"
|
||||
:theme="getItemFulfillmentStatus(item).theme"
|
||||
variant="light-outline"
|
||||
/>
|
||||
</div>
|
||||
<div class="description">
|
||||
<strong
|
||||
v-if="item.lineAmount !== null && item.lineAmount !== undefined"
|
||||
class="red"
|
||||
v-text="`¥${formatPackageAmount(item.lineAmount)}`"
|
||||
/>
|
||||
<t-tag v-else size="small" content="套餐权益" />
|
||||
<product-sku-tags
|
||||
:product-name="item.productNameSnapshot"
|
||||
:snapshot="item.skuSpecSnapshot"
|
||||
:fallback="item.specSummarySnapshot || item.skuNameSnapshot"
|
||||
:unit="item.unitSnapshot"
|
||||
/>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<div class="content">
|
||||
<div class="metric">
|
||||
<strong v-text="getPackageQuantityText(item.quantity)" />
|
||||
<span>订单数量</span>
|
||||
</div>
|
||||
<div class="metric">
|
||||
<strong :class="getAvailableQuantityClass(item)" v-text="getItemQuantityText(item, item.availableBaseQuantity)" />
|
||||
<span>可履约</span>
|
||||
</div>
|
||||
<div class="metric">
|
||||
<strong :class="getAmountClass(Number(item.pendingBaseQuantity || 0), 'red')" v-text="getItemQuantityText(item, item.pendingBaseQuantity)" />
|
||||
<span>待核销</span>
|
||||
</div>
|
||||
<div class="metric">
|
||||
<strong :class="getFulfilledQuantityClass(item)" v-text="getItemQuantityText(item, item.fulfilledBaseQuantity)" />
|
||||
<span>已履约</span>
|
||||
</div>
|
||||
<div class="metric">
|
||||
<strong :class="getRemainingQuantityClass(item)" v-text="getItemQuantityText(item, item.remainingBaseQuantity)" />
|
||||
<span>剩余</span>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</t-form-item>
|
||||
<t-form-item label="履约记录" arrow @click="toFulfillmentList">
|
||||
查看本单所有履约单
|
||||
</t-form-item>
|
||||
</t-form>
|
||||
<t-button
|
||||
v-if="canCreateFulfillment && canFulfillByPayment && order.status === 'ACTIVE'"
|
||||
class="cell-button"
|
||||
theme="primary"
|
||||
content="履约产品"
|
||||
@click="toCreateFulfillment"
|
||||
/>
|
||||
<t-cell-group class="finance-panel" title="资金摘要" theme="card">
|
||||
<t-cell title="成交金额">
|
||||
<template #note><span :class="getPaymentAmountClass(order.paymentStatus)" v-text="formatPackageAmount(order.saleAmount)" /></template>
|
||||
</t-cell>
|
||||
<t-cell title="已生效收款">
|
||||
<template #note><span :class="getAmountClass(order.paidAmount, 'green')" v-text="formatPackageAmount(order.paidAmount)" /></template>
|
||||
</t-cell>
|
||||
<t-cell title="待核销收款">
|
||||
<template #note><span :class="getAmountClass(order.pendingPaidAmount, 'orange')" v-text="formatPackageAmount(order.pendingPaidAmount)" /></template>
|
||||
</t-cell>
|
||||
<t-cell title="剩余待收款">
|
||||
<template #note><span :class="getRemainingAmountClass(order.unpaidAmount)" v-text="formatPackageAmount(order.unpaidAmount)" /></template>
|
||||
</t-cell>
|
||||
<t-cell title="有效退款">
|
||||
<template #note><span :class="getAmountClass(order.refundedAmount, 'red')" v-text="formatPackageAmount(order.refundedAmount)" /></template>
|
||||
</t-cell>
|
||||
<t-cell title="收款状态" :note="getSalesPaymentStatusText(order.paymentStatus)" />
|
||||
<t-cell v-if="order.paymentStatus === 'PAID'" title="全额实收时间" :note="getPaidAtText(order.paidAt)" />
|
||||
<t-cell title="退款状态" :note="getSalesRefundStatusText(order.refundStatus)" />
|
||||
<t-cell
|
||||
v-if="canReadFund || canReadMyReceive"
|
||||
:title="canReadFund ? '查看全部资金流水' : '查看我的收款申请'"
|
||||
arrow
|
||||
@click="toFundRecords"
|
||||
/>
|
||||
</t-cell-group>
|
||||
<t-cell-group v-if="order.status === 'CANCELLED'" class="cancel-info" title="取消记录" theme="card">
|
||||
<t-cell title="取消时间">
|
||||
<template #note>
|
||||
<time-label :timestamp="order.cancelledAt" underline />
|
||||
size="extra-small"
|
||||
:loading="isSaving"
|
||||
:disabled="isSaving"
|
||||
>保存</t-button>
|
||||
</template>
|
||||
</t-cell>
|
||||
<t-cell title="取消人" :note="order.cancelOperator?.nick || order.cancelOperator?.name || order.cancelOperatorUserId || '未知'" />
|
||||
<t-cell title="取消原因" :note="order.cancelReason || '未填写'" />
|
||||
</t-cell-group>
|
||||
<section class="actions" v-entrance-transition>
|
||||
<t-button
|
||||
v-if="canReceive"
|
||||
theme="primary"
|
||||
@click="toPayment"
|
||||
>登记收款</t-button>
|
||||
<t-button
|
||||
v-if="canRefund"
|
||||
theme="danger"
|
||||
@click="toRefund"
|
||||
>登记退款</t-button>
|
||||
<t-button
|
||||
v-if="canConfirmNoRefund"
|
||||
theme="default"
|
||||
@click="toNoRefund"
|
||||
>确认无需退款</t-button>
|
||||
<t-button
|
||||
v-if="canCancel"
|
||||
theme="danger"
|
||||
@click="toCancel"
|
||||
>取消订单</t-button>
|
||||
</section>
|
||||
</template>
|
||||
<t-empty v-else :description="loading ? '正在加载订单' : '订单不存在'" />
|
||||
</div>
|
||||
</div>
|
||||
</t-form-item>
|
||||
</t-form>
|
||||
<t-form
|
||||
v-if="order.itemList?.length"
|
||||
class="form card product"
|
||||
title="订单明细"
|
||||
theme="card"
|
||||
label-width="0"
|
||||
v-entrance-transition
|
||||
>
|
||||
<t-form-item class="form-item" v-for="item in order.itemList" :key="item.id">
|
||||
<div class="item">
|
||||
<div class="header">
|
||||
<div class="left">
|
||||
<t-image
|
||||
v-if="getProductPhotoURL(item)"
|
||||
:src="getProductPhotoURL(item)"
|
||||
:alt="item.productNameSnapshot || '产品图片'"
|
||||
fit="cover"
|
||||
class="avatar"
|
||||
/>
|
||||
<div
|
||||
v-else
|
||||
class="avatar fallback"
|
||||
v-text="(item.productNameSnapshot || '产').slice(0, 1)"
|
||||
/>
|
||||
</div>
|
||||
<div class="main">
|
||||
<div class="title">
|
||||
<div class="name-gift">
|
||||
<span class="name text-bold" v-text="item.productNameSnapshot || '未命名产品'" />
|
||||
<t-tag v-if="item.gifted" size="small" theme="success" content="赠送" />
|
||||
</div>
|
||||
<t-tag
|
||||
:content="getItemFulfillmentStatus(item).text"
|
||||
:theme="getItemFulfillmentStatus(item).theme"
|
||||
variant="light-outline"
|
||||
/>
|
||||
</div>
|
||||
<div class="description">
|
||||
<strong
|
||||
v-if="item.lineAmount !== null && item.lineAmount !== undefined"
|
||||
class="red"
|
||||
v-text="`¥${formatPackageAmount(item.lineAmount)}`"
|
||||
/>
|
||||
<t-tag v-else size="small" content="套餐权益" />
|
||||
<product-sku-tags
|
||||
:product-name="item.productNameSnapshot"
|
||||
:snapshot="item.skuSpecSnapshot"
|
||||
:fallback="item.specSummarySnapshot || item.skuNameSnapshot"
|
||||
:unit="item.unitSnapshot"
|
||||
/>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<div class="content">
|
||||
<div class="metric">
|
||||
<strong v-text="getPackageQuantityText(item.quantity)" />
|
||||
<span>订单数量</span>
|
||||
</div>
|
||||
<div class="metric">
|
||||
<strong :class="getAvailableQuantityClass(item)" v-text="getItemQuantityText(item, item.availableBaseQuantity)" />
|
||||
<span>可履约</span>
|
||||
</div>
|
||||
<div class="metric">
|
||||
<strong :class="getAmountClass(Number(item.pendingBaseQuantity || 0), 'red')" v-text="getItemQuantityText(item, item.pendingBaseQuantity)" />
|
||||
<span>待核销</span>
|
||||
</div>
|
||||
<div class="metric">
|
||||
<strong :class="getFulfilledQuantityClass(item)" v-text="getItemQuantityText(item, item.fulfilledBaseQuantity)" />
|
||||
<span>已履约</span>
|
||||
</div>
|
||||
<div class="metric">
|
||||
<strong :class="getRemainingQuantityClass(item)" v-text="getItemQuantityText(item, item.remainingBaseQuantity)" />
|
||||
<span>剩余</span>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</t-form-item>
|
||||
<t-form-item label="履约记录" arrow @click="toFulfillmentList">
|
||||
查看本单所有履约单
|
||||
</t-form-item>
|
||||
</t-form>
|
||||
<t-button
|
||||
v-if="canCreateFulfillment && canFulfillByPayment && hasFulfillableItems && order.status === 'ACTIVE'"
|
||||
class="cell-button"
|
||||
theme="primary"
|
||||
content="履约产品"
|
||||
@click="toCreateFulfillment"
|
||||
/>
|
||||
<t-cell-group v-if="!isRecycleOrder" class="finance-panel" title="资金摘要" theme="card">
|
||||
<t-cell title="成交金额">
|
||||
<template #note><span :class="getPaymentAmountClass(order.paymentStatus)" v-text="formatPackageAmount(order.saleAmount)" /></template>
|
||||
</t-cell>
|
||||
<t-cell title="已生效收款">
|
||||
<template #note><span :class="getAmountClass(order.paidAmount, 'green')" v-text="formatPackageAmount(order.paidAmount)" /></template>
|
||||
</t-cell>
|
||||
<t-cell title="待核销收款">
|
||||
<template #note><span :class="getAmountClass(order.pendingPaidAmount, 'orange')" v-text="formatPackageAmount(order.pendingPaidAmount)" /></template>
|
||||
</t-cell>
|
||||
<t-cell title="剩余待收款">
|
||||
<template #note><span :class="getRemainingAmountClass(order.unpaidAmount)" v-text="formatPackageAmount(order.unpaidAmount)" /></template>
|
||||
</t-cell>
|
||||
<t-cell title="有效退款">
|
||||
<template #note><span :class="getAmountClass(order.refundedAmount, 'red')" v-text="formatPackageAmount(order.refundedAmount)" /></template>
|
||||
</t-cell>
|
||||
<t-cell title="收款状态" :note="getSalesPaymentStatusText(order.paymentStatus)" />
|
||||
<t-cell v-if="order.paymentStatus === 'PAID'" title="全额实收时间" :note="getPaidAtText(order.paidAt)" />
|
||||
<t-cell title="退款状态" :note="getSalesRefundStatusText(order.refundStatus)" />
|
||||
<t-cell
|
||||
v-if="canReadFund || canReadMyReceive"
|
||||
:title="canReadFund ? '查看全部资金流水' : '查看我的收款申请'"
|
||||
arrow
|
||||
@click="toFundRecords"
|
||||
/>
|
||||
</t-cell-group>
|
||||
<!-- 兑换条款与支付明细在订单详情内展示 -->
|
||||
<recycle-exchange-panel
|
||||
v-if="isRecycleOrder && order.recycleExchangeId"
|
||||
ref="recyclePanel"
|
||||
:exchange-id="order.recycleExchangeId"
|
||||
:order="order"
|
||||
@changed="loadData"
|
||||
@open-rule="toRecycleRule"
|
||||
@open-payments="toRecyclePayments"
|
||||
/>
|
||||
<!-- 展示订单取消信息 -->
|
||||
<t-cell-group v-if="order.status === 'CANCELLED'" class="cancel-info" title="取消记录" theme="card">
|
||||
<t-cell title="取消时间">
|
||||
<template #note>
|
||||
<time-label :timestamp="order.cancelledAt" underline />
|
||||
</template>
|
||||
</t-cell>
|
||||
<t-cell title="取消人" :note="order.cancelOperator?.nick || order.cancelOperator?.name || order.cancelOperatorUserId || '未知'" />
|
||||
<t-cell title="取消原因" :note="order.cancelReason || '未填写'" />
|
||||
</t-cell-group>
|
||||
<section class="actions" v-entrance-transition>
|
||||
<t-button
|
||||
v-if="order.status !== 'CANCELLED' && recyclePanel?.canRegister"
|
||||
theme="primary"
|
||||
@click="toRecycleRegister(order.recycleExchangeId || '')"
|
||||
>登记回收</t-button>
|
||||
<t-button
|
||||
v-if="canReceive"
|
||||
theme="primary"
|
||||
@click="toPayment"
|
||||
>登记收款</t-button>
|
||||
<t-button
|
||||
v-if="canRefund"
|
||||
theme="danger"
|
||||
@click="toRefund"
|
||||
>登记退款</t-button>
|
||||
<t-button
|
||||
v-if="canConfirmNoRefund"
|
||||
theme="default"
|
||||
@click="toNoRefund"
|
||||
>确认无需退款</t-button>
|
||||
<t-button
|
||||
v-if="canCancel"
|
||||
theme="danger"
|
||||
@click="toCancel"
|
||||
>取消订单</t-button>
|
||||
</section>
|
||||
</template>
|
||||
<t-empty v-else :description="loading ? '正在加载订单' : '订单不存在'" />
|
||||
</main>
|
||||
</div>
|
||||
</template>
|
||||
@@ -237,8 +251,9 @@ import SalesOrderAPI from "@/api/SalesOrderAPI";
|
||||
import CustomerProfileCard from "@/components/CustomerProfileCard.vue";
|
||||
import AttachmentSelector from "@/components/attachmentSelector/AttachmentSelector.vue";
|
||||
import ProductSkuTags from "@/components/ProductSkuTags.vue";
|
||||
import RecycleExchangePanel from "@/pages/recycle/components/RecycleExchangePanel.vue";
|
||||
import type { PhotoItem } from "@/types/Photo";
|
||||
import { convertPackageQuantity, formatPackageAmount, getPackageQuantityText } from "@/utils/package";
|
||||
import { comparePackageQuantity, convertPackageQuantity, formatPackageAmount, getPackageQuantityText } from "@/utils/package";
|
||||
import { getAttachmentReadURL } from "@/utils/attachment";
|
||||
import { getErrorMessage } from "@/utils/error";
|
||||
import { emitListDataChanged, listDataEventKeys } from "@/utils/listDataEvents";
|
||||
@@ -251,7 +266,7 @@ import {
|
||||
getStatusTheme
|
||||
} from "@/utils/salesOrder";
|
||||
import { Message } from "@/utils/message";
|
||||
import { gaoRoleCodes, permissionCodes } from "@/utils/permission";
|
||||
import { permissionCodes } from "@/utils/permission";
|
||||
import { useExpandToMaster, usePane } from "timi-tdesign-mobile";
|
||||
import { uploadPhotoList } from "@/utils/photo";
|
||||
|
||||
@@ -274,12 +289,22 @@ function resolveId(): string {
|
||||
|
||||
// 竖屏整页进来后转成横屏:回到列表页并恢复右栏选中,而不是继续停在整页详情
|
||||
useExpandToMaster({
|
||||
path: "/management/sales-orders",
|
||||
path: "/product/sales-orders",
|
||||
id: () => resolveId()
|
||||
});
|
||||
/** 非空说明当前被内联在主从分栏的右栏里 */
|
||||
const pane = usePane();
|
||||
|
||||
/**
|
||||
* 尝试在右栏压入一层子页(分栏的第三层)。
|
||||
*
|
||||
* 接不住时有三种情况:整页打开详情、窄屏、宿主列表没声明子页槽,
|
||||
* 此时返回 false,调用方退回整页跳转。
|
||||
*/
|
||||
function openSub(view: string): boolean {
|
||||
return pane?.openSub(view) ?? false;
|
||||
}
|
||||
|
||||
function goBack(): void {
|
||||
if (pane) {
|
||||
pane.close();
|
||||
@@ -295,17 +320,27 @@ const isEditing = ref(false);
|
||||
const isSaving = ref(false);
|
||||
const editRemark = ref("");
|
||||
const photoItems = ref<PhotoItem[]>([]);
|
||||
const recyclePanel = ref<InstanceType<typeof RecycleExchangePanel>>();
|
||||
const canReadFund = computed(() => userStore.hasPermissions(permissionCodes.fundRecord.read));
|
||||
const canReadMyReceive = computed(() => userStore.hasPermissions(permissionCodes.fundReceive.create));
|
||||
const canUpdate = computed(() => userStore.hasPermissions(permissionCodes.salesOrder.update));
|
||||
/** 回收兑换订单不产生资金流水,服务端也会拒绝,前端不再暴露收款入口 */
|
||||
const isRecycleOrder = computed(() => order.value?.orderType === "RECYCLE");
|
||||
/** 回收兑换订单的备注与照片由兑换单承载,服务端也会拒绝,前端不暴露编辑入口 */
|
||||
const canUpdate = computed(() => !isRecycleOrder.value && userStore.hasPermissions(permissionCodes.salesOrder.update));
|
||||
const canCreateFulfillment = computed(() => userStore.hasPermissions(permissionCodes.orderFulfillment.create));
|
||||
const canReceive = computed(() => !!order.value && order.value.status !== "CANCELLED" && order.value.paymentStatus !== "PAID" && userStore.hasPermissions(permissionCodes.fundReceive.create));
|
||||
const hasFulfillableItems = computed(() => {
|
||||
const itemType = order.value?.orderType === "RECYCLE" ? "RECYCLE_ENTITLEMENT" : order.value?.orderType === "PACKAGE" ? "PACKAGE_ENTITLEMENT" : "DIRECT_PRODUCT";
|
||||
return (order.value?.itemList || []).some(item => item.itemType === itemType && 0 < comparePackageQuantity(item.availableBaseQuantity ?? "0", "0"));
|
||||
});
|
||||
const canReceive = computed(() => !!order.value && !isRecycleOrder.value && order.value.status !== "CANCELLED" && order.value.paymentStatus !== "PAID" && userStore.hasPermissions(permissionCodes.fundReceive.create));
|
||||
const canRefund = computed(() => !!order.value && order.value.status === "CANCELLED" && order.value.refundStatus === "PENDING" && userStore.hasPermissions(permissionCodes.fund.refund));
|
||||
const canConfirmNoRefund = computed(() => !!order.value && order.value.status === "CANCELLED" && order.value.refundStatus === "PENDING" && userStore.hasPermissions(permissionCodes.fund.refund));
|
||||
/** 订单和关联兑换单通过同一入口取消 */
|
||||
const canCancel = computed(() => !!order.value
|
||||
&& (order.value.status === "ACTIVE" || order.value.status === "FULFILLED")
|
||||
&& userStore.hasPermissions(permissionCodes.salesOrder.cancel));
|
||||
const canFulfillByPayment = computed(() => order.value?.paymentStatus === "PAID" || userStore.hasRoles(gaoRoleCodes.storeManager));
|
||||
/** 回收订单的「结清」由回收物支付驱动,paymentStatus 已同步,沿用同一判断 */
|
||||
const canFulfillByPayment = computed(() => order.value?.paymentStatus === "PAID" || userStore.hasPermissions(permissionCodes.orderFulfillment.unsettled));
|
||||
|
||||
function toPhotoItems(attachmentList?: readonly Partial<Attachment>[]): PhotoItem[] {
|
||||
return (attachmentList || [])
|
||||
@@ -420,6 +455,13 @@ async function loadData(): Promise<void> {
|
||||
}
|
||||
}
|
||||
|
||||
async function refreshAfterRecyclePayment(): Promise<void> {
|
||||
if (recyclePanel.value) await recyclePanel.value.reload();
|
||||
else await loadData();
|
||||
}
|
||||
|
||||
defineExpose({ refreshAfterRecyclePayment, refreshOrder: loadData });
|
||||
|
||||
function toEdit(): void {
|
||||
if (!order.value || !canUpdate.value) return;
|
||||
editRemark.value = order.value.remark || "";
|
||||
@@ -469,9 +511,31 @@ async function toEventRecord(): Promise<void> {
|
||||
if (order.value?.sourceEventRecord?.id) await router.push(`/management/registration-event-records/${order.value.sourceEventRecord.id}`);
|
||||
}
|
||||
|
||||
async function toRecycleRule(id: string): Promise<void> {
|
||||
// 分栏时换成「订单详情 + 兑换模板」,右栏换了内容,订单还留在主栏
|
||||
if (id && openSub(`recycle-rule:${id}`)) {
|
||||
return;
|
||||
}
|
||||
await router.push({
|
||||
name: "RecycleRuleDetail",
|
||||
params: { id },
|
||||
query: { transitionDepth: String(getCurrentRouteDepth() + 1) }
|
||||
});
|
||||
}
|
||||
|
||||
async function toRecyclePayments(id: string): Promise<void> {
|
||||
if (id && openSub(`recycle-payments:${id}`)) return;
|
||||
await router.push({ name: "RecyclePaymentList", params: { id } });
|
||||
}
|
||||
|
||||
async function toRecycleRegister(id: string): Promise<void> {
|
||||
if (!id || openSub(`recycle-register:${id}`)) return;
|
||||
await router.push({ name: "RecyclePaymentCreate", params: { id } });
|
||||
}
|
||||
|
||||
async function toFundRecords(): Promise<void> {
|
||||
if (order.value?.id) await router.push({
|
||||
path: "/management/fund-records",
|
||||
path: "/product/fund-records",
|
||||
query: {
|
||||
salesOrderId: order.value.id,
|
||||
transitionDepth: String(getCurrentRouteDepth() + 1)
|
||||
@@ -480,8 +544,14 @@ async function toFundRecords(): Promise<void> {
|
||||
}
|
||||
|
||||
async function toFulfillmentList(): Promise<void> {
|
||||
if (order.value?.id) await router.push({
|
||||
path: "/management/order-fulfillments",
|
||||
if (!order.value?.id) {
|
||||
return;
|
||||
}
|
||||
if (openSub("fulfillments")) {
|
||||
return;
|
||||
}
|
||||
await router.push({
|
||||
path: "/product/order-fulfillments",
|
||||
query: {
|
||||
salesOrderId: order.value.id,
|
||||
dateType: "all",
|
||||
@@ -491,8 +561,14 @@ async function toFulfillmentList(): Promise<void> {
|
||||
}
|
||||
|
||||
async function toCreateFulfillment(): Promise<void> {
|
||||
if (order.value?.id) await router.push({
|
||||
path: "/management/order-fulfillments/create",
|
||||
if (!order.value?.id) {
|
||||
return;
|
||||
}
|
||||
if (openSub("fulfillment-create")) {
|
||||
return;
|
||||
}
|
||||
await router.push({
|
||||
path: "/product/order-fulfillments/create",
|
||||
query: {
|
||||
salesOrderId: order.value.id,
|
||||
transitionDepth: String(getCurrentRouteDepth() + 1)
|
||||
@@ -501,19 +577,20 @@ async function toCreateFulfillment(): Promise<void> {
|
||||
}
|
||||
|
||||
async function toPayment(): Promise<void> {
|
||||
if (order.value?.id) await router.push(`/management/sales-orders/${order.value.id}/payment`);
|
||||
if (order.value?.id) await router.push(`/product/sales-orders/${order.value.id}/payment`);
|
||||
}
|
||||
|
||||
async function toRefund(): Promise<void> {
|
||||
if (order.value?.id) await router.push(`/management/sales-orders/${order.value.id}/refund`);
|
||||
if (order.value?.id) await router.push(`/product/sales-orders/${order.value.id}/refund`);
|
||||
}
|
||||
|
||||
async function toNoRefund(): Promise<void> {
|
||||
if (order.value?.id) await router.push(`/management/sales-orders/${order.value.id}/no-refund`);
|
||||
if (order.value?.id) await router.push(`/product/sales-orders/${order.value.id}/no-refund`);
|
||||
}
|
||||
|
||||
async function toCancel(): Promise<void> {
|
||||
if (order.value?.id) await router.push(`/management/sales-orders/${order.value.id}/cancel`);
|
||||
if (!order.value?.id || openSub("cancel")) return;
|
||||
await router.push(`/product/sales-orders/${order.value.id}/cancel`);
|
||||
}
|
||||
|
||||
function getCurrentRouteDepth(): number {
|
||||
@@ -528,15 +605,18 @@ function getCurrentRouteDepth(): number {
|
||||
}
|
||||
|
||||
onMounted(loadData);
|
||||
onActivated(loadData);
|
||||
watch(() => [props.orderId, route.params.id], loadData);
|
||||
</script>
|
||||
|
||||
<style scoped lang="less">
|
||||
.sales-order-detail {
|
||||
gap: 1rem;
|
||||
padding: 0 0 2rem;
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
|
||||
.tips {
|
||||
color: var(--td-text-color-secondary);
|
||||
font-size: .8125rem;
|
||||
line-height: 1.5;
|
||||
}
|
||||
|
||||
.customer {
|
||||
margin: 0 1rem;
|
||||
|
||||
Reference in New Issue
Block a user