作者 朱兆平

批量添加路由

@@ -5,10 +5,12 @@ @@ -5,10 +5,12 @@
5 <!-- 搜素区域 --> 5 <!-- 搜素区域 -->
6 <el-row> 6 <el-row>
7 <el-col :span="24" align="left"> 7 <el-col :span="24" align="left">
8 - <el-button type="warning" size="medium" icon="el-icon-search" @click="loadRouter" :loading="loadingStatus"> 8 + <el-button type="warning" size="medium" icon="el-icon-search" @click="loadRouter"
  9 + :loading="loadingStatus">
9 加载已配置消息 10 加载已配置消息
10 </el-button> 11 </el-button>
11 - <el-button type="primary" size="medium" icon="el-icon-plus" @click="batchAddRouter" :loading="loadingStatus"> 12 + <el-button type="primary" size="medium" icon="el-icon-plus" @click="batchAddRouter"
  13 + :loading="loadingStatus">
12 生成路由 14 生成路由
13 </el-button> 15 </el-button>
14 </el-col> 16 </el-col>
@@ -62,7 +64,7 @@ @@ -62,7 +64,7 @@
62 :data="rcvr" 64 :data="rcvr"
63 show-checkbox 65 show-checkbox
64 node-key="id" 66 node-key="id"
65 - :props="userProps" 67 + :props="queueProps"
66 ref="rcvrTree" 68 ref="rcvrTree"
67 @check-change="treeRcvrCheckChange" 69 @check-change="treeRcvrCheckChange"
68 > 70 >
@@ -74,9 +76,11 @@ @@ -74,9 +76,11 @@
74 <span>消息路由配置其他属性</span> 76 <span>消息路由配置其他属性</span>
75 </el-row> 77 </el-row>
76 <el-row> 78 <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"> 79 + <el-form :inline="true" :model="params" class="demo-form-inline" align="center"
  80 + style="border:3px solid #6F8294;height: 800px;padding-top: 15px">
78 <el-form-item label="路由状态:"> 81 <el-form-item label="路由状态:">
79 - <el-select v-model="params.status" placeholder="请选择" style="width: 150px" size="mini"> 82 + <el-select v-model="params.status" placeholder="请选择" style="width: 150px"
  83 + size="mini">
80 <el-option 84 <el-option
81 v-for="item in status_options" 85 v-for="item in status_options"
82 :key="item.value" 86 :key="item.value"
@@ -88,7 +92,8 @@ @@ -88,7 +92,8 @@
88 </el-select> 92 </el-select>
89 </el-form-item> 93 </el-form-item>
90 <el-form-item label="路由用途:"> 94 <el-form-item label="路由用途:">
91 - <el-select v-model="params.usage" placeholder="请选择" style="width: 150px" size="mini"> 95 + <el-select v-model="params.usage" placeholder="请选择" style="width: 150px"
  96 + size="mini">
92 <el-option 97 <el-option
93 v-for="item in usage_options" 98 v-for="item in usage_options"
94 :key="item.value" 99 :key="item.value"
@@ -100,7 +105,8 @@ @@ -100,7 +105,8 @@
100 </el-select> 105 </el-select>
101 </el-form-item> 106 </el-form-item>
102 <el-form-item label="路由描述:"> 107 <el-form-item label="路由描述:">
103 - <el-input type="textarea" v-model="params.des" style="width: 150px" size="mini"></el-input> 108 + <el-input type="textarea" v-model="params.des" style="width: 150px"
  109 + size="mini"></el-input>
104 </el-form-item> 110 </el-form-item>
105 </el-form> 111 </el-form>
106 </el-row> 112 </el-row>
@@ -115,7 +121,8 @@ @@ -115,7 +121,8 @@
115 </template> 121 </template>
116 122
117 <script> 123 <script>
118 - import { getAlltype,api_batchAddRouter,loadRouterBySndr } from "../../api/message_bus"; 124 + import {getAlltype, api_batchAddRouter, loadRouterBySndr, selectBusQueueList} from "../../api/message_bus";
  125 +
