Blame view

src/components/scm/withholdGold.vue 4.6 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
  <template>
    <el-dialog
      :title="$t('withholdGold.applyWithdraw')"
      :visible.sync="visible"
      width="50%"
      :before-close="handleClose"
    >
      <el-form
        ref="form"
        :model="form"
        :rules="rules"
        label-width="120px"
        label-position="right"
      >
        <el-row>
          <el-col :span="12">
            <el-form-item :label="$t('withholdGold.goldAmount')" prop="amount">
              <el-input v-model="form.amount" disabled />
            </el-form-item>
          </el-col>
          <el-col :span="12">
            <el-form-item :label="$t('withholdGold.withdrawAmount')" prop="applyAmount">
              <el-input v-model="form.applyAmount" />
            </el-form-item>
          </el-col>
        </el-row>
  
        <el-row>
          <el-col :span="12">
            <el-form-item :label="$t('withholdGold.applicant')" prop="applyUserName">
              <el-input v-model="form.applyUserName" />
            </el-form-item>
          </el-col>
          <el-col :span="12">
            <el-form-item :label="$t('withholdGold.applicantPhone')" prop="applyUserTel">
              <el-input v-model="form.applyUserTel" />
            </el-form-item>
          </el-col>
        </el-row>
  
        <el-row>
          <el-col :span="12">
            <el-form-item :label="$t('withholdGold.bankAccount')" prop="bankNum">
              <el-input v-model="form.bankNum" />
            </el-form-item>
          </el-col>
          <el-col :span="12">
            <el-form-item :label="$t('withholdGold.accountName')" prop="bankNumName">
              <el-input v-model="form.bankNumName" />
            </el-form-item>
          </el-col>
        </el-row>
  
        <el-row>
          <el-col :span="12">
            <el-form-item :label="$t('withholdGold.bankName')" prop="bankName">
              <el-input v-model="form.bankName" type="textarea" :rows="2" />
            </el-form-item>
          </el-col>
          <el-col :span="12">
            <el-form-item :label="$t('withholdGold.applicationNote')" prop="remark">
              <el-input v-model="form.remark" type="textarea" :rows="2" />
            </el-form-item>
          </el-col>
        </el-row>
      </el-form>
  
      <span slot="footer" class="dialog-footer">
        <el-button @click="handleClose">{{ $t('common.cancel') }}</el-button>
        <el-button
          type="primary"
          @click="submitForm"
          :loading="loading"
        >
          {{ $t('common.submit') }}
        </el-button>
      </span>
    </el-dialog>
  </template>
  
  <script>
  import { applyGoldWithHold } from '@/api/scm/goldApi'
  import { getCommunityId } from '@/api/community/communityApi'
  
  export default {
    name: 'WithholdGold',
    data() {
      return {
        visible: false,
        loading: false,
        form: {
          goldId: '',
          goldName: '',
          communityId: '',
          amount: '',
          applyAmount: '',
          applyUserName: '',
          applyUserTel: '',
          remark: '',
          bankNum: '',
          bankNumName: '',
          bankName: ''
        },
        rules: {
          applyAmount: [
            { required: true, message: this.$t('withholdGold.required'), trigger: 'blur' }
          ],
          applyUserName: [
            { required: true, message: this.$t('withholdGold.required'), trigger: 'blur' }
          ],
          applyUserTel: [
            { required: true, message: this.$t('withholdGold.required'), trigger: 'blur' }
          ],
          bankNum: [
            { required: true, message: this.$t('withholdGold.required'), trigger: 'blur' }
          ],
          bankNumName: [
            { required: true, message: this.$t('withholdGold.required'), trigger: 'blur' }
          ],
          bankName: [
            { required: true, message: this.$t('withholdGold.required'), trigger: 'blur' }
          ]
        }
      }
    },
    methods: {
      open(data) {
        this.form = {
          ...this.form,
          goldId: data.goldId,
          amount: data.amount,
          communityId: data.communityId || getCommunityId()
        }
        this.visible = true
        this.$nextTick(() => {
          this.$refs.form && this.$refs.form.clearValidate()
        })
      },
      handleClose() {
        this.visible = false
      },
      submitForm() {
        this.$refs.form.validate(async valid => {
          if (!valid) return
  
          try {
            this.loading = true
            await applyGoldWithHold(this.form)
            this.$emit('success')
            this.$message.success(this.$t('withholdGold.submitSuccess'))
            this.visible = false
          } catch (error) {
            console.error('Submit failed:', error)
            this.$message.error(this.$t('withholdGold.submitFailed'))
          } finally {
            this.loading = false
          }
        })
      }
    }
  }
  </script>
  
  <style scoped>
  .el-textarea {
    width: 100%;
  }
  </style>