feat:【antd】【member 会员】将 detail 独立目录

This commit is contained in:
YunaiV
2025-10-07 11:25:39 +08:00
parent e546247c0b
commit b9593c7a4a
9 changed files with 9 additions and 9 deletions

View File

@@ -0,0 +1,135 @@
<script setup lang="ts">
import type { MemberUserApi } from '#/api/member/user';
import type { PayWalletApi } from '#/api/pay/wallet/balance';
import { onMounted, ref } from 'vue';
import { useRoute } from 'vue-router';
import { Page, useVbenModal } from '@vben/common-ui';
import { useTabs } from '@vben/hooks';
import { Button, Card, message, TabPane, Tabs } from 'ant-design-vue';
import { getUser } from '#/api/member/user';
import { getWallet } from '#/api/pay/wallet/balance';
import { $t } from '#/locales';
import Form from '../modules/form.vue';
import UserAccountInfo from './modules/user-account-info.vue';
import UserAddressList from './modules/user-address-list.vue';
import UserBalanceList from './modules/user-balance-list.vue';
import UserBasicInfo from './modules/user-basic-info.vue';
import UserExperienceRecordList from './modules/user-experience-record-list.vue';
import UserPointList from './modules/user-point-list.vue';
import UserSignList from './modules/user-sign-list.vue';
const route = useRoute();
const { closeCurrentTab, refreshTab } = useTabs();
const [FormModal, formModalApi] = useVbenModal({
connectedComponent: Form,
destroyOnClose: true,
});
const userId = Number(route.query.id);
const user = ref<MemberUserApi.User>();
const wallet = ref<PayWalletApi.Wallet>();
/* 钱包初始化数据 */
const WALLET_INIT_DATA = {
balance: 0,
totalExpense: 0,
totalRecharge: 0,
} as PayWalletApi.Wallet;
async function getUserDetail() {
if (!userId) {
message.error('参数错误,会员编号不能为空!');
closeCurrentTab();
return;
}
user.value = await getUser(userId);
wallet.value = (await getWallet({ userId })) || WALLET_INIT_DATA;
}
function handleEdit() {
formModalApi.setData(user.value).open();
}
onMounted(async () => {
await getUserDetail();
});
</script>
<template>
<Page auto-content-height>
<FormModal @success="refreshTab" />
<div class="flex">
<UserBasicInfo v-if="user" class="w-3/5" :user="user" mode="member">
<template #title> 基本信息 </template>
<template #extra>
<Button type="primary" @click="handleEdit">
{{ $t('common.edit') }}
</Button>
</template>
</UserBasicInfo>
<UserAccountInfo
v-if="user && wallet"
class="ml-4 w-2/5"
:user="user"
:wallet="wallet"
>
<template #title> 账户信息 </template>
</UserAccountInfo>
</div>
<div class="mt-4">
<Card title="账户明细">
<Tabs>
<TabPane tab="积分" key="UserPointList">
<UserPointList class="h-full" :user-id="userId" />
</TabPane>
<TabPane tab="签到" key="UserSignList">
<UserSignList class="h-full" :user-id="userId" />
</TabPane>
<TabPane tab="成长值" key="UserExperienceRecordList">
<UserExperienceRecordList class="h-full" :user-id="userId" />
</TabPane>
<TabPane tab="余额" key="UserBalanceList">
<UserBalanceList class="h-full" :wallet-id="wallet?.id" />
</TabPane>
<TabPane tab="收货地址" key="UserAddressList">
<UserAddressList class="h-full" :user-id="userId" />
</TabPane>
<TabPane tab="订单管理" key="UserOrderList">
<!-- Todo: 商城模块 -->
<div class="h-full">
<h1>订单管理</h1>
</div>
</TabPane>
<TabPane tab="售后管理" key="UserAfterSaleList">
<!-- Todo: 商城模块 -->
<div class="h-full">
<h1>售后管理</h1>
</div>
</TabPane>
<TabPane tab="收藏记录" key="UserFavoriteList">
<!-- Todo: 商城模块 -->
<div class="h-full">
<h1>收藏记录</h1>
</div>
</TabPane>
<TabPane tab="优惠劵" key="UserCouponList">
<!-- Todo: 商城模块 -->
<div class="h-full">
<h1>优惠劵</h1>
</div>
</TabPane>
<TabPane tab="推广用户" key="UserBrokerageList">
<!-- Todo: 商城模块 -->
<div class="h-full">
<h1>推广用户</h1>
</div>
</TabPane>
</Tabs>
</Card>
</div>
</Page>
</template>

