cloudroam
2025-03-28 cef2bb0eeeb91a22860cf5d23c7348af1ba921dc
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
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
<template>
  <el-bus-crud v-bind="tableConfig" />
</template>
 
<script>
import MemberRule from '@/components/coupon/member-rule.vue'
export default {
  data() {
    return {
      tableConfig: {
        url: 'flower/api/member/list',
        newUrl: 'flower/api/member/new',
        editUrl: 'flower/api/member/edit',
        deleteUrl: 'flower/api/member/delete',
        columns: [
          { label: '序号', type: 'index' },
          { label: '等级名称', prop: 'name' },
          {
            label: '成长值',
            formatter: (row) =>
              `${row.startPoint ?? ''} ~ ${row.endPoint ?? ''}`,
          },
          { label: '等级折扣', prop: 'discountTypeStr' },
          { label: '操作人', prop: 'createName' },
          {
            label: '背景图片',
            formatter: (row) =>
              row.background ? (
                <el-bus-image
                  src={row.background}
                  lazy={true}
                  style="width:50px;height:50px"
                ></el-bus-image>
              ) : null,
          },
          {
            label: '样式图片',
            formatter: (row) =>
              row.pictures ? (
                <el-bus-image
                  src={row.pictures}
                  lazy={true}
                  style="width:50px;height:50px"
                ></el-bus-image>
              ) : null,
          },
          { label: '成长值获取规则', prop: 'growthValueDesc' },
        ],
        beforeOpen: (row, isNew) => {
          if (!isNew) {
            row.consumptionAmountStr = `消费${row.consumptionAmount}元等于${row.growthValue}成长值`
            row.startPointStr = `${
              this.$elBusUtil.isTrueEmpty(row.startPoint) ? '' : row.startPoint
            } ~ ${
              this.$elBusUtil.isTrueEmpty(row.endPoint) ? '' : row.endPoint
            }`
          }
        },
        searchForm: [
          {
            type: 'row',
            items: [{ label: '等级名称:', id: 'name', type: 'input' }],
          },
        ],
        form: [
          {
            label: '会员等级名称:',
            id: 'name',
            type: 'input',
            rules: { required: true, message: '请输入会员等级名称' },
          },
          {
            label: '成长值范围:',
            id: 'startPoint',
            component: 'el-bus-number-range',
            el: {
              unit: '',
              separator: '<= 成长值范围 <',
              controls: false,
              min: 0,
              max: 99999999,
            },
            commonFormat: true,
            commonFormatProps: ['startPoint', 'endPoint'],
            commonRules: true,
            commonRulesLevel: 1,
            str: true,
          },
          {
            label: '折扣类型:',
            id: 'discountType',
            type: 'bus-select-dict',
            el: {
              code: 'DISCOUNT_TYPE',
              style: 'width:100%',
            },
            str: true,
            rules: { required: true, message: '请选择折扣类型' },
            on: {
              change: (e, updateForm) => {
                updateForm({
                  discountRatio: undefined,
                  discountAmount: undefined,
                })
              },
            },
          },
          {
            label: '会员折扣:',
            id: 'discountRatio',
            type: 'input-number',
            el: {
              precision: 0,
              min: 0,
              max: 100,
              controls: false,
            },
            unit: '%',
            rules: {
              required: true,
              message: '请输入会员折扣',
              trigger: 'blur',
            },
            hidden: (row) => row.discountType !== 'ratio',
          },
          {
            label: '会员优惠:',
            id: 'discountAmount',
            type: 'input-number',
            el: {
              precision: 2,
              min: 0,
              max: 99999999,
              controls: false,
            },
            unit: '元/扎',
            rules: {
              required: true,
              message: '请输入会员优惠',
              trigger: 'blur',
            },
            hidden: (row) => row.discountType !== 'amount',
          },
          {
            label: '会员规则:',
            id: 'consumptionAmount',
            component: MemberRule,
            commonRules: true,
            commonFormat: true,
            commonFormatProps: ['consumptionAmount', 'growthValue'],
            str: true,
          },
          {
            label: '降级规则:',
            id: 'downgradeValue',
            type: 'input-number',
            el: {
              precision: 0,
              min: 0,
              max: 99999999,
              controls: false,
            },
            unit: '成长值',
            rules: {
              required: true,
              message: '请输入降级规则',
              trigger: 'blur',
            },
          },
          {
            label: '背景图片:',
            id: 'background',
            type: 'bus-upload',
            el: {
              listType: 'picture-card',
              limit: 1,
              limitSize: 2,
              tipText: '大小不超过2M',
              valueType: 'string',
            },
            forceDisabled: true,
            rules: {
              required: true,
              message: '请上传背景图片',
              trigger: 'blur',
            },
          },
          {
            label: '样式图片:',
            id: 'pictures',
            type: 'bus-upload',
            el: {
              listType: 'picture-card',
              limit: 1,
              limitSize: 2,
              tipText: '大小不超过2M',
              valueType: 'string',
            },
            forceDisabled: true,
            rules: {
              required: true,
              message: '请上传样式图片',
              trigger: 'blur',
            },
          },
          {
            label: '会员成长值获取规则:',
            id: 'growthValueDesc',
            type: 'input',
            el: {
              type: 'textarea',
              rows: 6,
            },
            rules: {
              required: true,
              message: '请输入会员成长值获取规则',
              trigger: 'blur',
            },
          },
        ],
      },
    }
  },
  head() {
    return {
      title: '会员等级',
    }
  },
}
</script>