feat:【ele】【member 会员】优化会员 list、form 相关的代码
This commit is contained in:
@@ -1,2 +1,2 @@
|
||||
export * from './data';
|
||||
export { default as CouponSendForm } from './send-form.vue';
|
||||
export * from './data';
|
||||
@@ -40,9 +40,9 @@ export namespace MallCouponApi {
|
||||
}
|
||||
|
||||
/** 发送优惠券 */
|
||||
export interface SendCoupon {
|
||||
export interface CouponSendReqVO {
|
||||
/** 优惠券编号 */
|
||||
couponId: number;
|
||||
templateId: 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);
|
||||
}
|
||||
|
||||
@@ -0,0 +1,64 @@
|
||||
import type { VbenFormSchema } from '#/adapter/form';
|
||||
import type { VxeGridProps } from '#/adapter/vxe-table';
|
||||
|
||||
import {
|
||||
discountFormat,
|
||||
remainedCountFormat,
|
||||
usePriceFormat,
|
||||
validityTypeFormat,
|
||||
} from '../formatter';
|
||||
|
||||
/** 搜索表单的 schema */
|
||||
export function useFormSchema(): VbenFormSchema[] {
|
||||
return [
|
||||
{
|
||||
component: 'Input',
|
||||
fieldName: 'name',
|
||||
label: '优惠券名称',
|
||||
componentProps: {
|
||||
placeholder: '请输入优惠券名称',
|
||||
clearable: true,
|
||||
},
|
||||
},
|
||||
];
|
||||
}
|
||||
|
||||
/** 表格列配置 */
|
||||
export function useGridColumns(): VxeGridProps['columns'] {
|
||||
return [
|
||||
{
|
||||
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' },
|
||||
},
|
||||
];
|
||||
}
|
||||
@@ -0,0 +1,2 @@
|
||||
export * from './data';
|
||||
export { default as CouponSendForm } from './send-form.vue';
|
||||
@@ -0,0 +1,86 @@
|
||||
<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 { ElMessage } from 'element-plus';
|
||||
|
||||
import { TableAction, useVbenVxeGrid } from '#/adapter/vxe-table';
|
||||
import { sendCoupon } from '#/api/mall/promotion/coupon/coupon';
|
||||
import { getCouponTemplatePage } from '#/api/mall/promotion/coupon/couponTemplate';
|
||||
|
||||
import { useFormSchema, useGridColumns } from './data';
|
||||
|
||||
/** 发送优惠券 */
|
||||
async function handleSendCoupon(row: MallCouponTemplateApi.CouponTemplate) {
|
||||
modalApi.lock();
|
||||
try {
|
||||
await sendCoupon({
|
||||
templateId: row.id,
|
||||
userIds: modalApi.getData().userIds,
|
||||
});
|
||||
ElMessage.success('发送成功');
|
||||
await modalApi.close();
|
||||
} finally {
|
||||
modalApi.unlock();
|
||||
}
|
||||
}
|
||||
|
||||
const [Grid] = useVbenVxeGrid({
|
||||
formOptions: {
|
||||
schema: useFormSchema(),
|
||||
},
|
||||
gridOptions: {
|
||||
columns: useGridColumns(),
|
||||
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({
|
||||
showCancelButton: false,
|
||||
showConfirmButton: false,
|
||||
});
|
||||
</script>
|
||||
|
||||
<template>
|
||||
<Modal title="发送优惠劵" class="w-1/2">
|
||||
<Grid>
|
||||
<template #actions="{ row }">
|
||||
<TableAction
|
||||
:actions="[
|
||||
{
|
||||
label: '发送',
|
||||
type: 'primary',
|
||||
link: true,
|
||||
auth: ['promotion:coupon:send'],
|
||||
onClick: () => handleSendCoupon(row),
|
||||
},
|
||||
]"
|
||||
/>
|
||||
</template>
|
||||
</Grid>
|
||||
</Modal>
|
||||
</template>
|
||||
@@ -12,7 +12,7 @@ import { ACTION_ICON, TableAction, useVbenVxeGrid } from '#/adapter/vxe-table';
|
||||
import { getUserPage } from '#/api/member/user';
|
||||
import { $t } from '#/locales';
|
||||
|
||||
// import { CouponSendForm } from '../../mall/promotion/coupon/components/CouponSendForm.vue';
|
||||
import { CouponSendForm } from '../../mall/promotion/coupon/components';
|
||||
import { useGridColumns, useGridFormSchema } from './data';
|
||||
import BalanceForm from './modules/balance-form.vue';
|
||||
import Form from './modules/form.vue';
|
||||
@@ -42,7 +42,7 @@ const [LevelFormModal, levelFormModalApi] = useVbenModal({
|
||||
});
|
||||
|
||||
const [CouponSendFormModal, couponSendFormModalApi] = useVbenModal({
|
||||
// connectedComponent: CouponSendForm,
|
||||
connectedComponent: CouponSendForm,
|
||||
destroyOnClose: true,
|
||||
});
|
||||
|
||||
@@ -99,17 +99,12 @@ function handleViewDetail(row: MemberUserApi.User) {
|
||||
});
|
||||
}
|
||||
|
||||
// 表格实例
|
||||
const [Grid, gridApi] = useVbenVxeGrid({
|
||||
formOptions: {
|
||||
schema: useGridFormSchema(),
|
||||
},
|
||||
gridOptions: {
|
||||
columns: useGridColumns(),
|
||||
checkboxConfig: {
|
||||
highlight: true,
|
||||
labelField: 'checkbox',
|
||||
},
|
||||
height: 'auto',
|
||||
keepSource: true,
|
||||
proxyConfig: {
|
||||
@@ -125,6 +120,7 @@ const [Grid, gridApi] = useVbenVxeGrid({
|
||||
},
|
||||
rowConfig: {
|
||||
keyField: 'id',
|
||||
isHover: true,
|
||||
},
|
||||
toolbarConfig: {
|
||||
refresh: true,
|
||||
|
||||
Reference in New Issue
Block a user