Blame view

src/components/scm/withholdIntegral.vue 5.44 KB
6ed9faf1   wuxw   开发完成优惠下的积分功能
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
  <template>
    <el-dialog
      :title="$t('withholdIntegral.applyWithdraw')"
      :visible.sync="visible"
      width="50%"
      center
    >
      <el-form ref="form" :model="formData" label-width="120px" :rules="rules">
        <el-row>
          <el-col :span="12">
            <el-form-item :label="$t('withholdIntegral.totalPoints')" prop="amount">
              <el-input v-model="formData.amount" disabled />
            </el-form-item>
          </el-col>
          <el-col :span="12">
            <el-form-item :label="$t('withholdIntegral.withdrawPoints')" prop="applyAmount">
              <el-input 
                v-model="formData.applyAmount" 
                :placeholder="$t('withholdIntegral.withdrawPointsPlaceholder')"
              />
            </el-form-item>
          </el-col>
        </el-row>
  
        <el-row>
          <el-col :span="12">
            <el-form-item :label="$t('withholdIntegral.applicant')" prop="applyUserName">
              <el-input 
                v-model="formData.applyUserName" 
                :placeholder="$t('withholdIntegral.applicantPlaceholder')"
              />
            </el-form-item>
          </el-col>
          <el-col :span="12">
            <el-form-item :label="$t('withholdIntegral.applicantPhone')" prop="applyUserTel">
              <el-input 
                v-model="formData.applyUserTel" 
                :placeholder="$t('withholdIntegral.applicantPhonePlaceholder')"
              />
            </el-form-item>
          </el-col>
        </el-row>
  
        <el-row>
          <el-col :span="12">
            <el-form-item :label="$t('withholdIntegral.bankAccount')" prop="bankNum">
              <el-input 
                v-model="formData.bankNum" 
                :placeholder="$t('withholdIntegral.bankAccountPlaceholder')"
              />
            </el-form-item>
          </el-col>
          <el-col :span="12">
            <el-form-item :label="$t('withholdIntegral.accountName')" prop="bankNumName">
              <el-input 
                v-model="formData.bankNumName" 
                :placeholder="$t('withholdIntegral.accountNamePlaceholder')"
              />
            </el-form-item>
          </el-col>
        </el-row>
  
        <el-row>
          <el-col :span="12">
            <el-form-item :label="$t('withholdIntegral.bank')" prop="bankName">
              <el-input 
                v-model="formData.bankName" 
                type="textarea"
                :placeholder="$t('withholdIntegral.bankPlaceholder')"
              />
            </el-form-item>
          </el-col>
          <el-col :span="12">
            <el-form-item :label="$t('withholdIntegral.applicationNote')" prop="remark">
              <el-input 
                v-model="formData.remark" 
                type="textarea"
                :placeholder="$t('withholdIntegral.applicationNotePlaceholder')"
              />
            </el-form-item>
          </el-col>
        </el-row>
      </el-form>
  
      <span slot="footer" class="dialog-footer">
        <el-button @click="close">{{ $t('common.cancel') }}</el-button>
        <el-button type="primary" @click="submit" :loading="loading">
          {{ $t('common.submit') }}
        </el-button>
      </span>
    </el-dialog>
  </template>
  
  <script>
  import { applyIntegralWithdrawal } from '@/api/scm/communityIntegralApi'
  import { getCommunityId } from '@/api/community/communityApi'
  
  export default {
    name: 'WithholdIntegral',
    data() {
      return {
        visible: false,
        loading: false,
        formData: {
          integralId: '',
          integralName: '',
          communityId: '',
          amount: '',
          applyAmount: '',
          applyUserName: '',
          applyUserTel: '',
          remark: '',
          bankNum: '',
          bankNumName: '',
          bankName: ''
        },
        rules: {
          applyAmount: [
            { required: true, message: this.$t('withholdIntegral.withdrawPointsRequired'), trigger: 'blur' }
          ],
          applyUserName: [
            { required: true, message: this.$t('withholdIntegral.applicantRequired'), trigger: 'blur' }
          ],
          applyUserTel: [
            { required: true, message: this.$t('withholdIntegral.applicantPhoneRequired'), trigger: 'blur' }
          ],
          bankNum: [
            { required: true, message: this.$t('withholdIntegral.bankAccountRequired'), trigger: 'blur' }
          ],
          bankNumName: [
            { required: true, message: this.$t('withholdIntegral.accountNameRequired'), trigger: 'blur' }
          ],
          bankName: [
            { required: true, message: this.$t('withholdIntegral.bankRequired'), trigger: 'blur' }
          ]
        }
      }
    },
    methods: {
      open(data) {
        this.resetForm()
        this.formData = {
          ...this.formData,
          ...data,
          communityId: getCommunityId()
        }
        this.visible = true
      },
      close() {
        this.visible = false
        this.loading = false
        this.$refs.form.resetFields()
      },
      resetForm() {
        if (this.$refs.form) {
          this.$refs.form.resetFields()
        }
      },
      async submit() {
        try {
          this.$refs.form.validate(async valid => {
            if (!valid) return
  
            this.loading = true
            await applyIntegralWithdrawal(this.formData)
            this.$emit('success')
            this.$message.success(this.$t('withholdIntegral.applySuccess'))
            this.close()
          })
        } catch (error) {
          console.error('Failed to apply integral withdrawal:', error)
          this.$message.error(this.$t('withholdIntegral.applyFailed'))
        } finally {
          this.loading = false
        }
      }
    }
  }
  </script>
  
  <style scoped>
  .el-textarea {
    width: 100%;
  }
  </style>