feat:【mall 商城】售后退款(20% antd detail grid 相关的几个描述)
This commit is contained in:
@@ -1,5 +1,7 @@
|
|||||||
import type { PageParam, PageResult } from '@vben/request';
|
import type { PageParam, PageResult } from '@vben/request';
|
||||||
|
|
||||||
|
import type { MallOrderApi } from '#/api/mall/trade/order';
|
||||||
|
|
||||||
import { requestClient } from '#/api/request';
|
import { requestClient } from '#/api/request';
|
||||||
|
|
||||||
export namespace MallAfterSaleApi {
|
export namespace MallAfterSaleApi {
|
||||||
@@ -75,6 +77,9 @@ export namespace MallAfterSaleApi {
|
|||||||
receiveTime?: Date;
|
receiveTime?: Date;
|
||||||
/** 收货备注 */
|
/** 收货备注 */
|
||||||
receiveReason?: string;
|
receiveReason?: string;
|
||||||
|
order?: MallOrderApi.Order; // 关联订单
|
||||||
|
orderItem?: MallOrderApi.OrderItem; // 关联订单项
|
||||||
|
logs?: any[]; // 关联售后日志
|
||||||
}
|
}
|
||||||
|
|
||||||
/** 拒绝售后请求 */
|
/** 拒绝售后请求 */
|
||||||
|
|||||||
@@ -173,91 +173,53 @@ export function useRefundStatusSchema(): DescriptionItemSchema[] {
|
|||||||
];
|
];
|
||||||
}
|
}
|
||||||
|
|
||||||
/** 商品信息 schema */
|
/** 商品信息 columns */
|
||||||
export function useProductInfoSchema() {
|
export function useProductColumns() {
|
||||||
return {
|
return [
|
||||||
columns: [
|
{
|
||||||
{
|
field: 'spuName',
|
||||||
field: 'spuName',
|
title: '商品信息',
|
||||||
title: '商品',
|
minWidth: 300,
|
||||||
width: 'auto',
|
slots: { default: 'spuName' },
|
||||||
formatter: ({ row }) => {
|
},
|
||||||
const properties = (row.properties || [])
|
{
|
||||||
.map(
|
field: 'price',
|
||||||
(property: any) =>
|
title: '商品原价',
|
||||||
`${property.propertyName}: ${property.valueName}`,
|
minWidth: 150,
|
||||||
)
|
formatter: 'formatFenToYuanAmount',
|
||||||
.join(', ');
|
},
|
||||||
return `${row.spuName}${properties ? ` (${properties})` : ''}`;
|
{
|
||||||
},
|
field: 'count',
|
||||||
},
|
title: '数量',
|
||||||
{
|
minWidth: 100,
|
||||||
field: 'price',
|
},
|
||||||
title: '商品原价',
|
{
|
||||||
width: 150,
|
field: 'payPrice',
|
||||||
formatter: ({ cellValue }) => `${fenToYuan(cellValue)} 元`,
|
title: '合计',
|
||||||
},
|
minWidth: 150,
|
||||||
{
|
formatter: 'formatFenToYuanAmount',
|
||||||
field: 'count',
|
},
|
||||||
title: '数量',
|
];
|
||||||
width: 100,
|
|
||||||
},
|
|
||||||
{
|
|
||||||
field: 'payPrice',
|
|
||||||
title: '合计',
|
|
||||||
width: 150,
|
|
||||||
formatter: ({ cellValue }) => `${fenToYuan(cellValue)} 元`,
|
|
||||||
},
|
|
||||||
],
|
|
||||||
data: [],
|
|
||||||
pagination: false,
|
|
||||||
border: true,
|
|
||||||
size: 'small',
|
|
||||||
};
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/** 操作日志 schema */
|
/** 操作日志 columns */
|
||||||
export function useOperateLogSchema() {
|
export function useOperateLogSchema() {
|
||||||
return {
|
return [
|
||||||
columns: [
|
{
|
||||||
{
|
field: 'createTime',
|
||||||
field: 'createTime',
|
title: '操作时间',
|
||||||
title: '操作时间',
|
width: 180,
|
||||||
width: 180,
|
formatter: 'formatDateTime',
|
||||||
formatter: ({ cellValue }) => formatDate(cellValue),
|
},
|
||||||
},
|
{
|
||||||
{
|
field: 'userType',
|
||||||
field: 'content',
|
title: '操作人',
|
||||||
title: '操作内容',
|
width: 100,
|
||||||
width: 'auto',
|
slots: { default: 'userType' },
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
field: 'userType',
|
field: 'content',
|
||||||
title: '操作人',
|
title: '操作内容',
|
||||||
width: 80,
|
},
|
||||||
formatter: ({ cellValue }) => {
|
];
|
||||||
const userTypeLabels: Record<number, string> = {
|
|
||||||
1: '管',
|
|
||||||
2: '商',
|
|
||||||
3: '买',
|
|
||||||
};
|
|
||||||
return userTypeLabels[cellValue || 0] || '系';
|
|
||||||
},
|
|
||||||
},
|
|
||||||
],
|
|
||||||
data: [],
|
|
||||||
pagination: false,
|
|
||||||
border: true,
|
|
||||||
size: 'small',
|
|
||||||
};
|
|
||||||
}
|
|
||||||
|
|
||||||
/** 获得用户类型颜色 */
|
|
||||||
export function getUserTypeColor(type: number): string {
|
|
||||||
const colorMap: Record<number, string> = {
|
|
||||||
1: '#1890ff', // 蓝色
|
|
||||||
2: '#52c41a', // 绿色
|
|
||||||
3: '#fa8c16', // 橙色
|
|
||||||
};
|
|
||||||
return colorMap[type] || '#1890ff';
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,28 +1,30 @@
|
|||||||
<script setup lang="ts">
|
<script setup lang="ts">
|
||||||
|
import type { VxeTableGridOptions } from '#/adapter/vxe-table';
|
||||||
import type { MallAfterSaleApi } from '#/api/mall/trade/afterSale';
|
import type { MallAfterSaleApi } from '#/api/mall/trade/afterSale';
|
||||||
import type { MallOrderApi } from '#/api/mall/trade/order';
|
import type { MallOrderApi } from '#/api/mall/trade/order';
|
||||||
|
|
||||||
import { h, onMounted, ref } from 'vue';
|
import { onMounted, ref } from 'vue';
|
||||||
import { useRoute, useRouter } from 'vue-router';
|
import { useRoute, useRouter } from 'vue-router';
|
||||||
|
|
||||||
import { Page, useVbenModal } from '@vben/common-ui';
|
import { Page, useVbenModal } from '@vben/common-ui';
|
||||||
import { DICT_TYPE } from '@vben/constants';
|
import { DICT_TYPE } from '@vben/constants';
|
||||||
import { getDictLabel, useTabs } from '@vben/hooks';
|
import { useTabs } from '@vben/hooks';
|
||||||
import { $t } from '@vben/locales';
|
import { $t } from '@vben/locales';
|
||||||
|
|
||||||
import { Card, message, Modal, Timeline } from 'ant-design-vue';
|
import { Card, message, Modal, Tag } from 'ant-design-vue';
|
||||||
|
|
||||||
import { useVbenVxeGrid } from '#/adapter/vxe-table';
|
import { useVbenVxeGrid } from '#/adapter/vxe-table';
|
||||||
|
// TODO @AI:移除 AfterSaleApi,直接换成 api
|
||||||
import * as AfterSaleApi from '#/api/mall/trade/afterSale/index';
|
import * as AfterSaleApi from '#/api/mall/trade/afterSale/index';
|
||||||
import { useDescription } from '#/components/description';
|
import { useDescription } from '#/components/description';
|
||||||
|
import { DictTag } from '#/components/dict-tag';
|
||||||
import { TableAction } from '#/components/table-action';
|
import { TableAction } from '#/components/table-action';
|
||||||
|
|
||||||
import {
|
import {
|
||||||
getUserTypeColor,
|
|
||||||
useAfterSaleInfoSchema,
|
useAfterSaleInfoSchema,
|
||||||
useOperateLogSchema,
|
useOperateLogSchema,
|
||||||
useOrderInfoSchema,
|
useOrderInfoSchema,
|
||||||
useProductInfoSchema,
|
useProductColumns,
|
||||||
useRefundStatusSchema,
|
useRefundStatusSchema,
|
||||||
} from './data';
|
} from './data';
|
||||||
|
|
||||||
@@ -35,9 +37,9 @@ const tabs = useTabs();
|
|||||||
const loading = ref(false);
|
const loading = ref(false);
|
||||||
const afterSaleId = ref(0);
|
const afterSaleId = ref(0);
|
||||||
const afterSale = ref<MallAfterSaleApi.AfterSale>({
|
const afterSale = ref<MallAfterSaleApi.AfterSale>({
|
||||||
order: {} as MallOrderApi.Order,
|
order: {},
|
||||||
orderItem: {} as MallOrderApi.OrderItem,
|
orderItem: {},
|
||||||
logs: [] as any[],
|
logs: [],
|
||||||
});
|
});
|
||||||
|
|
||||||
const [OrderDescriptions] = useDescription({
|
const [OrderDescriptions] = useDescription({
|
||||||
@@ -67,20 +69,38 @@ const [RefundStatusDescriptions] = useDescription({
|
|||||||
schema: useRefundStatusSchema(),
|
schema: useRefundStatusSchema(),
|
||||||
});
|
});
|
||||||
|
|
||||||
// TODO @AI:只把 columns 拿出去
|
const [ProductGrid, productGridApi] = useVbenVxeGrid({
|
||||||
const [ProductGrid] = useVbenVxeGrid({
|
|
||||||
gridOptions: {
|
gridOptions: {
|
||||||
...useProductInfoSchema(),
|
cellConfig: {
|
||||||
class: 'mt-4',
|
height: 60,
|
||||||
},
|
},
|
||||||
|
columns: useProductColumns(),
|
||||||
|
data: [],
|
||||||
|
height: 'auto',
|
||||||
|
border: true,
|
||||||
|
pagerConfig: {
|
||||||
|
enabled: false,
|
||||||
|
},
|
||||||
|
toolbarConfig: {
|
||||||
|
refresh: true,
|
||||||
|
search: true,
|
||||||
|
},
|
||||||
|
} as VxeTableGridOptions<MallOrderApi.OrderItem>,
|
||||||
});
|
});
|
||||||
|
|
||||||
// TODO @AI:只把 columns 拿出去
|
const [OperateLogGrid, operateLogGridApi] = useVbenVxeGrid({
|
||||||
const [OperateLogGrid] = useVbenVxeGrid({
|
|
||||||
gridOptions: {
|
gridOptions: {
|
||||||
...useOperateLogSchema(),
|
columns: useOperateLogSchema(),
|
||||||
class: 'mt-4',
|
data: [],
|
||||||
},
|
border: true,
|
||||||
|
pagerConfig: {
|
||||||
|
enabled: false,
|
||||||
|
},
|
||||||
|
toolbarConfig: {
|
||||||
|
refresh: true,
|
||||||
|
search: true,
|
||||||
|
},
|
||||||
|
} as VxeTableGridOptions,
|
||||||
});
|
});
|
||||||
|
|
||||||
const [DisagreeModal, disagreeModalApi] = useVbenModal({
|
const [DisagreeModal, disagreeModalApi] = useVbenModal({
|
||||||
@@ -99,15 +119,10 @@ async function getDetail() {
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
afterSale.value = res;
|
afterSale.value = res;
|
||||||
|
await productGridApi.setGridOptions({ data: [afterSale.value.orderItem] });
|
||||||
// 更新商品信息
|
await operateLogGridApi.setGridOptions({
|
||||||
if (res.orderItem) {
|
data: afterSale.value.logs || [],
|
||||||
ProductGrid.api?.reload([res.orderItem]);
|
});
|
||||||
}
|
|
||||||
// 更新操作日志
|
|
||||||
if (res.logs) {
|
|
||||||
OperateLogGrid.api?.reload(res.logs);
|
|
||||||
}
|
|
||||||
} finally {
|
} finally {
|
||||||
loading.value = false;
|
loading.value = false;
|
||||||
}
|
}
|
||||||
@@ -240,59 +255,6 @@ function getActionButtons() {
|
|||||||
return buttons;
|
return buttons;
|
||||||
}
|
}
|
||||||
|
|
||||||
/** 渲染操作日志时间线 */
|
|
||||||
function renderTimeline() {
|
|
||||||
return afterSale.value.logs?.map((log: any) => ({
|
|
||||||
key: log.id,
|
|
||||||
children: [
|
|
||||||
h(
|
|
||||||
'div',
|
|
||||||
{
|
|
||||||
style: {
|
|
||||||
backgroundColor: '#f5f5f5',
|
|
||||||
padding: '10px',
|
|
||||||
borderRadius: '4px',
|
|
||||||
position: 'relative',
|
|
||||||
marginLeft: '10px',
|
|
||||||
},
|
|
||||||
},
|
|
||||||
[
|
|
||||||
h('div', log.content),
|
|
||||||
h('div', {
|
|
||||||
style: {
|
|
||||||
position: 'absolute',
|
|
||||||
left: '-16px',
|
|
||||||
top: '10px',
|
|
||||||
width: 0,
|
|
||||||
height: 0,
|
|
||||||
borderTop: '8px solid transparent',
|
|
||||||
borderBottom: '8px solid transparent',
|
|
||||||
borderRight: '8px solid #f5f5f5',
|
|
||||||
},
|
|
||||||
}),
|
|
||||||
],
|
|
||||||
),
|
|
||||||
],
|
|
||||||
dot: h(
|
|
||||||
'span',
|
|
||||||
{
|
|
||||||
style: {
|
|
||||||
display: 'inline-flex',
|
|
||||||
alignItems: 'center',
|
|
||||||
justifyContent: 'center',
|
|
||||||
width: '20px',
|
|
||||||
height: '20px',
|
|
||||||
fontSize: '10px',
|
|
||||||
color: '#fff',
|
|
||||||
borderRadius: '50%',
|
|
||||||
backgroundColor: getUserTypeColor(log.userType ?? 0),
|
|
||||||
},
|
|
||||||
},
|
|
||||||
getDictLabel(DICT_TYPE.USER_TYPE, log.userType)?.[0] || '系',
|
|
||||||
),
|
|
||||||
}));
|
|
||||||
}
|
|
||||||
|
|
||||||
onMounted(() => {
|
onMounted(() => {
|
||||||
afterSaleId.value = Number(route.params.id);
|
afterSaleId.value = Number(route.params.id);
|
||||||
getDetail();
|
getDetail();
|
||||||
@@ -301,7 +263,9 @@ onMounted(() => {
|
|||||||
|
|
||||||
<template>
|
<template>
|
||||||
<Page auto-content-height :title="afterSale.no" :loading="loading">
|
<Page auto-content-height :title="afterSale.no" :loading="loading">
|
||||||
|
<!-- TODO @AI:晚点搞;
|
||||||
<DisagreeModal @success="getDetail" />
|
<DisagreeModal @success="getDetail" />
|
||||||
|
-->
|
||||||
|
|
||||||
<!-- TODO @AI:直接写,不用 getActionButtons;按钮是否展示,使用 ifShow -->
|
<!-- TODO @AI:直接写,不用 getActionButtons;按钮是否展示,使用 ifShow -->
|
||||||
<template #extra>
|
<template #extra>
|
||||||
@@ -321,14 +285,32 @@ onMounted(() => {
|
|||||||
<RefundStatusDescriptions :data="afterSale" />
|
<RefundStatusDescriptions :data="afterSale" />
|
||||||
</Card>
|
</Card>
|
||||||
<!-- 商品信息 -->
|
<!-- 商品信息 -->
|
||||||
<Card class="mb-4" title="商品信息">
|
<div class="mb-4">
|
||||||
<ProductGrid />
|
<ProductGrid table-title="商品信息">
|
||||||
</Card>
|
<template #spuName="{ row }">
|
||||||
|
<div class="flex flex-1 flex-col items-start gap-1 gap-2 text-left">
|
||||||
|
<span class="text-sm">{{ row.spuName }}</span>
|
||||||
|
<div class="flex flex-wrap gap-1">
|
||||||
|
<Tag
|
||||||
|
v-for="property in row.properties"
|
||||||
|
:key="property.propertyId!"
|
||||||
|
size="small"
|
||||||
|
>
|
||||||
|
{{ property.propertyName }}: {{ property.valueName }}
|
||||||
|
</Tag>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</template>
|
||||||
|
</ProductGrid>
|
||||||
|
</div>
|
||||||
<!-- 操作日志 -->
|
<!-- 操作日志 -->
|
||||||
<Card class="mb-4" title="售后日志">
|
<div>
|
||||||
<div style="margin-left: 160px">
|
<OperateLogGrid table-title="售后日志">
|
||||||
<Timeline :items="renderTimeline()" />
|
<template #userType="{ row }">
|
||||||
</div>
|
<Tag v-if="row.userId === 0" color="default">系统</Tag>
|
||||||
</Card>
|
<DictTag v-else :type="DICT_TYPE.USER_TYPE" :value="row.userType" />
|
||||||
|
</template>
|
||||||
|
</OperateLogGrid>
|
||||||
|
</div>
|
||||||
</Page>
|
</Page>
|
||||||
</template>
|
</template>
|
||||||
|
|||||||
Reference in New Issue
Block a user