update UI

This commit is contained in:
sophie committed 2026-05-26 10:36:25 +08:00
1 parent 6bc93490d4
commit dbef371b75
3 files changed
+421 -137

No files matched your search

+268 -4
View File
@@ -452,7 +452,8 @@ const messages = {
wecom: 'WeCom',
permissions: 'App Permissions',
requests: 'Permission Requests',
reports: 'Data Reports'
reports: 'Data Reports',
schedules: 'Schedule Management'
},
// Dashboard
@@ -1010,6 +1011,135 @@ const messages = {
// Common Messages
schedule: {
overviewTitle: 'Schedule Management Overview',
workbenchTitle: 'Schedule Management Workbench',
overviewSubtitle: 'Click a schedule card to open the workbench.',
workbenchSubtitle: 'Schedule list on the left, run records on the right.',
refresh: 'Refresh schedules',
stats: {
total: 'Total schedules',
enabled: 'Enabled',
disabled: 'Disabled',
running: 'Running'
},
sectionOverview: 'Schedule Management Overview',
switchByCard: 'Switch by card',
addTitle: 'Add schedule',
addHint: 'Click the button to fill in schedule fields in a dialog.',
addButton: 'Add schedule',
emptyList: 'No schedules yet. Create one first.',
loading: 'Loading...',
enabled: 'Enabled',
disabled: 'Disabled',
scheduleNo: 'No.',
config: 'Config',
owner: 'Owner',
lastRun: 'Last run',
nextRun: 'Next run',
noSelection: 'No schedule selected',
selectedHint: 'Selected schedule · Last run {time}',
runBatches: 'Run batches',
totalProcessed: 'Total processed',
totalSuccess: 'Total success',
totalFailed: 'Total failed',
listTitle: 'Schedule list',
recordsTitle: '{name} · Run records',
recordsSubtitle: 'Run record details are shown below.',
noSelectionHint: 'Select a schedule from the list on the left first.',
filterStart: 'Start',
filterEnd: 'End',
query: 'Search',
reset: 'Reset',
queryingRuns: 'Loading records...',
noRunRecords: 'No run records yet.',
runLogs: 'Run logs',
stepsCount: '{count} steps',
viewDetail: 'View details',
resizeColumn: 'Drag to resize {label} column',
notified: 'Notified',
notifyError: 'Error',
download: 'Download',
log: 'Log',
actions: {
edit: 'Edit',
start: 'Start',
pause: 'Pause',
run: 'Run',
test: 'Test',
delete: 'Delete'
},
columns: {
runNo: 'Run ID',
startedAt: 'Started at',
finishedAt: 'Finished at',
status: 'Status',
totalCount: 'Processed',
successCount: 'Success',
failedCount: 'Failed',
wecomNotified: 'WeCom notify',
detail: 'Detail',
log: 'Log'
},
form: {
editTitle: 'Edit schedule',
createTitle: 'Add schedule',
name: 'Schedule name',
namePlaceholder: 'e.g. RoHS auto review schedule',
owner: 'Schedule owner',
noUsers: 'No users available',
selectOwner: 'Select an owner',
dataSourceConfig: 'Data source & execution config',
databaseDirect: 'Database',
externalApi: 'External API',
querying: 'Querying...',
testQuery: 'Test query',
expandConfig: 'Expand config',
collapseConfig: 'Collapse config',
dataSourceSection: 'Data source config',
waitSeconds: 'Wait time (seconds)',
noAgents: 'No agents available',
agentDisabled: 'Disabled',
cronTitle: 'Cron visual editor',
cronHint: 'Cron expression is generated automatically from the frequency you choose.',
everyMinutes: 'Every N minutes',
hourly: 'Hourly',
daily: 'Daily',
weekly: 'Weekly',
minuteInterval: 'Minute interval',
minuteOfHour: 'Minute of hour',
hour: 'Hour',
minute: 'Minute',
weekday: 'Weekday',
cronPreview: 'Cron preview',
nextRun: 'Next run',
notifyEnabled: 'Enable notifications',
selectNotifyUsers: 'Select notification recipients...',
enableOnCreate: 'Enable after creation',
cancel: 'Cancel',
saving: 'Saving...',
saveChanges: 'Save changes',
createSchedule: 'Create schedule'
},
testRun: {
title: 'Test run — {name}',
subtitle: 'Edit WHERE clause, limit rows, run quickly and inspect each step',
close: 'Close',
running: 'Running...',
start: 'Start test run',
waitingHint: 'Dify calls may take a while, please wait...',
total: 'Total',
success: 'Success',
failed: 'Failed',
skipped: 'Skipped',
limitSummary: 'Limit {limit} rows | Dify Agent ID: {agentId}',
noAgent: 'None',
stepLogs: 'Step logs',
viewSql: 'View execution SQL',
errors: 'Errors ({count})',
queryResult: 'Query result',
resultSummary: '{total} total, showing {showing}',
viewGeneratedSql: 'View generated SQL'
},
status: {
all: 'All',
success: 'Success',
@@ -1038,6 +1168,7 @@ const messages = {
deleteConfirmMessage: 'Confirm deleting schedule \"{name}\"?',
msg: {
testRunFailed: 'Test run failed',
testQueryFailed: 'Test query failed',
configRequired: 'At least one of Dify Agent, SQL config, or external API is required.',
headerLabelsJsonInvalid: 'header_labels JSON format is invalid.',
apiHeadersJsonInvalid: 'API Headers JSON format is invalid.',
@@ -1766,7 +1897,8 @@ const messages = {
wecom: '企业微信',
permissions: '应用权限',
requests: '权限审批',
reports: '数据报表'
reports: '数据报表',
schedules: '排程管理'
},
// Dashboard
@@ -2303,6 +2435,135 @@ const messages = {
// Common Messages
schedule: {
overviewTitle: '排程管理概览',
workbenchTitle: '排程管理工作台',
overviewSubtitle: '点击排程卡片进入排程工作台。',
workbenchSubtitle: '左侧排程列表,右侧执行记录列表。',
refresh: '刷新排程',
stats: {
total: '排程总数',
enabled: '启用中',
disabled: '停用中',
running: '执行中'
},
sectionOverview: '排程管理概览',
switchByCard: '按卡片切换',
addTitle: '新增排程',
addHint: '点击按钮后弹窗录入排程字段。',
addButton: '新增排程',
emptyList: '暂无排程,请先创建。',
loading: '正在加载...',
enabled: '启用',
disabled: '停用',
scheduleNo: '编号',
config: '配置',
owner: '所有者',
lastRun: '最近执行',
nextRun: '下次执行',
noSelection: '未选择排程',
selectedHint: '当前选中排程 · 最近执行 {time}',
runBatches: '执行批次',
totalProcessed: '处理总数',
totalSuccess: '成功总数',
totalFailed: '失败总数',
listTitle: '排程列表',
recordsTitle: '{name} · 执行记录',
recordsSubtitle: '下方仅展示执行记录明细。',
noSelectionHint: '未选择排程,请先在左侧列表选择一个排程。',
filterStart: '开始',
filterEnd: '结束',
query: '查询',
reset: '重置',
queryingRuns: '正在查询记录...',
noRunRecords: '暂无执行记录。',
runLogs: '执行日志',
stepsCount: '共 {count} 步',
viewDetail: '查看详情',
resizeColumn: '拖拽调整{label}列宽',
notified: '已通知',
notifyError: '异常',
download: '下载',
log: '日志',
actions: {
edit: '编辑',
start: '启动',
pause: '暂停',
run: '执行',
test: '测试',
delete: '删除'
},
columns: {
runNo: '执行单号',
startedAt: '开始时间',
finishedAt: '结束时间',
status: '状态',
totalCount: '处理',
successCount: '成功',
failedCount: '失败',
wecomNotified: '企微通知',
detail: '明细',
log: '日志'
},
form: {
editTitle: '编辑排程',
createTitle: '新增排程',
name: '排程名称',
namePlaceholder: '例如:RoHS 自动审核排程',
owner: '排程所有者',
noUsers: '暂无可用用户',
selectOwner: '请选择所有者',
dataSourceConfig: '数据源与执行配置',
databaseDirect: '数据库直联',
externalApi: '外部API',
querying: '查询中...',
testQuery: '测试查询',
expandConfig: '展开配置',
collapseConfig: '收起配置',
dataSourceSection: '数据源配置',
waitSeconds: '等待时间(秒)',
noAgents: '暂无可用 Agent',
agentDisabled: '不启用',
cronTitle: 'Cron 图形化设置',
cronHint: '选择执行频率后自动生成 Cron 表达式。',
everyMinutes: '每隔分钟',
hourly: '每小时',
daily: '每天',
weekly: '每周',
minuteInterval: '分钟间隔',
minuteOfHour: '每小时第几分钟',
hour: '小时',
minute: '分钟',
weekday: '星期',
cronPreview: 'Cron 预览',
nextRun: '下次执行',
notifyEnabled: '启用通知',
selectNotifyUsers: '选择通知人员...',
enableOnCreate: '创建后启用',
cancel: '取消',
saving: '保存中...',
saveChanges: '保存修改',
createSchedule: '创建排程'
},
testRun: {
title: '测试执行 — {name}',
subtitle: '编辑 WHERE 条件,限制行数,快速执行并查看每步结果',
close: '关闭',
running: '执行中...',
start: '开始测试执行',
waitingHint: 'Dify 调用可能需要较长时间,请耐心等待...',
total: '总处理',
success: '成功',
failed: '失败',
skipped: '跳过',
limitSummary: '限制 {limit} 条 | Dify Agent ID: {agentId}',
noAgent: '无',
stepLogs: '步骤日志',
viewSql: '查看执行 SQL',
errors: '错误信息 ({count})',
queryResult: '查询结果',
resultSummary: '共 {total} 条,展示 {showing} 条',
viewGeneratedSql: '查看生成 SQL'
},
status: {
all: '全部状态',
success: '成功',
@@ -2331,6 +2592,7 @@ const messages = {
deleteConfirmMessage: '确认删除排程「{name}」?',
msg: {
testRunFailed: '测试执行失败',
testQueryFailed: '测试查询失败',
configRequired: 'Dify Agent、SQL 配置或外部 API 至少填写一项,否则排程执行无任何效果',
headerLabelsJsonInvalid: 'header_labels JSON 格式错误,请检查',
apiHeadersJsonInvalid: 'API Headers JSON 格式错误,请检查',
@@ -3043,7 +3305,8 @@ const messages = {
wecom: '企業微信',
permissions: '應用權限',
requests: '權限審批',
reports: '數據報表'
reports: '數據報表',
schedules: '排程管理'
},
// Dashboard
@@ -4242,7 +4505,8 @@ const messages = {
wecom: 'WeCom',
permissions: 'สิทธิ์แอปพลิเคชัน',
requests: 'คำขอสิทธิ์',
reports: 'รายงานข้อมูล'
reports: 'รายงานข้อมูล',
schedules: 'Schedule Management'
},
// Dashboard
+144 -124
View File
@@ -70,7 +70,7 @@ const sidebarItems = computed(() => {
{ id: 'departments', icon: Building, label: t('admin.nav.departments') },
{ id: 'agents', icon: Bot, label: t('admin.nav.agents') },
{ id: 'knowledge_base', icon: FileText, label: t('admin.nav.knowledgeBase') },
{ id: 'schedules', icon: Settings2, label: '排程管理' },
{ id: 'schedules', icon: Settings2, label: t('admin.nav.schedules') },
{ id: 'announcements', icon: Megaphone, label: t('admin.nav.announcements') },
{ id: 'questions', icon: MessageCircleQuestion, label: t('admin.nav.questions') },
{ id: 'wecom', icon: Link2, label: t('admin.nav.wecom') },
@@ -456,17 +456,37 @@ const scheduleRunStatusFilter = ref<'all' | string>('all');
const scheduleRunStartedAfter = ref('');
const scheduleRunStartedBefore = ref('');
const scheduleRunColumnDefs = ref([
{ key: 'run_no', label: '执行单号', width: 280, min: 60 },
{ key: 'started_at', label: '开始时间', width: 190, min: 60 },
{ key: 'finished_at', label: '结束时间', width: 190, min: 60 },
{ key: 'status', label: '状态', width: 130, min: 50 },
{ key: 'total_count', label: '处理', width: 70, min: 40 },
{ key: 'success_count', label: '成功', width: 70, min: 40 },
{ key: 'failed_count', label: '失败', width: 70, min: 40 },
{ key: 'wecom_notified', label: '企微通知', width: 90, min: 50 },
{ key: 'detail', label: '明细', width: 90, min: 50 },
{ key: 'log', label: '日志', width: 90, min: 50 },
{ key: 'run_no', label: '', width: 280, min: 60 },
{ key: 'started_at', label: '', width: 190, min: 60 },
{ key: 'finished_at', label: '', width: 190, min: 60 },
{ key: 'status', label: '', width: 130, min: 50 },
{ key: 'total_count', label: '', width: 70, min: 40 },
{ key: 'success_count', label: '', width: 70, min: 40 },
{ key: 'failed_count', label: '', width: 70, min: 40 },
{ key: 'wecom_notified', label: '', width: 90, min: 50 },
{ key: 'detail', label: '', width: 90, min: 50 },
{ key: 'log', label: '', width: 90, min: 50 },
]);
const syncScheduleRunColumnLabels = () => {
const keyToI18n: Record<string, string> = {
run_no: 'runNo',
started_at: 'startedAt',
finished_at: 'finishedAt',
status: 'status',
total_count: 'totalCount',
success_count: 'successCount',
failed_count: 'failedCount',
wecom_notified: 'wecomNotified',
detail: 'detail',
log: 'log',
};
scheduleRunColumnDefs.value.forEach((col) => {
const i18nKey = keyToI18n[col.key];
if (i18nKey) col.label = t(`admin.schedule.columns.${i18nKey}`);
});
};
watch(locale, syncScheduleRunColumnLabels, { immediate: true });
const resizingScheduleCol = ref<{ index: number; startX: number; startWidth: number } | null>(null);
const onScheduleColResizeMove = (event: MouseEvent) => {
@@ -522,7 +542,7 @@ const scheduleCronDesigner = ref({
weekly_hour: 9,
weekly_minute: 0,
});
const weeklyDayOptions = [
const weeklyDayOptions = computed(() => [
{ value: 1, label: t('admin.schedule.weekday.mon') },
{ value: 2, label: t('admin.schedule.weekday.tue') },
{ value: 3, label: t('admin.schedule.weekday.wed') },
@@ -530,7 +550,7 @@ const weeklyDayOptions = [
{ value: 5, label: t('admin.schedule.weekday.fri') },
{ value: 6, label: t('admin.schedule.weekday.sat') },
{ value: 0, label: t('admin.schedule.weekday.sun') },
];
]);
const buildCronExprFromDesigner = () => {
const cfg = scheduleCronDesigner.value;
@@ -807,13 +827,13 @@ const selectedSchedule = computed(() =>
schedules.value.find((item) => item.id === selectedScheduleId.value) || null
);
const scheduleRunStatusOptions = [
const scheduleRunStatusOptions = computed(() => [
{ value: 'all', label: t('admin.schedule.status.all') },
{ value: 'success', label: t('admin.schedule.status.success') },
{ value: 'partial_failed', label: t('admin.schedule.status.partialFailed') },
{ value: 'failed', label: t('admin.schedule.status.failed') },
{ value: 'running', label: t('admin.schedule.status.running') },
];
]);
const getScheduleRunStatusBadge = (status: string) => {
const map: Record<string, { cls: string; label: string }> = {
@@ -991,7 +1011,7 @@ const handleTestScheduleSql = async () => {
});
scheduleTestResult.value = result;
} catch (e: any) {
msg.error(`测试查询失败: ${e?.message || e}`);
msg.error(`${t('admin.schedule.msg.testQueryFailed')}: ${e?.message || e}`);
} finally {
scheduleTestLoading.value = false;
}
@@ -4258,10 +4278,10 @@ const handlePermissionImport = async (event: Event) => {
</div>
<div>
<h2 class="text-2xl font-bold tracking-tight text-slate-900">
{{ scheduleViewMode === 'overview' ? '排程管理概览' : '排程管理工作台' }}
{{ scheduleViewMode === 'overview' ? $t('admin.schedule.overviewTitle') : $t('admin.schedule.workbenchTitle') }}
</h2>
<p class="mt-1.5 text-sm text-slate-500">
{{ scheduleViewMode === 'overview' ? '点击排程卡片进入排程工作台。' : '左侧排程列表,右侧执行记录列表。' }}
{{ scheduleViewMode === 'overview' ? $t('admin.schedule.overviewSubtitle') : $t('admin.schedule.workbenchSubtitle') }}
</p>
</div>
</div>
@@ -4270,7 +4290,7 @@ const handlePermissionImport = async (event: Event) => {
@click="loadSchedules"
>
<RefreshCw class="h-5 w-5" />
刷新排程
{{ $t('admin.schedule.refresh') }}
</button>
</div>
</div>
@@ -4280,37 +4300,37 @@ const handlePermissionImport = async (event: Event) => {
<div class="mb-5 grid grid-cols-1 gap-3 md:grid-cols-2 xl:grid-cols-4">
<div class="rounded-2xl bg-slate-50 px-4 py-3">
<div class="text-xl font-bold text-slate-900">{{ schedules.length }}</div>
<div class="text-sm text-slate-500">排程总数</div>
<div class="text-sm text-slate-500">{{ $t('admin.schedule.stats.total') }}</div>
</div>
<div class="rounded-2xl bg-slate-50 px-4 py-3">
<div class="text-xl font-bold text-slate-900">{{ scheduleEnabledCount }}</div>
<div class="text-sm text-slate-500">启用中</div>
<div class="text-sm text-slate-500">{{ $t('admin.schedule.stats.enabled') }}</div>
</div>
<div class="rounded-2xl bg-slate-50 px-4 py-3">
<div class="text-xl font-bold text-slate-900">{{ scheduleDisabledCount }}</div>
<div class="text-sm text-slate-500">停用中</div>
<div class="text-sm text-slate-500">{{ $t('admin.schedule.stats.disabled') }}</div>
</div>
<div class="rounded-2xl bg-slate-50 px-4 py-3">
<div class="text-xl font-bold text-slate-900">{{ scheduleRunningCount }}</div>
<div class="text-sm text-slate-500">执行中</div>
<div class="text-sm text-slate-500">{{ $t('admin.schedule.stats.running') }}</div>
</div>
</div>
<div class="rounded-2xl border border-slate-200 bg-white p-4">
<div class="mb-3 flex items-center justify-between">
<h4 class="text-lg font-bold text-slate-900">排程管理概览</h4>
<span class="text-xs text-slate-400">按卡片切换</span>
<h4 class="text-lg font-bold text-slate-900">{{ $t('admin.schedule.sectionOverview') }}</h4>
<span class="text-xs text-slate-400">{{ $t('admin.schedule.switchByCard') }}</span>
</div>
<div v-if="scheduleLoading" class="py-8 text-center text-sm text-slate-400">正在加载...</div>
<div v-if="scheduleLoading" class="py-8 text-center text-sm text-slate-400">{{ $t('admin.schedule.loading') }}</div>
<div v-else class="grid grid-cols-1 gap-4 md:grid-cols-2 xl:grid-cols-3 auto-rows-fr">
<div class="rounded-2xl border border-slate-200 bg-white p-4 transition-colors hover:border-brand-300 h-full min-h-[260px] flex flex-col">
<div class="mb-3 flex items-center gap-2">
<div class="flex h-8 w-8 items-center justify-center rounded-xl bg-brand-50 text-brand-600">
<Settings2 class="h-4 w-4" />
</div>
<div class="font-semibold text-slate-900">新增排程</div>
<div class="font-semibold text-slate-900">{{ $t('admin.schedule.addTitle') }}</div>
</div>
<div class="text-sm text-slate-500">
点击按钮后弹窗录入排程字段。
{{ $t('admin.schedule.addHint') }}
</div>
<div class="mt-auto pt-3">
<button
@@ -4318,7 +4338,7 @@ const handlePermissionImport = async (event: Event) => {
class="inline-flex w-full items-center justify-center gap-2 rounded-xl bg-brand-600 px-3 py-2 text-sm font-medium text-white transition-colors hover:bg-brand-700 disabled:cursor-not-allowed disabled:opacity-60"
>
<Plus class="h-4 w-4" />
新增排程
{{ $t('admin.schedule.addButton') }}
</button>
</div>
</div>
@@ -4334,26 +4354,26 @@ const handlePermissionImport = async (event: Event) => {
<div class="truncate text-base font-semibold text-slate-900">{{ s.name }}</div>
<span class="inline-flex shrink-0 items-center whitespace-nowrap rounded-full px-2.5 py-1 text-xs font-semibold"
:class="s.enabled ? 'bg-emerald-100 text-emerald-700' : 'bg-slate-200 text-slate-600'">
{{ s.enabled ? '启用' : '停用' }}
{{ s.enabled ? $t('admin.schedule.enabled') : $t('admin.schedule.disabled') }}
</span>
</div>
<div class="mt-2 text-sm text-slate-500">编号:{{ s.schedule_no }}</div>
<div class="mt-2 text-sm text-slate-500">{{ $t('admin.schedule.scheduleNo') }}:{{ s.schedule_no }}</div>
<div class="mt-1 text-sm text-slate-500">Cron:{{ s.cron_expr }}</div>
<div
v-if="s.schedule_type === 'platform_app' && s.platform_api_path"
class="mt-1 text-sm text-slate-500"
>
配置:{{ s.platform_api_path }}
{{ $t('admin.schedule.config') }}:{{ s.platform_api_path }}
</div>
<div class="mt-1 text-sm text-slate-500">所有者:{{ s.owner_username || s.owner_user_id }}</div>
<div class="mt-1 text-sm text-slate-500">{{ $t('admin.schedule.owner') }}:{{ s.owner_username || s.owner_user_id }}</div>
</div>
</button>
<div class="mt-auto pt-3">
<div class="mb-1 text-sm text-slate-500">
最近执行:{{ formatDateTime(s.last_run_at) }}
{{ $t('admin.schedule.lastRun') }}:{{ formatDateTime(s.last_run_at) }}
</div>
<div class="mb-3 text-sm text-slate-500">
下次执行:{{ formatDateTime(s.next_run_at) }}
{{ $t('admin.schedule.nextRun') }}:{{ formatDateTime(s.next_run_at) }}
</div>
<div class="flex flex-wrap items-center gap-2">
<button
@@ -4361,7 +4381,7 @@ const handlePermissionImport = async (event: Event) => {
@click.stop="openScheduleEditModal(s)"
>
<Edit3 class="h-3.5 w-3.5" />
编辑
{{ $t('admin.schedule.actions.edit') }}
</button>
<button
v-if="!s.enabled"
@@ -4369,7 +4389,7 @@ const handlePermissionImport = async (event: Event) => {
@click.stop="setScheduleEnabled(s.id, true)"
>
<Power class="h-3.5 w-3.5" />
启动
{{ $t('admin.schedule.actions.start') }}
</button>
<button
v-else
@@ -4377,14 +4397,14 @@ const handlePermissionImport = async (event: Event) => {
@click.stop="setScheduleEnabled(s.id, false)"
>
<PowerOff class="h-3.5 w-3.5" />
暂停
{{ $t('admin.schedule.actions.pause') }}
</button>
<button
class="inline-flex items-center gap-1 rounded-xl border border-blue-200 px-3 py-2 text-xs font-medium text-blue-700 transition-colors hover:bg-blue-50"
@click.stop="runScheduleNow(s.id)"
>
<Rocket class="h-3.5 w-3.5" />
执行
{{ $t('admin.schedule.actions.run') }}
</button>
<button
v-if="s.platform_api_path && s.data_source_type !== 'external_api'"
@@ -4392,20 +4412,20 @@ const handlePermissionImport = async (event: Event) => {
@click.stop="openTestRunDialog(s)"
>
<FlaskConical class="h-3.5 w-3.5" />
测试
{{ $t('admin.schedule.actions.test') }}
</button>
<button
class="inline-flex items-center gap-1 rounded-xl border border-rose-200 px-3 py-2 text-xs font-medium text-rose-600 transition-colors hover:bg-rose-50"
@click.stop="deleteSchedule(s)"
>
<Trash2 class="h-3.5 w-3.5" />
删除
{{ $t('admin.schedule.actions.delete') }}
</button>
</div>
</div>
</div>
<div v-if="schedules.length === 0" class="rounded-xl border border-dashed border-slate-200 px-4 py-6 text-center text-sm text-slate-400">
暂无排程,请先创建。
{{ $t('admin.schedule.emptyList') }}
</div>
</div>
</div>
@@ -4416,24 +4436,24 @@ const handlePermissionImport = async (event: Event) => {
<div class="space-y-6">
<div class="grid grid-cols-2 gap-3 rounded-3xl border border-slate-200 bg-white p-4 shadow-sm md:grid-cols-4 xl:grid-cols-7">
<div class="col-span-2 rounded-2xl bg-slate-50 px-4 py-3 xl:col-span-3">
<div class="truncate text-base font-semibold text-slate-900">{{ selectedSchedule?.name || '未选择排程' }}</div>
<div class="mt-1 text-xs text-slate-500">当前选中排程 · 最近执行 {{ selectedScheduleLatestRunAt }}</div>
<div class="truncate text-base font-semibold text-slate-900">{{ selectedSchedule?.name || $t('admin.schedule.noSelection') }}</div>
<div class="mt-1 text-xs text-slate-500">{{ $t('admin.schedule.selectedHint', { time: selectedScheduleLatestRunAt }) }}</div>
</div>
<div class="rounded-2xl bg-slate-50 px-4 py-3 text-center">
<div class="text-base font-semibold text-slate-900">{{ selectedScheduleRuns.length }}</div>
<div class="mt-1 text-xs text-slate-500">执行批次</div>
<div class="mt-1 text-xs text-slate-500">{{ $t('admin.schedule.runBatches') }}</div>
</div>
<div class="rounded-2xl bg-slate-50 px-4 py-3 text-center">
<div class="text-base font-semibold text-slate-900">{{ selectedScheduleRunMetrics.total }}</div>
<div class="mt-1 text-xs text-slate-500">处理总数</div>
<div class="mt-1 text-xs text-slate-500">{{ $t('admin.schedule.totalProcessed') }}</div>
</div>
<div class="rounded-2xl bg-slate-50 px-4 py-3 text-center">
<div class="text-base font-semibold text-emerald-700">{{ selectedScheduleRunMetrics.success }}</div>
<div class="mt-1 text-xs text-slate-500">成功总数</div>
<div class="mt-1 text-xs text-slate-500">{{ $t('admin.schedule.totalSuccess') }}</div>
</div>
<div class="rounded-2xl bg-slate-50 px-4 py-3 text-center">
<div class="text-base font-semibold text-rose-600">{{ selectedScheduleRunMetrics.failed }}</div>
<div class="mt-1 text-xs text-slate-500">失败总数</div>
<div class="mt-1 text-xs text-slate-500">{{ $t('admin.schedule.totalFailed') }}</div>
</div>
</div>
@@ -4441,8 +4461,8 @@ const handlePermissionImport = async (event: Event) => {
<div class="grid grid-cols-1 gap-6 lg:grid-cols-[320px_minmax(0,1fr)]">
<div class="rounded-3xl border border-slate-200 bg-white p-6 shadow-sm">
<div class="mb-4 flex items-center justify-between">
<h4 class="text-lg font-semibold text-slate-900">排程列表</h4>
<span class="text-xs text-slate-400">按卡片切换</span>
<h4 class="text-lg font-semibold text-slate-900">{{ $t('admin.schedule.listTitle') }}</h4>
<span class="text-xs text-slate-400">{{ $t('admin.schedule.switchByCard') }}</span>
</div>
<div class="space-y-3">
<button
@@ -4459,7 +4479,7 @@ const handlePermissionImport = async (event: Event) => {
<div class="mt-2 flex flex-wrap items-center gap-2">
<button
class="inline-flex items-center justify-center rounded-xl border border-slate-200 p-1.5 text-xs font-medium text-slate-600 transition-colors hover:bg-slate-50"
title="编辑"
:title="$t('admin.schedule.actions.edit')"
@click.stop="openScheduleEditModal(s)"
>
<Edit3 class="h-3 w-3" />
@@ -4467,7 +4487,7 @@ const handlePermissionImport = async (event: Event) => {
<button
v-if="!s.enabled"
class="inline-flex items-center justify-center rounded-xl border border-emerald-200 p-1.5 text-xs font-medium text-emerald-700 transition-colors hover:bg-emerald-50"
title="启动"
:title="$t('admin.schedule.actions.start')"
@click.stop="setScheduleEnabled(s.id, true)"
>
<Power class="h-3 w-3" />
@@ -4475,14 +4495,14 @@ const handlePermissionImport = async (event: Event) => {
<button
v-else
class="inline-flex items-center justify-center rounded-xl border border-amber-200 p-1.5 text-xs font-medium text-amber-700 transition-colors hover:bg-amber-50"
title="暂停"
:title="$t('admin.schedule.actions.pause')"
@click.stop="setScheduleEnabled(s.id, false)"
>
<PowerOff class="h-3 w-3" />
</button>
<button
class="inline-flex items-center justify-center rounded-xl border border-blue-200 p-1.5 text-xs font-medium text-blue-700 transition-colors hover:bg-blue-50"
title="执行"
:title="$t('admin.schedule.actions.run')"
@click.stop="runScheduleNow(s.id)"
>
<Rocket class="h-3 w-3" />
@@ -4490,14 +4510,14 @@ const handlePermissionImport = async (event: Event) => {
<button
v-if="s.platform_api_path && s.data_source_type !== 'external_api'"
class="inline-flex items-center justify-center rounded-xl border border-violet-200 p-1.5 text-xs font-medium text-violet-700 transition-colors hover:bg-violet-50"
title="测试"
:title="$t('admin.schedule.actions.test')"
@click.stop="openTestRunDialog(s)"
>
<FlaskConical class="h-3 w-3" />
</button>
<button
class="inline-flex items-center justify-center rounded-xl border border-rose-200 p-1.5 text-xs font-medium text-rose-600 transition-colors hover:bg-rose-50"
title="删除"
:title="$t('admin.schedule.actions.delete')"
@click.stop="deleteSchedule(s)"
>
<Trash2 class="h-3 w-3" />
@@ -4506,7 +4526,7 @@ const handlePermissionImport = async (event: Event) => {
</div>
<span class="inline-flex shrink-0 items-center whitespace-nowrap rounded-full px-2.5 py-1 text-xs font-semibold"
:class="s.enabled ? 'bg-emerald-100 text-emerald-700' : 'bg-slate-200 text-slate-600'">
{{ s.enabled ? '启用' : '停用' }}
{{ s.enabled ? $t('admin.schedule.enabled') : $t('admin.schedule.disabled') }}
</span>
</div>
</button>
@@ -4517,16 +4537,16 @@ const handlePermissionImport = async (event: Event) => {
<div v-if="selectedSchedule" class="rounded-2xl border border-slate-200 bg-white p-4">
<div class="mb-4 flex flex-wrap items-center justify-between gap-3">
<div>
<h3 class="text-lg font-semibold text-slate-900">{{ selectedSchedule.name }} · 执行记录</h3>
<p class="mt-1 text-sm text-slate-500">下方仅展示执行记录明细。</p>
<h3 class="text-lg font-semibold text-slate-900">{{ $t('admin.schedule.recordsTitle', { name: selectedSchedule.name }) }}</h3>
<p class="mt-1 text-sm text-slate-500">{{ $t('admin.schedule.recordsSubtitle') }}</p>
</div>
</div>
<div>
<div class="mb-3 flex flex-wrap items-center gap-2 text-xs">
<label class="text-slate-500">开始</label>
<label class="text-slate-500">{{ $t('admin.schedule.filterStart') }}</label>
<input type="datetime-local" step="1" v-model="scheduleRunStartedAfter" class="!min-w-0 !w-[170px] !py-1 !px-2 !text-xs rounded-lg border border-slate-200" />
<label class="text-slate-500">结束</label>
<label class="text-slate-500">{{ $t('admin.schedule.filterEnd') }}</label>
<input type="datetime-local" step="1" v-model="scheduleRunStartedBefore" class="!min-w-0 !w-[170px] !py-1 !px-2 !text-xs rounded-lg border border-slate-200" />
<select v-model="scheduleRunStatusFilter" class="!min-w-0 !w-[90px] !py-1 !px-2 !text-xs rounded-lg border border-slate-200">
<option v-for="opt in scheduleRunStatusOptions" :key="opt.value" :value="opt.value">
@@ -4537,13 +4557,13 @@ const handlePermissionImport = async (event: Event) => {
class="inline-flex items-center rounded-lg bg-brand-600 px-2.5 py-1 text-xs font-medium text-white hover:bg-brand-700"
@click="viewScheduleRuns(selectedSchedule.id)"
>
查询
{{ $t('admin.schedule.query') }}
</button>
<button
class="inline-flex items-center rounded-lg border border-slate-200 px-2.5 py-1 text-xs font-medium text-slate-700 hover:bg-slate-50"
@click="resetScheduleRunFilters(); viewScheduleRuns(selectedSchedule.id)"
>
重置
{{ $t('admin.schedule.reset') }}
</button>
</div>
<div class="overflow-x-auto rounded-xl border border-slate-100">
@@ -4566,7 +4586,7 @@ const handlePermissionImport = async (event: Event) => {
<span
class="absolute inset-y-0 -right-1 z-10 w-3 cursor-col-resize"
@mousedown.prevent="startScheduleColResize(colIndex, $event)"
:title="`拖拽调整${col.label}列宽`"
:title="$t('admin.schedule.resizeColumn', { label: col.label })"
>
<span class="mx-auto block h-full w-px bg-slate-300"></span>
</span>
@@ -4575,10 +4595,10 @@ const handlePermissionImport = async (event: Event) => {
</thead>
<tbody class="divide-y divide-slate-100">
<tr v-if="scheduleRunsLoading">
<td colspan="10" class="px-4 py-8 text-center text-sm text-slate-400">正在查询记录...</td>
<td colspan="10" class="px-4 py-8 text-center text-sm text-slate-400">{{ $t('admin.schedule.queryingRuns') }}</td>
</tr>
<tr v-else-if="filteredScheduleRuns.length === 0">
<td colspan="10" class="px-4 py-8 text-center text-sm text-slate-400">暂无执行记录。</td>
<td colspan="10" class="px-4 py-8 text-center text-sm text-slate-400">{{ $t('admin.schedule.noRunRecords') }}</td>
</tr>
<tr
v-else
@@ -4602,9 +4622,9 @@ const handlePermissionImport = async (event: Event) => {
<td class="truncate px-4 py-2.5">
<span v-if="r.wecom_notified" class="inline-flex items-center gap-1 text-xs text-emerald-600">
<svg class="h-3.5 w-3.5" fill="none" viewBox="0 0 24 24" stroke="currentColor"><path stroke-linecap="round" stroke-linejoin="round" stroke-width="2" d="M5 13l4 4L19 7" /></svg>
已通知
{{ $t('admin.schedule.notified') }}
</span>
<span v-else-if="r.wecom_notify_error" class="text-xs text-amber-500" :title="r.wecom_notify_error">异常</span>
<span v-else-if="r.wecom_notify_error" class="text-xs text-amber-500" :title="r.wecom_notify_error">{{ $t('admin.schedule.notifyError') }}</span>
<span v-else class="text-xs text-slate-300">-</span>
</td>
<td class="px-4 py-2.5">
@@ -4616,7 +4636,7 @@ const handlePermissionImport = async (event: Event) => {
class="inline-flex items-center gap-1 rounded-lg border border-slate-200 px-2 py-1 text-xs font-medium text-slate-600 transition-colors hover:bg-slate-50"
>
<Download class="h-3 w-3" />
下载
{{ $t('admin.schedule.download') }}
</a>
<span v-if="r.total_count === 0" class="text-slate-300">-</span>
</div>
@@ -4629,7 +4649,7 @@ const handlePermissionImport = async (event: Event) => {
class="inline-flex items-center gap-1 rounded-lg border border-blue-200 px-2 py-1 text-xs font-medium text-blue-600 transition-colors hover:bg-blue-50"
>
<Eye class="h-3 w-3" />
日志
{{ $t('admin.schedule.log') }}
<ChevronDown v-if="expandedScheduleRunId !== r.id" class="h-3 w-3" />
<ChevronUp v-else class="h-3 w-3" />
</button>
@@ -4644,8 +4664,8 @@ const handlePermissionImport = async (event: Event) => {
<td colspan="10" class="px-4 py-3 bg-slate-50/60">
<div class="space-y-2">
<div class="flex items-center justify-between mb-2">
<h5 class="text-xs font-bold text-slate-600 uppercase">执行日志</h5>
<span class="text-xs text-slate-400">共 {{ filteredScheduleRuns.find(x => x.id === expandedScheduleRunId)?.step_logs?.length || 0 }} 步</span>
<h5 class="text-xs font-bold text-slate-600 uppercase">{{ $t('admin.schedule.runLogs') }}</h5>
<span class="text-xs text-slate-400">{{ $t('admin.schedule.stepsCount', { count: filteredScheduleRuns.find(x => x.id === expandedScheduleRunId)?.step_logs?.length || 0 }) }}</span>
</div>
<div
v-for="(log, li) in filteredScheduleRuns.find(x => x.id === expandedScheduleRunId)?.step_logs || []"
@@ -4663,7 +4683,7 @@ const handlePermissionImport = async (event: Event) => {
<span v-if="log.duration_ms != null" class="text-[10px] text-slate-400">{{ log.duration_ms }}ms</span>
</div>
<details v-if="log.detail" class="mt-1">
<summary class="cursor-pointer text-[10px] font-semibold text-slate-500 hover:text-slate-700">查看详情</summary>
<summary class="cursor-pointer text-[10px] font-semibold text-slate-500 hover:text-slate-700">{{ $t('admin.schedule.viewDetail') }}</summary>
<pre class="mt-1 whitespace-pre-wrap rounded-lg bg-slate-800 p-2 text-[10px] text-slate-200 font-mono max-h-[200px] overflow-auto">{{ JSON.stringify(log.detail, null, 2) }}</pre>
</details>
</div>
@@ -4676,7 +4696,7 @@ const handlePermissionImport = async (event: Event) => {
</div>
</div>
<div v-else class="rounded-2xl border border-dashed border-slate-200 bg-white px-4 py-10 text-center text-sm text-slate-400">
未选择排程,请先在左侧列表选择一个排程。
{{ $t('admin.schedule.noSelectionHint') }}
</div>
</div>
</div>
@@ -5619,10 +5639,10 @@ const handlePermissionImport = async (event: Event) => {
<div class="w-full max-w-4xl max-h-[90vh] overflow-y-auto rounded-3xl bg-white shadow-2xl">
<div class="sticky top-0 z-10 flex items-center justify-between border-b border-slate-100 bg-white px-6 py-4 rounded-t-3xl">
<div>
<h3 class="text-lg font-bold text-slate-900">测试执行 — {{ testRunSchedule?.name }}</h3>
<p class="text-xs text-slate-500 mt-0.5">编辑 WHERE 条件,限制行数,快速执行并查看每步结果</p>
<h3 class="text-lg font-bold text-slate-900">{{ $t('admin.schedule.testRun.title', { name: testRunSchedule?.name }) }}</h3>
<p class="text-xs text-slate-500 mt-0.5">{{ $t('admin.schedule.testRun.subtitle') }}</p>
</div>
<button @click="showTestRunDialog = false" class="rounded-xl border border-slate-200 px-3 py-1.5 text-sm text-slate-500 hover:bg-slate-50">关闭</button>
<button @click="showTestRunDialog = false" class="rounded-xl border border-slate-200 px-3 py-1.5 text-sm text-slate-500 hover:bg-slate-50">{{ $t('admin.schedule.testRun.close') }}</button>
</div>
<div class="p-6 space-y-4">
<div>
@@ -5655,36 +5675,36 @@ const handlePermissionImport = async (event: Event) => {
:disabled="testRunLoading"
@click="handleTestRun"
>
{{ testRunLoading ? '执行中...' : '开始测试执行' }}
{{ testRunLoading ? $t('admin.schedule.testRun.running') : $t('admin.schedule.testRun.start') }}
</button>
<span v-if="testRunLoading" class="text-xs text-slate-400">Dify 调用可能需要较长时间,请耐心等待...</span>
<span v-if="testRunLoading" class="text-xs text-slate-400">{{ $t('admin.schedule.testRun.waitingHint') }}</span>
</div>
<div v-if="testRunResult" class="space-y-4 mt-2">
<div class="flex items-center gap-4 rounded-xl border border-slate-200 bg-slate-50/50 px-4 py-3">
<div class="text-center">
<div class="text-lg font-bold text-slate-900">{{ testRunResult.total_count }}</div>
<div class="text-[10px] text-slate-500">总处理</div>
<div class="text-[10px] text-slate-500">{{ $t('admin.schedule.testRun.total') }}</div>
</div>
<div class="text-center">
<div class="text-lg font-bold text-emerald-600">{{ testRunResult.success_count }}</div>
<div class="text-[10px] text-slate-500">成功</div>
<div class="text-[10px] text-slate-500">{{ $t('admin.schedule.testRun.success') }}</div>
</div>
<div class="text-center">
<div class="text-lg font-bold text-rose-600">{{ testRunResult.failed_count }}</div>
<div class="text-[10px] text-slate-500">失败</div>
<div class="text-[10px] text-slate-500">{{ $t('admin.schedule.testRun.failed') }}</div>
</div>
<div class="text-center">
<div class="text-lg font-bold text-amber-600">{{ testRunResult.skipped_count }}</div>
<div class="text-[10px] text-slate-500">跳过</div>
<div class="text-[10px] text-slate-500">{{ $t('admin.schedule.testRun.skipped') }}</div>
</div>
<div class="ml-auto text-xs text-slate-400">
限制 {{ testRunResult.limit }} 条 | Dify Agent ID: {{ testRunResult.dify_agent_id || '无' }}
{{ $t('admin.schedule.testRun.limitSummary', { limit: testRunResult.limit, agentId: testRunResult.dify_agent_id || $t('admin.schedule.testRun.noAgent') }) }}
</div>
</div>
<div>
<h4 class="text-sm font-bold text-slate-700 mb-2">步骤日志</h4>
<h4 class="text-sm font-bold text-slate-700 mb-2">{{ $t('admin.schedule.testRun.stepLogs') }}</h4>
<div class="space-y-2">
<div
v-for="(log, li) in testRunResult.step_logs"
@@ -5702,7 +5722,7 @@ const handlePermissionImport = async (event: Event) => {
<span v-if="log.duration_ms != null" class="text-[10px] text-slate-400">{{ log.duration_ms }}ms</span>
</div>
<details v-if="log.detail" class="mt-1">
<summary class="cursor-pointer text-[10px] font-semibold text-slate-500 hover:text-slate-700">查看详情</summary>
<summary class="cursor-pointer text-[10px] font-semibold text-slate-500 hover:text-slate-700">{{ $t('admin.schedule.viewDetail') }}</summary>
<pre class="mt-1 whitespace-pre-wrap rounded-lg bg-slate-800 p-2 text-[10px] text-slate-200 font-mono max-h-[200px] overflow-auto">{{ JSON.stringify(log.detail, null, 2) }}</pre>
</details>
</div>
@@ -5710,12 +5730,12 @@ const handlePermissionImport = async (event: Event) => {
</div>
<details>
<summary class="cursor-pointer text-xs font-semibold text-slate-500 hover:text-slate-700">查看执行 SQL</summary>
<summary class="cursor-pointer text-xs font-semibold text-slate-500 hover:text-slate-700">{{ $t('admin.schedule.testRun.viewSql') }}</summary>
<pre class="mt-1 whitespace-pre-wrap rounded-lg bg-slate-800 p-3 text-xs text-emerald-300 font-mono">{{ testRunResult.sql }}</pre>
</details>
<details v-if="testRunResult.errors && testRunResult.errors.length > 0">
<summary class="cursor-pointer text-xs font-semibold text-rose-600 hover:text-rose-800">错误信息 ({{ testRunResult.errors.length }})</summary>
<summary class="cursor-pointer text-xs font-semibold text-rose-600 hover:text-rose-800">{{ $t('admin.schedule.testRun.errors', { count: testRunResult.errors.length }) }}</summary>
<pre class="mt-1 whitespace-pre-wrap rounded-lg bg-rose-50 p-3 text-xs text-rose-700 font-mono">{{ testRunResult.errors.join('\n') }}</pre>
</details>
</div>
@@ -5727,7 +5747,7 @@ const handlePermissionImport = async (event: Event) => {
<div v-if="showScheduleCreateModal" class="fixed inset-0 z-50 flex items-center justify-center bg-black/50 backdrop-blur-sm p-4">
<div class="w-full max-w-3xl rounded-3xl bg-white shadow-2xl">
<div class="flex items-center justify-between border-b border-slate-100 px-8 py-6">
<h3 class="text-2xl font-bold tracking-tight text-slate-900">{{ scheduleEditingId ? '编辑排程' : '新增排程' }}</h3>
<h3 class="text-2xl font-bold tracking-tight text-slate-900">{{ scheduleEditingId ? $t('admin.schedule.form.editTitle') : $t('admin.schedule.form.createTitle') }}</h3>
<button
class="rounded-full p-2 text-slate-400 transition hover:bg-slate-100 hover:text-slate-600"
@click="showScheduleCreateModal = false"
@@ -5738,14 +5758,14 @@ const handlePermissionImport = async (event: Event) => {
<div class="max-h-[72vh] space-y-5 overflow-y-auto px-8 py-6">
<div class="grid grid-cols-1 gap-4 md:grid-cols-2">
<div>
<label class="mb-2 block text-sm font-medium text-slate-600">排程名称</label>
<input v-model="scheduleCreateForm.name" class="input-field !text-sm !leading-5" placeholder="例如:RoHS 自动审核排程" />
<label class="mb-2 block text-sm font-medium text-slate-600">{{ $t('admin.schedule.form.name') }}</label>
<input v-model="scheduleCreateForm.name" class="input-field !text-sm !leading-5" :placeholder="$t('admin.schedule.form.namePlaceholder')" />
</div>
<div>
<label class="mb-2 block text-sm font-medium text-slate-600">排程所有者</label>
<label class="mb-2 block text-sm font-medium text-slate-600">{{ $t('admin.schedule.form.owner') }}</label>
<div class="relative">
<select v-model="scheduleCreateForm.owner_user_id" class="input-field appearance-none pr-10 !text-sm !leading-5" :disabled="users.length === 0">
<option :value="null">{{ users.length === 0 ? '暂无可用用户' : '请选择所有者' }}</option>
<option :value="null">{{ users.length === 0 ? $t('admin.schedule.form.noUsers') : $t('admin.schedule.form.selectOwner') }}</option>
<option v-for="u in users" :key="u.id" :value="u.id">{{ u.real_name || u.username }}{{ u.employee_id ? '(' + u.employee_id + ')' : '' }}</option>
</select>
<div class="pointer-events-none absolute inset-y-0 right-0 flex items-center pr-3">
@@ -5757,26 +5777,26 @@ const handlePermissionImport = async (event: Event) => {
<!-- SQL Config Panel -->
<div class="rounded-2xl border border-slate-200 bg-slate-50/40 p-4">
<div class="mb-3 flex items-center justify-between gap-3">
<h4 class="text-base font-bold text-slate-900">数据源与执行配置</h4>
<h4 class="text-base font-bold text-slate-900">{{ $t('admin.schedule.form.dataSourceConfig') }}</h4>
<div class="flex items-center gap-2">
<div class="flex rounded-xl border border-slate-200 overflow-hidden">
<button
class="px-3 py-1.5 text-xs font-semibold transition"
:class="scheduleCreateForm.data_source_type === 'database' ? 'bg-blue-600 text-white' : 'bg-white text-slate-600 hover:bg-slate-50'"
@click="scheduleCreateForm.data_source_type = 'database'"
>数据库直联</button>
>{{ $t('admin.schedule.form.databaseDirect') }}</button>
<button
class="px-3 py-1.5 text-xs font-semibold transition"
:class="scheduleCreateForm.data_source_type === 'external_api' ? 'bg-blue-600 text-white' : 'bg-white text-slate-600 hover:bg-slate-50'"
@click="scheduleCreateForm.data_source_type = 'external_api'"
>外部API</button>
>{{ $t('admin.schedule.form.externalApi') }}</button>
</div>
<button
class="inline-flex items-center gap-1.5 rounded-xl border border-amber-300 bg-amber-50 px-3 py-1.5 text-xs font-semibold text-amber-700 transition hover:bg-amber-100 disabled:cursor-not-allowed disabled:opacity-60"
:disabled="scheduleTestLoading || !scheduleEditingId"
@click="handleTestScheduleSql"
>
{{ scheduleTestLoading ? '查询中...' : '测试查询' }}
{{ scheduleTestLoading ? $t('admin.schedule.form.querying') : $t('admin.schedule.form.testQuery') }}
</button>
<button
class="inline-flex items-center gap-1.5 rounded-xl border border-slate-200 bg-white px-3 py-1.5 text-xs font-semibold text-slate-600 transition hover:bg-slate-50"
@@ -5784,7 +5804,7 @@ const handlePermissionImport = async (event: Event) => {
>
<ChevronDown v-if="scheduleConfigCollapsed" class="h-3.5 w-3.5" />
<ChevronUp v-else class="h-3.5 w-3.5" />
{{ scheduleConfigCollapsed ? '展开配置' : '收起配置' }}
{{ scheduleConfigCollapsed ? $t('admin.schedule.form.expandConfig') : $t('admin.schedule.form.collapseConfig') }}
</button>
</div>
</div>
@@ -5793,7 +5813,7 @@ const handlePermissionImport = async (event: Event) => {
<template v-if="scheduleCreateForm.data_source_type === 'database'">
<!-- 数据源配置 -->
<details class="rounded-xl border border-slate-200 bg-white" open>
<summary class="cursor-pointer px-4 py-2.5 text-sm font-semibold text-slate-700 hover:bg-slate-50 rounded-xl">数据源配置</summary>
<summary class="cursor-pointer px-4 py-2.5 text-sm font-semibold text-slate-700 hover:bg-slate-50 rounded-xl">{{ $t('admin.schedule.form.dataSourceSection') }}</summary>
<div class="space-y-3 px-4 pb-4 pt-2">
<div class="grid grid-cols-2 gap-3">
<div>
@@ -5952,9 +5972,9 @@ const handlePermissionImport = async (event: Event) => {
<div v-if="scheduleTestResult" class="mt-4 rounded-2xl border border-emerald-200 bg-emerald-50/40 p-4">
<div class="mb-3 flex items-center justify-between">
<h4 class="text-sm font-bold text-emerald-900">查询结果</h4>
<h4 class="text-sm font-bold text-emerald-900">{{ $t('admin.schedule.testRun.queryResult') }}</h4>
<div class="flex items-center gap-3">
<span class="text-xs text-emerald-600">共 {{ scheduleTestResult.total }} 条,展示 {{ scheduleTestResult.showing }} 条</span>
<span class="text-xs text-emerald-600">{{ $t('admin.schedule.testRun.resultSummary', { total: scheduleTestResult.total, showing: scheduleTestResult.showing }) }}</span>
<button class="rounded-full p-1 text-emerald-400 transition hover:bg-emerald-100 hover:text-emerald-600" @click="scheduleTestResult = null">✕</button>
</div>
</div>
@@ -5973,7 +5993,7 @@ const handlePermissionImport = async (event: Event) => {
</table>
</div>
<details class="mt-2">
<summary class="cursor-pointer text-xs font-semibold text-emerald-700 hover:text-emerald-900">查看生成 SQL</summary>
<summary class="cursor-pointer text-xs font-semibold text-emerald-700 hover:text-emerald-900">{{ $t('admin.schedule.testRun.viewGeneratedSql') }}</summary>
<pre class="mt-1 whitespace-pre-wrap rounded-lg bg-slate-800 p-3 text-xs text-emerald-300 font-mono">{{ scheduleTestResult.sql }}</pre>
</details>
</div>
@@ -5984,7 +6004,7 @@ const handlePermissionImport = async (event: Event) => {
<label class="mb-2 block text-sm font-medium text-slate-600">Agent</label>
<div class="relative">
<select v-model="scheduleCreateForm.dify_agent_id" class="input-field appearance-none pr-10 !text-sm !leading-5" :disabled="agents.length === 0">
<option :value="null">{{ agents.length === 0 ? '暂无可用 Agent' : '不启用' }}</option>
<option :value="null">{{ agents.length === 0 ? $t('admin.schedule.form.noAgents') : $t('admin.schedule.form.agentDisabled') }}</option>
<option v-for="a in agents" :key="a.id" :value="a.id">{{ a.name }}(ID: {{ a.dify_app_id?.slice(0, 8) || a.id }})</option>
</select>
<div class="pointer-events-none absolute inset-y-0 right-0 flex items-center pr-3">
@@ -5993,15 +6013,15 @@ const handlePermissionImport = async (event: Event) => {
</div>
</div>
<div>
<label class="mb-2 block text-sm font-medium text-slate-600">等待时间(秒)</label>
<label class="mb-2 block text-sm font-medium text-slate-600">{{ $t('admin.schedule.form.waitSeconds') }}</label>
<input v-model.number="scheduleCreateForm.wait_seconds" type="number" min="0" class="input-field !text-sm !leading-5" placeholder="300" />
</div>
</div>
<div class="rounded-2xl border border-slate-200 bg-slate-50/40 p-4">
<div class="mb-3">
<h4 class="text-base font-bold text-slate-900">Cron 图形化设置</h4>
<p class="text-sm text-slate-500">选择执行频率后自动生成 Cron 表达式。</p>
<h4 class="text-base font-bold text-slate-900">{{ $t('admin.schedule.form.cronTitle') }}</h4>
<p class="text-sm text-slate-500">{{ $t('admin.schedule.form.cronHint') }}</p>
</div>
<div class="grid grid-cols-1 gap-3 md:grid-cols-4">
<button
@@ -6009,74 +6029,74 @@ const handlePermissionImport = async (event: Event) => {
:class="scheduleCronDesigner.mode === 'every_minutes' ? 'border-blue-300 bg-blue-50 text-blue-700' : 'border-slate-200 bg-white text-slate-600'"
@click="scheduleCronDesigner.mode = 'every_minutes'"
>
每隔分钟
{{ $t('admin.schedule.form.everyMinutes') }}
</button>
<button
class="rounded-xl border px-3 py-2 text-xs font-semibold transition"
:class="scheduleCronDesigner.mode === 'hourly' ? 'border-blue-300 bg-blue-50 text-blue-700' : 'border-slate-200 bg-white text-slate-600'"
@click="scheduleCronDesigner.mode = 'hourly'"
>
每小时
{{ $t('admin.schedule.form.hourly') }}
</button>
<button
class="rounded-xl border px-3 py-2 text-xs font-semibold transition"
:class="scheduleCronDesigner.mode === 'daily' ? 'border-blue-300 bg-blue-50 text-blue-700' : 'border-slate-200 bg-white text-slate-600'"
@click="scheduleCronDesigner.mode = 'daily'"
>
每天
{{ $t('admin.schedule.form.daily') }}
</button>
<button
class="rounded-xl border px-3 py-2 text-xs font-semibold transition"
:class="scheduleCronDesigner.mode === 'weekly' ? 'border-blue-300 bg-blue-50 text-blue-700' : 'border-slate-200 bg-white text-slate-600'"
@click="scheduleCronDesigner.mode = 'weekly'"
>
每周
{{ $t('admin.schedule.form.weekly') }}
</button>
</div>
<div class="mt-4 grid grid-cols-1 gap-3 md:grid-cols-3">
<template v-if="scheduleCronDesigner.mode === 'every_minutes'">
<div>
<label class="mb-1 block text-xs font-semibold text-slate-500 uppercase">分钟间隔</label>
<label class="mb-1 block text-xs font-semibold text-slate-500 uppercase">{{ $t('admin.schedule.form.minuteInterval') }}</label>
<input v-model.number="scheduleCronDesigner.every_minutes" type="number" min="1" max="59" class="input-field !text-sm !leading-5" />
</div>
</template>
<template v-else-if="scheduleCronDesigner.mode === 'hourly'">
<div>
<label class="mb-1 block text-xs font-semibold text-slate-500 uppercase">每小时第几分钟</label>
<label class="mb-1 block text-xs font-semibold text-slate-500 uppercase">{{ $t('admin.schedule.form.minuteOfHour') }}</label>
<input v-model.number="scheduleCronDesigner.hourly_minute" type="number" min="0" max="59" class="input-field !text-sm !leading-5" />
</div>
</template>
<template v-else-if="scheduleCronDesigner.mode === 'daily'">
<div>
<label class="mb-1 block text-xs font-semibold text-slate-500 uppercase">小时</label>
<label class="mb-1 block text-xs font-semibold text-slate-500 uppercase">{{ $t('admin.schedule.form.hour') }}</label>
<input v-model.number="scheduleCronDesigner.daily_hour" type="number" min="0" max="23" class="input-field !text-sm !leading-5" />
</div>
<div>
<label class="mb-1 block text-xs font-semibold text-slate-500 uppercase">分钟</label>
<label class="mb-1 block text-xs font-semibold text-slate-500 uppercase">{{ $t('admin.schedule.form.minute') }}</label>
<input v-model.number="scheduleCronDesigner.daily_minute" type="number" min="0" max="59" class="input-field !text-sm !leading-5" />
</div>
</template>
<template v-else>
<div>
<label class="mb-1 block text-xs font-semibold text-slate-500 uppercase">星期</label>
<label class="mb-1 block text-xs font-semibold text-slate-500 uppercase">{{ $t('admin.schedule.form.weekday') }}</label>
<select v-model.number="scheduleCronDesigner.weekly_day" class="input-field !text-sm !leading-5">
<option v-for="d in weeklyDayOptions" :key="d.value" :value="d.value">{{ d.label }}</option>
</select>
</div>
<div>
<label class="mb-1 block text-xs font-semibold text-slate-500 uppercase">小时</label>
<label class="mb-1 block text-xs font-semibold text-slate-500 uppercase">{{ $t('admin.schedule.form.hour') }}</label>
<input v-model.number="scheduleCronDesigner.weekly_hour" type="number" min="0" max="23" class="input-field !text-sm !leading-5" />
</div>
<div>
<label class="mb-1 block text-xs font-semibold text-slate-500 uppercase">分钟</label>
<label class="mb-1 block text-xs font-semibold text-slate-500 uppercase">{{ $t('admin.schedule.form.minute') }}</label>
<input v-model.number="scheduleCronDesigner.weekly_minute" type="number" min="0" max="59" class="input-field !text-sm !leading-5" />
</div>
</template>
</div>
<div class="mt-4 rounded-xl border border-dashed border-slate-300 bg-white px-4 py-3 text-xs text-slate-600">
Cron 预览:<span class="font-mono text-slate-900">{{ scheduleCronPreview }}</span>
<span v-if="scheduleNextRunPreview" class="ml-4">下次执行:<span class="font-medium text-slate-900">{{ formatDateTime(scheduleNextRunPreview.toISOString()) }}</span></span>
{{ $t('admin.schedule.form.cronPreview') }}:<span class="font-mono text-slate-900">{{ scheduleCronPreview }}</span>
<span v-if="scheduleNextRunPreview" class="ml-4">{{ $t('admin.schedule.form.nextRun') }}:<span class="font-medium text-slate-900">{{ formatDateTime(scheduleNextRunPreview.toISOString()) }}</span></span>
</div>
</div>
@@ -6084,7 +6104,7 @@ const handlePermissionImport = async (event: Event) => {
<div class="flex flex-col gap-2 md:flex-row md:items-center">
<label class="inline-flex shrink-0 items-center gap-2 text-sm text-slate-700">
<input v-model="scheduleCreateForm.notify_enabled" type="checkbox" class="h-4 w-4 rounded text-blue-600" />
启用通知
{{ $t('admin.schedule.form.notifyEnabled') }}
</label>
<div v-if="scheduleCreateForm.notify_enabled" class="relative flex-1">
<div
@@ -6104,7 +6124,7 @@ const handlePermissionImport = async (event: Event) => {
>✕</button>
</span>
</template>
<span v-else class="text-slate-400">选择通知人员...</span>
<span v-else class="text-slate-400">{{ $t('admin.schedule.form.selectNotifyUsers') }}</span>
</div>
<div
v-if="scheduleNotifyDropdownOpen"
@@ -6136,14 +6156,14 @@ const handlePermissionImport = async (event: Event) => {
<div class="flex items-center justify-between gap-3 border-t border-slate-100 px-8 py-5">
<label class="inline-flex items-center gap-2 rounded-xl border border-slate-200 bg-white px-3 py-2 text-sm text-slate-700">
<input v-model="scheduleCreateForm.enabled" type="checkbox" class="h-4 w-4 rounded text-blue-600" />
创建后启用
{{ $t('admin.schedule.form.enableOnCreate') }}
</label>
<div class="flex items-center gap-3">
<button
class="rounded-2xl border border-slate-200 px-6 py-2.5 text-sm text-slate-600 hover:bg-slate-50"
@click="showScheduleCreateModal = false"
>
取消
{{ $t('admin.schedule.form.cancel') }}
</button>
<button
class="inline-flex items-center gap-2 rounded-2xl bg-blue-600 px-6 py-2.5 text-sm font-semibold text-white hover:bg-blue-700 disabled:cursor-not-allowed disabled:opacity-60"
@@ -6151,7 +6171,7 @@ const handlePermissionImport = async (event: Event) => {
@click="createSchedule"
>
<Plus class="h-4 w-4" />
{{ scheduleCreateSaving ? '保存中...' : (scheduleEditingId ? '保存修改' : '创建排程') }}
{{ scheduleCreateSaving ? $t('admin.schedule.form.saving') : (scheduleEditingId ? $t('admin.schedule.form.saveChanges') : $t('admin.schedule.form.createSchedule')) }}
</button>
</div>
</div>
+9 -9
View File
@@ -13,7 +13,7 @@
import { ref, onMounted, onBeforeUnmount, computed, watch, nextTick } from 'vue';
import { useI18n } from 'vue-i18n';
import { useChat } from '../composables/useChat';
import { Send, Loader2, Plus, Copy, Edit2, RotateCw, Check, X, PanelLeftClose, PanelLeftOpen, Mail, Settings, ChevronDown, Sparkles, Database, Mic, LogOut, MessageSquareText, Globe, ExternalLink, Search, LayoutGrid, History, Sun, Moon } from 'lucide-vue-next';
import { Send, Loader2, Plus, Copy, Edit2, RotateCw, Check, X, PanelLeftClose, PanelLeftOpen, ChevronDown, Sparkles, Database, Mic, LogOut, MessageSquareText, Globe, ExternalLink, Search, LayoutGrid, Briefcase, History, Sun, Moon } from 'lucide-vue-next';
import { marked } from 'marked';
import { useRoute, useRouter } from 'vue-router';
import { config } from '../config';
@@ -1848,8 +1848,8 @@ const showChatRating = ref(false);
<div class="flex h-8 w-8 items-center justify-center rounded-full bg-brand-600 text-sm font-bold text-white shadow-sm shadow-brand-500/20">
{{ (currentUser?.username || 'I').charAt(0).toUpperCase() }}
</div>
<button @click="showGeneralFeedbackDialog = true" class="transition-colors hover:text-slate-600 dark:hover:text-slate-200" :title="$t('chat.generalFeedback')"><Mail class="h-5 w-5" /></button>
<button @click="router.push('/workspace?no_redirect=1')" class="transition-colors hover:text-slate-600 dark:hover:text-slate-200"><Settings class="h-5 w-5" /></button>
<button @click="showGeneralFeedbackDialog = true" class="transition-colors hover:text-slate-600 dark:hover:text-slate-200" :title="$t('chat.generalFeedback')"><MessageSquareText class="h-5 w-5" /></button>
<button @click="router.push('/workspace?no_redirect=1')" class="transition-colors hover:text-slate-600 dark:hover:text-slate-200" :title="$t('workspace.title')"><Briefcase class="h-5 w-5" /></button>
</div>
</div>
</template>
@@ -1945,9 +1945,9 @@ const showChatRating = ref(false);
</div>
</div>
<div class="px-4 pt-3 pb-1 text-xs font-medium text-slate-500 dark:text-slate-400">{{ $t('chat.language') }}</div>
<div class="px-4 pb-2">
<select v-model="locale" class="w-full rounded-xl border border-slate-200 bg-white px-3 py-2 text-sm text-slate-700 outline-none transition focus:border-brand-400 dark:border-slate-700 dark:bg-slate-900 dark:text-slate-200">
<div class="flex items-center gap-2 px-4 py-2">
<span class="shrink-0 text-xs font-medium text-slate-500 dark:text-slate-400">{{ $t('chat.language') }}</span>
<select v-model="locale" class="min-w-0 flex-1 rounded-lg border border-slate-200 bg-slate-50 px-2 py-1 text-xs text-slate-700 outline-none transition focus:border-brand-400 dark:border-slate-600 dark:bg-slate-800 dark:text-slate-200">
<option value="zh-CN">简体中文</option>
<option value="en">English</option>
<option value="zh-TW">繁體中文</option>
@@ -1955,7 +1955,7 @@ const showChatRating = ref(false);
</select>
</div>
<button @click="handleLogout" class="w-full text-left px-4 py-2 text-sm text-red-600 hover:bg-red-50 flex items-center gap-2 transition-colors mt-1">
<button @click="handleLogout" class="flex w-full items-center gap-2 border-t border-slate-50 px-4 py-2 text-left text-sm text-red-600 transition-colors hover:bg-red-50 dark:border-slate-700/50 dark:hover:bg-red-950/30">
<LogOut class="w-4 h-4" />
{{ $t('chat.logout') }}
</button>
@@ -1969,8 +1969,8 @@ const showChatRating = ref(false);
<Sun v-if="appliedTheme === 'dark'" class="h-4 w-4" />
<Moon v-else class="h-4 w-4" />
</button>
<button @click="showGeneralFeedbackDialog = true" class="transition-colors hover:text-slate-600 dark:hover:text-slate-200" :title="$t('chat.generalFeedback')"><Mail class="h-4 w-4" /></button>
<button @click="router.push('/workspace?no_redirect=1')" class="transition-colors hover:text-slate-600 dark:hover:text-slate-200"><Settings class="h-4 w-4" /></button>
<button @click="showGeneralFeedbackDialog = true" class="transition-colors hover:text-slate-600 dark:hover:text-slate-200" :title="$t('chat.generalFeedback')"><MessageSquareText class="h-4 w-4" /></button>
<button @click="router.push('/workspace?no_redirect=1')" class="transition-colors hover:text-slate-600 dark:hover:text-slate-200" :title="$t('workspace.title')"><Briefcase class="h-4 w-4" /></button>
</div>
</div>
</div>