Blame view

src/components/system/addPaymentPool.vue 6.31 KB
6ec243d6   wuxw   v1.9 点击提交后,成功提示没有...
1
  <template>
ce5e1a2a   wuxw   系统模块开发中
2
    <el-dialog :title="$t('paymentPool.add.title')" :visible.sync="visible" width="50%" @close="handleClose">
27dcfde5   wuxw   系统全面测试完成
3
      <el-form ref="form" :model="formData" :rules="rules" label-width="120px" class="text-left">
ce5e1a2a   wuxw   系统模块开发中
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
        <el-form-item :label="$t('paymentPool.add.paymentName')" prop="paymentName">
          <el-input v-model="formData.paymentName" :placeholder="$t('paymentPool.add.paymentNamePlaceholder')" />
        </el-form-item>
  
        <el-form-item :label="$t('paymentPool.add.paymentType')" prop="paymentType">
          <el-select v-model="formData.paymentType" :placeholder="$t('paymentPool.add.paymentTypePlaceholder')"
            style="width:100%" @change="handlePaymentTypeChange">
            <el-option v-for="item in paymentTypes" :key="item.paymentType" :label="item.name"
              :value="item.paymentType" />
          </el-select>
        </el-form-item>
  
        <el-form-item v-for="(item, index) in paymentKeys" :key="index" :label="item.name">
          <el-input v-model="item.columnValue" type="textarea" :placeholder="item.remark" :rows="3" />
        </el-form-item>
  
        <el-form-item v-if="formData.paymentType === 'WECHAT'" :label="$t('paymentPool.add.certFile')">
27dcfde5   wuxw   系统全面测试完成
21
          <upload-file ref="uploadFile" @notify="handleNotifyCert" />
ce5e1a2a   wuxw   系统模块开发中
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
        </el-form-item>
  
        <el-form-item :label="$t('paymentPool.add.payRange')" prop="payType">
          <el-select v-model="formData.payType" :placeholder="$t('paymentPool.add.payRangePlaceholder')"
            style="width:100%">
            <el-option :label="$t('paymentPool.add.communityFee')" value="1001" />
            <el-option :label="$t('paymentPool.add.tempCarFee')" value="2002" />
            <el-option :label="$t('paymentPool.add.specifiedFee')" value="3003" />
          </el-select>
        </el-form-item>
  
        <el-form-item v-if="formData.payType === '3003'" :label="$t('paymentPool.add.feeItems')">
          <el-checkbox-group v-model="formData.configIds">
            <el-checkbox v-for="item in feeConfigs" :key="item.configId" :label="item.configId">
              {{ item.feeName }}
            </el-checkbox>
          </el-checkbox-group>
        </el-form-item>
  
        <el-form-item :label="$t('paymentPool.add.remark')">
          <el-input v-model="formData.remark" type="textarea" :placeholder="$t('paymentPool.add.remarkPlaceholder')"
            :rows="3" />
        </el-form-item>
      </el-form>
  
      <div 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>
      </div>
    </el-dialog>
  </template>
  
  <script>
27dcfde5   wuxw   系统全面测试完成
59
60
  import { savePaymentPool, listPaymentKey, listFeeConfigs, listPaymentAdapt } from '@/api/system/paymentPoolApi'
  import UploadFile from '@/components/upload/uploadFile'
ce5e1a2a   wuxw   系统模块开发中
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
  import { getCommunityId } from '@/api/community/communityApi'
  
  export default {
    name: 'AddPaymentPool',
    components: {
      UploadFile
    },
    props: {
      callBackListener: {
        type: String,
        default: ''
      },
      callBackFunction: {
        type: String,
        default: ''
      }
    },
    data() {
      return {
        visible: false,
        formData: {
          paymentName: '',
          paymentType: '',
          certPath: '',
          state: 'Y',
          remark: '',
          payType: '1001',
          configIds: [],
          communityId: ''
        },
        paymentTypes: [],
        paymentKeys: [],
        feeConfigs: [],
        rules: {
          paymentName: [
            { required: true, message: this.$t('paymentPool.validate.paymentNameRequired'), trigger: 'blur' },
            { max: 64, message: this.$t('paymentPool.validate.paymentNameMaxLength'), trigger: 'blur' }
          ],
          paymentType: [
            { required: true, message: this.$t('paymentPool.validate.paymentTypeRequired'), trigger: 'change' }
          ],
          payType: [
            { required: true, message: this.$t('paymentPool.validate.payTypeRequired'), trigger: 'change' }
          ]
        }
      }
    },
    created() {
      this.formData.communityId = getCommunityId()
      this.getPaymentTypes()
ce5e1a2a   wuxw   系统模块开发中
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
    },
    methods: {
      open() {
        this.visible = true
        this.getFeeConfigs()
        if (this.$refs.uploadFile) {
          this.$refs.uploadFile.clear()
        }
      },
      handleClose() {
        this.$refs.form.resetFields()
        this.formData = {
          paymentName: '',
          paymentType: '',
          certPath: '',
          state: 'Y',
          remark: '',
          payType: '1001',
          configIds: [],
          communityId: getCommunityId()
        }
        this.paymentKeys = []
      },
      async getPaymentTypes() {
        try {
          const { data } = await listPaymentAdapt({
            page: 1,
            row: 100,
          })
          this.paymentTypes = data
        } catch (error) {
          console.error('获取支付类型失败:', error)
        }
      },
      async getFeeConfigs() {
        try {
          const params = {
            page: 1,
            row: 100,
            isDefault: 'F',
            communityId: this.formData.communityId
          }
048b90a9   wuxw   v1.9 优化支付没法设置费用项bug
153
154
          const { feeConfigs } = await listFeeConfigs(params)
          this.feeConfigs = feeConfigs
ce5e1a2a   wuxw   系统模块开发中
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
        } catch (error) {
          console.error('获取费用配置失败:', error)
        }
      },
      async handlePaymentTypeChange() {
        if (!this.formData.paymentType) return
  
        try {
          const params = {
            paymentType: this.formData.paymentType,
            page: 1,
            row: 100
          }
          const { data } = await listPaymentKey(params)
          this.paymentKeys = data.map(item => ({
            ...item,
            columnValue: ''
          }))
        } catch (error) {
          console.error('获取支付密钥失败:', error)
        }
      },
      handleNotifyCert(param) {
        this.formData.certPath = param.realFileName
      },
      handleSubmit() {
        this.$refs.form.validate(async valid => {
          if (!valid) return
  
          try {
            const params = {
              ...this.formData,
27dcfde5   wuxw   系统全面测试完成
187
              paymentKeys: this.paymentKeys.map(item => ({
ce5e1a2a   wuxw   系统模块开发中
188
189
190
191
192
                columnKey: item.columnKey,
                columnValue: item.columnValue
              }))
            }
            await savePaymentPool(params)
6ec243d6   wuxw   v1.9 点击提交后,成功提示没有...
193
            this.$message.success(this.$t('common.operationSuccess'))
ce5e1a2a   wuxw   系统模块开发中
194
195
196
197
198
199
200
201
202
203
            this.visible = false
            this.$emit('success')
          } catch (error) {
            this.$message.error(error.message || this.$t('paymentPool.add.error'))
          }
        })
      }
    }
  }
  </script>