View File

@@ -0,0 +1,83 @@
<script setup lang="ts">
import type { MemberUserApi } from '#/api/member/user';
import type { PayWalletApi } from '#/api/pay/wallet/balance';
import { fenToYuan } from '@vben/utils';
import { Card } from 'ant-design-vue';
import { useDescription } from '#/components/description';
withDefaults(
defineProps<{
mode?: 'kefu' | 'member';
user: MemberUserApi.User;
wallet: PayWalletApi.Wallet;
}>(),
{
mode: 'member',
},
);
const [Descriptions] = useDescription({
componentProps: {
bordered: false,
class: 'mx-4',
},
schema: [
{
field: 'levelName',
label: '等级',
content: (data) => data.levelName || '无',
},
{
field: 'experience',
label: '成长值',
content: (data) => data.experience || 0,
},
{
field: 'point',
label: '当前积分',
content: (data) => data.point || 0,
},
{
field: 'totalPoint',
label: '总积分',
content: (data) => data.totalPoint || 0,
},
{
field: 'balance',
label: '当前余额',
content: (data) => fenToYuan(data.balance || 0),
},
{
field: 'totalExpense',
label: '支出金额',
content: (data) => fenToYuan(data.totalExpense || 0),
},
{
field: 'totalRecharge',
label: '充值金额',
content: (data) => fenToYuan(data.totalRecharge || 0),
},
],
});
</script>
<template>
<Card>
<template #title>
<slot name="title"></slot>
</template>
<template #extra>
<slot name="extra"></slot>
</template>
<Descriptions
:column="mode === 'member' ? 2 : 1"
:data="{
...user,
...wallet,
}"
/>
</Card>
</template>

View File

@@ -0,0 +1,87 @@
<script lang="ts" setup>
import type { VxeTableGridOptions } from '#/adapter/vxe-table';
import type { MemberAddressApi } from '#/api/member/address';
import { h } from 'vue';
import { Tag } from 'ant-design-vue';
import { useVbenVxeGrid } from '#/adapter/vxe-table';
import { getAddressList } from '#/api/member/address';
const props = defineProps<{
userId: number;
}>();
const [Grid] = useVbenVxeGrid({
gridOptions: {
columns: [
{
field: 'id',
title: '地址编号',
},
{
field: 'name',
title: '收件人名称',
},
{
field: 'mobile',
title: '手机号',
},
{
field: 'areaId',
title: '地区编码',
},
{
field: 'detailAddress',
title: '收件详细地址',
},
{
field: 'defaultStatus',
title: '是否默认',
slots: {
default: ({ row }) => {
return h(
Tag,
{
class: 'mr-1',
color: row.defaultStatus ? 'blue' : 'red',
},
() => (row.defaultStatus ? '是' : '否'),
);
},
},
},
{
field: 'createTime',
title: '创建时间',
formatter: 'formatDateTime',
},
],
keepSource: true,
pagerConfig: {
enabled: false,
},
proxyConfig: {
ajax: {
query: async () => {
return await getAddressList({
userId: props.userId,
});
},
},
},
rowConfig: {
keyField: 'id',
},
toolbarConfig: {
refresh: true,
search: true,
},
} as VxeTableGridOptions<MemberAddressApi.Address>,
});
</script>
<template>
<Grid />
</template>

View File

@@ -0,0 +1,68 @@
<script lang="ts" setup>
import type { VxeTableGridOptions } from '#/adapter/vxe-table';
import type { WalletTransactionApi } from '#/api/pay/wallet/transaction';
import { useVbenVxeGrid } from '#/adapter/vxe-table';
import { getTransactionPage } from '#/api/pay/wallet/transaction';
const props = defineProps<{
walletId: number | undefined;
}>();
const [Grid] = useVbenVxeGrid({
gridOptions: {
columns: [
{
field: 'id',
title: '编号',
},
{
field: 'title',
title: '关联业务标题',
},
{
field: 'price',
title: '交易金额',
formatter: 'formatAmount2',
},
{
field: 'balance',
title: '钱包余额',
formatter: 'formatAmount2',
},
{
field: 'createTime',
title: '交易时间',
formatter: 'formatDateTime',
},
],
keepSource: true,
pagerConfig: {
pageSize: 10,
},
proxyConfig: {
ajax: {
query: async ({ page }, formValues) => {
return await getTransactionPage({
pageNo: page.currentPage,
pageSize: page.pageSize,
walletId: props.walletId,
...formValues,
});
},
},
},
rowConfig: {
keyField: 'id',
},
toolbarConfig: {
refresh: true,
search: true,
},
} as VxeTableGridOptions<WalletTransactionApi.Transaction>,
});
</script>
<template>
<Grid />
</template>

