|
|
1
|
+<template>
|
|
|
2
|
+ <el-container>
|
|
|
3
|
+ <el-main>
|
|
|
4
|
+ <el-card style="background-color: #F5F7FA">
|
|
|
5
|
+ <!-- 搜素区域 -->
|
|
|
6
|
+ <el-row>
|
|
|
7
|
+ <el-col :span="24" align="left">
|
|
|
8
|
+ <el-button type="warning" size="medium" icon="el-icon-search" @click="loadRouter" :loading="loadingStatus">
|
|
|
9
|
+ 加载已配置消息
|
|
|
10
|
+ </el-button>
|
|
|
11
|
+ <el-button type="primary" size="medium" icon="el-icon-plus" @click="batchAddRouter" :loading="loadingStatus">
|
|
|
12
|
+ 生成路由
|
|
|
13
|
+ </el-button>
|
|
|
14
|
+ </el-col>
|
|
|
15
|
+ </el-row>
|
|
|
16
|
+ <el-divider></el-divider>
|
|
|
17
|
+ <el-row>
|
|
|
18
|
+ <div style="border: 6px solid #6F8294;">
|
|
|
19
|
+ <el-row style="margin: -2px">
|
|
|
20
|
+ <el-col :span="6">
|
|
|
21
|
+ <el-row class="bt">
|
|
|
22
|
+ <span>选择消息发送者</span>
|
|
|
23
|
+ </el-row>
|
|
|
24
|
+ <el-row>
|
|
|
25
|
+ <el-tree
|
|
|
26
|
+ :data="sndr"
|
|
|
27
|
+ show-checkbox
|
|
|
28
|
+ node-key="username"
|
|
|
29
|
+ :props="userProps"
|
|
|
30
|
+ ref="sndrTree"
|
|
|
31
|
+ @check-change="treeSndrCheckChange"
|
|
|
32
|
+
|
|
|
33
|
+ >
|
|
|
34
|
+ </el-tree>
|
|
|
35
|
+ </el-row>
|
|
|
36
|
+ </el-col>
|
|
|
37
|
+ <el-col :span="6" align="center">
|
|
|
38
|
+ <el-row class="bt">
|
|
|
39
|
+ <span>选择要发送的消息类型</span>
|
|
|
40
|
+ </el-row>
|
|
|
41
|
+ <el-row>
|
|
|
42
|
+ <el-tree
|
|
|
43
|
+ :data="message_type"
|
|
|
44
|
+ show-checkbox
|
|
|
45
|
+ node-key="name"
|
|
|
46
|
+ default-expand-all
|
|
|
47
|
+ check-strictly
|
|
|
48
|
+ :props="defaultProps"
|
|
|
49
|
+ highlight-current
|
|
|
50
|
+ ref="typeTree"
|
|
|
51
|
+ @check-change="treeTypeCheckChange"
|
|
|
52
|
+ >
|
|
|
53
|
+ </el-tree>
|
|
|
54
|
+ </el-row>
|
|
|
55
|
+ </el-col>
|
|
|
56
|
+ <el-col :span="6">
|
|
|
57
|
+ <el-row class="bt">
|
|
|
58
|
+ <span>选择消息接收者</span>
|
|
|
59
|
+ </el-row>
|
|
|
60
|
+ <el-row>
|
|
|
61
|
+ <el-tree
|
|
|
62
|
+ :data="rcvr"
|
|
|
63
|
+ show-checkbox
|
|
|
64
|
+ node-key="id"
|
|
|
65
|
+ :props="userProps"
|
|
|
66
|
+ ref="rcvrTree"
|
|
|
67
|
+ @check-change="treeRcvrCheckChange"
|
|
|
68
|
+ >
|
|
|
69
|
+ </el-tree>
|
|
|
70
|
+ </el-row>
|
|
|
71
|
+ </el-col>
|
|
|
72
|
+ <el-col :span="6">
|
|
|
73
|
+ <el-row class="bt">
|
|
|
74
|
+ <span>消息路由配置其他属性</span>
|
|
|
75
|
+ </el-row>
|
|
|
76
|
+ <el-row>
|
|
|
77
|
+ <el-form :inline="true" :model="params" class="demo-form-inline" align="center" style="border:3px solid #6F8294;height: 800px;padding-top: 15px">
|
|
|
78
|
+ <el-form-item label="路由状态:">
|
|
|
79
|
+ <el-select v-model="params.status" placeholder="请选择" style="width: 150px" size="mini">
|
|
|
80
|
+ <el-option
|
|
|
81
|
+ v-for="item in status_options"
|
|
|
82
|
+ :key="item.value"
|
|
|
83
|
+ :label="item.label"
|
|
|
84
|
+ :value="item.value">
|
|
|
85
|
+ <span style="float: left">{{ item.label }}</span>
|
|
|
86
|
+ <span style="float: right; color: #8492a6; font-size: 13px">{{ item.value }}</span>
|
|
|
87
|
+ </el-option>
|
|
|
88
|
+ </el-select>
|
|
|
89
|
+ </el-form-item>
|
|
|
90
|
+ <el-form-item label="路由用途:">
|
|
|
91
|
+ <el-select v-model="params.usage" placeholder="请选择" style="width: 150px" size="mini">
|
|
|
92
|
+ <el-option
|
|
|
93
|
+ v-for="item in usage_options"
|
|
|
94
|
+ :key="item.value"
|
|
|
95
|
+ :label="item.label"
|
|
|
96
|
+ :value="item.value">
|
|
|
97
|
+ <span style="float: left">{{ item.label }}</span>
|
|
|
98
|
+ <span style="float: right; color: #8492a6; font-size: 13px">{{ item.value }}</span>
|
|
|
99
|
+ </el-option>
|
|
|
100
|
+ </el-select>
|
|
|
101
|
+ </el-form-item>
|
|
|
102
|
+ <el-form-item label="路由描述:">
|
|
|
103
|
+ <el-input type="textarea" v-model="params.des" style="width: 150px" size="mini"></el-input>
|
|
|
104
|
+ </el-form-item>
|
|
|
105
|
+ </el-form>
|
|
|
106
|
+ </el-row>
|
|
|
107
|
+ </el-col>
|
|
|
108
|
+ </el-row>
|
|
|
109
|
+
|
|
|
110
|
+ </div>
|
|
|
111
|
+ </el-row>
|
|
|
112
|
+ </el-card>
|
|
|
113
|
+ </el-main>
|
|
|
114
|
+ </el-container>
|
|
|
115
|
+</template>
|
|
|
116
|
+
|
|
|
117
|
+<script>
|
|
|
118
|
+ import { getAlltype,api_batchAddRouter,loadRouterBySndr } from "../../api/message_bus";
|
|
|
119
|
+ export default {
|
|
|
120
|
+ name: "Configure",
|
|
|
121
|
+
|
|
|
122
|
+ data() {
|
|
|
123
|
+ return {
|
|
|
124
|
+ loadingStatus: false,
|
|
|
125
|
+ sndr: [],
|
|
|
126
|
+ rcvr: [],
|
|
|
127
|
+ api_back: [],
|
|
|
128
|
+ params:{
|
|
|
129
|
+ sndr: '',
|
|
|
130
|
+ sndrs: [],
|
|
|
131
|
+ types: [],
|
|
|
132
|
+ rcvrs: [],
|
|
|
133
|
+ status: 1,
|
|
|
134
|
+ usage: 2,
|
|
|
135
|
+ des: "",
|
|
|
136
|
+ ver: "1.0"
|
|
|
137
|
+ },
|
|
|
138
|
+ status_options:[
|
|
|
139
|
+ {
|
|
|
140
|
+ label: "启用",
|
|
|
141
|
+ value: 1
|
|
|
142
|
+ },
|
|
|
143
|
+ {
|
|
|
144
|
+ label:"关闭",
|
|
|
145
|
+ value: 0
|
|
|
146
|
+ }
|
|
|
147
|
+ ],
|
|
|
148
|
+ usage_options:[
|
|
|
149
|
+ {
|
|
|
150
|
+ label: "生产用",
|
|
|
151
|
+ value: 1
|
|
|
152
|
+ },
|
|
|
153
|
+ {
|
|
|
154
|
+ label:"测试用",
|
|
|
155
|
+ value: 2
|
|
|
156
|
+ }
|
|
|
157
|
+ ],
|
|
|
158
|
+ message_type: [{
|
|
|
159
|
+ id: 1,
|
|
|
160
|
+ name: '航班动态(1)',
|
|
|
161
|
+ children: [{
|
|
|
162
|
+ id: 7,
|
|
|
163
|
+ name: '',
|
|
|
164
|
+ children: [{
|
|
|
165
|
+ id: 8,
|
|
|
166
|
+ name: ''
|
|
|
167
|
+ }, {
|
|
|
168
|
+ id: 9,
|
|
|
169
|
+ name: ''
|
|
|
170
|
+ }]
|
|
|
171
|
+ }]
|
|
|
172
|
+ }, {
|
|
|
173
|
+ id: 2,
|
|
|
174
|
+ name: '航班历史(2)',
|
|
|
175
|
+ children: [{
|
|
|
176
|
+ id: 7,
|
|
|
177
|
+ name: '',
|
|
|
178
|
+ children: [{
|
|
|
179
|
+ id: 8,
|
|
|
180
|
+ name: ''
|
|
|
181
|
+ }, {
|
|
|
182
|
+ id: 9,
|
|
|
183
|
+ name: ''
|
|
|
184
|
+ }]
|
|
|
185
|
+ }]
|
|
|
186
|
+ }, {
|
|
|
187
|
+ id: 3,
|
|
|
188
|
+ name: '卡口业务交换信息(80)',
|
|
|
189
|
+ children: [{
|
|
|
190
|
+ id: 4,
|
|
|
191
|
+ name: '卡口业务数据(KAKO)',
|
|
|
192
|
+ children: [{
|
|
|
193
|
+ id: 5,
|
|
|
194
|
+ name: 'ALL'
|
|
|
195
|
+ }, {
|
|
|
196
|
+ id: 6,
|
|
|
197
|
+ name: '卡口车单绑定关系数据(CARB)'
|
|
|
198
|
+ }]
|
|
|
199
|
+ }]
|
|
|
200
|
+ }],
|
|
|
201
|
+ defaultProps: {
|
|
|
202
|
+ children: 'children',
|
|
|
203
|
+ label: function (data,node) {
|
|
|
204
|
+ return '[' + data.name+ ']' + data.des;
|
|
|
205
|
+ },
|
|
|
206
|
+ disabled: 'disabled'
|
|
|
207
|
+ },
|
|
|
208
|
+ userProps: {
|
|
|
209
|
+ children: 'children',
|
|
|
210
|
+ label: function (data, node) {
|
|
|
211
|
+ return '('+data.username + ')' + data.des;
|
|
|
212
|
+ }
|
|
|
213
|
+ }
|
|
|
214
|
+ }
|
|
|
215
|
+ },
|
|
|
216
|
+ methods: {
|
|
|
217
|
+ typeFilterNode(treeList) {
|
|
|
218
|
+ let _this = this;
|
|
|
219
|
+ if (Array.isArray(treeList)){
|
|
|
220
|
+ treeList.forEach(function(item,index){
|
|
|
221
|
+ if (item.type == 1 || item.type==2){
|
|
|
222
|
+ item.disabled = true;
|
|
|
223
|
+ }
|
|
|
224
|
+ if (item.children !== undefined){
|
|
|
225
|
+ _this.typeFilterNode(item.children);
|
|
|
226
|
+ }
|
|
|
227
|
+ })
|
|
|
228
|
+ }
|
|
|
229
|
+
|
|
|
230
|
+ },
|
|
|
231
|
+ getAllType() {
|
|
|
232
|
+ let _this =this;
|
|
|
233
|
+ _this.loadingStatus = true;
|
|
|
234
|
+ getAlltype().then((response) => {
|
|
|
235
|
+ let res = response.data;
|
|
|
236
|
+ if (res.code !== '200') {
|
|
|
237
|
+ _this.loadingStatus = false;
|
|
|
238
|
+ return _this.$message.error('获取消息类型失败!');
|
|
|
239
|
+ }
|
|
|
240
|
+ // 获取列表数据
|
|
|
241
|
+ _this.message_type = res.data;
|
|
|
242
|
+ // _this.typeFilterNode(_this.message_type);
|
|
|
243
|
+ // 关闭加载
|
|
|
244
|
+ _this.$message.success('获取消息类型成功!');
|
|
|
245
|
+ _this.loadingStatus = false;
|
|
|
246
|
+ }).catch(error => {
|
|
|
247
|
+ // 关闭加载
|
|
|
248
|
+ _this.$message.error(error.toString());
|
|
|
249
|
+ _this.loadingStatus = false;
|
|
|
250
|
+ });
|
|
|
251
|
+ },
|
|
|
252
|
+ /**
|
|
|
253
|
+ * 访问用户服务,绑定用户列表,按组搜索
|
|
|
254
|
+ */
|
|
|
255
|
+ getUserInfo(){
|
|
|
256
|
+ let userResponse = [{
|
|
|
257
|
+ id: 1,
|
|
|
258
|
+ username: "zp260",
|
|
|
259
|
+ des: "测试用户1"
|
|
|
260
|
+ }, {
|
|
|
261
|
+ id: 2,
|
|
|
262
|
+ username: "test04",
|
|
|
263
|
+ des: "测试用户2"
|
|
|
264
|
+ },
|
|
|
265
|
+ {
|
|
|
266
|
+ id: 3,
|
|
|
267
|
+ username: "zp2505",
|
|
|
268
|
+ des: "测试用户3"
|
|
|
269
|
+ }
|
|
|
270
|
+ ];
|
|
|
271
|
+ this.sndr = userResponse;
|
|
|
272
|
+ this.rcvr = userResponse;
|
|
|
273
|
+ },
|
|
|
274
|
+ treeSndrCheckChange(data, checked, indeterminate) {
|
|
|
275
|
+ if (checked) {
|
|
|
276
|
+ this.params.sndrs.push(data.username);
|
|
|
277
|
+ } else {
|
|
|
278
|
+ this.params.sndrs.splice(this.params.sndrs.contains(data.username), 1);
|
|
|
279
|
+ }
|
|
|
280
|
+ },
|
|
|
281
|
+ treeRcvrCheckChange(data, checked, indeterminate) {
|
|
|
282
|
+ if (checked) {
|
|
|
283
|
+ this.params.rcvrs.push(data.username);
|
|
|
284
|
+ } else {
|
|
|
285
|
+ this.params.rcvrs.splice(this.params.rcvrs.contains(data.username), 1);
|
|
|
286
|
+ }
|
|
|
287
|
+ },
|
|
|
288
|
+ treeTypeCheckChange(data, checked, indeterminate) {
|
|
|
289
|
+ let mt = {
|
|
|
290
|
+ name:'',
|
|
|
291
|
+ type:0
|
|
|
292
|
+ };
|
|
|
293
|
+ mt.name = data.name;
|
|
|
294
|
+ mt.type = data.type;
|
|
|
295
|
+ if (checked) {
|
|
|
296
|
+ this.params.types.push(mt);
|
|
|
297
|
+ } else {
|
|
|
298
|
+ this.params.types.splice(this.params.types.contains(mt), 1);
|
|
|
299
|
+ }
|
|
|
300
|
+ console.log(this.params.types);
|
|
|
301
|
+ },
|
|
|
302
|
+ loadRouter(){
|
|
|
303
|
+ let _this = this;
|
|
|
304
|
+ this.loadingStatus = true;
|
|
|
305
|
+ if(this.params.sndrs.length !== 1){
|
|
|
306
|
+ this.$confirm('请选择单个发送者', '错误', {
|
|
|
307
|
+ confirmButtonText: '确定',
|
|
|
308
|
+ type: 'error',
|
|
|
309
|
+ center: true
|
|
|
310
|
+ }).then(() => {
|
|
|
311
|
+ _this.loadingStatus = false;
|
|
|
312
|
+ }).catch(() => {
|
|
|
313
|
+
|
|
|
314
|
+ });
|
|
|
315
|
+ }else{
|
|
|
316
|
+ let pam = {
|
|
|
317
|
+ sndr: _this.params.sndrs[0]
|
|
|
318
|
+ };
|
|
|
319
|
+ loadRouterBySndr(pam).then(response => {
|
|
|
320
|
+ let res = response.data;
|
|
|
321
|
+ if (res.code !== '200') {
|
|
|
322
|
+ return _this.$message.error('读取用户路由,失败!');
|
|
|
323
|
+ }
|
|
|
324
|
+ _this.api_back = res.data;
|
|
|
325
|
+ _this.loadRouterHandle();
|
|
|
326
|
+ // 关闭加载
|
|
|
327
|
+ _this.$message.success('读取用户路由,成功!');
|
|
|
328
|
+ _this.loadingStatus = false;
|
|
|
329
|
+ }).catch(
|
|
|
330
|
+ error => {
|
|
|
331
|
+ // 关闭加载
|
|
|
332
|
+ _this.$message.error(error.toString());
|
|
|
333
|
+ _this.loadingStatus = false;
|
|
|
334
|
+ }
|
|
|
335
|
+ )
|
|
|
336
|
+ }
|
|
|
337
|
+ },
|
|
|
338
|
+ loadRouterHandle(){
|
|
|
339
|
+ if (Array.isArray(this.api_back) && this.api_back.length>0){
|
|
|
340
|
+ let typeList = [];
|
|
|
341
|
+ this.api_back.forEach(function(routerItem,index){
|
|
|
342
|
+ typeList.push({name:routerItem.stype});
|
|
|
343
|
+ });
|
|
|
344
|
+ this.typeTreeSet(typeList);
|
|
|
345
|
+ }
|
|
|
346
|
+ },
|
|
|
347
|
+ typeTreeSet(typeList){
|
|
|
348
|
+ this.$refs.typeTree.setCheckedNodes(typeList);
|
|
|
349
|
+ },
|
|
|
350
|
+ batchAddRouter() {
|
|
|
351
|
+ let _this = this;
|
|
|
352
|
+ _this.loadingStatus = true;
|
|
|
353
|
+ api_batchAddRouter(this.params).then(response => {
|
|
|
354
|
+ let res = response.data;
|
|
|
355
|
+ if (res.code !== '200') {
|
|
|
356
|
+ return _this.$message.error('批量添加路由,失败!');
|
|
|
357
|
+ }
|
|
|
358
|
+ // 关闭加载
|
|
|
359
|
+ _this.$message.success('批量添加路由,成功!');
|
|
|
360
|
+ _this.loadingStatus = false;
|
|
|
361
|
+ _this.resetPage();
|
|
|
362
|
+ }).catch(
|
|
|
363
|
+ error => {
|
|
|
364
|
+ // 关闭加载
|
|
|
365
|
+ _this.$message.error(error.toString());
|
|
|
366
|
+ _this.loadingStatus = false;
|
|
|
367
|
+ }
|
|
|
368
|
+ )
|
|
|
369
|
+ },
|
|
|
370
|
+ resetPage() {
|
|
|
371
|
+ this.$refs.sndrTree.setCheckedKeys([]);
|
|
|
372
|
+ this.$refs.typeTree.setCheckedKeys([]);
|
|
|
373
|
+ this.$refs.rcvrTree.setCheckedKeys([]);
|
|
|
374
|
+ }
|
|
|
375
|
+ },
|
|
|
376
|
+ mounted() {
|
|
|
377
|
+ this.getAllType();
|
|
|
378
|
+ this.getUserInfo();
|
|
|
379
|
+ }
|
|
|
380
|
+
|
|
|
381
|
+ }
|
|
|
382
|
+</script>
|
|
|
383
|
+
|
|
|
384
|
+<style scoped>
|
|
|
385
|
+ .bt {
|
|
|
386
|
+ font-weight: bold;
|
|
|
387
|
+ background-color: #6F8294;
|
|
|
388
|
+ color: #ffffff;
|
|
|
389
|
+ text-align: center
|
|
|
390
|
+ }
|
|
|
391
|
+ .el-col {
|
|
|
392
|
+ margin-right: 0px;
|
|
|
393
|
+ }
|
|
|
394
|
+ .el-tree {
|
|
|
395
|
+ padding-top: 15px;
|
|
|
396
|
+ border:3px solid #6F8294;
|
|
|
397
|
+ height: 800px
|
|
|
398
|
+ }
|
|
|
399
|
+ .el-row .el-col .el-row {
|
|
|
400
|
+ margin-top: 0px;
|
|
|
401
|
+ }
|
|
|
402
|
+</style> |