Skip to content

Commit 5e6cd1b

Browse files
hyunfawyyalt
authored andcommitted
feat(front): 增加检查托管信息的功能
# Reviewed, transaction id: 54836
1 parent 3494dfa commit 5e6cd1b

File tree

6 files changed

+179
-2
lines changed

6 files changed

+179
-2
lines changed

web/package.json

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -52,7 +52,8 @@
5252
"vue": "2.5.22",
5353
"vue-i18n": "8.21.1",
5454
"vue-router": "3.0.6",
55-
"vuex": "3.1.1"
55+
"vuex": "3.1.1",
56+
"xlsx": "^0.18.5"
5657
},
5758
"devDependencies": {
5859
"@babel/core": "^7.9.0",

web/src/language/lang/en.js

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -44,6 +44,15 @@ export default {
4444
// 进程管理
4545
进程状态: 'Process Status',
4646
进程管理: 'Process Manage',
47+
导出为excel: 'ExportToExcel',
48+
主机ID: 'Host id',
49+
管控区域: 'Cloud Area',
50+
管控区域ID: 'Cloud Area ID',
51+
错误类型: 'Error type',
52+
错误信息: 'Error Message',
53+
处理建议: 'Handling suggestion',
54+
托管信息: 'Hosting Info',
55+
检查托管信息: 'Check Hosting Info',
4756
// 配置文件
4857
'配置文件模板,新建成功。': 'Successfully created config-file template',
4958
配置文件: 'Config File',

web/src/language/lang/zh.js

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -44,6 +44,16 @@ export default {
4444
// 进程管理
4545
进程状态: '进程状态',
4646
进程管理: '进程管理',
47+
导出为excel: '导出为excel',
48+
主机ID: '主机ID',
49+
内网IP: '内网IP',
50+
管控区域: '管控区域',
51+
管控区域ID: '管控区域ID',
52+
错误类型: '错误类型',
53+
错误信息: '错误信息',
54+
处理建议: '处理建议',
55+
托管信息: '托管信息',
56+
检查托管信息: '检查托管信息',
4757
// 配置文件
4858
'配置文件模板,新建成功。': '配置文件模板,新建成功。',
4959
配置文件: '配置文件',

web/src/store/modules/process.js

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -75,5 +75,10 @@ export default {
7575
const url = `/api/${rootState.bizId}/process/sync_process_status_time/`;
7676
return http.get(url);
7777
},
78+
// 检查托管信息
79+
ajaxCheckHostingInfo({ rootState }) {
80+
const url = `/api/${rootState.bizId}/process/check/`;
81+
return http.get(url);
82+
},
7883
},
7984
};

web/src/views/ProcessManage/Status/ButtonGrounp.vue

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -74,6 +74,12 @@
7474
<p class="syncProcessStateTime" style="color: #FF9C01;">
7575
{{ $t('状态同步', [time] ) }}
7676
</p>
77+
<bk-button
78+
style="margin-right: 10px;"
79+
@click="checkHostingInfo"
80+
>
81+
{{ $t('检查托管信息') }}
82+
</bk-button>
7783
<bk-button
7884
v-test="'syncStatus'"
7985
icon="bk-icon icon-refresh"
@@ -172,6 +178,10 @@ export default {
172178
this.$emit('synchronousProcess', 'config');
173179
this.$refs.synchronousPopover.hideHandler();
174180
},
181+
// 检查托管信息
182+
checkHostingInfo() {
183+
this.$emit('checkHostingInfo');
184+
},
175185
// 同步状态时间
176186
async SyncProcessStateTime() {
177187
const res = await this.$store.dispatch('process/ajaxFlushSyncProcessStateTime');

web/src/views/ProcessManage/Status/index.vue

Lines changed: 143 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,8 @@
1616
:is-selected-all-pages="isSelectedAllPages"
1717
@operateProcess="operateProcess"
1818
@operateConfigDistribute="operateConfigDistribute"
19-
@synchronousProcess="synchronousProcess">
19+
@synchronousProcess="synchronousProcess"
20+
@checkHostingInfo="checkHostingInfo">
2021
</ButtonGrounp>
2122
<!-- 下拉筛选 -->
2223
<div class="search-content">
@@ -98,6 +99,65 @@
9899
{{ $t('所选进程?') }}
99100
</div>
100101
</bk-dialog>
102+
<!-- 托管信息弹窗 -->
103+
<bk-dialog
104+
ext-cls="host-info-dialog"
105+
v-model="dialogHostInfo.visible"
106+
:render-directive="'if'"
107+
width="1450"
108+
:mask-close="false"
109+
:show-footer="false"
110+
header-position="left">
111+
<template #header>
112+
<div class="header">
113+
{{ dialogHostInfo.title }}
114+
</div>
115+
</template>
116+
<div class="downLoad">
117+
<bk-button @click="handleExport">
118+
{{ $t('导出为excel') }}
119+
</bk-button>
120+
</div>
121+
<bk-table
122+
:data="currentTableData"
123+
:max-height="400"
124+
:pagination="infoPagination"
125+
v-bkloading="{ isLoading: infoTableLoading, zIndex: 0 }"
126+
@page-change="handleInfoPageChange"
127+
@page-limit-change="handleInfoPageLimitChange"
128+
>
129+
<bk-table-column :label="$t('主机ID')" min-width="140" prop="host_id" key="host_id">
130+
<div v-bk-overflow-tips slot-scope="{ row }">
131+
<span>{{ row.host_id }}</span>
132+
</div>
133+
</bk-table-column>
134+
<bk-table-column :label="$t('内网IP')" min-width="140" prop="inner_ip" key="inner_ip">
135+
<div v-bk-overflow-tips slot-scope="{ row }">
136+
<span>{{ row.inner_ip }}</span>
137+
</div>
138+
</bk-table-column>
139+
<bk-table-column :label="$t('管控区域')" min-width="140" prop="bk_cloud_name" key="bk_cloud_name">
140+
<div v-bk-overflow-tips slot-scope="{ row }">
141+
<span>{{ row.bk_cloud_name }}</span>
142+
</div>
143+
</bk-table-column>
144+
<bk-table-column :label="$t('错误类型')" min-width="140" prop="error_type" key="error_type">
145+
<div v-bk-overflow-tips slot-scope="{ row }">
146+
<span>{{ row.error_type }}</span>
147+
</div>
148+
</bk-table-column>
149+
<bk-table-column :label="$t('错误信息')" min-width="240" prop="error_msg" key="error_msg">
150+
<div v-bk-overflow-tips slot-scope="{ row }">
151+
<span>{{ row.error_msg }}</span>
152+
</div>
153+
</bk-table-column>
154+
<bk-table-column :label="$t('处理建议')" min-width="180" prop="handling_suggestion" key="handling_suggestion">
155+
<div v-bk-overflow-tips slot-scope="{ row }">
156+
<span>{{ row.handling_suggestion }}</span>
157+
</div>
158+
</bk-table-column>
159+
</bk-table>
160+
</bk-dialog>
101161
</section>
102162
</div>
103163
</template>
@@ -110,6 +170,7 @@ import ButtonGrounp from './ButtonGrounp';
110170
import EmptyProcess from '@/components/Empty/EmptyProcess';
111171
import { bus } from '@/common/bus';
112172
import { debounce } from 'lodash';
173+
import * as XLSX from 'xlsx';
113174
114175
export default {
115176
name: 'ProcessStatus',
@@ -189,6 +250,18 @@ export default {
189250
operateType: '', // 操作类型
190251
title: '', // dialog标题
191252
},
253+
originInfoData: [],
254+
currentTableData: [],
255+
infoTableLoading: false,
256+
dialogHostInfo: {
257+
visible: false, // 弹框是否可见
258+
title: '', // dialog标题
259+
},
260+
infoPagination: {
261+
current: 1,
262+
count: 0,
263+
limit: 50,
264+
},
192265
prevListLength: 0,
193266
isMatch: true,
194267
isExisted: false,
@@ -502,6 +575,64 @@ export default {
502575
onConfigDistribute() {
503576
this.isShow = false;
504577
},
578+
getPaginatedData(data, page, pageSize) {
579+
const startIndex = (page - 1) * pageSize;
580+
const endIndex = startIndex + pageSize;
581+
return data.slice(startIndex, endIndex);
582+
},
583+
handleInfoPageLimitChange(limit) {
584+
this.infoPagination.limit = limit;
585+
this.currentTableData = this.getPaginatedData(this.originInfoData, this.infoPagination.current, limit);
586+
},
587+
handleInfoPageChange(page) {
588+
this.infoPagination.current = page;
589+
this.currentTableData = this.getPaginatedData(this.originInfoData, page, this.infoPagination.limit)
590+
},
591+
// 检查托管信息
592+
async checkHostingInfo() {
593+
this.dialogHostInfo.visible = true;
594+
this.dialogHostInfo.title = this.$t('托管信息');
595+
this.infoTableLoading = true;
596+
const res = await this.$store.dispatch('process/ajaxCheckHostingInfo');
597+
if (res.result) {
598+
const cloudList = this.filterData.find(item => item.id === 'bk_cloud_id')?.children || [];
599+
this.originInfoData = res.data.map(item => ({
600+
...item,
601+
bk_cloud_name: cloudList.find(el => el.id === item.bk_cloud_id)?.name
602+
}));
603+
this.currentTableData = [...this.originInfoData];
604+
this.infoPagination.count = res.data.length;
605+
}
606+
this.infoTableLoading = false;
607+
},
608+
handleExport() {
609+
const data = this.originInfoData.map(item => ({
610+
...item,
611+
host_id: String(item.host_id)
612+
}));
613+
const customHeaders = {
614+
"host_id": this.$t("主机ID"),
615+
"inner_ip": this.$t("内网IP"),
616+
"bk_cloud_id": this.$t("管控区域ID"),
617+
"bk_cloud_name": this.$t("管控区域"),
618+
"error_type": this.$t("错误类型"),
619+
"error_msg": this.$t("错误信息"),
620+
"handling_suggestion": this.$t("处理建议")
621+
};
622+
623+
// 将 JSON 数据转换为工作表
624+
const worksheet = XLSX.utils.json_to_sheet(data, { header: Object.keys(customHeaders) });
625+
// 插入自定义表头,假设表头位于第一行
626+
XLSX.utils.sheet_add_aoa(worksheet, [Object.values(customHeaders)], { origin: 'A1' });
627+
// 创建一个新的工作簿
628+
const workbook = XLSX.utils.book_new();
629+
630+
// 将工作表添加到工作簿
631+
XLSX.utils.book_append_sheet(workbook, worksheet, this.$t('托管信息'));
632+
633+
// 将工作簿导出为 Excel 文件
634+
XLSX.writeFile(workbook, '托管信息.xlsx');
635+
},
505636
// 同步进程
506637
async synchronousProcess(type) {
507638
try {
@@ -864,4 +995,15 @@ export default {
864995
}
865996
}
866997
}
998+
.header {
999+
width: 100%;
1000+
font-size: 20px;
1001+
color: #313238;
1002+
line-height: 25px;
1003+
}
1004+
.downLoad {
1005+
width: 100%;
1006+
text-align: right;
1007+
margin: 0 16px 16px 0;
1008+
}
8671009
</style>

0 commit comments

Comments
 (0)