|
@@ -0,0 +1,222 @@
|
|
1
|
+<template>
|
|
2
|
+ <div>
|
|
3
|
+ <div class="title">
|
|
4
|
+ <span class="fWeight600 c-000 f14">渠道分组</span>
|
|
5
|
+ <span
|
|
6
|
+ class="addGroupBox"
|
|
7
|
+ @click="($refs.dialogGroupRef.dialogVisible = true),($refs.dialogGroupRef.groupName = '')"
|
|
8
|
+ >
|
|
9
|
+ <i class="el-icon-plus f12"></i>
|
|
10
|
+ 添加分组
|
|
11
|
+ </span>
|
|
12
|
+ </div>
|
|
13
|
+ <div class="listBox" v-loading="loading">
|
|
14
|
+ <div class="item_css" :class="[acIdx == null ? 'ac_css' : '']" @click="itemClick(null)">
|
|
15
|
+ <i class="el-icon-folder"></i>全部渠道群活码
|
|
16
|
+ </div>
|
|
17
|
+ <draggable
|
|
18
|
+ class="syllable_ul"
|
|
19
|
+ element="ul"
|
|
20
|
+ @sort="draggableSort"
|
|
21
|
+ :list="tableData"
|
|
22
|
+ :emptyInsertThreshold="0"
|
|
23
|
+ :options="{
|
|
24
|
+ group: 'name',
|
|
25
|
+ animation: 200,
|
|
26
|
+ ghostClass: 'ghostClass',
|
|
27
|
+ dragClass: 'dragClass',
|
|
28
|
+ }"
|
|
29
|
+ >
|
|
30
|
+ <div
|
|
31
|
+ v-for="(item, index) in tableData"
|
|
32
|
+ :key="item.id"
|
|
33
|
+ class="item_css"
|
|
34
|
+ @click="itemClick(item.id)"
|
|
35
|
+ :class="{'ac_css': acIdx == item.id}"
|
|
36
|
+ >
|
|
37
|
+ <i class="el-icon-folder" style="cursor: move"></i>
|
|
38
|
+ <span>{{ item.name || "-" }}</span>
|
|
39
|
+ <span class="lMarauto">
|
|
40
|
+ <el-dropdown @command="handleCommand">
|
|
41
|
+ <span class="el-dropdown-link">
|
|
42
|
+ <i class="el-icon-more" />
|
|
43
|
+ </span>
|
|
44
|
+ <el-dropdown-menu slot="dropdown">
|
|
45
|
+ <el-dropdown-item :command="handleGetEditCommand(item)">修改名称</el-dropdown-item>
|
|
46
|
+ <el-dropdown-item :command="handleGetDeleteCommand(item)">删除分组</el-dropdown-item>
|
|
47
|
+ </el-dropdown-menu>
|
|
48
|
+ </el-dropdown>
|
|
49
|
+ </span>
|
|
50
|
+ </div>
|
|
51
|
+ </draggable>
|
|
52
|
+ </div>
|
|
53
|
+
|
|
54
|
+ <dialogGroup ref="dialogGroupRef" :propsData="{ dialogTitle, groupId }" @init="init" />
|
|
55
|
+ </div>
|
|
56
|
+</template>
|
|
57
|
+
|
|
58
|
+<script>
|
|
59
|
+import dialogGroup from "./dialogGroup.vue";
|
|
60
|
+import draggable from "vuedraggable";
|
|
61
|
+const eventOptions = {
|
|
62
|
+ 'EDIT': 'edit',
|
|
63
|
+ 'DELETE': 'delete'
|
|
64
|
+}
|
|
65
|
+export default {
|
|
66
|
+ components: {
|
|
67
|
+ dialogGroup,
|
|
68
|
+ draggable,
|
|
69
|
+ },
|
|
70
|
+ data() {
|
|
71
|
+ return {
|
|
72
|
+ dialogTitle: "添加",
|
|
73
|
+ acIdx: null,
|
|
74
|
+ tableData: [],
|
|
75
|
+ loading: false,
|
|
76
|
+ page: 1,
|
|
77
|
+ pages: 0,
|
|
78
|
+ total: 0,
|
|
79
|
+ page_size: 500,
|
|
80
|
+ groupId: "",
|
|
81
|
+ };
|
|
82
|
+ },
|
|
83
|
+ created() {
|
|
84
|
+ this.init()
|
|
85
|
+ },
|
|
86
|
+ methods: {
|
|
87
|
+ handleGetEditCommand({ id, name }) {
|
|
88
|
+ return `${eventOptions.EDIT}/${id}/${name}`
|
|
89
|
+ },
|
|
90
|
+ handleGetDeleteCommand({ id }) {
|
|
91
|
+ return `${eventOptions.DELETE}/${id}`
|
|
92
|
+ },
|
|
93
|
+ async init() {
|
|
94
|
+ try {
|
|
95
|
+ this.loading = true;
|
|
96
|
+ const { data: res = {} } = await this.$axios.get(this.URL.BASEURL + this.URL.channel_groupList, {
|
|
97
|
+ params: {
|
|
98
|
+ type: 2, // 1:渠道活码 2:群活码
|
|
99
|
+ page: this.page,
|
|
100
|
+ pagesize: this.page_size,
|
|
101
|
+ }
|
|
102
|
+ })
|
|
103
|
+ if (res && res.errno == 0) {
|
|
104
|
+ this.tableData = res.rst.data;
|
|
105
|
+ this.total = res.rst.pageInfo.total;
|
|
106
|
+ this.pages = res.rst.pageInfo.pages;
|
|
107
|
+ } else if (res.errno != 4002) {
|
|
108
|
+ this.$message.warning(res.err)
|
|
109
|
+ }
|
|
110
|
+ } catch (error) {
|
|
111
|
+ console.log('error => ', error)
|
|
112
|
+ } finally {
|
|
113
|
+ this.loading = false
|
|
114
|
+ }
|
|
115
|
+ },
|
|
116
|
+ handleCommand(command) {
|
|
117
|
+ const [eventName, groupId, groupName] = command.split('/')
|
|
118
|
+ if (eventName == eventOptions.EDIT) {
|
|
119
|
+ this.editGroup(groupName, groupId)
|
|
120
|
+ } else if (eventName == eventOptions.DELETE) {
|
|
121
|
+ this.deleGroup(groupId)
|
|
122
|
+ }
|
|
123
|
+ },
|
|
124
|
+ editGroup(groupName, groupId) {
|
|
125
|
+ //修改分组
|
|
126
|
+ this.$nextTick(() => {
|
|
127
|
+ this.dialogTitle = "修改";
|
|
128
|
+ this.$refs.dialogGroupRef.groupName = groupName;
|
|
129
|
+ this.groupId = groupId;
|
|
130
|
+ this.$refs.dialogGroupRef.dialogVisible = true;
|
|
131
|
+ });
|
|
132
|
+ },
|
|
133
|
+ // 删除分组
|
|
134
|
+ async deleGroup(groupId) {
|
|
135
|
+ try {
|
|
136
|
+ await this.$confirm("此操作将永久删除该分组, 是否继续?", "提示", {
|
|
137
|
+ confirmButtonText: "确定",
|
|
138
|
+ cancelButtonText: "取消",
|
|
139
|
+ type: "warning",
|
|
140
|
+ })
|
|
141
|
+ this.loading = true
|
|
142
|
+ const { data: res = {} } = await this.$axios.post(this.URL.BASEURL + this.URL.channel_deleGroup, {
|
|
143
|
+ id: groupId,
|
|
144
|
+ del_sqs: 0, //是否删除子活码
|
|
145
|
+ })
|
|
146
|
+ if (res && res.errno == 0) {
|
|
147
|
+ this.init();
|
|
148
|
+ } else if (res.errno != 4002) {
|
|
149
|
+ this.$message.warning(res.err)
|
|
150
|
+ this.loading = false
|
|
151
|
+ }
|
|
152
|
+ } catch (error) {
|
|
153
|
+ console.log('error => ', error)
|
|
154
|
+ this.loading = false
|
|
155
|
+ }
|
|
156
|
+ },
|
|
157
|
+ async draggableSort() {
|
|
158
|
+ try {
|
|
159
|
+ this.loading = true;
|
|
160
|
+ const ids = this.tableData.map(item => item.id)
|
|
161
|
+ const { data: res = {} } = await this.$axios.post(this.URL.BASEURL + this.URL.channel_sortGroup, { ids })
|
|
162
|
+ if (res && res.errno == 0) {
|
|
163
|
+ // this.init()
|
|
164
|
+ } else if (res.errno != 4002) {
|
|
165
|
+ this.$message.warning(res.err)
|
|
166
|
+ }
|
|
167
|
+ } catch (error) {
|
|
168
|
+ console.log('error => ', error)
|
|
169
|
+ } finally {
|
|
170
|
+ this.loading = false
|
|
171
|
+ }
|
|
172
|
+ },
|
|
173
|
+ itemClick(id) {
|
|
174
|
+ this.acIdx = id
|
|
175
|
+ this.$emit('changeGroupId', id)
|
|
176
|
+ },
|
|
177
|
+ },
|
|
178
|
+};
|
|
179
|
+</script>
|
|
180
|
+
|
|
181
|
+<style lang="scss" scoped>
|
|
182
|
+.ghostClass {
|
|
183
|
+ font-weight: 600;
|
|
184
|
+}
|
|
185
|
+.title {
|
|
186
|
+ padding: 10px;
|
|
187
|
+ display: flex;
|
|
188
|
+ align-items: center;
|
|
189
|
+ justify-content: space-between;
|
|
190
|
+ .addGroupBox {
|
|
191
|
+ color: #00b38a;
|
|
192
|
+ font-size: 13px;
|
|
193
|
+ cursor: pointer;
|
|
194
|
+ }
|
|
195
|
+}
|
|
196
|
+.listBox {
|
|
197
|
+ margin-top: 10px;
|
|
198
|
+ .item_css {
|
|
199
|
+ display: flex;
|
|
200
|
+ align-items: center;
|
|
201
|
+ padding: 15px 10px;
|
|
202
|
+ font-size: 14px;
|
|
203
|
+ cursor: pointer;
|
|
204
|
+ border-left: 2px solid transparent;
|
|
205
|
+ .el-icon-folder {
|
|
206
|
+ margin-right: 4px;
|
|
207
|
+ color: #00b38a;
|
|
208
|
+ }
|
|
209
|
+ .el-icon-more {
|
|
210
|
+ //transform:rotate(90deg);
|
|
211
|
+ font-size: 12px;
|
|
212
|
+ color: #999;
|
|
213
|
+ cursor: pointer;
|
|
214
|
+ }
|
|
215
|
+ }
|
|
216
|
+ .ac_css,
|
|
217
|
+ .item_css:hover {
|
|
218
|
+ border-left: 2px solid #00b38a;
|
|
219
|
+ background-color: rgba(0, 179, 138, 0.1);
|
|
220
|
+ }
|
|
221
|
+}
|
|
222
|
+</style>
|