View File

@@ -0,0 +1,96 @@
<script setup lang="ts">
import type { MemberUserApi } from '#/api/member/user';
import { h } from 'vue';
import { DICT_TYPE } from '@vben/constants';
import { formatDate } from '@vben/utils';
import { Avatar, Card, Col, Row } from 'ant-design-vue';
import { useDescription } from '#/components/description';
import { DictTag } from '#/components/dict-tag';
withDefaults(
defineProps<{ mode?: 'kefu' | 'member'; user: MemberUserApi.User }>(),
{
mode: 'member',
},
);
const [Descriptions] = useDescription({
componentProps: {
bordered: false,
class: 'mx-4',
},
schema: [
{
field: 'name',
label: '用户名',
},
{
field: 'nickname',
label: '昵称',
},
{
field: 'mobile',
label: '手机号',
},
{
field: 'sex',
label: '性别',
content: (data) =>
h(DictTag, {
type: DICT_TYPE.SYSTEM_USER_SEX,
value: data.sex,
}),
},
{
field: 'areaName',
label: '所在地',
},
{
field: 'registerIp',
label: '注册 IP',
},
{
field: 'birthday',
label: '生日',
content: (data) => formatDate(data.birthday)?.toString() || '空',
},
{
field: 'createTime',
label: '注册时间',
content: (data) => formatDate(data.createTime)?.toString() || '空',
},
{
field: 'loginDate',
label: '最后登录时间',
content: (data) => formatDate(data.loginDate)?.toString() || '空',
},
],
});
</script>
<template>
<Card>
<template #title>
<slot name="title"></slot>
</template>
<template #extra>
<slot name="extra"></slot>
</template>
<Row v-if="mode === 'member'" :gutter="24">
<Col :span="4">
<Avatar :size="140" shape="square" :src="user.avatar" />
</Col>
<Col :span="20">
<Descriptions :column="2" :data="user" />
</Col>
</Row>
<template v-else-if="mode === 'kefu'">
<Avatar :size="140" shape="square" :src="user.avatar" />
<Descriptions :column="1" :data="user" />
</template>
</Card>
</template>

View File

@@ -0,0 +1,134 @@
<script lang="ts" setup>
import type { VxeTableGridOptions } from '#/adapter/vxe-table';
import type { MemberExperienceRecordApi } from '#/api/member/experience-record';
import { h } from 'vue';
import { DICT_TYPE } from '@vben/constants';
import { getDictOptions } from '@vben/hooks';
import { Tag } from 'ant-design-vue';
import { useVbenVxeGrid } from '#/adapter/vxe-table';
import { getExperienceRecordPage } from '#/api/member/experience-record';
import { getRangePickerDefaultProps } from '#/utils';
const props = defineProps<{
userId: number;
}>();
const [Grid] = useVbenVxeGrid({
formOptions: {
schema: [
{
fieldName: 'bizType',
label: '业务类型',
component: 'Select',
componentProps: {
allowClear: true,
options: getDictOptions(
DICT_TYPE.MEMBER_EXPERIENCE_BIZ_TYPE,
'number',
),
},
},
{
fieldName: 'title',
label: '标题',
component: 'Input',
},
{
fieldName: 'createDate',
label: '获得时间',
component: 'RangePicker',
componentProps: {
...getRangePickerDefaultProps(),
allowClear: true,
},
},
],
},
gridOptions: {
columns: [
{
field: 'id',
title: '编号',
},
{
field: 'createTime',
title: '获得时间',
formatter: 'formatDateTime',
},
{
field: 'experience',
title: '经验',
slots: {
default: ({ row }) => {
return h(
Tag,
{
class: 'mr-1',
color: row.experience > 0 ? 'blue' : 'red',
},
() =>
row.experience > 0 ? `+${row.experience}` : row.experience,
);
},
},
},
{
field: 'totalExperience',
title: '总经验',
},
{
field: 'title',
title: '标题',
},
{
field: 'description',
title: '描述',
},
{
field: 'bizId',
title: '业务编号',
},
{
field: 'bizType',
title: '业务类型',
cellRender: {
name: 'CellDict',
props: { type: DICT_TYPE.MEMBER_EXPERIENCE_BIZ_TYPE },
},
},
],
keepSource: true,
pagerConfig: {
pageSize: 10,
},
proxyConfig: {
ajax: {
query: async ({ page }, formValues) => {
return await getExperienceRecordPage({
pageNo: page.currentPage,
pageSize: page.pageSize,
userId: props.userId,
...formValues,
});
},
},
},
rowConfig: {
keyField: 'id',
},
toolbarConfig: {
refresh: true,
search: true,
},
} as VxeTableGridOptions<MemberExperienceRecordApi.ExperienceRecord>,
separator: false,
});
</script>
<template>
<Grid />
</template>

