117 lines
8.1 KiB
Vue
117 lines
8.1 KiB
Vue
<script setup lang="ts">
|
|
/**
|
|
* features/workspace/pages/ScheduleRunsPage.vue
|
|
* 排程执行记录:筛选、列表展示与结果 Excel 下载。
|
|
*/
|
|
import { inject } from 'vue';
|
|
import { RefreshCw, Search, Download } from 'lucide-vue-next';
|
|
import { WORKSPACE_KEY } from '../composables/workspace.context';
|
|
|
|
const ws = inject(WORKSPACE_KEY)! as any;
|
|
</script>
|
|
|
|
<template>
|
|
<div class="space-y-5 animate-fade-in-up">
|
|
<div class="flex items-center justify-between">
|
|
<h2 class="text-2xl font-bold text-primary">{{ $t('workspace.schedule.title') }}</h2>
|
|
<button
|
|
@click="ws.loadWorkspaceScheduleRuns"
|
|
class="inline-flex items-center gap-1.5 rounded-xl border border-default px-3 py-1.5 text-sm font-medium text-secondary transition-colors hover:bg-surface-soft"
|
|
>
|
|
<RefreshCw class="h-3.5 w-3.5" />
|
|
{{ $t('workspace.schedule.refresh') }}
|
|
</button>
|
|
</div>
|
|
<div class="flex flex-wrap items-end gap-3 rounded-2xl border border-default/80 bg-surface/70 px-4 py-3 shadow-sm">
|
|
<div>
|
|
<label class="mb-1 block text-xs font-medium text-muted">{{ $t('workspace.schedule.filters.name') }}</label>
|
|
<input type="text" v-model="ws.wsScheduleNameFilter" :placeholder="$t('workspace.schedule.filters.namePlaceholder')" :class="['!w-[150px]', ws.wsScheduleFilterInputClass]" />
|
|
</div>
|
|
<div>
|
|
<label class="mb-1 block text-xs font-medium text-muted">{{ $t('workspace.schedule.filters.start') }}</label>
|
|
<input type="datetime-local" step="1" v-model="ws.wsScheduleStartedAfter" :class="['!w-[170px]', ws.wsScheduleFilterInputClass]" />
|
|
</div>
|
|
<div>
|
|
<label class="mb-1 block text-xs font-medium text-muted">{{ $t('workspace.schedule.filters.end') }}</label>
|
|
<input type="datetime-local" step="1" v-model="ws.wsScheduleStartedBefore" :class="['!w-[170px]', ws.wsScheduleFilterInputClass]" />
|
|
</div>
|
|
<div>
|
|
<label class="mb-1 block text-xs font-medium text-muted">{{ $t('workspace.schedule.filters.status') }}</label>
|
|
<select v-model="ws.wsScheduleStatusFilter" :class="['!w-[120px]', ws.wsScheduleFilterInputClass]">
|
|
<option v-for="o in ws.wsScheduleStatusOptions" :key="o.value" :value="o.value">{{ o.label }}</option>
|
|
</select>
|
|
</div>
|
|
<button
|
|
@click="ws.loadWorkspaceScheduleRuns"
|
|
class="inline-flex items-center gap-1 rounded-xl bg-brand-600 px-3 py-1.5 text-sm font-medium text-white transition-colors hover:bg-brand-700"
|
|
>
|
|
<Search class="h-3.5 w-3.5" />
|
|
{{ $t('workspace.schedule.search') }}
|
|
</button>
|
|
<button
|
|
@click="ws.resetWsScheduleFilters"
|
|
class="rounded-xl border border-default px-3 py-1.5 text-sm font-medium text-secondary transition-colors hover:bg-surface-soft"
|
|
>
|
|
{{ $t('workspace.schedule.reset') }}
|
|
</button>
|
|
</div>
|
|
<div v-if="ws.workspaceScheduleLoading" class="rounded-2xl border border-dashed border-default py-10 text-center text-sm text-muted">{{ $t('workspace.schedule.loading') }}</div>
|
|
<div v-else-if="ws.workspaceScheduleRuns.length === 0" class="rounded-2xl border border-dashed border-default py-10 text-center text-sm text-muted">{{ $t('workspace.schedule.empty') }}</div>
|
|
<div v-else class="overflow-hidden rounded-2xl border border-default bg-surface">
|
|
<div class="max-h-[calc(100vh-17rem)] overflow-auto scrollbar-thin">
|
|
<table class="w-full min-w-[1080px] text-sm">
|
|
<thead class="sticky top-0 z-10">
|
|
<tr class="border-b border-subtle bg-surface-soft">
|
|
<th class="min-w-[120px] whitespace-nowrap bg-surface-soft px-4 py-3 text-left font-semibold text-secondary">{{ $t('workspace.schedule.columns.name') }}</th>
|
|
<th class="min-w-[168px] whitespace-nowrap bg-surface-soft px-4 py-3 text-left font-semibold text-secondary">{{ $t('workspace.schedule.columns.runNo') }}</th>
|
|
<th class="min-w-[72px] whitespace-nowrap bg-surface-soft px-4 py-3 text-left font-semibold text-secondary">{{ $t('workspace.schedule.columns.triggerType') }}</th>
|
|
<th class="min-w-[152px] whitespace-nowrap bg-surface-soft px-4 py-3 text-left font-semibold text-secondary">{{ $t('workspace.schedule.columns.start') }}</th>
|
|
<th class="min-w-[152px] whitespace-nowrap bg-surface-soft px-4 py-3 text-left font-semibold text-secondary">{{ $t('workspace.schedule.columns.end') }}</th>
|
|
<th class="min-w-[64px] whitespace-nowrap bg-surface-soft px-4 py-3 text-left font-semibold text-secondary">{{ $t('workspace.schedule.columns.duration') }}</th>
|
|
<th class="min-w-[88px] whitespace-nowrap bg-surface-soft px-4 py-3 text-left font-semibold text-secondary">{{ $t('workspace.schedule.columns.status') }}</th>
|
|
<th class="min-w-[72px] whitespace-nowrap bg-surface-soft px-4 py-3 text-left font-semibold text-secondary">{{ $t('workspace.schedule.columns.total') }}</th>
|
|
<th class="min-w-[72px] whitespace-nowrap bg-surface-soft px-4 py-3 text-left font-semibold text-secondary">{{ $t('workspace.schedule.columns.success') }}</th>
|
|
<th class="min-w-[72px] whitespace-nowrap bg-surface-soft px-4 py-3 text-left font-semibold text-secondary">{{ $t('workspace.schedule.columns.failed') }}</th>
|
|
|
|
<th class="min-w-[72px] whitespace-nowrap bg-surface-soft px-4 py-3 text-left font-semibold text-secondary">{{ $t('workspace.schedule.columns.detail') }}</th>
|
|
</tr>
|
|
</thead>
|
|
<tbody>
|
|
<tr v-for="r in ws.workspaceScheduleRuns" :key="r.id" class="border-b border-slate-50 transition-colors hover:bg-surface-soft/50">
|
|
<td class="whitespace-nowrap px-4 py-3 font-medium text-primary">{{ r.schedule_name || '-' }}</td>
|
|
<td class="whitespace-nowrap px-4 py-3 font-mono text-xs text-muted">{{ r.run_no }}</td>
|
|
<td class="whitespace-nowrap px-4 py-3 text-muted">{{ r.trigger_type === 'manual' ? $t('workspace.schedule.trigger.manual') : r.trigger_type === 'test' ? $t('workspace.schedule.trigger.test') : $t('workspace.schedule.trigger.timed') }}</td>
|
|
<td class="whitespace-nowrap px-4 py-3 text-muted">{{ ws.formatDateTime(r.started_at) }}</td>
|
|
<td class="whitespace-nowrap px-4 py-3 text-muted">{{ ws.formatDateTime(r.finished_at) }}</td>
|
|
<td class="whitespace-nowrap px-4 py-3 text-muted">{{ r.duration_ms != null ? (r.duration_ms >= 1000 ? (r.duration_ms / 1000).toFixed(1) + 's' : r.duration_ms + 'ms') : '-' }}</td>
|
|
<td class="whitespace-nowrap px-4 py-3">
|
|
<span class="inline-flex shrink-0 items-center whitespace-nowrap rounded-full px-2.5 py-1 text-xs font-semibold" :class="ws.getWsScheduleStatusBadge(r.status).cls">
|
|
{{ ws.getWsScheduleStatusBadge(r.status).label }}
|
|
</span>
|
|
<span v-if="r.error_message && r.error_message !== '无待处理数据'" class="ml-1 text-xs text-muted" :title="r.error_message">...</span>
|
|
<span v-else-if="r.error_message === '无待处理数据'" class="ml-1 text-xs text-muted">({{ $t('workspace.schedule.noPendingData') }})</span>
|
|
</td>
|
|
<td class="whitespace-nowrap px-4 py-3 text-muted">{{ r.total_count || 0 }}</td>
|
|
<td class="whitespace-nowrap px-4 py-3 font-medium text-emerald-600">{{ r.success_count ?? 0 }}</td>
|
|
<td class="whitespace-nowrap px-4 py-3 font-medium text-rose-600">{{ r.failed_count ?? 0 }}</td>
|
|
|
|
<td class="whitespace-nowrap px-4 py-3">
|
|
<a
|
|
v-if="r.total_count > 0 && r.excel_file_name"
|
|
href="#"
|
|
@click.prevent="ws.downloadWsScheduleExcel(r.id)"
|
|
class="inline-flex items-center gap-1 rounded-lg border border-default px-2 py-1 text-xs font-medium text-secondary transition-colors hover:bg-surface-soft"
|
|
>
|
|
<Download class="h-3 w-3" />
|
|
{{ $t('workspace.schedule.download') }}
|
|
</a>
|
|
<span v-else class="text-xs text-slate-300">-</span>
|
|
</td>
|
|
</tr>
|
|
</tbody>
|
|
</table>
|
|
</div>
|
|
</div>
|
|
</div>
|
|
</template>
|