fix: restore FAQ batch actions
parent
60d2ffa4fb
commit
6f8ecc32de
|
|
@ -2623,6 +2623,7 @@ export default {
|
|||
similarityThresholdLabel: 'Similarity Threshold',
|
||||
statusEnabled: 'Enabled',
|
||||
statusDisabled: 'Disabled',
|
||||
statusEnableSuccess: 'FAQ entry enabled',
|
||||
statusDisableSuccess: 'FAQ entry disabled',
|
||||
statusUpdateFailed: 'Failed to update status',
|
||||
recommended: 'Recommend',
|
||||
|
|
@ -2631,7 +2632,12 @@ export default {
|
|||
recommendedDisableSuccess: 'FAQ entry recommendation disabled',
|
||||
recommendedUpdateFailed: 'Failed to update recommendation status',
|
||||
batchUpdateTag: 'Batch Set Tags',
|
||||
batchUpdateTagTip: 'Set tags for {count} selected entries'
|
||||
batchUpdateTagTip: 'Set tags for {count} selected entries',
|
||||
batchEnable: 'Enable selected',
|
||||
batchDisable: 'Disable selected',
|
||||
batchDelete: 'Delete selected',
|
||||
confirmBatchDelete: 'Delete the selected {count} FAQ entries? This action cannot be undone.',
|
||||
batchDeleteSuccess: 'Deleted {count} FAQ entries'
|
||||
},
|
||||
faqImport: {
|
||||
title: 'Batch Import FAQ',
|
||||
|
|
|
|||
|
|
@ -3558,6 +3558,7 @@ export default {
|
|||
similarityThresholdLabel: '유사도 임계값',
|
||||
statusEnabled: '활성화됨',
|
||||
statusDisabled: '비활성화됨',
|
||||
statusEnableSuccess: 'FAQ 항목이 활성화되었습니다',
|
||||
statusDisableSuccess: 'FAQ 항목이 비활성화되었습니다',
|
||||
statusUpdateFailed: '상태 업데이트 실패',
|
||||
recommended: '추천',
|
||||
|
|
@ -3567,6 +3568,11 @@ export default {
|
|||
recommendedUpdateFailed: '추천 상태 업데이트 실패',
|
||||
batchUpdateTag: '일괄 태그 설정',
|
||||
batchUpdateTagTip: '{count}개 선택된 항목에 태그가 설정됩니다',
|
||||
batchEnable: '일괄 활성화',
|
||||
batchDisable: '일괄 비활성화',
|
||||
batchDelete: '일괄 삭제',
|
||||
confirmBatchDelete: '선택한 FAQ 항목 {count}개를 삭제하시겠습니까? 삭제 후에는 복구할 수 없습니다.',
|
||||
batchDeleteSuccess: 'FAQ 항목 {count}개를 삭제했습니다',
|
||||
modes: {
|
||||
questionOnly: '표준 질문/유사 질문만',
|
||||
questionAnswer: '표준 질문 + 답변',
|
||||
|
|
|
|||
|
|
@ -3558,6 +3558,7 @@ export default {
|
|||
similarityThresholdLabel: 'Порог сходства',
|
||||
statusEnabled: 'Включено',
|
||||
statusDisabled: 'Выключено',
|
||||
statusEnableSuccess: 'Запись FAQ включена',
|
||||
statusDisableSuccess: 'Запись FAQ отключена',
|
||||
statusUpdateFailed: 'Не удалось обновить статус',
|
||||
recommended: 'Рекомендовать',
|
||||
|
|
@ -3567,6 +3568,11 @@ export default {
|
|||
recommendedUpdateFailed: 'Не удалось обновить статус рекомендации',
|
||||
batchUpdateTag: 'Пакетная установка тегов',
|
||||
batchUpdateTagTip: 'Установить теги для {count} выбранных записей',
|
||||
batchEnable: 'Включить выбранные',
|
||||
batchDisable: 'Отключить выбранные',
|
||||
batchDelete: 'Удалить выбранные',
|
||||
confirmBatchDelete: 'Удалить выбранные записи FAQ ({count})? Это действие нельзя отменить.',
|
||||
batchDeleteSuccess: 'Удалено записей FAQ: {count}',
|
||||
modes: {
|
||||
questionOnly: 'Только вопросы',
|
||||
questionAnswer: 'Вопрос + ответ',
|
||||
|
|
|
|||
|
|
@ -3558,6 +3558,7 @@ export default {
|
|||
similarityThresholdLabel: '相似度阈值',
|
||||
statusEnabled: '已启用',
|
||||
statusDisabled: '已禁用',
|
||||
statusEnableSuccess: 'FAQ 条目已启用',
|
||||
statusDisableSuccess: 'FAQ 条目已禁用',
|
||||
statusUpdateFailed: '更新状态失败',
|
||||
recommended: '推荐',
|
||||
|
|
@ -3567,6 +3568,11 @@ export default {
|
|||
recommendedUpdateFailed: '更新推荐状态失败',
|
||||
batchUpdateTag: '批量设置标签',
|
||||
batchUpdateTagTip: '将为 {count} 个选中的条目设置标签',
|
||||
batchEnable: '批量启用',
|
||||
batchDisable: '批量禁用',
|
||||
batchDelete: '批量删除',
|
||||
confirmBatchDelete: '确认删除选中的 {count} 个 FAQ 条目?删除后将无法恢复。',
|
||||
batchDeleteSuccess: '已删除 {count} 个 FAQ 条目',
|
||||
modes: {
|
||||
questionOnly: '仅标准问/相似问',
|
||||
questionAnswer: '标准问 + 答案',
|
||||
|
|
|
|||
|
|
@ -0,0 +1,53 @@
|
|||
import assert from 'node:assert/strict'
|
||||
import test from 'node:test'
|
||||
import { readFileSync } from 'node:fs'
|
||||
|
||||
const manager = readFileSync(new URL('./FAQEntryManager.vue', import.meta.url), 'utf8')
|
||||
const batchBar = readFileSync(new URL('./FAQBatchBar.vue', import.meta.url), 'utf8')
|
||||
const locales = [
|
||||
readFileSync(new URL('../../../i18n/locales/zh-CN.ts', import.meta.url), 'utf8'),
|
||||
readFileSync(new URL('../../../i18n/locales/en-US.ts', import.meta.url), 'utf8'),
|
||||
readFileSync(new URL('../../../i18n/locales/ko-KR.ts', import.meta.url), 'utf8'),
|
||||
readFileSync(new URL('../../../i18n/locales/ru-RU.ts', import.meta.url), 'utf8'),
|
||||
]
|
||||
|
||||
test('FAQ 批量操作通过组件事件直接连接,不再依赖全局事件', () => {
|
||||
assert.match(manager, /import FAQBatchBar from '\.\/FAQBatchBar\.vue'/)
|
||||
assert.match(manager, /<FAQBatchBar[\s\S]*?@batch-tag="openBatchTagDialog"/)
|
||||
assert.match(manager, /@enable="handleBatchStatusChange\(true\)"/)
|
||||
assert.match(manager, /@disable="handleBatchStatusChange\(false\)"/)
|
||||
assert.match(manager, /@delete="handleBatchDelete"/)
|
||||
assert.doesNotMatch(manager, /faqMenuAction/)
|
||||
assert.doesNotMatch(manager, /faqSelectionChanged/)
|
||||
})
|
||||
|
||||
test('批量操作条根据选择状态和权限展示有效操作', () => {
|
||||
assert.match(batchBar, /v-if="count > 0 && \(canEdit \|\| canManage\)"/)
|
||||
assert.match(batchBar, /v-if="canEdit && disabledCount > 0"/)
|
||||
assert.match(batchBar, /v-if="canEdit && enabledCount > 0"/)
|
||||
assert.match(batchBar, /<t-popconfirm v-if="canManage"/)
|
||||
assert.match(manager, /const canSelectEntries = computed\(\(\) => canEdit\.value \|\| canManage\.value\)/)
|
||||
assert.match(manager, /if \(!canSelectEntries\.value \|\| batchActionLoading\.value\) return/)
|
||||
})
|
||||
|
||||
test('危险操作需要确认,所有批量请求都防止重复提交', () => {
|
||||
assert.match(batchBar, /confirmBatchDelete/)
|
||||
assert.match(batchBar, /@confirm="emit\('delete'\)"/)
|
||||
assert.match(batchBar, /const actionLoading = computed/)
|
||||
assert.match(manager, /const batchDeleteLoading = ref\(false\)/)
|
||||
assert.match(manager, /const batchTagLoading = ref\(false\)/)
|
||||
assert.match(manager, /const batchStatusAction = ref<'enable' \| 'disable' \| null>\(null\)/)
|
||||
assert.match(manager, /finally \{\s*batchDeleteLoading\.value = false\s*\}/)
|
||||
assert.match(manager, /finally \{\s*batchTagLoading\.value = false\s*\}/)
|
||||
assert.match(manager, /finally \{\s*batchStatusAction\.value = null\s*\}/)
|
||||
})
|
||||
|
||||
test('所有支持的语言都包含 FAQ 批量操作文案', () => {
|
||||
for (const locale of locales) {
|
||||
assert.match(locale, /batchEnable:/)
|
||||
assert.match(locale, /batchDisable:/)
|
||||
assert.match(locale, /batchDelete:/)
|
||||
assert.match(locale, /confirmBatchDelete:/)
|
||||
assert.match(locale, /batchDeleteSuccess:/)
|
||||
}
|
||||
})
|
||||
|
|
@ -0,0 +1,145 @@
|
|||
<script setup lang="ts">
|
||||
import { computed } from 'vue'
|
||||
import { useI18n } from 'vue-i18n'
|
||||
|
||||
const props = defineProps<{
|
||||
count: number
|
||||
enabledCount: number
|
||||
disabledCount: number
|
||||
canEdit: boolean
|
||||
canManage: boolean
|
||||
tagLoading?: boolean
|
||||
statusAction?: 'enable' | 'disable' | null
|
||||
deleteLoading?: boolean
|
||||
}>()
|
||||
|
||||
const emit = defineEmits<{
|
||||
(event: 'cancel'): void
|
||||
(event: 'batchTag'): void
|
||||
(event: 'enable'): void
|
||||
(event: 'disable'): void
|
||||
(event: 'delete'): void
|
||||
}>()
|
||||
|
||||
const { t } = useI18n()
|
||||
|
||||
const actionLoading = computed(() => (
|
||||
props.tagLoading
|
||||
|| props.statusAction != null
|
||||
|| props.deleteLoading
|
||||
))
|
||||
</script>
|
||||
|
||||
<template>
|
||||
<transition name="faq-batch-bar-fade">
|
||||
<div v-if="count > 0 && (canEdit || canManage)" class="faq-batch-bar" role="region"
|
||||
:aria-label="t('knowledgeBase.selectedCount', { count })">
|
||||
<div class="faq-batch-bar__inner">
|
||||
<div class="faq-batch-bar__selection">
|
||||
<span class="faq-batch-bar__count">{{ t('knowledgeBase.selectedCount', { count }) }}</span>
|
||||
<t-button variant="text" theme="default" size="small" :disabled="actionLoading"
|
||||
@click="emit('cancel')">
|
||||
{{ t('knowledgeBase.clearSelection') }}
|
||||
</t-button>
|
||||
</div>
|
||||
|
||||
<div class="faq-batch-bar__actions">
|
||||
<t-button v-if="canEdit" theme="default" variant="outline" size="small"
|
||||
:disabled="actionLoading" :loading="tagLoading" @click="emit('batchTag')">
|
||||
<template #icon><t-icon name="discount" size="14px" /></template>
|
||||
{{ t('knowledgeEditor.faq.batchUpdateTag') }}
|
||||
</t-button>
|
||||
|
||||
<t-button v-if="canEdit && disabledCount > 0" theme="default" variant="outline" size="small"
|
||||
:disabled="actionLoading" :loading="statusAction === 'enable'" @click="emit('enable')">
|
||||
<template #icon><t-icon name="check-circle" size="14px" /></template>
|
||||
{{ t('knowledgeEditor.faq.batchEnable') }}
|
||||
</t-button>
|
||||
|
||||
<t-button v-if="canEdit && enabledCount > 0" theme="default" variant="outline" size="small"
|
||||
:disabled="actionLoading" :loading="statusAction === 'disable'" @click="emit('disable')">
|
||||
<template #icon><t-icon name="minus-circle" size="14px" /></template>
|
||||
{{ t('knowledgeEditor.faq.batchDisable') }}
|
||||
</t-button>
|
||||
|
||||
<t-popconfirm v-if="canManage" theme="warning"
|
||||
:content="t('knowledgeEditor.faq.confirmBatchDelete', { count })"
|
||||
:confirm-btn="{ content: t('knowledgeBase.confirmDelete'), theme: 'danger' }"
|
||||
:cancel-btn="{ content: t('common.cancel') }" placement="top" @confirm="emit('delete')">
|
||||
<t-button theme="danger" variant="outline" size="small" :disabled="actionLoading"
|
||||
:loading="deleteLoading" @click.stop>
|
||||
<template #icon><t-icon name="delete" size="14px" /></template>
|
||||
{{ t('knowledgeEditor.faq.batchDelete') }}
|
||||
</t-button>
|
||||
</t-popconfirm>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</transition>
|
||||
</template>
|
||||
|
||||
<style scoped lang="less">
|
||||
.faq-batch-bar {
|
||||
width: 100%;
|
||||
max-width: 760px;
|
||||
padding: 0 4px;
|
||||
box-sizing: border-box;
|
||||
}
|
||||
|
||||
.faq-batch-bar__inner {
|
||||
display: flex;
|
||||
align-items: center;
|
||||
justify-content: space-between;
|
||||
gap: 12px;
|
||||
padding: 8px 12px;
|
||||
background: var(--td-bg-color-container);
|
||||
border: 1px solid var(--td-component-stroke);
|
||||
border-radius: 8px;
|
||||
box-shadow: 0 6px 16px rgba(0, 0, 0, 0.08);
|
||||
}
|
||||
|
||||
.faq-batch-bar__selection {
|
||||
display: flex;
|
||||
align-items: center;
|
||||
gap: 4px;
|
||||
min-width: 0;
|
||||
flex-shrink: 0;
|
||||
}
|
||||
|
||||
.faq-batch-bar__count {
|
||||
color: var(--td-text-color-secondary);
|
||||
font-size: 13px;
|
||||
font-weight: 500;
|
||||
white-space: nowrap;
|
||||
}
|
||||
|
||||
.faq-batch-bar__actions {
|
||||
display: flex;
|
||||
flex-wrap: wrap;
|
||||
align-items: center;
|
||||
justify-content: flex-end;
|
||||
gap: 8px;
|
||||
}
|
||||
|
||||
.faq-batch-bar-fade-enter-active,
|
||||
.faq-batch-bar-fade-leave-active {
|
||||
transition: transform 0.2s ease, opacity 0.2s ease;
|
||||
}
|
||||
|
||||
.faq-batch-bar-fade-enter-from,
|
||||
.faq-batch-bar-fade-leave-to {
|
||||
opacity: 0;
|
||||
transform: translateY(6px);
|
||||
}
|
||||
|
||||
@media (max-width: 760px) {
|
||||
.faq-batch-bar__inner {
|
||||
align-items: stretch;
|
||||
flex-direction: column;
|
||||
}
|
||||
|
||||
.faq-batch-bar__actions {
|
||||
justify-content: flex-start;
|
||||
}
|
||||
}
|
||||
</style>
|
||||
|
|
@ -231,7 +231,8 @@
|
|||
</div>
|
||||
</div>
|
||||
<!-- Card List Container with Scroll -->
|
||||
<div ref="scrollContainer" class="faq-scroll-container" @scroll="handleScroll">
|
||||
<div ref="scrollContainer" class="faq-scroll-container"
|
||||
:class="{ 'has-batch-bar': selectedRowKeys.length > 0 && canSelectEntries }" @scroll="handleScroll">
|
||||
<!-- FAQ 骨架屏 -->
|
||||
<div v-if="loading && entries.length === 0" class="faq-skeleton-grid">
|
||||
<div v-for="n in 6" :key="'faq-skel-' + n" class="faq-card faq-card-skeleton">
|
||||
|
|
@ -252,7 +253,7 @@
|
|||
<template v-else-if="entries.length > 0">
|
||||
<div ref="cardListRef" class="faq-card-list">
|
||||
<div v-for="entry in entries" :key="entry.id" class="faq-card"
|
||||
:class="{ 'selected': selectedRowKeys.includes(entry.id) }"
|
||||
:class="{ 'selected': selectedRowKeys.includes(entry.id), 'is-selectable': canSelectEntries }"
|
||||
@click="handleCardSelect(entry.id, !selectedRowKeys.includes(entry.id))">
|
||||
<!-- Card Header -->
|
||||
<div class="faq-card-header">
|
||||
|
|
@ -424,6 +425,14 @@
|
|||
{{ $t('common.noMoreData') }}
|
||||
</div>
|
||||
</div>
|
||||
<div class="faq-batch-bar-anchor">
|
||||
<FAQBatchBar :count="selectedRowKeys.length" :enabled-count="selectedEnabledCount"
|
||||
:disabled-count="selectedDisabledCount" :can-edit="canEdit" :can-manage="canManage"
|
||||
:tag-loading="batchTagLoading" :status-action="batchStatusAction"
|
||||
:delete-loading="batchDeleteLoading" @cancel="clearFAQSelection" @batch-tag="openBatchTagDialog"
|
||||
@enable="handleBatchStatusChange(true)" @disable="handleBatchStatusChange(false)"
|
||||
@delete="handleBatchDelete" />
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
|
@ -711,7 +720,8 @@
|
|||
<t-button theme="default" variant="outline" @click="batchTagDialogVisible = false">
|
||||
{{ $t('common.cancel') }}
|
||||
</t-button>
|
||||
<t-button theme="primary" @click="handleBatchTag">
|
||||
<t-button theme="primary" :loading="batchTagLoading" :disabled="batchActionLoading"
|
||||
@click="handleBatchTag">
|
||||
{{ $t('common.confirm') }}
|
||||
</t-button>
|
||||
</div>
|
||||
|
|
@ -880,6 +890,7 @@ import Papa from 'papaparse'
|
|||
import FAQTagTooltip from '@/components/FAQTagTooltip.vue'
|
||||
import KBInfoPopover from '@/components/KBInfoPopover.vue'
|
||||
import KBSwitcherDropdown from '@/components/KBSwitcherDropdown.vue'
|
||||
import FAQBatchBar from './FAQBatchBar.vue'
|
||||
import KbTagManageDrawer from './KbTagManageDrawer.vue'
|
||||
import { useUIStore } from '@/stores/ui'
|
||||
|
||||
|
|
@ -979,6 +990,8 @@ const canManage = computed(() => {
|
|||
return orgStore.canManageKB(props.kbId, false)
|
||||
})
|
||||
|
||||
const canSelectEntries = computed(() => canEdit.value || canManage.value)
|
||||
|
||||
const faqExportOptions = computed(() => [
|
||||
{ content: t('knowledgeEditor.faqExport.exportCSV'), value: 'export_csv' },
|
||||
{ content: t('knowledgeEditor.faqExport.exportJSON'), value: 'export_json' },
|
||||
|
|
@ -1023,6 +1036,22 @@ const entries = ref<FAQEntry[]>([])
|
|||
const entryStatusLoading = reactive<Record<number, boolean>>({})
|
||||
const entryRecommendedLoading = reactive<Record<number, boolean>>({})
|
||||
const selectedRowKeys = ref<number[]>([])
|
||||
const batchDeleteLoading = ref(false)
|
||||
const batchTagLoading = ref(false)
|
||||
const batchStatusAction = ref<'enable' | 'disable' | null>(null)
|
||||
const selectedEntries = computed(() => {
|
||||
const selectedIds = new Set(selectedRowKeys.value)
|
||||
return entries.value.filter(entry => selectedIds.has(entry.id))
|
||||
})
|
||||
const selectedEnabledCount = computed(() => (
|
||||
selectedEntries.value.filter(entry => entry.is_enabled !== false).length
|
||||
))
|
||||
const selectedDisabledCount = computed(() => selectedEntries.value.length - selectedEnabledCount.value)
|
||||
const batchActionLoading = computed(() => (
|
||||
batchDeleteLoading.value
|
||||
|| batchTagLoading.value
|
||||
|| batchStatusAction.value != null
|
||||
))
|
||||
const scrollContainer = ref<HTMLElement | null>(null)
|
||||
const cardListRef = ref<HTMLElement | null>(null)
|
||||
const hasMore = ref(true)
|
||||
|
|
@ -1455,43 +1484,6 @@ const handleKnowledgeDropdownSelect = (data: { value: string }) => {
|
|||
router.push(`/platform/knowledge-bases/${data.value}`)
|
||||
}
|
||||
|
||||
const handleFaqMenuAction = (event: Event) => {
|
||||
const detail = (event as CustomEvent<{ action: string; kbId: string }>).detail
|
||||
if (!detail || detail.kbId !== props.kbId) return
|
||||
|
||||
if (detail.action === 'create') {
|
||||
if (canEdit.value) openEditor()
|
||||
} else if (detail.action === 'import') {
|
||||
if (canEdit.value) openImportDialog()
|
||||
} else if (detail.action === 'search') {
|
||||
searchDrawerVisible.value = true
|
||||
} else if (detail.action === 'export') {
|
||||
// Export is usually allowed for viewers as well
|
||||
handleExportCSV()
|
||||
} else if (detail.action === 'batch') {
|
||||
// 批量操作通过左侧菜单的下拉菜单处理
|
||||
if (selectedRowKeys.value.length === 0) {
|
||||
MessagePlugin.warning(t('knowledgeEditor.faq.selectEntriesFirst'))
|
||||
}
|
||||
} else if (detail.action === 'batchTag') {
|
||||
if (canEdit.value && selectedRowKeys.value.length > 0) {
|
||||
openBatchTagDialog()
|
||||
}
|
||||
} else if (detail.action === 'batchEnable') {
|
||||
if (canEdit.value && selectedRowKeys.value.length > 0) {
|
||||
handleBatchStatusChange(true)
|
||||
}
|
||||
} else if (detail.action === 'batchDisable') {
|
||||
if (canEdit.value && selectedRowKeys.value.length > 0) {
|
||||
handleBatchStatusChange(false)
|
||||
}
|
||||
} else if (detail.action === 'batchDelete') {
|
||||
if (canManage.value && selectedRowKeys.value.length > 0) {
|
||||
handleBatchDelete()
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
const handleEntryStatusChange = async (entry: FAQEntry, value: boolean) => {
|
||||
if (!props.kbId) {
|
||||
return
|
||||
|
|
@ -1660,6 +1652,7 @@ const checkAndLoadMore = () => {
|
|||
}
|
||||
|
||||
const handleCardSelect = (entryId: number, checked: boolean) => {
|
||||
if (!canSelectEntries.value || batchActionLoading.value) return
|
||||
if (checked) {
|
||||
if (!selectedRowKeys.value.includes(entryId)) {
|
||||
selectedRowKeys.value.push(entryId)
|
||||
|
|
@ -1672,6 +1665,11 @@ const handleCardSelect = (entryId: number, checked: boolean) => {
|
|||
}
|
||||
}
|
||||
|
||||
const clearFAQSelection = () => {
|
||||
if (batchActionLoading.value) return
|
||||
selectedRowKeys.value = []
|
||||
}
|
||||
|
||||
const resetEditorForm = () => {
|
||||
editorForm.standard_question = ''
|
||||
editorForm.similar_questions = []
|
||||
|
|
@ -1785,14 +1783,18 @@ const handleSubmitEntry = async () => {
|
|||
}
|
||||
|
||||
const handleBatchDelete = async () => {
|
||||
if (!selectedRowKeys.value.length) return
|
||||
if (!canManage.value || !selectedRowKeys.value.length || !props.kbId || batchActionLoading.value) return
|
||||
const selectedIds = [...selectedRowKeys.value]
|
||||
batchDeleteLoading.value = true
|
||||
try {
|
||||
await deleteFAQEntries(props.kbId, selectedRowKeys.value)
|
||||
MessagePlugin.success(t('knowledgeEditor.faqImport.deleteSuccess'))
|
||||
await deleteFAQEntries(props.kbId, selectedIds)
|
||||
MessagePlugin.success(t('knowledgeEditor.faq.batchDeleteSuccess', { count: selectedIds.length }))
|
||||
selectedRowKeys.value = []
|
||||
await loadEntries()
|
||||
} catch (error: any) {
|
||||
MessagePlugin.error(error?.message || t('common.operationFailed'))
|
||||
} finally {
|
||||
batchDeleteLoading.value = false
|
||||
}
|
||||
}
|
||||
|
||||
|
|
@ -1801,16 +1803,18 @@ const batchTagDialogVisible = ref(false)
|
|||
const batchTagValue = ref<string>('')
|
||||
|
||||
const openBatchTagDialog = () => {
|
||||
if (!selectedRowKeys.value.length) return
|
||||
if (!canEdit.value || !selectedRowKeys.value.length || batchActionLoading.value) return
|
||||
batchTagValue.value = ''
|
||||
batchTagDialogVisible.value = true
|
||||
}
|
||||
|
||||
const handleBatchTag = async () => {
|
||||
if (!selectedRowKeys.value.length || !props.kbId) return
|
||||
if (!canEdit.value || !selectedRowKeys.value.length || !props.kbId || batchActionLoading.value) return
|
||||
const selectedIds = [...selectedRowKeys.value]
|
||||
batchTagLoading.value = true
|
||||
try {
|
||||
const updates: Record<number, number | null> = {}
|
||||
selectedRowKeys.value.forEach(id => {
|
||||
selectedIds.forEach(id => {
|
||||
updates[id] = batchTagValue.value ? Number(batchTagValue.value) : null
|
||||
})
|
||||
await updateFAQEntryTagBatch(props.kbId, { updates })
|
||||
|
|
@ -1821,14 +1825,18 @@ const handleBatchTag = async () => {
|
|||
await loadTags(true)
|
||||
} catch (error: any) {
|
||||
MessagePlugin.error(error?.message || t('common.operationFailed'))
|
||||
} finally {
|
||||
batchTagLoading.value = false
|
||||
}
|
||||
}
|
||||
|
||||
const handleBatchStatusChange = async (isEnabled: boolean) => {
|
||||
if (!selectedRowKeys.value.length || !props.kbId) return
|
||||
if (!canEdit.value || !selectedRowKeys.value.length || !props.kbId || batchActionLoading.value) return
|
||||
const selectedIds = [...selectedRowKeys.value]
|
||||
batchStatusAction.value = isEnabled ? 'enable' : 'disable'
|
||||
try {
|
||||
const by_id: Record<number, { is_enabled: boolean }> = {}
|
||||
selectedRowKeys.value.forEach(id => {
|
||||
selectedIds.forEach(id => {
|
||||
by_id[id] = { is_enabled: isEnabled }
|
||||
})
|
||||
await updateFAQEntryFieldsBatch(props.kbId, { by_id })
|
||||
|
|
@ -1837,6 +1845,8 @@ const handleBatchStatusChange = async (isEnabled: boolean) => {
|
|||
await loadEntries()
|
||||
} catch (error: any) {
|
||||
MessagePlugin.error(error?.message || t('common.operationFailed'))
|
||||
} finally {
|
||||
batchStatusAction.value = null
|
||||
}
|
||||
}
|
||||
|
||||
|
|
@ -2424,24 +2434,6 @@ const handleImport = async () => {
|
|||
}
|
||||
}
|
||||
|
||||
// 监听选中数量变化,通知左侧菜单
|
||||
watch(selectedRowKeys, (newKeys, oldKeys) => {
|
||||
const count = newKeys.length
|
||||
// 获取选中条目的状态信息
|
||||
const selectedEntries = entries.value.filter(entry => newKeys.includes(entry.id))
|
||||
const enabledCount = selectedEntries.filter(entry => entry.is_enabled !== false).length
|
||||
const disabledCount = count - enabledCount
|
||||
|
||||
const event = new CustomEvent('faqSelectionChanged', {
|
||||
detail: {
|
||||
count,
|
||||
enabledCount,
|
||||
disabledCount
|
||||
}
|
||||
})
|
||||
window.dispatchEvent(event)
|
||||
}, { immediate: true, deep: true })
|
||||
|
||||
// 组件卸载时清理轮询
|
||||
onUnmounted(() => {
|
||||
stopPolling()
|
||||
|
|
@ -2830,31 +2822,15 @@ onMounted(async () => {
|
|||
orgStore.fetchSharedKnowledgeBases()
|
||||
loadKnowledgeList()
|
||||
window.addEventListener('resize', handleResize)
|
||||
window.addEventListener('faqMenuAction', handleFaqMenuAction as EventListener)
|
||||
// 如果已有kbId,恢复导入任务状态
|
||||
if (props.kbId) {
|
||||
await restoreImportTask()
|
||||
await loadImportResult() // 加载导入结果
|
||||
}
|
||||
// 主动触发一次选中数量事件,确保左侧菜单能接收到初始状态
|
||||
nextTick(() => {
|
||||
const count = selectedRowKeys.value.length
|
||||
const selectedEntries = entries.value.filter(entry => selectedRowKeys.value.includes(entry.id))
|
||||
const enabledCount = selectedEntries.filter(entry => entry.is_enabled !== false).length
|
||||
const disabledCount = count - enabledCount
|
||||
window.dispatchEvent(new CustomEvent('faqSelectionChanged', {
|
||||
detail: {
|
||||
count,
|
||||
enabledCount,
|
||||
disabledCount
|
||||
}
|
||||
}))
|
||||
})
|
||||
})
|
||||
|
||||
onUnmounted(() => {
|
||||
window.removeEventListener('resize', handleResize)
|
||||
window.removeEventListener('faqMenuAction', handleFaqMenuAction as EventListener)
|
||||
if (arrangeCardsTimer) {
|
||||
clearTimeout(arrangeCardsTimer)
|
||||
}
|
||||
|
|
@ -3047,6 +3023,7 @@ watch(() => entries.value.map(e => ({
|
|||
}
|
||||
|
||||
.faq-card-area {
|
||||
position: relative;
|
||||
flex: 1;
|
||||
min-width: 0;
|
||||
display: flex;
|
||||
|
|
@ -3622,6 +3599,26 @@ watch(() => entries.value.map(e => ({
|
|||
overflow-y: auto;
|
||||
overflow-x: hidden;
|
||||
padding-right: 4px;
|
||||
|
||||
&.has-batch-bar {
|
||||
padding-bottom: 76px;
|
||||
}
|
||||
}
|
||||
|
||||
.faq-batch-bar-anchor {
|
||||
position: absolute;
|
||||
right: 0;
|
||||
bottom: 12px;
|
||||
left: 0;
|
||||
z-index: 6;
|
||||
display: flex;
|
||||
justify-content: center;
|
||||
padding: 0 16px;
|
||||
pointer-events: none;
|
||||
|
||||
&>* {
|
||||
pointer-events: auto;
|
||||
}
|
||||
}
|
||||
|
||||
@keyframes contentFadeIn {
|
||||
|
|
@ -3683,14 +3680,18 @@ watch(() => entries.value.map(e => ({
|
|||
min-width: 0;
|
||||
max-width: 100%;
|
||||
overflow: hidden;
|
||||
cursor: pointer;
|
||||
cursor: default;
|
||||
transition: border-color 0.2s ease, box-shadow 0.2s ease, background-color 0.2s ease;
|
||||
box-sizing: border-box;
|
||||
height: fit-content;
|
||||
|
||||
&:hover {
|
||||
border-color: var(--td-brand-color);
|
||||
box-shadow: 0 2px 8px rgba(7, 192, 95, 0.1);
|
||||
&.is-selectable {
|
||||
cursor: pointer;
|
||||
|
||||
&:hover {
|
||||
border-color: var(--td-brand-color);
|
||||
box-shadow: 0 2px 8px rgba(7, 192, 95, 0.1);
|
||||
}
|
||||
}
|
||||
|
||||
&.selected {
|
||||
|
|
|
|||
Loading…
Reference in New Issue