View File

@@ -0,0 +1,77 @@
<script lang="ts" setup>
import type { VxeTableGridOptions } from '#/adapter/vxe-table';
import type { MemberPointRecordApi } from '#/api/member/point/record';
import { useVbenVxeGrid } from '#/adapter/vxe-table';
import { getRecordPage } from '#/api/member/point/record';
import { DICT_TYPE } from '@vben/constants';
import { getDictOptions } from '@vben/hooks';
import { getRangePickerDefaultProps } from '#/utils';
import { useGridColumns } from '#/views/member/point/record/data';
const props = defineProps<{
userId: number;
}>();
const [Grid] = useVbenVxeGrid({
formOptions: {
schema: [
{
fieldName: 'bizType',
label: '业务类型',
component: 'Select',
componentProps: {
allowClear: true,
options: getDictOptions(DICT_TYPE.MEMBER_POINT_BIZ_TYPE, 'number'),
},
},
{
fieldName: 'title',
label: '积分标题',
component: 'Input',
},
{
fieldName: 'createDate',
label: '获得时间',
component: 'RangePicker',
componentProps: {
...getRangePickerDefaultProps(),
allowClear: true,
},
},
],
},
gridOptions: {
columns: useGridColumns(),
keepSource: true,
pagerConfig: {
pageSize: 10,
},
proxyConfig: {
ajax: {
query: async ({ page }, formValues) => {
return await getRecordPage({
pageNo: page.currentPage,
pageSize: page.pageSize,
userId: props.userId,
...formValues,
});
},
},
},
rowConfig: {
keyField: 'id',
},
toolbarConfig: {
refresh: true,
search: true,
},
} as VxeTableGridOptions<MemberPointRecordApi.Record>,
separator: false,
});
</script>
<template>
<Grid />
</template>

View File

@@ -0,0 +1,65 @@
<script lang="ts" setup>
import type { VxeTableGridOptions } from '#/adapter/vxe-table';
import type { MemberSignInRecordApi } from '#/api/member/signin/record';
import { useVbenVxeGrid } from '#/adapter/vxe-table';
import { getSignInRecordPage } from '#/api/member/signin/record';
import { getRangePickerDefaultProps } from '#/utils';
import { useGridColumns } from '#/views/member/signin/record/data';
const props = defineProps<{
userId: number;
}>();
const [Grid] = useVbenVxeGrid({
formOptions: {
schema: [
{
fieldName: 'day',
label: '签到天数',
component: 'Input',
},
{
fieldName: 'createTime',
label: '签到时间',
component: 'RangePicker',
componentProps: {
...getRangePickerDefaultProps(),
allowClear: true,
},
},
],
},
gridOptions: {
columns: useGridColumns(),
keepSource: true,
pagerConfig: {
pageSize: 10,
},
proxyConfig: {
ajax: {
query: async ({ page }, formValues) => {
return await getSignInRecordPage({
pageNo: page.currentPage,
pageSize: page.pageSize,
userId: props.userId,
...formValues,
});
},
},
},
rowConfig: {
keyField: 'id',
},
toolbarConfig: {
refresh: true,
search: true,
},
} as VxeTableGridOptions<MemberSignInRecordApi.SignInRecord>,
separator: false,
});
</script>
<template>
<Grid />
</template>