Blame view

src/components/scm/editCouponPropertyPool.vue 5.53 KB
6ec243d6   wuxw   v1.9 点击提交后,成功提示没有...
1
  <template>
71def04c   wuxw   优化优惠
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
    <el-dialog
      :title="$t('couponPropertyPoolManage.edit.title')"
      :visible.sync="visible"
      width="50%"
      @close="handleClose"
    >
      <el-form
        ref="form"
        :model="formData"
        :rules="rules"
        label-width="120px"
      >
        <el-form-item
          :label="$t('couponPropertyPoolManage.edit.couponName')"
          prop="couponName"
        >
          <el-input
            v-model="formData.couponName"
            :placeholder="$t('couponPropertyPoolManage.edit.couponNamePlaceholder')"
          />
        </el-form-item>
  
        <el-form-item
          :label="$t('couponPropertyPoolManage.edit.toType')"
          prop="toType"
        >
          <el-select
            v-model="formData.toType"
            :placeholder="$t('couponPropertyPoolManage.edit.toTypePlaceholder')"
            style="width:100%"
            @change="handleToTypeChange"
          >
            <el-option
              v-for="item in toTypeOptions"
              :key="item.value"
              :label="item.label"
              :value="item.value"
            />
          </el-select>
        </el-form-item>
  
        <el-form-item
          v-for="(item, index) in formData.toTypes"
          :key="index"
          :label="item.name"
        >
          <el-input
            v-model="item.columnValue"
            :placeholder="item.remark"
          />
        </el-form-item>
  
        <el-form-item
          :label="$t('couponPropertyPoolManage.edit.stock')"
          prop="stock"
        >
          <el-input
            v-model="formData.stock"
            :placeholder="$t('couponPropertyPoolManage.edit.stockPlaceholder')"
          />
        </el-form-item>
  
        <el-form-item
          :label="$t('couponPropertyPoolManage.edit.validityDay')"
          prop="validityDay"
        >
          <el-input
            v-model="formData.validityDay"
            :placeholder="$t('couponPropertyPoolManage.edit.validityDayPlaceholder')"
          />
        </el-form-item>
  
        <el-form-item
          :label="$t('couponPropertyPoolManage.edit.remark')"
          prop="remark"
        >
          <el-input
            v-model="formData.remark"
            type="textarea"
            :placeholder="$t('couponPropertyPoolManage.edit.remarkPlaceholder')"
            :rows="3"
          />
        </el-form-item>
      </el-form>
  
      <span slot="footer" class="dialog-footer">
        <el-button @click="visible = false">{{ $t('common.cancel') }}</el-button>
        <el-button type="primary" @click="handleSubmit">{{ $t('common.confirm') }}</el-button>
      </span>
    </el-dialog>
  </template>
  
  <script>
  import { updateCouponPropertyPool, listCouponKey } from '@/api/scm/couponPropertyPoolManageApi'
  import { getCommunityId } from '@/api/community/communityApi'
  
  export default {
    name: 'EditCouponPropertyPool',
    data() {
      return {
        visible: false,
        formData: {
          cppId: '',
          couponName: '',
          fromType: '2002',
          toType: '',
          stock: '',
          validityDay: '',
          remark: '',
          toTypes: [],
          communityId: getCommunityId()
        },
        rules: {
          couponName: [
            { required: true, message: this.$t('couponPropertyPoolManage.validate.couponNameRequired'), trigger: 'blur' },
            { max: 64, message: this.$t('couponPropertyPoolManage.validate.couponNameMaxLength'), trigger: 'blur' }
          ],
          toType: [
            { required: true, message: this.$t('couponPropertyPoolManage.validate.toTypeRequired'), trigger: 'change' }
          ],
          stock: [
            { required: true, message: this.$t('couponPropertyPoolManage.validate.stockRequired'), trigger: 'blur' }
          ],
          validityDay: [
            { required: true, message: this.$t('couponPropertyPoolManage.validate.validityDayRequired'), trigger: 'blur' }
          ],
          remark: [
            { required: true, message: this.$t('couponPropertyPoolManage.validate.remarkRequired'), trigger: 'blur' }
          ],
          cppId: [
            { required: true, message: this.$t('couponPropertyPoolManage.validate.cppIdRequired'), trigger: 'blur' }
          ]
        },
        toTypeOptions: [
          { value: '1011', label: this.$t('couponPropertyPoolManage.toType.shopping') },
          { value: '2002', label: this.$t('couponPropertyPoolManage.toType.payment') },
          { value: '3003', label: this.$t('couponPropertyPoolManage.toType.repair') },
          { value: '4004', label: this.$t('couponPropertyPoolManage.toType.parking') },
          { value: '5005', label: this.$t('couponPropertyPoolManage.toType.charging') }
        ]
      }
    },
    methods: {
      open(row) {
        this.formData = {
          ...this.formData,
          ...row,
          toType: row.toType || ''
        }
        this.formData.toTypes = row.configs || []
        this.visible = true
      },
      handleClose() {
        this.$refs.form.resetFields()
        this.formData.toTypes = []
      },
      async handleToTypeChange(val) {
        if (!val) return
        try {
          const params = {
            beanName: val,
            page: 1,
            row: 100
          }
          const { data } = await listCouponKey(params)
          this.formData.toTypes = data
        } catch (error) {
          console.error('获取优惠券属性失败:', error)
        }
      },
      handleSubmit() {
        this.$refs.form.validate(async valid => {
          if (valid) {
            try {
              await updateCouponPropertyPool(this.formData)
6ec243d6   wuxw   v1.9 点击提交后,成功提示没有...
177
              this.$message.success(this.$t('common.operationSuccess'))
71def04c   wuxw   优化优惠
178
179
180
181
182
183
184
185
186
187
188
              this.visible = false
              this.$emit('success')
            } catch (error) {
              this.$message.error(error.message || this.$t('couponPropertyPoolManage.edit.error'))
            }
          }
        })
      }
    }
  }
  </script>