mayf
2024-09-03 3a68c4380090ce1ded8941ef30d22a8a576ca6a3
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
<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: '成长值', prop: 'startPoint' },
          { label: '等级折扣', prop: 'discountTypeStr' },
          { label: '操作人', prop: 'createName' },
        ],
        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: '<= 成长值范围 <',
              inputAttrs: {
                controls: false,
              },
            },
            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,
              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,
              controls: false,
            },
            unit: '成长值',
            rules: {
              required: true,
              message: '请输入降级规则',
              trigger: 'blur',
            },
          },
        ],
      },
    }
  },
}
</script>