Merge branch 'dev' into test
This commit is contained in:
commit
736dab2c4e
25 files changed
+864
-200
No files matched your search
@@ -34,5 +34,13 @@ CASDOOR_SCOPE=openid profile email
|
||||
# Casdoor Providers → wecom(Name=wecom,与 prod 共用同一 Provider 即可)
|
||||
CASDOOR_WECOM_PROVIDER_HINT=wecom
|
||||
|
||||
# 知识库 Dify 对接
|
||||
PUBLIC_BASE_URL=http://192.168.100.192:8891
|
||||
DIFY_API_BASE=http://192.168.100.192:8882/v1
|
||||
DIFY_API_KEY=dataset-7xxs1P1QnqBmkEAjGhXLjmwF
|
||||
DEFAULT_ADMIN_USERNAME=admin
|
||||
DEFAULT_ADMIN_PASSWORD=admin123456
|
||||
TASK_EXECUTION_MODE=sync
|
||||
|
||||
# Gunicorn配置
|
||||
GUNICORN_WORKERS=10
|
||||
@@ -34,5 +34,13 @@ CASDOOR_SCOPE=openid profile email
|
||||
# Casdoor Providers → wecom:Name 字段(截图即为 wecom);Organization=organization_HX,Sub type=Internal,Scope=snsapi_userinfo
|
||||
CASDOOR_WECOM_PROVIDER_HINT=wecom
|
||||
|
||||
# 知识库 Dify 对接
|
||||
PUBLIC_BASE_URL=http://192.168.100.230:8891
|
||||
DIFY_API_BASE=http://192.168.100.230:8882/v1
|
||||
DIFY_API_KEY=dataset-7xxs1P1QnqBmkEAjGhXLjmwF
|
||||
DEFAULT_ADMIN_USERNAME=admin
|
||||
DEFAULT_ADMIN_PASSWORD=admin123456
|
||||
TASK_EXECUTION_MODE=rq
|
||||
|
||||
# Gunicorn配置
|
||||
GUNICORN_WORKERS=20
|
||||
@@ -33,6 +33,14 @@ CASDOOR_SCOPE=openid profile email
|
||||
# Casdoor Providers → wecom:Name 字段(截图即为 wecom);Organization=organization_HX,Sub type=Internal,Scope=snsapi_userinfo
|
||||
CASDOOR_WECOM_PROVIDER_HINT=wecom
|
||||
|
||||
# 知识库 Dify 对接
|
||||
PUBLIC_BASE_URL=http://192.168.100.192:8891
|
||||
DIFY_API_BASE=http://192.168.100.192:8882/v1
|
||||
DIFY_API_KEY=dataset-7xxs1P1QnqBmkEAjGhXLjmwF
|
||||
DEFAULT_ADMIN_USERNAME=admin
|
||||
DEFAULT_ADMIN_PASSWORD=admin123456
|
||||
TASK_EXECUTION_MODE=rq
|
||||
|
||||
# Gunicorn配置
|
||||
GUNICORN_WORKERS=6
|
||||
|
||||
|
||||
@@ -8,6 +8,7 @@ from flask import Blueprint, jsonify, request
|
||||
from app import db
|
||||
from app.models import ScheduleRun, ScheduleTask
|
||||
from app.services.schedule import _run_generic_check_job
|
||||
from app.services.schedule.dify_snapshot import capture_dify_execution_snapshot
|
||||
|
||||
internal_jobs_bp = Blueprint('internal_jobs', __name__)
|
||||
|
||||
@@ -47,6 +48,10 @@ def run_internal_job(name: str):
|
||||
db.session.add(run)
|
||||
db.session.commit()
|
||||
|
||||
if not run.dify_execution_snapshot:
|
||||
capture_dify_execution_snapshot(run, task)
|
||||
db.session.commit()
|
||||
|
||||
try:
|
||||
total_count, success_count, failed_count, skipped_count, details, errors, step_logs = _run_generic_check_job(task, run)
|
||||
except Exception as exc:
|
||||
@@ -68,6 +73,7 @@ def run_internal_job(name: str):
|
||||
run.finished_at = datetime.utcnow()
|
||||
if run.started_at and run.finished_at:
|
||||
run.duration_ms = int((run.finished_at - run.started_at).total_seconds() * 1000)
|
||||
run.step_logs = step_logs if step_logs else None
|
||||
db.session.commit()
|
||||
|
||||
return jsonify({
|
||||
|
||||
@@ -1036,10 +1036,11 @@ def delete_document(document_id: int):
|
||||
if not document or document.is_deleted:
|
||||
return jsonify({'error': 'Knowledge base document not found'}), 404
|
||||
|
||||
delete_result = None
|
||||
try:
|
||||
delete_result = delete_document_from_dify(document.id)
|
||||
except Exception as exc:
|
||||
return jsonify({'error': f'删除 Dify 远端文档失败:{exc}'}), 400
|
||||
except Exception:
|
||||
pass
|
||||
|
||||
document.is_deleted = True
|
||||
document.updated_by_id = getattr(current_user, 'id', None)
|
||||
|
||||
@@ -62,6 +62,7 @@ def _serialize_task_config(cfg_model: ScheduleTaskConfig) -> dict:
|
||||
"headers": cfg_model.api_headers or {},
|
||||
"body_template": cfg_model.api_body_template or "",
|
||||
},
|
||||
"dify_system_prompt": cfg_model.dify_system_prompt or "",
|
||||
}
|
||||
|
||||
|
||||
@@ -206,6 +207,10 @@ def test_schedule_run(task_id: int):
|
||||
db.session.add(run)
|
||||
db.session.commit()
|
||||
|
||||
from app.services.schedule.dify_snapshot import capture_dify_execution_snapshot
|
||||
capture_dify_execution_snapshot(run, task)
|
||||
db.session.commit()
|
||||
|
||||
if not cfg.fetch_sql:
|
||||
run.status = 'success'
|
||||
run.finished_at = datetime.utcnow()
|
||||
@@ -289,6 +294,7 @@ def test_schedule_run(task_id: int):
|
||||
fetch_sql=test_sql,
|
||||
max_rows=limit,
|
||||
pre_dify_fn=test_pre_dify,
|
||||
dify_system_prompt=cfg.dify_system_prompt,
|
||||
)
|
||||
|
||||
duration_ms = int((_time.time() - start_ts) * 1000)
|
||||
@@ -363,6 +369,7 @@ def test_schedule_run(task_id: int):
|
||||
"errors": errors,
|
||||
"step_logs": step_logs,
|
||||
"dify_agent_id": dify_agent_id,
|
||||
"dify_execution_snapshot": run.dify_execution_snapshot,
|
||||
})
|
||||
except Exception as e:
|
||||
duration_ms = int((_time.time() - start_ts) * 1000)
|
||||
@@ -510,6 +517,11 @@ def post_schedule():
|
||||
config_data = data.get('config')
|
||||
if config_data:
|
||||
upsert_schedule_task_config(task.id, config_data)
|
||||
if not task.dify_agent_id:
|
||||
cfg_model = ScheduleTaskConfig.query.filter_by(schedule_task_id=task.id).first()
|
||||
if cfg_model and cfg_model.dify_system_prompt:
|
||||
cfg_model.dify_system_prompt = None
|
||||
db.session.commit()
|
||||
|
||||
return jsonify(serialize_task(task)), 201
|
||||
|
||||
@@ -541,6 +553,13 @@ def patch_schedule(task_id: int):
|
||||
upsert_schedule_task_config(task_id, config_data)
|
||||
|
||||
task = update_task(task, payload=data, actor_id=getattr(user, 'id', None))
|
||||
|
||||
if not task.dify_agent_id:
|
||||
cfg_model = ScheduleTaskConfig.query.filter_by(schedule_task_id=task_id).first()
|
||||
if cfg_model and cfg_model.dify_system_prompt:
|
||||
cfg_model.dify_system_prompt = None
|
||||
db.session.commit()
|
||||
|
||||
return jsonify(serialize_task(task))
|
||||
|
||||
|
||||
|
||||
@@ -39,7 +39,7 @@ def _load_environment_files() -> str:
|
||||
|
||||
env_file = _ROOT_DIR / f'.env.{env_name}'
|
||||
if env_file.exists():
|
||||
load_dotenv(env_file, override=False)
|
||||
load_dotenv(env_file, override=True)
|
||||
|
||||
if env_name == 'dev':
|
||||
local_file = _ROOT_DIR / '.env.local'
|
||||
@@ -64,6 +64,10 @@ class Config:
|
||||
'pool_recycle': 3600,
|
||||
'pool_pre_ping': True,
|
||||
}
|
||||
PUBLIC_BASE_URL = os.getenv('PUBLIC_BASE_URL')
|
||||
DEFAULT_ADMIN_USERNAME = os.getenv('DEFAULT_ADMIN_USERNAME')
|
||||
DEFAULT_ADMIN_PASSWORD = os.getenv('DEFAULT_ADMIN_PASSWORD')
|
||||
TASK_EXECUTION_MODE = os.getenv('TASK_EXECUTION_MODE', 'sync').strip().lower()
|
||||
# Dify 网关配置
|
||||
DIFY_API_BASE = os.getenv('DIFY_API_BASE')
|
||||
DIFY_API_KEY = os.getenv('DIFY_API_KEY')
|
||||
|
||||
@@ -613,6 +613,7 @@ class ScheduleTaskConfig(Base):
|
||||
api_method: Mapped[str] = mapped_column(String(16), default='POST')
|
||||
api_headers: Mapped[Optional[dict]] = mapped_column(JSON, default={})
|
||||
api_body_template: Mapped[Optional[str]] = mapped_column(Text, nullable=True)
|
||||
dify_system_prompt: Mapped[Optional[str]] = mapped_column(Text, nullable=True)
|
||||
|
||||
created_at: Mapped[datetime] = mapped_column(default=datetime.utcnow)
|
||||
updated_at: Mapped[datetime] = mapped_column(default=datetime.utcnow, onupdate=datetime.utcnow)
|
||||
@@ -644,6 +645,7 @@ class ScheduleRun(Base):
|
||||
api_response_json: Mapped[Optional[dict]] = mapped_column(JSON)
|
||||
response_summary_json: Mapped[Optional[dict]] = mapped_column(JSON)
|
||||
step_logs: Mapped[Optional[list]] = mapped_column(JSON)
|
||||
dify_execution_snapshot: Mapped[Optional[dict]] = mapped_column(JSON)
|
||||
error_message: Mapped[Optional[str]] = mapped_column(Text)
|
||||
excel_file_data: Mapped[Optional[bytes]] = mapped_column(LargeBinary)
|
||||
excel_file_name: Mapped[Optional[str]] = mapped_column(String(255))
|
||||
|
||||
@@ -17,7 +17,10 @@ def enqueue_kb_job(job_id: int) -> tuple[bool, str]:
|
||||
- worker: 仅保留 queued,等待独立 worker 轮询;
|
||||
- manual: 保留 queued,等待管理台手动执行。
|
||||
"""
|
||||
mode = str(current_app.config.get('KB_TASK_EXECUTION_MODE', 'sync')).strip().lower()
|
||||
mode = str(
|
||||
current_app.config.get('TASK_EXECUTION_MODE')
|
||||
or current_app.config.get('KB_TASK_EXECUTION_MODE', 'sync')
|
||||
).strip().lower()
|
||||
|
||||
job = db.session.get(KbJob, job_id)
|
||||
if not job:
|
||||
@@ -32,7 +35,7 @@ def enqueue_kb_job(job_id: int) -> tuple[bool, str]:
|
||||
return run_path_upload_job(job_id)
|
||||
return False, f'unsupported_sync_job:{job.job_type}'
|
||||
|
||||
if mode == 'worker':
|
||||
if mode in ('worker', 'rq'):
|
||||
return True, 'queued_for_worker'
|
||||
|
||||
return True, 'queued_manual'
|
||||
|
||||
@@ -258,6 +258,7 @@ def _run_generic_check_job(task: ScheduleTask, run: ScheduleRun) -> ScheduleExec
|
||||
log_prefix=cfg.log_prefix,
|
||||
fetch_sql=cfg.fetch_sql,
|
||||
pre_dify_fn=pre_dify_fn,
|
||||
dify_system_prompt=cfg.dify_system_prompt,
|
||||
)
|
||||
|
||||
|
||||
|
||||
@@ -0,0 +1,40 @@
|
||||
from __future__ import annotations
|
||||
|
||||
from datetime import datetime
|
||||
from typing import Any
|
||||
|
||||
from app import db
|
||||
from app.models import Agent, ScheduleRun, ScheduleTask
|
||||
from app.services.schedule.sql_config import get_schedule_sql_config_by_task_id
|
||||
|
||||
|
||||
def build_dify_execution_snapshot(task: ScheduleTask) -> dict[str, Any]:
|
||||
"""Capture Dify agent + system prompt used at execution time for audit."""
|
||||
captured_at = datetime.utcnow().isoformat() + "Z"
|
||||
if not task.dify_agent_id:
|
||||
return {
|
||||
"dify_enabled": False,
|
||||
"dify_agent_id": None,
|
||||
"dify_agent_name": None,
|
||||
"dify_app_id": None,
|
||||
"dify_system_prompt": "",
|
||||
"captured_at": captured_at,
|
||||
}
|
||||
|
||||
cfg = get_schedule_sql_config_by_task_id(task.id)
|
||||
prompt = str(cfg.dify_system_prompt if cfg else "").strip()
|
||||
agent = db.session.get(Agent, task.dify_agent_id)
|
||||
return {
|
||||
"dify_enabled": True,
|
||||
"dify_agent_id": task.dify_agent_id,
|
||||
"dify_agent_name": getattr(agent, "name", None) if agent else None,
|
||||
"dify_app_id": getattr(agent, "dify_app_id", None) if agent else None,
|
||||
"dify_system_prompt": prompt,
|
||||
"captured_at": captured_at,
|
||||
}
|
||||
|
||||
|
||||
def capture_dify_execution_snapshot(run: ScheduleRun, task: ScheduleTask) -> dict[str, Any]:
|
||||
snapshot = build_dify_execution_snapshot(task)
|
||||
run.dify_execution_snapshot = snapshot
|
||||
return snapshot
|
||||
@@ -54,6 +54,7 @@ def serialize_run(run: ScheduleRun) -> dict:
|
||||
'api_response_json': run.api_response_json,
|
||||
'response_summary_json': run.response_summary_json,
|
||||
'step_logs': run.step_logs,
|
||||
'dify_execution_snapshot': run.dify_execution_snapshot,
|
||||
'error_message': run.error_message,
|
||||
'excel_file_name': run.excel_file_name,
|
||||
'excel_file_size': run.excel_file_size,
|
||||
|
||||
@@ -14,6 +14,7 @@ from app.models import ScheduleRun, ScheduleTask, User
|
||||
from app.services.schedule import normalize_platform_api_path, resolve_schedule_executor, resolve_schedule_header
|
||||
from app.services.schedule.sql_config import get_schedule_sql_config_by_task_id
|
||||
from app.services.schedule.excel_service import export_schedule_result_excel
|
||||
from app.services.schedule.dify_snapshot import capture_dify_execution_snapshot
|
||||
|
||||
_worker_started = False
|
||||
_worker_lock = threading.Lock()
|
||||
@@ -248,6 +249,9 @@ def run_task_now(task: ScheduleTask, *, trigger_type: str, triggered_by_user_id:
|
||||
db.session.add(run)
|
||||
db.session.commit()
|
||||
|
||||
capture_dify_execution_snapshot(run, task)
|
||||
db.session.commit()
|
||||
|
||||
if task.cron_expr and trigger_type == "cron":
|
||||
try:
|
||||
iter = croniter(task.cron_expr, datetime.utcnow())
|
||||
|
||||
@@ -94,6 +94,7 @@ class ScheduleSqlConfig:
|
||||
data_source: DataSourceConfig = field(default_factory=DataSourceConfig)
|
||||
external_api: ExternalApiConfig = field(default_factory=ExternalApiConfig)
|
||||
data_source_type: str = "database"
|
||||
dify_system_prompt: str = ""
|
||||
|
||||
|
||||
def _build_fetch_sql(base: str, where_conds: str, order_by: str) -> str:
|
||||
@@ -153,6 +154,7 @@ def _config_from_model(cfg_model: Any) -> ScheduleSqlConfig:
|
||||
data_source=ds,
|
||||
external_api=ext,
|
||||
data_source_type=str(task.data_source_type if task else "database"),
|
||||
dify_system_prompt=str(cfg_model.dify_system_prompt or ""),
|
||||
)
|
||||
|
||||
|
||||
@@ -233,6 +235,8 @@ def upsert_schedule_task_config(task_id: int, data: dict[str, Any]) -> ScheduleS
|
||||
setattr(cfg_model, k, list(v) if isinstance(v, (list, tuple)) else [])
|
||||
elif k == "header_labels":
|
||||
setattr(cfg_model, k, dict(v) if isinstance(v, dict) else {})
|
||||
elif k == "dify_system_prompt":
|
||||
setattr(cfg_model, k, str(v) if v is not None else None)
|
||||
|
||||
db.session.commit()
|
||||
db.session.refresh(cfg_model)
|
||||
|
||||
@@ -117,6 +117,17 @@ def _truncate_str(s: str, max_len: int = _MAX_DIFY_RESPONSE_LEN) -> str:
|
||||
return s[:max_len] + f"...[truncated, total {len(s)} chars]"
|
||||
|
||||
|
||||
def _serialize_dify_inputs_for_log(inputs: dict[str, Any]) -> dict[str, Any]:
|
||||
"""Log Dify request inputs; keep system_prompt intact for audit."""
|
||||
out: dict[str, Any] = {}
|
||||
for k, v in inputs.items():
|
||||
if k == "system_prompt":
|
||||
out[k] = str(v)
|
||||
else:
|
||||
out[k] = _truncate_str(str(v), 500)
|
||||
return out
|
||||
|
||||
|
||||
def _run_check_job_loop(
|
||||
*,
|
||||
conn_str: str,
|
||||
@@ -134,6 +145,7 @@ def _run_check_job_loop(
|
||||
fetch_sql: str = "",
|
||||
max_rows: int = 0,
|
||||
pre_dify_fn: PreDifyFunc | None = None,
|
||||
dify_system_prompt: str = "",
|
||||
) -> tuple[int, int, int, int, list[dict[str, Any]], list[str], list[dict[str, Any]]]:
|
||||
from app.services.schedule.scheduler_service import is_run_cancelled
|
||||
|
||||
@@ -218,6 +230,9 @@ def _run_check_job_loop(
|
||||
"record": record_text,
|
||||
"attachment_url": attachment_url,
|
||||
}
|
||||
prompt = str(dify_system_prompt or "").strip()
|
||||
if prompt:
|
||||
dify_inputs["system_prompt"] = prompt
|
||||
t_dify = _ts()
|
||||
try:
|
||||
dify_res = DifyService.run_workflow_streaming(
|
||||
@@ -228,7 +243,10 @@ def _run_check_job_loop(
|
||||
)
|
||||
except Exception as dify_exc:
|
||||
step_logs.append(_make_step("call_dify", "failed", t_dify, _ts(), row_id=row_id_value, detail={
|
||||
"request": {"inputs": {k: _truncate_str(str(v), 500) for k, v in dify_inputs.items()}, "agent_id": getattr(agent, "id", None)},
|
||||
"request": {
|
||||
"inputs": _serialize_dify_inputs_for_log(dify_inputs),
|
||||
"agent_id": getattr(agent, "id", None),
|
||||
},
|
||||
"error": str(dify_exc),
|
||||
}))
|
||||
raise
|
||||
@@ -243,7 +261,10 @@ def _run_check_job_loop(
|
||||
dify_message = f"Dify执行失败:{err_detail}"
|
||||
|
||||
step_logs.append(_make_step("call_dify", "failed", t_dify, _ts(), row_id=row_id_value, detail={
|
||||
"request": {"inputs": {k: _truncate_str(str(v), 500) for k, v in dify_inputs.items()}, "agent_id": getattr(agent, "id", None)},
|
||||
"request": {
|
||||
"inputs": _serialize_dify_inputs_for_log(dify_inputs),
|
||||
"agent_id": getattr(agent, "id", None),
|
||||
},
|
||||
"response": _truncate_str(str(dify_res)),
|
||||
"workflow_run_id": workflow_run_id,
|
||||
}))
|
||||
@@ -271,7 +292,10 @@ def _run_check_job_loop(
|
||||
dify_ok = True
|
||||
|
||||
step_logs.append(_make_step("call_dify", "success", t_dify, _ts(), row_id=row_id_value, detail={
|
||||
"request": {"inputs": {k: _truncate_str(str(v), 500) for k, v in dify_inputs.items()}, "agent_id": getattr(agent, "id", None)},
|
||||
"request": {
|
||||
"inputs": _serialize_dify_inputs_for_log(dify_inputs),
|
||||
"agent_id": getattr(agent, "id", None),
|
||||
},
|
||||
"response": {
|
||||
"status": dify_status,
|
||||
"dify_result": dify_result,
|
||||
|
||||
Binary file not shown.
+25
@@ -0,0 +1,25 @@
|
||||
"""add_dify_system_prompt_to_schedule_configs
|
||||
|
||||
Revision ID: d2e3f4a5b6c7
|
||||
Revises: c1d2e3f4a5b6
|
||||
Create Date: 2026-05-25
|
||||
|
||||
"""
|
||||
from alembic import op
|
||||
import sqlalchemy as sa
|
||||
|
||||
|
||||
revision = 'd2e3f4a5b6c7'
|
||||
down_revision = 'c1d2e3f4a5b6'
|
||||
branch_labels = None
|
||||
depends_on = None
|
||||
|
||||
|
||||
def upgrade():
|
||||
with op.batch_alter_table('schedule_task_configs', schema=None) as batch_op:
|
||||
batch_op.add_column(sa.Column('dify_system_prompt', sa.Text(), nullable=True))
|
||||
|
||||
|
||||
def downgrade():
|
||||
with op.batch_alter_table('schedule_task_configs', schema=None) as batch_op:
|
||||
batch_op.drop_column('dify_system_prompt')
|
||||
+25
@@ -0,0 +1,25 @@
|
||||
"""add_dify_execution_snapshot_to_schedule_runs
|
||||
|
||||
Revision ID: e3f4a5b6c7d8
|
||||
Revises: d2e3f4a5b6c7
|
||||
Create Date: 2026-05-25
|
||||
|
||||
"""
|
||||
from alembic import op
|
||||
import sqlalchemy as sa
|
||||
|
||||
|
||||
revision = 'e3f4a5b6c7d8'
|
||||
down_revision = 'd2e3f4a5b6c7'
|
||||
branch_labels = None
|
||||
depends_on = None
|
||||
|
||||
|
||||
def upgrade():
|
||||
with op.batch_alter_table('schedule_runs', schema=None) as batch_op:
|
||||
batch_op.add_column(sa.Column('dify_execution_snapshot', sa.JSON(), nullable=True))
|
||||
|
||||
|
||||
def downgrade():
|
||||
with op.batch_alter_table('schedule_runs', schema=None) as batch_op:
|
||||
batch_op.drop_column('dify_execution_snapshot')
|
||||
@@ -40,6 +40,7 @@ export interface ScheduleRun {
|
||||
api_response_json?: Record<string, any> | null;
|
||||
response_summary_json?: Record<string, any> | null;
|
||||
step_logs?: StepLog[] | null;
|
||||
dify_execution_snapshot?: DifyExecutionSnapshot | null;
|
||||
error_message?: string | null;
|
||||
excel_file_name?: string | null;
|
||||
excel_file_size?: number | null;
|
||||
@@ -59,6 +60,15 @@ export interface StepLog {
|
||||
detail?: Record<string, any>;
|
||||
}
|
||||
|
||||
export interface DifyExecutionSnapshot {
|
||||
dify_enabled?: boolean;
|
||||
dify_agent_id?: number | null;
|
||||
dify_agent_name?: string | null;
|
||||
dify_app_id?: string | null;
|
||||
dify_system_prompt?: string;
|
||||
captured_at?: string;
|
||||
}
|
||||
|
||||
async function getJson<T>(url: string): Promise<T> {
|
||||
const res = await fetch(url, { headers: getAuthHeaders() });
|
||||
if (!res.ok) throw new Error((await res.json().catch(() => ({})))?.error || 'Request failed');
|
||||
@@ -119,6 +129,7 @@ export interface TestScheduleRunResult {
|
||||
errors: string[];
|
||||
step_logs: StepLog[];
|
||||
dify_agent_id: number | null;
|
||||
dify_execution_snapshot?: DifyExecutionSnapshot | null;
|
||||
}
|
||||
|
||||
export const testAdminScheduleRun = (taskId: number, payload: { fetch_where_conditions?: string; fetch_order_by?: string; limit?: number }) =>
|
||||
|
||||
@@ -73,41 +73,43 @@ onBeforeUnmount(() => {
|
||||
</script>
|
||||
|
||||
<template>
|
||||
<Transition name="delete-dialog-fade">
|
||||
<div
|
||||
v-if="modelValue"
|
||||
class="fixed inset-0 z-[100] bg-black/45 flex items-center justify-center p-4"
|
||||
@click.self="handleCancel"
|
||||
>
|
||||
<div class="delete-dialog-container w-full max-w-[416px] rounded-lg bg-white shadow-[0_6px_16px_0_rgba(0,0,0,0.08),0_3px_6px_-4px_rgba(0,0,0,0.12),0_9px_28px_8px_rgba(0,0,0,0.05)] px-6 pt-7 pb-5">
|
||||
<div class="flex items-start gap-3">
|
||||
<span class="delete-dialog-icon" aria-hidden="true">!</span>
|
||||
<div class="min-w-0">
|
||||
<h3 class="text-[16px] leading-6 font-semibold text-[rgba(0,0,0,0.88)]">
|
||||
{{ resolvedTitle }}
|
||||
</h3>
|
||||
<p class="mt-3 text-[14px] leading-[22px] text-[rgba(0,0,0,0.65)] whitespace-pre-line">
|
||||
{{ resolvedMessage }}
|
||||
</p>
|
||||
<Teleport to="body">
|
||||
<Transition name="delete-dialog-fade">
|
||||
<div
|
||||
v-if="modelValue"
|
||||
class="fixed inset-0 z-[100] bg-black/45 flex items-center justify-center p-4"
|
||||
@click.self="handleCancel"
|
||||
>
|
||||
<div class="delete-dialog-container w-full max-w-[416px] rounded-lg bg-white shadow-[0_6px_16px_0_rgba(0,0,0,0.08),0_3px_6px_-4px_rgba(0,0,0,0.12),0_9px_28px_8px_rgba(0,0,0,0.05)] px-6 pt-7 pb-5">
|
||||
<div class="flex items-start gap-3">
|
||||
<span class="delete-dialog-icon" aria-hidden="true">!</span>
|
||||
<div class="min-w-0">
|
||||
<h3 class="text-[16px] leading-6 font-semibold text-[rgba(0,0,0,0.88)]">
|
||||
{{ resolvedTitle }}
|
||||
</h3>
|
||||
<p class="mt-3 text-[14px] leading-[22px] text-[rgba(0,0,0,0.65)] whitespace-pre-line">
|
||||
{{ resolvedMessage }}
|
||||
</p>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="mt-6 flex justify-end gap-2">
|
||||
<button type="button" class="delete-dialog-btn cancel" @click="handleCancel">
|
||||
{{ resolvedCancelText }}
|
||||
</button>
|
||||
<button
|
||||
type="button"
|
||||
class="delete-dialog-btn confirm"
|
||||
:disabled="confirmLoading"
|
||||
@click="handleConfirm"
|
||||
>
|
||||
{{ resolvedConfirmText }}
|
||||
</button>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="mt-6 flex justify-end gap-2">
|
||||
<button type="button" class="delete-dialog-btn cancel" @click="handleCancel">
|
||||
{{ resolvedCancelText }}
|
||||
</button>
|
||||
<button
|
||||
type="button"
|
||||
class="delete-dialog-btn confirm"
|
||||
:disabled="confirmLoading"
|
||||
@click="handleConfirm"
|
||||
>
|
||||
{{ resolvedConfirmText }}
|
||||
</button>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</Transition>
|
||||
</Transition>
|
||||
</Teleport>
|
||||
</template>
|
||||
|
||||
<style scoped>
|
||||
|
||||
+308
-8
@@ -452,7 +452,8 @@ const messages = {
|
||||
wecom: 'WeCom',
|
||||
permissions: 'App Permissions',
|
||||
requests: 'Permission Requests',
|
||||
reports: 'Data Reports'
|
||||
reports: 'Data Reports',
|
||||
schedules: 'Schedule Management'
|
||||
},
|
||||
|
||||
// Dashboard
|
||||
@@ -1010,6 +1011,135 @@ const messages = {
|
||||
|
||||
// Common Messages
|
||||
schedule: {
|
||||
overviewTitle: 'Schedule Management Overview',
|
||||
workbenchTitle: 'Schedule Management Workbench',
|
||||
overviewSubtitle: 'Click a schedule card to open the workbench.',
|
||||
workbenchSubtitle: 'Schedule list on the left, run records on the right.',
|
||||
refresh: 'Refresh schedules',
|
||||
stats: {
|
||||
total: 'Total schedules',
|
||||
enabled: 'Enabled',
|
||||
disabled: 'Disabled',
|
||||
running: 'Running'
|
||||
},
|
||||
sectionOverview: 'Schedule Management Overview',
|
||||
switchByCard: 'Switch by card',
|
||||
addTitle: 'Add schedule',
|
||||
addHint: 'Click the button to fill in schedule fields in a dialog.',
|
||||
addButton: 'Add schedule',
|
||||
emptyList: 'No schedules yet. Create one first.',
|
||||
loading: 'Loading...',
|
||||
enabled: 'Enabled',
|
||||
disabled: 'Disabled',
|
||||
scheduleNo: 'No.',
|
||||
config: 'Config',
|
||||
owner: 'Owner',
|
||||
lastRun: 'Last run',
|
||||
nextRun: 'Next run',
|
||||
noSelection: 'No schedule selected',
|
||||
selectedHint: 'Selected schedule · Last run {time}',
|
||||
runBatches: 'Run batches',
|
||||
totalProcessed: 'Total processed',
|
||||
totalSuccess: 'Total success',
|
||||
totalFailed: 'Total failed',
|
||||
listTitle: 'Schedule list',
|
||||
recordsTitle: '{name} · Run records',
|
||||
recordsSubtitle: 'Run record details are shown below.',
|
||||
noSelectionHint: 'Select a schedule from the list on the left first.',
|
||||
filterStart: 'Start',
|
||||
filterEnd: 'End',
|
||||
query: 'Search',
|
||||
reset: 'Reset',
|
||||
queryingRuns: 'Loading records...',
|
||||
noRunRecords: 'No run records yet.',
|
||||
runLogs: 'Run logs',
|
||||
stepsCount: '{count} steps',
|
||||
viewDetail: 'View details',
|
||||
resizeColumn: 'Drag to resize {label} column',
|
||||
notified: 'Notified',
|
||||
notifyError: 'Error',
|
||||
download: 'Download',
|
||||
log: 'Log',
|
||||
actions: {
|
||||
edit: 'Edit',
|
||||
start: 'Start',
|
||||
pause: 'Pause',
|
||||
run: 'Run',
|
||||
test: 'Test',
|
||||
delete: 'Delete'
|
||||
},
|
||||
columns: {
|
||||
runNo: 'Run ID',
|
||||
startedAt: 'Started at',
|
||||
finishedAt: 'Finished at',
|
||||
status: 'Status',
|
||||
totalCount: 'Processed',
|
||||
successCount: 'Success',
|
||||
failedCount: 'Failed',
|
||||
wecomNotified: 'WeCom notify',
|
||||
detail: 'Detail',
|
||||
log: 'Log'
|
||||
},
|
||||
form: {
|
||||
editTitle: 'Edit schedule',
|
||||
createTitle: 'Add schedule',
|
||||
name: 'Schedule name',
|
||||
namePlaceholder: 'e.g. RoHS auto review schedule',
|
||||
owner: 'Schedule owner',
|
||||
noUsers: 'No users available',
|
||||
selectOwner: 'Select an owner',
|
||||
dataSourceConfig: 'Data source & execution config',
|
||||
databaseDirect: 'Database',
|
||||
externalApi: 'External API',
|
||||
querying: 'Querying...',
|
||||
testQuery: 'Test query',
|
||||
expandConfig: 'Expand config',
|
||||
collapseConfig: 'Collapse config',
|
||||
dataSourceSection: 'Data source config',
|
||||
waitSeconds: 'Wait time (seconds)',
|
||||
noAgents: 'No agents available',
|
||||
agentDisabled: 'Disabled',
|
||||
cronTitle: 'Cron visual editor',
|
||||
cronHint: 'Cron expression is generated automatically from the frequency you choose.',
|
||||
everyMinutes: 'Every N minutes',
|
||||
hourly: 'Hourly',
|
||||
daily: 'Daily',
|
||||
weekly: 'Weekly',
|
||||
minuteInterval: 'Minute interval',
|
||||
minuteOfHour: 'Minute of hour',
|
||||
hour: 'Hour',
|
||||
minute: 'Minute',
|
||||
weekday: 'Weekday',
|
||||
cronPreview: 'Cron preview',
|
||||
nextRun: 'Next run',
|
||||
notifyEnabled: 'Enable notifications',
|
||||
selectNotifyUsers: 'Select notification recipients...',
|
||||
enableOnCreate: 'Enable after creation',
|
||||
cancel: 'Cancel',
|
||||
saving: 'Saving...',
|
||||
saveChanges: 'Save changes',
|
||||
createSchedule: 'Create schedule'
|
||||
},
|
||||
testRun: {
|
||||
title: 'Test run — {name}',
|
||||
subtitle: 'Edit WHERE clause, limit rows, run quickly and inspect each step',
|
||||
close: 'Close',
|
||||
running: 'Running...',
|
||||
start: 'Start test run',
|
||||
waitingHint: 'Dify calls may take a while, please wait...',
|
||||
total: 'Total',
|
||||
success: 'Success',
|
||||
failed: 'Failed',
|
||||
skipped: 'Skipped',
|
||||
limitSummary: 'Limit {limit} rows | Dify Agent ID: {agentId}',
|
||||
noAgent: 'None',
|
||||
stepLogs: 'Step logs',
|
||||
viewSql: 'View execution SQL',
|
||||
errors: 'Errors ({count})',
|
||||
queryResult: 'Query result',
|
||||
resultSummary: '{total} total, showing {showing}',
|
||||
viewGeneratedSql: 'View generated SQL'
|
||||
},
|
||||
status: {
|
||||
all: 'All',
|
||||
success: 'Success',
|
||||
@@ -1038,6 +1168,7 @@ const messages = {
|
||||
deleteConfirmMessage: 'Confirm deleting schedule \"{name}\"?',
|
||||
msg: {
|
||||
testRunFailed: 'Test run failed',
|
||||
testQueryFailed: 'Test query failed',
|
||||
configRequired: 'At least one of Dify Agent, SQL config, or external API is required.',
|
||||
headerLabelsJsonInvalid: 'header_labels JSON format is invalid.',
|
||||
apiHeadersJsonInvalid: 'API Headers JSON format is invalid.',
|
||||
@@ -1225,7 +1356,16 @@ const messages = {
|
||||
oaDataConnected: 'Connected to OA database view query.',
|
||||
searchByNameOrEmployeeId: 'Search by name or employee ID, press Enter',
|
||||
name: 'Name',
|
||||
employeeIdRequired: 'Employee ID is required.'
|
||||
employeeIdRequired: 'Employee ID is required.',
|
||||
actions: {
|
||||
copy: 'Copy',
|
||||
edit: 'Edit',
|
||||
resend: 'Resend',
|
||||
regenerate: 'Regenerate',
|
||||
copySuccess: 'Copied',
|
||||
copyFailed: 'Copy failed. Please allow clipboard access or try again.',
|
||||
copyEmpty: 'Nothing to copy'
|
||||
}
|
||||
},
|
||||
profile: {
|
||||
title: 'Profile',
|
||||
@@ -1766,7 +1906,8 @@ const messages = {
|
||||
wecom: '企业微信',
|
||||
permissions: '应用权限',
|
||||
requests: '权限审批',
|
||||
reports: '数据报表'
|
||||
reports: '数据报表',
|
||||
schedules: '排程管理'
|
||||
},
|
||||
|
||||
// Dashboard
|
||||
@@ -2303,6 +2444,135 @@ const messages = {
|
||||
|
||||
// Common Messages
|
||||
schedule: {
|
||||
overviewTitle: '排程管理概览',
|
||||
workbenchTitle: '排程管理工作台',
|
||||
overviewSubtitle: '点击排程卡片进入排程工作台。',
|
||||
workbenchSubtitle: '左侧排程列表,右侧执行记录列表。',
|
||||
refresh: '刷新排程',
|
||||
stats: {
|
||||
total: '排程总数',
|
||||
enabled: '启用中',
|
||||
disabled: '停用中',
|
||||
running: '执行中'
|
||||
},
|
||||
sectionOverview: '排程管理概览',
|
||||
switchByCard: '按卡片切换',
|
||||
addTitle: '新增排程',
|
||||
addHint: '点击按钮后弹窗录入排程字段。',
|
||||
addButton: '新增排程',
|
||||
emptyList: '暂无排程,请先创建。',
|
||||
loading: '正在加载...',
|
||||
enabled: '启用',
|
||||
disabled: '停用',
|
||||
scheduleNo: '编号',
|
||||
config: '配置',
|
||||
owner: '所有者',
|
||||
lastRun: '最近执行',
|
||||
nextRun: '下次执行',
|
||||
noSelection: '未选择排程',
|
||||
selectedHint: '当前选中排程 · 最近执行 {time}',
|
||||
runBatches: '执行批次',
|
||||
totalProcessed: '处理总数',
|
||||
totalSuccess: '成功总数',
|
||||
totalFailed: '失败总数',
|
||||
listTitle: '排程列表',
|
||||
recordsTitle: '{name} · 执行记录',
|
||||
recordsSubtitle: '下方仅展示执行记录明细。',
|
||||
noSelectionHint: '未选择排程,请先在左侧列表选择一个排程。',
|
||||
filterStart: '开始',
|
||||
filterEnd: '结束',
|
||||
query: '查询',
|
||||
reset: '重置',
|
||||
queryingRuns: '正在查询记录...',
|
||||
noRunRecords: '暂无执行记录。',
|
||||
runLogs: '执行日志',
|
||||
stepsCount: '共 {count} 步',
|
||||
viewDetail: '查看详情',
|
||||
resizeColumn: '拖拽调整{label}列宽',
|
||||
notified: '已通知',
|
||||
notifyError: '异常',
|
||||
download: '下载',
|
||||
log: '日志',
|
||||
actions: {
|
||||
edit: '编辑',
|
||||
start: '启动',
|
||||
pause: '暂停',
|
||||
run: '执行',
|
||||
test: '测试',
|
||||
delete: '删除'
|
||||
},
|
||||
columns: {
|
||||
runNo: '执行单号',
|
||||
startedAt: '开始时间',
|
||||
finishedAt: '结束时间',
|
||||
status: '状态',
|
||||
totalCount: '处理',
|
||||
successCount: '成功',
|
||||
failedCount: '失败',
|
||||
wecomNotified: '企微通知',
|
||||
detail: '明细',
|
||||
log: '日志'
|
||||
},
|
||||
form: {
|
||||
editTitle: '编辑排程',
|
||||
createTitle: '新增排程',
|
||||
name: '排程名称',
|
||||
namePlaceholder: '例如:RoHS 自动审核排程',
|
||||
owner: '排程所有者',
|
||||
noUsers: '暂无可用用户',
|
||||
selectOwner: '请选择所有者',
|
||||
dataSourceConfig: '数据源与执行配置',
|
||||
databaseDirect: '数据库直联',
|
||||
externalApi: '外部API',
|
||||
querying: '查询中...',
|
||||
testQuery: '测试查询',
|
||||
expandConfig: '展开配置',
|
||||
collapseConfig: '收起配置',
|
||||
dataSourceSection: '数据源配置',
|
||||
waitSeconds: '等待时间(秒)',
|
||||
noAgents: '暂无可用 Agent',
|
||||
agentDisabled: '不启用',
|
||||
cronTitle: 'Cron 图形化设置',
|
||||
cronHint: '选择执行频率后自动生成 Cron 表达式。',
|
||||
everyMinutes: '每隔分钟',
|
||||
hourly: '每小时',
|
||||
daily: '每天',
|
||||
weekly: '每周',
|
||||
minuteInterval: '分钟间隔',
|
||||
minuteOfHour: '每小时第几分钟',
|
||||
hour: '小时',
|
||||
minute: '分钟',
|
||||
weekday: '星期',
|
||||
cronPreview: 'Cron 预览',
|
||||
nextRun: '下次执行',
|
||||
notifyEnabled: '启用通知',
|
||||
selectNotifyUsers: '选择通知人员...',
|
||||
enableOnCreate: '创建后启用',
|
||||
cancel: '取消',
|
||||
saving: '保存中...',
|
||||
saveChanges: '保存修改',
|
||||
createSchedule: '创建排程'
|
||||
},
|
||||
testRun: {
|
||||
title: '测试执行 — {name}',
|
||||
subtitle: '编辑 WHERE 条件,限制行数,快速执行并查看每步结果',
|
||||
close: '关闭',
|
||||
running: '执行中...',
|
||||
start: '开始测试执行',
|
||||
waitingHint: 'Dify 调用可能需要较长时间,请耐心等待...',
|
||||
total: '总处理',
|
||||
success: '成功',
|
||||
failed: '失败',
|
||||
skipped: '跳过',
|
||||
limitSummary: '限制 {limit} 条 | Dify Agent ID: {agentId}',
|
||||
noAgent: '无',
|
||||
stepLogs: '步骤日志',
|
||||
viewSql: '查看执行 SQL',
|
||||
errors: '错误信息 ({count})',
|
||||
queryResult: '查询结果',
|
||||
resultSummary: '共 {total} 条,展示 {showing} 条',
|
||||
viewGeneratedSql: '查看生成 SQL'
|
||||
},
|
||||
status: {
|
||||
all: '全部状态',
|
||||
success: '成功',
|
||||
@@ -2331,6 +2601,7 @@ const messages = {
|
||||
deleteConfirmMessage: '确认删除排程「{name}」?',
|
||||
msg: {
|
||||
testRunFailed: '测试执行失败',
|
||||
testQueryFailed: '测试查询失败',
|
||||
configRequired: 'Dify Agent、SQL 配置或外部 API 至少填写一项,否则排程执行无任何效果',
|
||||
headerLabelsJsonInvalid: 'header_labels JSON 格式错误,请检查',
|
||||
apiHeadersJsonInvalid: 'API Headers JSON 格式错误,请检查',
|
||||
@@ -2518,7 +2789,16 @@ const messages = {
|
||||
oaDataConnected: '已接入 OA 数据库视图查询。',
|
||||
searchByNameOrEmployeeId: '输入姓名或工号搜索,按回车键查询',
|
||||
name: '姓名',
|
||||
employeeIdRequired: '工号不能为空。'
|
||||
employeeIdRequired: '工号不能为空。',
|
||||
actions: {
|
||||
copy: '复制',
|
||||
edit: '编辑',
|
||||
resend: '重新发送',
|
||||
regenerate: '重新生成',
|
||||
copySuccess: '已复制',
|
||||
copyFailed: '复制失败,请允许剪贴板权限后重试',
|
||||
copyEmpty: '没有可复制的内容'
|
||||
}
|
||||
},
|
||||
profile: {
|
||||
title: '个人资料',
|
||||
@@ -3043,7 +3323,8 @@ const messages = {
|
||||
wecom: '企業微信',
|
||||
permissions: '應用權限',
|
||||
requests: '權限審批',
|
||||
reports: '數據報表'
|
||||
reports: '數據報表',
|
||||
schedules: '排程管理'
|
||||
},
|
||||
|
||||
// Dashboard
|
||||
@@ -3800,7 +4081,16 @@ const messages = {
|
||||
oaDataConnected: '已接入 OA 資料庫視圖查詢。',
|
||||
searchByNameOrEmployeeId: '輸入姓名或工號搜尋,按 Enter 查詢',
|
||||
name: '姓名',
|
||||
employeeIdRequired: '工號不能為空。'
|
||||
employeeIdRequired: '工號不能為空。',
|
||||
actions: {
|
||||
copy: '複製',
|
||||
edit: '編輯',
|
||||
resend: '重新發送',
|
||||
regenerate: '重新生成',
|
||||
copySuccess: '已複製',
|
||||
copyFailed: '複製失敗,請允許剪貼簿權限後重試',
|
||||
copyEmpty: '沒有可複製的內容'
|
||||
}
|
||||
},
|
||||
profile: {
|
||||
title: '個人資料',
|
||||
@@ -4242,7 +4532,8 @@ const messages = {
|
||||
wecom: 'WeCom',
|
||||
permissions: 'สิทธิ์แอปพลิเคชัน',
|
||||
requests: 'คำขอสิทธิ์',
|
||||
reports: 'รายงานข้อมูล'
|
||||
reports: 'รายงานข้อมูล',
|
||||
schedules: 'Schedule Management'
|
||||
},
|
||||
|
||||
// Dashboard
|
||||
@@ -4999,7 +5290,16 @@ const messages = {
|
||||
oaDataConnected: 'เชื่อมต่อการค้นหามุมมองฐานข้อมูล OA แล้ว',
|
||||
searchByNameOrEmployeeId: 'ค้นหาด้วยชื่อหรือรหัสพนักงาน แล้วกด Enter',
|
||||
name: 'ชื่อ',
|
||||
employeeIdRequired: 'รหัสพนักงานห้ามว่าง'
|
||||
employeeIdRequired: 'รหัสพนักงานห้ามว่าง',
|
||||
actions: {
|
||||
copy: 'คัดลอก',
|
||||
edit: 'แก้ไข',
|
||||
resend: 'ส่งอีกครั้ง',
|
||||
regenerate: 'สร้างใหม่',
|
||||
copySuccess: 'คัดลอกแล้ว',
|
||||
copyFailed: 'คัดลอกไม่สำเร็จ โปรดอนุญาตการเข้าถึงคลิปบอร์ดแล้วลองอีกครั้ง',
|
||||
copyEmpty: 'ไม่มีเนื้อหาให้คัดลอก'
|
||||
}
|
||||
},
|
||||
profile: {
|
||||
title: 'โปรไฟล์',
|
||||
|
||||
@@ -0,0 +1,36 @@
|
||||
/**
|
||||
* Copy plain text to the clipboard with fallbacks for restricted browsers
|
||||
* (e.g. WeCom embedded WebView, HTTP deployments).
|
||||
*/
|
||||
export async function copyTextToClipboard(text: string): Promise<boolean> {
|
||||
const value = String(text ?? '');
|
||||
if (!value.trim()) return false;
|
||||
|
||||
if (navigator.clipboard?.writeText) {
|
||||
try {
|
||||
await navigator.clipboard.writeText(value);
|
||||
return true;
|
||||
} catch {
|
||||
// Fall through to legacy copy.
|
||||
}
|
||||
}
|
||||
|
||||
try {
|
||||
const textarea = document.createElement('textarea');
|
||||
textarea.value = value;
|
||||
textarea.setAttribute('readonly', 'true');
|
||||
textarea.style.position = 'fixed';
|
||||
textarea.style.left = '-9999px';
|
||||
textarea.style.top = '0';
|
||||
textarea.style.opacity = '0';
|
||||
document.body.appendChild(textarea);
|
||||
textarea.focus();
|
||||
textarea.select();
|
||||
textarea.setSelectionRange(0, value.length);
|
||||
const ok = document.execCommand('copy');
|
||||
document.body.removeChild(textarea);
|
||||
return ok;
|
||||
} catch {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
+232
-128
@@ -70,7 +70,7 @@ const sidebarItems = computed(() => {
|
||||
{ id: 'departments', icon: Building, label: t('admin.nav.departments') },
|
||||
{ id: 'agents', icon: Bot, label: t('admin.nav.agents') },
|
||||
{ id: 'knowledge_base', icon: FileText, label: t('admin.nav.knowledgeBase') },
|
||||
{ id: 'schedules', icon: Settings2, label: '排程管理' },
|
||||
{ id: 'schedules', icon: Settings2, label: t('admin.nav.schedules') },
|
||||
{ id: 'announcements', icon: Megaphone, label: t('admin.nav.announcements') },
|
||||
{ id: 'questions', icon: MessageCircleQuestion, label: t('admin.nav.questions') },
|
||||
{ id: 'wecom', icon: Link2, label: t('admin.nav.wecom') },
|
||||
@@ -456,17 +456,37 @@ const scheduleRunStatusFilter = ref<'all' | string>('all');
|
||||
const scheduleRunStartedAfter = ref('');
|
||||
const scheduleRunStartedBefore = ref('');
|
||||
const scheduleRunColumnDefs = ref([
|
||||
{ key: 'run_no', label: '执行单号', width: 280, min: 60 },
|
||||
{ key: 'started_at', label: '开始时间', width: 190, min: 60 },
|
||||
{ key: 'finished_at', label: '结束时间', width: 190, min: 60 },
|
||||
{ key: 'status', label: '状态', width: 130, min: 50 },
|
||||
{ key: 'total_count', label: '处理', width: 70, min: 40 },
|
||||
{ key: 'success_count', label: '成功', width: 70, min: 40 },
|
||||
{ key: 'failed_count', label: '失败', width: 70, min: 40 },
|
||||
{ key: 'wecom_notified', label: '企微通知', width: 90, min: 50 },
|
||||
{ key: 'detail', label: '明细', width: 90, min: 50 },
|
||||
{ key: 'log', label: '日志', width: 90, min: 50 },
|
||||
{ key: 'run_no', label: '', width: 280, min: 60 },
|
||||
{ key: 'started_at', label: '', width: 190, min: 60 },
|
||||
{ key: 'finished_at', label: '', width: 190, min: 60 },
|
||||
{ key: 'status', label: '', width: 130, min: 50 },
|
||||
{ key: 'total_count', label: '', width: 70, min: 40 },
|
||||
{ key: 'success_count', label: '', width: 70, min: 40 },
|
||||
{ key: 'failed_count', label: '', width: 70, min: 40 },
|
||||
{ key: 'wecom_notified', label: '', width: 90, min: 50 },
|
||||
{ key: 'detail', label: '', width: 90, min: 50 },
|
||||
{ key: 'log', label: '', width: 90, min: 50 },
|
||||
]);
|
||||
|
||||
const syncScheduleRunColumnLabels = () => {
|
||||
const keyToI18n: Record<string, string> = {
|
||||
run_no: 'runNo',
|
||||
started_at: 'startedAt',
|
||||
finished_at: 'finishedAt',
|
||||
status: 'status',
|
||||
total_count: 'totalCount',
|
||||
success_count: 'successCount',
|
||||
failed_count: 'failedCount',
|
||||
wecom_notified: 'wecomNotified',
|
||||
detail: 'detail',
|
||||
log: 'log',
|
||||
};
|
||||
scheduleRunColumnDefs.value.forEach((col) => {
|
||||
const i18nKey = keyToI18n[col.key];
|
||||
if (i18nKey) col.label = t(`admin.schedule.columns.${i18nKey}`);
|
||||
});
|
||||
};
|
||||
watch(locale, syncScheduleRunColumnLabels, { immediate: true });
|
||||
const resizingScheduleCol = ref<{ index: number; startX: number; startWidth: number } | null>(null);
|
||||
|
||||
const onScheduleColResizeMove = (event: MouseEvent) => {
|
||||
@@ -522,7 +542,7 @@ const scheduleCronDesigner = ref({
|
||||
weekly_hour: 9,
|
||||
weekly_minute: 0,
|
||||
});
|
||||
const weeklyDayOptions = [
|
||||
const weeklyDayOptions = computed(() => [
|
||||
{ value: 1, label: t('admin.schedule.weekday.mon') },
|
||||
{ value: 2, label: t('admin.schedule.weekday.tue') },
|
||||
{ value: 3, label: t('admin.schedule.weekday.wed') },
|
||||
@@ -530,7 +550,7 @@ const weeklyDayOptions = [
|
||||
{ value: 5, label: t('admin.schedule.weekday.fri') },
|
||||
{ value: 6, label: t('admin.schedule.weekday.sat') },
|
||||
{ value: 0, label: t('admin.schedule.weekday.sun') },
|
||||
];
|
||||
]);
|
||||
|
||||
const buildCronExprFromDesigner = () => {
|
||||
const cfg = scheduleCronDesigner.value;
|
||||
@@ -702,6 +722,7 @@ const resetScheduleCreateForm = () => {
|
||||
api_method: 'POST',
|
||||
api_headers_str: '{}',
|
||||
api_body_template: '',
|
||||
dify_system_prompt: '',
|
||||
};
|
||||
scheduleTestResult.value = null;
|
||||
scheduleCronDesigner.value = {
|
||||
@@ -768,6 +789,7 @@ const openScheduleEditModal = async (task: ScheduleTask) => {
|
||||
api_method: cfg.external_api?.method || 'POST',
|
||||
api_headers_str: cfg.external_api?.headers ? JSON.stringify(cfg.external_api.headers, null, 2) : '{}',
|
||||
api_body_template: cfg.external_api?.body_template || '',
|
||||
dify_system_prompt: cfg.dify_system_prompt || '',
|
||||
};
|
||||
}
|
||||
} catch {
|
||||
@@ -795,6 +817,7 @@ const openScheduleEditModal = async (task: ScheduleTask) => {
|
||||
api_method: 'POST',
|
||||
api_headers_str: '{}',
|
||||
api_body_template: '',
|
||||
dify_system_prompt: '',
|
||||
};
|
||||
}
|
||||
|
||||
@@ -807,13 +830,13 @@ const selectedSchedule = computed(() =>
|
||||
schedules.value.find((item) => item.id === selectedScheduleId.value) || null
|
||||
);
|
||||
|
||||
const scheduleRunStatusOptions = [
|
||||
const scheduleRunStatusOptions = computed(() => [
|
||||
{ value: 'all', label: t('admin.schedule.status.all') },
|
||||
{ value: 'success', label: t('admin.schedule.status.success') },
|
||||
{ value: 'partial_failed', label: t('admin.schedule.status.partialFailed') },
|
||||
{ value: 'failed', label: t('admin.schedule.status.failed') },
|
||||
{ value: 'running', label: t('admin.schedule.status.running') },
|
||||
];
|
||||
]);
|
||||
|
||||
const getScheduleRunStatusBadge = (status: string) => {
|
||||
const map: Record<string, { cls: string; label: string }> = {
|
||||
@@ -836,6 +859,11 @@ const formatDateTime = (iso?: string | null) => {
|
||||
|
||||
const expandedScheduleRunId = ref<number | null>(null);
|
||||
|
||||
const expandedScheduleRun = computed(() => {
|
||||
if (!expandedScheduleRunId.value) return null;
|
||||
return filteredScheduleRuns.value.find((x) => x.id === expandedScheduleRunId.value) || null;
|
||||
});
|
||||
|
||||
const stepLabelMap: Record<string, string> = {
|
||||
fetch_srm: t('admin.schedule.step.fetchSrm'),
|
||||
call_dify: t('admin.schedule.step.callDify'),
|
||||
@@ -972,6 +1000,7 @@ const scheduleSqlEditForm = ref({
|
||||
api_method: 'POST',
|
||||
api_headers_str: '{}',
|
||||
api_body_template: '',
|
||||
dify_system_prompt: '',
|
||||
});
|
||||
const scheduleSqlSaving = ref(false); void scheduleSqlSaving;
|
||||
const scheduleTestLoading = ref(false);
|
||||
@@ -991,7 +1020,7 @@ const handleTestScheduleSql = async () => {
|
||||
});
|
||||
scheduleTestResult.value = result;
|
||||
} catch (e: any) {
|
||||
msg.error(`测试查询失败: ${e?.message || e}`);
|
||||
msg.error(`${t('admin.schedule.msg.testQueryFailed')}: ${e?.message || e}`);
|
||||
} finally {
|
||||
scheduleTestLoading.value = false;
|
||||
}
|
||||
@@ -999,6 +1028,12 @@ const handleTestScheduleSql = async () => {
|
||||
|
||||
const scheduleNotifyDropdownOpen = ref(false);
|
||||
|
||||
watch(() => scheduleCreateForm.value.dify_agent_id, (agentId) => {
|
||||
if (!agentId) {
|
||||
scheduleSqlEditForm.value.dify_system_prompt = '';
|
||||
}
|
||||
});
|
||||
|
||||
const getUserName = (uid: number) => {
|
||||
const u = users.value.find(x => x.id === uid);
|
||||
return u ? (u.real_name || u.username) : String(uid);
|
||||
@@ -1076,6 +1111,7 @@ const createSchedule = async () => {
|
||||
headers: apiHeaders,
|
||||
body_template: scheduleSqlEditForm.value.api_body_template,
|
||||
} : undefined,
|
||||
dify_system_prompt: hasAgent ? scheduleSqlEditForm.value.dify_system_prompt : '',
|
||||
};
|
||||
|
||||
scheduleCreateSaving.value = true;
|
||||
@@ -4258,10 +4294,10 @@ const handlePermissionImport = async (event: Event) => {
|
||||
</div>
|
||||
<div>
|
||||
<h2 class="text-2xl font-bold tracking-tight text-slate-900">
|
||||
{{ scheduleViewMode === 'overview' ? '排程管理概览' : '排程管理工作台' }}
|
||||
{{ scheduleViewMode === 'overview' ? $t('admin.schedule.overviewTitle') : $t('admin.schedule.workbenchTitle') }}
|
||||
</h2>
|
||||
<p class="mt-1.5 text-sm text-slate-500">
|
||||
{{ scheduleViewMode === 'overview' ? '点击排程卡片进入排程工作台。' : '左侧排程列表,右侧执行记录列表。' }}
|
||||
{{ scheduleViewMode === 'overview' ? $t('admin.schedule.overviewSubtitle') : $t('admin.schedule.workbenchSubtitle') }}
|
||||
</p>
|
||||
</div>
|
||||
</div>
|
||||
@@ -4270,7 +4306,7 @@ const handlePermissionImport = async (event: Event) => {
|
||||
@click="loadSchedules"
|
||||
>
|
||||
<RefreshCw class="h-5 w-5" />
|
||||
刷新排程
|
||||
{{ $t('admin.schedule.refresh') }}
|
||||
</button>
|
||||
</div>
|
||||
</div>
|
||||
@@ -4280,37 +4316,37 @@ const handlePermissionImport = async (event: Event) => {
|
||||
<div class="mb-5 grid grid-cols-1 gap-3 md:grid-cols-2 xl:grid-cols-4">
|
||||
<div class="rounded-2xl bg-slate-50 px-4 py-3">
|
||||
<div class="text-xl font-bold text-slate-900">{{ schedules.length }}</div>
|
||||
<div class="text-sm text-slate-500">排程总数</div>
|
||||
<div class="text-sm text-slate-500">{{ $t('admin.schedule.stats.total') }}</div>
|
||||
</div>
|
||||
<div class="rounded-2xl bg-slate-50 px-4 py-3">
|
||||
<div class="text-xl font-bold text-slate-900">{{ scheduleEnabledCount }}</div>
|
||||
<div class="text-sm text-slate-500">启用中</div>
|
||||
<div class="text-sm text-slate-500">{{ $t('admin.schedule.stats.enabled') }}</div>
|
||||
</div>
|
||||
<div class="rounded-2xl bg-slate-50 px-4 py-3">
|
||||
<div class="text-xl font-bold text-slate-900">{{ scheduleDisabledCount }}</div>
|
||||
<div class="text-sm text-slate-500">停用中</div>
|
||||
<div class="text-sm text-slate-500">{{ $t('admin.schedule.stats.disabled') }}</div>
|
||||
</div>
|
||||
<div class="rounded-2xl bg-slate-50 px-4 py-3">
|
||||
<div class="text-xl font-bold text-slate-900">{{ scheduleRunningCount }}</div>
|
||||
<div class="text-sm text-slate-500">执行中</div>
|
||||
<div class="text-sm text-slate-500">{{ $t('admin.schedule.stats.running') }}</div>
|
||||
</div>
|
||||
</div>
|
||||
<div class="rounded-2xl border border-slate-200 bg-white p-4">
|
||||
<div class="mb-3 flex items-center justify-between">
|
||||
<h4 class="text-lg font-bold text-slate-900">排程管理概览</h4>
|
||||
<span class="text-xs text-slate-400">按卡片切换</span>
|
||||
<h4 class="text-lg font-bold text-slate-900">{{ $t('admin.schedule.sectionOverview') }}</h4>
|
||||
<span class="text-xs text-slate-400">{{ $t('admin.schedule.switchByCard') }}</span>
|
||||
</div>
|
||||
<div v-if="scheduleLoading" class="py-8 text-center text-sm text-slate-400">正在加载...</div>
|
||||
<div v-if="scheduleLoading" class="py-8 text-center text-sm text-slate-400">{{ $t('admin.schedule.loading') }}</div>
|
||||
<div v-else class="grid grid-cols-1 gap-4 md:grid-cols-2 xl:grid-cols-3 auto-rows-fr">
|
||||
<div class="rounded-2xl border border-slate-200 bg-white p-4 transition-colors hover:border-brand-300 h-full min-h-[260px] flex flex-col">
|
||||
<div class="mb-3 flex items-center gap-2">
|
||||
<div class="flex h-8 w-8 items-center justify-center rounded-xl bg-brand-50 text-brand-600">
|
||||
<Settings2 class="h-4 w-4" />
|
||||
</div>
|
||||
<div class="font-semibold text-slate-900">新增排程</div>
|
||||
<div class="font-semibold text-slate-900">{{ $t('admin.schedule.addTitle') }}</div>
|
||||
</div>
|
||||
<div class="text-sm text-slate-500">
|
||||
点击按钮后弹窗录入排程字段。
|
||||
{{ $t('admin.schedule.addHint') }}
|
||||
</div>
|
||||
<div class="mt-auto pt-3">
|
||||
<button
|
||||
@@ -4318,7 +4354,7 @@ const handlePermissionImport = async (event: Event) => {
|
||||
class="inline-flex w-full items-center justify-center gap-2 rounded-xl bg-brand-600 px-3 py-2 text-sm font-medium text-white transition-colors hover:bg-brand-700 disabled:cursor-not-allowed disabled:opacity-60"
|
||||
>
|
||||
<Plus class="h-4 w-4" />
|
||||
新增排程
|
||||
{{ $t('admin.schedule.addButton') }}
|
||||
</button>
|
||||
</div>
|
||||
</div>
|
||||
@@ -4334,26 +4370,26 @@ const handlePermissionImport = async (event: Event) => {
|
||||
<div class="truncate text-base font-semibold text-slate-900">{{ s.name }}</div>
|
||||
<span class="inline-flex shrink-0 items-center whitespace-nowrap rounded-full px-2.5 py-1 text-xs font-semibold"
|
||||
:class="s.enabled ? 'bg-emerald-100 text-emerald-700' : 'bg-slate-200 text-slate-600'">
|
||||
{{ s.enabled ? '启用' : '停用' }}
|
||||
{{ s.enabled ? $t('admin.schedule.enabled') : $t('admin.schedule.disabled') }}
|
||||
</span>
|
||||
</div>
|
||||
<div class="mt-2 text-sm text-slate-500">编号:{{ s.schedule_no }}</div>
|
||||
<div class="mt-2 text-sm text-slate-500">{{ $t('admin.schedule.scheduleNo') }}:{{ s.schedule_no }}</div>
|
||||
<div class="mt-1 text-sm text-slate-500">Cron:{{ s.cron_expr }}</div>
|
||||
<div
|
||||
v-if="s.schedule_type === 'platform_app' && s.platform_api_path"
|
||||
class="mt-1 text-sm text-slate-500"
|
||||
>
|
||||
配置:{{ s.platform_api_path }}
|
||||
{{ $t('admin.schedule.config') }}:{{ s.platform_api_path }}
|
||||
</div>
|
||||
<div class="mt-1 text-sm text-slate-500">所有者:{{ s.owner_username || s.owner_user_id }}</div>
|
||||
<div class="mt-1 text-sm text-slate-500">{{ $t('admin.schedule.owner') }}:{{ s.owner_username || s.owner_user_id }}</div>
|
||||
</div>
|
||||
</button>
|
||||
<div class="mt-auto pt-3">
|
||||
<div class="mb-1 text-sm text-slate-500">
|
||||
最近执行:{{ formatDateTime(s.last_run_at) }}
|
||||
{{ $t('admin.schedule.lastRun') }}:{{ formatDateTime(s.last_run_at) }}
|
||||
</div>
|
||||
<div class="mb-3 text-sm text-slate-500">
|
||||
下次执行:{{ formatDateTime(s.next_run_at) }}
|
||||
{{ $t('admin.schedule.nextRun') }}:{{ formatDateTime(s.next_run_at) }}
|
||||
</div>
|
||||
<div class="flex flex-wrap items-center gap-2">
|
||||
<button
|
||||
@@ -4361,7 +4397,7 @@ const handlePermissionImport = async (event: Event) => {
|
||||
@click.stop="openScheduleEditModal(s)"
|
||||
>
|
||||
<Edit3 class="h-3.5 w-3.5" />
|
||||
编辑
|
||||
{{ $t('admin.schedule.actions.edit') }}
|
||||
</button>
|
||||
<button
|
||||
v-if="!s.enabled"
|
||||
@@ -4369,7 +4405,7 @@ const handlePermissionImport = async (event: Event) => {
|
||||
@click.stop="setScheduleEnabled(s.id, true)"
|
||||
>
|
||||
<Power class="h-3.5 w-3.5" />
|
||||
启动
|
||||
{{ $t('admin.schedule.actions.start') }}
|
||||
</button>
|
||||
<button
|
||||
v-else
|
||||
@@ -4377,14 +4413,14 @@ const handlePermissionImport = async (event: Event) => {
|
||||
@click.stop="setScheduleEnabled(s.id, false)"
|
||||
>
|
||||
<PowerOff class="h-3.5 w-3.5" />
|
||||
暂停
|
||||
{{ $t('admin.schedule.actions.pause') }}
|
||||
</button>
|
||||
<button
|
||||
class="inline-flex items-center gap-1 rounded-xl border border-blue-200 px-3 py-2 text-xs font-medium text-blue-700 transition-colors hover:bg-blue-50"
|
||||
@click.stop="runScheduleNow(s.id)"
|
||||
>
|
||||
<Rocket class="h-3.5 w-3.5" />
|
||||
执行
|
||||
{{ $t('admin.schedule.actions.run') }}
|
||||
</button>
|
||||
<button
|
||||
v-if="s.platform_api_path && s.data_source_type !== 'external_api'"
|
||||
@@ -4392,20 +4428,20 @@ const handlePermissionImport = async (event: Event) => {
|
||||
@click.stop="openTestRunDialog(s)"
|
||||
>
|
||||
<FlaskConical class="h-3.5 w-3.5" />
|
||||
测试
|
||||
{{ $t('admin.schedule.actions.test') }}
|
||||
</button>
|
||||
<button
|
||||
class="inline-flex items-center gap-1 rounded-xl border border-rose-200 px-3 py-2 text-xs font-medium text-rose-600 transition-colors hover:bg-rose-50"
|
||||
@click.stop="deleteSchedule(s)"
|
||||
>
|
||||
<Trash2 class="h-3.5 w-3.5" />
|
||||
删除
|
||||
{{ $t('admin.schedule.actions.delete') }}
|
||||
</button>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<div v-if="schedules.length === 0" class="rounded-xl border border-dashed border-slate-200 px-4 py-6 text-center text-sm text-slate-400">
|
||||
暂无排程,请先创建。
|
||||
{{ $t('admin.schedule.emptyList') }}
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
@@ -4416,24 +4452,24 @@ const handlePermissionImport = async (event: Event) => {
|
||||
<div class="space-y-6">
|
||||
<div class="grid grid-cols-2 gap-3 rounded-3xl border border-slate-200 bg-white p-4 shadow-sm md:grid-cols-4 xl:grid-cols-7">
|
||||
<div class="col-span-2 rounded-2xl bg-slate-50 px-4 py-3 xl:col-span-3">
|
||||
<div class="truncate text-base font-semibold text-slate-900">{{ selectedSchedule?.name || '未选择排程' }}</div>
|
||||
<div class="mt-1 text-xs text-slate-500">当前选中排程 · 最近执行 {{ selectedScheduleLatestRunAt }}</div>
|
||||
<div class="truncate text-base font-semibold text-slate-900">{{ selectedSchedule?.name || $t('admin.schedule.noSelection') }}</div>
|
||||
<div class="mt-1 text-xs text-slate-500">{{ $t('admin.schedule.selectedHint', { time: selectedScheduleLatestRunAt }) }}</div>
|
||||
</div>
|
||||
<div class="rounded-2xl bg-slate-50 px-4 py-3 text-center">
|
||||
<div class="text-base font-semibold text-slate-900">{{ selectedScheduleRuns.length }}</div>
|
||||
<div class="mt-1 text-xs text-slate-500">执行批次</div>
|
||||
<div class="mt-1 text-xs text-slate-500">{{ $t('admin.schedule.runBatches') }}</div>
|
||||
</div>
|
||||
<div class="rounded-2xl bg-slate-50 px-4 py-3 text-center">
|
||||
<div class="text-base font-semibold text-slate-900">{{ selectedScheduleRunMetrics.total }}</div>
|
||||
<div class="mt-1 text-xs text-slate-500">处理总数</div>
|
||||
<div class="mt-1 text-xs text-slate-500">{{ $t('admin.schedule.totalProcessed') }}</div>
|
||||
</div>
|
||||
<div class="rounded-2xl bg-slate-50 px-4 py-3 text-center">
|
||||
<div class="text-base font-semibold text-emerald-700">{{ selectedScheduleRunMetrics.success }}</div>
|
||||
<div class="mt-1 text-xs text-slate-500">成功总数</div>
|
||||
<div class="mt-1 text-xs text-slate-500">{{ $t('admin.schedule.totalSuccess') }}</div>
|
||||
</div>
|
||||
<div class="rounded-2xl bg-slate-50 px-4 py-3 text-center">
|
||||
<div class="text-base font-semibold text-rose-600">{{ selectedScheduleRunMetrics.failed }}</div>
|
||||
<div class="mt-1 text-xs text-slate-500">失败总数</div>
|
||||
<div class="mt-1 text-xs text-slate-500">{{ $t('admin.schedule.totalFailed') }}</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
@@ -4441,8 +4477,8 @@ const handlePermissionImport = async (event: Event) => {
|
||||
<div class="grid grid-cols-1 gap-6 lg:grid-cols-[320px_minmax(0,1fr)]">
|
||||
<div class="rounded-3xl border border-slate-200 bg-white p-6 shadow-sm">
|
||||
<div class="mb-4 flex items-center justify-between">
|
||||
<h4 class="text-lg font-semibold text-slate-900">排程列表</h4>
|
||||
<span class="text-xs text-slate-400">按卡片切换</span>
|
||||
<h4 class="text-lg font-semibold text-slate-900">{{ $t('admin.schedule.listTitle') }}</h4>
|
||||
<span class="text-xs text-slate-400">{{ $t('admin.schedule.switchByCard') }}</span>
|
||||
</div>
|
||||
<div class="space-y-3">
|
||||
<button
|
||||
@@ -4459,7 +4495,7 @@ const handlePermissionImport = async (event: Event) => {
|
||||
<div class="mt-2 flex flex-wrap items-center gap-2">
|
||||
<button
|
||||
class="inline-flex items-center justify-center rounded-xl border border-slate-200 p-1.5 text-xs font-medium text-slate-600 transition-colors hover:bg-slate-50"
|
||||
title="编辑"
|
||||
:title="$t('admin.schedule.actions.edit')"
|
||||
@click.stop="openScheduleEditModal(s)"
|
||||
>
|
||||
<Edit3 class="h-3 w-3" />
|
||||
@@ -4467,7 +4503,7 @@ const handlePermissionImport = async (event: Event) => {
|
||||
<button
|
||||
v-if="!s.enabled"
|
||||
class="inline-flex items-center justify-center rounded-xl border border-emerald-200 p-1.5 text-xs font-medium text-emerald-700 transition-colors hover:bg-emerald-50"
|
||||
title="启动"
|
||||
:title="$t('admin.schedule.actions.start')"
|
||||
@click.stop="setScheduleEnabled(s.id, true)"
|
||||
>
|
||||
<Power class="h-3 w-3" />
|
||||
@@ -4475,14 +4511,14 @@ const handlePermissionImport = async (event: Event) => {
|
||||
<button
|
||||
v-else
|
||||
class="inline-flex items-center justify-center rounded-xl border border-amber-200 p-1.5 text-xs font-medium text-amber-700 transition-colors hover:bg-amber-50"
|
||||
title="暂停"
|
||||
:title="$t('admin.schedule.actions.pause')"
|
||||
@click.stop="setScheduleEnabled(s.id, false)"
|
||||
>
|
||||
<PowerOff class="h-3 w-3" />
|
||||
</button>
|
||||
<button
|
||||
class="inline-flex items-center justify-center rounded-xl border border-blue-200 p-1.5 text-xs font-medium text-blue-700 transition-colors hover:bg-blue-50"
|
||||
title="执行"
|
||||
:title="$t('admin.schedule.actions.run')"
|
||||
@click.stop="runScheduleNow(s.id)"
|
||||
>
|
||||
<Rocket class="h-3 w-3" />
|
||||
@@ -4490,14 +4526,14 @@ const handlePermissionImport = async (event: Event) => {
|
||||
<button
|
||||
v-if="s.platform_api_path && s.data_source_type !== 'external_api'"
|
||||
class="inline-flex items-center justify-center rounded-xl border border-violet-200 p-1.5 text-xs font-medium text-violet-700 transition-colors hover:bg-violet-50"
|
||||
title="测试"
|
||||
:title="$t('admin.schedule.actions.test')"
|
||||
@click.stop="openTestRunDialog(s)"
|
||||
>
|
||||
<FlaskConical class="h-3 w-3" />
|
||||
</button>
|
||||
<button
|
||||
class="inline-flex items-center justify-center rounded-xl border border-rose-200 p-1.5 text-xs font-medium text-rose-600 transition-colors hover:bg-rose-50"
|
||||
title="删除"
|
||||
:title="$t('admin.schedule.actions.delete')"
|
||||
@click.stop="deleteSchedule(s)"
|
||||
>
|
||||
<Trash2 class="h-3 w-3" />
|
||||
@@ -4506,7 +4542,7 @@ const handlePermissionImport = async (event: Event) => {
|
||||
</div>
|
||||
<span class="inline-flex shrink-0 items-center whitespace-nowrap rounded-full px-2.5 py-1 text-xs font-semibold"
|
||||
:class="s.enabled ? 'bg-emerald-100 text-emerald-700' : 'bg-slate-200 text-slate-600'">
|
||||
{{ s.enabled ? '启用' : '停用' }}
|
||||
{{ s.enabled ? $t('admin.schedule.enabled') : $t('admin.schedule.disabled') }}
|
||||
</span>
|
||||
</div>
|
||||
</button>
|
||||
@@ -4517,16 +4553,16 @@ const handlePermissionImport = async (event: Event) => {
|
||||
<div v-if="selectedSchedule" class="rounded-2xl border border-slate-200 bg-white p-4">
|
||||
<div class="mb-4 flex flex-wrap items-center justify-between gap-3">
|
||||
<div>
|
||||
<h3 class="text-lg font-semibold text-slate-900">{{ selectedSchedule.name }} · 执行记录</h3>
|
||||
<p class="mt-1 text-sm text-slate-500">下方仅展示执行记录明细。</p>
|
||||
<h3 class="text-lg font-semibold text-slate-900">{{ $t('admin.schedule.recordsTitle', { name: selectedSchedule.name }) }}</h3>
|
||||
<p class="mt-1 text-sm text-slate-500">{{ $t('admin.schedule.recordsSubtitle') }}</p>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div>
|
||||
<div class="mb-3 flex flex-wrap items-center gap-2 text-xs">
|
||||
<label class="text-slate-500">开始</label>
|
||||
<label class="text-slate-500">{{ $t('admin.schedule.filterStart') }}</label>
|
||||
<input type="datetime-local" step="1" v-model="scheduleRunStartedAfter" class="!min-w-0 !w-[170px] !py-1 !px-2 !text-xs rounded-lg border border-slate-200" />
|
||||
<label class="text-slate-500">结束</label>
|
||||
<label class="text-slate-500">{{ $t('admin.schedule.filterEnd') }}</label>
|
||||
<input type="datetime-local" step="1" v-model="scheduleRunStartedBefore" class="!min-w-0 !w-[170px] !py-1 !px-2 !text-xs rounded-lg border border-slate-200" />
|
||||
<select v-model="scheduleRunStatusFilter" class="!min-w-0 !w-[90px] !py-1 !px-2 !text-xs rounded-lg border border-slate-200">
|
||||
<option v-for="opt in scheduleRunStatusOptions" :key="opt.value" :value="opt.value">
|
||||
@@ -4537,13 +4573,13 @@ const handlePermissionImport = async (event: Event) => {
|
||||
class="inline-flex items-center rounded-lg bg-brand-600 px-2.5 py-1 text-xs font-medium text-white hover:bg-brand-700"
|
||||
@click="viewScheduleRuns(selectedSchedule.id)"
|
||||
>
|
||||
查询
|
||||
{{ $t('admin.schedule.query') }}
|
||||
</button>
|
||||
<button
|
||||
class="inline-flex items-center rounded-lg border border-slate-200 px-2.5 py-1 text-xs font-medium text-slate-700 hover:bg-slate-50"
|
||||
@click="resetScheduleRunFilters(); viewScheduleRuns(selectedSchedule.id)"
|
||||
>
|
||||
重置
|
||||
{{ $t('admin.schedule.reset') }}
|
||||
</button>
|
||||
</div>
|
||||
<div class="overflow-x-auto rounded-xl border border-slate-100">
|
||||
@@ -4566,7 +4602,7 @@ const handlePermissionImport = async (event: Event) => {
|
||||
<span
|
||||
class="absolute inset-y-0 -right-1 z-10 w-3 cursor-col-resize"
|
||||
@mousedown.prevent="startScheduleColResize(colIndex, $event)"
|
||||
:title="`拖拽调整${col.label}列宽`"
|
||||
:title="$t('admin.schedule.resizeColumn', { label: col.label })"
|
||||
>
|
||||
<span class="mx-auto block h-full w-px bg-slate-300"></span>
|
||||
</span>
|
||||
@@ -4575,10 +4611,10 @@ const handlePermissionImport = async (event: Event) => {
|
||||
</thead>
|
||||
<tbody class="divide-y divide-slate-100">
|
||||
<tr v-if="scheduleRunsLoading">
|
||||
<td colspan="10" class="px-4 py-8 text-center text-sm text-slate-400">正在查询记录...</td>
|
||||
<td colspan="10" class="px-4 py-8 text-center text-sm text-slate-400">{{ $t('admin.schedule.queryingRuns') }}</td>
|
||||
</tr>
|
||||
<tr v-else-if="filteredScheduleRuns.length === 0">
|
||||
<td colspan="10" class="px-4 py-8 text-center text-sm text-slate-400">暂无执行记录。</td>
|
||||
<td colspan="10" class="px-4 py-8 text-center text-sm text-slate-400">{{ $t('admin.schedule.noRunRecords') }}</td>
|
||||
</tr>
|
||||
<tr
|
||||
v-else
|
||||
@@ -4602,9 +4638,9 @@ const handlePermissionImport = async (event: Event) => {
|
||||
<td class="truncate px-4 py-2.5">
|
||||
<span v-if="r.wecom_notified" class="inline-flex items-center gap-1 text-xs text-emerald-600">
|
||||
<svg class="h-3.5 w-3.5" fill="none" viewBox="0 0 24 24" stroke="currentColor"><path stroke-linecap="round" stroke-linejoin="round" stroke-width="2" d="M5 13l4 4L19 7" /></svg>
|
||||
已通知
|
||||
{{ $t('admin.schedule.notified') }}
|
||||
</span>
|
||||
<span v-else-if="r.wecom_notify_error" class="text-xs text-amber-500" :title="r.wecom_notify_error">异常</span>
|
||||
<span v-else-if="r.wecom_notify_error" class="text-xs text-amber-500" :title="r.wecom_notify_error">{{ $t('admin.schedule.notifyError') }}</span>
|
||||
<span v-else class="text-xs text-slate-300">-</span>
|
||||
</td>
|
||||
<td class="px-4 py-2.5">
|
||||
@@ -4616,7 +4652,7 @@ const handlePermissionImport = async (event: Event) => {
|
||||
class="inline-flex items-center gap-1 rounded-lg border border-slate-200 px-2 py-1 text-xs font-medium text-slate-600 transition-colors hover:bg-slate-50"
|
||||
>
|
||||
<Download class="h-3 w-3" />
|
||||
下载
|
||||
{{ $t('admin.schedule.download') }}
|
||||
</a>
|
||||
<span v-if="r.total_count === 0" class="text-slate-300">-</span>
|
||||
</div>
|
||||
@@ -4624,12 +4660,12 @@ const handlePermissionImport = async (event: Event) => {
|
||||
<td class="px-4 py-2.5">
|
||||
<div class="flex items-center">
|
||||
<button
|
||||
v-if="r.step_logs && r.step_logs.length > 0"
|
||||
v-if="(r.step_logs && r.step_logs.length > 0) || r.dify_execution_snapshot"
|
||||
@click="expandedScheduleRunId = expandedScheduleRunId === r.id ? null : r.id"
|
||||
class="inline-flex items-center gap-1 rounded-lg border border-blue-200 px-2 py-1 text-xs font-medium text-blue-600 transition-colors hover:bg-blue-50"
|
||||
>
|
||||
<Eye class="h-3 w-3" />
|
||||
日志
|
||||
{{ $t('admin.schedule.log') }}
|
||||
<ChevronDown v-if="expandedScheduleRunId !== r.id" class="h-3 w-3" />
|
||||
<ChevronUp v-else class="h-3 w-3" />
|
||||
</button>
|
||||
@@ -4638,17 +4674,49 @@ const handlePermissionImport = async (event: Event) => {
|
||||
</td>
|
||||
</tr>
|
||||
<tr
|
||||
v-if="expandedScheduleRunId && filteredScheduleRuns.find(x => x.id === expandedScheduleRunId)"
|
||||
v-if="expandedScheduleRun"
|
||||
:key="'expanded-' + expandedScheduleRunId"
|
||||
>
|
||||
<td colspan="10" class="px-4 py-3 bg-slate-50/60">
|
||||
<div class="space-y-2">
|
||||
<div class="space-y-3">
|
||||
<div
|
||||
v-if="expandedScheduleRun.dify_execution_snapshot"
|
||||
class="rounded-xl border border-indigo-200 bg-indigo-50/50 p-3"
|
||||
>
|
||||
<div class="mb-2 flex items-center justify-between">
|
||||
<h5 class="text-xs font-bold uppercase text-indigo-800">Dify 执行快照(审计)</h5>
|
||||
<span class="text-[10px] text-indigo-600/80">
|
||||
{{ expandedScheduleRun.dify_execution_snapshot.captured_at || '-' }}
|
||||
</span>
|
||||
</div>
|
||||
<div v-if="expandedScheduleRun.dify_execution_snapshot.dify_enabled" class="space-y-2 text-xs text-slate-700">
|
||||
<div>
|
||||
<span class="font-semibold text-slate-500">Agent:</span>
|
||||
{{ expandedScheduleRun.dify_execution_snapshot.dify_agent_name || '-' }}
|
||||
<span class="text-slate-400">(ID: {{ expandedScheduleRun.dify_execution_snapshot.dify_agent_id ?? '-' }})</span>
|
||||
</div>
|
||||
<div v-if="expandedScheduleRun.dify_execution_snapshot.dify_app_id">
|
||||
<span class="font-semibold text-slate-500">Dify App ID:</span>
|
||||
{{ expandedScheduleRun.dify_execution_snapshot.dify_app_id }}
|
||||
</div>
|
||||
<div>
|
||||
<span class="mb-1 block font-semibold text-slate-500">System Prompt:</span>
|
||||
<pre
|
||||
v-if="expandedScheduleRun.dify_execution_snapshot.dify_system_prompt"
|
||||
class="max-h-[240px] overflow-auto whitespace-pre-wrap rounded-lg border border-indigo-100 bg-white p-3 font-mono text-[11px] leading-relaxed text-slate-800"
|
||||
>{{ expandedScheduleRun.dify_execution_snapshot.dify_system_prompt }}</pre>
|
||||
<span v-else class="text-slate-400">(未配置,使用 Dify 编排内默认提示词)</span>
|
||||
</div>
|
||||
</div>
|
||||
<div v-else class="text-xs text-slate-500">本次执行未启用 Dify Agent</div>
|
||||
</div>
|
||||
<div class="space-y-2">
|
||||
<div class="flex items-center justify-between mb-2">
|
||||
<h5 class="text-xs font-bold text-slate-600 uppercase">执行日志</h5>
|
||||
<span class="text-xs text-slate-400">共 {{ filteredScheduleRuns.find(x => x.id === expandedScheduleRunId)?.step_logs?.length || 0 }} 步</span>
|
||||
<h5 class="text-xs font-bold text-slate-600 uppercase">{{ $t('admin.schedule.runLogs') }}</h5>
|
||||
<span class="text-xs text-slate-400">{{ $t('admin.schedule.stepsCount', { count: expandedScheduleRun.step_logs?.length || 0 }) }}</span>
|
||||
</div>
|
||||
<div
|
||||
v-for="(log, li) in filteredScheduleRuns.find(x => x.id === expandedScheduleRunId)?.step_logs || []"
|
||||
v-for="(log, li) in expandedScheduleRun.step_logs || []"
|
||||
:key="li"
|
||||
class="rounded-xl border p-3"
|
||||
:class="log.status === 'failed' ? 'border-rose-200 bg-rose-50/40' : 'border-slate-200 bg-white'"
|
||||
@@ -4663,10 +4731,11 @@ const handlePermissionImport = async (event: Event) => {
|
||||
<span v-if="log.duration_ms != null" class="text-[10px] text-slate-400">{{ log.duration_ms }}ms</span>
|
||||
</div>
|
||||
<details v-if="log.detail" class="mt-1">
|
||||
<summary class="cursor-pointer text-[10px] font-semibold text-slate-500 hover:text-slate-700">查看详情</summary>
|
||||
<summary class="cursor-pointer text-[10px] font-semibold text-slate-500 hover:text-slate-700">{{ $t('admin.schedule.viewDetail') }}</summary>
|
||||
<pre class="mt-1 whitespace-pre-wrap rounded-lg bg-slate-800 p-2 text-[10px] text-slate-200 font-mono max-h-[200px] overflow-auto">{{ JSON.stringify(log.detail, null, 2) }}</pre>
|
||||
</details>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</td>
|
||||
</tr>
|
||||
@@ -4676,7 +4745,7 @@ const handlePermissionImport = async (event: Event) => {
|
||||
</div>
|
||||
</div>
|
||||
<div v-else class="rounded-2xl border border-dashed border-slate-200 bg-white px-4 py-10 text-center text-sm text-slate-400">
|
||||
未选择排程,请先在左侧列表选择一个排程。
|
||||
{{ $t('admin.schedule.noSelectionHint') }}
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
@@ -5619,10 +5688,10 @@ const handlePermissionImport = async (event: Event) => {
|
||||
<div class="w-full max-w-4xl max-h-[90vh] overflow-y-auto rounded-3xl bg-white shadow-2xl">
|
||||
<div class="sticky top-0 z-10 flex items-center justify-between border-b border-slate-100 bg-white px-6 py-4 rounded-t-3xl">
|
||||
<div>
|
||||
<h3 class="text-lg font-bold text-slate-900">测试执行 — {{ testRunSchedule?.name }}</h3>
|
||||
<p class="text-xs text-slate-500 mt-0.5">编辑 WHERE 条件,限制行数,快速执行并查看每步结果</p>
|
||||
<h3 class="text-lg font-bold text-slate-900">{{ $t('admin.schedule.testRun.title', { name: testRunSchedule?.name }) }}</h3>
|
||||
<p class="text-xs text-slate-500 mt-0.5">{{ $t('admin.schedule.testRun.subtitle') }}</p>
|
||||
</div>
|
||||
<button @click="showTestRunDialog = false" class="rounded-xl border border-slate-200 px-3 py-1.5 text-sm text-slate-500 hover:bg-slate-50">关闭</button>
|
||||
<button @click="showTestRunDialog = false" class="rounded-xl border border-slate-200 px-3 py-1.5 text-sm text-slate-500 hover:bg-slate-50">{{ $t('admin.schedule.testRun.close') }}</button>
|
||||
</div>
|
||||
<div class="p-6 space-y-4">
|
||||
<div>
|
||||
@@ -5655,36 +5724,59 @@ const handlePermissionImport = async (event: Event) => {
|
||||
:disabled="testRunLoading"
|
||||
@click="handleTestRun"
|
||||
>
|
||||
{{ testRunLoading ? '执行中...' : '开始测试执行' }}
|
||||
{{ testRunLoading ? $t('admin.schedule.testRun.running') : $t('admin.schedule.testRun.start') }}
|
||||
</button>
|
||||
<span v-if="testRunLoading" class="text-xs text-slate-400">Dify 调用可能需要较长时间,请耐心等待...</span>
|
||||
<span v-if="testRunLoading" class="text-xs text-slate-400">{{ $t('admin.schedule.testRun.waitingHint') }}</span>
|
||||
</div>
|
||||
|
||||
<div v-if="testRunResult" class="space-y-4 mt-2">
|
||||
<div class="flex items-center gap-4 rounded-xl border border-slate-200 bg-slate-50/50 px-4 py-3">
|
||||
<div class="text-center">
|
||||
<div class="text-lg font-bold text-slate-900">{{ testRunResult.total_count }}</div>
|
||||
<div class="text-[10px] text-slate-500">总处理</div>
|
||||
<div class="text-[10px] text-slate-500">{{ $t('admin.schedule.testRun.total') }}</div>
|
||||
</div>
|
||||
<div class="text-center">
|
||||
<div class="text-lg font-bold text-emerald-600">{{ testRunResult.success_count }}</div>
|
||||
<div class="text-[10px] text-slate-500">成功</div>
|
||||
<div class="text-[10px] text-slate-500">{{ $t('admin.schedule.testRun.success') }}</div>
|
||||
</div>
|
||||
<div class="text-center">
|
||||
<div class="text-lg font-bold text-rose-600">{{ testRunResult.failed_count }}</div>
|
||||
<div class="text-[10px] text-slate-500">失败</div>
|
||||
<div class="text-[10px] text-slate-500">{{ $t('admin.schedule.testRun.failed') }}</div>
|
||||
</div>
|
||||
<div class="text-center">
|
||||
<div class="text-lg font-bold text-amber-600">{{ testRunResult.skipped_count }}</div>
|
||||
<div class="text-[10px] text-slate-500">跳过</div>
|
||||
<div class="text-[10px] text-slate-500">{{ $t('admin.schedule.testRun.skipped') }}</div>
|
||||
</div>
|
||||
<div class="ml-auto text-xs text-slate-400">
|
||||
限制 {{ testRunResult.limit }} 条 | Dify Agent ID: {{ testRunResult.dify_agent_id || '无' }}
|
||||
{{ $t('admin.schedule.testRun.limitSummary', { limit: testRunResult.limit, agentId: testRunResult.dify_agent_id || $t('admin.schedule.testRun.noAgent') }) }}
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div
|
||||
v-if="testRunResult.dify_execution_snapshot"
|
||||
class="rounded-xl border border-indigo-200 bg-indigo-50/50 p-3"
|
||||
>
|
||||
<h4 class="mb-2 text-sm font-bold text-indigo-900">Dify 执行快照(审计)</h4>
|
||||
<div v-if="testRunResult.dify_execution_snapshot.dify_enabled" class="space-y-2 text-xs text-slate-700">
|
||||
<div>
|
||||
<span class="font-semibold text-slate-500">Agent:</span>
|
||||
{{ testRunResult.dify_execution_snapshot.dify_agent_name || '-' }}
|
||||
(ID: {{ testRunResult.dify_execution_snapshot.dify_agent_id ?? '-' }})
|
||||
</div>
|
||||
<div>
|
||||
<span class="mb-1 block font-semibold text-slate-500">System Prompt:</span>
|
||||
<pre
|
||||
v-if="testRunResult.dify_execution_snapshot.dify_system_prompt"
|
||||
class="max-h-[200px] overflow-auto whitespace-pre-wrap rounded-lg border border-indigo-100 bg-white p-3 font-mono text-[11px] text-slate-800"
|
||||
>{{ testRunResult.dify_execution_snapshot.dify_system_prompt }}</pre>
|
||||
<span v-else class="text-slate-400">(未配置)</span>
|
||||
</div>
|
||||
</div>
|
||||
<div v-else class="text-xs text-slate-500">本次测试未启用 Dify</div>
|
||||
</div>
|
||||
|
||||
<div>
|
||||
<h4 class="text-sm font-bold text-slate-700 mb-2">步骤日志</h4>
|
||||
<h4 class="text-sm font-bold text-slate-700 mb-2">{{ $t('admin.schedule.testRun.stepLogs') }}</h4>
|
||||
<div class="space-y-2">
|
||||
<div
|
||||
v-for="(log, li) in testRunResult.step_logs"
|
||||
@@ -5702,7 +5794,7 @@ const handlePermissionImport = async (event: Event) => {
|
||||
<span v-if="log.duration_ms != null" class="text-[10px] text-slate-400">{{ log.duration_ms }}ms</span>
|
||||
</div>
|
||||
<details v-if="log.detail" class="mt-1">
|
||||
<summary class="cursor-pointer text-[10px] font-semibold text-slate-500 hover:text-slate-700">查看详情</summary>
|
||||
<summary class="cursor-pointer text-[10px] font-semibold text-slate-500 hover:text-slate-700">{{ $t('admin.schedule.viewDetail') }}</summary>
|
||||
<pre class="mt-1 whitespace-pre-wrap rounded-lg bg-slate-800 p-2 text-[10px] text-slate-200 font-mono max-h-[200px] overflow-auto">{{ JSON.stringify(log.detail, null, 2) }}</pre>
|
||||
</details>
|
||||
</div>
|
||||
@@ -5710,12 +5802,12 @@ const handlePermissionImport = async (event: Event) => {
|
||||
</div>
|
||||
|
||||
<details>
|
||||
<summary class="cursor-pointer text-xs font-semibold text-slate-500 hover:text-slate-700">查看执行 SQL</summary>
|
||||
<summary class="cursor-pointer text-xs font-semibold text-slate-500 hover:text-slate-700">{{ $t('admin.schedule.testRun.viewSql') }}</summary>
|
||||
<pre class="mt-1 whitespace-pre-wrap rounded-lg bg-slate-800 p-3 text-xs text-emerald-300 font-mono">{{ testRunResult.sql }}</pre>
|
||||
</details>
|
||||
|
||||
<details v-if="testRunResult.errors && testRunResult.errors.length > 0">
|
||||
<summary class="cursor-pointer text-xs font-semibold text-rose-600 hover:text-rose-800">错误信息 ({{ testRunResult.errors.length }})</summary>
|
||||
<summary class="cursor-pointer text-xs font-semibold text-rose-600 hover:text-rose-800">{{ $t('admin.schedule.testRun.errors', { count: testRunResult.errors.length }) }}</summary>
|
||||
<pre class="mt-1 whitespace-pre-wrap rounded-lg bg-rose-50 p-3 text-xs text-rose-700 font-mono">{{ testRunResult.errors.join('\n') }}</pre>
|
||||
</details>
|
||||
</div>
|
||||
@@ -5727,7 +5819,7 @@ const handlePermissionImport = async (event: Event) => {
|
||||
<div v-if="showScheduleCreateModal" class="fixed inset-0 z-50 flex items-center justify-center bg-black/50 backdrop-blur-sm p-4">
|
||||
<div class="w-full max-w-3xl rounded-3xl bg-white shadow-2xl">
|
||||
<div class="flex items-center justify-between border-b border-slate-100 px-8 py-6">
|
||||
<h3 class="text-2xl font-bold tracking-tight text-slate-900">{{ scheduleEditingId ? '编辑排程' : '新增排程' }}</h3>
|
||||
<h3 class="text-2xl font-bold tracking-tight text-slate-900">{{ scheduleEditingId ? $t('admin.schedule.form.editTitle') : $t('admin.schedule.form.createTitle') }}</h3>
|
||||
<button
|
||||
class="rounded-full p-2 text-slate-400 transition hover:bg-slate-100 hover:text-slate-600"
|
||||
@click="showScheduleCreateModal = false"
|
||||
@@ -5738,14 +5830,14 @@ const handlePermissionImport = async (event: Event) => {
|
||||
<div class="max-h-[72vh] space-y-5 overflow-y-auto px-8 py-6">
|
||||
<div class="grid grid-cols-1 gap-4 md:grid-cols-2">
|
||||
<div>
|
||||
<label class="mb-2 block text-sm font-medium text-slate-600">排程名称</label>
|
||||
<input v-model="scheduleCreateForm.name" class="input-field !text-sm !leading-5" placeholder="例如:RoHS 自动审核排程" />
|
||||
<label class="mb-2 block text-sm font-medium text-slate-600">{{ $t('admin.schedule.form.name') }}</label>
|
||||
<input v-model="scheduleCreateForm.name" class="input-field !text-sm !leading-5" :placeholder="$t('admin.schedule.form.namePlaceholder')" />
|
||||
</div>
|
||||
<div>
|
||||
<label class="mb-2 block text-sm font-medium text-slate-600">排程所有者</label>
|
||||
<label class="mb-2 block text-sm font-medium text-slate-600">{{ $t('admin.schedule.form.owner') }}</label>
|
||||
<div class="relative">
|
||||
<select v-model="scheduleCreateForm.owner_user_id" class="input-field appearance-none pr-10 !text-sm !leading-5" :disabled="users.length === 0">
|
||||
<option :value="null">{{ users.length === 0 ? '暂无可用用户' : '请选择所有者' }}</option>
|
||||
<option :value="null">{{ users.length === 0 ? $t('admin.schedule.form.noUsers') : $t('admin.schedule.form.selectOwner') }}</option>
|
||||
<option v-for="u in users" :key="u.id" :value="u.id">{{ u.real_name || u.username }}{{ u.employee_id ? '(' + u.employee_id + ')' : '' }}</option>
|
||||
</select>
|
||||
<div class="pointer-events-none absolute inset-y-0 right-0 flex items-center pr-3">
|
||||
@@ -5757,26 +5849,26 @@ const handlePermissionImport = async (event: Event) => {
|
||||
<!-- SQL Config Panel -->
|
||||
<div class="rounded-2xl border border-slate-200 bg-slate-50/40 p-4">
|
||||
<div class="mb-3 flex items-center justify-between gap-3">
|
||||
<h4 class="text-base font-bold text-slate-900">数据源与执行配置</h4>
|
||||
<h4 class="text-base font-bold text-slate-900">{{ $t('admin.schedule.form.dataSourceConfig') }}</h4>
|
||||
<div class="flex items-center gap-2">
|
||||
<div class="flex rounded-xl border border-slate-200 overflow-hidden">
|
||||
<button
|
||||
class="px-3 py-1.5 text-xs font-semibold transition"
|
||||
:class="scheduleCreateForm.data_source_type === 'database' ? 'bg-blue-600 text-white' : 'bg-white text-slate-600 hover:bg-slate-50'"
|
||||
@click="scheduleCreateForm.data_source_type = 'database'"
|
||||
>数据库直联</button>
|
||||
>{{ $t('admin.schedule.form.databaseDirect') }}</button>
|
||||
<button
|
||||
class="px-3 py-1.5 text-xs font-semibold transition"
|
||||
:class="scheduleCreateForm.data_source_type === 'external_api' ? 'bg-blue-600 text-white' : 'bg-white text-slate-600 hover:bg-slate-50'"
|
||||
@click="scheduleCreateForm.data_source_type = 'external_api'"
|
||||
>外部API</button>
|
||||
>{{ $t('admin.schedule.form.externalApi') }}</button>
|
||||
</div>
|
||||
<button
|
||||
class="inline-flex items-center gap-1.5 rounded-xl border border-amber-300 bg-amber-50 px-3 py-1.5 text-xs font-semibold text-amber-700 transition hover:bg-amber-100 disabled:cursor-not-allowed disabled:opacity-60"
|
||||
:disabled="scheduleTestLoading || !scheduleEditingId"
|
||||
@click="handleTestScheduleSql"
|
||||
>
|
||||
{{ scheduleTestLoading ? '查询中...' : '测试查询' }}
|
||||
{{ scheduleTestLoading ? $t('admin.schedule.form.querying') : $t('admin.schedule.form.testQuery') }}
|
||||
</button>
|
||||
<button
|
||||
class="inline-flex items-center gap-1.5 rounded-xl border border-slate-200 bg-white px-3 py-1.5 text-xs font-semibold text-slate-600 transition hover:bg-slate-50"
|
||||
@@ -5784,7 +5876,7 @@ const handlePermissionImport = async (event: Event) => {
|
||||
>
|
||||
<ChevronDown v-if="scheduleConfigCollapsed" class="h-3.5 w-3.5" />
|
||||
<ChevronUp v-else class="h-3.5 w-3.5" />
|
||||
{{ scheduleConfigCollapsed ? '展开配置' : '收起配置' }}
|
||||
{{ scheduleConfigCollapsed ? $t('admin.schedule.form.expandConfig') : $t('admin.schedule.form.collapseConfig') }}
|
||||
</button>
|
||||
</div>
|
||||
</div>
|
||||
@@ -5793,7 +5885,7 @@ const handlePermissionImport = async (event: Event) => {
|
||||
<template v-if="scheduleCreateForm.data_source_type === 'database'">
|
||||
<!-- 数据源配置 -->
|
||||
<details class="rounded-xl border border-slate-200 bg-white" open>
|
||||
<summary class="cursor-pointer px-4 py-2.5 text-sm font-semibold text-slate-700 hover:bg-slate-50 rounded-xl">数据源配置</summary>
|
||||
<summary class="cursor-pointer px-4 py-2.5 text-sm font-semibold text-slate-700 hover:bg-slate-50 rounded-xl">{{ $t('admin.schedule.form.dataSourceSection') }}</summary>
|
||||
<div class="space-y-3 px-4 pb-4 pt-2">
|
||||
<div class="grid grid-cols-2 gap-3">
|
||||
<div>
|
||||
@@ -5952,9 +6044,9 @@ const handlePermissionImport = async (event: Event) => {
|
||||
|
||||
<div v-if="scheduleTestResult" class="mt-4 rounded-2xl border border-emerald-200 bg-emerald-50/40 p-4">
|
||||
<div class="mb-3 flex items-center justify-between">
|
||||
<h4 class="text-sm font-bold text-emerald-900">查询结果</h4>
|
||||
<h4 class="text-sm font-bold text-emerald-900">{{ $t('admin.schedule.testRun.queryResult') }}</h4>
|
||||
<div class="flex items-center gap-3">
|
||||
<span class="text-xs text-emerald-600">共 {{ scheduleTestResult.total }} 条,展示 {{ scheduleTestResult.showing }} 条</span>
|
||||
<span class="text-xs text-emerald-600">{{ $t('admin.schedule.testRun.resultSummary', { total: scheduleTestResult.total, showing: scheduleTestResult.showing }) }}</span>
|
||||
<button class="rounded-full p-1 text-emerald-400 transition hover:bg-emerald-100 hover:text-emerald-600" @click="scheduleTestResult = null">✕</button>
|
||||
</div>
|
||||
</div>
|
||||
@@ -5973,7 +6065,7 @@ const handlePermissionImport = async (event: Event) => {
|
||||
</table>
|
||||
</div>
|
||||
<details class="mt-2">
|
||||
<summary class="cursor-pointer text-xs font-semibold text-emerald-700 hover:text-emerald-900">查看生成 SQL</summary>
|
||||
<summary class="cursor-pointer text-xs font-semibold text-emerald-700 hover:text-emerald-900">{{ $t('admin.schedule.testRun.viewGeneratedSql') }}</summary>
|
||||
<pre class="mt-1 whitespace-pre-wrap rounded-lg bg-slate-800 p-3 text-xs text-emerald-300 font-mono">{{ scheduleTestResult.sql }}</pre>
|
||||
</details>
|
||||
</div>
|
||||
@@ -5984,7 +6076,7 @@ const handlePermissionImport = async (event: Event) => {
|
||||
<label class="mb-2 block text-sm font-medium text-slate-600">Agent</label>
|
||||
<div class="relative">
|
||||
<select v-model="scheduleCreateForm.dify_agent_id" class="input-field appearance-none pr-10 !text-sm !leading-5" :disabled="agents.length === 0">
|
||||
<option :value="null">{{ agents.length === 0 ? '暂无可用 Agent' : '不启用' }}</option>
|
||||
<option :value="null">{{ agents.length === 0 ? $t('admin.schedule.form.noAgents') : $t('admin.schedule.form.agentDisabled') }}</option>
|
||||
<option v-for="a in agents" :key="a.id" :value="a.id">{{ a.name }}(ID: {{ a.dify_app_id?.slice(0, 8) || a.id }})</option>
|
||||
</select>
|
||||
<div class="pointer-events-none absolute inset-y-0 right-0 flex items-center pr-3">
|
||||
@@ -5993,15 +6085,27 @@ const handlePermissionImport = async (event: Event) => {
|
||||
</div>
|
||||
</div>
|
||||
<div>
|
||||
<label class="mb-2 block text-sm font-medium text-slate-600">等待时间(秒)</label>
|
||||
<label class="mb-2 block text-sm font-medium text-slate-600">{{ $t('admin.schedule.form.waitSeconds') }}</label>
|
||||
<input v-model.number="scheduleCreateForm.wait_seconds" type="number" min="0" class="input-field !text-sm !leading-5" placeholder="300" />
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div v-if="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-slate-700">Dify System Prompt</label>
|
||||
<p class="mt-1 text-xs text-slate-500">仅在启用 Dify Agent 时可配置。保存后将作为 <code class="rounded bg-white px-1 py-0.5 text-indigo-700">system_prompt</code> 传入 Workflow;编排中 LLM 节点需引用该变量。</p>
|
||||
</div>
|
||||
<textarea
|
||||
v-model="scheduleSqlEditForm.dify_system_prompt"
|
||||
class="w-full min-h-[140px] rounded-xl border border-indigo-200 bg-white p-3 text-sm leading-relaxed text-slate-700 font-mono focus:border-indigo-300 focus:outline-none focus:ring-1 focus:ring-indigo-200 resize-y"
|
||||
placeholder="例如:你是物料合规判定助手。根据 record 中的检测数据判定是否合格,仅返回 JSON:dify_result(合格/不合格/人工判定)与 dify_message。"
|
||||
></textarea>
|
||||
</div>
|
||||
|
||||
<div class="rounded-2xl border border-slate-200 bg-slate-50/40 p-4">
|
||||
<div class="mb-3">
|
||||
<h4 class="text-base font-bold text-slate-900">Cron 图形化设置</h4>
|
||||
<p class="text-sm text-slate-500">选择执行频率后自动生成 Cron 表达式。</p>
|
||||
<h4 class="text-base font-bold text-slate-900">{{ $t('admin.schedule.form.cronTitle') }}</h4>
|
||||
<p class="text-sm text-slate-500">{{ $t('admin.schedule.form.cronHint') }}</p>
|
||||
</div>
|
||||
<div class="grid grid-cols-1 gap-3 md:grid-cols-4">
|
||||
<button
|
||||
@@ -6009,74 +6113,74 @@ const handlePermissionImport = async (event: Event) => {
|
||||
:class="scheduleCronDesigner.mode === 'every_minutes' ? 'border-blue-300 bg-blue-50 text-blue-700' : 'border-slate-200 bg-white text-slate-600'"
|
||||
@click="scheduleCronDesigner.mode = 'every_minutes'"
|
||||
>
|
||||
每隔分钟
|
||||
{{ $t('admin.schedule.form.everyMinutes') }}
|
||||
</button>
|
||||
<button
|
||||
class="rounded-xl border px-3 py-2 text-xs font-semibold transition"
|
||||
:class="scheduleCronDesigner.mode === 'hourly' ? 'border-blue-300 bg-blue-50 text-blue-700' : 'border-slate-200 bg-white text-slate-600'"
|
||||
@click="scheduleCronDesigner.mode = 'hourly'"
|
||||
>
|
||||
每小时
|
||||
{{ $t('admin.schedule.form.hourly') }}
|
||||
</button>
|
||||
<button
|
||||
class="rounded-xl border px-3 py-2 text-xs font-semibold transition"
|
||||
:class="scheduleCronDesigner.mode === 'daily' ? 'border-blue-300 bg-blue-50 text-blue-700' : 'border-slate-200 bg-white text-slate-600'"
|
||||
@click="scheduleCronDesigner.mode = 'daily'"
|
||||
>
|
||||
每天
|
||||
{{ $t('admin.schedule.form.daily') }}
|
||||
</button>
|
||||
<button
|
||||
class="rounded-xl border px-3 py-2 text-xs font-semibold transition"
|
||||
:class="scheduleCronDesigner.mode === 'weekly' ? 'border-blue-300 bg-blue-50 text-blue-700' : 'border-slate-200 bg-white text-slate-600'"
|
||||
@click="scheduleCronDesigner.mode = 'weekly'"
|
||||
>
|
||||
每周
|
||||
{{ $t('admin.schedule.form.weekly') }}
|
||||
</button>
|
||||
</div>
|
||||
|
||||
<div class="mt-4 grid grid-cols-1 gap-3 md:grid-cols-3">
|
||||
<template v-if="scheduleCronDesigner.mode === 'every_minutes'">
|
||||
<div>
|
||||
<label class="mb-1 block text-xs font-semibold text-slate-500 uppercase">分钟间隔</label>
|
||||
<label class="mb-1 block text-xs font-semibold text-slate-500 uppercase">{{ $t('admin.schedule.form.minuteInterval') }}</label>
|
||||
<input v-model.number="scheduleCronDesigner.every_minutes" type="number" min="1" max="59" class="input-field !text-sm !leading-5" />
|
||||
</div>
|
||||
</template>
|
||||
<template v-else-if="scheduleCronDesigner.mode === 'hourly'">
|
||||
<div>
|
||||
<label class="mb-1 block text-xs font-semibold text-slate-500 uppercase">每小时第几分钟</label>
|
||||
<label class="mb-1 block text-xs font-semibold text-slate-500 uppercase">{{ $t('admin.schedule.form.minuteOfHour') }}</label>
|
||||
<input v-model.number="scheduleCronDesigner.hourly_minute" type="number" min="0" max="59" class="input-field !text-sm !leading-5" />
|
||||
</div>
|
||||
</template>
|
||||
<template v-else-if="scheduleCronDesigner.mode === 'daily'">
|
||||
<div>
|
||||
<label class="mb-1 block text-xs font-semibold text-slate-500 uppercase">小时</label>
|
||||
<label class="mb-1 block text-xs font-semibold text-slate-500 uppercase">{{ $t('admin.schedule.form.hour') }}</label>
|
||||
<input v-model.number="scheduleCronDesigner.daily_hour" type="number" min="0" max="23" class="input-field !text-sm !leading-5" />
|
||||
</div>
|
||||
<div>
|
||||
<label class="mb-1 block text-xs font-semibold text-slate-500 uppercase">分钟</label>
|
||||
<label class="mb-1 block text-xs font-semibold text-slate-500 uppercase">{{ $t('admin.schedule.form.minute') }}</label>
|
||||
<input v-model.number="scheduleCronDesigner.daily_minute" type="number" min="0" max="59" class="input-field !text-sm !leading-5" />
|
||||
</div>
|
||||
</template>
|
||||
<template v-else>
|
||||
<div>
|
||||
<label class="mb-1 block text-xs font-semibold text-slate-500 uppercase">星期</label>
|
||||
<label class="mb-1 block text-xs font-semibold text-slate-500 uppercase">{{ $t('admin.schedule.form.weekday') }}</label>
|
||||
<select v-model.number="scheduleCronDesigner.weekly_day" class="input-field !text-sm !leading-5">
|
||||
<option v-for="d in weeklyDayOptions" :key="d.value" :value="d.value">{{ d.label }}</option>
|
||||
</select>
|
||||
</div>
|
||||
<div>
|
||||
<label class="mb-1 block text-xs font-semibold text-slate-500 uppercase">小时</label>
|
||||
<label class="mb-1 block text-xs font-semibold text-slate-500 uppercase">{{ $t('admin.schedule.form.hour') }}</label>
|
||||
<input v-model.number="scheduleCronDesigner.weekly_hour" type="number" min="0" max="23" class="input-field !text-sm !leading-5" />
|
||||
</div>
|
||||
<div>
|
||||
<label class="mb-1 block text-xs font-semibold text-slate-500 uppercase">分钟</label>
|
||||
<label class="mb-1 block text-xs font-semibold text-slate-500 uppercase">{{ $t('admin.schedule.form.minute') }}</label>
|
||||
<input v-model.number="scheduleCronDesigner.weekly_minute" type="number" min="0" max="59" class="input-field !text-sm !leading-5" />
|
||||
</div>
|
||||
</template>
|
||||
</div>
|
||||
<div class="mt-4 rounded-xl border border-dashed border-slate-300 bg-white px-4 py-3 text-xs text-slate-600">
|
||||
Cron 预览:<span class="font-mono text-slate-900">{{ scheduleCronPreview }}</span>
|
||||
<span v-if="scheduleNextRunPreview" class="ml-4">下次执行:<span class="font-medium text-slate-900">{{ formatDateTime(scheduleNextRunPreview.toISOString()) }}</span></span>
|
||||
{{ $t('admin.schedule.form.cronPreview') }}:<span class="font-mono text-slate-900">{{ scheduleCronPreview }}</span>
|
||||
<span v-if="scheduleNextRunPreview" class="ml-4">{{ $t('admin.schedule.form.nextRun') }}:<span class="font-medium text-slate-900">{{ formatDateTime(scheduleNextRunPreview.toISOString()) }}</span></span>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
@@ -6084,7 +6188,7 @@ const handlePermissionImport = async (event: Event) => {
|
||||
<div class="flex flex-col gap-2 md:flex-row md:items-center">
|
||||
<label class="inline-flex shrink-0 items-center gap-2 text-sm text-slate-700">
|
||||
<input v-model="scheduleCreateForm.notify_enabled" type="checkbox" class="h-4 w-4 rounded text-blue-600" />
|
||||
启用通知
|
||||
{{ $t('admin.schedule.form.notifyEnabled') }}
|
||||
</label>
|
||||
<div v-if="scheduleCreateForm.notify_enabled" class="relative flex-1">
|
||||
<div
|
||||
@@ -6104,7 +6208,7 @@ const handlePermissionImport = async (event: Event) => {
|
||||
>✕</button>
|
||||
</span>
|
||||
</template>
|
||||
<span v-else class="text-slate-400">选择通知人员...</span>
|
||||
<span v-else class="text-slate-400">{{ $t('admin.schedule.form.selectNotifyUsers') }}</span>
|
||||
</div>
|
||||
<div
|
||||
v-if="scheduleNotifyDropdownOpen"
|
||||
@@ -6136,14 +6240,14 @@ const handlePermissionImport = async (event: Event) => {
|
||||
<div class="flex items-center justify-between gap-3 border-t border-slate-100 px-8 py-5">
|
||||
<label class="inline-flex items-center gap-2 rounded-xl border border-slate-200 bg-white px-3 py-2 text-sm text-slate-700">
|
||||
<input v-model="scheduleCreateForm.enabled" type="checkbox" class="h-4 w-4 rounded text-blue-600" />
|
||||
创建后启用
|
||||
{{ $t('admin.schedule.form.enableOnCreate') }}
|
||||
</label>
|
||||
<div class="flex items-center gap-3">
|
||||
<button
|
||||
class="rounded-2xl border border-slate-200 px-6 py-2.5 text-sm text-slate-600 hover:bg-slate-50"
|
||||
@click="showScheduleCreateModal = false"
|
||||
>
|
||||
取消
|
||||
{{ $t('admin.schedule.form.cancel') }}
|
||||
</button>
|
||||
<button
|
||||
class="inline-flex items-center gap-2 rounded-2xl bg-blue-600 px-6 py-2.5 text-sm font-semibold text-white hover:bg-blue-700 disabled:cursor-not-allowed disabled:opacity-60"
|
||||
@@ -6151,7 +6255,7 @@ const handlePermissionImport = async (event: Event) => {
|
||||
@click="createSchedule"
|
||||
>
|
||||
<Plus class="h-4 w-4" />
|
||||
{{ scheduleCreateSaving ? '保存中...' : (scheduleEditingId ? '保存修改' : '创建排程') }}
|
||||
{{ scheduleCreateSaving ? $t('admin.schedule.form.saving') : (scheduleEditingId ? $t('admin.schedule.form.saveChanges') : $t('admin.schedule.form.createSchedule')) }}
|
||||
</button>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
@@ -13,7 +13,7 @@
|
||||
import { ref, onMounted, onBeforeUnmount, computed, watch, nextTick } from 'vue';
|
||||
import { useI18n } from 'vue-i18n';
|
||||
import { useChat } from '../composables/useChat';
|
||||
import { Send, Loader2, Plus, Copy, Edit2, RotateCw, Check, X, PanelLeftClose, PanelLeftOpen, Mail, Settings, ChevronDown, Sparkles, Database, Mic, LogOut, MessageSquareText, Globe, ExternalLink, Search, LayoutGrid, History, Sun, Moon } from 'lucide-vue-next';
|
||||
import { Send, Loader2, Plus, Copy, Edit2, RotateCw, Check, X, PanelLeftClose, PanelLeftOpen, ChevronDown, Sparkles, Database, Mic, LogOut, MessageSquareText, Globe, ExternalLink, Search, LayoutGrid, Briefcase, History, Sun, Moon } from 'lucide-vue-next';
|
||||
import { marked } from 'marked';
|
||||
import { useRoute, useRouter } from 'vue-router';
|
||||
import { config } from '../config';
|
||||
@@ -24,6 +24,7 @@ import { useMessage } from '../composables/useMessage';
|
||||
import { useIsMobile } from '../composables/useIsMobile';
|
||||
import { useTheme } from '../composables/useTheme';
|
||||
import { getAuthHeaders, getStoredAuthUser, clearAuthUser } from '../utils/auth';
|
||||
import { copyTextToClipboard } from '../utils/clipboard';
|
||||
|
||||
const { t, locale } = useI18n();
|
||||
const { appliedTheme, toggleLightDark } = useTheme();
|
||||
@@ -1613,16 +1614,29 @@ const confirmLeaveSubmission = async (msg: any) => {
|
||||
}
|
||||
};
|
||||
|
||||
const copyToClipboard = async (text: string, index: number) => {
|
||||
try {
|
||||
await navigator.clipboard.writeText(text);
|
||||
const getMessageCopyText = (message: { role?: string; content?: string; type?: string }) => {
|
||||
const content = String(message?.content ?? '').trim();
|
||||
if (content) return content;
|
||||
return '';
|
||||
};
|
||||
|
||||
const copyToClipboard = async (message: { role?: string; content?: string; type?: string }, index: number) => {
|
||||
const text = getMessageCopyText(message);
|
||||
if (!text) {
|
||||
msg.warning(t('chat.actions.copyEmpty'));
|
||||
return;
|
||||
}
|
||||
|
||||
const ok = await copyTextToClipboard(text);
|
||||
if (ok) {
|
||||
copiedIndex.value = index;
|
||||
setTimeout(() => {
|
||||
copiedIndex.value = null;
|
||||
}, 2000);
|
||||
} catch (err) {
|
||||
console.error('Failed to copy:', err);
|
||||
return;
|
||||
}
|
||||
|
||||
msg.warning(t('chat.actions.copyFailed'));
|
||||
};
|
||||
|
||||
const regenerate = () => {
|
||||
@@ -1848,8 +1862,8 @@ const showChatRating = ref(false);
|
||||
<div class="flex h-8 w-8 items-center justify-center rounded-full bg-brand-600 text-sm font-bold text-white shadow-sm shadow-brand-500/20">
|
||||
{{ (currentUser?.username || 'I').charAt(0).toUpperCase() }}
|
||||
</div>
|
||||
<button @click="showGeneralFeedbackDialog = true" class="transition-colors hover:text-slate-600 dark:hover:text-slate-200" :title="$t('chat.generalFeedback')"><Mail class="h-5 w-5" /></button>
|
||||
<button @click="router.push('/workspace?no_redirect=1')" class="transition-colors hover:text-slate-600 dark:hover:text-slate-200"><Settings class="h-5 w-5" /></button>
|
||||
<button @click="showGeneralFeedbackDialog = true" class="transition-colors hover:text-slate-600 dark:hover:text-slate-200" :title="$t('chat.generalFeedback')"><MessageSquareText class="h-5 w-5" /></button>
|
||||
<button @click="router.push('/workspace?no_redirect=1')" class="transition-colors hover:text-slate-600 dark:hover:text-slate-200" :title="$t('workspace.title')"><Briefcase class="h-5 w-5" /></button>
|
||||
</div>
|
||||
</div>
|
||||
</template>
|
||||
@@ -1945,9 +1959,9 @@ const showChatRating = ref(false);
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="px-4 pt-3 pb-1 text-xs font-medium text-slate-500 dark:text-slate-400">{{ $t('chat.language') }}</div>
|
||||
<div class="px-4 pb-2">
|
||||
<select v-model="locale" class="w-full rounded-xl border border-slate-200 bg-white px-3 py-2 text-sm text-slate-700 outline-none transition focus:border-brand-400 dark:border-slate-700 dark:bg-slate-900 dark:text-slate-200">
|
||||
<div class="flex items-center gap-2 px-4 py-2">
|
||||
<span class="shrink-0 text-xs font-medium text-slate-500 dark:text-slate-400">{{ $t('chat.language') }}</span>
|
||||
<select v-model="locale" class="min-w-0 flex-1 rounded-lg border border-slate-200 bg-slate-50 px-2 py-1 text-xs text-slate-700 outline-none transition focus:border-brand-400 dark:border-slate-600 dark:bg-slate-800 dark:text-slate-200">
|
||||
<option value="zh-CN">简体中文</option>
|
||||
<option value="en">English</option>
|
||||
<option value="zh-TW">繁體中文</option>
|
||||
@@ -1955,7 +1969,7 @@ const showChatRating = ref(false);
|
||||
</select>
|
||||
</div>
|
||||
|
||||
<button @click="handleLogout" class="w-full text-left px-4 py-2 text-sm text-red-600 hover:bg-red-50 flex items-center gap-2 transition-colors mt-1">
|
||||
<button @click="handleLogout" class="flex w-full items-center gap-2 border-t border-slate-50 px-4 py-2 text-left text-sm text-red-600 transition-colors hover:bg-red-50 dark:border-slate-700/50 dark:hover:bg-red-950/30">
|
||||
<LogOut class="w-4 h-4" />
|
||||
{{ $t('chat.logout') }}
|
||||
</button>
|
||||
@@ -1969,8 +1983,8 @@ const showChatRating = ref(false);
|
||||
<Sun v-if="appliedTheme === 'dark'" class="h-4 w-4" />
|
||||
<Moon v-else class="h-4 w-4" />
|
||||
</button>
|
||||
<button @click="showGeneralFeedbackDialog = true" class="transition-colors hover:text-slate-600 dark:hover:text-slate-200" :title="$t('chat.generalFeedback')"><Mail class="h-4 w-4" /></button>
|
||||
<button @click="router.push('/workspace?no_redirect=1')" class="transition-colors hover:text-slate-600 dark:hover:text-slate-200"><Settings class="h-4 w-4" /></button>
|
||||
<button @click="showGeneralFeedbackDialog = true" class="transition-colors hover:text-slate-600 dark:hover:text-slate-200" :title="$t('chat.generalFeedback')"><MessageSquareText class="h-4 w-4" /></button>
|
||||
<button @click="router.push('/workspace?no_redirect=1')" class="transition-colors hover:text-slate-600 dark:hover:text-slate-200" :title="$t('workspace.title')"><Briefcase class="h-4 w-4" /></button>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
@@ -2364,7 +2378,8 @@ const showChatRating = ref(false);
|
||||
:class="msg.role === 'user' ? 'justify-end text-slate-500' : 'justify-start text-slate-500'"
|
||||
>
|
||||
<button
|
||||
@click="copyToClipboard(msg.content, index)"
|
||||
type="button"
|
||||
@click.stop="copyToClipboard(msg, index)"
|
||||
class="rounded-md p-1.5 text-xs transition-colors hover:bg-slate-100 dark:hover:bg-slate-800"
|
||||
:title="$t('chat.actions.copy')"
|
||||
>
|
||||
@@ -2374,14 +2389,16 @@ const showChatRating = ref(false);
|
||||
|
||||
<template v-if="msg.role === 'user'">
|
||||
<button
|
||||
@click="input = msg.content"
|
||||
type="button"
|
||||
@click.stop="input = msg.content"
|
||||
class="rounded-md p-1.5 text-xs transition-colors hover:bg-slate-100 dark:hover:bg-slate-800"
|
||||
:title="$t('chat.actions.edit')"
|
||||
>
|
||||
<Edit2 class="h-3.5 w-3.5" />
|
||||
</button>
|
||||
<button
|
||||
@click="handleSend(msg.content)"
|
||||
type="button"
|
||||
@click.stop="handleSend(msg.content)"
|
||||
class="rounded-md p-1.5 text-xs transition-colors hover:bg-slate-100 dark:hover:bg-slate-800"
|
||||
:title="$t('chat.actions.resend')"
|
||||
>
|
||||
|
||||
@@ -102,9 +102,11 @@ const openDeleteConfirmDialog = (
|
||||
message: string,
|
||||
onConfirm: () => Promise<void> | void
|
||||
) => {
|
||||
console.log('[KB] openDeleteConfirmDialog', message);
|
||||
deleteConfirmMessage.value = message;
|
||||
pendingDeleteAction = onConfirm;
|
||||
showDeleteConfirmDialog.value = true;
|
||||
console.log('[KB] showDeleteConfirmDialog set to', showDeleteConfirmDialog.value);
|
||||
};
|
||||
|
||||
const closeDeleteConfirmDialog = () => {
|
||||
@@ -115,7 +117,13 @@ const closeDeleteConfirmDialog = () => {
|
||||
|
||||
const handleDeleteConfirm = async () => {
|
||||
if (!pendingDeleteAction) return;
|
||||
await pendingDeleteAction();
|
||||
try {
|
||||
await pendingDeleteAction();
|
||||
} catch (err) {
|
||||
console.error('[deleteConfirm]', err);
|
||||
feedback.value = String(err) || '操作失败';
|
||||
feedbackType.value = 'error';
|
||||
}
|
||||
closeDeleteConfirmDialog();
|
||||
};
|
||||
const selectedDocument = computed(() => documents.value.find((item) => item.id === selectedDocumentId.value) || null);
|
||||
@@ -1110,6 +1118,7 @@ const toggleSelectAllFiltered = () => {
|
||||
};
|
||||
|
||||
const handleDeleteDocument = async (doc: KbDocumentItem) => {
|
||||
console.log('[KB] handleDeleteDocument called', doc.id, doc.title);
|
||||
openDeleteConfirmDialog(`确认删除文档「${getDocumentDisplayTitle(doc)}」吗?`, async () => {
|
||||
const result = await deleteKbDocument(doc.id);
|
||||
if (!result.ok) {
|
||||
@@ -1161,6 +1170,7 @@ const handleBatchSync = async () => {
|
||||
};
|
||||
|
||||
const handleBatchDelete = async () => {
|
||||
console.log('[KB] handleBatchDelete called, selected:', selectedDocuments.value.length);
|
||||
if (!selectedDocuments.value.length) {
|
||||
feedback.value = '请先选择要批量删除的文档';
|
||||
feedbackType.value = 'error';
|
||||
@@ -2581,11 +2591,12 @@ onUnmounted(() => {
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<DeleteConfirmDialog
|
||||
v-model="showDeleteConfirmDialog"
|
||||
:message="deleteConfirmMessage"
|
||||
@confirm="handleDeleteConfirm"
|
||||
@cancel="closeDeleteConfirmDialog"
|
||||
/>
|
||||
</div>
|
||||
|
||||
<DeleteConfirmDialog
|
||||
v-model="showDeleteConfirmDialog"
|
||||
:message="deleteConfirmMessage"
|
||||
@confirm="handleDeleteConfirm"
|
||||
@cancel="closeDeleteConfirmDialog"
|
||||
/>
|
||||
</template>
|
||||
Reference in new issue
Block a user