feat(in-transit-transfer): 落地证据流重解析并纳入货代与排程配套改动
外部单号进入异动档自然键,圈档按 T-2 成熟封顶,当前归档可单独重解析。同批带上 Crane 禁整页刷新、ODM 白名单降级、排程抽屉与执行记录日期窗,以及 YAML 库存源下线。 Co-authored-by: Cursor <cursoragent@cursor.com>
This commit is contained in:
1 parent
911afa0f73
commit
4c2a7e2a23
145 files changed
+11695
-4214
No files matched your search
@@ -232,6 +232,7 @@
|
||||
<label><span>{{ t('admin.freightRpa.reportGroup') }}</span><el-input v-model="outboundConfig.report_path_json.report_group" required /></label>
|
||||
<label><span>{{ t('admin.freightRpa.reportName') }}</span><el-input v-model="outboundConfig.report_path_json.report_name" required /></label>
|
||||
<div class="subsection full">{{ t('admin.freightRpa.queryParameters') }}</div>
|
||||
<p class="section-hint full">{{ t('admin.freightRpa.outboundQueryParametersHint') }}</p>
|
||||
<div v-for="(parameter, index) in outboundConfig.query_parameters_json" :key="`outbound-${index}-${parameter.name}`" class="parameter-row full">
|
||||
<el-input v-model="parameter.name" :placeholder="t('admin.freightRpa.parameterName')" />
|
||||
<el-select v-model="parameter.mode"><el-option value="single" :label="t('admin.freightRpa.single')" /><el-option value="multi_text" :label="t('admin.freightRpa.multiText')" /><el-option value="multi_select" :label="t('admin.freightRpa.multiSelect')" /></el-select>
|
||||
|
||||
@@ -20,6 +20,7 @@ const BACKEND_MOVEMENT_FIELD_CODES = [
|
||||
'doc_no', 'line_no', 'in_out_flag', 'material_code', 'material_name',
|
||||
'warehouse_code', 'storage_code', 'lot_no', 'quantity', 'movement_date', 'unit',
|
||||
'line_seq', 'specification', 'order_type', 'odm_id', 'odm_name', 'carton_id', 'pallet_id',
|
||||
'external_doc_no', 'external_line_no',
|
||||
] as const;
|
||||
|
||||
const LABEL_MAPS: Record<string, Record<string, string>> = {
|
||||
|
||||
@@ -1,23 +1,34 @@
|
||||
/**
|
||||
* features/admin/modules/schedules/SchedulesPage.vue
|
||||
* 定时任务管理独立页面壳层。路由:/admin/schedules
|
||||
* 依赖:useSchedulesAdmin、schedules.context、子 panel/overlays 组件。
|
||||
* 逻辑:reactive + provide admin 上下文;onMounted 加载列表。
|
||||
* 用途:定时任务管理独立页面壳层。路由:/admin/schedules
|
||||
* 依赖:useSchedulesAdmin、schedules.context、Element Plus、子 panel/overlays。
|
||||
* 逻辑:reactive + provide admin;ElConfigProvider 包裹 admin-table-section;概览/工作台切换。
|
||||
*/
|
||||
<script setup lang="ts">
|
||||
import { onMounted, provide, reactive } from 'vue';
|
||||
import { ElConfigProvider } from 'element-plus';
|
||||
import 'element-plus/dist/index.css';
|
||||
import 'element-plus/theme-chalk/dark/css-vars.css';
|
||||
import '@/features/admin/styles/element-trial.css';
|
||||
import { useElementProvider } from '@/features/admin/composables/useElementProvider';
|
||||
import { useSchedulesAdmin } from './composables/useSchedulesAdmin';
|
||||
import { SCHEDULES_ADMIN_KEY, SCHEDULE_CREATE_MODAL_OPEN_KEY, type SchedulesAdminContextProvided } from './composables/schedules.context';
|
||||
import {
|
||||
SCHEDULES_ADMIN_KEY,
|
||||
SCHEDULE_CREATE_MODAL_OPEN_KEY,
|
||||
type SchedulesAdminContextProvided,
|
||||
} from './composables/schedules.context';
|
||||
import SchedulePageHeader from './components/SchedulePageHeader.vue';
|
||||
import ScheduleOverviewPanel from './components/ScheduleOverviewPanel.vue';
|
||||
import ScheduleWorkbenchPanel from './components/ScheduleWorkbenchPanel.vue';
|
||||
import SchedulesPageOverlays from './components/SchedulesPageOverlays.vue';
|
||||
|
||||
const { elementLocale } = useElementProvider();
|
||||
const adminApi = useSchedulesAdmin();
|
||||
const admin = reactive(adminApi) as SchedulesAdminContextProvided;
|
||||
provide(SCHEDULES_ADMIN_KEY, admin);
|
||||
/** 弹窗 v-if 须绑定原始 ref,避免 reactive 属性赋值破坏 ref 链接 */
|
||||
provide(SCHEDULE_CREATE_MODAL_OPEN_KEY, adminApi.showScheduleCreateModal);
|
||||
|
||||
onMounted(async () => {
|
||||
await admin.loadAll();
|
||||
await admin.applyFromRouteQuery();
|
||||
@@ -25,10 +36,12 @@ onMounted(async () => {
|
||||
</script>
|
||||
|
||||
<template>
|
||||
<section class="section-gap animate-fade-in-up">
|
||||
<SchedulePageHeader />
|
||||
<ScheduleOverviewPanel v-if="admin.scheduleViewMode === 'overview'" />
|
||||
<ScheduleWorkbenchPanel v-else />
|
||||
</section>
|
||||
<SchedulesPageOverlays />
|
||||
<ElConfigProvider :locale="elementLocale">
|
||||
<section class="admin-table-section animate-fade-in-up">
|
||||
<SchedulePageHeader />
|
||||
<ScheduleOverviewPanel v-if="admin.scheduleViewMode === 'overview'" />
|
||||
<ScheduleWorkbenchPanel v-else />
|
||||
</section>
|
||||
<SchedulesPageOverlays />
|
||||
</ElConfigProvider>
|
||||
</template>
|
||||
@@ -3,7 +3,7 @@
|
||||
* features/admin/modules/schedules/components/DynamicTaskParamsForm.vue
|
||||
* 用途:平台任务参数通用表单——按注册表 params_schema 渲染控件并输出统一 job_params。
|
||||
* 依赖:schedule.api(PlatformTaskDefinition/listAdminPlatformTaskOptions)、vue-i18n。
|
||||
* 逻辑:ScheduleCreateEditModal 传入选中任务的 definition;本组件只认识控件 type 与
|
||||
* 逻辑:ScheduleCreateEditDrawer 传入选中任务的 definition;本组件只认识控件 type 与
|
||||
* options_source,不认识具体任务(红框参数区完全由 schema 决定);
|
||||
* 高级配置折叠 JSON 与 schema type=json 字段均本地校验,非法时 emit valid=false 阻止保存;
|
||||
* modelValue 异步回填时同步 _advanced / json 文本(用户已编辑时不覆盖)。
|
||||
|
||||
+472
@@ -0,0 +1,472 @@
|
||||
/**
|
||||
* features/admin/modules/schedules/components/ScheduleCreateEditDrawer.vue
|
||||
* 用途:排程新增/编辑右侧抽屉(Element Plus ElDrawer + ElForm)。
|
||||
* 依赖:schedules.context、ScheduleCronDesigner、DynamicTaskParamsForm、Element Plus。
|
||||
* 逻辑:替换原居中 Modal;平台 Job 与动态参数区行为不变;ElDrawer resizable 支持左缘拖拽调宽。
|
||||
*/
|
||||
<script setup lang="ts">
|
||||
import { computed } from 'vue';
|
||||
import { useI18n } from 'vue-i18n';
|
||||
import { ArrowDown, ArrowUp, Plus } from '@element-plus/icons-vue';
|
||||
import {
|
||||
ElButton,
|
||||
ElCheckbox,
|
||||
ElCollapse,
|
||||
ElCollapseItem,
|
||||
ElDivider,
|
||||
ElDrawer,
|
||||
ElForm,
|
||||
ElFormItem,
|
||||
ElInput,
|
||||
ElInputNumber,
|
||||
ElOption,
|
||||
ElSelect,
|
||||
ElSpace,
|
||||
} from 'element-plus';
|
||||
import { useScheduleCreateModalOpen, useSchedulesAdminContext } from '../composables/schedules.context';
|
||||
import DynamicTaskParamsForm from './DynamicTaskParamsForm.vue';
|
||||
import ScheduleCronDesigner from './ScheduleCronDesigner.vue';
|
||||
|
||||
const { t } = useI18n();
|
||||
const admin = useSchedulesAdminContext();
|
||||
const showCreateModal = useScheduleCreateModalOpen();
|
||||
|
||||
const drawerTitle = computed(() => (
|
||||
admin.scheduleEditingId ? t('admin.schedule.form.editTitle') : t('admin.schedule.form.createTitle')
|
||||
));
|
||||
|
||||
const submitDisabled = computed(() => (
|
||||
admin.scheduleCreateSaving
|
||||
|| !admin.scheduleCreateForm.name
|
||||
|| !admin.scheduleCreateForm.owner_user_id
|
||||
|| !admin.cronDesigner.isValid
|
||||
));
|
||||
|
||||
/**
|
||||
* 用户下拉展示名。
|
||||
* @param user - 用户行
|
||||
*/
|
||||
function userLabel(user: { real_name?: string | null; username: string; employee_id?: string | null }): string {
|
||||
const name = user.real_name || user.username;
|
||||
return user.employee_id ? `${name}(${user.employee_id})` : name;
|
||||
}
|
||||
|
||||
/**
|
||||
* 关闭抽屉(提交中忽略,由 ElDrawer 的 close-on 控制)。
|
||||
*/
|
||||
function handleClose(): void {
|
||||
if (!admin.scheduleCreateSaving) admin.closeScheduleCreateModal();
|
||||
}
|
||||
</script>
|
||||
|
||||
<template>
|
||||
<ElDrawer
|
||||
:model-value="showCreateModal"
|
||||
size="min(720px, 96vw)"
|
||||
direction="rtl"
|
||||
resizable
|
||||
append-to-body
|
||||
destroy-on-close
|
||||
:close-on-click-modal="!admin.scheduleCreateSaving"
|
||||
:close-on-press-escape="!admin.scheduleCreateSaving"
|
||||
:show-close="!admin.scheduleCreateSaving"
|
||||
class="schedule-create-drawer"
|
||||
@close="handleClose"
|
||||
>
|
||||
<template #header>
|
||||
<h3 class="text-lg font-semibold text-primary">{{ drawerTitle }}</h3>
|
||||
</template>
|
||||
|
||||
<ElForm label-position="top" class="schedule-create-form" @submit.prevent>
|
||||
<div class="grid grid-cols-1 gap-2 sm:grid-cols-2">
|
||||
<ElFormItem :label="t('admin.schedule.form.name')" required>
|
||||
<ElInput
|
||||
v-model="admin.scheduleCreateForm.name"
|
||||
:placeholder="t('admin.schedule.form.namePlaceholder')"
|
||||
/>
|
||||
</ElFormItem>
|
||||
<ElFormItem :label="t('admin.schedule.form.owner')" required>
|
||||
<ElSelect
|
||||
v-model="admin.scheduleCreateForm.owner_user_id"
|
||||
filterable
|
||||
class="w-full"
|
||||
:disabled="admin.users.length === 0"
|
||||
:placeholder="admin.users.length === 0 ? t('admin.schedule.form.noUsers') : t('admin.schedule.form.selectOwner')"
|
||||
>
|
||||
<ElOption
|
||||
v-for="u in admin.users"
|
||||
:key="u.id"
|
||||
:label="userLabel(u)"
|
||||
:value="u.id"
|
||||
/>
|
||||
</ElSelect>
|
||||
</ElFormItem>
|
||||
</div>
|
||||
|
||||
<ElDivider content-position="left">{{ t('admin.schedule.form.dataSourceConfig') }}</ElDivider>
|
||||
|
||||
<div class="grid grid-cols-1 gap-2 sm:grid-cols-2">
|
||||
<ElFormItem :label="t('admin.schedule.form.scheduleType')">
|
||||
<ElSelect v-model="admin.scheduleCreateForm.schedule_type" class="w-full">
|
||||
<ElOption :label="t('admin.schedule.form.scheduleTypeDataPipeline')" value="data_pipeline" />
|
||||
<ElOption :label="t('admin.schedule.form.scheduleTypePlatformJob')" value="platform_job" />
|
||||
</ElSelect>
|
||||
</ElFormItem>
|
||||
<ElFormItem
|
||||
v-if="admin.scheduleCreateForm.schedule_type === 'data_pipeline'"
|
||||
:label="t('admin.schedule.form.dataSourceType')"
|
||||
>
|
||||
<ElSelect v-model="admin.scheduleCreateForm.data_source_type" class="w-full">
|
||||
<ElOption :label="t('admin.schedule.form.databaseDirect')" value="database" />
|
||||
<ElOption :label="t('admin.schedule.form.externalApi')" value="external_api" />
|
||||
</ElSelect>
|
||||
</ElFormItem>
|
||||
<ElFormItem
|
||||
v-else
|
||||
:label="t('admin.schedule.form.platformJob')"
|
||||
>
|
||||
<ElSelect
|
||||
v-model="admin.scheduleCreateForm.platform_api_path"
|
||||
class="w-full"
|
||||
:placeholder="t('admin.schedule.form.selectPlatformJob')"
|
||||
@change="admin.handlePlatformJobChange"
|
||||
>
|
||||
<ElOption
|
||||
v-for="job in admin.platformJobs"
|
||||
:key="job.key"
|
||||
:label="job.label_key ? t(job.label_key) : (job.label || job.key)"
|
||||
:value="job.key"
|
||||
/>
|
||||
</ElSelect>
|
||||
</ElFormItem>
|
||||
</div>
|
||||
|
||||
<ElSpace v-if="admin.scheduleCreateForm.schedule_type === 'data_pipeline'" wrap class="mb-3">
|
||||
<ElButton
|
||||
:disabled="admin.scheduleTestLoading || !admin.scheduleEditingId"
|
||||
:loading="admin.scheduleTestLoading"
|
||||
@click="admin.handleTestScheduleSql"
|
||||
>
|
||||
{{ admin.scheduleTestLoading ? t('admin.schedule.form.querying') : t('admin.schedule.form.testQuery') }}
|
||||
</ElButton>
|
||||
<ElButton
|
||||
:icon="admin.scheduleConfigCollapsed ? ArrowDown : ArrowUp"
|
||||
@click="admin.scheduleConfigCollapsed = !admin.scheduleConfigCollapsed"
|
||||
>
|
||||
{{ admin.scheduleConfigCollapsed ? t('admin.schedule.form.expandConfig') : t('admin.schedule.form.collapseConfig') }}
|
||||
</ElButton>
|
||||
</ElSpace>
|
||||
|
||||
<div
|
||||
v-show="admin.scheduleCreateForm.schedule_type === 'data_pipeline' && !admin.scheduleConfigCollapsed"
|
||||
class="space-y-3"
|
||||
>
|
||||
<template v-if="admin.scheduleCreateForm.data_source_type === 'database'">
|
||||
<ElCollapse model-value="ds">
|
||||
<ElCollapseItem :title="t('admin.schedule.form.dataSourceSection')" name="ds">
|
||||
<div class="grid grid-cols-1 gap-2 sm:grid-cols-2">
|
||||
<ElFormItem :label="t('admin.schedule.form.dsDbType')">
|
||||
<ElSelect v-model="admin.scheduleSqlEditForm.ds_db_type" class="w-full">
|
||||
<ElOption label="SQL Server" value="sqlserver" />
|
||||
<ElOption label="PostgreSQL" value="postgresql" />
|
||||
<ElOption label="MySQL" value="mysql" />
|
||||
</ElSelect>
|
||||
</ElFormItem>
|
||||
<ElFormItem :label="t('admin.schedule.form.dsHost')">
|
||||
<ElInput v-model="admin.scheduleSqlEditForm.ds_host" :placeholder="t('admin.schedule.form.dsHostPlaceholder')" />
|
||||
</ElFormItem>
|
||||
<ElFormItem :label="t('admin.schedule.form.dsPort')">
|
||||
<ElInput v-model="admin.scheduleSqlEditForm.ds_port" placeholder="1433" />
|
||||
</ElFormItem>
|
||||
<ElFormItem :label="t('admin.schedule.form.dsDatabase')">
|
||||
<ElInput v-model="admin.scheduleSqlEditForm.ds_database" :placeholder="t('admin.schedule.form.dsDatabasePlaceholder')" />
|
||||
</ElFormItem>
|
||||
<ElFormItem :label="t('admin.schedule.form.dsUsername')">
|
||||
<ElInput v-model="admin.scheduleSqlEditForm.ds_username" placeholder="sa" />
|
||||
</ElFormItem>
|
||||
<ElFormItem :label="t('admin.schedule.form.dsPassword')">
|
||||
<ElInput v-model="admin.scheduleSqlEditForm.ds_password" type="password" show-password :placeholder="t('admin.schedule.form.dsPasswordPlaceholder')" />
|
||||
</ElFormItem>
|
||||
</div>
|
||||
<div v-if="admin.scheduleSqlEditForm.ds_db_type === 'sqlserver'" class="grid grid-cols-1 gap-2 sm:grid-cols-3">
|
||||
<ElFormItem :label="t('admin.schedule.form.dsDriver')">
|
||||
<ElInput v-model="admin.scheduleSqlEditForm.ds_driver" placeholder="SQL Server" />
|
||||
</ElFormItem>
|
||||
<ElFormItem :label="t('admin.schedule.form.dsEncrypt')">
|
||||
<ElSelect v-model="admin.scheduleSqlEditForm.ds_encrypt" class="w-full" clearable>
|
||||
<ElOption :label="t('admin.schedule.form.defaultNo')" value="" />
|
||||
<ElOption label="yes" value="yes" />
|
||||
<ElOption label="no" value="no" />
|
||||
</ElSelect>
|
||||
</ElFormItem>
|
||||
<ElFormItem :label="t('admin.schedule.form.dsTrustCert')">
|
||||
<ElSelect v-model="admin.scheduleSqlEditForm.ds_trust_cert" class="w-full" clearable>
|
||||
<ElOption :label="t('admin.schedule.form.defaultYes')" value="" />
|
||||
<ElOption label="yes" value="yes" />
|
||||
<ElOption label="no" value="no" />
|
||||
</ElSelect>
|
||||
</ElFormItem>
|
||||
</div>
|
||||
<p class="text-xs text-muted">{{ t('admin.schedule.form.envVarHint', { token: t('admin.schedule.form.envVarToken') }) }}</p>
|
||||
</ElCollapseItem>
|
||||
</ElCollapse>
|
||||
|
||||
<ElFormItem :label="t('admin.schedule.form.baseFetchSql')">
|
||||
<ElInput v-model="admin.scheduleSqlEditForm.base_fetch_sql" type="textarea" :rows="6" class="font-mono text-xs" />
|
||||
</ElFormItem>
|
||||
<ElFormItem :label="t('admin.schedule.form.fetchWhereConditions')">
|
||||
<ElInput v-model="admin.scheduleSqlEditForm.fetch_where_conditions" type="textarea" :rows="3" class="font-mono text-xs" />
|
||||
</ElFormItem>
|
||||
<ElFormItem :label="t('admin.schedule.form.fetchOrderBy')">
|
||||
<ElInput v-model="admin.scheduleSqlEditForm.fetch_order_by" class="font-mono text-xs" />
|
||||
</ElFormItem>
|
||||
<ElFormItem :label="t('admin.schedule.form.detailSql')">
|
||||
<ElInput v-model="admin.scheduleSqlEditForm.detail_sql" type="textarea" :rows="4" class="font-mono text-xs" />
|
||||
</ElFormItem>
|
||||
<ElFormItem :label="t('admin.schedule.form.writebackSql')">
|
||||
<ElInput v-model="admin.scheduleSqlEditForm.writeback_sql" type="textarea" :rows="2" class="font-mono text-xs" />
|
||||
</ElFormItem>
|
||||
<div class="grid grid-cols-1 gap-2 sm:grid-cols-2">
|
||||
<ElFormItem :label="t('admin.schedule.form.rowIdKey')">
|
||||
<ElInput v-model="admin.scheduleSqlEditForm.row_id_key" />
|
||||
</ElFormItem>
|
||||
<ElFormItem :label="t('admin.schedule.form.logPrefix')">
|
||||
<ElInput v-model="admin.scheduleSqlEditForm.log_prefix" />
|
||||
</ElFormItem>
|
||||
</div>
|
||||
<ElFormItem :label="t('admin.schedule.form.aliasOrder')">
|
||||
<ElInput v-model="admin.scheduleSqlEditForm.alias_order_str" class="font-mono text-xs" />
|
||||
</ElFormItem>
|
||||
<ElFormItem :label="t('admin.schedule.form.detailAliasOrder')">
|
||||
<ElInput v-model="admin.scheduleSqlEditForm.detail_alias_order_str" class="font-mono text-xs" />
|
||||
</ElFormItem>
|
||||
<ElFormItem :label="t('admin.schedule.form.headerLabels')">
|
||||
<ElInput v-model="admin.scheduleSqlEditForm.header_labels_str" type="textarea" :rows="3" class="font-mono text-xs" />
|
||||
</ElFormItem>
|
||||
</template>
|
||||
|
||||
<template v-if="admin.scheduleCreateForm.data_source_type === 'external_api'">
|
||||
<ElFormItem :label="t('admin.schedule.form.apiUrl')">
|
||||
<ElInput v-model="admin.scheduleSqlEditForm.api_url" placeholder="https://api.example.com/endpoint" />
|
||||
</ElFormItem>
|
||||
<div class="grid grid-cols-1 gap-2 sm:grid-cols-2">
|
||||
<ElFormItem :label="t('admin.schedule.form.apiMethod')">
|
||||
<ElSelect v-model="admin.scheduleSqlEditForm.api_method" class="w-full">
|
||||
<ElOption label="POST" value="POST" />
|
||||
<ElOption label="GET" value="GET" />
|
||||
<ElOption label="PUT" value="PUT" />
|
||||
</ElSelect>
|
||||
</ElFormItem>
|
||||
<ElFormItem :label="t('admin.schedule.form.apiTimeoutSeconds')">
|
||||
<ElInputNumber :model-value="120" disabled class="w-full" />
|
||||
</ElFormItem>
|
||||
</div>
|
||||
<ElFormItem :label="t('admin.schedule.form.apiHeaders')">
|
||||
<ElInput v-model="admin.scheduleSqlEditForm.api_headers_str" type="textarea" :rows="2" class="font-mono text-xs" />
|
||||
</ElFormItem>
|
||||
<ElFormItem :label="t('admin.schedule.form.apiBodyTemplate')">
|
||||
<ElInput v-model="admin.scheduleSqlEditForm.api_body_template" type="textarea" :rows="3" class="font-mono text-xs" />
|
||||
</ElFormItem>
|
||||
</template>
|
||||
</div>
|
||||
|
||||
<div v-if="admin.scheduleCreateForm.schedule_type === 'platform_job'" class="mt-2">
|
||||
<DynamicTaskParamsForm
|
||||
v-if="admin.selectedPlatformTaskDefinition"
|
||||
:definition="admin.selectedPlatformTaskDefinition"
|
||||
:model-value="admin.scheduleCreateForm.job_params"
|
||||
:valid="admin.platformJobParamsValid"
|
||||
@update:model-value="admin.scheduleCreateForm.job_params = $event"
|
||||
@update:valid="admin.platformJobParamsValid = $event"
|
||||
/>
|
||||
<div
|
||||
v-else-if="admin.platformTaskDefinitionsLoading || admin.platformTaskDefinitionsError"
|
||||
class="space-y-2 rounded-lg border border-default px-4 py-3 text-sm text-muted"
|
||||
>
|
||||
<p>
|
||||
{{ admin.platformTaskDefinitionsLoading
|
||||
? t('admin.schedule.form.dynamicParamsLoading')
|
||||
: t('admin.schedule.form.dynamicParamsLoadFailed') }}
|
||||
</p>
|
||||
<ElButton
|
||||
v-if="admin.platformTaskDefinitionsError && !admin.platformTaskDefinitionsLoading"
|
||||
size="small"
|
||||
@click="admin.loadPlatformTaskDefinitions"
|
||||
>
|
||||
{{ t('admin.schedule.form.dynamicParamsRetry') }}
|
||||
</ElButton>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div v-if="admin.scheduleTestResult" class="mt-3 rounded-lg border border-emerald-200 bg-emerald-50/40 p-3">
|
||||
<div class="mb-2 flex items-center justify-between">
|
||||
<h4 class="text-sm font-bold text-emerald-900">{{ t('admin.schedule.testRun.queryResult') }}</h4>
|
||||
<ElButton link type="primary" @click="admin.scheduleTestResult = null">✕</ElButton>
|
||||
</div>
|
||||
<p class="mb-2 text-xs text-emerald-600">
|
||||
{{ t('admin.schedule.testRun.resultSummary', { total: admin.scheduleTestResult.total, showing: admin.scheduleTestResult.showing }) }}
|
||||
</p>
|
||||
<div class="mb-2 overflow-x-auto rounded border border-emerald-200 bg-surface">
|
||||
<table class="w-full text-xs">
|
||||
<thead class="bg-emerald-50">
|
||||
<tr>
|
||||
<th
|
||||
v-for="col in admin.scheduleTestResult.columns"
|
||||
:key="col"
|
||||
class="whitespace-nowrap px-3 py-2 text-left font-semibold text-emerald-800"
|
||||
>{{ col }}</th>
|
||||
</tr>
|
||||
</thead>
|
||||
<tbody>
|
||||
<tr
|
||||
v-for="(row, ri) in admin.scheduleTestResult.rows"
|
||||
:key="ri"
|
||||
class="border-t border-emerald-100"
|
||||
>
|
||||
<td
|
||||
v-for="col in admin.scheduleTestResult.columns"
|
||||
:key="col"
|
||||
class="whitespace-nowrap px-3 py-1.5 text-secondary"
|
||||
>{{ row[col] }}</td>
|
||||
</tr>
|
||||
</tbody>
|
||||
</table>
|
||||
</div>
|
||||
<details>
|
||||
<summary class="cursor-pointer text-xs font-semibold text-emerald-700">{{ t('admin.schedule.testRun.viewGeneratedSql') }}</summary>
|
||||
<pre class="admin-pre-block admin-pre-block--sql">{{ admin.scheduleTestResult.sql }}</pre>
|
||||
</details>
|
||||
</div>
|
||||
|
||||
<template v-if="admin.scheduleCreateForm.schedule_type === 'data_pipeline'">
|
||||
<ElDivider />
|
||||
<div class="grid grid-cols-1 gap-2 sm:grid-cols-2">
|
||||
<ElFormItem :label="t('admin.schedule.form.agentLabel')">
|
||||
<ElSelect
|
||||
v-model="admin.scheduleCreateForm.dify_agent_id"
|
||||
class="w-full"
|
||||
clearable
|
||||
:disabled="admin.agents.length === 0"
|
||||
:placeholder="admin.agents.length === 0 ? t('admin.schedule.form.noAgents') : t('admin.schedule.form.agentDisabled')"
|
||||
>
|
||||
<ElOption
|
||||
v-for="a in admin.agents"
|
||||
:key="a.id"
|
||||
:label="`${a.name}${t('admin.schedule.form.agentOptionId', { id: a.dify_app_id?.slice(0, 8) || a.id })}`"
|
||||
:value="a.id"
|
||||
/>
|
||||
</ElSelect>
|
||||
</ElFormItem>
|
||||
<ElFormItem :label="t('admin.schedule.form.waitSeconds')">
|
||||
<ElInputNumber v-model="admin.scheduleCreateForm.wait_seconds" :min="0" class="w-full" />
|
||||
</ElFormItem>
|
||||
</div>
|
||||
|
||||
<ElFormItem>
|
||||
<ElCheckbox v-model="admin.scheduleCreateForm.kb_sync_enabled">
|
||||
{{ t('admin.schedule.form.kbSyncEnabled') }}
|
||||
</ElCheckbox>
|
||||
<p class="mt-1 text-xs text-muted">{{ t('admin.schedule.form.kbSyncHint') }}</p>
|
||||
</ElFormItem>
|
||||
<ElFormItem
|
||||
v-if="admin.scheduleCreateForm.kb_sync_enabled"
|
||||
:label="t('admin.schedule.form.kbGroup')"
|
||||
>
|
||||
<ElSelect
|
||||
v-model="admin.scheduleCreateForm.kb_group_id"
|
||||
class="w-full"
|
||||
:disabled="admin.kbGroups.length === 0"
|
||||
:placeholder="admin.kbGroups.length === 0 ? t('admin.schedule.form.noKbGroups') : t('admin.schedule.form.selectKbGroup')"
|
||||
>
|
||||
<ElOption
|
||||
v-for="group in admin.kbGroups"
|
||||
:key="group.id"
|
||||
:label="group.name"
|
||||
:value="group.id"
|
||||
/>
|
||||
</ElSelect>
|
||||
</ElFormItem>
|
||||
|
||||
<ElFormItem
|
||||
v-if="admin.scheduleCreateForm.dify_agent_id"
|
||||
:label="t('admin.schedule.form.difySystemPrompt')"
|
||||
>
|
||||
<p class="mb-2 text-xs text-muted">{{ t('admin.schedule.form.difySystemPromptHint') }}</p>
|
||||
<ElInput
|
||||
v-model="admin.scheduleSqlEditForm.dify_system_prompt"
|
||||
type="textarea"
|
||||
:rows="5"
|
||||
class="font-mono text-sm"
|
||||
:placeholder="t('admin.schedule.form.difySystemPromptPlaceholder')"
|
||||
/>
|
||||
</ElFormItem>
|
||||
</template>
|
||||
|
||||
<ElDivider content-position="left">{{ t('admin.schedule.form.cronTitle') }}</ElDivider>
|
||||
<p class="mb-3 text-xs text-muted">{{ t('admin.schedule.form.cronHint') }}</p>
|
||||
<ScheduleCronDesigner
|
||||
:designer="admin.cronDesigner"
|
||||
:format-date-time="admin.formatDateTime"
|
||||
/>
|
||||
|
||||
<ElFormItem class="mt-4">
|
||||
<ElCheckbox v-model="admin.scheduleCreateForm.notify_enabled">
|
||||
{{ t('admin.schedule.form.notifyEnabled') }}
|
||||
</ElCheckbox>
|
||||
</ElFormItem>
|
||||
<ElFormItem v-if="admin.scheduleCreateForm.notify_enabled" :label="t('admin.schedule.form.selectNotifyUsers')">
|
||||
<ElSelect
|
||||
v-model="admin.scheduleCreateForm.notify_user_ids_json"
|
||||
multiple
|
||||
filterable
|
||||
class="w-full"
|
||||
:placeholder="t('admin.schedule.form.selectNotifyUsers')"
|
||||
>
|
||||
<ElOption
|
||||
v-for="u in admin.users"
|
||||
:key="u.id"
|
||||
:label="userLabel(u)"
|
||||
:value="u.id"
|
||||
/>
|
||||
</ElSelect>
|
||||
</ElFormItem>
|
||||
|
||||
<ElFormItem>
|
||||
<ElCheckbox v-model="admin.scheduleCreateForm.enabled">
|
||||
{{ t('admin.schedule.form.enableOnCreate') }}
|
||||
</ElCheckbox>
|
||||
</ElFormItem>
|
||||
</ElForm>
|
||||
|
||||
<template #footer>
|
||||
<div class="flex justify-end gap-3">
|
||||
<ElButton :disabled="admin.scheduleCreateSaving" @click="admin.closeScheduleCreateModal">
|
||||
{{ t('admin.schedule.form.cancel') }}
|
||||
</ElButton>
|
||||
<ElButton
|
||||
type="primary"
|
||||
:icon="Plus"
|
||||
:loading="admin.scheduleCreateSaving"
|
||||
:disabled="submitDisabled"
|
||||
@click="admin.createSchedule"
|
||||
>
|
||||
{{ admin.scheduleCreateSaving
|
||||
? t('admin.schedule.form.saving')
|
||||
: (admin.scheduleEditingId
|
||||
? t('admin.schedule.form.saveChanges')
|
||||
: t('admin.schedule.form.createSchedule')) }}
|
||||
</ElButton>
|
||||
</div>
|
||||
</template>
|
||||
</ElDrawer>
|
||||
</template>
|
||||
|
||||
<style scoped>
|
||||
.schedule-create-form :deep(.el-form-item) {
|
||||
margin-bottom: 14px;
|
||||
}
|
||||
|
||||
.schedule-create-form :deep(.el-divider) {
|
||||
margin: 12px 0 16px;
|
||||
}
|
||||
</style>
|
||||
@@ -1,500 +0,0 @@
|
||||
<script setup lang="ts">
|
||||
/**
|
||||
* features/admin/modules/schedules/components/ScheduleCreateEditModal.vue
|
||||
* 用途:定时任务创建/编辑弹窗。
|
||||
* 依赖:schedules.context、ScheduleCronDesigner、DynamicTaskParamsForm。
|
||||
* 逻辑:平台 Job 下拉展示由 registry 返回的 label_key 经 $t() 渲染;平台任务参数区由
|
||||
* DynamicTaskParamsForm 按 params_schema 通用渲染,本组件不再按任务硬编码 v-if。
|
||||
*/
|
||||
import { ChevronDown, ChevronUp, Plus } from 'lucide-vue-next';
|
||||
import { useScheduleCreateModalOpen, useSchedulesAdminContext } from '../composables/schedules.context';
|
||||
import DynamicTaskParamsForm from './DynamicTaskParamsForm.vue';
|
||||
import ScheduleCronDesigner from './ScheduleCronDesigner.vue';
|
||||
|
||||
const admin = useSchedulesAdminContext();
|
||||
const showCreateModal = useScheduleCreateModalOpen();
|
||||
</script>
|
||||
|
||||
<template>
|
||||
<Teleport to="body">
|
||||
<div v-if="showCreateModal" class="admin-modal-overlay items-center">
|
||||
<div class="admin-modal-panel max-h-[92vh] max-w-3xl min-h-0">
|
||||
<div class="flex shrink-0 items-center justify-between border-b border-subtle px-8 py-6">
|
||||
<h3 class="text-2xl font-bold tracking-tight text-primary">{{ admin.scheduleEditingId ? $t('admin.schedule.form.editTitle') : $t('admin.schedule.form.createTitle') }}</h3>
|
||||
<button
|
||||
class="rounded-full p-2 text-muted transition hover-surface-soft hover:text-secondary"
|
||||
@click="admin.closeScheduleCreateModal"
|
||||
>
|
||||
✕
|
||||
</button>
|
||||
</div>
|
||||
<div class="min-h-0 flex-1 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-secondary">{{ $t('admin.schedule.form.name') }}</label>
|
||||
<input v-model="admin.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-secondary">{{ $t('admin.schedule.form.owner') }}</label>
|
||||
<div class="relative">
|
||||
<input
|
||||
v-model="admin.scheduleOwnerQuery"
|
||||
type="text"
|
||||
class="input-field !text-sm !leading-5"
|
||||
:placeholder="admin.users.length === 0 ? $t('admin.schedule.form.noUsers') : $t('admin.schedule.form.selectOwner')"
|
||||
:disabled="admin.users.length === 0"
|
||||
@focus="admin.scheduleOwnerDropdownOpen = true"
|
||||
@input="admin.handleScheduleOwnerInput"
|
||||
@blur="admin.scheduleCloseOwnerDropdown"
|
||||
/>
|
||||
<div
|
||||
v-if="admin.scheduleOwnerDropdownOpen && admin.users.length > 0"
|
||||
class="admin-dropdown max-h-60 w-full overflow-y-auto"
|
||||
>
|
||||
<button
|
||||
v-for="u in admin.filteredOwnerUsers"
|
||||
:key="u.id"
|
||||
type="button"
|
||||
class="flex w-full items-center gap-3 px-3 py-2 text-left text-sm transition hover:bg-surface-soft"
|
||||
:class="admin.scheduleCreateForm.owner_user_id === u.id ? 'bg-blue-50/50' : ''"
|
||||
@mousedown.prevent="admin.selectScheduleOwner(u.id)"
|
||||
>
|
||||
<span class="text-secondary">{{ u.real_name || u.username }}{{ u.employee_id ? '(' + u.employee_id + ')' : '' }}</span>
|
||||
</button>
|
||||
<div v-if="admin.filteredOwnerUsers.length === 0" class="px-3 py-2 text-sm text-muted">
|
||||
{{ $t('admin.wecom.noData') }}
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<!-- SQL Config Panel -->
|
||||
<div class="rounded-2xl border border-default bg-surface-soft/40 p-4">
|
||||
<div class="mb-3 space-y-3">
|
||||
<h4 class="text-base font-bold text-primary">{{ $t('admin.schedule.form.dataSourceConfig') }}</h4>
|
||||
<div class="grid grid-cols-1 gap-3 sm:grid-cols-2">
|
||||
<div>
|
||||
<label class="mb-1.5 block text-xs font-semibold uppercase tracking-wide text-muted">
|
||||
{{ $t('admin.schedule.form.scheduleType') }}
|
||||
</label>
|
||||
<select
|
||||
v-model="admin.scheduleCreateForm.schedule_type"
|
||||
class="input-field w-full !text-sm !leading-5"
|
||||
>
|
||||
<option value="data_pipeline">{{ $t('admin.schedule.form.scheduleTypeDataPipeline') }}</option>
|
||||
<option value="platform_job">{{ $t('admin.schedule.form.scheduleTypePlatformJob') }}</option>
|
||||
</select>
|
||||
</div>
|
||||
<div v-if="admin.scheduleCreateForm.schedule_type === 'data_pipeline'">
|
||||
<label class="mb-1.5 block text-xs font-semibold uppercase tracking-wide text-muted">
|
||||
{{ $t('admin.schedule.form.dataSourceType') }}
|
||||
</label>
|
||||
<select
|
||||
v-model="admin.scheduleCreateForm.data_source_type"
|
||||
class="input-field w-full !text-sm !leading-5"
|
||||
>
|
||||
<option value="database">{{ $t('admin.schedule.form.databaseDirect') }}</option>
|
||||
<option value="external_api">{{ $t('admin.schedule.form.externalApi') }}</option>
|
||||
</select>
|
||||
</div>
|
||||
<div v-else>
|
||||
<label class="mb-1.5 block text-xs font-semibold uppercase tracking-wide text-muted">
|
||||
{{ $t('admin.schedule.form.platformJob') }}
|
||||
</label>
|
||||
<select
|
||||
v-model="admin.scheduleCreateForm.platform_api_path"
|
||||
class="input-field w-full !text-sm !leading-5"
|
||||
@change="admin.handlePlatformJobChange"
|
||||
>
|
||||
<option :value="null">{{ $t('admin.schedule.form.selectPlatformJob') }}</option>
|
||||
<option v-for="job in admin.platformJobs" :key="job.key" :value="job.key">
|
||||
{{ job.label_key ? $t(job.label_key) : job.label || job.key }}
|
||||
</option>
|
||||
</select>
|
||||
</div>
|
||||
</div>
|
||||
<div
|
||||
v-if="admin.scheduleCreateForm.schedule_type === 'data_pipeline'"
|
||||
class="flex flex-wrap items-center gap-2 sm:shrink-0"
|
||||
>
|
||||
<button
|
||||
type="button"
|
||||
class="btn-secondary btn-sm inline-flex shrink-0 items-center gap-1.5 whitespace-nowrap disabled:cursor-not-allowed disabled:opacity-60"
|
||||
:disabled="admin.scheduleTestLoading || !admin.scheduleEditingId"
|
||||
@click="admin.handleTestScheduleSql"
|
||||
>
|
||||
{{ admin.scheduleTestLoading ? $t('admin.schedule.form.querying') : $t('admin.schedule.form.testQuery') }}
|
||||
</button>
|
||||
<button
|
||||
type="button"
|
||||
class="btn-secondary btn-sm inline-flex shrink-0 items-center gap-1.5 whitespace-nowrap"
|
||||
@click="admin.scheduleConfigCollapsed = !admin.scheduleConfigCollapsed"
|
||||
>
|
||||
<ChevronDown v-if="admin.scheduleConfigCollapsed" class="h-3.5 w-3.5 shrink-0" />
|
||||
<ChevronUp v-else class="h-3.5 w-3.5 shrink-0" />
|
||||
{{ admin.scheduleConfigCollapsed ? $t('admin.schedule.form.expandConfig') : $t('admin.schedule.form.collapseConfig') }}
|
||||
</button>
|
||||
</div>
|
||||
</div>
|
||||
<div
|
||||
v-show="admin.scheduleCreateForm.schedule_type === 'data_pipeline' && !admin.scheduleConfigCollapsed"
|
||||
class="space-y-3"
|
||||
>
|
||||
<template v-if="admin.scheduleCreateForm.data_source_type === 'database'">
|
||||
<!-- 数据源配置 -->
|
||||
<details class="rounded-xl border border-default bg-surface" open>
|
||||
<summary class="cursor-pointer px-4 py-2.5 text-sm font-semibold text-secondary hover:bg-surface-soft 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>
|
||||
<label class="mb-1 block text-xs font-semibold text-muted uppercase">{{ $t('admin.schedule.form.dsDbType') }}</label>
|
||||
<select v-model="admin.scheduleSqlEditForm.ds_db_type" class="w-full input-field px-3 py-2 text-sm text-secondary focus:border-blue-300 focus:outline-none focus:ring-1 focus:ring-blue-200">
|
||||
<option value="sqlserver">SQL Server</option>
|
||||
<option value="postgresql">PostgreSQL</option>
|
||||
<option value="mysql">MySQL</option>
|
||||
</select>
|
||||
</div>
|
||||
<div>
|
||||
<label class="mb-1 block text-xs font-semibold text-muted uppercase">{{ $t('admin.schedule.form.dsHost') }}</label>
|
||||
<input v-model="admin.scheduleSqlEditForm.ds_host" class="w-full input-field px-3 py-2 text-sm text-secondary focus:border-blue-300 focus:outline-none focus:ring-1 focus:ring-blue-200" :placeholder="$t('admin.schedule.form.dsHostPlaceholder')" />
|
||||
</div>
|
||||
</div>
|
||||
<div class="grid grid-cols-4 gap-3">
|
||||
<div>
|
||||
<label class="mb-1 block text-xs font-semibold text-muted uppercase">{{ $t('admin.schedule.form.dsPort') }}</label>
|
||||
<input v-model="admin.scheduleSqlEditForm.ds_port" class="w-full input-field px-3 py-2 text-sm text-secondary focus:border-blue-300 focus:outline-none focus:ring-1 focus:ring-blue-200" placeholder="1433" />
|
||||
</div>
|
||||
<div>
|
||||
<label class="mb-1 block text-xs font-semibold text-muted uppercase">{{ $t('admin.schedule.form.dsDatabase') }}</label>
|
||||
<input v-model="admin.scheduleSqlEditForm.ds_database" class="w-full input-field px-3 py-2 text-sm text-secondary focus:border-blue-300 focus:outline-none focus:ring-1 focus:ring-blue-200" :placeholder="$t('admin.schedule.form.dsDatabasePlaceholder')" />
|
||||
</div>
|
||||
<div>
|
||||
<label class="mb-1 block text-xs font-semibold text-muted uppercase">{{ $t('admin.schedule.form.dsUsername') }}</label>
|
||||
<input v-model="admin.scheduleSqlEditForm.ds_username" class="w-full input-field px-3 py-2 text-sm text-secondary focus:border-blue-300 focus:outline-none focus:ring-1 focus:ring-blue-200" placeholder="sa" />
|
||||
</div>
|
||||
<div>
|
||||
<label class="mb-1 block text-xs font-semibold text-muted uppercase">{{ $t('admin.schedule.form.dsPassword') }}</label>
|
||||
<input v-model="admin.scheduleSqlEditForm.ds_password" type="password" class="w-full input-field px-3 py-2 text-sm text-secondary focus:border-blue-300 focus:outline-none focus:ring-1 focus:ring-blue-200" :placeholder="$t('admin.schedule.form.dsPasswordPlaceholder')" />
|
||||
</div>
|
||||
</div>
|
||||
<div v-if="admin.scheduleSqlEditForm.ds_db_type === 'sqlserver'" class="grid grid-cols-3 gap-3">
|
||||
<div>
|
||||
<label class="mb-1 block text-xs font-semibold text-muted uppercase">{{ $t('admin.schedule.form.dsDriver') }}</label>
|
||||
<input v-model="admin.scheduleSqlEditForm.ds_driver" class="w-full input-field px-3 py-2 text-sm text-secondary focus:border-blue-300 focus:outline-none focus:ring-1 focus:ring-blue-200" placeholder="SQL Server" />
|
||||
</div>
|
||||
<div>
|
||||
<label class="mb-1 block text-xs font-semibold text-muted uppercase">{{ $t('admin.schedule.form.dsEncrypt') }}</label>
|
||||
<select v-model="admin.scheduleSqlEditForm.ds_encrypt" class="w-full input-field px-3 py-2 text-sm text-secondary focus:border-blue-300 focus:outline-none focus:ring-1 focus:ring-blue-200">
|
||||
<option value="">{{ $t('admin.schedule.form.defaultNo') }}</option>
|
||||
<option value="yes">yes</option>
|
||||
<option value="no">no</option>
|
||||
</select>
|
||||
</div>
|
||||
<div>
|
||||
<label class="mb-1 block text-xs font-semibold text-muted uppercase">{{ $t('admin.schedule.form.dsTrustCert') }}</label>
|
||||
<select v-model="admin.scheduleSqlEditForm.ds_trust_cert" class="w-full input-field px-3 py-2 text-sm text-secondary focus:border-blue-300 focus:outline-none focus:ring-1 focus:ring-blue-200">
|
||||
<option value="">{{ $t('admin.schedule.form.defaultYes') }}</option>
|
||||
<option value="yes">yes</option>
|
||||
<option value="no">no</option>
|
||||
</select>
|
||||
</div>
|
||||
</div>
|
||||
<p class="text-xs text-muted">{{ $t('admin.schedule.form.envVarHint', { token: $t('admin.schedule.form.envVarToken') }) }}</p>
|
||||
</div>
|
||||
</details>
|
||||
<div>
|
||||
<label class="mb-1 block text-xs font-semibold text-muted uppercase">{{ $t('admin.schedule.form.baseFetchSql') }}</label>
|
||||
<textarea
|
||||
v-model="admin.scheduleSqlEditForm.base_fetch_sql"
|
||||
class="w-full min-h-[160px] input-field p-3 text-xs leading-relaxed text-secondary font-mono focus:border-blue-300 focus:outline-none focus:ring-1 focus:ring-blue-200 resize-y"
|
||||
></textarea>
|
||||
</div>
|
||||
<div>
|
||||
<label class="mb-1 block text-xs font-semibold text-muted uppercase">{{ $t('admin.schedule.form.fetchWhereConditions') }}</label>
|
||||
<textarea
|
||||
v-model="admin.scheduleSqlEditForm.fetch_where_conditions"
|
||||
class="w-full min-h-[80px] rounded-xl border border-amber-200 bg-amber-50/30 p-3 text-xs leading-relaxed text-secondary font-mono focus:border-amber-300 focus:outline-none focus:ring-1 focus:ring-amber-200 resize-y"
|
||||
></textarea>
|
||||
</div>
|
||||
<div>
|
||||
<label class="mb-1 block text-xs font-semibold text-muted uppercase">{{ $t('admin.schedule.form.fetchOrderBy') }}</label>
|
||||
<input v-model="admin.scheduleSqlEditForm.fetch_order_by" class="w-full input-field px-3 py-2 text-xs font-mono text-secondary focus:border-blue-300 focus:outline-none focus:ring-1 focus:ring-blue-200" />
|
||||
</div>
|
||||
<div>
|
||||
<label class="mb-1 block text-xs font-semibold text-muted uppercase">{{ $t('admin.schedule.form.detailSql') }}</label>
|
||||
<textarea
|
||||
v-model="admin.scheduleSqlEditForm.detail_sql"
|
||||
class="w-full min-h-[120px] input-field p-3 text-xs leading-relaxed text-secondary font-mono focus:border-blue-300 focus:outline-none focus:ring-1 focus:ring-blue-200 resize-y"
|
||||
></textarea>
|
||||
</div>
|
||||
<div>
|
||||
<label class="mb-1 block text-xs font-semibold text-muted uppercase">{{ $t('admin.schedule.form.writebackSql') }}</label>
|
||||
<textarea
|
||||
v-model="admin.scheduleSqlEditForm.writeback_sql"
|
||||
class="w-full min-h-[48px] input-field p-3 text-xs leading-relaxed text-secondary font-mono focus:border-blue-300 focus:outline-none focus:ring-1 focus:ring-blue-200 resize-y"
|
||||
></textarea>
|
||||
</div>
|
||||
<div class="grid grid-cols-2 gap-3">
|
||||
<div>
|
||||
<label class="mb-1 block text-xs font-semibold text-muted uppercase">{{ $t('admin.schedule.form.rowIdKey') }}</label>
|
||||
<input v-model="admin.scheduleSqlEditForm.row_id_key" class="w-full input-field px-3 py-2 text-sm text-secondary focus:border-blue-300 focus:outline-none focus:ring-1 focus:ring-blue-200" />
|
||||
</div>
|
||||
<div>
|
||||
<label class="mb-1 block text-xs font-semibold text-muted uppercase">{{ $t('admin.schedule.form.logPrefix') }}</label>
|
||||
<input v-model="admin.scheduleSqlEditForm.log_prefix" class="w-full input-field px-3 py-2 text-sm text-secondary focus:border-blue-300 focus:outline-none focus:ring-1 focus:ring-blue-200" />
|
||||
</div>
|
||||
</div>
|
||||
<div class="hidden">
|
||||
</div>
|
||||
<div>
|
||||
<label class="mb-1 block text-xs font-semibold text-muted uppercase">{{ $t('admin.schedule.form.aliasOrder') }}</label>
|
||||
<input v-model="admin.scheduleSqlEditForm.alias_order_str" class="w-full input-field px-3 py-2 text-xs font-mono text-secondary focus:border-blue-300 focus:outline-none focus:ring-1 focus:ring-blue-200" />
|
||||
</div>
|
||||
<div>
|
||||
<label class="mb-1 block text-xs font-semibold text-muted uppercase">{{ $t('admin.schedule.form.detailAliasOrder') }}</label>
|
||||
<input v-model="admin.scheduleSqlEditForm.detail_alias_order_str" class="w-full input-field px-3 py-2 text-xs font-mono text-secondary focus:border-blue-300 focus:outline-none focus:ring-1 focus:ring-blue-200" />
|
||||
</div>
|
||||
<div>
|
||||
<label class="mb-1 block text-xs font-semibold text-muted uppercase">{{ $t('admin.schedule.form.headerLabels') }}</label>
|
||||
<textarea
|
||||
v-model="admin.scheduleSqlEditForm.header_labels_str"
|
||||
class="w-full min-h-[100px] input-field p-3 text-xs leading-relaxed text-secondary font-mono focus:border-blue-300 focus:outline-none focus:ring-1 focus:ring-blue-200 resize-y"
|
||||
></textarea>
|
||||
</div>
|
||||
</template>
|
||||
|
||||
<!-- 外部API模式 -->
|
||||
<template v-if="admin.scheduleCreateForm.data_source_type === 'external_api'">
|
||||
<div>
|
||||
<label class="mb-1 block text-xs font-semibold text-muted uppercase">{{ $t('admin.schedule.form.apiUrl') }}</label>
|
||||
<input v-model="admin.scheduleSqlEditForm.api_url" class="w-full input-field px-3 py-2 text-sm text-secondary focus:border-blue-300 focus:outline-none focus:ring-1 focus:ring-blue-200" placeholder="https://api.example.com/endpoint" />
|
||||
</div>
|
||||
<div class="grid grid-cols-2 gap-3">
|
||||
<div>
|
||||
<label class="mb-1 block text-xs font-semibold text-muted uppercase">{{ $t('admin.schedule.form.apiMethod') }}</label>
|
||||
<select v-model="admin.scheduleSqlEditForm.api_method" class="w-full input-field px-3 py-2 text-sm text-secondary focus:border-blue-300 focus:outline-none focus:ring-1 focus:ring-blue-200">
|
||||
<option value="POST">POST</option>
|
||||
<option value="GET">GET</option>
|
||||
<option value="PUT">PUT</option>
|
||||
</select>
|
||||
</div>
|
||||
<div>
|
||||
<label class="mb-1 block text-xs font-semibold text-muted uppercase">{{ $t('admin.schedule.form.apiTimeoutSeconds') }}</label>
|
||||
<input type="number" :value="120" class="w-full input-field px-3 py-2 text-sm text-secondary focus:border-blue-300 focus:outline-none focus:ring-1 focus:ring-blue-200" disabled />
|
||||
</div>
|
||||
</div>
|
||||
<div>
|
||||
<label class="mb-1 block text-xs font-semibold text-muted uppercase">{{ $t('admin.schedule.form.apiHeaders') }}</label>
|
||||
<textarea
|
||||
v-model="admin.scheduleSqlEditForm.api_headers_str"
|
||||
class="w-full min-h-[60px] input-field p-3 text-xs leading-relaxed text-secondary font-mono focus:border-blue-300 focus:outline-none focus:ring-1 focus:ring-blue-200 resize-y"
|
||||
></textarea>
|
||||
</div>
|
||||
<div>
|
||||
<label class="mb-1 block text-xs font-semibold text-muted uppercase">{{ $t('admin.schedule.form.apiBodyTemplate') }}</label>
|
||||
<textarea
|
||||
v-model="admin.scheduleSqlEditForm.api_body_template"
|
||||
class="w-full min-h-[80px] input-field p-3 text-xs leading-relaxed text-secondary font-mono focus:border-blue-300 focus:outline-none focus:ring-1 focus:ring-blue-200 resize-y"
|
||||
></textarea>
|
||||
</div>
|
||||
</template>
|
||||
</div>
|
||||
|
||||
<!-- 平台任务参数区:完全由注册表 params_schema 决定,无任务级 v-if。
|
||||
外层仅按 schedule_type 判定(同步、必然为真),不依赖异步 definitions;
|
||||
定义解析完成前显示加载提示,完成后立即渲染 DynamicTaskParamsForm(含库存源)。 -->
|
||||
<div v-if="admin.scheduleCreateForm.schedule_type === 'platform_job'" class="mt-3">
|
||||
<DynamicTaskParamsForm
|
||||
v-if="admin.selectedPlatformTaskDefinition"
|
||||
:definition="admin.selectedPlatformTaskDefinition"
|
||||
:model-value="admin.scheduleCreateForm.job_params"
|
||||
:valid="admin.platformJobParamsValid"
|
||||
@update:model-value="admin.scheduleCreateForm.job_params = $event"
|
||||
@update:valid="admin.platformJobParamsValid = $event"
|
||||
/>
|
||||
<div v-else-if="admin.platformTaskDefinitionsLoading || admin.platformTaskDefinitionsError" class="space-y-2 rounded-xl border border-blue-200 bg-blue-50/40 px-4 py-3 text-sm text-muted">
|
||||
<p>{{ admin.platformTaskDefinitionsLoading
|
||||
? $t('admin.schedule.form.dynamicParamsLoading')
|
||||
: $t('admin.schedule.form.dynamicParamsLoadFailed') }}</p>
|
||||
<button
|
||||
v-if="admin.platformTaskDefinitionsError && !admin.platformTaskDefinitionsLoading"
|
||||
type="button"
|
||||
class="btn-secondary btn-sm"
|
||||
@click="admin.loadPlatformTaskDefinitions"
|
||||
>
|
||||
{{ $t('admin.schedule.form.dynamicParamsRetry') }}
|
||||
</button>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div v-if="admin.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">{{ $t('admin.schedule.testRun.queryResult') }}</h4>
|
||||
<div class="flex items-center gap-3">
|
||||
<span class="text-xs text-emerald-600">{{ $t('admin.schedule.testRun.resultSummary', { total: admin.scheduleTestResult.total, showing: admin.scheduleTestResult.showing }) }}</span>
|
||||
<button class="rounded-full p-1 text-emerald-400 transition hover:bg-emerald-100 hover:text-emerald-600" @click="admin.scheduleTestResult = null">✕</button>
|
||||
</div>
|
||||
</div>
|
||||
<div class="mb-2 overflow-x-auto rounded-xl border border-emerald-200 bg-surface">
|
||||
<table class="w-full text-xs">
|
||||
<thead class="bg-emerald-50">
|
||||
<tr>
|
||||
<th v-for="col in admin.scheduleTestResult.columns" :key="col" class="whitespace-nowrap px-3 py-2 text-left font-semibold text-emerald-800">{{ col }}</th>
|
||||
</tr>
|
||||
</thead>
|
||||
<tbody>
|
||||
<tr v-for="(row, ri) in admin.scheduleTestResult.rows" :key="ri" class="border-t border-emerald-100">
|
||||
<td v-for="col in admin.scheduleTestResult.columns" :key="col" class="whitespace-nowrap px-3 py-1.5 text-secondary">{{ row[col] }}</td>
|
||||
</tr>
|
||||
</tbody>
|
||||
</table>
|
||||
</div>
|
||||
<details class="mt-2">
|
||||
<summary class="cursor-pointer text-xs font-semibold text-emerald-700 hover:text-emerald-900">{{ $t('admin.schedule.testRun.viewGeneratedSql') }}</summary>
|
||||
<pre class="admin-pre-block admin-pre-block--sql">{{ admin.scheduleTestResult.sql }}</pre>
|
||||
</details>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div v-if="admin.scheduleCreateForm.schedule_type === 'data_pipeline'" class="grid grid-cols-1 gap-4 md:grid-cols-2">
|
||||
<div>
|
||||
<label class="mb-2 block text-sm font-medium text-secondary">{{ $t('admin.schedule.form.agentLabel') }}</label>
|
||||
<div class="relative">
|
||||
<select v-model="admin.scheduleCreateForm.dify_agent_id" class="input-field appearance-none pr-10 !text-sm !leading-5" :disabled="admin.agents.length === 0">
|
||||
<option :value="null">{{ admin.agents.length === 0 ? $t('admin.schedule.form.noAgents') : $t('admin.schedule.form.agentDisabled') }}</option>
|
||||
<option v-for="a in admin.agents" :key="a.id" :value="a.id">{{ a.name }}{{ $t('admin.schedule.form.agentOptionId', { 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">
|
||||
<svg class="h-4 w-4 text-muted" viewBox="0 0 20 20" fill="currentColor"><path fill-rule="evenodd" d="M5.23 7.21a.75.75 0 011.06.02L10 11.168l3.71-3.938a.75.75 0 111.08 1.04l-4.25 4.5a.75.75 0 01-1.08 0l-4.25-4.5a.75.75 0 01.02-1.06z" clip-rule="evenodd"/></svg>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<div>
|
||||
<label class="mb-2 block text-sm font-medium text-secondary">{{ $t('admin.schedule.form.waitSeconds') }}</label>
|
||||
<input v-model.number="admin.scheduleCreateForm.wait_seconds" type="number" min="0" class="input-field !text-sm !leading-5" placeholder="300" />
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div v-if="admin.scheduleCreateForm.schedule_type === 'data_pipeline'" class="rounded-2xl border border-emerald-200 bg-emerald-50/40 p-4">
|
||||
<label class="flex items-center gap-2 text-sm font-semibold text-secondary">
|
||||
<input v-model="admin.scheduleCreateForm.kb_sync_enabled" type="checkbox" class="h-4 w-4 rounded border-default text-emerald-600 focus:ring-emerald-300" />
|
||||
{{ $t('admin.schedule.form.kbSyncEnabled') }}
|
||||
</label>
|
||||
<p class="mt-1 text-xs text-muted">{{ $t('admin.schedule.form.kbSyncHint') }}</p>
|
||||
<div v-if="admin.scheduleCreateForm.kb_sync_enabled" class="mt-3">
|
||||
<label class="mb-2 block text-sm font-medium text-secondary">{{ $t('admin.schedule.form.kbGroup') }}</label>
|
||||
<select v-model="admin.scheduleCreateForm.kb_group_id" class="input-field !text-sm !leading-5" :disabled="admin.kbGroups.length === 0">
|
||||
<option :value="null">{{ admin.kbGroups.length === 0 ? $t('admin.schedule.form.noKbGroups') : $t('admin.schedule.form.selectKbGroup') }}</option>
|
||||
<option v-for="group in admin.kbGroups" :key="group.id" :value="group.id">{{ group.name }}</option>
|
||||
</select>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div v-if="admin.scheduleCreateForm.dify_agent_id" class="rounded-2xl border border-indigo-200 bg-indigo-50/40 p-4">
|
||||
<div class="mb-2">
|
||||
<label class="block text-sm font-medium text-secondary">{{ $t('admin.schedule.form.difySystemPrompt') }}</label>
|
||||
<p class="mt-1 text-xs text-muted">{{ $t('admin.schedule.form.difySystemPromptHint') }}</p>
|
||||
</div>
|
||||
<textarea
|
||||
v-model="admin.scheduleSqlEditForm.dify_system_prompt"
|
||||
class="input-field min-h-[140px] p-3 text-sm font-mono resize-y border-indigo-200"
|
||||
:placeholder="$t('admin.schedule.form.difySystemPromptPlaceholder')"
|
||||
></textarea>
|
||||
</div>
|
||||
|
||||
<ScheduleCronDesigner
|
||||
:designer="admin.cronDesigner"
|
||||
:format-date-time="admin.formatDateTime"
|
||||
/>
|
||||
|
||||
<div class="input-field px-3 py-2.5">
|
||||
<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-secondary">
|
||||
<input v-model="admin.scheduleCreateForm.notify_enabled" type="checkbox" class="h-4 w-4 rounded text-blue-600" />
|
||||
{{ $t('admin.schedule.form.notifyEnabled') }}
|
||||
</label>
|
||||
<div v-if="admin.scheduleCreateForm.notify_enabled" class="relative flex-1">
|
||||
<div
|
||||
class="min-h-[38px] input-field px-3 py-2 text-sm flex flex-wrap gap-1.5 items-center focus-within:border-blue-300 focus-within:ring-1 focus-within:ring-blue-200"
|
||||
>
|
||||
<span
|
||||
v-for="uid in admin.scheduleCreateForm.notify_user_ids_json"
|
||||
:key="uid"
|
||||
class="inline-flex items-center gap-1 rounded-lg bg-blue-50 px-2 py-0.5 text-xs font-medium text-blue-700"
|
||||
>
|
||||
{{ admin.getUserName(uid) }}
|
||||
<button
|
||||
type="button"
|
||||
class="ml-0.5 text-blue-400 hover:text-blue-600"
|
||||
@click.stop="admin.removeNotifyUser(uid)"
|
||||
>✕</button>
|
||||
</span>
|
||||
<input
|
||||
v-model="admin.scheduleNotifyUserQuery"
|
||||
type="text"
|
||||
class="min-w-[120px] flex-1 border-0 bg-transparent p-0 text-sm text-secondary outline-none focus:ring-0"
|
||||
:placeholder="$t('admin.schedule.form.selectNotifyUsers')"
|
||||
@focus="admin.scheduleNotifyDropdownOpen = true"
|
||||
@input="admin.scheduleNotifyDropdownOpen = true"
|
||||
@blur="admin.scheduleCloseNotifyDropdown"
|
||||
/>
|
||||
</div>
|
||||
<div
|
||||
v-if="admin.scheduleNotifyDropdownOpen"
|
||||
class="admin-dropdown max-h-60 w-full overflow-y-auto"
|
||||
>
|
||||
<button
|
||||
v-for="u in admin.filteredNotifyUsers"
|
||||
:key="u.id"
|
||||
type="button"
|
||||
class="flex w-full cursor-pointer items-center gap-2 px-3 py-2 text-left text-sm transition hover:bg-surface-soft"
|
||||
:class="admin.scheduleCreateForm.notify_user_ids_json.includes(u.id) ? 'bg-blue-50/50' : ''"
|
||||
@mousedown.prevent="admin.toggleNotifyUser(u.id)"
|
||||
>
|
||||
<input
|
||||
type="checkbox"
|
||||
class="pointer-events-none h-3.5 w-3.5 rounded text-blue-600"
|
||||
:checked="admin.scheduleCreateForm.notify_user_ids_json.includes(u.id)"
|
||||
tabindex="-1"
|
||||
readonly
|
||||
/>
|
||||
<span class="text-secondary">{{ u.real_name || u.username }}{{ u.employee_id ? '(' + u.employee_id + ')' : '' }}</span>
|
||||
</button>
|
||||
<div v-if="admin.filteredNotifyUsers.length === 0" class="px-3 py-2 text-sm text-muted">
|
||||
{{ $t('admin.wecom.noData') }}
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="rounded-2xl border border-default bg-surface-soft/40 px-4 py-3">
|
||||
<label class="inline-flex cursor-pointer items-center gap-2 text-sm text-secondary">
|
||||
<input v-model="admin.scheduleCreateForm.enabled" type="checkbox" class="admin-checkbox" />
|
||||
{{ $t('admin.schedule.form.enableOnCreate') }}
|
||||
</label>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="admin-modal-footer admin-modal-footer--muted relative z-10 pointer-events-auto justify-end gap-3 px-8 py-5">
|
||||
<button
|
||||
type="button"
|
||||
class="btn-secondary"
|
||||
@click="admin.closeScheduleCreateModal"
|
||||
>
|
||||
{{ $t('admin.schedule.form.cancel') }}
|
||||
</button>
|
||||
<button
|
||||
type="button"
|
||||
class="btn-primary inline-flex items-center gap-2 disabled:cursor-not-allowed disabled:opacity-60"
|
||||
:disabled="admin.scheduleCreateSaving || !admin.scheduleCreateForm.name || !admin.scheduleCreateForm.owner_user_id || !admin.cronDesigner.isValid"
|
||||
@click="admin.createSchedule"
|
||||
>
|
||||
<Plus class="h-4 w-4 shrink-0" />
|
||||
{{ admin.scheduleCreateSaving ? $t('admin.schedule.form.saving') : (admin.scheduleEditingId ? $t('admin.schedule.form.saveChanges') : $t('admin.schedule.form.createSchedule')) }}
|
||||
</button>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</Teleport>
|
||||
</template>
|
||||
+329
-132
@@ -1,153 +1,350 @@
|
||||
/**
|
||||
* features/admin/modules/schedules/components/ScheduleOverviewPanel.vue
|
||||
* 定时任务概览模式:统计卡片与任务卡片网格。
|
||||
* 依赖:schedules.context、lucide-vue-next。
|
||||
* 逻辑:inject admin;展示 schedules 列表与快捷操作。
|
||||
* 用途:排程管理概览——紧凑统计条 + 筛选 + ElTable + 前端分页 + 批量启停。
|
||||
* 依赖:schedules.context、Element Plus、ScheduleTask。
|
||||
* 逻辑:全量 schedules 前端过滤/排序/分页;行点击进工作台;操作列 stop 冒泡。
|
||||
*/
|
||||
<script setup lang="ts">
|
||||
import { Edit3, FlaskConical, Plus, Power, PowerOff, Rocket, Settings2, Trash2 } from 'lucide-vue-next';
|
||||
import { computed, ref, watch } from 'vue';
|
||||
import { useI18n } from 'vue-i18n';
|
||||
import { Search } from '@element-plus/icons-vue';
|
||||
import {
|
||||
ElButton,
|
||||
ElInput,
|
||||
ElLoading,
|
||||
ElOption,
|
||||
ElPagination,
|
||||
ElSelect,
|
||||
ElSpace,
|
||||
ElTable,
|
||||
ElTableColumn,
|
||||
ElTag,
|
||||
} from 'element-plus';
|
||||
import type { ScheduleTask } from '@/shared/types/schedule.types';
|
||||
import { useSchedulesAdminContext } from '../composables/schedules.context';
|
||||
|
||||
const vLoading = ElLoading.directive;
|
||||
const { t } = useI18n();
|
||||
const admin = useSchedulesAdminContext();
|
||||
|
||||
type StatusFilter = 'all' | 'enabled' | 'disabled';
|
||||
type TypeFilter = 'all' | 'data_pipeline' | 'platform_job';
|
||||
type SortKey = 'name' | 'last_run_at' | 'next_run_at' | '';
|
||||
|
||||
const searchKeyword = ref('');
|
||||
const statusFilter = ref<StatusFilter>('all');
|
||||
const typeFilter = ref<TypeFilter>('all');
|
||||
const sortKey = ref<SortKey>('name');
|
||||
const sortDir = ref<'asc' | 'desc'>('asc');
|
||||
const currentPage = ref(1);
|
||||
const pageSize = ref(20);
|
||||
const pageSizeOptions = [10, 20, 50, 100];
|
||||
const selectedRows = ref<ScheduleTask[]>([]);
|
||||
const bulkBusy = ref(false);
|
||||
|
||||
/**
|
||||
* 按关键词/状态/类型过滤后的排程列表,再按当前排序键排序。
|
||||
*/
|
||||
const filteredSchedules = computed(() => {
|
||||
const keyword = searchKeyword.value.trim().toLowerCase();
|
||||
const matched = admin.schedules.filter((item) => {
|
||||
const haystack = `${item.name} ${item.schedule_no} ${item.cron_expr} ${item.owner_username || ''}`.toLowerCase();
|
||||
const matchesKeyword = !keyword || haystack.includes(keyword);
|
||||
const matchesStatus = statusFilter.value === 'all'
|
||||
|| (statusFilter.value === 'enabled' && item.enabled)
|
||||
|| (statusFilter.value === 'disabled' && !item.enabled);
|
||||
const matchesType = typeFilter.value === 'all' || item.schedule_type === typeFilter.value;
|
||||
return matchesKeyword && matchesStatus && matchesType;
|
||||
});
|
||||
|
||||
if (!sortKey.value) return matched;
|
||||
return [...matched].sort((a, b) => {
|
||||
let result = 0;
|
||||
if (sortKey.value === 'name') {
|
||||
result = a.name.localeCompare(b.name, undefined, { numeric: true });
|
||||
} else if (sortKey.value === 'last_run_at') {
|
||||
result = (Date.parse(a.last_run_at || '') || 0) - (Date.parse(b.last_run_at || '') || 0);
|
||||
} else {
|
||||
result = (Date.parse(a.next_run_at || '') || 0) - (Date.parse(b.next_run_at || '') || 0);
|
||||
}
|
||||
return sortDir.value === 'asc' ? result : -result;
|
||||
});
|
||||
});
|
||||
|
||||
const pagedSchedules = computed(() => {
|
||||
const start = (currentPage.value - 1) * pageSize.value;
|
||||
return filteredSchedules.value.slice(start, start + pageSize.value);
|
||||
});
|
||||
|
||||
const tableEmptyText = computed(() => (
|
||||
admin.schedules.length === 0 ? t('admin.schedule.emptyList') : t('admin.schedule.filters.emptyResult')
|
||||
));
|
||||
|
||||
watch([searchKeyword, statusFilter, typeFilter], () => {
|
||||
currentPage.value = 1;
|
||||
});
|
||||
|
||||
/**
|
||||
* 同步表格勾选行,供批量启停使用。
|
||||
* @param rows - 当前选中的排程行
|
||||
*/
|
||||
function onSelectionChange(rows: ScheduleTask[]): void {
|
||||
selectedRows.value = rows;
|
||||
}
|
||||
|
||||
/**
|
||||
* 表头自定义排序写回本地 sortKey/sortDir。
|
||||
* @param payload - Element sort-change 载荷
|
||||
*/
|
||||
function onSortChange(payload: { prop: string | null; order: string | null }): void {
|
||||
const prop = payload.prop;
|
||||
if (prop === 'name' || prop === 'last_run_at' || prop === 'next_run_at') {
|
||||
sortKey.value = payload.order ? prop : '';
|
||||
sortDir.value = payload.order === 'ascending' ? 'asc' : 'desc';
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 行点击进入工作台(操作列需 stop 冒泡)。
|
||||
* @param row - 被点击的排程
|
||||
*/
|
||||
function onRowClick(row: ScheduleTask): void {
|
||||
void admin.openScheduleRunSubmenu(row.id);
|
||||
}
|
||||
|
||||
/**
|
||||
* 批量将选中排程设为启用或停用。
|
||||
* @param enabled - true 启用,false 停用
|
||||
*/
|
||||
async function bulkSetEnabled(enabled: boolean): Promise<void> {
|
||||
if (selectedRows.value.length === 0 || bulkBusy.value) return;
|
||||
bulkBusy.value = true;
|
||||
try {
|
||||
for (const row of selectedRows.value) {
|
||||
if (row.enabled !== enabled) {
|
||||
await admin.setScheduleEnabled(row.id, enabled);
|
||||
}
|
||||
}
|
||||
selectedRows.value = [];
|
||||
} finally {
|
||||
bulkBusy.value = false;
|
||||
}
|
||||
}
|
||||
|
||||
</script>
|
||||
|
||||
<template>
|
||||
<div class="admin-panel-lg p-6 shadow-sm">
|
||||
<div class="mb-5 grid grid-cols-1 gap-3 md:grid-cols-2 xl:grid-cols-4">
|
||||
<div class="admin-stat-tile px-4 py-3">
|
||||
<div class="text-xl font-bold text-primary">{{ admin.schedules.length }}</div>
|
||||
<div class="text-sm text-muted">{{ $t('admin.schedule.stats.total') }}</div>
|
||||
<div>
|
||||
<div class="schedule-stats-bar">
|
||||
<div class="schedule-stat">
|
||||
<span class="schedule-stat__value">{{ admin.schedules.length }}</span>
|
||||
<span class="schedule-stat__label">{{ t('admin.schedule.stats.total') }}</span>
|
||||
</div>
|
||||
<div class="admin-stat-tile px-4 py-3">
|
||||
<div class="text-xl font-bold text-primary">{{ admin.scheduleEnabledCount }}</div>
|
||||
<div class="text-sm text-muted">{{ $t('admin.schedule.stats.enabled') }}</div>
|
||||
<div class="schedule-stat">
|
||||
<span class="schedule-stat__value">{{ admin.scheduleEnabledCount }}</span>
|
||||
<span class="schedule-stat__label">{{ t('admin.schedule.stats.enabled') }}</span>
|
||||
</div>
|
||||
<div class="admin-stat-tile px-4 py-3">
|
||||
<div class="text-xl font-bold text-primary">{{ admin.scheduleDisabledCount }}</div>
|
||||
<div class="text-sm text-muted">{{ $t('admin.schedule.stats.disabled') }}</div>
|
||||
<div class="schedule-stat">
|
||||
<span class="schedule-stat__value">{{ admin.scheduleDisabledCount }}</span>
|
||||
<span class="schedule-stat__label">{{ t('admin.schedule.stats.disabled') }}</span>
|
||||
</div>
|
||||
<div class="admin-stat-tile px-4 py-3">
|
||||
<div class="text-xl font-bold text-primary">{{ admin.scheduleRunningCount }}</div>
|
||||
<div class="text-sm text-muted">{{ $t('admin.schedule.stats.running') }}</div>
|
||||
<div class="schedule-stat">
|
||||
<span class="schedule-stat__value">{{ admin.scheduleRunningCount }}</span>
|
||||
<span class="schedule-stat__label">{{ t('admin.schedule.stats.running') }}</span>
|
||||
</div>
|
||||
</div>
|
||||
<div class="admin-panel p-4">
|
||||
<div class="mb-3 flex items-center justify-between">
|
||||
<h4 class="text-lg font-bold text-primary">{{ $t('admin.schedule.sectionOverview') }}</h4>
|
||||
<span class="text-xs text-muted">{{ $t('admin.schedule.switchByCard') }}</span>
|
||||
</div>
|
||||
<div v-if="admin.scheduleLoading" class="py-8 text-center text-sm text-muted">{{ $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="admin-panel 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-primary">{{ $t('admin.schedule.addTitle') }}</div>
|
||||
</div>
|
||||
<div class="text-sm text-muted">
|
||||
{{ $t('admin.schedule.addHint') }}
|
||||
</div>
|
||||
<div class="mt-auto pt-3">
|
||||
<button
|
||||
@click="admin.openScheduleCreateModal"
|
||||
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>
|
||||
|
||||
<div
|
||||
v-for="s in admin.schedules"
|
||||
:key="s.id"
|
||||
class="flex h-full min-h-[260px] flex-col admin-panel p-4 transition hover:border-blue-200 hover:bg-surface-soft"
|
||||
>
|
||||
<div
|
||||
class="w-full shrink-0 cursor-pointer rounded-lg text-left outline-none focus-visible:ring-2 focus-visible:ring-brand-400"
|
||||
role="button"
|
||||
tabindex="0"
|
||||
@click="admin.openScheduleRunSubmenu(s.id)"
|
||||
@keydown.enter.prevent="admin.openScheduleRunSubmenu(s.id)"
|
||||
@keydown.space.prevent="admin.openScheduleRunSubmenu(s.id)"
|
||||
>
|
||||
<div class="min-h-[96px]">
|
||||
<div class="flex items-start justify-between gap-3">
|
||||
<div class="min-w-0">
|
||||
<div class="truncate text-base font-semibold text-primary">{{ s.name }}</div>
|
||||
<div class="mt-0.5 truncate text-xs text-muted" :title="s.schedule_no">{{ s.schedule_no }}</div>
|
||||
</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-surface-strong text-secondary'">
|
||||
{{ s.enabled ? $t('admin.schedule.enabled') : $t('admin.schedule.disabled') }}
|
||||
</span>
|
||||
</div>
|
||||
<div class="mt-2 text-sm text-muted">Cron:{{ s.cron_expr }}</div>
|
||||
<div class="mt-1 text-sm text-muted">{{ $t('admin.schedule.owner') }}:{{ s.owner_username || s.owner_user_id }}</div>
|
||||
</div>
|
||||
<div class="schedule-filters">
|
||||
<ElInput
|
||||
v-model="searchKeyword"
|
||||
clearable
|
||||
:prefix-icon="Search"
|
||||
class="schedule-filter-search"
|
||||
:placeholder="t('admin.schedule.filters.searchPlaceholder')"
|
||||
/>
|
||||
<ElSelect v-model="statusFilter" class="schedule-filter-select" :placeholder="t('admin.schedule.filters.statusAll')">
|
||||
<ElOption :label="t('admin.schedule.filters.statusAll')" value="all" />
|
||||
<ElOption :label="t('admin.schedule.enabled')" value="enabled" />
|
||||
<ElOption :label="t('admin.schedule.disabled')" value="disabled" />
|
||||
</ElSelect>
|
||||
<ElSelect v-model="typeFilter" class="schedule-filter-select" :placeholder="t('admin.schedule.filters.typeAll')">
|
||||
<ElOption :label="t('admin.schedule.filters.typeAll')" value="all" />
|
||||
<ElOption :label="t('admin.schedule.form.scheduleTypeDataPipeline')" value="data_pipeline" />
|
||||
<ElOption :label="t('admin.schedule.form.scheduleTypePlatformJob')" value="platform_job" />
|
||||
</ElSelect>
|
||||
<ElSpace v-if="selectedRows.length > 0" wrap>
|
||||
<ElButton :loading="bulkBusy" @click="() => void bulkSetEnabled(true)">
|
||||
{{ t('admin.schedule.bulk.enable') }} ({{ selectedRows.length }})
|
||||
</ElButton>
|
||||
<ElButton :loading="bulkBusy" @click="() => void bulkSetEnabled(false)">
|
||||
{{ t('admin.schedule.bulk.disable') }} ({{ selectedRows.length }})
|
||||
</ElButton>
|
||||
</ElSpace>
|
||||
</div>
|
||||
|
||||
<ElTable
|
||||
v-loading="admin.scheduleLoading"
|
||||
class="hx-admin-table"
|
||||
:data="pagedSchedules"
|
||||
row-key="id"
|
||||
:default-sort="{ prop: 'name', order: 'ascending' }"
|
||||
:empty-text="tableEmptyText"
|
||||
highlight-current-row
|
||||
@selection-change="onSelectionChange"
|
||||
@sort-change="onSortChange"
|
||||
@row-click="onRowClick"
|
||||
>
|
||||
<ElTableColumn type="selection" width="48" reserve-selection />
|
||||
<ElTableColumn prop="name" :label="t('admin.schedule.table.name')" min-width="160" sortable="custom">
|
||||
<template #default="{ row }">
|
||||
<div class="truncate font-medium text-primary" :title="(row as ScheduleTask).name">
|
||||
{{ (row as ScheduleTask).name }}
|
||||
</div>
|
||||
<div class="relative z-10 mt-auto shrink-0 pt-3" @click.stop>
|
||||
<div class="mb-1 text-sm text-muted">
|
||||
{{ $t('admin.schedule.lastRun') }}:{{ admin.formatDateTime(s.last_run_at) }}
|
||||
</div>
|
||||
<div class="mb-3 text-sm text-muted">
|
||||
{{ $t('admin.schedule.nextRun') }}:{{ admin.formatDateTime(s.next_run_at) }}
|
||||
</div>
|
||||
<div class="flex flex-wrap items-center gap-2">
|
||||
<button
|
||||
type="button"
|
||||
class="inline-flex items-center gap-1 rounded-xl border border-default px-3 py-2 text-xs font-medium text-secondary transition-colors hover:bg-surface-soft"
|
||||
@click="admin.openScheduleEditModal(s)"
|
||||
>
|
||||
<Edit3 class="h-3.5 w-3.5" />
|
||||
{{ $t('admin.schedule.actions.edit') }}
|
||||
</button>
|
||||
<button
|
||||
v-if="!s.enabled"
|
||||
class="inline-flex items-center gap-1 rounded-xl border border-emerald-200 px-3 py-2 text-xs font-medium text-emerald-700 transition-colors hover:bg-emerald-50"
|
||||
@click.stop="admin.setScheduleEnabled(s.id, true)"
|
||||
>
|
||||
<Power class="h-3.5 w-3.5" />
|
||||
{{ $t('admin.schedule.actions.start') }}
|
||||
</button>
|
||||
<button
|
||||
v-else
|
||||
class="inline-flex items-center gap-1 rounded-xl border border-amber-200 px-3 py-2 text-xs font-medium text-amber-700 transition-colors hover:bg-amber-50"
|
||||
@click.stop="admin.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="admin.runScheduleNow(s.id)"
|
||||
>
|
||||
<Rocket class="h-3.5 w-3.5" />
|
||||
{{ $t('admin.schedule.actions.run') }}
|
||||
</button>
|
||||
<button
|
||||
v-if="s.schedule_type === 'data_pipeline' && s.data_source_type === 'database'"
|
||||
class="inline-flex items-center gap-1 rounded-xl border border-violet-200 px-3 py-2 text-xs font-medium text-violet-700 transition-colors hover:bg-violet-50"
|
||||
@click.stop="admin.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="admin.deleteSchedule(s)"
|
||||
>
|
||||
<Trash2 class="h-3.5 w-3.5" />
|
||||
{{ $t('admin.schedule.actions.delete') }}
|
||||
</button>
|
||||
</div>
|
||||
</template>
|
||||
</ElTableColumn>
|
||||
<ElTableColumn prop="schedule_no" :label="t('admin.schedule.scheduleNo')" min-width="140">
|
||||
<template #default="{ row }">
|
||||
<span class="truncate text-muted" :title="(row as ScheduleTask).schedule_no">
|
||||
{{ (row as ScheduleTask).schedule_no }}
|
||||
</span>
|
||||
</template>
|
||||
</ElTableColumn>
|
||||
<ElTableColumn :label="t('admin.schedule.table.status')" width="100">
|
||||
<template #default="{ row }">
|
||||
<ElTag :type="(row as ScheduleTask).enabled ? 'success' : 'info'" effect="light" size="small">
|
||||
{{ (row as ScheduleTask).enabled ? t('admin.schedule.enabled') : t('admin.schedule.disabled') }}
|
||||
</ElTag>
|
||||
</template>
|
||||
</ElTableColumn>
|
||||
<ElTableColumn prop="cron_expr" :label="t('admin.schedule.table.cron')" min-width="120">
|
||||
<template #default="{ row }">
|
||||
<code class="schedule-cron">{{ (row as ScheduleTask).cron_expr }}</code>
|
||||
</template>
|
||||
</ElTableColumn>
|
||||
<ElTableColumn :label="t('admin.schedule.owner')" min-width="100">
|
||||
<template #default="{ row }">
|
||||
{{ (row as ScheduleTask).owner_username || (row as ScheduleTask).owner_user_id }}
|
||||
</template>
|
||||
</ElTableColumn>
|
||||
<ElTableColumn prop="last_run_at" :label="t('admin.schedule.lastRun')" min-width="160" sortable="custom">
|
||||
<template #default="{ row }">{{ admin.formatDateTime((row as ScheduleTask).last_run_at) }}</template>
|
||||
</ElTableColumn>
|
||||
<ElTableColumn prop="next_run_at" :label="t('admin.schedule.nextRun')" min-width="160" sortable="custom">
|
||||
<template #default="{ row }">{{ admin.formatDateTime((row as ScheduleTask).next_run_at) }}</template>
|
||||
</ElTableColumn>
|
||||
<ElTableColumn :label="t('admin.schedule.table.actions')" width="280" align="right" fixed="right">
|
||||
<template #default="{ row }">
|
||||
<div class="schedule-row-actions" @click.stop>
|
||||
<ElButton link type="primary" @click="admin.openScheduleEditModal(row as ScheduleTask)">
|
||||
{{ t('admin.schedule.actions.edit') }}
|
||||
</ElButton>
|
||||
<ElButton
|
||||
v-if="!(row as ScheduleTask).enabled"
|
||||
link
|
||||
type="success"
|
||||
@click="() => void admin.setScheduleEnabled((row as ScheduleTask).id, true)"
|
||||
>
|
||||
{{ t('admin.schedule.actions.start') }}
|
||||
</ElButton>
|
||||
<ElButton
|
||||
v-else
|
||||
link
|
||||
type="warning"
|
||||
@click="() => void admin.setScheduleEnabled((row as ScheduleTask).id, false)"
|
||||
>
|
||||
{{ t('admin.schedule.actions.pause') }}
|
||||
</ElButton>
|
||||
<ElButton link type="primary" @click="() => void admin.runScheduleNow((row as ScheduleTask).id)">
|
||||
{{ t('admin.schedule.actions.run') }}
|
||||
</ElButton>
|
||||
<ElButton
|
||||
v-if="(row as ScheduleTask).schedule_type === 'data_pipeline' && (row as ScheduleTask).data_source_type === 'database'"
|
||||
link
|
||||
type="primary"
|
||||
@click="admin.openTestRunDialog(row as ScheduleTask)"
|
||||
>
|
||||
{{ t('admin.schedule.actions.test') }}
|
||||
</ElButton>
|
||||
<ElButton link type="danger" @click="() => void admin.deleteSchedule(row as ScheduleTask)">
|
||||
{{ t('admin.schedule.actions.delete') }}
|
||||
</ElButton>
|
||||
</div>
|
||||
</div>
|
||||
<div v-if="admin.schedules.length === 0" class="rounded-xl border border-dashed border-default px-4 py-6 text-center text-sm text-muted">
|
||||
{{ $t('admin.schedule.emptyList') }}
|
||||
</div>
|
||||
</div>
|
||||
</template>
|
||||
</ElTableColumn>
|
||||
</ElTable>
|
||||
|
||||
<div v-if="filteredSchedules.length > 0" class="hx-admin-pager">
|
||||
<ElPagination
|
||||
v-model:current-page="currentPage"
|
||||
v-model:page-size="pageSize"
|
||||
:total="filteredSchedules.length"
|
||||
:page-sizes="pageSizeOptions"
|
||||
layout="total, sizes, prev, pager, next"
|
||||
background
|
||||
/>
|
||||
</div>
|
||||
</div>
|
||||
</template>
|
||||
|
||||
<style scoped>
|
||||
.schedule-stats-bar {
|
||||
display: flex;
|
||||
flex-wrap: wrap;
|
||||
gap: 16px 32px;
|
||||
padding: 12px 32px;
|
||||
border-bottom: 1px solid var(--el-border-color-lighter);
|
||||
}
|
||||
|
||||
.schedule-stat {
|
||||
display: inline-flex;
|
||||
align-items: baseline;
|
||||
gap: 8px;
|
||||
}
|
||||
|
||||
.schedule-stat__value {
|
||||
font-size: 1.125rem;
|
||||
font-weight: 700;
|
||||
color: var(--el-text-color-primary);
|
||||
}
|
||||
|
||||
.schedule-stat__label {
|
||||
font-size: 0.8125rem;
|
||||
color: var(--el-text-color-secondary);
|
||||
}
|
||||
|
||||
.schedule-filters {
|
||||
display: flex;
|
||||
flex-wrap: wrap;
|
||||
align-items: center;
|
||||
gap: 12px;
|
||||
padding: 16px 32px;
|
||||
border-bottom: 1px solid var(--el-border-color-lighter);
|
||||
}
|
||||
|
||||
.schedule-filter-search {
|
||||
width: 16rem;
|
||||
}
|
||||
|
||||
.schedule-filter-select {
|
||||
width: 10rem;
|
||||
}
|
||||
|
||||
.schedule-cron {
|
||||
font-family: ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, monospace;
|
||||
font-size: 0.75rem;
|
||||
}
|
||||
|
||||
.schedule-row-actions {
|
||||
display: inline-flex;
|
||||
flex-wrap: nowrap;
|
||||
align-items: center;
|
||||
justify-content: flex-end;
|
||||
gap: 0;
|
||||
white-space: nowrap;
|
||||
}
|
||||
|
||||
.schedule-row-actions :deep(.el-button) {
|
||||
margin-left: 0;
|
||||
padding: 0 6px;
|
||||
}
|
||||
</style>
|
||||
@@ -1,46 +1,57 @@
|
||||
/**
|
||||
* features/admin/modules/schedules/components/SchedulePageHeader.vue
|
||||
* 定时任务页顶栏:返回、标题、刷新。
|
||||
* 依赖:schedules.context、lucide-vue-next。
|
||||
* 逻辑:inject admin 上下文;概览/工作台模式切换标题与返回按钮。
|
||||
* 用途:排程管理页表头(KB 式 admin-table-header)。
|
||||
* 依赖:schedules.context、Element Plus、@element-plus/icons-vue。
|
||||
* 逻辑:概览显示刷新/新增;工作台显示返回/刷新;由 SchedulesPage 包在 admin-table-section 内。
|
||||
*/
|
||||
<script setup lang="ts">
|
||||
import { ArrowLeft, RefreshCw, Settings2 } from 'lucide-vue-next';
|
||||
import { computed } from 'vue';
|
||||
import { useI18n } from 'vue-i18n';
|
||||
import { ArrowLeft, Plus, Refresh } from '@element-plus/icons-vue';
|
||||
import { ElButton, ElSpace } from 'element-plus';
|
||||
import { useSchedulesAdminContext } from '../composables/schedules.context';
|
||||
|
||||
const { t } = useI18n();
|
||||
const admin = useSchedulesAdminContext();
|
||||
|
||||
const isWorkbench = computed(() => admin.scheduleViewMode === 'workbench');
|
||||
const title = computed(() => (
|
||||
isWorkbench.value ? t('admin.schedule.workbenchTitle') : t('admin.schedule.overviewTitle')
|
||||
));
|
||||
const subtitle = computed(() => (
|
||||
isWorkbench.value ? t('admin.schedule.workbenchSubtitle') : t('admin.schedule.overviewSubtitle')
|
||||
));
|
||||
</script>
|
||||
|
||||
<template>
|
||||
<div class="admin-panel-lg px-7 py-6 shadow-sm">
|
||||
<div class="flex flex-col gap-4 md:flex-row md:items-center md:justify-between">
|
||||
<div class="flex items-start gap-4">
|
||||
<button
|
||||
v-if="admin.scheduleViewMode === 'workbench'"
|
||||
class="inline-flex h-14 w-14 items-center justify-center admin-panel text-muted transition hover:bg-surface-soft hover:text-secondary"
|
||||
<div class="admin-table-header admin-table-header--stacked">
|
||||
<div class="min-w-0 flex-1">
|
||||
<div class="flex items-start gap-3">
|
||||
<ElButton
|
||||
v-if="isWorkbench"
|
||||
:icon="ArrowLeft"
|
||||
circle
|
||||
:aria-label="t('admin.schedule.backToOverview')"
|
||||
@click="admin.backToScheduleOverview"
|
||||
>
|
||||
<ArrowLeft class="h-7 w-7" />
|
||||
</button>
|
||||
<div class="flex h-14 w-14 items-center justify-center rounded-2xl bg-blue-50 text-blue-600">
|
||||
<Settings2 class="h-7 w-7" />
|
||||
</div>
|
||||
<div>
|
||||
<h2 class="text-2xl font-bold tracking-tight text-primary">
|
||||
{{ admin.scheduleViewMode === 'overview' ? $t('admin.schedule.overviewTitle') : $t('admin.schedule.workbenchTitle') }}
|
||||
</h2>
|
||||
<p class="mt-1.5 text-sm text-muted">
|
||||
{{ admin.scheduleViewMode === 'overview' ? $t('admin.schedule.overviewSubtitle') : $t('admin.schedule.workbenchSubtitle') }}
|
||||
</p>
|
||||
/>
|
||||
<div class="min-w-0">
|
||||
<h2 class="section-title">{{ title }}</h2>
|
||||
<p class="section-desc mt-1">{{ subtitle }}</p>
|
||||
</div>
|
||||
</div>
|
||||
<button
|
||||
class="inline-flex items-center gap-2 admin-panel px-5 py-2.5 text-sm font-semibold text-secondary transition hover:bg-surface-soft"
|
||||
@click="() => void admin.loadSchedules()"
|
||||
>
|
||||
<RefreshCw class="h-5 w-5" />
|
||||
{{ $t('admin.schedule.refresh') }}
|
||||
</button>
|
||||
</div>
|
||||
<ElSpace wrap>
|
||||
<ElButton :icon="Refresh" @click="() => void admin.loadSchedules()">
|
||||
{{ t('admin.schedule.refresh') }}
|
||||
</ElButton>
|
||||
<ElButton
|
||||
v-if="!isWorkbench"
|
||||
type="primary"
|
||||
:icon="Plus"
|
||||
@click="admin.openScheduleCreateModal"
|
||||
>
|
||||
{{ t('admin.schedule.addButton') }}
|
||||
</ElButton>
|
||||
</ElSpace>
|
||||
</div>
|
||||
</template>
|
||||
+15
-5
@@ -1,23 +1,23 @@
|
||||
/**
|
||||
* features/admin/modules/schedules/components/ScheduleWorkbenchPanel.spec.ts
|
||||
* 用途:断言执行记录页不默认展示原始库存/收料下载;仅企微深链 raw_zip=1 时突出下载入口。
|
||||
* 用途:断言执行记录页不默认展示原始库存/收料下载;仅企微深链 raw_zip=1 时突出下载入口;
|
||||
* 方案 C 无左侧排程列表,使用 ElSelect 切换任务。
|
||||
*/
|
||||
import { readFileSync } from 'node:fs';
|
||||
import { resolve } from 'node:path';
|
||||
import { describe, expect, it } from 'vitest';
|
||||
|
||||
describe('ScheduleWorkbenchPanel run table actions', () => {
|
||||
const panelPath = resolve(__dirname, 'ScheduleWorkbenchPanel.vue');
|
||||
const content = readFileSync(panelPath, 'utf8');
|
||||
|
||||
it('does not render raw inventory zip download in the run table column', () => {
|
||||
const panelPath = resolve(__dirname, 'ScheduleWorkbenchPanel.vue');
|
||||
const content = readFileSync(panelPath, 'utf8');
|
||||
expect(content).not.toMatch(/downloadScheduleInventoryRawZip\(r\.id\)/);
|
||||
expect(content).not.toMatch(/downloadScheduleInboundRawZip\(r\.id\)/);
|
||||
expect(content).not.toMatch(/downloadScheduleOutboundRawZip\(r\.id\)/);
|
||||
});
|
||||
|
||||
it('only shows raw inventory/inbound/outbound download when wecom deep link prompt is active', () => {
|
||||
const panelPath = resolve(__dirname, 'ScheduleWorkbenchPanel.vue');
|
||||
const content = readFileSync(panelPath, 'utf8');
|
||||
expect(content).toMatch(/wecomRawZipPromptRunId/);
|
||||
expect(content).not.toMatch(/v-if="admin\.expandedScheduleRun\.inventory_raw_zip_available"/);
|
||||
expect(content).not.toMatch(/v-if="admin\.expandedScheduleRun\.inbound_raw_zip_available"/);
|
||||
@@ -26,4 +26,14 @@ describe('ScheduleWorkbenchPanel run table actions', () => {
|
||||
expect(content).toMatch(/downloadScheduleInboundRawZip/);
|
||||
expect(content).toMatch(/downloadScheduleOutboundRawZip/);
|
||||
});
|
||||
|
||||
it('uses scheme C full-width layout without left schedule card list', () => {
|
||||
// 无左侧卡片式排程列表(旧 workbench-* 卡片循环)
|
||||
expect(content).not.toMatch(/workbench-\$\{s\.id\}/);
|
||||
expect(content).not.toMatch(/lg:grid-cols-\[320px/);
|
||||
// 顶栏 ElSelect 切换任务
|
||||
expect(content).toMatch(/ElSelect/);
|
||||
expect(content).toMatch(/selectedIdModel/);
|
||||
expect(content).toMatch(/admin\.schedule\.currentTask/);
|
||||
});
|
||||
});
|
||||
+534
-415
@@ -1,441 +1,560 @@
|
||||
/**
|
||||
* features/admin/modules/schedules/components/ScheduleWorkbenchPanel.vue
|
||||
* 定时任务工作台模式:侧边任务列表与运行记录表格。
|
||||
* 依赖:schedules.context、lucide-vue-next。
|
||||
* 逻辑:inject admin;筛选/查询运行记录、展开日志详情。
|
||||
* 用途:排程工作台方案 C——无左栏;顶栏 ElSelect 切换任务;全宽执行记录。
|
||||
* 依赖:schedules.context、Element Plus、lucide-vue-next(展开区图标)。
|
||||
* 逻辑:选中任务上下文条 + 紧凑指标 + 筛选 + 运行表;保留企微 raw zip 深链提示。
|
||||
*/
|
||||
<script setup lang="ts">
|
||||
import { computed } from 'vue';
|
||||
import { useI18n } from 'vue-i18n';
|
||||
import {
|
||||
ChevronDown, ChevronUp, Download, Edit3, Eye, FlaskConical, Power, PowerOff, Rocket, Trash2,
|
||||
ChevronDown, ChevronUp, Download, Eye,
|
||||
} from 'lucide-vue-next';
|
||||
import {
|
||||
ElButton,
|
||||
ElDatePicker,
|
||||
ElOption,
|
||||
ElSelect,
|
||||
ElSpace,
|
||||
ElTag,
|
||||
} from 'element-plus';
|
||||
import { useSchedulesAdminContext } from '../composables/schedules.context';
|
||||
|
||||
const { t } = useI18n();
|
||||
const admin = useSchedulesAdminContext();
|
||||
|
||||
const selectedIdModel = computed({
|
||||
get: () => admin.selectedScheduleId,
|
||||
set: (id: number | null) => {
|
||||
if (id != null) void admin.viewScheduleRuns(id);
|
||||
},
|
||||
});
|
||||
|
||||
const skippedMetricLabel = computed(() => {
|
||||
if (admin.isInboundRpaSchedule) return t('admin.schedule.totalSkippedReceipt');
|
||||
if (admin.isOutboundRpaSchedule) return t('admin.schedule.totalSkippedOutbound');
|
||||
if (admin.isInventoryRpaSchedule) return t('admin.schedule.totalSkippedInventory');
|
||||
return t('admin.schedule.totalSkipped');
|
||||
});
|
||||
|
||||
/**
|
||||
* 顶栏切换排程时的 option 展示文案。
|
||||
* @param name - 排程名称
|
||||
* @param scheduleNo - 排程编号
|
||||
*/
|
||||
function scheduleOptionLabel(name: string, scheduleNo: string): string {
|
||||
return `${name} · ${scheduleNo}`;
|
||||
}
|
||||
</script>
|
||||
|
||||
<template>
|
||||
<div class="space-y-6">
|
||||
<div class="grid grid-cols-2 gap-3 admin-panel-lg p-4 shadow-sm md:grid-cols-4 xl:grid-cols-8">
|
||||
<div class="col-span-2 admin-stat-tile px-4 py-3 xl:col-span-3">
|
||||
<div class="truncate text-base font-semibold text-primary">{{ admin.selectedSchedule?.name || $t('admin.schedule.noSelection') }}</div>
|
||||
<div class="mt-1 text-xs text-muted">{{ $t('admin.schedule.selectedHint', { time: admin.selectedScheduleLatestRunAt }) }}</div>
|
||||
<div class="schedule-workbench">
|
||||
<div class="schedule-workbench__context">
|
||||
<div class="schedule-workbench__switcher">
|
||||
<span class="schedule-workbench__label">{{ t('admin.schedule.currentTask') }}</span>
|
||||
<ElSelect
|
||||
v-model="selectedIdModel"
|
||||
filterable
|
||||
class="schedule-workbench__select"
|
||||
:placeholder="t('admin.schedule.noSelection')"
|
||||
>
|
||||
<ElOption
|
||||
v-for="s in admin.schedules"
|
||||
:key="s.id"
|
||||
:label="scheduleOptionLabel(s.name, s.schedule_no)"
|
||||
:value="s.id"
|
||||
/>
|
||||
</ElSelect>
|
||||
<template v-if="admin.selectedSchedule">
|
||||
<ElTag
|
||||
:type="admin.selectedSchedule.enabled ? 'success' : 'info'"
|
||||
effect="light"
|
||||
size="small"
|
||||
>
|
||||
{{ admin.selectedSchedule.enabled ? t('admin.schedule.enabled') : t('admin.schedule.disabled') }}
|
||||
</ElTag>
|
||||
<code class="schedule-cron">{{ admin.selectedSchedule.cron_expr }}</code>
|
||||
<div
|
||||
v-if="admin.showsRpaWorkerStatus"
|
||||
class="schedule-workbench__worker"
|
||||
>
|
||||
<span class="text-muted">{{ t('admin.schedule.rpaWorker.title') }}</span>
|
||||
<ElTag
|
||||
v-if="admin.rpaWorkerStatusLoading"
|
||||
size="small"
|
||||
type="info"
|
||||
effect="plain"
|
||||
>
|
||||
{{ t('admin.schedule.rpaWorker.loading') }}
|
||||
</ElTag>
|
||||
<ElTag
|
||||
v-else
|
||||
size="small"
|
||||
:type="admin.rpaWorkerStatus?.ready ? 'success' : 'danger'"
|
||||
effect="light"
|
||||
>
|
||||
{{ admin.rpaWorkerStatus?.ready ? t('admin.schedule.rpaWorker.online') : t('admin.schedule.rpaWorker.offline') }}
|
||||
</ElTag>
|
||||
<span class="text-muted text-xs">
|
||||
{{ t('admin.schedule.rpaWorker.lastHeartbeat', { time: admin.rpaWorkerLastHeartbeatAt }) }}
|
||||
</span>
|
||||
</div>
|
||||
</template>
|
||||
</div>
|
||||
<div class="admin-stat-tile px-4 py-3 text-center">
|
||||
<div class="text-base font-semibold text-primary">{{ admin.selectedScheduleRuns.length }}</div>
|
||||
<div class="mt-1 text-xs text-muted">{{ $t('admin.schedule.runBatches') }}</div>
|
||||
|
||||
<ElSpace v-if="admin.selectedSchedule" wrap>
|
||||
<ElButton @click="admin.openScheduleEditModal(admin.selectedSchedule)">
|
||||
{{ t('admin.schedule.actions.edit') }}
|
||||
</ElButton>
|
||||
<ElButton
|
||||
v-if="!admin.selectedSchedule.enabled"
|
||||
type="success"
|
||||
plain
|
||||
@click="() => void admin.setScheduleEnabled(admin.selectedSchedule!.id, true)"
|
||||
>
|
||||
{{ t('admin.schedule.actions.start') }}
|
||||
</ElButton>
|
||||
<ElButton
|
||||
v-else
|
||||
type="warning"
|
||||
plain
|
||||
@click="() => void admin.setScheduleEnabled(admin.selectedSchedule!.id, false)"
|
||||
>
|
||||
{{ t('admin.schedule.actions.pause') }}
|
||||
</ElButton>
|
||||
<ElButton type="primary" plain @click="() => void admin.runScheduleNow(admin.selectedSchedule!.id)">
|
||||
{{ t('admin.schedule.actions.run') }}
|
||||
</ElButton>
|
||||
<ElButton
|
||||
v-if="admin.selectedSchedule.schedule_type === 'data_pipeline' && admin.selectedSchedule.data_source_type === 'database'"
|
||||
@click="admin.openTestRunDialog(admin.selectedSchedule)"
|
||||
>
|
||||
{{ t('admin.schedule.actions.test') }}
|
||||
</ElButton>
|
||||
<ElButton type="danger" plain @click="() => void admin.deleteSchedule(admin.selectedSchedule!)">
|
||||
{{ t('admin.schedule.actions.delete') }}
|
||||
</ElButton>
|
||||
</ElSpace>
|
||||
</div>
|
||||
|
||||
<div class="schedule-stats-bar">
|
||||
<div class="schedule-stat">
|
||||
<span class="schedule-stat__value">{{ admin.selectedScheduleRuns.length }}</span>
|
||||
<span class="schedule-stat__label">{{ t('admin.schedule.runBatches') }}</span>
|
||||
</div>
|
||||
<div class="admin-stat-tile px-4 py-3 text-center">
|
||||
<div class="text-base font-semibold text-primary">{{ admin.selectedScheduleRunMetrics.total }}</div>
|
||||
<div class="mt-1 text-xs text-muted">{{ $t('admin.schedule.totalProcessed') }}</div>
|
||||
<div class="schedule-stat">
|
||||
<span class="schedule-stat__value">{{ admin.selectedScheduleRunMetrics.total }}</span>
|
||||
<span class="schedule-stat__label">{{ t('admin.schedule.totalProcessed') }}</span>
|
||||
</div>
|
||||
<div class="admin-stat-tile px-4 py-3 text-center">
|
||||
<div class="text-base font-semibold text-emerald-700">{{ admin.selectedScheduleRunMetrics.success }}</div>
|
||||
<div class="mt-1 text-xs text-muted">{{ $t('admin.schedule.totalSuccess') }}</div>
|
||||
<div class="schedule-stat">
|
||||
<span class="schedule-stat__value text-emerald-700">{{ admin.selectedScheduleRunMetrics.success }}</span>
|
||||
<span class="schedule-stat__label">{{ t('admin.schedule.totalSuccess') }}</span>
|
||||
</div>
|
||||
<div class="admin-stat-tile px-4 py-3 text-center">
|
||||
<div class="text-base font-semibold text-amber-600">{{ admin.selectedScheduleRunMetrics.skipped }}</div>
|
||||
<div class="mt-1 text-xs text-muted">{{
|
||||
admin.isInboundRpaSchedule
|
||||
? $t('admin.schedule.totalSkippedReceipt')
|
||||
: admin.isOutboundRpaSchedule
|
||||
? $t('admin.schedule.totalSkippedOutbound')
|
||||
: admin.isInventoryRpaSchedule
|
||||
? $t('admin.schedule.totalSkippedInventory')
|
||||
: $t('admin.schedule.totalSkipped')
|
||||
}}</div>
|
||||
<div class="schedule-stat">
|
||||
<span class="schedule-stat__value text-amber-600">{{ admin.selectedScheduleRunMetrics.skipped }}</span>
|
||||
<span class="schedule-stat__label">{{ skippedMetricLabel }}</span>
|
||||
</div>
|
||||
<div class="admin-stat-tile px-4 py-3 text-center">
|
||||
<div class="text-base font-semibold text-rose-600">{{ admin.selectedScheduleRunMetrics.failed }}</div>
|
||||
<div class="mt-1 text-xs text-muted">{{ $t('admin.schedule.totalFailed') }}</div>
|
||||
<div class="schedule-stat">
|
||||
<span class="schedule-stat__value text-rose-600">{{ admin.selectedScheduleRunMetrics.failed }}</span>
|
||||
<span class="schedule-stat__label">{{ t('admin.schedule.totalFailed') }}</span>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="admin-panel-lg p-6 shadow-sm">
|
||||
<div class="grid grid-cols-1 gap-6 lg:grid-cols-[320px_minmax(0,1fr)]">
|
||||
<div class="admin-panel-lg p-6 shadow-sm">
|
||||
<div class="mb-4 flex items-center justify-between">
|
||||
<h4 class="text-lg font-semibold text-primary">{{ $t('admin.schedule.listTitle') }}</h4>
|
||||
<span class="text-xs text-muted">{{ $t('admin.schedule.switchByCard') }}</span>
|
||||
</div>
|
||||
<div class="space-y-3">
|
||||
<div
|
||||
v-for="s in admin.schedules"
|
||||
:key="`workbench-${s.id}`"
|
||||
class="w-full cursor-pointer rounded-2xl border px-4 py-4 text-left transition-all"
|
||||
:class="admin.selectedScheduleId === s.id ? 'border-blue-300 bg-blue-50/60' : 'border-default bg-surface hover:border-blue-200 hover:bg-surface-soft'"
|
||||
role="button"
|
||||
tabindex="0"
|
||||
@click="admin.viewScheduleRuns(s.id)"
|
||||
@keydown.enter.prevent="admin.viewScheduleRuns(s.id)"
|
||||
@keydown.space.prevent="admin.viewScheduleRuns(s.id)"
|
||||
>
|
||||
<div class="flex items-start justify-between gap-3">
|
||||
<div class="min-w-0">
|
||||
<div class="truncate font-semibold text-primary">{{ s.name }}</div>
|
||||
<div class="mt-0.5 text-xs text-muted">{{ s.schedule_no }}</div>
|
||||
<div class="mt-2 flex flex-wrap items-center gap-2">
|
||||
<button
|
||||
type="button"
|
||||
class="inline-flex items-center justify-center rounded-xl border border-default p-1.5 text-xs font-medium text-secondary transition-colors hover:bg-surface-soft"
|
||||
:title="$t('admin.schedule.actions.edit')"
|
||||
@click.stop="admin.openScheduleEditModal(s)"
|
||||
>
|
||||
<Edit3 class="h-3 w-3" />
|
||||
</button>
|
||||
<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="$t('admin.schedule.actions.start')"
|
||||
@click.stop="admin.setScheduleEnabled(s.id, true)"
|
||||
>
|
||||
<Power class="h-3 w-3" />
|
||||
</button>
|
||||
<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="$t('admin.schedule.actions.pause')"
|
||||
@click.stop="admin.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="$t('admin.schedule.actions.run')"
|
||||
@click.stop="admin.runScheduleNow(s.id)"
|
||||
>
|
||||
<Rocket class="h-3 w-3" />
|
||||
</button>
|
||||
<button
|
||||
v-if="s.schedule_type === 'data_pipeline' && s.data_source_type === 'database'"
|
||||
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="$t('admin.schedule.actions.test')"
|
||||
@click.stop="admin.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="$t('admin.schedule.actions.delete')"
|
||||
@click.stop="admin.deleteSchedule(s)"
|
||||
>
|
||||
<Trash2 class="h-3 w-3" />
|
||||
</button>
|
||||
</div>
|
||||
</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-surface-strong text-secondary'">
|
||||
{{ s.enabled ? $t('admin.schedule.enabled') : $t('admin.schedule.disabled') }}
|
||||
</span>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div v-if="admin.selectedSchedule" class="schedule-workbench__runs">
|
||||
<div class="schedule-workbench__runs-head">
|
||||
<div>
|
||||
<div v-if="admin.selectedSchedule" class="admin-panel p-4">
|
||||
<div class="mb-4 flex flex-wrap items-center justify-between gap-3">
|
||||
<div>
|
||||
<h3 class="text-lg font-semibold text-primary">{{ $t('admin.schedule.recordsTitle', { name: admin.selectedSchedule.name }) }}</h3>
|
||||
<p class="mt-1 text-sm text-muted">{{ $t('admin.schedule.recordsSubtitle') }}</p>
|
||||
</div>
|
||||
<div
|
||||
v-if="admin.showsRpaWorkerStatus"
|
||||
class="inline-flex items-center gap-2 rounded-lg border border-default px-3 py-2 text-xs"
|
||||
>
|
||||
<span class="text-muted">{{ $t('admin.schedule.rpaWorker.title') }}</span>
|
||||
<span
|
||||
v-if="admin.rpaWorkerStatusLoading"
|
||||
class="rounded-full bg-surface-soft px-2 py-0.5 text-secondary"
|
||||
>
|
||||
{{ $t('admin.schedule.rpaWorker.loading') }}
|
||||
</span>
|
||||
<span
|
||||
v-else
|
||||
class="rounded-full px-2 py-0.5 font-medium"
|
||||
:class="admin.rpaWorkerStatus?.ready ? 'bg-emerald-100 text-emerald-700' : 'bg-rose-100 text-rose-700'"
|
||||
>
|
||||
{{ admin.rpaWorkerStatus?.ready ? $t('admin.schedule.rpaWorker.online') : $t('admin.schedule.rpaWorker.offline') }}
|
||||
</span>
|
||||
<span class="text-muted">
|
||||
{{ $t('admin.schedule.rpaWorker.lastHeartbeat', { time: admin.rpaWorkerLastHeartbeatAt }) }}
|
||||
</span>
|
||||
<span
|
||||
v-if="!admin.rpaWorkerStatusLoading && admin.rpaWorkerStatus && !admin.rpaWorkerStatus.ready && admin.rpaWorkerStatus.detail_message"
|
||||
class="max-w-[360px] truncate text-amber-700"
|
||||
:title="admin.rpaWorkerStatus.detail_message"
|
||||
>
|
||||
{{ admin.rpaWorkerStatus.detail_message }}
|
||||
</span>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div>
|
||||
<div class="mb-3 flex flex-wrap items-center gap-2 text-xs">
|
||||
<label class="text-muted">{{ $t('admin.schedule.filterStart') }}</label>
|
||||
<input type="datetime-local" step="1" v-model="admin.scheduleRunStartedAfter" class="!min-w-0 !w-[170px] !py-1 !px-2 !text-xs rounded-lg border border-default" />
|
||||
<label class="text-muted">{{ $t('admin.schedule.filterEnd') }}</label>
|
||||
<input type="datetime-local" step="1" v-model="admin.scheduleRunStartedBefore" class="!min-w-0 !w-[170px] !py-1 !px-2 !text-xs rounded-lg border border-default" />
|
||||
<select v-model="admin.scheduleRunStatusFilter" class="!min-w-0 !w-[90px] !py-1 !px-2 !text-xs rounded-lg border border-default">
|
||||
<option v-for="opt in admin.scheduleRunStatusOptions" :key="opt.value" :value="opt.value">
|
||||
{{ opt.label }}
|
||||
</option>
|
||||
</select>
|
||||
<button
|
||||
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="admin.viewScheduleRuns(admin.selectedSchedule.id)"
|
||||
>
|
||||
{{ $t('admin.schedule.query') }}
|
||||
</button>
|
||||
<button
|
||||
class="inline-flex items-center rounded-lg border border-default px-2.5 py-1 text-xs font-medium text-secondary hover:bg-surface-soft"
|
||||
@click="admin.resetScheduleRunFilters(); admin.viewScheduleRuns(admin.selectedSchedule.id)"
|
||||
>
|
||||
{{ $t('admin.schedule.reset') }}
|
||||
</button>
|
||||
</div>
|
||||
<div class="admin-table-wrap max-h-[calc(100vh-20rem)] rounded-xl border border-subtle scrollbar-thin">
|
||||
<table
|
||||
class="admin-table table-fixed text-xs"
|
||||
:style="{ minWidth: `${admin.scheduleRunColumnDefs.reduce((sum, col) => sum + col.width, 0)}px` }"
|
||||
>
|
||||
<colgroup>
|
||||
<col
|
||||
v-for="col in admin.scheduleRunColumnDefs"
|
||||
:key="col.key"
|
||||
:style="{
|
||||
width: `${col.width}px`,
|
||||
minWidth: `${col.width}px`,
|
||||
maxWidth: `${col.width}px`,
|
||||
}"
|
||||
/>
|
||||
</colgroup>
|
||||
<thead class="sticky top-0 z-10 admin-table-sticky-head">
|
||||
<tr class="text-muted">
|
||||
<th
|
||||
v-for="(col, colIndex) in admin.scheduleRunColumnDefs"
|
||||
:key="col.key"
|
||||
class="group relative max-w-0 overflow-hidden admin-table-sticky-head px-4 py-3 text-xs font-semibold uppercase select-none"
|
||||
>
|
||||
<span class="block truncate pr-2" :title="col.label">{{ col.label }}</span>
|
||||
<span
|
||||
class="absolute inset-y-0 -right-1 z-10 w-2 cursor-col-resize"
|
||||
@mousedown.prevent="admin.startScheduleColResize(colIndex, $event)"
|
||||
:title="$t('admin.schedule.resizeColumn', { label: col.label })"
|
||||
></span>
|
||||
</th>
|
||||
</tr>
|
||||
</thead>
|
||||
<tbody>
|
||||
<tr v-if="admin.scheduleRunsLoading">
|
||||
<td colspan="11" class="px-4 py-8 text-center text-sm text-muted">{{ $t('admin.schedule.queryingRuns') }}</td>
|
||||
</tr>
|
||||
<tr v-else-if="admin.filteredScheduleRuns.length === 0">
|
||||
<td colspan="11" class="px-4 py-8 text-center text-sm text-muted">{{ $t('admin.schedule.noRunRecords') }}</td>
|
||||
</tr>
|
||||
<tr
|
||||
v-else
|
||||
v-for="r in admin.filteredScheduleRuns"
|
||||
:key="r.id"
|
||||
class="text-secondary transition"
|
||||
>
|
||||
<td class="max-w-0 truncate px-4 py-2.5" :title="r.run_no">{{ r.run_no }}</td>
|
||||
<td class="max-w-0 truncate px-4 py-2.5" :title="admin.formatDateTime(r.started_at)">{{ admin.formatDateTime(r.started_at) }}</td>
|
||||
<td class="max-w-0 truncate px-4 py-2.5" :title="admin.formatDateTime(r.finished_at)">{{ admin.formatDateTime(r.finished_at) }}</td>
|
||||
<td class="max-w-0 overflow-hidden px-4 py-2.5">
|
||||
<div class="flex min-w-0 items-center gap-1 overflow-hidden">
|
||||
<span class="inline-flex shrink-0 items-center whitespace-nowrap rounded-full px-2.5 py-1 text-xs font-semibold"
|
||||
:class="admin.getScheduleRunStatusBadge(r.status).cls">
|
||||
{{ admin.getScheduleRunStatusBadge(r.status).label }}
|
||||
</span>
|
||||
<span v-if="r.error_message" class="min-w-0 truncate text-xs text-muted" :title="r.error_message">...</span>
|
||||
</div>
|
||||
</td>
|
||||
<td class="max-w-0 truncate px-4 py-2.5">{{ r.total_count }}</td>
|
||||
<td class="max-w-0 truncate px-4 py-2.5">{{ r.success_count }}</td>
|
||||
<td class="max-w-0 truncate px-4 py-2.5">{{ r.skipped_count ?? 0 }}</td>
|
||||
<td class="max-w-0 truncate px-4 py-2.5" :title="admin.getScheduleRunFailedCountTitle(r)">
|
||||
<span>{{ r.failed_count }}</span>
|
||||
<span
|
||||
v-if="admin.isScheduleRunExcelExportFailed(r)"
|
||||
class="ml-1 text-xs font-medium text-amber-600"
|
||||
>+Excel</span>
|
||||
</td>
|
||||
<td class="max-w-0 overflow-hidden px-4 py-2.5">
|
||||
<span v-if="r.wecom_notified" class="inline-flex max-w-full shrink-0 items-center gap-1 truncate text-xs text-emerald-600" :title="$t('admin.schedule.notified')">
|
||||
<svg class="h-3.5 w-3.5 shrink-0" 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="block truncate text-xs text-amber-500" :title="r.wecom_notify_error">{{ $t('admin.schedule.notifyError') }}</span>
|
||||
<span v-else class="text-xs text-muted">-</span>
|
||||
</td>
|
||||
<td class="max-w-0 overflow-hidden px-4 py-2.5">
|
||||
<div class="flex min-w-0 flex-wrap items-center gap-1 overflow-hidden">
|
||||
<a
|
||||
v-if="r.total_count > 0"
|
||||
href="#"
|
||||
@click.prevent="admin.downloadScheduleExcel(r.id)"
|
||||
class="inline-flex shrink-0 items-center gap-1 whitespace-nowrap 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 shrink-0" />
|
||||
{{ $t('admin.schedule.downloadDetail') }}
|
||||
</a>
|
||||
<span v-else class="text-muted">-</span>
|
||||
</div>
|
||||
</td>
|
||||
<td class="max-w-0 overflow-hidden px-4 py-2.5">
|
||||
<div class="flex min-w-0 items-center overflow-hidden">
|
||||
<button
|
||||
v-if="(r.step_logs && r.step_logs.length > 0) || r.dify_execution_snapshot || r.kb_sync_status"
|
||||
@click="admin.expandedScheduleRunId = admin.expandedScheduleRunId === r.id ? null : r.id"
|
||||
class="inline-flex shrink-0 items-center gap-1 whitespace-nowrap 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 shrink-0" />
|
||||
{{ $t('admin.schedule.log') }}
|
||||
<ChevronDown v-if="admin.expandedScheduleRunId !== r.id" class="h-3 w-3 shrink-0" />
|
||||
<ChevronUp v-else class="h-3 w-3 shrink-0" />
|
||||
</button>
|
||||
<span v-else class="text-muted">-</span>
|
||||
</div>
|
||||
</td>
|
||||
</tr>
|
||||
<tr
|
||||
v-if="admin.expandedScheduleRun"
|
||||
:key="'expanded-' + admin.expandedScheduleRunId"
|
||||
>
|
||||
<td colspan="11" class="w-full max-w-none px-4 py-3 bg-surface-soft/60">
|
||||
<div class="min-w-0 w-full max-w-full space-y-3">
|
||||
<div
|
||||
v-if="admin.wecomRawZipPromptRunId === admin.expandedScheduleRun.id && admin.expandedScheduleRun.inventory_raw_zip_available"
|
||||
class="rounded-xl border border-blue-200 bg-blue-50/80 p-4"
|
||||
>
|
||||
<p class="text-sm font-medium text-blue-900">{{ $t('admin.schedule.rawInventoryZipWecomHint') }}</p>
|
||||
<button
|
||||
type="button"
|
||||
class="mt-3 inline-flex items-center gap-2 rounded-xl border border-blue-300 bg-surface px-4 py-2 text-sm font-semibold text-blue-700 shadow-sm transition-colors hover:bg-blue-50"
|
||||
@click="admin.downloadScheduleInventoryRawZip(admin.expandedScheduleRun.id)"
|
||||
>
|
||||
<Download class="h-4 w-4 shrink-0" />
|
||||
{{ $t('admin.schedule.downloadInventoryRawZipPackage') }}
|
||||
</button>
|
||||
</div>
|
||||
<div
|
||||
v-if="admin.wecomRawZipPromptRunId === admin.expandedScheduleRun.id && admin.expandedScheduleRun.inbound_raw_zip_available"
|
||||
class="rounded-xl border border-blue-200 bg-blue-50/80 p-4"
|
||||
>
|
||||
<p class="text-sm font-medium text-blue-900">{{ $t('admin.schedule.rawInboundZipWecomHint') }}</p>
|
||||
<button
|
||||
type="button"
|
||||
class="mt-3 inline-flex items-center gap-2 rounded-xl border border-blue-300 bg-surface px-4 py-2 text-sm font-semibold text-blue-700 shadow-sm transition-colors hover:bg-blue-50"
|
||||
@click="admin.downloadScheduleInboundRawZip(admin.expandedScheduleRun.id)"
|
||||
>
|
||||
<Download class="h-4 w-4 shrink-0" />
|
||||
{{ $t('admin.schedule.downloadInboundRawZipPackage') }}
|
||||
</button>
|
||||
</div>
|
||||
<div
|
||||
v-if="admin.wecomRawZipPromptRunId === admin.expandedScheduleRun.id && admin.expandedScheduleRun.outbound_raw_zip_available"
|
||||
class="rounded-xl border border-blue-200 bg-blue-50/80 p-4"
|
||||
>
|
||||
<p class="text-sm font-medium text-blue-900">{{ $t('admin.schedule.rawOutboundZipWecomHint') }}</p>
|
||||
<button
|
||||
type="button"
|
||||
class="mt-3 inline-flex items-center gap-2 rounded-xl border border-blue-300 bg-surface px-4 py-2 text-sm font-semibold text-blue-700 shadow-sm transition-colors hover:bg-blue-50"
|
||||
@click="admin.downloadScheduleOutboundRawZip(admin.expandedScheduleRun.id)"
|
||||
>
|
||||
<Download class="h-4 w-4 shrink-0" />
|
||||
{{ $t('admin.schedule.downloadOutboundRawZipPackage') }}
|
||||
</button>
|
||||
</div>
|
||||
<div
|
||||
v-if="admin.expandedScheduleRun.kb_sync_status"
|
||||
class="rounded-xl border border-emerald-200 bg-emerald-50/50 p-3 text-xs text-secondary"
|
||||
>
|
||||
<div class="font-bold text-emerald-800">{{ $t('admin.schedule.kbSync.title') }}</div>
|
||||
<div class="mt-1">
|
||||
<span class="font-semibold text-muted">{{ $t('admin.schedule.kbSync.status') }}:</span>
|
||||
{{ admin.expandedScheduleRun.kb_sync_status }}
|
||||
</div>
|
||||
<div v-if="admin.expandedScheduleRun.kb_document_id" class="mt-1">
|
||||
<span class="font-semibold text-muted">{{ $t('admin.schedule.kbSync.document') }}:</span>
|
||||
{{ admin.expandedScheduleRun.kb_document_id }}
|
||||
</div>
|
||||
<div v-if="admin.expandedScheduleRun.kb_sync_error" class="mt-1 text-rose-600">
|
||||
{{ admin.expandedScheduleRun.kb_sync_error }}
|
||||
</div>
|
||||
</div>
|
||||
<div
|
||||
v-if="admin.expandedScheduleRun.dify_execution_snapshot"
|
||||
class="rounded-xl border border-indigo-200 bg-indigo-50/50 p-3"
|
||||
>
|
||||
<div class="mb-2 flex flex-wrap items-start justify-between gap-x-4 gap-y-1">
|
||||
<h5 class="min-w-0 text-xs font-bold uppercase text-indigo-800">{{ $t('admin.schedule.difySnapshot.title') }}</h5>
|
||||
<time
|
||||
class="shrink-0 whitespace-nowrap text-[10px] text-indigo-600/80"
|
||||
:title="admin.expandedScheduleRun.dify_execution_snapshot.captured_at || '-'"
|
||||
>
|
||||
{{ admin.formatDateTime(admin.expandedScheduleRun.dify_execution_snapshot.captured_at) }}
|
||||
</time>
|
||||
</div>
|
||||
<div v-if="admin.expandedScheduleRun.dify_execution_snapshot.dify_enabled" class="space-y-2 text-xs text-secondary">
|
||||
<div class="break-words">
|
||||
<span class="font-semibold text-muted">{{ $t('admin.schedule.difySnapshot.agent') }}:</span>
|
||||
{{ admin.expandedScheduleRun.dify_execution_snapshot.dify_agent_name || '-' }}
|
||||
<span class="text-muted">{{ $t('admin.schedule.difySnapshot.agentId', { id: admin.expandedScheduleRun.dify_execution_snapshot.dify_agent_id ?? '-' }) }}</span>
|
||||
</div>
|
||||
<div v-if="admin.expandedScheduleRun.dify_execution_snapshot.dify_app_id">
|
||||
<span class="font-semibold text-muted">{{ $t('admin.schedule.difySnapshot.difyAppId') }}:</span>
|
||||
{{ admin.expandedScheduleRun.dify_execution_snapshot.dify_app_id }}
|
||||
</div>
|
||||
<div>
|
||||
<span class="mb-1 block font-semibold text-muted">{{ $t('admin.schedule.difySnapshot.systemPrompt') }}:</span>
|
||||
<pre
|
||||
v-if="admin.expandedScheduleRun.dify_execution_snapshot.dify_system_prompt"
|
||||
class="max-h-[240px] overflow-auto whitespace-pre-wrap rounded-lg border border-indigo-100 bg-surface p-3 font-mono text-[11px] leading-relaxed text-primary"
|
||||
>{{ admin.expandedScheduleRun.dify_execution_snapshot.dify_system_prompt }}</pre>
|
||||
<span v-else class="text-muted">{{ $t('admin.schedule.difySnapshot.notConfiguredUseDefault') }}</span>
|
||||
</div>
|
||||
</div>
|
||||
<div v-else class="text-xs text-muted">{{ $t('admin.schedule.difySnapshot.notEnabledRun') }}</div>
|
||||
</div>
|
||||
<div class="space-y-2">
|
||||
<div class="flex flex-wrap items-center justify-between gap-2 mb-2">
|
||||
<h5 class="text-xs font-bold text-secondary uppercase">{{ $t('admin.schedule.runLogs') }}</h5>
|
||||
<span class="text-xs text-muted">{{ $t('admin.schedule.stepsCount', { count: admin.expandedScheduleRun.step_logs?.length || 0 }) }}</span>
|
||||
</div>
|
||||
<div
|
||||
v-for="(log, li) in admin.expandedScheduleRun.step_logs || []"
|
||||
:key="li"
|
||||
class="rounded-xl border p-3"
|
||||
:class="log.status === 'failed' ? 'border-rose-200 bg-rose-50/40' : 'border-default bg-surface'"
|
||||
>
|
||||
<div class="flex items-center gap-2 mb-1">
|
||||
<span class="inline-flex items-center rounded-full px-2 py-0.5 text-[10px] font-bold"
|
||||
:class="(admin.stepStatusMap[log.status] || admin.stepStatusMap.success || { cls: 'bg-surface-soft text-secondary' }).cls">
|
||||
{{ (admin.stepStatusMap[log.status] || { label: log.status }).label }}
|
||||
</span>
|
||||
<span class="text-xs font-semibold text-secondary">{{ admin.stepLabelMap[log.step] || log.step }}</span>
|
||||
<span v-if="log.row_id" class="text-[10px] text-muted">row_id={{ log.row_id }}</span>
|
||||
<span v-if="log.duration_ms != null" class="text-[10px] text-muted">{{ log.duration_ms }}ms</span>
|
||||
</div>
|
||||
<details v-if="log.detail" class="mt-1">
|
||||
<summary class="cursor-pointer text-[10px] font-semibold text-muted hover:text-secondary">{{ $t('admin.schedule.viewDetail') }}</summary>
|
||||
<pre class="admin-pre-block">{{ JSON.stringify(log.detail, null, 2) }}</pre>
|
||||
</details>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</td>
|
||||
</tr>
|
||||
</tbody>
|
||||
</table>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<div v-else class="rounded-2xl border border-dashed border-default bg-surface px-4 py-10 text-center text-sm text-muted">
|
||||
{{ $t('admin.schedule.noSelectionHint') }}
|
||||
</div>
|
||||
<h3 class="text-base font-semibold text-primary">
|
||||
{{ t('admin.schedule.recordsTitle', { name: admin.selectedSchedule.name }) }}
|
||||
</h3>
|
||||
<p class="mt-1 text-sm text-muted">{{ t('admin.schedule.recordsSubtitle') }}</p>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="schedule-filters">
|
||||
<ElDatePicker
|
||||
v-model="admin.scheduleRunStartedAfter"
|
||||
type="datetime"
|
||||
value-format="YYYY-MM-DDTHH:mm:ss"
|
||||
:placeholder="t('admin.schedule.filterStart')"
|
||||
class="schedule-filter-date"
|
||||
/>
|
||||
<ElDatePicker
|
||||
v-model="admin.scheduleRunStartedBefore"
|
||||
type="datetime"
|
||||
value-format="YYYY-MM-DDTHH:mm:ss"
|
||||
:placeholder="t('admin.schedule.filterEnd')"
|
||||
class="schedule-filter-date"
|
||||
/>
|
||||
<ElSelect
|
||||
v-model="admin.scheduleRunStatusFilter"
|
||||
class="schedule-filter-status"
|
||||
:placeholder="t('admin.schedule.columns.status')"
|
||||
>
|
||||
<ElOption
|
||||
v-for="opt in admin.scheduleRunStatusOptions"
|
||||
:key="opt.value"
|
||||
:label="opt.label"
|
||||
:value="opt.value"
|
||||
/>
|
||||
</ElSelect>
|
||||
<ElButton type="primary" @click="admin.viewScheduleRuns(admin.selectedSchedule.id)">
|
||||
{{ t('admin.schedule.query') }}
|
||||
</ElButton>
|
||||
<ElButton @click="admin.resetScheduleRunFilters(); admin.viewScheduleRuns(admin.selectedSchedule.id)">
|
||||
{{ t('admin.schedule.reset') }}
|
||||
</ElButton>
|
||||
</div>
|
||||
|
||||
<div class="admin-table-wrap max-h-[calc(100vh-22rem)] scrollbar-thin">
|
||||
<table
|
||||
class="admin-table table-fixed text-xs"
|
||||
:style="{ minWidth: `${admin.scheduleRunColumnDefs.reduce((sum, col) => sum + col.width, 0)}px` }"
|
||||
>
|
||||
<colgroup>
|
||||
<col
|
||||
v-for="col in admin.scheduleRunColumnDefs"
|
||||
:key="col.key"
|
||||
:style="{
|
||||
width: `${col.width}px`,
|
||||
minWidth: `${col.width}px`,
|
||||
maxWidth: `${col.width}px`,
|
||||
}"
|
||||
/>
|
||||
</colgroup>
|
||||
<thead class="sticky top-0 z-10 admin-table-sticky-head">
|
||||
<tr class="text-muted">
|
||||
<th
|
||||
v-for="(col, colIndex) in admin.scheduleRunColumnDefs"
|
||||
:key="col.key"
|
||||
class="group relative max-w-0 overflow-hidden admin-table-sticky-head px-4 py-3 text-xs font-semibold uppercase select-none"
|
||||
>
|
||||
<span class="block truncate pr-2" :title="col.label">{{ col.label }}</span>
|
||||
<span
|
||||
class="absolute inset-y-0 -right-1 z-10 w-2 cursor-col-resize"
|
||||
@mousedown.prevent="admin.startScheduleColResize(colIndex, $event)"
|
||||
:title="t('admin.schedule.resizeColumn', { label: col.label })"
|
||||
></span>
|
||||
</th>
|
||||
</tr>
|
||||
</thead>
|
||||
<tbody>
|
||||
<tr v-if="admin.scheduleRunsLoading">
|
||||
<td colspan="11" class="px-4 py-8 text-center text-sm text-muted">{{ t('admin.schedule.queryingRuns') }}</td>
|
||||
</tr>
|
||||
<tr v-else-if="admin.filteredScheduleRuns.length === 0">
|
||||
<td colspan="11" class="px-4 py-8 text-center text-sm text-muted">{{ t('admin.schedule.noRunRecords') }}</td>
|
||||
</tr>
|
||||
<tr
|
||||
v-else
|
||||
v-for="r in admin.filteredScheduleRuns"
|
||||
:key="r.id"
|
||||
class="text-secondary transition"
|
||||
>
|
||||
<td class="max-w-0 truncate px-4 py-2.5" :title="r.run_no">{{ r.run_no }}</td>
|
||||
<td class="max-w-0 truncate px-4 py-2.5" :title="admin.formatDateTime(r.started_at)">{{ admin.formatDateTime(r.started_at) }}</td>
|
||||
<td class="max-w-0 truncate px-4 py-2.5" :title="admin.formatDateTime(r.finished_at)">{{ admin.formatDateTime(r.finished_at) }}</td>
|
||||
<td class="max-w-0 overflow-hidden px-4 py-2.5">
|
||||
<div class="flex min-w-0 items-center gap-1 overflow-hidden">
|
||||
<span
|
||||
class="inline-flex shrink-0 items-center whitespace-nowrap rounded-full px-2.5 py-1 text-xs font-semibold"
|
||||
:class="admin.getScheduleRunStatusBadge(r.status).cls"
|
||||
>
|
||||
{{ admin.getScheduleRunStatusBadge(r.status).label }}
|
||||
</span>
|
||||
<span v-if="r.error_message" class="min-w-0 truncate text-xs text-muted" :title="r.error_message">...</span>
|
||||
</div>
|
||||
</td>
|
||||
<td class="max-w-0 truncate px-4 py-2.5">{{ r.total_count }}</td>
|
||||
<td class="max-w-0 truncate px-4 py-2.5">{{ r.success_count }}</td>
|
||||
<td class="max-w-0 truncate px-4 py-2.5">{{ r.skipped_count ?? 0 }}</td>
|
||||
<td class="max-w-0 truncate px-4 py-2.5" :title="admin.getScheduleRunFailedCountTitle(r)">
|
||||
<span>{{ r.failed_count }}</span>
|
||||
<span
|
||||
v-if="admin.isScheduleRunExcelExportFailed(r)"
|
||||
class="ml-1 text-xs font-medium text-amber-600"
|
||||
>+Excel</span>
|
||||
</td>
|
||||
<td class="max-w-0 overflow-hidden px-4 py-2.5">
|
||||
<span
|
||||
v-if="r.wecom_notified"
|
||||
class="inline-flex max-w-full shrink-0 items-center gap-1 truncate text-xs text-emerald-600"
|
||||
:title="t('admin.schedule.notified')"
|
||||
>
|
||||
{{ t('admin.schedule.notified') }}
|
||||
</span>
|
||||
<span
|
||||
v-else-if="r.wecom_notify_error"
|
||||
class="block truncate text-xs text-amber-500"
|
||||
:title="r.wecom_notify_error"
|
||||
>{{ t('admin.schedule.notifyError') }}</span>
|
||||
<span v-else class="text-xs text-muted">-</span>
|
||||
</td>
|
||||
<td class="max-w-0 overflow-hidden px-4 py-2.5">
|
||||
<div class="flex min-w-0 flex-wrap items-center gap-1 overflow-hidden">
|
||||
<a
|
||||
v-if="r.total_count > 0"
|
||||
href="#"
|
||||
class="inline-flex shrink-0 items-center gap-1 whitespace-nowrap rounded-lg border border-default px-2 py-1 text-xs font-medium text-secondary transition-colors hover:bg-surface-soft"
|
||||
@click.prevent="admin.downloadScheduleExcel(r.id)"
|
||||
>
|
||||
<Download class="h-3 w-3 shrink-0" />
|
||||
{{ t('admin.schedule.downloadDetail') }}
|
||||
</a>
|
||||
<span v-else class="text-muted">-</span>
|
||||
</div>
|
||||
</td>
|
||||
<td class="max-w-0 overflow-hidden px-4 py-2.5">
|
||||
<div class="flex min-w-0 items-center overflow-hidden">
|
||||
<button
|
||||
v-if="(r.step_logs && r.step_logs.length > 0) || r.dify_execution_snapshot || r.kb_sync_status"
|
||||
class="inline-flex shrink-0 items-center gap-1 whitespace-nowrap rounded-lg border border-blue-200 px-2 py-1 text-xs font-medium text-blue-600 transition-colors hover:bg-blue-50"
|
||||
@click="admin.expandedScheduleRunId = admin.expandedScheduleRunId === r.id ? null : r.id"
|
||||
>
|
||||
<Eye class="h-3 w-3 shrink-0" />
|
||||
{{ t('admin.schedule.log') }}
|
||||
<ChevronDown v-if="admin.expandedScheduleRunId !== r.id" class="h-3 w-3 shrink-0" />
|
||||
<ChevronUp v-else class="h-3 w-3 shrink-0" />
|
||||
</button>
|
||||
<span v-else class="text-muted">-</span>
|
||||
</div>
|
||||
</td>
|
||||
</tr>
|
||||
<tr
|
||||
v-if="admin.expandedScheduleRun"
|
||||
:key="'expanded-' + admin.expandedScheduleRunId"
|
||||
>
|
||||
<td colspan="11" class="w-full max-w-none px-4 py-3 bg-surface-soft/60">
|
||||
<div class="min-w-0 w-full max-w-full space-y-3">
|
||||
<div
|
||||
v-if="admin.wecomRawZipPromptRunId === admin.expandedScheduleRun.id && admin.expandedScheduleRun.inventory_raw_zip_available"
|
||||
class="rounded-xl border border-blue-200 bg-blue-50/80 p-4"
|
||||
>
|
||||
<p class="text-sm font-medium text-blue-900">{{ t('admin.schedule.rawInventoryZipWecomHint') }}</p>
|
||||
<button
|
||||
type="button"
|
||||
class="mt-3 inline-flex items-center gap-2 rounded-xl border border-blue-300 bg-surface px-4 py-2 text-sm font-semibold text-blue-700 shadow-sm transition-colors hover:bg-blue-50"
|
||||
@click="admin.downloadScheduleInventoryRawZip(admin.expandedScheduleRun.id)"
|
||||
>
|
||||
<Download class="h-4 w-4 shrink-0" />
|
||||
{{ t('admin.schedule.downloadInventoryRawZipPackage') }}
|
||||
</button>
|
||||
</div>
|
||||
<div
|
||||
v-if="admin.wecomRawZipPromptRunId === admin.expandedScheduleRun.id && admin.expandedScheduleRun.inbound_raw_zip_available"
|
||||
class="rounded-xl border border-blue-200 bg-blue-50/80 p-4"
|
||||
>
|
||||
<p class="text-sm font-medium text-blue-900">{{ t('admin.schedule.rawInboundZipWecomHint') }}</p>
|
||||
<button
|
||||
type="button"
|
||||
class="mt-3 inline-flex items-center gap-2 rounded-xl border border-blue-300 bg-surface px-4 py-2 text-sm font-semibold text-blue-700 shadow-sm transition-colors hover:bg-blue-50"
|
||||
@click="admin.downloadScheduleInboundRawZip(admin.expandedScheduleRun.id)"
|
||||
>
|
||||
<Download class="h-4 w-4 shrink-0" />
|
||||
{{ t('admin.schedule.downloadInboundRawZipPackage') }}
|
||||
</button>
|
||||
</div>
|
||||
<div
|
||||
v-if="admin.wecomRawZipPromptRunId === admin.expandedScheduleRun.id && admin.expandedScheduleRun.outbound_raw_zip_available"
|
||||
class="rounded-xl border border-blue-200 bg-blue-50/80 p-4"
|
||||
>
|
||||
<p class="text-sm font-medium text-blue-900">{{ t('admin.schedule.rawOutboundZipWecomHint') }}</p>
|
||||
<button
|
||||
type="button"
|
||||
class="mt-3 inline-flex items-center gap-2 rounded-xl border border-blue-300 bg-surface px-4 py-2 text-sm font-semibold text-blue-700 shadow-sm transition-colors hover:bg-blue-50"
|
||||
@click="admin.downloadScheduleOutboundRawZip(admin.expandedScheduleRun.id)"
|
||||
>
|
||||
<Download class="h-4 w-4 shrink-0" />
|
||||
{{ t('admin.schedule.downloadOutboundRawZipPackage') }}
|
||||
</button>
|
||||
</div>
|
||||
<div
|
||||
v-if="admin.expandedScheduleRun.kb_sync_status"
|
||||
class="rounded-xl border border-emerald-200 bg-emerald-50/50 p-3 text-xs text-secondary"
|
||||
>
|
||||
<div class="font-bold text-emerald-800">{{ t('admin.schedule.kbSync.title') }}</div>
|
||||
<div class="mt-1">
|
||||
<span class="font-semibold text-muted">{{ t('admin.schedule.kbSync.status') }}:</span>
|
||||
{{ admin.expandedScheduleRun.kb_sync_status }}
|
||||
</div>
|
||||
<div v-if="admin.expandedScheduleRun.kb_document_id" class="mt-1">
|
||||
<span class="font-semibold text-muted">{{ t('admin.schedule.kbSync.document') }}:</span>
|
||||
{{ admin.expandedScheduleRun.kb_document_id }}
|
||||
</div>
|
||||
<div v-if="admin.expandedScheduleRun.kb_sync_error" class="mt-1 text-rose-600">
|
||||
{{ admin.expandedScheduleRun.kb_sync_error }}
|
||||
</div>
|
||||
</div>
|
||||
<div
|
||||
v-if="admin.expandedScheduleRun.dify_execution_snapshot"
|
||||
class="rounded-xl border border-indigo-200 bg-indigo-50/50 p-3"
|
||||
>
|
||||
<div class="mb-2 flex flex-wrap items-start justify-between gap-x-4 gap-y-1">
|
||||
<h5 class="min-w-0 text-xs font-bold uppercase text-indigo-800">{{ t('admin.schedule.difySnapshot.title') }}</h5>
|
||||
<time
|
||||
class="shrink-0 whitespace-nowrap text-[10px] text-indigo-600/80"
|
||||
:title="admin.expandedScheduleRun.dify_execution_snapshot.captured_at || '-'"
|
||||
>
|
||||
{{ admin.formatDateTime(admin.expandedScheduleRun.dify_execution_snapshot.captured_at) }}
|
||||
</time>
|
||||
</div>
|
||||
<div v-if="admin.expandedScheduleRun.dify_execution_snapshot.dify_enabled" class="space-y-2 text-xs text-secondary">
|
||||
<div class="break-words">
|
||||
<span class="font-semibold text-muted">{{ t('admin.schedule.difySnapshot.agent') }}:</span>
|
||||
{{ admin.expandedScheduleRun.dify_execution_snapshot.dify_agent_name || '-' }}
|
||||
<span class="text-muted">{{ t('admin.schedule.difySnapshot.agentId', { id: admin.expandedScheduleRun.dify_execution_snapshot.dify_agent_id ?? '-' }) }}</span>
|
||||
</div>
|
||||
<div v-if="admin.expandedScheduleRun.dify_execution_snapshot.dify_app_id">
|
||||
<span class="font-semibold text-muted">{{ t('admin.schedule.difySnapshot.difyAppId') }}:</span>
|
||||
{{ admin.expandedScheduleRun.dify_execution_snapshot.dify_app_id }}
|
||||
</div>
|
||||
<div>
|
||||
<span class="mb-1 block font-semibold text-muted">{{ t('admin.schedule.difySnapshot.systemPrompt') }}:</span>
|
||||
<pre
|
||||
v-if="admin.expandedScheduleRun.dify_execution_snapshot.dify_system_prompt"
|
||||
class="max-h-[240px] overflow-auto whitespace-pre-wrap rounded-lg border border-indigo-100 bg-surface p-3 font-mono text-[11px] leading-relaxed text-primary"
|
||||
>{{ admin.expandedScheduleRun.dify_execution_snapshot.dify_system_prompt }}</pre>
|
||||
<span v-else class="text-muted">{{ t('admin.schedule.difySnapshot.notConfiguredUseDefault') }}</span>
|
||||
</div>
|
||||
</div>
|
||||
<div v-else class="text-xs text-muted">{{ t('admin.schedule.difySnapshot.notEnabledRun') }}</div>
|
||||
</div>
|
||||
<div class="space-y-2">
|
||||
<div class="mb-2 flex flex-wrap items-center justify-between gap-2">
|
||||
<h5 class="text-xs font-bold uppercase text-secondary">{{ t('admin.schedule.runLogs') }}</h5>
|
||||
<span class="text-xs text-muted">{{ t('admin.schedule.stepsCount', { count: admin.expandedScheduleRun.step_logs?.length || 0 }) }}</span>
|
||||
</div>
|
||||
<div
|
||||
v-for="(log, li) in admin.expandedScheduleRun.step_logs || []"
|
||||
:key="li"
|
||||
class="rounded-xl border p-3"
|
||||
:class="log.status === 'failed' ? 'border-rose-200 bg-rose-50/40' : 'border-default bg-surface'"
|
||||
>
|
||||
<div class="mb-1 flex items-center gap-2">
|
||||
<span
|
||||
class="inline-flex items-center rounded-full px-2 py-0.5 text-[10px] font-bold"
|
||||
:class="(admin.stepStatusMap[log.status] || admin.stepStatusMap.success || { cls: 'bg-surface-soft text-secondary' }).cls"
|
||||
>
|
||||
{{ (admin.stepStatusMap[log.status] || { label: log.status }).label }}
|
||||
</span>
|
||||
<span class="text-xs font-semibold text-secondary">{{ admin.stepLabelMap[log.step] || log.step }}</span>
|
||||
<span v-if="log.row_id" class="text-[10px] text-muted">row_id={{ log.row_id }}</span>
|
||||
<span v-if="log.duration_ms != null" class="text-[10px] text-muted">{{ log.duration_ms }}ms</span>
|
||||
</div>
|
||||
<details v-if="log.detail" class="mt-1">
|
||||
<summary class="cursor-pointer text-[10px] font-semibold text-muted hover:text-secondary">{{ t('admin.schedule.viewDetail') }}</summary>
|
||||
<pre class="admin-pre-block">{{ JSON.stringify(log.detail, null, 2) }}</pre>
|
||||
</details>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</td>
|
||||
</tr>
|
||||
</tbody>
|
||||
</table>
|
||||
</div>
|
||||
</div>
|
||||
<div
|
||||
v-else
|
||||
class="px-8 py-16 text-center text-sm text-muted"
|
||||
>
|
||||
{{ t('admin.schedule.noSelectionHint') }}
|
||||
</div>
|
||||
</div>
|
||||
</template>
|
||||
|
||||
<style scoped>
|
||||
.schedule-workbench__context {
|
||||
display: flex;
|
||||
flex-wrap: wrap;
|
||||
align-items: flex-start;
|
||||
justify-content: space-between;
|
||||
gap: 12px 16px;
|
||||
padding: 16px 32px;
|
||||
border-bottom: 1px solid var(--el-border-color-lighter);
|
||||
}
|
||||
|
||||
.schedule-workbench__switcher {
|
||||
display: flex;
|
||||
flex-wrap: wrap;
|
||||
align-items: center;
|
||||
gap: 8px 12px;
|
||||
min-width: 0;
|
||||
flex: 1;
|
||||
}
|
||||
|
||||
.schedule-workbench__label {
|
||||
font-size: 0.875rem;
|
||||
color: var(--el-text-color-secondary);
|
||||
white-space: nowrap;
|
||||
}
|
||||
|
||||
.schedule-workbench__select {
|
||||
width: min(100%, 28rem);
|
||||
}
|
||||
|
||||
.schedule-workbench__worker {
|
||||
display: inline-flex;
|
||||
flex-wrap: wrap;
|
||||
align-items: center;
|
||||
gap: 6px 8px;
|
||||
font-size: 0.75rem;
|
||||
}
|
||||
|
||||
.schedule-stats-bar {
|
||||
display: flex;
|
||||
flex-wrap: wrap;
|
||||
gap: 16px 32px;
|
||||
padding: 12px 32px;
|
||||
border-bottom: 1px solid var(--el-border-color-lighter);
|
||||
}
|
||||
|
||||
.schedule-stat {
|
||||
display: inline-flex;
|
||||
align-items: baseline;
|
||||
gap: 8px;
|
||||
}
|
||||
|
||||
.schedule-stat__value {
|
||||
font-size: 1.125rem;
|
||||
font-weight: 700;
|
||||
color: var(--el-text-color-primary);
|
||||
}
|
||||
|
||||
.schedule-stat__label {
|
||||
font-size: 0.8125rem;
|
||||
color: var(--el-text-color-secondary);
|
||||
}
|
||||
|
||||
.schedule-workbench__runs-head {
|
||||
padding: 16px 32px 0;
|
||||
}
|
||||
|
||||
.schedule-filters {
|
||||
display: flex;
|
||||
flex-wrap: wrap;
|
||||
align-items: center;
|
||||
gap: 12px;
|
||||
padding: 12px 32px 16px;
|
||||
}
|
||||
|
||||
.schedule-filter-date {
|
||||
width: 11.5rem;
|
||||
}
|
||||
|
||||
.schedule-filter-status {
|
||||
width: 8rem;
|
||||
}
|
||||
|
||||
.schedule-cron {
|
||||
font-family: ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, monospace;
|
||||
font-size: 0.75rem;
|
||||
color: var(--el-text-color-secondary);
|
||||
}
|
||||
|
||||
.admin-table-wrap {
|
||||
margin: 0 32px 24px;
|
||||
border: 1px solid var(--el-border-color-lighter);
|
||||
border-radius: 8px;
|
||||
overflow: auto;
|
||||
}
|
||||
</style>
|
||||
@@ -1,11 +1,13 @@
|
||||
<script setup lang="ts">
|
||||
/**
|
||||
* features/admin/modules/schedules/components/SchedulesPageOverlays.vue
|
||||
* 定时任务页弹窗层:试运行、创建/编辑、删除确认。
|
||||
* 用途:定时任务页弹层——试运行、创建/编辑抽屉、删除确认。
|
||||
* 依赖:DeleteConfirmDialog、ScheduleCreateEditDrawer、ScheduleTestRunDialog、schedules.context。
|
||||
* 逻辑:由 SchedulesPage 挂载;创建/编辑已改为右侧 ElDrawer。
|
||||
*/
|
||||
<script setup lang="ts">
|
||||
import DeleteConfirmDialog from '@/shared/components/DeleteConfirmDialog.vue';
|
||||
import { useSchedulesAdminContext } from '../composables/schedules.context';
|
||||
import ScheduleCreateEditModal from './ScheduleCreateEditModal.vue';
|
||||
import ScheduleCreateEditDrawer from './ScheduleCreateEditDrawer.vue';
|
||||
import ScheduleTestRunDialog from './ScheduleTestRunDialog.vue';
|
||||
|
||||
const admin = useSchedulesAdminContext();
|
||||
@@ -13,7 +15,7 @@ const admin = useSchedulesAdminContext();
|
||||
|
||||
<template>
|
||||
<ScheduleTestRunDialog />
|
||||
<ScheduleCreateEditModal />
|
||||
<ScheduleCreateEditDrawer />
|
||||
<DeleteConfirmDialog
|
||||
v-model="admin.showDeleteConfirmDialog"
|
||||
:title="admin.deleteConfirmTitle"
|
||||
|
||||
Reference in new issue
Block a user