yqStoreConfig.vue
3.85 KB
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
<!-- 服务商管理 -->
<template>
<d2-container class="config_page">
<div class="d2-container-content">
<div class="page_head">园区店配置</div>
<div class="form_box">
<el-form label-width="100px" size="small">
<el-form-item label="支付方式:">
<el-checkbox-group v-model="checkList" @change="onChange">
<el-checkbox v-for="(item,index) in pageTypeList" :key="index" :label="item.id" :disabled="item.disabled">{{item.name}}</el-checkbox>
</el-checkbox-group>
</el-form-item>
<el-form-item>
<el-button type="primary" @click="saveInfo">确认</el-button>
<el-button type="default" @click="goBack">取消</el-button>
</el-form-item>
</el-form>
</div>
</div>
</d2-container>
</template>
<script>
import { showToast } from '@/common/util'
import {
GETYQMERCHANTCONFIGDETAIL,
UPDATEYQMERCHANTCONFIG
} from '@api/serviceManage'
export default {
data() {
return {
pageTypeList: [
{ id: 2, name: '门店收款', disabled: false },
{ id: 3, name: 'POS机收款', disabled: false },
{ id: 0, name: '不升级', disabled: true },
{ id: 1, name: '微信支付', disabled: false }
// { id: 4, name: '支付宝支付', disabled: false },
],
checkList: [0]
}
},
mounted() {
this.getInfo()
},
methods: {
// 获取园区店配置
getInfo() {
const o = this.$route.query
const oParams = {}
oParams.yqMerchantId = o.yqMerchantId
GETYQMERCHANTCONFIGDETAIL(oParams).then((res) => {
this.checkList = res.supportPayTypes || []
this.onChange(this.checkList)
})
},
// 监听支付方式勾选
onChange(list) {
console.log(list)
const olist = this.pageTypeList
const idx = list.findIndex((k) => k == 3)
// 初始化,所有设置可选
olist.map((k) => {
if (k.id != 0) {
k.disabled = false
}
return k
})
// 如果包含 POS机收款,则不能选择微信、支付宝
if (idx >= 0) {
olist.map((k) => {
if (k.id == 1 || k.id == 4) {
k.disabled = true
}
return k
})
}
// 如果包含 微信、支付宝,则不能选择POS机收款
if (list.indexOf(1) >= 0 || list.indexOf(4) >= 0) {
olist.map((k) => {
if (k.id == 3) {
k.disabled = true
}
return k
})
}
console.log(olist)
},
// 取消
goBack() {
this.$router.go(-1)
},
// 保存配置
saveInfo() {
if (!this.checkList || this.checkList.length <= 0) {
showToast({
message: '请选择支付方式'
})
return false
}
if (this.checkList.indexOf(3) < 0 && this.checkList.indexOf(1) < 0) {
showToast({
message: '微信支付和pos机收款必须选择一个'
})
return false
}
const oParams = {}
oParams.yqMerchantId = this.$route.query.yqMerchantId
oParams.supportPayTypes = this.checkList
UPDATEYQMERCHANTCONFIG(oParams).then((res) => {
console.log(res)
showToast({
message: '保存成功',
type: 'success'
})
this.goBack()
})
}
}
}
</script>
<style lang="scss" scoped>
.page_head {
position: relative;
font-size: 18px;
color: #0947c6;
padding-bottom: 20px;
font-weight: bold;
}
.page_head:after {
position: absolute;
display: block;
content: '';
height: 1px;
background: #d8d8d8;
left: 0;
right: 0;
bottom: 0;
}
.form_box {
min-height: 60vh;
padding: 40px 0 50px 0;
}
</style>