Browse Source

feat: 企微助手 - 群活码 - 列表框架&渠道分组&分组接口联调

zhengxy 2 years ago
parent
commit
a58256dcec

+ 222 - 0
project/src/components/groupCode/components/channelGroup.vue

@@ -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>

+ 107 - 0
project/src/components/groupCode/components/dialogGroup.vue

@@ -0,0 +1,107 @@
1
+<template>
2
+  <el-dialog
3
+    :append-to-body="true"
4
+    custom-class="channel_code_group"
5
+    :title="propsData.dialogTitle + '分组'"
6
+    :visible.sync="dialogVisible"
7
+    width="30%"
8
+  >
9
+    <div class="dialogBox" v-loading="loading">
10
+      <div class="lable">分组名称</div>
11
+      <el-input
12
+        size="small"
13
+        placeholder="请输入内容"
14
+        maxlength="8"
15
+        show-word-limit
16
+        v-model="groupName"
17
+        clearable
18
+      />
19
+    </div>
20
+    <span slot="footer" class="dialog-footer">
21
+      <el-button size="mini" @click="dialogVisible = false">取 消</el-button>
22
+      <el-button size="mini" type="primary" @click="save(propsData.dialogTitle)">确 定</el-button>
23
+    </span>
24
+  </el-dialog>
25
+</template>
26
+
27
+<script>
28
+export default {
29
+  name: "dialogGroup",
30
+  props: ["propsData"],
31
+  data() {
32
+    return {
33
+      groupName: "",
34
+      dialogVisible: false,
35
+      loading: false,
36
+    };
37
+  },
38
+  methods: {
39
+    save(type) {
40
+      if (type == "修改") {
41
+        this.editGroup();
42
+      } else {
43
+        this.addGroup();
44
+      }
45
+    },
46
+    async addGroup() {
47
+      if (this.groupName == "") {
48
+        this.$message.warning("分组名必填")
49
+        return
50
+      }
51
+      try {
52
+        this.loading = true;
53
+        const { data: res = {} } = await this.$axios.post(this.URL.BASEURL + this.URL.channel_addGroup, {
54
+          name: this.groupName,
55
+          type: 2, // 1:渠道活码 2:群活码
56
+        })
57
+        if (res && res.errno == 0) {
58
+          this.$message.success(res.err)
59
+          this.dialogVisible = false;
60
+          this.$emit("init");
61
+        }
62
+      } catch (error) {
63
+        console.log('error => ', error)
64
+      } finally {
65
+        this.loading = false;
66
+      }
67
+    },
68
+    async editGroup() {
69
+      if (this.groupName == "") {
70
+        this.$message.warning("分组名必填")
71
+        return;
72
+      }
73
+      try {
74
+        this.loading = true;
75
+        const { data: res = {} } = await this.$axios.post(this.URL.BASEURL + this.URL.channel_editGroup, {
76
+          id: this.propsData.groupId,
77
+          name: this.groupName,
78
+        })
79
+        if (res && res.errno == 0) {
80
+          this.$message.success(res.err);
81
+          this.dialogVisible = false;
82
+          this.$emit("init");
83
+        }
84
+      } catch (error) {
85
+        console.log('error => ', error)
86
+      } finally {
87
+        this.loading = false
88
+      }
89
+    },
90
+  },
91
+};
92
+</script>
93
+
94
+<style lang="scss">
95
+.channel_code_group {
96
+  .dialogBox {
97
+    display: flex;
98
+    align-items: center;
99
+    .lable {
100
+      font-weight: 600;
101
+      margin-right: 10px;
102
+      font-size: 14px;
103
+      flex-shrink: 0;
104
+    }
105
+  }
106
+}
107
+</style>

+ 125 - 0
project/src/components/groupCode/index.vue

