Skip to content

Commit 2b7c583

Browse files
committed
新增模拟支付渠道,通知查询为空bug 修改
1 parent 3cfcec3 commit 2b7c583

File tree

4 files changed

+134
-2
lines changed

4 files changed

+134
-2
lines changed

src/utils/constants.js

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -160,6 +160,10 @@ export const PayChannelEnum = {
160160
"code": "alipay_bar",
161161
"name": "支付宝条码支付"
162162
},
163+
MOCK : {
164+
"code": "mock",
165+
"name": "模拟支付"
166+
}
163167
}
164168

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

src/views/pay/app/index.vue

Lines changed: 21 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -157,6 +157,19 @@
157157
</template>
158158
</el-table-column>
159159
</el-table-column>
160+
<el-table-column label="模拟支付配置" align="center">
161+
<el-table-column :label="payChannelEnum.MOCK.name" align="center">
162+
<template v-slot="scope">
163+
<el-button type="success" icon="el-icon-check" circle
164+
v-if="isChannelExists(scope.row.channelCodes, payChannelEnum.MOCK.code)"
165+
@click="handleChannel(scope.row, payChannelEnum.MOCK.code)">
166+
</el-button>
167+
<el-button v-else type="danger" icon="el-icon-close" circle
168+
@click="handleChannel(scope.row, payChannelEnum.MOCK.code)">
169+
</el-button>
170+
</template>
171+
</el-table-column>
172+
</el-table-column>
160173
<el-table-column label="操作" align="center" class-name="small-padding fixed-width">
161174
<template v-slot="scope">
162175
<el-button size="mini" type="text" icon="el-icon-edit" @click="handleUpdate(scope.row)"
@@ -206,6 +219,7 @@
206219
<!-- 对话框(支付应用的配置) -->
207220
<weixin-channel-form ref="weixinChannelFormRef" @success="getList" />
208221
<alipay-channel-form ref="alipayChannelFormRef" @success="getList" />
222+
<mock-channel-form ref="mockChannelFormRef" @success="getList" />
209223
</div>
210224
</template>
211225

@@ -214,12 +228,14 @@ import { createApp, updateApp, changeAppStatus, deleteApp, getApp, getAppPage }
214228
import { PayChannelEnum, CommonStatusEnum } from "@/utils/constants";
215229
import weixinChannelForm from "@/views/pay/app/components/weixinChannelForm";
216230
import alipayChannelForm from "@/views/pay/app/components/alipayChannelForm";
231+
import mockChannelForm from '@/views/pay/app/components/mockChannelForm';
217232
218233
export default {
219234
name: "PayApp",
220235
components: {
221236
weixinChannelForm,
222-
alipayChannelForm
237+
alipayChannelForm,
238+
mockChannelForm
223239
},
224240
data() {
225241
return {
@@ -374,6 +390,10 @@ export default {
374390
this.$refs['weixinChannelFormRef'].open(row.id, code);
375391
return
376392
}
393+
if (code === 'mock') {
394+
this.$refs['mockChannelFormRef'].open(row.id, code);
395+
return
396+
}
377397
},
378398
/**
379399
* 根据渠道编码判断渠道列表中是否存在

src/views/pay/cashier/index.vue

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,7 @@
3535
<el-descriptions title="选择其它支付" style="margin-top: 20px;" />
3636
<div class="pay-channel-container">
3737
<div class="box" v-for="channel in channels" :key="channel.code"
38-
v-if="channel.code.indexOf('alipay_') === -1 && channel.code.indexOf('wx_') === -1">
38+
v-if="channel.code.indexOf('alipay_') === -1 && channel.code.indexOf('wx_') === -1" @click="submit(channel.code)">
3939
<img :src="channel.icon">
4040
<div class="title">{{ channel.name }}</div>
4141
</div>

0 commit comments

Comments
 (0)