119 export default { 126 export default {
120 name: "Configure", 127 name: "Configure",
121 128
@@ -125,7 +132,7 @@ @@ -125,7 +132,7 @@
125 sndr: [], 132 sndr: [],
126 rcvr: [], 133 rcvr: [],
127 api_back: [], 134 api_back: [],
128 - params:{ 135 + params: {
129 sndr: '', 136 sndr: '',
130 sndrs: [], 137 sndrs: [],
131 types: [], 138 types: [],
@@ -135,38 +142,44 @@ @@ -135,38 +142,44 @@
135 des: "", 142 des: "",
136 ver: "1.0" 143 ver: "1.0"
137 }, 144 },
138 - status_options:[ 145 + status_options: [
139 { 146 {
140 label: "启用", 147 label: "启用",
141 value: 1 148 value: 1
142 }, 149 },
143 { 150 {
144 - label:"关闭", 151 + label: "关闭",
145 value: 0 152 value: 0
146 } 153 }
147 ], 154 ],
148 - usage_options:[ 155 + usage_options: [
149 { 156 {
150 label: "生产用", 157 label: "生产用",
151 value: 1 158 value: 1
152 }, 159 },
153 { 160 {
154 - label:"测试用", 161 + label: "测试用",
155 value: 2 162 value: 2
156 } 163 }
157 ], 164 ],
158 message_type: [], 165 message_type: [],
159 defaultProps: { 166 defaultProps: {
160 children: 'children', 167 children: 'children',
161 - label: function (data,node) {  
162 - return '[' + data.name+ ']' + data.des; 168 + label: function (data, node) {
  169 + return '[' + data.name + ']' + data.des;
163 }, 170 },
164 disabled: 'disabled' 171 disabled: 'disabled'
165 }, 172 },
166 userProps: { 173 userProps: {
167 children: 'children', 174 children: 'children',
168 label: function (data, node) { 175 label: function (data, node) {
169 - return '('+data.username + ')' + data.des; 176 + return '(' + data.username + ')' + data.des;
  177 + }
  178 + },
  179 + queueProps:{
  180 + children: 'children',
  181 + label: function (data, node) {
  182 + return '(' + data.queueName + ')' + data.description;
170 } 183 }
171 } 184 }
172 } 185 }
@@ -174,12 +187,12 @@ @@ -174,12 +187,12 @@
174 methods: { 187 methods: {
175 typeFilterNode(treeList) { 188 typeFilterNode(treeList) {
176 let _this = this; 189 let _this = this;
177 - if (Array.isArray(treeList)){  
178 - treeList.forEach(function(item,index){  
179 - if (item.type == 1 || item.type==2){ 190 + if (Array.isArray(treeList)) {
  191 + treeList.forEach(function (item, index) {
  192 + if (item.type == 1 || item.type == 2) {
180 item.disabled = true; 193 item.disabled = true;
181 } 194 }
182 - if (item.children !== undefined){ 195 + if (item.children !== undefined) {
183 _this.typeFilterNode(item.children); 196 _this.typeFilterNode(item.children);
184 } 197 }
185 }) 198 })
@@ -187,7 +200,7 @@ @@ -187,7 +200,7 @@
187 200
188 }, 201 },
189 getAllType() { 202 getAllType() {
190 - let _this =this; 203 + let _this = this;
191 _this.loadingStatus = true; 204 _this.loadingStatus = true;
192 getAlltype().then((response) => { 205 getAlltype().then((response) => {
193 let res = response.data; 206 let res = response.data;
@@ -210,7 +223,7 @@ @@ -210,7 +223,7 @@
210 /** 223 /**
211 * 访问用户服务,绑定用户列表,按组搜索 224 * 访问用户服务,绑定用户列表,按组搜索
212 */ 225 */
213 - getUserInfo(){ 226 + getUserInfo() {
214 let userResponse = [{ 227 let userResponse = [{
215 id: 1, 228 id: 1,
216 username: "zp260", 229 username: "zp260",
@@ -227,7 +240,6 @@ @@ -227,7 +240,6 @@
227 } 240 }
228 ]; 241 ];
229 this.sndr = userResponse; 242 this.sndr = userResponse;
230 - this.rcvr = userResponse;  
231 }, 243 },
232 treeSndrCheckChange(data, checked, indeterminate) { 244 treeSndrCheckChange(data, checked, indeterminate) {
233 if (checked) { 245 if (checked) {
@@ -238,15 +250,15 @@ @@ -238,15 +250,15 @@
238 }, 250 },
239 treeRcvrCheckChange(data, checked, indeterminate) { 251 treeRcvrCheckChange(data, checked, indeterminate) {
240 if (checked) { 252 if (checked) {
241 - this.params.rcvrs.push(data.username); 253 + this.params.rcvrs.push(data.queueName);
242 } else { 254 } else {
243 - this.params.rcvrs.splice(this.params.rcvrs.contains(data.username), 1); 255 + this.params.rcvrs.splice(this.params.rcvrs.contains(data.queueName), 1);
244 } 256 }
245 }, 257 },
246 treeTypeCheckChange(data, checked, indeterminate) { 258 treeTypeCheckChange(data, checked, indeterminate) {
247 let mt = { 259 let mt = {
248 - name:'',  
249 - type:0 260 + name: '',
  261 + type: 0
250 }; 262 };
251 mt.name = data.name; 263 mt.name = data.name;
252 mt.type = data.type; 264 mt.type = data.type;
@@ -257,10 +269,10 @@ @@ -257,10 +269,10 @@
257 } 269 }
258 console.log(this.params.types); 270 console.log(this.params.types);
259 }, 271 },
260 - loadRouter(){ 272 + loadRouter() {
261 let _this = this; 273 let _this = this;
262 this.loadingStatus = true; 274 this.loadingStatus = true;
263 - if(this.params.sndrs.length !== 1){ 275 + if (this.params.sndrs.length !== 1) {
264 this.$confirm('请选择单个发送者', '错误', { 276 this.$confirm('请选择单个发送者', '错误', {
265 confirmButtonText: '确定', 277 confirmButtonText: '确定',
266 type: 'error', 278 type: 'error',
@@ -268,9 +280,9 @@ @@ -268,9 +280,9 @@
268 }).then(() => { 280 }).then(() => {
269 _this.loadingStatus = false; 281 _this.loadingStatus = false;
270 }).catch(() => { 282 }).catch(() => {
271 - 283 + _this.loadingStatus = false;
272 }); 284 });
273 - }else{ 285 + } else {
274 let pam = { 286 let pam = {
275 sndr: _this.params.sndrs[0] 287 sndr: _this.params.sndrs[0]
276 }; 288 };
@@ -293,21 +305,22 @@ @@ -293,21 +305,22 @@
293 ) 305 )
294 } 306 }
295 }, 307 },
296 - loadRouterHandle(){  
297 - if (Array.isArray(this.api_back) && this.api_back.length>0){ 308 + loadRouterHandle() {
  309 + if (Array.isArray(this.api_back) && this.api_back.length > 0) {
298 let typeList = []; 310 let typeList = [];
299 - this.api_back.forEach(function(routerItem,index){  
300 - typeList.push({name:routerItem.stype}); 311 + this.api_back.forEach(function (routerItem, index) {
  312 + typeList.push({name: routerItem.stype});
301 }); 313 });
302 this.typeTreeSet(typeList); 314 this.typeTreeSet(typeList);
303 } 315 }
304 }, 316 },
305 - typeTreeSet(typeList){ 317 + typeTreeSet(typeList) {
306 this.$refs.typeTree.setCheckedNodes(typeList); 318 this.$refs.typeTree.setCheckedNodes(typeList);
307 }, 319 },
308 batchAddRouter() { 320 batchAddRouter() {
309 let _this = this; 321 let _this = this;
310 _this.loadingStatus = true; 322 _this.loadingStatus = true;
  323 + //todo: 生产者列表,消费者列表,及路由类型判空后再访问接口
311 api_batchAddRouter(this.params).then(response => { 324 api_batchAddRouter(this.params).then(response => {
312 let res = response.data; 325 let res = response.data;
313 console.log(res) 326 console.log(res)
@@ -331,11 +344,33 @@ @@ -331,11 +344,33 @@
331 this.$refs.sndrTree.setCheckedKeys([]); 344 this.$refs.sndrTree.setCheckedKeys([]);
332 this.$refs.typeTree.setCheckedKeys([]); 345 this.$refs.typeTree.setCheckedKeys([]);
333 this.$refs.rcvrTree.setCheckedKeys([]); 346 this.$refs.rcvrTree.setCheckedKeys([]);
  347 + },
  348 + queue_getList() {
  349 + let queue_queryInfo = {
  350 + // 当前页数
  351 + pageNum: 1,
  352 + // 每页条数
  353 + pageSize: 100000
  354 + };
  355 + selectBusQueueList(queue_queryInfo).then((response) => {
  356 + let res = response.data;
  357 + if (res.code !== '200') {
  358 + // 关闭加载
  359 + return this.$message.error(res.msg);
  360 + }
  361 + // 获取列表数据
  362 + this.rcvr = res.data.list;
  363 + this.$message.success(res.msg);
  364 + }).catch(error => {
  365 + // 关闭加载
  366 + this.$message.error(error.toString());
  367 + });
334 } 368 }
335 }, 369 },
336 mounted() { 370 mounted() {
337 this.getAllType(); 371 this.getAllType();
338 this.getUserInfo(); 372 this.getUserInfo();
  373 + this.queue_getList();
339 } 374 }
340 375
341 } 376 }
@@ -348,14 +383,17 @@ @@ -348,14 +383,17 @@
348 color: #ffffff; 383 color: #ffffff;
349 text-align: center 384 text-align: center
350 } 385 }
  386 +
351 .el-col { 387 .el-col {
352 margin-right: 0px; 388 margin-right: 0px;
353 } 389 }
  390 +
354 .el-tree { 391 .el-tree {
355 padding-top: 15px; 392 padding-top: 15px;
356 - border:3px solid #6F8294; 393 + border: 3px solid #6F8294;
357 height: 800px 394 height: 800px
358 } 395 }
  396 +
359 .el-row .el-col .el-row { 397 .el-row .el-col .el-row {
360 margin-top: 0px; 398 margin-top: 0px;
361 } 399 }