Merge branch 'dev' into runny827
feat(training): 新增精益培训视频与周任务管理 # Conflicts: # backend/app/models/__init__.py
This commit is contained in:
1 parent
85d27e9ffa
commit
91b7233872
812 files changed
+73763
-18908
No files matched your search
@@ -0,0 +1,246 @@
|
||||
<!--
|
||||
features/chat/components/messages/TransferSourceSelectCard.vue
|
||||
用途:来源实例选择卡(决策 2/3/4:手工两步第一步)——按平台 DBS/Crane 分组勾选实例,
|
||||
“确认范围并预检”发起预检。
|
||||
依赖:props.sources、i18n chat.transfer.*。
|
||||
逻辑:平台仅分组不可直接执行;未选任何实例时确认按钮禁用。
|
||||
-->
|
||||
<script setup lang="ts">
|
||||
import { computed, ref } from 'vue';
|
||||
import { useI18n } from 'vue-i18n';
|
||||
import { useMessage } from '@/shared/composables/useMessage';
|
||||
import type { TransferSourceOption } from '../../types/transfer.types';
|
||||
|
||||
const props = defineProps<{
|
||||
sources: TransferSourceOption[];
|
||||
busy?: boolean;
|
||||
/** 正在重试收料 RPA 的来源编码集合 */
|
||||
retrying?: Set<string>;
|
||||
}>();
|
||||
|
||||
const emit = defineEmits<{
|
||||
confirm: [sourceCodes: string[]];
|
||||
/** 批量重试收料 RPA:传来源编码列表 */
|
||||
retry: [sourceCodes: string[]];
|
||||
}>();
|
||||
|
||||
const { warning: notifyWarning } = useMessage();
|
||||
const { t } = useI18n();
|
||||
|
||||
const selected = ref<Set<string>>(new Set());
|
||||
|
||||
const platforms = computed(() => [...new Set(props.sources.map((source) => source.platform))]);
|
||||
const selectedCount = computed(() => selected.value.size);
|
||||
|
||||
/** 可重试判定:仅 待抓取(none) / 抓取失败(failed) 的来源可重试(ready/fetching 不重复触发)。 */
|
||||
function isRetryable(source: TransferSourceOption): boolean {
|
||||
return source.file_status === 'none' || source.file_status === 'failed';
|
||||
}
|
||||
|
||||
/** 全部可重试来源。 */
|
||||
const retryableSources = computed(() => props.sources.filter(isRetryable));
|
||||
/** 已选来源中可重试的数量。 */
|
||||
const selectedRetryableCount = computed(() =>
|
||||
[...selected.value].filter((code) => props.sources.some((s) => s.source_code === code && isRetryable(s))).length,
|
||||
);
|
||||
const batchRetryDisabled = computed(() => props.busy || selectedRetryableCount.value === 0);
|
||||
|
||||
/** 已选来源中是否有具备 ready 文件的(门禁:都无 ready 文件则禁止确认预检)。 */
|
||||
const selectedHasReadyFile = computed(() =>
|
||||
[...selected.value].some((code) => props.sources.find((s) => s.source_code === code)?.has_ready_file),
|
||||
);
|
||||
const confirmDisabled = computed(() => props.busy || selectedCount.value === 0 || !selectedHasReadyFile.value);
|
||||
|
||||
function toggle(sourceCode: string, checked: boolean) {
|
||||
const next = new Set(selected.value);
|
||||
if (checked) next.add(sourceCode);
|
||||
else next.delete(sourceCode);
|
||||
selected.value = next;
|
||||
}
|
||||
|
||||
function togglePlatform(platform: string, checked: boolean) {
|
||||
const next = new Set(selected.value);
|
||||
for (const source of props.sources) {
|
||||
if (source.platform === platform) {
|
||||
if (checked) next.add(source.source_code);
|
||||
else next.delete(source.source_code);
|
||||
}
|
||||
}
|
||||
selected.value = next;
|
||||
}
|
||||
|
||||
/** 全选当前可见来源(已启用实例)。 */
|
||||
function selectVisible() {
|
||||
selected.value = new Set(props.sources.filter((source) => source.enabled).map((source) => source.source_code));
|
||||
}
|
||||
|
||||
/** 只选可重试来源(待抓取/抓取失败),来源多时一键收敛。 */
|
||||
function selectRetryable() {
|
||||
selected.value = new Set(retryableSources.value.map((source) => source.source_code));
|
||||
}
|
||||
|
||||
/** 清空选择。 */
|
||||
function clearSelected() {
|
||||
selected.value = new Set();
|
||||
}
|
||||
|
||||
/** 批量重试收料 RPA:仅触发所选来源中可重试的那部分。 */
|
||||
function batchRetry() {
|
||||
const codes = [...selected.value].filter(
|
||||
(code) => props.sources.some((s) => s.source_code === code && isRetryable(s)),
|
||||
);
|
||||
if (codes.length === 0) {
|
||||
notifyWarning(t('chat.transfer.noRetryable'), t('chat.transfer.sourceSelectTitle'));
|
||||
return;
|
||||
}
|
||||
emit('retry', codes);
|
||||
}
|
||||
|
||||
function confirm() {
|
||||
if (selectedCount.value === 0) {
|
||||
notifyWarning(t('chat.transfer.needSelectSource'), t('chat.transfer.sourceSelectTitle'));
|
||||
return;
|
||||
}
|
||||
if (!selectedHasReadyFile.value) {
|
||||
notifyWarning(t('chat.transfer.needReadyFile'), t('chat.transfer.sourceSelectTitle'));
|
||||
return;
|
||||
}
|
||||
emit('confirm', [...selected.value]);
|
||||
}
|
||||
</script>
|
||||
|
||||
<template>
|
||||
<div class="my-2 rounded-2xl border border-brand-100 bg-surface p-4 shadow-sm" data-testid="transfer-source-select-card">
|
||||
<h3 class="mb-1 text-sm font-bold text-primary">{{ $t('chat.transfer.sourceSelectTitle') }}</h3>
|
||||
<p class="mb-3 text-xs text-muted">{{ $t('chat.transfer.sourceSelectHint') }}</p>
|
||||
|
||||
<div class="mb-3 flex flex-wrap items-center gap-2">
|
||||
<button
|
||||
type="button"
|
||||
class="rounded-lg border border-brand-200 px-3 py-1.5 text-xs font-bold text-brand-700 hover:bg-brand-50 disabled:opacity-50"
|
||||
:disabled="busy"
|
||||
data-testid="transfer-source-select-visible"
|
||||
@click="selectVisible"
|
||||
>
|
||||
{{ $t('chat.transfer.selectVisible') }}
|
||||
</button>
|
||||
<button
|
||||
type="button"
|
||||
class="rounded-lg border border-brand-200 px-3 py-1.5 text-xs font-bold text-brand-700 hover:bg-brand-50 disabled:opacity-50"
|
||||
:disabled="busy"
|
||||
data-testid="transfer-source-select-retryable"
|
||||
@click="selectRetryable"
|
||||
>
|
||||
{{ $t('chat.transfer.selectRetryable') }}
|
||||
</button>
|
||||
<button
|
||||
type="button"
|
||||
class="rounded-lg bg-brand-600 px-3 py-1.5 text-xs font-bold text-white hover:bg-brand-700 disabled:opacity-50"
|
||||
:disabled="batchRetryDisabled"
|
||||
data-testid="transfer-source-batch-retry"
|
||||
@click="batchRetry"
|
||||
>
|
||||
{{ $t('chat.transfer.batchRetry') }}
|
||||
</button>
|
||||
<button
|
||||
type="button"
|
||||
class="rounded-lg border border-default px-3 py-1.5 text-xs font-bold text-secondary hover-surface-soft disabled:opacity-50"
|
||||
:disabled="busy"
|
||||
data-testid="transfer-source-clear"
|
||||
@click="clearSelected"
|
||||
>
|
||||
{{ $t('chat.transfer.clearSources') }}
|
||||
</button>
|
||||
<span class="ml-auto text-xs text-muted">
|
||||
{{ $t('chat.transfer.selectedSourceCount', { count: selectedCount }) }}
|
||||
<span v-if="selectedRetryableCount > 0" class="text-amber-600"> · {{ $t('chat.transfer.selectedRetryableCount', { count: selectedRetryableCount }) }}</span>
|
||||
</span>
|
||||
</div>
|
||||
|
||||
<div v-for="platform in platforms" :key="platform" class="mb-3 rounded-lg border border-subtle">
|
||||
<div class="flex items-center justify-between rounded-t-lg bg-surface-soft px-3 py-1.5">
|
||||
<b class="text-xs text-secondary">{{ platform.toUpperCase() }}</b>
|
||||
<label class="text-[11px] text-muted">
|
||||
<input
|
||||
type="checkbox"
|
||||
:checked="props.sources.filter((source) => source.platform === platform).every((source) => selected.has(source.source_code))"
|
||||
@change="togglePlatform(platform, ($event.target as HTMLInputElement).checked)"
|
||||
/>
|
||||
{{ $t('chat.transfer.selectAll') }}
|
||||
</label>
|
||||
</div>
|
||||
<div class="grid grid-cols-1 gap-1 p-2 sm:grid-cols-2">
|
||||
<div
|
||||
v-for="source in props.sources.filter((item) => item.platform === platform)"
|
||||
:key="source.source_code"
|
||||
class="flex items-center gap-2 rounded-lg px-2 py-1.5 hover-surface-soft"
|
||||
:data-testid="`transfer-source-option-${source.source_code}`"
|
||||
>
|
||||
<input
|
||||
type="checkbox"
|
||||
:checked="selected.has(source.source_code)"
|
||||
:disabled="busy"
|
||||
@change="toggle(source.source_code, ($event.target as HTMLInputElement).checked)"
|
||||
/>
|
||||
<span class="min-w-0 flex-1">
|
||||
<span class="block truncate text-xs font-semibold text-secondary">{{ source.source_code }}</span>
|
||||
<span class="block truncate text-[11px] text-muted">{{ source.display_name }}</span>
|
||||
</span>
|
||||
<span class="shrink-0">
|
||||
<span
|
||||
v-if="source.has_ready_file"
|
||||
class="inline-flex items-center gap-1 rounded-full bg-emerald-50 px-2 py-0.5 text-[10px] font-bold text-emerald-700"
|
||||
:data-testid="`transfer-source-status-${source.source_code}`"
|
||||
>
|
||||
{{ t('chat.transfer.fileReady') }}
|
||||
</span>
|
||||
<span
|
||||
v-else-if="source.file_status === 'fetching'"
|
||||
class="inline-flex items-center gap-1 rounded-full bg-amber-50 px-2 py-0.5 text-[10px] font-bold text-amber-700"
|
||||
:data-testid="`transfer-source-status-${source.source_code}`"
|
||||
>
|
||||
{{ t('chat.transfer.fileFetching') }}
|
||||
</span>
|
||||
<span
|
||||
v-else-if="source.file_status === 'failed'"
|
||||
class="inline-flex items-center gap-1 rounded-full bg-red-50 px-2 py-0.5 text-[10px] font-bold text-red-700"
|
||||
:data-testid="`transfer-source-status-${source.source_code}`"
|
||||
>
|
||||
{{ t('chat.transfer.fileFailed') }}
|
||||
</span>
|
||||
<span
|
||||
v-else
|
||||
class="inline-flex items-center gap-1 rounded-full bg-surface-strong px-2 py-0.5 text-[10px] font-bold text-muted"
|
||||
:data-testid="`transfer-source-status-${source.source_code}`"
|
||||
>
|
||||
{{ t('chat.transfer.fileNone') }}
|
||||
</span>
|
||||
<button
|
||||
type="button"
|
||||
class="ml-1 inline-flex h-6 w-6 items-center justify-center rounded-md border border-default text-sm text-muted hover:border-brand-200 hover:text-brand-700 disabled:cursor-not-allowed disabled:opacity-40"
|
||||
:disabled="busy || !isRetryable(source) || retrying?.has(source.source_code)"
|
||||
:title="t('chat.transfer.retryReceipt')"
|
||||
:data-testid="`transfer-source-retry-${source.source_code}`"
|
||||
@click.stop="emit('retry', [source.source_code])"
|
||||
>
|
||||
<span aria-hidden="true">{{ retrying?.has(source.source_code) ? '…' : '↻' }}</span>
|
||||
</button>
|
||||
</span>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="flex items-center justify-end gap-3 border-t border-subtle pt-3">
|
||||
<span class="text-xs text-muted">{{ $t('chat.transfer.selectedCount', { count: selectedCount }) }}</span>
|
||||
<button
|
||||
type="button"
|
||||
class="rounded-lg bg-brand-600 px-4 py-1.5 text-sm font-bold text-white hover:bg-brand-700 disabled:cursor-not-allowed disabled:opacity-40"
|
||||
:disabled="confirmDisabled"
|
||||
data-testid="transfer-source-confirm"
|
||||
@click="confirm"
|
||||
>
|
||||
{{ $t('chat.transfer.confirmScopeAndPrecheck') }}
|
||||
</button>
|
||||
</div>
|
||||
</div>
|
||||
</template>
|
||||
Reference in new issue
Block a user