Browse Source

feat: 客户欢迎语 - 支持成员&状态筛选&删除

zhengxy 1 year ago
parent
commit
9bfbb8ae90

+ 1 - 0
project/src/assets/config/interface_api.js

@@ -29,6 +29,7 @@ var api = {
29 29
   blackList: "/api/customer/blackList",
30 30
   removeCustomerFromBlackList: "/api/customer/removeCustomerFromBlackList",
31 31
   welcomeMsg_lists: "/api/welcomeMsg/lists",
32
+  welcomeMsg_ruleDel: "/api/welcomeMsg/ruleDel",
32 33
   welcomeMsg_set: "/api/welcomeMsg/set",
33 34
   welcomeMsg_detail: "/api/welcomeMsg/detail",
34 35
   welcomeMsg_updateStatus: "/api/welcomeMsg/updateStatus",

+ 109 - 5
project/src/components/customOperate/welcomeMsg.vue

@@ -1,5 +1,11 @@
1 1
 <template>
2 2
   <div>
3
+    <div class="screenBox">
4
+      <!-- 使用成员 -->
5
+      <serviceSingle style="width: auto;" title="使用成员" placeholder="请选择" @customerDefine="onChangeUserId" />
6
+      <!-- 状态 -->
7
+      <selfChannelV2 v-model="status" type="enableStatus" title="状态" :labelWidth="true" @change="onChangeStatus" />
8
+    </div>
3 9
     <div class="tableInfo">
4 10
       <div>
5 11
         <div class="flex">
@@ -36,16 +42,23 @@
36 42
       </el-table-column>
37 43
       <el-table-column prop="updated_at" label="更新时间" show-overflow-tooltip align="center"></el-table-column>
38 44
       <el-table-column prop="created_at" label="创建时间" show-overflow-tooltip align="center"></el-table-column>
39
-      <el-table-column label="是否可用" show-overflow-tooltip align="center">
45
+      <el-table-column label="状态" align="center">
46
+        <template slot-scope="{ row }">
47
+          <el-switch v-if="row.enable !== ''"  v-model="row.enable" :active-value="1" :inactive-value="0" disabled @click.native="onClickStatus(row)" />
48
+          <div v-else> - </div>
49
+        </template>
50
+      </el-table-column>
51
+      <!-- <el-table-column label="是否可用" show-overflow-tooltip align="center">
40 52
         <template slot-scope="scope">
41 53
           <div>{{scope.row.enable==0?'否':'是'}}</div>
42 54
         </template>
43
-      </el-table-column>
55
+      </el-table-column> -->
44 56
       <el-table-column label="操作" align="center">
45 57
         <template slot-scope="scope">
46 58
           <div class="flex" style="justify-content:center">
47
-            <div :class="['pointer',scope.row.enable == 1 ? 'c-FF604D' :'c-007AFF']" style="margin:0 6px" @click="welcomeMsg_del(scope.row)">{{scope.row.enable == 1 ? '禁用' : '启用'}}</div>
59
+            <!-- <div :class="['pointer',scope.row.enable == 1 ? 'c-FF604D' :'c-007AFF']" @click="welcomeMsg_del(scope.row)">{{scope.row.enable == 1 ? '禁用' : '启用'}}</div> -->
48 60
             <div class="c-00B38A pointer" style="margin:0 6px" @click="goDetail(scope.row.rule_id)">编辑</div>
61
+            <div class="c-FF604D pointer" @click="onClickDelete(scope.row)">删除</div>
49 62
           </div>
50 63
         </template>
51 64
       </el-table-column>
@@ -57,7 +70,11 @@
57 70
   </div>
58 71
 </template>
59 72
 <script>
73
+import serviceSingle from '@/components/assembly/screen/serviceSingle.vue'
74
+import selfChannelV2 from '@/components/assembly/screen/channelV2.vue'
75
+
60 76
 export default {
77
+  components: { serviceSingle, selfChannelV2 },
61 78
   data () {
62 79
     return {
63 80
       loading: false,
@@ -66,7 +83,9 @@ export default {
66 83
       total: 0,
67 84
       page_size: 20,
68 85
       tableData: [],
69
-      height: ''
86
+      height: '',
87
+      user_id: '',
88
+      status: '',
70 89
     }
71 90
   },
72 91
   created () {
@@ -74,6 +93,42 @@ export default {
74 93
     this.init(1)
75 94
   },
76 95
   methods: {
96
+    // 监听点击切换"状态"
97
+    async onClickStatus(row) {
98
+      try {
99
+        await this.$confirm(`确定${row.enable == 0 ? '启用' : '禁用'}【${row.name}】?`, '提示', {
100
+          confirmButtonText: '确定',
101
+          cancelButtonText: '取消',
102
+          type: 'warning'
103
+        })
104
+        this.$loading(this.$loadingConfig);
105
+        this.$axios.get(this.URL.BASEURL + this.URL.welcomeMsg_updateStatus, {
106
+          params: {
107
+            rule_id: row.rule_id,
108
+            status: row.enable == 1 ? 0 : 1
109
+          }
110
+        }).then((res) => {
111
+          var res = res.data;
112
+          this.$loading(this.$loadingConfig).close();
113
+          if (res && res.errno == 0) {
114
+            this.$message({
115
+              message: '操作成功!',
116
+              type: 'success'
117
+            })
118
+            this.init(1)
119
+          } else {
120
+            this.$message({
121
+              message: res.err,
122
+              type: 'warning'
123
+            })
124
+          }
125
+        }).catch(() => {
126
+          this.$loading(this.$loadingConfig).close();
127
+        })
128
+      } catch (error) {
129
+        console.log(error)
130
+      }
131
+    },
77 132
     welcomeMsg_del (item) {
78 133
       this.$confirm(`确定${item.enable == 1 ? '禁用' : '启用'}【${item.name}】?`, '提示', {
79 134
         confirmButtonText: '确定',
@@ -118,6 +173,8 @@ export default {
118 173
       this.loading = true
119 174
       this.$axios.get(this.URL.BASEURL + this.URL.welcomeMsg_lists, {
120 175
         params: {
176
+          user_id: this.user_id,
177
+          status: this.status,
121 178
           page: this.page,
122 179
           page_size: this.page_size
123 180
         }
@@ -140,7 +197,48 @@ export default {
140 197
     },
141 198
     handleCurrentChange (val) {
142 199
       this.init(val)
143
-    }
200
+    },
201
+
202
+    onChangeUserId(val) {
203
+       this.user_id = val ? val.user_id : ''
204
+      this.init(1)
205
+    },
206
+    onChangeStatus(val) {
207
+      this.status = val
208
+      this.init(1)
209
+    },
210
+    onClickDelete(info){
211
+      this.$confirm(`确定要删除“${info.name}”吗?`, '提示', {
212
+        confirmButtonText: '确定',
213
+        cancelButtonText: '取消',
214
+        type: 'warning'
215
+      }).then(() => {
216
+        this.$loading(this.$loadingConfig)
217
+        this.$axios.get(this.URL.BASEURL + this.URL.welcomeMsg_ruleDel, {
218
+          params: {
219
+            rule_id: info.rule_id,
220
+            corpid: info.corpid,
221
+          }
222
+        }).then((res) => {
223
+          var res = res.data
224
+          this.$loading(this.$loadingConfig).close()
225
+          if (res && res.errno == 0) {
226
+            this.init()
227
+            this.$message({
228
+              type: 'success',
229
+              message: '删除成功!'
230
+            });
231
+          } else if (res.errno != 4002) {
232
+            this.$message({
233
+              message: res.err,
234
+              type: "warning"
235
+            })
236
+          }
237
+        }).catch(()=>{
238
+          this.$loading(this.$loadingConfig).close()
239
+        })
240
+      }).catch(() => {});
241
+    },
144 242
   }
145 243
 }
146 244
 </script>
@@ -149,4 +247,10 @@ export default {
149 247
 .tableInfo {
150 248
   height: 50px;
151 249
 }
250
+/deep/ .el-switch.is-disabled .el-switch__core {
251
+  cursor: pointer;
252
+}
253
+/deep/ .el-switch.is-disabled {
254
+  opacity: 1;
255
+}
152 256
 </style>