|
84 | 84 | {{ $t('复制审批链接') }} |
85 | 85 | </bk-button> |
86 | 86 | </span> |
87 | | - <span v-else-if="['name', 'description'].includes(column.prop)"> |
88 | | - <a |
89 | | - v-if="row.mcp_server?.doc_link && column.prop === 'name'" |
90 | | - :href="row.mcp_server?.doc_link" |
91 | | - target="_blank" |
92 | | - v-dompurify-html="highlight(row.mcp_server?.name || '--')" |
93 | | - ></a> |
94 | | - <span |
95 | | - v-else |
96 | | - v-dompurify-html="highlight(row.mcp_server?.[column.prop] || '--')" |
97 | | - ></span> |
| 87 | + <a |
| 88 | + v-else-if="column.prop === 'name' && row.mcp_server?.doc_link" |
| 89 | + :href="row.mcp_server?.doc_link" |
| 90 | + target="_blank" |
| 91 | + class="text-ellipsis" |
| 92 | + v-dompurify-html="highlight(getDisplayName(row))" |
| 93 | + ></a> |
| 94 | + <div |
| 95 | + v-else-if="column.prop === 'name'" |
| 96 | + class="text-ellipsis" |
| 97 | + v-dompurify-html="highlight(getDisplayName(row))" |
| 98 | + ></div> |
| 99 | + <span v-else-if="column.prop === 'description'"> |
| 100 | + <span v-dompurify-html="highlight(row.mcp_server?.description || '--')"></span> |
98 | 101 | </span> |
99 | 102 | <template v-else> |
100 | 103 | {{ row.mcp_server?.[column.prop] || '--' }} |
|
141 | 144 |
|
142 | 145 | <script> |
143 | 146 | import BatchDialog from './batch-apply-dialog'; |
144 | | -import { paginationFun } from '@/common/utils'; |
| 147 | +import { filterListByKeywordInFields, paginationFun } from '@/common/utils'; |
145 | 148 | import { MCP_SERVER_STATUS } from '@/common/constants'; |
146 | 149 | import { debounce } from 'lodash'; |
147 | 150 | import { copy } from '@/common/tools'; |
@@ -288,23 +291,18 @@ export default { |
288 | 291 |
|
289 | 292 | // 获取过滤后的数据(根据搜索条件) |
290 | 293 | getFilteredData() { |
291 | | - console.log('this.headerFilterField', this.headerFilterField); |
292 | | - if (!this.searchQuery && !this.headerFilterField) { |
293 | | - return this.allMcpServerList; |
| 294 | + const keywordFilteredData = filterListByKeywordInFields(this.allMcpServerList, this.searchQuery, [ |
| 295 | + 'mcp_server.title', |
| 296 | + 'mcp_server.name', |
| 297 | + 'mcp_server.description', |
| 298 | + ]); |
| 299 | +
|
| 300 | + if (!this.headerFilterField) { |
| 301 | + return keywordFilteredData; |
294 | 302 | } |
295 | | - const keyword = this.searchQuery.toLowerCase(); |
296 | | - return this.allMcpServerList.filter((item) => { |
297 | | - console.log('item', item); |
298 | | - const name = item.mcp_server?.name?.toLowerCase() || ''; |
299 | | - const description = item.mcp_server?.description?.toLowerCase() || ''; |
300 | | - const status = item.permission?.status || ''; |
301 | | - // 关键字搜索条件 |
302 | | - const keywordMatch = !this.searchQuery || name.includes(keyword) || description.includes(keyword); |
303 | | - // 状态筛选条件 |
304 | | - const statusMatch = !this.headerFilterField || status === this.headerFilterField; |
305 | | - // 同时满足关键字搜索和状态筛选条件 |
306 | | - return keywordMatch && statusMatch; |
307 | | - }); |
| 303 | +
|
| 304 | + // 表头状态过滤 |
| 305 | + return keywordFilteredData.filter((item) => item.permission?.status === this.headerFilterField); |
308 | 306 | }, |
309 | 307 |
|
310 | 308 | // 分页处理 |
@@ -401,6 +399,12 @@ export default { |
401 | 399 | copy(url, this); |
402 | 400 | }, |
403 | 401 |
|
| 402 | + // 获取展示名称:title (name) |
| 403 | + getDisplayName(row) { |
| 404 | + const mcp = row.mcp_server || {}; |
| 405 | + return `${mcp.title || '--'} (${mcp.name || '--'})`; |
| 406 | + }, |
| 407 | +
|
404 | 408 | // 搜索关键词高亮 |
405 | 409 | highlight(text) { |
406 | 410 | const keyword = this.searchQuery; |
@@ -435,5 +439,8 @@ export default { |
435 | 439 | border-color: #2caf5e; |
436 | 440 | } |
437 | 441 | } |
| 442 | + .text-ellipsis { |
| 443 | + display: block; |
| 444 | + } |
438 | 445 | } |
439 | 446 | </style> |
0 commit comments