feat:【antd】【member 会员】迁移 CouponSendForm 组件
This commit is contained in:
@@ -40,9 +40,9 @@ export namespace MallCouponApi {
|
|||||||
}
|
}
|
||||||
|
|
||||||
/** 发送优惠券 */
|
/** 发送优惠券 */
|
||||||
export interface SendCoupon {
|
export interface CouponSendReqVO {
|
||||||
/** 优惠券编号 */
|
/** 优惠券编号 */
|
||||||
couponId: number;
|
templateId: number;
|
||||||
/** 用户编号数组 */
|
/** 用户编号数组 */
|
||||||
userIds: number[];
|
userIds: number[];
|
||||||
}
|
}
|
||||||
@@ -62,6 +62,6 @@ export function getCouponPage(params: PageParam) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
/** 发送优惠券 */
|
/** 发送优惠券 */
|
||||||
export function sendCoupon(data: MallCouponApi.SendCoupon) {
|
export function sendCoupon(data: MallCouponApi.CouponSendReqVO) {
|
||||||
return requestClient.post('/promotion/coupon/send', data);
|
return requestClient.post('/promotion/coupon/send', data);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -0,0 +1,134 @@
|
|||||||
|
<script lang="ts" setup>
|
||||||
|
import type { VxeGridProps } from '#/adapter/vxe-table';
|
||||||
|
import type { MallCouponTemplateApi } from '#/api/mall/promotion/coupon/couponTemplate';
|
||||||
|
|
||||||
|
import { useVbenModal } from '@vben/common-ui';
|
||||||
|
import { CouponTemplateTakeTypeEnum } from '@vben/constants';
|
||||||
|
|
||||||
|
import { message } from 'ant-design-vue';
|
||||||
|
|
||||||
|
import { TableAction, useVbenVxeGrid } from '#/adapter/vxe-table';
|
||||||
|
import { sendCoupon } from '#/api/mall/promotion/coupon/coupon';
|
||||||
|
import { getCouponTemplatePage } from '#/api/mall/promotion/coupon/couponTemplate';
|
||||||
|
|
||||||
|
import {
|
||||||
|
discountFormat,
|
||||||
|
remainedCountFormat,
|
||||||
|
usePriceFormat,
|
||||||
|
validityTypeFormat,
|
||||||
|
} from '../formatter';
|
||||||
|
|
||||||
|
/** 发送优惠券 */
|
||||||
|
async function handleSendCoupon(row: MallCouponTemplateApi.CouponTemplate) {
|
||||||
|
modalApi.lock();
|
||||||
|
try {
|
||||||
|
await sendCoupon({
|
||||||
|
templateId: row.id,
|
||||||
|
userIds: modalApi.getData().userIds,
|
||||||
|
});
|
||||||
|
message.success('发送成功');
|
||||||
|
await modalApi.close();
|
||||||
|
} finally {
|
||||||
|
modalApi.unlock();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
const [Grid] = useVbenVxeGrid({
|
||||||
|
formOptions: {
|
||||||
|
// TODO @AI:挪到 data.ts
|
||||||
|
schema: [
|
||||||
|
{
|
||||||
|
component: 'Input',
|
||||||
|
fieldName: 'name',
|
||||||
|
label: '优惠券名称',
|
||||||
|
componentProps: {
|
||||||
|
placeholder: '请输入优惠券名称',
|
||||||
|
allowClear: true,
|
||||||
|
},
|
||||||
|
},
|
||||||
|
],
|
||||||
|
},
|
||||||
|
gridOptions: {
|
||||||
|
// TODO @AI:挪到 data.ts
|
||||||
|
columns: [
|
||||||
|
{
|
||||||
|
title: '优惠券名称',
|
||||||
|
field: 'name',
|
||||||
|
minWidth: 120,
|
||||||
|
},
|
||||||
|
{
|
||||||
|
title: '优惠金额 / 折扣',
|
||||||
|
field: 'discount',
|
||||||
|
minWidth: 120,
|
||||||
|
formatter: ({ row }) => discountFormat(row),
|
||||||
|
},
|
||||||
|
{
|
||||||
|
title: '最低消费',
|
||||||
|
field: 'usePrice',
|
||||||
|
minWidth: 100,
|
||||||
|
formatter: ({ row }) => usePriceFormat(row),
|
||||||
|
},
|
||||||
|
{
|
||||||
|
title: '有效期限',
|
||||||
|
field: 'validityType',
|
||||||
|
minWidth: 140,
|
||||||
|
formatter: ({ row }) => validityTypeFormat(row),
|
||||||
|
},
|
||||||
|
{
|
||||||
|
title: '剩余数量',
|
||||||
|
minWidth: 100,
|
||||||
|
formatter: ({ row }) => remainedCountFormat(row),
|
||||||
|
},
|
||||||
|
{
|
||||||
|
title: '操作',
|
||||||
|
width: 100,
|
||||||
|
fixed: 'right',
|
||||||
|
slots: { default: 'actions' },
|
||||||
|
},
|
||||||
|
],
|
||||||
|
height: 500,
|
||||||
|
keepSource: true,
|
||||||
|
proxyConfig: {
|
||||||
|
ajax: {
|
||||||
|
query: async ({ page }, formValues) => {
|
||||||
|
return await getCouponTemplatePage({
|
||||||
|
pageNo: page.currentPage,
|
||||||
|
pageSize: page.pageSize,
|
||||||
|
...formValues,
|
||||||
|
canTakeTypes: [CouponTemplateTakeTypeEnum.ADMIN.type],
|
||||||
|
});
|
||||||
|
},
|
||||||
|
},
|
||||||
|
},
|
||||||
|
rowConfig: {
|
||||||
|
keyField: 'id',
|
||||||
|
isHover: true,
|
||||||
|
},
|
||||||
|
toolbarConfig: {
|
||||||
|
refresh: true,
|
||||||
|
search: true,
|
||||||
|
},
|
||||||
|
} as VxeGridProps<MallCouponTemplateApi.CouponTemplate>,
|
||||||
|
});
|
||||||
|
|
||||||
|
const [Modal, modalApi] = useVbenModal({});
|
||||||
|
</script>
|
||||||
|
|
||||||
|
<template>
|
||||||
|
<Modal title="发送优惠劵" class="w-1/2">
|
||||||
|
<Grid>
|
||||||
|
<template #actions="{ row }">
|
||||||
|
<TableAction
|
||||||
|
:actions="[
|
||||||
|
{
|
||||||
|
label: '发送',
|
||||||
|
type: 'link',
|
||||||
|
auth: ['promotion:coupon:send'],
|
||||||
|
onClick: () => handleSendCoupon(row),
|
||||||
|
},
|
||||||
|
]"
|
||||||
|
/>
|
||||||
|
</template>
|
||||||
|
</Grid>
|
||||||
|
</Modal>
|
||||||
|
</template>
|
||||||
@@ -6,11 +6,13 @@ import { ref } from 'vue';
|
|||||||
import { useRouter } from 'vue-router';
|
import { useRouter } from 'vue-router';
|
||||||
|
|
||||||
import { DocAlert, Page, useVbenModal } from '@vben/common-ui';
|
import { DocAlert, Page, useVbenModal } from '@vben/common-ui';
|
||||||
|
import { isEmpty } from '@vben/utils';
|
||||||
|
|
||||||
import { ACTION_ICON, TableAction, useVbenVxeGrid } from '#/adapter/vxe-table';
|
import { ACTION_ICON, TableAction, useVbenVxeGrid } from '#/adapter/vxe-table';
|
||||||
import { getUserPage } from '#/api/member/user';
|
import { getUserPage } from '#/api/member/user';
|
||||||
import { $t } from '#/locales';
|
import { $t } from '#/locales';
|
||||||
|
|
||||||
|
import CouponSendForm from '../../mall/promotion/coupon/components/CouponSendForm.vue';
|
||||||
import { useGridColumns, useGridFormSchema } from './data';
|
import { useGridColumns, useGridFormSchema } from './data';
|
||||||
import BalanceForm from './modules/balance-form.vue';
|
import BalanceForm from './modules/balance-form.vue';
|
||||||
import Form from './modules/form.vue';
|
import Form from './modules/form.vue';
|
||||||
@@ -39,6 +41,11 @@ const [LevelFormModal, levelFormModalApi] = useVbenModal({
|
|||||||
destroyOnClose: true,
|
destroyOnClose: true,
|
||||||
});
|
});
|
||||||
|
|
||||||
|
const [CouponSendFormModal, couponSendFormModalApi] = useVbenModal({
|
||||||
|
connectedComponent: CouponSendForm,
|
||||||
|
destroyOnClose: true,
|
||||||
|
});
|
||||||
|
|
||||||
/** 刷新表格 */
|
/** 刷新表格 */
|
||||||
function handleRefresh() {
|
function handleRefresh() {
|
||||||
gridApi.query();
|
gridApi.query();
|
||||||
@@ -65,9 +72,12 @@ function handleUpdateBalance(row: MemberUserApi.User) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
/** 发送优惠券 */
|
/** 发送优惠券 */
|
||||||
// TODO @xingyu:这个功能没开发对,是发送优惠劵哈;
|
async function handleSendCoupon() {
|
||||||
function handleSendCoupon() {
|
couponSendFormModalApi
|
||||||
formModalApi.setData(null).open();
|
.setData({
|
||||||
|
userIds: checkedIds.value,
|
||||||
|
})
|
||||||
|
.open();
|
||||||
}
|
}
|
||||||
|
|
||||||
const checkedIds = ref<number[]>([]);
|
const checkedIds = ref<number[]>([]);
|
||||||
@@ -137,6 +147,7 @@ const [Grid, gridApi] = useVbenVxeGrid({
|
|||||||
<PointFormModal @success="handleRefresh" />
|
<PointFormModal @success="handleRefresh" />
|
||||||
<BalanceFormModal @success="handleRefresh" />
|
<BalanceFormModal @success="handleRefresh" />
|
||||||
<LevelFormModal @success="handleRefresh" />
|
<LevelFormModal @success="handleRefresh" />
|
||||||
|
<CouponSendFormModal />
|
||||||
<Grid table-title="会员列表">
|
<Grid table-title="会员列表">
|
||||||
<template #toolbar-tools>
|
<template #toolbar-tools>
|
||||||
<TableAction
|
<TableAction
|
||||||
@@ -145,6 +156,7 @@ const [Grid, gridApi] = useVbenVxeGrid({
|
|||||||
label: '发送优惠券',
|
label: '发送优惠券',
|
||||||
type: 'primary',
|
type: 'primary',
|
||||||
icon: 'lucide:mouse-pointer-2',
|
icon: 'lucide:mouse-pointer-2',
|
||||||
|
disabled: isEmpty(checkedIds),
|
||||||
auth: ['promotion:coupon:send'],
|
auth: ['promotion:coupon:send'],
|
||||||
onClick: handleSendCoupon,
|
onClick: handleSendCoupon,
|
||||||
},
|
},
|
||||||
|
|||||||
Reference in New Issue
Block a user