measureConfig.vue
5.86 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
152
153
154
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
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
<template>
<div>
<div class="d2-container-content">
<div class="app-config">
展业助手收入测算入口配置:
<el-radio-group v-model="configFlag" @change="radioChange">
<el-radio :label="0">全员打开</el-radio>
<el-radio :label="1">全员关闭</el-radio>
<el-radio :label="2">白名单开启</el-radio>
</el-radio-group>
</div>
<template v-if="configFlag == '2'">
<div class="theader">
<h2>白名单管理</h2>
<div>
<el-button @click="handleAdd" size="small" type="primary">
增加
</el-button>
</div>
</div>
<d2-table ref="measurementConfigTable" :hasNum="false" :get-list-api="getListApi"
:search-form="searchFormSearch" :table-params="tableParams">
<template slot="auth-button" slot-scope="scope">
<el-button type="text" @click="delWhite(scope.scope)">删除</el-button>
</template>
</d2-table>
</template>
</div>
<el-dialog class="white-dialog" title="新增白名单" :visible.sync="dialogVisible" width="668px"
:before-close="handleClose" :close-on-click-modal="false">
<el-form ref="whiteForm" class="white-form" :model="whiteForm" :rules="rules" label-width="150px">
<el-form-item label="手机号码:" prop="staffPhone">
<el-input v-model="whiteForm.staffPhone" maxlength="11" placeholder="请输入手机号码"></el-input>
</el-form-item>
<div class="line"></div>
<el-form-item label="员工姓名:">
{{ whiteForm.staffName }}
</el-form-item>
</el-form>
<span slot="footer" class="dialog-footer">
<template v-if="whiteForm.staffName">
<el-button type="primary" @click="addWhite">加入白名单</el-button>
</template>
<template v-else>
<el-button type="primary" @click="searchStaff">查询</el-button>
<el-button @click="dialogVisible = false">取 消</el-button>
</template>
</span>
</el-dialog>
</div>
</template>
<script>
import { Util } from '@/common/util'
import { getWhiteStaff, getSwitchConfig, addSwitchConfig, getStaffInfo, addWhiteStaff, delWhiteStaff } from "@api/resident"
export default {
name: 'MeasureConfig',
data() {
function checkPhone(rule, value, callback) {
console.log(value);
if (!Util.checkPhone(value)) {
callback(new Error('请输入正确的手机号码'))
return false
}
callback()
}
return {
// 收入测算配置
configFlag: 1,
getListApi: getWhiteStaff,
searchFormSearch: {},
tableParams: {
btnId: new Date().getTime() + parseInt(Math.random() * 1000),
listName: 'list',
tableOption: true,
tableColumns: [
{
label: '员工姓名',
prop: 'staffName'
},
{
label: '电话号码',
prop: 'staffPhone'
},
{
label: '适配业务',
prop: 'staffScenes'
},
{
label: '服务门店',
prop: 'serviceMerchantName'
}
]
},
dialogVisible: false,
whiteForm: {
staffName: '',
staffPhone: ''
},
rules: {
staffPhone: [
{
required: true,
message: '请输入手机号码',
trigger: 'blur'
}, {
validator: checkPhone,
trigger: 'blur'
}]
}
}
},
created() {
this.getSwitch()
},
methods: {
// 查询测试配置开关
async getSwitch() {
const res = await getSwitchConfig()
if(res) this.configFlag = res.configFlag
},
handleAdd() {
console.log('111');
this.dialogVisible = true
},
handleClose() {
this.dialogVisible = false
this.whiteForm = {
staffName: '',
staffPhone: ''
}
},
radioChange(e) {
console.log(e);
addSwitchConfig({ configFlag: e }).then(res => {
console.log(res)
if (res) this.$message.success('修改成功')
})
},
// 查询员工
searchStaff() {
this.$refs.whiteForm.validate((valid) => {
if (valid) {
const {staffPhone} = this.whiteForm
// if (!staffPhone) return this.$message.error('请输入手机号码')
getStaffInfo({staffPhone}).then(res => {
console.log(res);
if (res) {
this.whiteForm.staffName = res.staffName
} else {
this.$message.error('不存在该直营驻店人员')
}
})
}
})
},
// 加入白名单
addWhite() {
const {staffPhone, staffName} = this.whiteForm
addWhiteStaff({staffPhone, staffName}).then(res => {
console.log(res);
if (res) {
this.$message.success('修改成功')
this.$refs.measurementConfigTable.refreshTable(true, true)
this.handleClose()
}
})
},
delWhite(row) {
console.log(row);
delWhiteStaff({id: row.id}).then(res => {
if (res) {
this.$message.success('删除成功')
this.$refs.measurementConfigTable.refreshTable(true, true)
}
})
}
}
}
</script>
<style lang="scss" scoped>
.d2-container-content {
background-color: #fff;
margin-top: 0 !important;
padding: 0 20px 20px !important;
}
.app-config {
color: #333333;
font-size: 16px;
padding: 12.5px 20px;
background-color: #F8FAFF;
// margin: 0 20px;
}
.theader {
width: 100%;
display: flex;
justify-content: space-between;
align-items: center;
h2 {
font-weight: 600;
font-size: 16px;
color: #333333;
}
}
.white-form {
height: 108px;
.line {
width: 100%;
height: 1px;
background-color: #E5E5E5;
margin-bottom: 20px;
}
}
</style>