@arkxos/arkos-app-gateway-manage 0.1.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +36 -0
- package/ark_dist/ark-meta.json +75 -0
- package/ark_dist/ark_userChunk_1.js +5 -0
- package/ark_dist/ark_userChunk_2.js +49 -0
- package/ark_dist/css/views/views-CreateGateway.41b2bde6.css +297 -0
- package/ark_dist/favicon.ico +0 -0
- package/ark_dist/img/404.png +0 -0
- package/ark_dist/img/auth_banner.jpg +0 -0
- package/ark_dist/img/avatar.jpg +0 -0
- package/ark_dist/img/avatar2.gif +0 -0
- package/ark_dist/img/avatar3.gif +0 -0
- package/ark_dist/img/loginbg.svg +1 -0
- package/ark_dist/img/logo-r.png +0 -0
- package/ark_dist/img/logo.png +0 -0
- package/ark_dist/img/no-widgets.svg +57 -0
- package/ark_dist/img/tasks-example.png +0 -0
- package/ark_dist/img/ver.svg +236 -0
- package/ark_dist/index.html +132 -0
- package/ark_dist/js/app.e014b7a5.js +1 -0
- package/ark_dist/js/views/views-CreateGateway.7db295a9.js +3 -0
- package/ark_dist/js/views/views-CreateGateway.7db295a9.js.LICENSE.txt +1 -0
- package/ark_dist/js/views/views-CreateGateway.7db295a9.js.map +1 -0
- package/ark_proxy/entry.js +30 -0
- package/ark_proxy_es/entry.js +18 -0
- package/package.json +156 -0
- package/scripts/check.js +13 -0
- package/scripts/meta.js +21 -0
- package/scripts/prepublishOnly.js +28 -0
- package/src/api/apidoc_api.js +35 -0
- package/src/api/authority.js +161 -0
- package/src/api/balanced_api.js +101 -0
- package/src/api/client_api.js +68 -0
- package/src/api/count_api.js +62 -0
- package/src/api/gateway-manage/client_api.js +68 -0
- package/src/api/gateway-manage/open_client.js +188 -0
- package/src/api/gateway_api.js +81 -0
- package/src/api/global_function.js +278 -0
- package/src/api/global_variable.js +35 -0
- package/src/api/groovyscript_api.js +130 -0
- package/src/api/ip_api.js +47 -0
- package/src/api/monitor_api.js +24 -0
- package/src/api/regserver_api.js +224 -0
- package/src/api/request.js +107 -0
- package/src/assets/font_1930435_u2cpsigmd9d.js +38 -0
- package/src/assets/font_ma6wg7gw3td/demo.css +539 -0
- package/src/assets/font_ma6wg7gw3td/demo_index.html +674 -0
- package/src/assets/font_ma6wg7gw3td/iconfont.css +105 -0
- package/src/assets/font_ma6wg7gw3td/iconfont.eot +0 -0
- package/src/assets/font_ma6wg7gw3td/iconfont.js +1 -0
- package/src/assets/font_ma6wg7gw3td/iconfont.json +163 -0
- package/src/assets/font_ma6wg7gw3td/iconfont.svg +92 -0
- package/src/assets/font_ma6wg7gw3td/iconfont.ttf +0 -0
- package/src/assets/font_ma6wg7gw3td/iconfont.woff +0 -0
- package/src/assets/font_ma6wg7gw3td/iconfont.woff2 +0 -0
- package/src/assets/logo.png +0 -0
- package/src/assets/particles.json +110 -0
- package/src/auto-imports.d.ts +307 -0
- package/src/component/BoxCard.vue +156 -0
- package/src/component/ClientInfo.vue +82 -0
- package/src/component/GroovyScriptTable.vue +74 -0
- package/src/component/PanThumb/index.vue +149 -0
- package/src/component/RouteAccessChart.vue +85 -0
- package/src/component/RouteInfo.vue +146 -0
- package/src/component/RouteRequestCount.vue +126 -0
- package/src/component/TextHoverEffect/Mallki.vue +120 -0
- package/src/configs/subApp.ts +9 -0
- package/src/entrance/libProperties.ts +30 -0
- package/src/entrance/libTypes.ts +27 -0
- package/src/main.ts +13 -0
- package/src/plugins/index.ts +11 -0
- package/src/router/constantRoutes.js +155 -0
- package/src/router/loadComponent.js +29 -0
- package/src/views/AddClientGateway.vue +253 -0
- package/src/views/AddGatewayClient.vue +360 -0
- package/src/views/AddGroovyScript.vue +337 -0
- package/src/views/ApiCount.vue +291 -0
- package/src/views/ApiDoc.vue +293 -0
- package/src/views/ApiMonitor.vue +292 -0
- package/src/views/ClientList.vue +217 -0
- package/src/views/CreateBalanced.vue +341 -0
- package/src/views/CreateClient.vue +171 -0
- package/src/views/CreateGateway.vue +836 -0
- package/src/views/GatewayList.vue +322 -0
- package/src/views/GatewayTopology.vue +245 -0
- package/src/views/IpList.vue +218 -0
- package/src/views/LoadBalanced.vue +389 -0
- package/src/views/Main.vue +98 -0
|
@@ -0,0 +1,217 @@
|
|
|
1
|
+
<template>
|
|
2
|
+
<div class="layout-padding">
|
|
3
|
+
<div class="layout-padding-auto layout-padding-view">
|
|
4
|
+
<div class="box-flex-between">
|
|
5
|
+
<el-button icon="el-icon-folder-add" type="primary" style="margin-left: 5px;" @click="handleCreateClient"></el-button>
|
|
6
|
+
|
|
7
|
+
<el-input placeholder="请输入客户端名称" v-model="form.name" class="input-with-select" style="width: 620px;" clearable>
|
|
8
|
+
<template #prepend>
|
|
9
|
+
<el-select v-model="form.groupCode" placeholder="请选择分组" style="width: 140px; margin-right: 10px;">
|
|
10
|
+
<el-option label="所有" value=""/>
|
|
11
|
+
<el-option v-for="item in groupOptions" :key="item.value" :label="item.label" :value="item.value"/>
|
|
12
|
+
</el-select>
|
|
13
|
+
<el-popover placement="bottom" trigger="click">
|
|
14
|
+
<el-radio v-model="form.status" v-for="item in statusOptions" :key="item.value" :label="item.value">{{item.label}}</el-radio>
|
|
15
|
+
<template #reference>
|
|
16
|
+
<el-button>
|
|
17
|
+
服务状态:{{form.status === '0' ? '启用': form.status === '1' ? '禁用' : '所有'}}<i class="el-icon-caret-bottom el-icon--right"></i>
|
|
18
|
+
</el-button>
|
|
19
|
+
</template>
|
|
20
|
+
</el-popover>
|
|
21
|
+
</template>
|
|
22
|
+
<template #append>
|
|
23
|
+
<el-button icon="el-icon-search" @click="search"></el-button>
|
|
24
|
+
</template>
|
|
25
|
+
</el-input>
|
|
26
|
+
</div>
|
|
27
|
+
|
|
28
|
+
<el-table size="small" :data="tableData" height="100%">
|
|
29
|
+
<el-table-column label="客户端ID(系统生成)" width="300">
|
|
30
|
+
<template #default="{ row }">
|
|
31
|
+
<el-tag size="small" type="warning" style="font-weight: bold;">{{row.id}}</el-tag>
|
|
32
|
+
</template>
|
|
33
|
+
</el-table-column>
|
|
34
|
+
<el-table-column label="分组">
|
|
35
|
+
<template #default="{ row }">
|
|
36
|
+
<el-tag v-for="group in groupOptions" :key="group.value" v-show="group.value === row.groupCode" size="small" type="">{{group.label}}</el-tag>
|
|
37
|
+
</template>
|
|
38
|
+
</el-table-column>
|
|
39
|
+
<el-table-column label="系统代号>客户端名称">
|
|
40
|
+
<template #default="{ row }">
|
|
41
|
+
<span style="font-weight: bold;" v-if="row.systemCode != undefined && row.systemCode != ''">{{row.systemCode}} ></span> {{row.name}}
|
|
42
|
+
</template>
|
|
43
|
+
</el-table-column>
|
|
44
|
+
<el-table-column label="IP地址">
|
|
45
|
+
<template #default="{ row }">
|
|
46
|
+
<el-tag size="small" type="success">{{row.ip}}</el-tag>
|
|
47
|
+
</template>
|
|
48
|
+
</el-table-column>
|
|
49
|
+
<el-table-column label="创建时间" prop="createTime" width="220"></el-table-column>
|
|
50
|
+
<el-table-column label="状态" prop="status" width="100">
|
|
51
|
+
<template #default="{ row }">
|
|
52
|
+
<el-tag effect="dark" size="small" v-if="row.status === '0'" type="">启用</el-tag>
|
|
53
|
+
<el-tag effect="dark" size="small" v-if="row.status === '1'" type="danger">禁用</el-tag>
|
|
54
|
+
</template>
|
|
55
|
+
</el-table-column>
|
|
56
|
+
<el-table-column label="备注" prop="remarks" width="350"></el-table-column>
|
|
57
|
+
<el-table-column label="操作" width="120">
|
|
58
|
+
<template #default="{ row }">
|
|
59
|
+
<el-dropdown trigger="click" @command="handleCommandClient">
|
|
60
|
+
<el-button size="small" type="warning">
|
|
61
|
+
管理
|
|
62
|
+
<el-icon><ArrowDown /></el-icon>
|
|
63
|
+
</el-button>
|
|
64
|
+
<template #dropdown>
|
|
65
|
+
<el-dropdown-menu>
|
|
66
|
+
<el-dropdown-item icon="el-icon-connection" :command="{command:'addGateway', row: row}">注册网关服务</el-dropdown-item>
|
|
67
|
+
<el-dropdown-item icon="el-icon-tickets" :command="{command:'info', row: row}">详情</el-dropdown-item>
|
|
68
|
+
<el-dropdown-item icon="el-icon-edit" :command="{command:'edit', row: row}">编辑</el-dropdown-item>
|
|
69
|
+
<el-dropdown-item :command="{command:'start', row: row}" divided><el-icon color="#409EFF"><CircleCheckFilled /></el-icon>启用</el-dropdown-item>
|
|
70
|
+
<el-dropdown-item :command="{command:'stop', row: row}"><el-icon color="#ff0000"><CircleCloseFilled /></el-icon>禁用</el-dropdown-item>
|
|
71
|
+
<el-dropdown-item icon="el-icon-delete" :command="{command:'delete', row: row}" divided>删除</el-dropdown-item>
|
|
72
|
+
</el-dropdown-menu>
|
|
73
|
+
</template>
|
|
74
|
+
</el-dropdown>
|
|
75
|
+
</template>
|
|
76
|
+
</el-table-column>
|
|
77
|
+
</el-table>
|
|
78
|
+
<div class="block">
|
|
79
|
+
<el-pagination
|
|
80
|
+
@size-change="handleSizeChange"
|
|
81
|
+
@current-change="handleCurrentChange"
|
|
82
|
+
:current-page="currentPage"
|
|
83
|
+
:page-sizes="[10, 30, 50]"
|
|
84
|
+
:page-size="pageSize"
|
|
85
|
+
layout="total, sizes, prev, pager, next, jumper"
|
|
86
|
+
:total="totalNum">
|
|
87
|
+
</el-pagination>
|
|
88
|
+
</div>
|
|
89
|
+
</div>
|
|
90
|
+
<el-drawer v-model="drawer" :direction="direction" :before-close="handleClose" :with-header="false" size="26%" @opened="handleOpenedClientInfo">
|
|
91
|
+
<!-- 父组件传参与子组件方法监听 -->
|
|
92
|
+
<clientInfoComponent ref="clientInfo" :infoForm="infoForm"></clientInfoComponent>
|
|
93
|
+
</el-drawer>
|
|
94
|
+
</div>
|
|
95
|
+
</template>
|
|
96
|
+
|
|
97
|
+
<script setup>
|
|
98
|
+
import { CircleCheckFilled, CircleCloseFilled, ArrowDown } from '@element-plus/icons-vue'
|
|
99
|
+
</script>
|
|
100
|
+
|
|
101
|
+
<script>
|
|
102
|
+
import { getCurrentInstance } from 'vue';
|
|
103
|
+
import {clientPageList, deleteClient, startClient, stopClient} from '../api/client_api.js'
|
|
104
|
+
import clientInfoComponent from '../component/ClientInfo.vue'
|
|
105
|
+
|
|
106
|
+
export default {
|
|
107
|
+
data() {
|
|
108
|
+
const me = getCurrentInstance();
|
|
109
|
+
const groups = me.proxy.GLOBAL_VAR.groups;
|
|
110
|
+
|
|
111
|
+
return {
|
|
112
|
+
form:{
|
|
113
|
+
name:null,
|
|
114
|
+
groupCode: null,
|
|
115
|
+
status: null
|
|
116
|
+
},
|
|
117
|
+
ip: null,
|
|
118
|
+
drawer: false,
|
|
119
|
+
direction: 'rtl',
|
|
120
|
+
infoForm:{},
|
|
121
|
+
tableData: [],
|
|
122
|
+
currentPage: 1,
|
|
123
|
+
pageSize: 10,
|
|
124
|
+
totalNum: 0,
|
|
125
|
+
statusOptions: [
|
|
126
|
+
{value: null, label: '所有'},
|
|
127
|
+
{value: '0',label: '启用'},
|
|
128
|
+
{value: '1',label: '禁用'},
|
|
129
|
+
],
|
|
130
|
+
groupOptions: groups
|
|
131
|
+
};
|
|
132
|
+
},
|
|
133
|
+
created: function() {
|
|
134
|
+
this.init();
|
|
135
|
+
},
|
|
136
|
+
components:{
|
|
137
|
+
clientInfoComponent
|
|
138
|
+
},
|
|
139
|
+
mounted: function() {
|
|
140
|
+
|
|
141
|
+
},
|
|
142
|
+
beforeDestroy: function() {
|
|
143
|
+
|
|
144
|
+
},
|
|
145
|
+
methods:{
|
|
146
|
+
init() {
|
|
147
|
+
this.search();
|
|
148
|
+
},
|
|
149
|
+
handleSizeChange(val) {
|
|
150
|
+
this.pageSize = val;
|
|
151
|
+
this.search();
|
|
152
|
+
},
|
|
153
|
+
handleCurrentChange(val) {
|
|
154
|
+
this.currentPage = val;
|
|
155
|
+
this.search();
|
|
156
|
+
},
|
|
157
|
+
handleCreateClient(){
|
|
158
|
+
this.$router.push({path:'/createClient',query:{handleType:'add'}});
|
|
159
|
+
},
|
|
160
|
+
handleOpenedClientInfo(){
|
|
161
|
+
this.$refs.clientInfo.init();
|
|
162
|
+
},
|
|
163
|
+
handleCommandClient(obj){
|
|
164
|
+
console.log("command" , obj);
|
|
165
|
+
let _this = this;
|
|
166
|
+
if (obj.command === 'addGateway'){
|
|
167
|
+
this.$router.push({path:'/addClientGateway',query:{client:obj.row}});
|
|
168
|
+
} else if (obj.command === 'info'){
|
|
169
|
+
this.drawer = true;
|
|
170
|
+
this.infoForm = obj.row;
|
|
171
|
+
} else if (obj.command === 'edit'){
|
|
172
|
+
this.infoForm = obj.row;
|
|
173
|
+
this.$router.push({path:'/createClient',query:{handleType:'edit',client:obj.row}});
|
|
174
|
+
} else if (obj.command === 'start'){
|
|
175
|
+
startClient({id:obj.row.id}).then(function(result){
|
|
176
|
+
_this.GLOBAL_FUN.successMsg();
|
|
177
|
+
_this.search();
|
|
178
|
+
});
|
|
179
|
+
} else if (obj.command === 'stop'){
|
|
180
|
+
stopClient({id:obj.row.id}).then(function(result){
|
|
181
|
+
_this.GLOBAL_FUN.successMsg();
|
|
182
|
+
_this.search();
|
|
183
|
+
});
|
|
184
|
+
} else if (obj.command === 'delete'){
|
|
185
|
+
this.$confirm('确认删除"'+obj.row.name+'"客户端?').then(_ => {
|
|
186
|
+
deleteClient({id:obj.row.id}).then(function(result){
|
|
187
|
+
_this.GLOBAL_FUN.successMsg();
|
|
188
|
+
_this.search();
|
|
189
|
+
})
|
|
190
|
+
}).catch(_ => {});
|
|
191
|
+
}
|
|
192
|
+
},
|
|
193
|
+
handleClose(done) {
|
|
194
|
+
done();
|
|
195
|
+
},
|
|
196
|
+
search(){
|
|
197
|
+
let _this = this;
|
|
198
|
+
clientPageList({name:this.form.name, status: this.form.status, groupCode: this.form.groupCode, ip: this.ip, currentPage: this.currentPage, pageSize: this.pageSize}).then(function(result){
|
|
199
|
+
if (result.data){
|
|
200
|
+
_this.tableData = result.data.records;
|
|
201
|
+
_this.totalNum = result.data.total;
|
|
202
|
+
}
|
|
203
|
+
});
|
|
204
|
+
}
|
|
205
|
+
}
|
|
206
|
+
};
|
|
207
|
+
</script>
|
|
208
|
+
|
|
209
|
+
<style lang="scss" scoped>
|
|
210
|
+
.box-flex-between {
|
|
211
|
+
padding-bottom: 18px;
|
|
212
|
+
}
|
|
213
|
+
|
|
214
|
+
.block {
|
|
215
|
+
padding: 0 20px;
|
|
216
|
+
}
|
|
217
|
+
</style>
|
|
@@ -0,0 +1,341 @@
|
|
|
1
|
+
<template>
|
|
2
|
+
<div class="createBalanced">
|
|
3
|
+
<el-card class="box-card" style="margin-top: 20px;">
|
|
4
|
+
<template #header>
|
|
5
|
+
<div class="clear-box">
|
|
6
|
+
<div lass="clear-l">
|
|
7
|
+
<span style="font-weight: 500;">负载管理配置</span>
|
|
8
|
+
<el-popover trigger="click" placement="bottom" width="500">
|
|
9
|
+
<div style="font-size: 10pt;">
|
|
10
|
+
<span>配置说明:</span><br/>
|
|
11
|
+
<span>1. 名称不能重复。</span><br/>
|
|
12
|
+
<span>2. 路径不能为空,路径规则需要满足gateway断言Path规则,请根据实际API调用路径设置。</span><br/>
|
|
13
|
+
<span>3. 路径/parent/为默认根路径,不可更改,只做网关路由规则识别,用于区分负载路由路径与普通路由路径。</span><br/>
|
|
14
|
+
<span>4. 实际转发到服务端不包含该/parent/根路径。</span><br/>
|
|
15
|
+
<span>5. 网关转发路由规则:http://gateway_host:gateway_port/server-id/api 或 http://gateway_host:gateway_port/api。</span><br/>
|
|
16
|
+
</div>
|
|
17
|
+
<template #reference>
|
|
18
|
+
<el-button style="padding: 3px 0;" icon="el-icon-questionFilled" type="text" title="说明"></el-button>
|
|
19
|
+
</template>
|
|
20
|
+
</el-popover>
|
|
21
|
+
</div>
|
|
22
|
+
<div class="clear-r">
|
|
23
|
+
<div style="margin-left: 10px;">
|
|
24
|
+
<el-button icon="el-icon-delete" size="default" type="warning" @click="resetForm">清 空</el-button>
|
|
25
|
+
</div>
|
|
26
|
+
<div style="margin-left: 10px;">
|
|
27
|
+
<el-button icon="el-icon-tickets" size="default" type="success" @click="submit">发 布</el-button>
|
|
28
|
+
</div>
|
|
29
|
+
<div style="margin-left: 10px;">
|
|
30
|
+
<el-button icon="el-icon-connection" size="default" type="primary" @click="search" title="查找服务端">添加服务</el-button>
|
|
31
|
+
</div>
|
|
32
|
+
</div>
|
|
33
|
+
</div>
|
|
34
|
+
</template>
|
|
35
|
+
|
|
36
|
+
<el-dialog title="添加服务端" v-model="dialogFormVisible" width="40%" :close-on-click-modal="false">
|
|
37
|
+
<el-table size="mini" :data="routeTableData" style="width: 100%">
|
|
38
|
+
<el-table-column label="服务ID" prop="id"></el-table-column>
|
|
39
|
+
<el-table-column label="服务名称" prop="name"></el-table-column>
|
|
40
|
+
<el-table-column label="服务地址" prop="uri"></el-table-column>
|
|
41
|
+
<el-table-column label="操作" width="60">
|
|
42
|
+
<template #default="{ row }">
|
|
43
|
+
<el-button v-if="row.selected !== true" size="mini" circle icon="el-icon-plus" type="success" title="点击添加" @click="handleAddRegServer(row)"></el-button>
|
|
44
|
+
<el-button v-if="row.selected === true" size="mini" circle icon="el-icon-check" type="primary" title="已添加" @click="handleAddRegServer(row)"></el-button>
|
|
45
|
+
</template>
|
|
46
|
+
</el-table-column>
|
|
47
|
+
</el-table>
|
|
48
|
+
<div class="block" style="margin-top: 20px;">
|
|
49
|
+
<el-pagination
|
|
50
|
+
@size-change="handleRouteSizeChange"
|
|
51
|
+
@current-change="handleRouteCurrentChange"
|
|
52
|
+
:current-page="currentPage"
|
|
53
|
+
:page-sizes="[10, 30, 50]"
|
|
54
|
+
:page-size="pageSize"
|
|
55
|
+
layout="total, sizes, prev, pager, next, jumper"
|
|
56
|
+
:total="totalNum">
|
|
57
|
+
</el-pagination>
|
|
58
|
+
</div>
|
|
59
|
+
<template #footer>
|
|
60
|
+
<div class="dialog-footer">
|
|
61
|
+
<el-button @click="dialogFormVisible = false" size="small">关 闭</el-button>
|
|
62
|
+
</div>
|
|
63
|
+
</template>
|
|
64
|
+
|
|
65
|
+
</el-dialog>
|
|
66
|
+
|
|
67
|
+
<el-row :gutter="24">
|
|
68
|
+
<el-col :span="8">
|
|
69
|
+
<el-card class="box-card">
|
|
70
|
+
<el-form size="small" :rules="rules" ref="form" :model="form" label-width="70px">
|
|
71
|
+
<el-form-item label="名称" prop="name">
|
|
72
|
+
<el-input v-model="form.name" style="width: 60%;"></el-input>
|
|
73
|
+
</el-form-item>
|
|
74
|
+
<el-form-item label="分组" prop="groupCode">
|
|
75
|
+
<el-select filterable v-model="form.groupCode" placeholder="请选择分组" style="width: 60%;">
|
|
76
|
+
<el-option v-for="item in groupOptions" :key="item.value" :label="item.label" :value="item.value" />
|
|
77
|
+
</el-select>
|
|
78
|
+
</el-form-item>
|
|
79
|
+
<el-form-item label="状态" prop="status">
|
|
80
|
+
<el-radio-group v-model="form.status">
|
|
81
|
+
<el-radio label="0">启用</el-radio>
|
|
82
|
+
<el-radio label="1">禁用</el-radio>
|
|
83
|
+
</el-radio-group>
|
|
84
|
+
</el-form-item>
|
|
85
|
+
<el-form-item label="路径" prop="loadUri">
|
|
86
|
+
<el-row :gutter="20">
|
|
87
|
+
<el-col :span="4" style="border: 0px solid red; padding: 0;">
|
|
88
|
+
<el-input v-model="parent" :disabled="true" title="默认负载地址前缀'/parent/',请不要在自定义地址前加/"></el-input>
|
|
89
|
+
</el-col>
|
|
90
|
+
<el-col :span="19" style="border: 0px solid red; padding: 0;">
|
|
91
|
+
<el-input v-model="form.loadUri" :disabled="uriDisabled" placeholder="请输入网关Path,示例:producer/** 或 producer/api"></el-input>
|
|
92
|
+
</el-col>
|
|
93
|
+
</el-row>
|
|
94
|
+
</el-form-item>
|
|
95
|
+
<el-form-item label="备注" prop="remarks">
|
|
96
|
+
<el-input type="textarea" v-model="form.remarks"></el-input>
|
|
97
|
+
</el-form-item>
|
|
98
|
+
</el-form>
|
|
99
|
+
</el-card>
|
|
100
|
+
</el-col>
|
|
101
|
+
<el-col :span="16">
|
|
102
|
+
<el-card class="box-card">
|
|
103
|
+
<el-table size="small" :data="tableData" style="width: 100%">
|
|
104
|
+
<el-table-column prop="routeId" label="路由ID"></el-table-column>
|
|
105
|
+
<el-table-column prop="name" label="路由名称"></el-table-column>
|
|
106
|
+
<el-table-column prop="uri" label="路由地址"></el-table-column>
|
|
107
|
+
<el-table-column label="路由权重" width="80">
|
|
108
|
+
<template #default="{ row }">
|
|
109
|
+
<el-tag size="small" type="" style="font-weight: bold;">{{row.weight}}</el-tag>
|
|
110
|
+
</template>
|
|
111
|
+
</el-table-column>
|
|
112
|
+
<el-table-column label="配置比例">
|
|
113
|
+
<template #default="{ row }">
|
|
114
|
+
<div class="block">
|
|
115
|
+
<el-slider v-model="row.weight"></el-slider>
|
|
116
|
+
</div>
|
|
117
|
+
</template>
|
|
118
|
+
</el-table-column>
|
|
119
|
+
<el-table-column label="操作" width="60">
|
|
120
|
+
<template #default="{ row }">
|
|
121
|
+
<el-button size="mini" circle icon="el-icon-delete" title="删除" style="border: 0px; font-size: 12pt;" @click="handleDeleteServer(row)"></el-button>
|
|
122
|
+
</template>
|
|
123
|
+
</el-table-column>
|
|
124
|
+
</el-table>
|
|
125
|
+
</el-card>
|
|
126
|
+
</el-col>
|
|
127
|
+
</el-row>
|
|
128
|
+
</el-card>
|
|
129
|
+
</div>
|
|
130
|
+
</template>
|
|
131
|
+
|
|
132
|
+
<script>
|
|
133
|
+
|
|
134
|
+
import {addBalanced, updateBalanced, loadServerRegList, loadServerNotRegList} from '../api/balanced_api.js'
|
|
135
|
+
|
|
136
|
+
export default {
|
|
137
|
+
data() {
|
|
138
|
+
return {
|
|
139
|
+
dialogFormVisible: false,
|
|
140
|
+
form: {
|
|
141
|
+
id: null,
|
|
142
|
+
name:null,
|
|
143
|
+
groupCode:null,
|
|
144
|
+
loadUri:null,
|
|
145
|
+
status: '0',
|
|
146
|
+
remarks: null
|
|
147
|
+
},
|
|
148
|
+
rules: {
|
|
149
|
+
name: [
|
|
150
|
+
{ required: true, message: '请输入负载名称', trigger: 'blur' },
|
|
151
|
+
{ min: 2, max: 40, message: '长度在 2 到 40 个字符', trigger: 'blur' },
|
|
152
|
+
],
|
|
153
|
+
groupCode: [
|
|
154
|
+
{ required: true, message: '请选择分组', trigger: 'change' },
|
|
155
|
+
],
|
|
156
|
+
loadUri: [
|
|
157
|
+
{ required: true, message: '请输入负载地址', trigger: 'blur' },
|
|
158
|
+
{ min: 2, max: 160, message: '长度在 2 到 160 个字符,如:/test.html', trigger: 'blur' },
|
|
159
|
+
],
|
|
160
|
+
status: [
|
|
161
|
+
{ required: true, message: '请选择状态', trigger: 'change' }
|
|
162
|
+
],
|
|
163
|
+
remarks: [
|
|
164
|
+
{ required: false, message: '请填写备注', trigger: 'blur' },
|
|
165
|
+
{ min: 2, max: 200, message: '长度在 2 到 200 个字符', trigger: 'blur' },
|
|
166
|
+
]
|
|
167
|
+
},
|
|
168
|
+
parent: '/parent/',
|
|
169
|
+
handleType: 'add',
|
|
170
|
+
uriDisabled: false,
|
|
171
|
+
groupOptions: this.GLOBAL_VAR.groups,
|
|
172
|
+
currentPage: 1,
|
|
173
|
+
pageSize: 10,
|
|
174
|
+
totalNum: 1,
|
|
175
|
+
routeTableData: [],
|
|
176
|
+
tableData: []
|
|
177
|
+
};
|
|
178
|
+
},
|
|
179
|
+
created: function() {
|
|
180
|
+
//在组件创建完毕后加载
|
|
181
|
+
let query = this.$route.query;
|
|
182
|
+
if (query){
|
|
183
|
+
let handleType = query.handleType;
|
|
184
|
+
if (handleType === 'edit'){
|
|
185
|
+
let balanced = query.balanced;
|
|
186
|
+
console.log('balanced', balanced);
|
|
187
|
+
this.form = balanced;
|
|
188
|
+
this.handleType = handleType;
|
|
189
|
+
}
|
|
190
|
+
}
|
|
191
|
+
},
|
|
192
|
+
mounted: function() {
|
|
193
|
+
this.init();
|
|
194
|
+
},
|
|
195
|
+
beforeDestroy: function() {
|
|
196
|
+
|
|
197
|
+
},
|
|
198
|
+
methods: {
|
|
199
|
+
init(balanced) {
|
|
200
|
+
this.serverRegList();
|
|
201
|
+
},
|
|
202
|
+
goBack() {
|
|
203
|
+
this.$router.push({ path: '/loadBalanced', query: {} });
|
|
204
|
+
},
|
|
205
|
+
handleRouteSizeChange(val) {
|
|
206
|
+
this.currentPage = val;
|
|
207
|
+
this.addServerList();
|
|
208
|
+
},
|
|
209
|
+
handleRouteCurrentChange(val) {
|
|
210
|
+
this.currentPage = val;
|
|
211
|
+
this.addServerList();
|
|
212
|
+
},
|
|
213
|
+
handleAddRegServer(row){
|
|
214
|
+
let isExist = false;
|
|
215
|
+
this.tableData.forEach((_row, _index)=>{
|
|
216
|
+
if (_row.routeId === row.id){
|
|
217
|
+
isExist = true;
|
|
218
|
+
}
|
|
219
|
+
});
|
|
220
|
+
if (isExist){
|
|
221
|
+
return false;
|
|
222
|
+
}
|
|
223
|
+
row.selected = true;
|
|
224
|
+
console.log(row);
|
|
225
|
+
let server = {
|
|
226
|
+
id: null,
|
|
227
|
+
balancedId: this.form.id,
|
|
228
|
+
routeId: row.id,
|
|
229
|
+
name: row.name,
|
|
230
|
+
uri: row.uri,
|
|
231
|
+
weight: 0
|
|
232
|
+
}
|
|
233
|
+
this.tableData.push(server);
|
|
234
|
+
},
|
|
235
|
+
handleDeleteServer(row){
|
|
236
|
+
let data = [];
|
|
237
|
+
this.tableData.forEach((_row, _index)=>{
|
|
238
|
+
if (_row.routeId !== row.routeId){
|
|
239
|
+
data.push(_row);
|
|
240
|
+
}
|
|
241
|
+
});
|
|
242
|
+
this.tableData = data;
|
|
243
|
+
},
|
|
244
|
+
addServerList(){
|
|
245
|
+
let _this = this;
|
|
246
|
+
loadServerNotRegList({balancedId: this.form.id, currentPage: this.currentPage, pageSize: this.pageSize}).then(function(result){
|
|
247
|
+
if (result.data && result.data.records){
|
|
248
|
+
let lists = result.data.records;
|
|
249
|
+
//将已被选中的服务置为已选中图标
|
|
250
|
+
if (lists != null){
|
|
251
|
+
lists.forEach((row,index)=>{
|
|
252
|
+
let selected = false;
|
|
253
|
+
_this.tableData.forEach((_row, _index)=>{
|
|
254
|
+
if (_row.routeId == row.id){
|
|
255
|
+
selected = true;
|
|
256
|
+
}
|
|
257
|
+
});
|
|
258
|
+
row.selected = selected;
|
|
259
|
+
});
|
|
260
|
+
}
|
|
261
|
+
_this.routeTableData = lists;
|
|
262
|
+
_this.totalNum = result.data.total;
|
|
263
|
+
}
|
|
264
|
+
});
|
|
265
|
+
},
|
|
266
|
+
serverRegList(){
|
|
267
|
+
if (this.form.id == null || this.form.id == undefined){
|
|
268
|
+
this.tableData=[];
|
|
269
|
+
return false;
|
|
270
|
+
}
|
|
271
|
+
let _this = this;
|
|
272
|
+
loadServerRegList({balancedId: this.form.id}).then(function(result){
|
|
273
|
+
console.log(result);
|
|
274
|
+
if (result && result.data){
|
|
275
|
+
_this.tableData = result.data;
|
|
276
|
+
}
|
|
277
|
+
});
|
|
278
|
+
},
|
|
279
|
+
submit(){
|
|
280
|
+
let _this = this;
|
|
281
|
+
let balanced = this.form;
|
|
282
|
+
balanced.serverList = this.tableData;
|
|
283
|
+
console.log(balanced);
|
|
284
|
+
this.$refs['form'].validate((valid) => {
|
|
285
|
+
if (valid) {
|
|
286
|
+
if (this.handleType === 'edit'){
|
|
287
|
+
updateBalanced(balanced).then(function(result){
|
|
288
|
+
_this.GLOBAL_FUN.successMsg();
|
|
289
|
+
_this.goBack();
|
|
290
|
+
});
|
|
291
|
+
}else {
|
|
292
|
+
addBalanced(balanced).then(function(result){
|
|
293
|
+
_this.GLOBAL_FUN.successMsg();
|
|
294
|
+
_this.goBack();
|
|
295
|
+
});
|
|
296
|
+
}
|
|
297
|
+
}
|
|
298
|
+
});
|
|
299
|
+
},
|
|
300
|
+
search(){
|
|
301
|
+
this.dialogFormVisible = true;
|
|
302
|
+
//如果上次已查询,则直接返回页面缓存数据
|
|
303
|
+
if (this.routeTableData == null || this.routeTableData.length <= 0){
|
|
304
|
+
this.addServerList();
|
|
305
|
+
this.handleDelete = false;
|
|
306
|
+
}
|
|
307
|
+
},
|
|
308
|
+
resetForm(){
|
|
309
|
+
if (this.handleType === 'add'){
|
|
310
|
+
this.form = {
|
|
311
|
+
id: null,
|
|
312
|
+
name:null,
|
|
313
|
+
groupCode:null,
|
|
314
|
+
loadUri:null,
|
|
315
|
+
status: '0',
|
|
316
|
+
remarks: null
|
|
317
|
+
}
|
|
318
|
+
}
|
|
319
|
+
}
|
|
320
|
+
}
|
|
321
|
+
}
|
|
322
|
+
|
|
323
|
+
</script>
|
|
324
|
+
|
|
325
|
+
<style lang="scss" scoped>
|
|
326
|
+
.createBalanced {
|
|
327
|
+
width: 100%;
|
|
328
|
+
|
|
329
|
+
.clear-box {
|
|
330
|
+
width: 100%;
|
|
331
|
+
display: flex;
|
|
332
|
+
justify-content: space-between;
|
|
333
|
+
|
|
334
|
+
.clear-l,
|
|
335
|
+
.clear-r {
|
|
336
|
+
display: flex;
|
|
337
|
+
align-items: center;
|
|
338
|
+
}
|
|
339
|
+
}
|
|
340
|
+
}
|
|
341
|
+
</style>
|