form.vue
3.5 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
<template>
<el-dialog :close-on-click-modal="false" :title="isAdd?'新建用户黑名单':'编辑用户黑名单'" width="500px" :visible.sync="visible">
<div class="user-search">
<el-select
v-model="searchKey"
filterable
remote
reserve-keyword
placeholder="请输入关键词"
:remote-method="userQuery"
:loading="userLoading"
@change="userSelectChane"
value-key='buyerUserId'
>
<el-option
v-for="item in userOptions"
:key="item.buyerUserId"
:label="item.name"
:value="item"
/>
</el-select>
</div>
<div class="user-result">
<el-descriptions v-if="JSON.stringify(resultData) !== '{}'" class="margin-top" title="" :column="1" border>
<el-descriptions-item>
<template slot="label">
userid
</template>
{{ resultData.buyerUserId }}
</el-descriptions-item>
<el-descriptions-item>
<template slot="label">
openid
</template>
{{ resultData.wechatOpenId }}
</el-descriptions-item>
<el-descriptions-item>
<template slot="label">
昵称
</template>
{{ resultData.name }}
</el-descriptions-item>
<el-descriptions-item>
<template slot="label">
手机号
</template>
{{ resultData.phone }}
</el-descriptions-item>
</el-descriptions>
</div>
<div slot="footer" class="dialog-footer">
<el-button type="text" @click="doCancel">取消</el-button>
<el-button type="primary" @click="doSubmit">确认</el-button>
</div>
</el-dialog>
</template>
<script>
import {
addBlack,
searchUser
} from '@/api/risk'
export default {
name: 'AdForm',
data () {
return {
visible: false,
isAdd: false,
searchKey: '',
userParams: {
searchKey: '',
page: 1,
pageSize: 10,
},
userLoading: false,
userOptions: [],
resultData: {}
}
},
methods: {
// 打开弹出窗
show (row) {
this.isAdd = !row
if (this.isAdd) {
this.searchKey = ''
this.resultData = {}
} else {
this.form = JSON.parse(JSON.stringify(row))
}
this.visible = true
},
// 取消
doCancel () {
this.visible = false
},
// 提交
doSubmit () {
if (JSON.stringify(this.resultData) === '{}') {
this.$message({
message: '请先查找用户',
type: 'warning'
})
return false
}
const params = {
type: 2,
buyerUserId: this.resultData.buyerUserId
}
addBlack(params).then(res => {
this.$message({
message: '新增成功',
type: 'success'
})
this.$emit('reset')
this.visible = false
}).catch(err => {
this.visible = false
})
},
// 用户搜索
userQuery (val) {
if (val) {
this.userLoading = true
this.userParams.searchKey = val
searchUser(this.userParams).then(res => {
this.userOptions = res.data.list
this.userLoading = false
}).catch(err => {
this.userLoading = false
})
}
},
userSelectChane (val) {
this.resultData = val || {}
}
}
}
</script>
<style scoped lang="scss">
.user-search{
margin-bottom: 10px;
}
.head-container .el-form-item{
margin-bottom: 0px;
}
</style>