1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
| <script lang="ts" setup>
| import type { VxeGridProps } from '#/adapter/vxe-table';
| import type { MallCouponTemplateApi } from '#/api/mall/promotion/coupon/couponTemplate';
|
| import { useVbenModal } from '..\..\..\..\..\packages\effects\common-ui\src';
| import { CouponTemplateTakeTypeEnum } from '..\..\..\..\..\packages\constants\src';
|
| 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 { useFormSchema, useGridColumns } from './send-form-data';
|
| /** 发送优惠券 */
| 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: {
| 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: 'link',
| auth: ['promotion:coupon:send'],
| onClick: () => handleSendCoupon(row),
| },
| ]"
| />
| </template>
| </Grid>
| </Modal>
| </template>
|
|