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
<template>
<div>
<el-dialog
title="添加人群包客户"
:visible.sync="shows"
:show-close="!1"
:close-on-click-modal="!1"
width="600px"
>
<!-- 操作区域 -->
<el-form ref="form" :rules="rules" :model="queryParams" label-width="100px">
<el-form-item label="选择客户" prop="customerId">
<el-select v-model="queryParams.customerId" clearable size="small" style="width: 240px">
<el-option
v-for="(item,index) in customerOptions"
:key="index"
:label="item.name"
:value="item.value"
/>
</el-select>
</el-form-item>
<el-form-item label="预付金额" prop="prepaidAmount">
<el-input
v-model="queryParams.prepaidAmount"
placeholder="请输入预付金额"
clearable
size="small"
style="width: 240px"
/>
</el-form-item>
</el-form>
<!-- 底部区域 -->
<div slot="footer" class="dialog-footer">
<el-button type="primary" @click="submitForm">确认</el-button>
<el-button @click="cancel">取消</el-button>
</div>
</el-dialog>
</div>
</template>
<script>
import bus from "../bus";
import { getPackOption, addCustomer } from "@/api/system/pack";
export default {
data() {
return {
// 表单校验
rules: {
customerId: [
{ required: true, message: "选项不能为空", trigger: "blur" }
],
prepaidAmount: [
{ required: true, message: "预付金额不能为空", trigger: "blur" }
]
},
queryParams: {
customerId: null,
prepaidAmount: null
},
shows: false,
customerOptions: []
};
},
created() {
this.getOptions();
},
mounted() {
// 响应组件状态
bus.$on("shows", va => {
this.shows = va;
});
},
methods: {
// 清空
clear() {
this.queryParams = {
customerId: null,
prepaidAmount: null
};
},
// 获取客户下拉
getOptions() {
getPackOption()
.then(res => {
this.customerOptions = res.data;
})
.catch(console.log);
},
// 添加-确认
submitForm() {
this.$refs["form"].validate(valid => {
if (valid) {
addCustomer(this.queryParams)
.then(res => {
res.success
? this.msgSuccess("添加人群包客户成功")
: this.msgError("异常错误");
this.clear();
this.shows = false;
this.$emit("refresh", true);
})
.catch(console.log);
}
});
},
// 添加-取消
cancel() {
this.shows = false;
this.clear();
}
}
};
</script>
<style>
</style>