|
@@ -0,0 +1,219 @@
|
|
1
|
+<template>
|
|
2
|
+ <el-dialog
|
|
3
|
+ :visible.sync="dialogVisible"
|
|
4
|
+ :before-close="handleCancel"
|
|
5
|
+ class="bind-dialog"
|
|
6
|
+ :title="dialogTitle"
|
|
7
|
+ width="500px"
|
|
8
|
+ :close-on-click-modal="false"
|
|
9
|
+ :append-to-body="true"
|
|
10
|
+ >
|
|
11
|
+ <div class="form-wrap" v-loading="loading">
|
|
12
|
+ <div class="form-item">
|
|
13
|
+ <span class="lable required">分组</span>
|
|
14
|
+ <div>
|
|
15
|
+ <el-select v-model="form.group_id" class="select-cls" style="width:280px;" size="small" placeholder="请选择" filterable clearable @change="onChangeGroupId">
|
|
16
|
+ <el-option v-for="group in groupOptions" :key="group.group_id" :label="group.title" :value="group.group_id" />
|
|
17
|
+ </el-select>
|
|
18
|
+ </div>
|
|
19
|
+ <div class="newGroupCss" @click="onClickCreateGroup">新建分组</div>
|
|
20
|
+ </div>
|
|
21
|
+ </div>
|
|
22
|
+ <div slot="footer" class="dialog-footer">
|
|
23
|
+ <el-button size="mini" @click="handleCancel">取 消</el-button>
|
|
24
|
+ <el-button size="mini" type="primary" @click="handleConfirm">确 定</el-button>
|
|
25
|
+ </div>
|
|
26
|
+
|
|
27
|
+ <!-- S 编辑分组弹框 -->
|
|
28
|
+ <pushGroupDialog
|
|
29
|
+ :dialogVisible="pushGroupVisible"
|
|
30
|
+ @confirm="onConfirmGroup"
|
|
31
|
+ @cancel="onCancelGroup"
|
|
32
|
+ />
|
|
33
|
+ <!-- E 编辑分组弹框 -->
|
|
34
|
+ </el-dialog>
|
|
35
|
+</template>
|
|
36
|
+
|
|
37
|
+<script>
|
|
38
|
+import pushGroupDialog from './pushGroupDialog.vue'
|
|
39
|
+
|
|
40
|
+export default {
|
|
41
|
+ name: "batchGroupDialog",
|
|
42
|
+ components: { pushGroupDialog },
|
|
43
|
+ props: {
|
|
44
|
+ // 控制弹框是否显示
|
|
45
|
+ dialogVisible: {
|
|
46
|
+ type: Boolean,
|
|
47
|
+ default: () => false
|
|
48
|
+ },
|
|
49
|
+ rule_ids: {
|
|
50
|
+ type: String,
|
|
51
|
+ default: () => ''
|
|
52
|
+ },
|
|
53
|
+ },
|
|
54
|
+ data() {
|
|
55
|
+ return {
|
|
56
|
+ loading: false,
|
|
57
|
+ form: {
|
|
58
|
+ group_id: '',
|
|
59
|
+ },
|
|
60
|
+ groupOptions: [],
|
|
61
|
+ pushGroupVisible: false,
|
|
62
|
+ }
|
|
63
|
+ },
|
|
64
|
+ computed: {
|
|
65
|
+ dialogTitle() {
|
|
66
|
+ return '批量设置分组'
|
|
67
|
+ },
|
|
68
|
+ },
|
|
69
|
+ watch: {
|
|
70
|
+ dialogVisible(isShow) {
|
|
71
|
+ if (isShow) {
|
|
72
|
+ this.handleGetGroupOptions()
|
|
73
|
+ // 获取表单数据
|
|
74
|
+ // this.handleGetFormData()
|
|
75
|
+ }
|
|
76
|
+ },
|
|
77
|
+ },
|
|
78
|
+ methods: {
|
|
79
|
+ async handleConfirm() {
|
|
80
|
+ try {
|
|
81
|
+ // 表单校验
|
|
82
|
+ await this.handleFormValidate()
|
|
83
|
+ const url = `${this.URL.BASEURL}${this.URL.smartPushV3_changeGroupBatch}`
|
|
84
|
+ const params = {
|
|
85
|
+ group_id: this.form.group_id,
|
|
86
|
+ rule_ids: this.rule_ids,
|
|
87
|
+ }
|
|
88
|
+ this.loading = true
|
|
89
|
+ const { data: res = {} } = await this.$axios.post(url, params)
|
|
90
|
+ if (res && res.errno == 0) {
|
|
91
|
+ this.$message.success('操作成功')
|
|
92
|
+ this.handleClearFormData()
|
|
93
|
+ this.$emit('confirm')
|
|
94
|
+ } else if (res.errno != 4002) {
|
|
95
|
+ this.$message.warning(res.err || '操作失败')
|
|
96
|
+ }
|
|
97
|
+ } catch (error) {
|
|
98
|
+ console.log('error => ', error)
|
|
99
|
+ } finally {
|
|
100
|
+ this.loading = false
|
|
101
|
+ }
|
|
102
|
+ },
|
|
103
|
+ handleCancel() {
|
|
104
|
+ this.handleClearFormData()
|
|
105
|
+ this.$emit('cancel')
|
|
106
|
+ },
|
|
107
|
+ // 执行表单校验
|
|
108
|
+ handleFormValidate() {
|
|
109
|
+ return new Promise((resolve, reject) => {
|
|
110
|
+ if (!this.form.group_id) {
|
|
111
|
+ this.$message.warning('请选择分组')
|
|
112
|
+ reject('表单校验未通过')
|
|
113
|
+ } else {
|
|
114
|
+ resolve('表单校验通过')
|
|
115
|
+ }
|
|
116
|
+ })
|
|
117
|
+ },
|
|
118
|
+ // 获取表单数据
|
|
119
|
+ // handleGetFormData() {
|
|
120
|
+ // this.form.title = title
|
|
121
|
+ // },
|
|
122
|
+ // 清空弹框表单数据
|
|
123
|
+ handleClearFormData() {
|
|
124
|
+ this.form.group_id = ''
|
|
125
|
+ },
|
|
126
|
+
|
|
127
|
+ async handleGetGroupOptions() {
|
|
128
|
+ const params = { status: 1, page: 1, page_size: 1000 }
|
|
129
|
+ const { data: res = {} } = await this.$axios.post(this.URL.BASEURL + this.URL.smartPushV3_groupList, params)
|
|
130
|
+ if (res && res.errno == 0 && Array.isArray(res.rst.data)) {
|
|
131
|
+ this.groupOptions = res.rst.data;
|
|
132
|
+ } else if (res.errno != 4002) {
|
|
133
|
+ this.$message.warning(res.err)
|
|
134
|
+ this.groupOptions = [];
|
|
135
|
+ }
|
|
136
|
+ },
|
|
137
|
+ onChangeGroupId(groupId) {
|
|
138
|
+ this.group_id = groupId || ''
|
|
139
|
+ },
|
|
140
|
+ onClickCreateGroup() {
|
|
141
|
+ this.pushGroupVisible = true
|
|
142
|
+ },
|
|
143
|
+ onConfirmGroup() {
|
|
144
|
+ this.handleGetGroupOptions()
|
|
145
|
+ this.pushGroupVisible = false
|
|
146
|
+ },
|
|
147
|
+ onCancelGroup() {
|
|
148
|
+ this.pushGroupVisible = false
|
|
149
|
+ },
|
|
150
|
+ },
|
|
151
|
+};
|
|
152
|
+</script>
|
|
153
|
+
|
|
154
|
+<style lang="scss" scoped>
|
|
155
|
+.bind-dialog {
|
|
156
|
+ .form-wrap {
|
|
157
|
+ padding: 0 10px;
|
|
158
|
+ .form-item {
|
|
159
|
+ display: flex;
|
|
160
|
+ align-items: center;
|
|
161
|
+ margin-top: 16px;
|
|
162
|
+ &:first-child {
|
|
163
|
+ margin-top: 0;
|
|
164
|
+ }
|
|
165
|
+ .lable {
|
|
166
|
+ width: 60px;
|
|
167
|
+ font-weight: 500;
|
|
168
|
+ flex-shrink: 0;
|
|
169
|
+
|
|
170
|
+ &.required {
|
|
171
|
+ position: relative;
|
|
172
|
+ &::before {
|
|
173
|
+ position: absolute;
|
|
174
|
+ left: -8px;
|
|
175
|
+ top: 0;
|
|
176
|
+ content: "*";
|
|
177
|
+ color: #f56c6c;
|
|
178
|
+ }
|
|
179
|
+ }
|
|
180
|
+ }
|
|
181
|
+ .el-select {
|
|
182
|
+ width: 100%;
|
|
183
|
+ }
|
|
184
|
+ }
|
|
185
|
+ .form-tips {
|
|
186
|
+ margin: 5px 0 0 80px;
|
|
187
|
+ font-size: 13px;
|
|
188
|
+ color: #999;
|
|
189
|
+ }
|
|
190
|
+ }
|
|
191
|
+ .dialog-footer {
|
|
192
|
+ text-align: center;
|
|
193
|
+ }
|
|
194
|
+}
|
|
195
|
+
|
|
196
|
+.select-cls {
|
|
197
|
+ /deep/ &.el-select .el-input.is-focus .el-input__inner,
|
|
198
|
+ /deep/ &.el-select .el-input__inner:focus {
|
|
199
|
+ border-color: #DCDFE6;
|
|
200
|
+ }
|
|
201
|
+ /deep/ .el-input__suffix {
|
|
202
|
+ border-top-right-radius: 4px;
|
|
203
|
+ border-bottom-right-radius: 4px;
|
|
204
|
+ border: 1px solid #DCDFE6;
|
|
205
|
+ right: 0;
|
|
206
|
+ width: 30px;
|
|
207
|
+ background-color: #F1F1F1;
|
|
208
|
+ .el-input__icon {
|
|
209
|
+ color: #909399;
|
|
210
|
+ }
|
|
211
|
+ }
|
|
212
|
+}
|
|
213
|
+.newGroupCss{
|
|
214
|
+ color: #00b38a;
|
|
215
|
+ font-size: 14px;
|
|
216
|
+ margin-left: 10px;
|
|
217
|
+ cursor: pointer;
|
|
218
|
+}
|
|
219
|
+</style>
|