RouterManage.vue
28.0 KB
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
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
<template>
<el-container>
<el-main>
<el-card style="background-color: #F5F7FA">
<!-- 搜素区域 -->
<el-row>
<el-col :span="5">
<el-input v-model="umb_queryInfo.sndr"
size="mini"
placeholder="帐户名称" clearable>
<template slot="prepend" ><i class="el-icon-user"></i>帐户名称</template>
</el-input>
</el-col>
<el-col :span="5">
<el-input v-model="umb_queryInfo.btype"
size="mini"
placeholder="消息大类" clearable>
<template slot="prepend"><i class="el-icon-s-platform"></i>消息大类</template>
</el-input>
</el-col>
<el-col :span="5">
<el-input v-model="umb_queryInfo.stype"
size="mini"
placeholder="消息子类" clearable>
<template slot="prepend"><i class="el-icon-s-operation"></i>消息子类</template>
</el-input>
</el-col>
<el-col :span="5">
<el-button type="warning" size="mini" icon="el-icon-search" @click="queryRouterList">
查询
</el-button>
<el-button type="primary" size="mini" icon="el-icon-plus" @click="addFormShow">
添加
</el-button>
</el-col>
</el-row>
<el-row>
<el-col :span="24">
<el-table
:data="umb_queryData.tableData"
border size="small"
:header-cell-style="{background:'#6F8294',color:'#FFFFFF'}"
style="border-radius: 10px 10px 0px 0px;line-height: 25px">
<el-table-column
prop="sndr"
label="帐户名称"
width="80"
align="center"
>
</el-table-column>
<el-table-column
prop="btype"
label="消息大类"
width="80"
align="center"
>
</el-table-column>
<el-table-column
prop="stype"
label="消息子类"
width="80"
align="center"
>
</el-table-column>
<el-table-column
prop="rcvr_topic"
label="订阅者"
width="300"
align="center"
>
<template slot-scope="scope" style="text-align: right">
<div v-for="reciver in scope.row.rcvrList" v-bind:key="reciver.id" style="text-align: right;margin-right: 40px">
{{reciver.rcvrTopic}}
<el-button type="text" size="mini" @click="delReceiverFiletery(reciver.id)">[删除]</el-button><!--,{{reciver.filterList.filter}}-->
<el-button type="text" size="mini" @click="addReceiverFiletery(reciver.id)">[增加过滤]</el-button>
<!-- <div v-for="filters in reciver.filterList">{{filters.filter}}</div>-->
</div>
<div style="text-align: right;margin-right: 40px">
<el-button type="text" size="mini" @click="addRcvr(scope.$index,scope.row)">[增加订阅者]</el-button>
</div>
</template>
</el-table-column>
<el-table-column
prop="filter"
label="过滤规则"
width="450"
align="center"
>
<template slot-scope="scope">
<div v-for="reciver in scope.row.rcvrList">
<!-- {{reciver.rcvrTopic}},{{reciver.filterList.filter}}-->
<div v-for="filters in reciver.filterList">[{{reciver.rcvrTopic}}]:{{filters.filter}}</div>
</div>
</template>
</el-table-column>
<el-table-column label="操作" width="150px" align="center" fixed="right">
<template slot-scope="scope">
<el-button type="primary" size="mini" @click="editRouter(scope.$index,scope.row)">编辑</el-button>
<el-button type="danger" size="mini" @click="delRouter(scope.$index,scope.row)">删除</el-button>
</template>
</el-table-column>
</el-table>
</el-col>
</el-row>
<el-row>
<div class="block">
<el-pagination
@size-change="handleSizeChange"
@current-change="handleCurrentChange"
:current-page="umb_queryInfo.pageNum"
:page-sizes="[10, 20, 50, 100]"
:page-size="umb_queryInfo.pageSize"
layout="total, sizes, prev, pager, next, jumper"
:total="umb_queryData.total">
</el-pagination>
</div>
</el-row>
<!-- 编辑-->
<el-row>
<el-dialog title="编辑" :visible.sync="dialogFormVisibles" width="70%" style="margin-top: -20px" text-align="center">
<el-form :model="ruleForm" :rules="rules" ref="ruleForm" label-width="145px"
class="demo-ruleForm" style="margin-top: -10px ;margin-left: -150px" align="center" >
<el-form-item label="" prop="sndr">
<el-input v-model="ruleForm.sndr" style="width:300px" size="small">
<template slot="prepend" >账户名称</template>
</el-input>
</el-form-item>
<el-form-item label="" prop="btype">
<el-input v-model="ruleForm.btype" style="width:300px" size="small">
<template slot="prepend" >消息大类</template>
</el-input>
</el-form-item>
<el-form-item label="" prop="stype">
<el-input v-model="ruleForm.stype" style="width:300px" size="small">
<template slot="prepend" >消息子类</template>
</el-input>
</el-form-item>
</el-form>
<div slot="footer" class="dialog-footer" align="center">
<el-button @click="dialogFormVisibles = false" size="medium"
style="width: 100px;background-color: #6F8294;color: #ffffff">取 消</el-button>
<el-button type="primary" size="medium" style="width: 100px" @click="submitEdit('ruleForm')">确 定</el-button>
</div>
</el-dialog>
</el-row>
<!-- 添加/增加订阅者-->
<el-row>
<el-dialog :title="dialogMap[dialogStatus]" :visible.sync="dialogFormVisible" width="70%" style="margin-top: -20px" text-align="center">
<el-form :model="ruleForm" :rules="rules" ref="ruleForm" label-width="145px"
class="demo-ruleForm" style="margin-top: -10px ;margin-left: -150px" align="center" >
<el-form-item label="" prop="sndr">
<el-input v-model="ruleForm.sndr" style="width:300px" size="small">
<template slot="prepend" >账户名称</template>
</el-input>
</el-form-item>
<el-form-item label="" prop="btype">
<el-input v-model="ruleForm.btype" style="width:300px" size="small">
<template slot="prepend" >消息大类</template>
</el-input>
</el-form-item>
<el-form-item label="" prop="stype">
<el-input v-model="ruleForm.stype" style="width:300px" size="small">
<template slot="prepend" >消息子类</template>
</el-input>
</el-form-item>
</el-form>
<Queue v-on:getQueueListEvent="getQueueInfo"></Queue>
<div slot="footer" class="dialog-footer" align="center">
<el-button @click="dialogFormVisible = false" size="medium"
style="width: 100px;background-color: #6F8294;color: #ffffff">取 消</el-button>
<el-button type="primary" size="medium" style="width: 100px" @click="dialogStatus==='create'?submitForm('ruleForm'):subRcvrForm()">确 定</el-button>
</div>
</el-dialog>
</el-row>
<el-row>
<el-dialog :title="dialogMap[dialogStatus]" :visible.sync="dialogFilterVisible" width="40%" style="margin-top: 100px">
<!-- <RouterFilter v-bind:propRouterReceiveId="selectReceiverId"> </RouterFilter>-->
<el-form :inline="true" label-width="120px" status-icon style="margin-top: -10px"
:model="queue_addForm" :rules="queue_addFormRules" ref="queue_addFormRef" align="center">
<el-form-item label="过滤规则" prop="filter">
<el-input v-model="queue_addForm.filter" style="width:250px" size="small" clearable
placeholder="请输入过滤规则">
</el-input>
</el-form-item>
<el-form-item label="状态" prop="status">
<el-select v-model="queue_addForm.status" style="width:250px" size="small" clearable
placeholder="请选择状态">
<el-option label="true" value="true"></el-option>
<el-option label="false" value="false"></el-option>
</el-select>
</el-form-item>
<el-form-item label="规则类型" prop="type">
<el-input v-model="queue_addForm.type" style="width:250px" size="small" clearable
placeholder="请输入规则类型" disabled></el-input>
</el-form-item>
<el-form-item label="订阅者ID" prop="messageRouterReciverId">
<el-input v-model="queue_addForm.messageRouterReciverId" style="width:250px" size="small" clearable
placeholder="请输入用户ID" disabled></el-input>
</el-form-item>
<!-- <el-form-item label="状态" prop="status" style="margin-left: -60px">-->
<!-- <el-select v-model="queue_addForm.status" style="width:250px" size="small" clearable-->
<!-- placeholder="请选择状态">-->
<!-- <el-option label="true" ></el-option>-->
<!-- <el-option label="false"></el-option>-->
<!-- </el-select>-->
<!-- </el-form-item>-->
<!-- <el-form-item label="" prop="filter">-->
<!-- <el-input v-model="queue_addForm.filter" style="width:300px" size="small" clearable-->
<!-- placeholder="请输入过滤规则">-->
<!-- <template slot="prepend" >过滤规则</template>-->
<!-- </el-input>-->
<!-- </el-form-item>-->
<!-- <el-form-item label="" prop="type">-->
<!-- <el-input v-model="queue_addForm.type" style="width:300px" size="small" clearable-->
<!-- placeholder="请输入规则类型" disabled>-->
<!-- <template slot="prepend" >规则类型</template>-->
<!-- </el-input>-->
<!-- </el-form-item>-->
<!-- <el-form-item label="" prop="messageRouterReciverId">-->
<!-- <el-input v-model="queue_addForm.messageRouterReciverId" style="width:300px" size="small" clearable-->
<!-- placeholder="订阅者ID" disabled>-->
<!-- <template slot="prepend" >订阅者ID</template>-->
<!-- </el-input>-->
<!-- </el-form-item>-->
</el-form>
<div slot="footer" class="dialog-footer" style="text-align: center;margin-top: -20px">
<el-button type="info" @click="dialogFilterVisible = false" size="medium"
style="width: 100px;background-color: #6F8294;color: #ffffff">取消
</el-button>
<el-button type="primary" @click="queue_add()"
size="medium" style="width: 100px">提交
</el-button>
</div>
</el-dialog>
</el-row>
</el-card>
</el-main>
</el-container>
</template>
<script>
import {
queRouter,
deleteRouter,
addRouter,
api_addReceiverFileter,
deleteMessage,
addRcvrs,
delRcvr,
ediRcvr,
updateMessage
} from "../../api/message_bus";
import Queue from "@/views/bus/Queue";
import RouterFilter from "@/views/bus/RouterReceiverFilter";
export default {
components: { Queue,RouterFilter },
data(){
return{
dialogFormVisibles:false,
dialogMap: {
create: '新增',
update: '增加订阅者',
},
dialogStatus: 'create',
/**
* queue,新增表单
*/
queue_addForm: {
filter: '',
messageRouterReciverId: '',
type: 'REGULAR',
status:'true'
},
/**
* queue,添加表单,验证规则
*/
queue_addFormRules: {
// 队列名称
filter: [
{required: true, message: '请输入过滤规则', trigger: ['blur', 'change']},
],
// 用户名称
type: [
{required: true, message: '请输入规则类型', trigger: ['blur', 'change']},
],
// 所属虚拟机id
messageRouterReciverId: [
{required: true, message: '请输入订阅者ID', trigger: ['blur', 'change']},
],
// // 所属虚拟机id
// virtualHostId: [
// {required: true, message: '请选择所属虚拟机', trigger: ['blur', 'change']},
// ],
// // 是否持久化,默认 true
// durability: [
// {required: true, message: '请选择是否持久化', trigger: ['blur', 'change']},
// ],
// // 是否自动删除,默认 false
// autoDelete: [
// {required: true, message: '请选择是否自动删除', trigger: ['blur', 'change']},
// ],
// // 扩展参数,以JSON格式存储
// arguments: [
// {required: true, message: '扩展参数', trigger: ['blur', 'change']},
// ],
// // 相关描述
// description: [
// {required: true, message: '请输入相关描述', trigger: ['blur', 'change']},
// ],
},
selectReceiverId: '',
dialogFormVisible:false,
dialogFilterVisible:false,
ruleForm:{
sndr:undefined,
btype:undefined,
stype:undefined,
rcvrList:[
{
rcvrTopic:undefined,
filterList:{
filter: undefined,
filterValue: undefined
}
}
],
},
rules: {
sndr: [
{ required: true, message: '请输入账户名称', trigger: 'blur' }
],
btype: [
{ required: true, message: '请输入消息大类', trigger: 'blur' }
],
stype: [
{ required: true, message: '请输入消息子类', trigger: 'blur' }
]
},
user_cloud: {
cloudUserList: [],
queryInfo: {
pageNum: 1,
pageSize: 10000,
}
},
umb_queryInfo: {
// 用户名称
sndr: undefined,
// 消息大类
btype: undefined,
// 消息子类
stype: undefined,
// 当前页数
pageNum: 1,
// 每页条数
pageSize: 10
},
umb_queryData: {
tableData: [],
total:0
},
receiverFilterForm: {
filter: undefined,
type: 'REGULAR',
messageRouterReciverId: ''
}
}
},
methods: {
handleSizeChange(val) {
this.umb_queryInfo.pageSize=val;
this.queryRouterList();
},
handleCurrentChange(val) {
this.umb_queryInfo.pageNum=val;
this.queryRouterList();
},
addFormShow:function(){
this.dialogStatus= 'create';
this.dialogFormVisible = true;
},
queryRouterList(){
queRouter(this.umb_queryInfo).then((response) => {
let res = response.data;
console.log(res)
this.umb_queryData.tableData=res.data.list;
this.umb_queryData.total=res.data.total;
}).catch(error => {
});
},
// 打开新增订阅者
addRcvr:function(index,row){
this.dialogStatus= 'update';
this.dialogFormVisible = true;
this.ruleForm = Object.assign({}, row);
},
// 新增订阅者
subRcvrForm() {
this.$confirm('确认新增订阅者吗?', '提示', {
}).then(() => {
let para = Object.assign({}, this.ruleForm);
addRcvrs(para).then((res) => {
this.$message({
message: '提交成功',
type: 'success'
});
this.$refs['ruleForm'].resetFields();
this.dialogFormVisible = false;
this.queryRouterList();
}).catch(error => alert(error));
});
},
//删除
delReceiverFiletery: function (id) {
this.$confirm('确认删除该记录吗?', '提示', {
type: 'warning'
}).then(() => {
let para = { id: id };
//console.log(row);
delRcvr(para).then((res) => {
this.$message({
message: '删除成功',
type: 'success'
});
this.queryRouterList();
}).catch((error) => {
alert(error);
});
}).catch();
},
// 打开编辑
editRouter:function(index,row){
// this.dialogStatus= 'update';
this.dialogFormVisibles = true;
this.ruleForm = Object.assign({}, row);
},
//编辑
submitEdit: function () {
this.$refs.ruleForm.validate((valid) => {
if (valid) {
this.$confirm('确认提交吗?', '提示', {}).then(() => {
let para = Object.assign({}, this.ruleForm);
ediRcvr(para).then((res) => {
this.$message({
message: '提交成功',
type: 'success'
});
this.$refs['ruleForm'].resetFields();
this.dialogFormVisibles = false;
this.queryRouterList();
}).catch(error => alert(error));
});
}
});
},
delRouter(index,row){
// 弹框询问是否删除?
this.$confirm('此操作永久删除该消息收发记录, 是否继续?', '警告', {
confirmButtonText: '确定删除',
cancelButtonText: '取消',
type: 'warning'
}
).then(() => {
deleteRouter({id:row.id}).then((response) => {
let res = response.data;
this.$message.success(res.msg);
this.queryRouterList();
}).catch(error => {
this.$message.error(res.msg);
});
}).catch(() => {
});
},
submitForm(formName){
this.$refs[formName].validate((valid) => {
if (valid) {
addRouter(this.ruleForm).then((response) => {
let res = response.data;
this.dialogFormVisible=false;
this.$message.success(res.msg);
this.queryRouterList();
}).catch(error => {
this.$message.error(res.msg);
});
} else {
console.log('error submit!!');
return false;
}
});
},
getQueueInfo:function (queueInfo) {
let _this = this;
_this.ruleForm.rcvrList =[];
let reciverList = queueInfo;
if (reciverList.length>0){
reciverList.forEach(function (queue) {
let selectQueue = {};
selectQueue.rcvrTopic = queue.queueName
_this.ruleForm.rcvrList.push(selectQueue);
})
}
console.log(_this.ruleForm.rcvrList);
},
addReceiverFileter:function (receiverId) {
let _this = this;
_this.receiverFilterForm.messageRouterReciverId = receiverId;
},
//打开增加过滤
addReceiverFiletery(id){
this.dialogFilterVisible = true;
console.log(id)
this.queue_addForm.messageRouterReciverId = id;
},
//提交增加过滤
queue_add() {
// 进行表单的预验证
this.$refs.queue_addFormRef.validate(valid => {
// 未通过,表单预校验
if (!valid) return;
// 通过,表单预检验,开启加载
// this.queue_loading.addLoading = true;
api_addReceiverFileter(this.queue_addForm).then((response) => {
let res = response.data;
// 添加失败
if (res.code !== '200') {
// 关闭加载
// this.queue_loading.addLoading = false;
return this.$message.error(res.msg);
}
// 添加,成功
this.$message.success(res.msg);
// 关闭加载
// this.queue_loading.addLoading = false;
// 隐藏对话框
// this.queue_dialog.addDialog = false;
this.dialogFilterVisible = false;
// 刷新列表
this.queryRouterList();
}).catch(error => {
// 关闭加载
// this.queue_loading.addLoading = false;
this.$message.error(error.toString());
});
})
},
}
}
</script>
<style scoped></style>