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
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
| <template>
| <el-bus-crud v-bind="tableConfig" />
| </template>
|
| <script>
| import InputSelect from '@/components/input-select'
| import SelectShopUser from '@/components/coupon/select-shop-user'
| import { couponForm, couponSearchForm, couponColumn } from '@/utils/coupon-form'
| export default {
| data() {
| return {
| tableConfig: {
| url: 'flower/api/v2/coupon/user/page',
| newUrl: 'flower/api/v2/coupon/user',
| viewUrl: 'flower/api/v2/coupon/user',
| viewOnPath: true,
| editUrl: 'flower/api/v2/coupon/user',
| editMethodType: 'put',
| editOnPath: true,
| deleteUrl: 'flower/api/v2/coupon/user',
| deleteMethodType: 'delete',
| deleteOnPath: true,
| dialogNeedRequest: true,
| canEdit: (row) => row.status === 'inactive' || row.status === 'expired',
| canDelete: (row) =>
| row.status === 'inactive' || row.status === 'expired',
| onResetView: (row) => {
| this.$router.push(`${this.$route.path}/${row.id}`)
| },
| operationAttrs: {
| width: 200,
| fixed: 'right',
| },
| columns: [
| ...couponColumn(),
| { label: '发放时间', prop: 'createTime', minWidth: 180 },
| {
| label: '有效期',
| formatter: (row) =>
| row.usageStartDate
| ? `${row.usageStartDate} ~ ${row.usageEndDate || ''}`
| : `发放后${row.usageTimeNum}${row.usageTimeTypeName || ''}`,
| minWidth: 400,
| },
| { label: '状态', prop: 'statusName', minWidth: 120 },
| { label: '操作人', prop: 'createByName', minWidth: 120 },
| ],
| searchForm: [
| {
| type: 'row',
| items: [...couponSearchForm()],
| },
| ],
| form: [
| ...couponForm(),
| {
| label: '发放后有效期:',
| id: 'usageTimeNum',
| component: InputSelect,
| commonRules: true,
| commonFormat: true,
| commonFormatProps: ['usageTimeNum', 'usageTimeType'],
| el: {
| inputAttrs: {
| min: 1,
| max: 99999999,
| precision: 0,
| controls: false,
| },
| selectAttrs: {
| code: 'COUPON_USAGE_TIME_TYPE',
| },
| },
| },
| {
| label: '领取用户:',
| id: 'pointCostomIdList',
| component: SelectShopUser,
| rules: { required: true, message: '请选择领取用户' },
| inputFormat: (row) => {
| if ('customerList' in row) {
| return row.customerList.filter((i) => i)
| }
| },
| outputFormat: (val) => {
| return val?.length ? val.map((i) => i.id) : []
| },
| forceDisabled: true,
| },
| ],
| extraButtons: [
| {
| text: '发布',
| show: (row) => row.status === 'inactive',
| atClick: async (row) => {
| try {
| await this.$elBusUtil.confirm('确定要发布吗?')
| const { code } = await this.$elBusHttp.request(
| `flower/api/v2/coupon/user/active/${row.id}`,
| { method: 'put' }
| )
| if (code === 0) {
| this.$message.success('发布成功')
| }
| } catch (e) {
| return false
| }
| },
| },
| {
| text: '下架',
| show: (row) => row.status === 'active',
| atClick: async (row) => {
| try {
| await this.$elBusUtil.confirm('确定要下架吗?')
| const { code } = await this.$elBusHttp.request(
| `flower/api/v2/coupon/user/expire/${row.id}`,
| { method: 'put' }
| )
| if (code === 0) {
| this.$message.success('下架成功')
| }
| } catch (e) {
| return false
| }
| },
| },
| ],
| },
| }
| },
| head() {
| return {
| title: '用户优惠券',
| }
| },
| }
| </script>
|
|