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" >
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';
110170import EmptyProcess from ' @/components/Empty/EmptyProcess' ;
111171import { bus } from ' @/common/bus' ;
112172import { debounce } from ' lodash' ;
173+ import * as XLSX from ' xlsx' ;
113174
114175export 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