Blame view

yudao-ui-admin/src/views/pay/app/components/noneConfigChannelForm.vue 3.15 KB
6a387387   jason   新增模拟支付渠道,通知查询为空bu...
1
2
3
4
5
6
7
  <template>
    <div>
      <el-dialog :visible.sync="dialogVisible" :title="title" @closed="close" append-to-body width="800px">
        <el-form ref="form" :model="formData" :rules="rules" size="medium" label-width="100px" v-loading="formLoading">
          <el-form-item label-width="180px" label="渠道状态" prop="status">
            <el-radio-group v-model="formData.status" size="medium">
              <el-radio v-for="dict in this.getDictDatas(DICT_TYPE.COMMON_STATUS)" :key="parseInt(dict.value)"
9074312f   jason   后台接入钱包支付
8
9
                        :label="parseInt(dict.value)"
              >
6a387387   jason   新增模拟支付渠道,通知查询为空bu...
10
11
12
13
                {{ dict.label }}
              </el-radio>
            </el-radio-group>
          </el-form-item>
6a387387   jason   新增模拟支付渠道,通知查询为空bu...
14
15
16
17
18
19
20
21
22
23
24
25
          <el-form-item label-width="180px" label="备注" prop="remark">
            <el-input v-model="formData.remark" :style="{width: '100%'}"></el-input>
          </el-form-item>
        </el-form>
        <div slot="footer" class="dialog-footer">
          <el-button @click="close">取消</el-button>
          <el-button type="primary" @click="submitForm">确定</el-button>
        </div>
      </el-dialog>
    </div>
  </template>
  <script>
9074312f   jason   后台接入钱包支付
26
27
  import { createChannel, getChannel, updateChannel } from '@/api/pay/channel'
  import { CommonStatusEnum } from '@/utils/constants'
6a387387   jason   新增模拟支付渠道,通知查询为空bu...
28
29
  
  export default {
9074312f   jason   后台接入钱包支付
30
    name: 'noneConfigChannelForm',
6a387387   jason   新增模拟支付渠道,通知查询为空bu...
31
32
33
34
    data() {
      return {
        dialogVisible: false,
        formLoading: false,
9074312f   jason   后台接入钱包支付
35
        title: '',
6a387387   jason   新增模拟支付渠道,通知查询为空bu...
36
37
38
39
40
41
42
        formData: {
          appId: '',
          code: '',
          status: undefined,
          feeRate: 0,
          remark: '',
          config: {
9074312f   jason   后台接入钱包支付
43
            name: 'none-config'
6a387387   jason   新增模拟支付渠道,通知查询为空bu...
44
45
46
          }
        },
        rules: {
9074312f   jason   后台接入钱包支付
47
          status: [{ required: true, message: '渠道状态不能为空', trigger: 'blur' }]
6a387387   jason   新增模拟支付渠道,通知查询为空bu...
48
49
50
51
52
        }
      }
    },
    methods: {
      open(appId, code) {
9074312f   jason   后台接入钱包支付
53
54
55
        this.dialogVisible = true
        this.formLoading = true
        this.reset(appId, code)
6a387387   jason   新增模拟支付渠道,通知查询为空bu...
56
57
        getChannel(appId, code).then(response => {
          if (response.data && response.data.id) {
9074312f   jason   后台接入钱包支付
58
59
            this.formData = response.data
            this.formData.config = JSON.parse(response.data.config)
6a387387   jason   新增模拟支付渠道,通知查询为空bu...
60
61
62
          }
          this.title = !this.formData.id ? '创建支付渠道' : '编辑支付渠道'
        }).finally(() => {
9074312f   jason   后台接入钱包支付
63
64
          this.formLoading = false
        })
6a387387   jason   新增模拟支付渠道,通知查询为空bu...
65
66
      },
      close() {
9074312f   jason   后台接入钱包支付
67
68
        this.dialogVisible = false
        this.reset(undefined, undefined)
6a387387   jason   新增模拟支付渠道,通知查询为空bu...
69
70
71
72
73
74
      },
      submitForm() {
        this.$refs['form'].validate(valid => {
          if (!valid) {
            return
          }
9074312f   jason   后台接入钱包支付
75
76
          const data = { ...this.formData }
          data.config = JSON.stringify(this.formData.config)
6a387387   jason   新增模拟支付渠道,通知查询为空bu...
77
78
          if (!data.id) {
            createChannel(data).then(response => {
9074312f   jason   后台接入钱包支付
79
              this.$modal.msgSuccess('新增成功')
6a387387   jason   新增模拟支付渠道,通知查询为空bu...
80
              this.$emit('success')
9074312f   jason   后台接入钱包支付
81
82
              this.close()
            })
6a387387   jason   新增模拟支付渠道,通知查询为空bu...
83
84
          } else {
            updateChannel(data).then(response => {
9074312f   jason   后台接入钱包支付
85
              this.$modal.msgSuccess('修改成功')
6a387387   jason   新增模拟支付渠道,通知查询为空bu...
86
              this.$emit('success')
9074312f   jason   后台接入钱包支付
87
              this.close()
6a387387   jason   新增模拟支付渠道,通知查询为空bu...
88
89
            })
          }
9074312f   jason   后台接入钱包支付
90
        })
6a387387   jason   新增模拟支付渠道,通知查询为空bu...
91
92
93
94
95
96
97
98
99
100
      },
      /** 重置表单 */
      reset(appId, code) {
        this.formData = {
          appId: appId,
          code: code,
          status: CommonStatusEnum.ENABLE,
          remark: '',
          feeRate: 0,
          config: {
9074312f   jason   后台接入钱包支付
101
            name: 'none-config'
6a387387   jason   新增模拟支付渠道,通知查询为空bu...
102
103
104
          }
        }
        this.resetForm('form')
9074312f   jason   后台接入钱包支付
105
      }
6a387387   jason   新增模拟支付渠道,通知查询为空bu...
106
107
108
    }
  }
  </script>