@@ -0,0 +1,125 @@
1
+<template>
2
+  <div class="con">
3
+    <div class="searchBox">
4
+      <el-button type="primary" size="mini">新建渠道群活码</el-button>
5
+      <selfInput :reset="reset" label_name="搜索渠道" @inputChange="onInputChangeChannel" />
6
+      <div class="reset" @click="resetEvent">重置</div>
7
+    </div>
8
+    <div class="mainBox">
9
+      <div class="groupBox">
10
+        <channelGroup @changeGroupId="onChangeGroupId" />
11
+      </div>
12
+      <div class="tableBox">
13
+        <!-- 列表 -->
14
+      </div>
15
+    </div>
16
+  </div>
17
+</template>
18
+
19
+<script>
20
+import selfInput from '@/components/assembly/screen/input.vue'
21
+import channelGroup from './components/channelGroup.vue'
22
+
23
+export default {
24
+  name: "groupCodeIndex",
25
+  components: {
26
+    selfInput,
27
+    channelGroup,
28
+  },
29
+  data() {
30
+    return {
31
+      reset: false, // 重置标识
32
+      params: {
33
+        group_id: '', // 分组id
34
+        name: '', // 搜索渠道关键字
35
+        page: 1,
36
+        page_size: 20,
37
+      }
38
+    }
39
+  },
40
+  created() {
41
+    this.handleGetCodeList()
42
+  },
43
+  methods: {
44
+    // 获取群活码列表
45
+    handleGetCodeList() {
46
+      console.log('handleGetCodeList => ',)
47
+      console.log('this.params => ', this.params)
48
+    },
49
+    // 搜索渠道
50
+    onInputChangeChannel(keyword) {
51
+      console.log('onInputChangeChannel => ', keyword)
52
+      this.params.name = keyword || ''
53
+      this.params.page = 1
54
+      this.handleGetCodeList()
55
+    },
56
+    onChangeGroupId(group_id) {
57
+      this.params.group_id = group_id
58
+      this.params.page = 1
59
+      this.handleGetCodeList()
60
+    },
61
+    // 重置
62
+    resetEvent () {
63
+      this.reset = !this.reset
64
+      this.params.name = ''
65
+      this.params.page = 1
66
+      this.handleGetCodeList()
67
+    },
68
+  }
69
+}
70
+</script>
71
+
72
+<style lang="scss" scoped>
73
+.con{
74
+  padding-right: 10px;
75
+  .searchBox{
76
+    display: flex;
77
+    align-items: center;
78
+    background-color: #fff;
79
+    padding: 5px 10px ;
80
+    position: relative;
81
+    .reset {
82
+      width: 80px;
83
+      height: 30px;
84
+      background: #00b38a;
85
+      border-radius: 100px 3px 3px 3px;
86
+      border: 1px solid #d2d2d2;
87
+      color: #ffffff;
88
+      font-size: 14px;
89
+      line-height: 30px;
90
+      text-align: center;
91
+      position: absolute;
92
+      bottom: 0;
93
+      right: 0;
94
+      letter-spacing: 2px;
95
+      cursor: pointer;
96
+    }
97
+  }
98
+  .mainBox{
99
+    display: flex;
100
+    align-items: flex-start;
101
+    margin-top: 10px;
102
+    .groupBox{
103
+      width: 20%;
104
+      background-color: #fff;
105
+      flex-shrink: 0;
106
+      margin-right: 10px;
107
+      height: calc(100vh - 60px - 62px - 20px - 10px);
108
+      overflow-y: auto;
109
+      &::-webkit-scrollbar{
110
+        width: 3px;
111
+      }
112
+    }
113
+    .tableBox{
114
+      flex: 1;
115
+      background-color: #fff;
116
+      height: calc(100vh - 60px - 62px - 20px - 10px);
117
+      overflow-y: auto;
118
+      &::-webkit-scrollbar{
119
+        width: 3px;
120
+      }
121
+    }
122
+  }
123
+}
124
+
125
+</style>

+ 13 - 0
project/src/router/allRouter.js

@@ -45,6 +45,9 @@ const code_dataAnalyse = () => import(/* webpackChunkName: 'dataAnalyse' */ '@/c
45 45
 const createChannelCode = () => import(/* webpackChunkName: 'createChannelCode' */ '@/components/channelCode/createChannelCode.vue')
46 46
 const radarIndex = () => import(/* webpackChunkName: 'radarIndex' */ '@/components/customOperate/sideTool/smartRadar/index.vue')
47 47
 
48
+const groupCodeIndex = () => import(/* webpackChunkName: 'groupCodeIndex' */ '@/components/groupCode/index.vue')
49
+
50
+
48 51
 // name与菜单配置的页面路由一致
49 52
 // meta下isData:true为数据看板,否则为助手
50 53
 export var allRouter = [
@@ -115,6 +118,16 @@ export var allRouter = [
115 118
         }
116 119
       },
117 120
       {
121
+        path: 'groupCodeIndex',
122
+        name: 'groupCodeIndex',
123
+        component: groupCodeIndex,
124
+        meta: {
125
+          keepAlive: false,
126
+          isLogin: true,
127
+          title: '渠道群活码'
128
+        }
129
+      },
130
+      {
118 131
         path: 'codeIndex',
119 132
         name: 'codeIndex',
120 133
         component: codeIndex,