Merge branch 'dev' into hugo-shipping-notice
This commit is contained in:
commit
472b530be3
397 files changed
+46450
-34171
No files matched your search
@@ -21,6 +21,24 @@ import type {
|
||||
const auth = () => ({ headers: getAuthHeaders() });
|
||||
const jsonAuth = () => ({ headers: { 'Content-Type': 'application/json', ...getAuthHeaders() } });
|
||||
|
||||
export type LinkedServicePayload = {
|
||||
name: string;
|
||||
url: string;
|
||||
description?: string;
|
||||
icon?: string;
|
||||
sort_order?: number;
|
||||
enabled?: boolean;
|
||||
is_enabled?: boolean;
|
||||
};
|
||||
|
||||
export const listLinkedServices = () => requestJson<any[]>('/api/admin/linked-services', auth());
|
||||
export const createLinkedService = (payload: LinkedServicePayload) =>
|
||||
requestJson<any>('/api/admin/linked-services', { method: 'POST', ...jsonAuth(), body: JSON.stringify(payload) });
|
||||
export const updateLinkedService = (id: number, payload: LinkedServicePayload) =>
|
||||
requestJson<any>(`/api/admin/linked-services/${id}`, { method: 'PUT', ...jsonAuth(), body: JSON.stringify(payload) });
|
||||
export const deleteLinkedService = (id: number) =>
|
||||
requestJson<void>(`/api/admin/linked-services/${id}`, { method: 'DELETE', ...auth() });
|
||||
|
||||
export type ShippingInventoryReadinessCheck = {
|
||||
code: string;
|
||||
status: 'passed' | 'pending' | 'failed' | 'stale' | 'empty';
|
||||
|
||||
@@ -0,0 +1,406 @@
|
||||
/**
|
||||
* features/admin/api/procurement-contract.api.ts
|
||||
* 用途:采购合同审查 Admin / 会话 API 封装(含鉴权下载)。
|
||||
* 依赖:shared/api/client requestJson、auth headers。
|
||||
* 逻辑:Templates / Reviews 页面与 Chat 控件调用;下载走 fetch+blob。
|
||||
*/
|
||||
import { requestJson } from '@/shared/api/client';
|
||||
import { getAuthHeaders } from '@/shared/utils/auth';
|
||||
|
||||
export type ContractMetadataField = 'title' | 'version' | 'contract_no' | 'buyer' | 'seller';
|
||||
|
||||
export interface ContractComparisonRegionConfig {
|
||||
metadata_fields: ContractMetadataField[];
|
||||
body_start_anchors: string[];
|
||||
body_end_anchors: string[];
|
||||
signature_terms: string[];
|
||||
attachment_start_anchors: string[];
|
||||
attachment_policy: 'page_count_only';
|
||||
}
|
||||
|
||||
export interface ContractComparisonRegionPreview {
|
||||
status: 'recognized' | 'incomplete' | string;
|
||||
body_start_anchor?: string | null;
|
||||
body_end_anchor?: string | null;
|
||||
signature_terms_found?: string[];
|
||||
attachment_anchor?: string | null;
|
||||
warning?: string | null;
|
||||
}
|
||||
|
||||
export interface ContractTemplateRow {
|
||||
id: number;
|
||||
name: string;
|
||||
version: string;
|
||||
file_name: string;
|
||||
file_asset_id?: number | null;
|
||||
contract_type?: string;
|
||||
applicable_scope?: string | null;
|
||||
change_note?: string | null;
|
||||
comparison_region_config?: ContractComparisonRegionConfig | null;
|
||||
status: 'enabled' | 'disabled' | string;
|
||||
is_default: boolean;
|
||||
remark?: string | null;
|
||||
updated_by_name?: string | null;
|
||||
created_at?: string | null;
|
||||
updated_at?: string | null;
|
||||
}
|
||||
|
||||
export interface ContractClauseItem {
|
||||
clause_no?: string;
|
||||
title?: string;
|
||||
change_type?: string;
|
||||
/** 后端语义分类:仅 obligation 会参与法律与履约风险统计。 */
|
||||
change_class?: 'format' | 'metadata' | 'commercial' | 'obligation' | string;
|
||||
risk_level?: string;
|
||||
clause_category?: string;
|
||||
detail?: string;
|
||||
risk_hint?: string;
|
||||
suggestion?: string;
|
||||
negotiation_text?: string;
|
||||
old_text?: string;
|
||||
new_text?: string;
|
||||
/** 后端标记:old/new 是否为可读抽取片段;false 时前端展示编码不兼容提示 */
|
||||
comparison_readable?: boolean;
|
||||
llm_enabled?: boolean;
|
||||
llm_confidence?: number | null;
|
||||
llm_reason?: string;
|
||||
llm_suggestion?: string;
|
||||
llm_negotiation_text?: string;
|
||||
llm_model_risk_level?: string;
|
||||
llm_decision?: 'confirm' | 'reject' | 'uncertain' | string;
|
||||
llm_evidence?: string;
|
||||
evidence?: string;
|
||||
source?: string;
|
||||
validation_status?: 'confirmed' | 'needs_review' | string;
|
||||
/** 同一业务主题下聚合的底层 OCR 不确定片段数。 */
|
||||
affected_fragments?: number;
|
||||
business_impact?: string;
|
||||
anchor_status?: 'anchored' | 'unanchored' | string;
|
||||
evidence_anchor?: {
|
||||
page_no?: number;
|
||||
rects?: number[][];
|
||||
matched_text?: string;
|
||||
source_text?: string;
|
||||
confidence?: number;
|
||||
method?: 'exact' | 'fuzzy' | 'ocr_page' | string;
|
||||
} | null;
|
||||
}
|
||||
|
||||
export interface ContractRiskRuleRow {
|
||||
id: number;
|
||||
code: string;
|
||||
/** 内置规则携带组合业务判断;自定义规则仅执行关键词命中判断。 */
|
||||
rule_kind?: 'builtin' | 'custom' | string;
|
||||
contract_type: string;
|
||||
clause_category: string;
|
||||
title: string;
|
||||
keywords: string[];
|
||||
trigger_type: 'keyword_missing' | 'keyword_present' | string;
|
||||
risk_level: 'high' | 'medium' | 'low' | string;
|
||||
risk_hint: string;
|
||||
suggestion: string;
|
||||
negotiation_text?: string | null;
|
||||
status: 'enabled' | 'disabled' | string;
|
||||
sort_order: number;
|
||||
created_at?: string | null;
|
||||
updated_at?: string | null;
|
||||
}
|
||||
|
||||
export interface ContractReviewRow {
|
||||
id: number;
|
||||
review_no: string;
|
||||
review_mode: 'compare' | 'solo' | string;
|
||||
status: string;
|
||||
contract_file_name: string;
|
||||
supplier_name?: string | null;
|
||||
/** 从合同正文抽取的业务合同编号(非审查编号) */
|
||||
contract_no?: string | null;
|
||||
contract_type?: string;
|
||||
template_id?: number | null;
|
||||
template_source: string;
|
||||
template_name?: string | null;
|
||||
total_change_count?: number;
|
||||
high_risk_count: number;
|
||||
medium_risk_count: number;
|
||||
low_risk_count: number;
|
||||
user_id: number;
|
||||
user_name?: string | null;
|
||||
error_message?: string | null;
|
||||
started_at?: string | null;
|
||||
finished_at?: string | null;
|
||||
created_at?: string | null;
|
||||
progress?: number;
|
||||
processing_stage?: string | null;
|
||||
processing_message?: string | null;
|
||||
summary_json?: Record<string, unknown> | null;
|
||||
clauses_json?: ContractClauseItem[] | null;
|
||||
report_text?: string | null;
|
||||
template_asset_id?: number | null;
|
||||
}
|
||||
|
||||
/**
|
||||
* 鉴权下载:fetch blob → 触发浏览器保存。
|
||||
* @param url - 需携带 JWT 的下载 URL
|
||||
* @param fallbackName - Content-Disposition 缺失时的文件名
|
||||
*/
|
||||
async function downloadAuthenticatedFile(url: string, fallbackName: string): Promise<void> {
|
||||
const res = await fetch(url, { headers: getAuthHeaders() });
|
||||
if (!res.ok) {
|
||||
const body = await res.json().catch(() => ({}));
|
||||
const err = body as { error?: { message?: string }; message?: string };
|
||||
throw new Error(err?.error?.message || err?.message || res.statusText);
|
||||
}
|
||||
const disposition = res.headers.get('content-disposition');
|
||||
const blob = await res.blob();
|
||||
const objectUrl = URL.createObjectURL(blob);
|
||||
const a = document.createElement('a');
|
||||
a.href = objectUrl;
|
||||
const rawName = disposition?.match(/filename\*?=(?:UTF-8'')?["']?([^;"'\n]+)/)?.[1] || fallbackName;
|
||||
try {
|
||||
a.download = decodeURIComponent(rawName);
|
||||
} catch {
|
||||
a.download = rawName;
|
||||
}
|
||||
document.body.appendChild(a);
|
||||
a.click();
|
||||
document.body.removeChild(a);
|
||||
URL.revokeObjectURL(objectUrl);
|
||||
}
|
||||
|
||||
/** Admin:下载模板文件 */
|
||||
export function downloadAdminContractTemplate(templateId: number): Promise<void> {
|
||||
return downloadAuthenticatedFile(
|
||||
`/api/admin/procurement-contract/templates/${templateId}/file`,
|
||||
`template-${templateId}`,
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* Admin:下载审查报告。
|
||||
* @param reviewId - 审查主键
|
||||
* @param reviewNo - 审查编号(文件名用)
|
||||
* @param format - 默认 docx;传 txt 可下载纯文本
|
||||
*/
|
||||
export function downloadAdminContractReviewReport(
|
||||
reviewId: number,
|
||||
reviewNo?: string,
|
||||
format: 'txt' | 'docx' = 'docx',
|
||||
): Promise<void> {
|
||||
const q = format === 'docx' ? '?format=docx' : '';
|
||||
return downloadAuthenticatedFile(
|
||||
`/api/admin/procurement-contract/reviews/${reviewId}/report${q}`,
|
||||
`${reviewNo || reviewId}_report.${format === 'docx' ? 'docx' : 'txt'}`,
|
||||
);
|
||||
}
|
||||
|
||||
/** Admin:下载待审合同 */
|
||||
export function downloadAdminContractReviewContract(reviewId: number, fileName?: string): Promise<void> {
|
||||
return downloadAuthenticatedFile(
|
||||
`/api/admin/procurement-contract/reviews/${reviewId}/contract`,
|
||||
fileName || `contract-${reviewId}`,
|
||||
);
|
||||
}
|
||||
|
||||
/** Admin:下载带风险高亮批注的合同 PDF 副本 */
|
||||
export function downloadAdminAnnotatedContract(reviewId: number, reviewNo?: string): Promise<void> {
|
||||
return downloadAuthenticatedFile(
|
||||
`/api/admin/procurement-contract/reviews/${reviewId}/annotated-contract`,
|
||||
`${reviewNo || reviewId}_annotated.pdf`,
|
||||
);
|
||||
}
|
||||
|
||||
/** Admin:下载本次审查所用模板文件 */
|
||||
export function downloadAdminContractReviewTemplateFile(reviewId: number): Promise<void> {
|
||||
return downloadAuthenticatedFile(
|
||||
`/api/admin/procurement-contract/reviews/${reviewId}/template-file`,
|
||||
`template-for-review-${reviewId}`,
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* Chat:下载本人审查报告。
|
||||
* @param reviewNo - 审查编号
|
||||
* @param format - 默认 docx;传 txt 可下载纯文本
|
||||
*/
|
||||
export function downloadChatContractReviewReport(
|
||||
reviewNo: string,
|
||||
format: 'txt' | 'docx' = 'docx',
|
||||
): Promise<void> {
|
||||
const q = format === 'docx' ? '?format=docx' : '';
|
||||
return downloadAuthenticatedFile(
|
||||
`/api/procurement-contract/reviews/${encodeURIComponent(reviewNo)}/report${q}`,
|
||||
`${reviewNo}_report.${format === 'docx' ? 'docx' : 'txt'}`,
|
||||
);
|
||||
}
|
||||
|
||||
/** Chat:下载本人带风险高亮批注的合同 PDF */
|
||||
export function downloadChatAnnotatedContract(reviewNo: string): Promise<void> {
|
||||
return downloadAuthenticatedFile(
|
||||
`/api/procurement-contract/reviews/${encodeURIComponent(reviewNo)}/annotated-contract`,
|
||||
`${reviewNo}_annotated.pdf`,
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* 管理端模板列表。
|
||||
*/
|
||||
export async function listAdminContractTemplates(status?: string): Promise<ContractTemplateRow[]> {
|
||||
const q = status ? `?status=${encodeURIComponent(status)}` : '';
|
||||
return requestJson<ContractTemplateRow[]>(`/api/admin/procurement-contract/templates${q}`);
|
||||
}
|
||||
|
||||
/**
|
||||
* 上传并创建模板(multipart)。
|
||||
*/
|
||||
export async function createAdminContractTemplate(form: FormData): Promise<ContractTemplateRow> {
|
||||
const res = await fetch('/api/admin/procurement-contract/templates', {
|
||||
method: 'POST',
|
||||
headers: getAuthHeaders(),
|
||||
body: form,
|
||||
});
|
||||
const body = await res.json();
|
||||
if (!res.ok || body?.success === false) {
|
||||
throw new Error(body?.error?.message || body?.message || 'upload failed');
|
||||
}
|
||||
return (body?.data ?? body) as ContractTemplateRow;
|
||||
}
|
||||
|
||||
/**
|
||||
* 更新模板。
|
||||
*/
|
||||
export async function updateAdminContractTemplate(
|
||||
id: number,
|
||||
data: Partial<Pick<ContractTemplateRow, 'name' | 'version' | 'status' | 'is_default' | 'remark' | 'contract_type' | 'applicable_scope' | 'change_note' | 'comparison_region_config'>>,
|
||||
): Promise<ContractTemplateRow> {
|
||||
return requestJson<ContractTemplateRow>(`/api/admin/procurement-contract/templates/${id}`, {
|
||||
method: 'PATCH',
|
||||
headers: { 'Content-Type': 'application/json' },
|
||||
body: JSON.stringify(data),
|
||||
});
|
||||
}
|
||||
|
||||
/** Admin: preview unsaved region anchors against the stored template file. */
|
||||
export async function previewAdminContractTemplateRegions(
|
||||
id: number,
|
||||
comparisonRegionConfig: ContractComparisonRegionConfig,
|
||||
): Promise<ContractComparisonRegionPreview> {
|
||||
return requestJson<ContractComparisonRegionPreview>(
|
||||
`/api/admin/procurement-contract/templates/${id}/comparison-region-preview`,
|
||||
{
|
||||
method: 'POST',
|
||||
headers: { 'Content-Type': 'application/json' },
|
||||
body: JSON.stringify({ comparison_region_config: comparisonRegionConfig }),
|
||||
},
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* 删除模板。
|
||||
*/
|
||||
export async function deleteAdminContractTemplate(id: number): Promise<void> {
|
||||
await requestJson(`/api/admin/procurement-contract/templates/${id}`, { method: 'DELETE' });
|
||||
}
|
||||
|
||||
/**
|
||||
* 审查历史列表。
|
||||
*/
|
||||
export async function listAdminContractReviews(params?: {
|
||||
review_mode?: string;
|
||||
template_source?: string;
|
||||
status?: string;
|
||||
keyword?: string;
|
||||
contract_type?: string;
|
||||
supplier_name?: string;
|
||||
risk_level?: string;
|
||||
date_from?: string;
|
||||
date_to?: string;
|
||||
}): Promise<{ total: number; items: ContractReviewRow[] }> {
|
||||
const sp = new URLSearchParams();
|
||||
if (params?.review_mode) sp.set('review_mode', params.review_mode);
|
||||
if (params?.template_source) sp.set('template_source', params.template_source);
|
||||
if (params?.status) sp.set('status', params.status);
|
||||
if (params?.keyword) sp.set('keyword', params.keyword);
|
||||
if (params?.contract_type) sp.set('contract_type', params.contract_type);
|
||||
if (params?.supplier_name) sp.set('supplier_name', params.supplier_name);
|
||||
if (params?.risk_level) sp.set('risk_level', params.risk_level);
|
||||
if (params?.date_from) sp.set('date_from', params.date_from);
|
||||
if (params?.date_to) sp.set('date_to', params.date_to);
|
||||
const q = sp.toString() ? `?${sp.toString()}` : '';
|
||||
return requestJson(`/api/admin/procurement-contract/reviews${q}`);
|
||||
}
|
||||
|
||||
/**
|
||||
* 审查详情。
|
||||
*/
|
||||
export async function getAdminContractReview(id: number): Promise<ContractReviewRow> {
|
||||
return requestJson(`/api/admin/procurement-contract/reviews/${id}`);
|
||||
}
|
||||
|
||||
/** Admin:风险规则列表 */
|
||||
export async function listAdminContractRiskRules(params?: {
|
||||
contract_type?: string;
|
||||
status?: string;
|
||||
clause_category?: string;
|
||||
}): Promise<ContractRiskRuleRow[]> {
|
||||
const sp = new URLSearchParams();
|
||||
if (params?.contract_type) sp.set('contract_type', params.contract_type);
|
||||
if (params?.status) sp.set('status', params.status);
|
||||
if (params?.clause_category) sp.set('clause_category', params.clause_category);
|
||||
const q = sp.toString() ? `?${sp.toString()}` : '';
|
||||
return requestJson(`/api/admin/procurement-contract/rules${q}`);
|
||||
}
|
||||
|
||||
/** Admin:创建风险规则 */
|
||||
export async function createAdminContractRiskRule(
|
||||
data: Omit<Partial<ContractRiskRuleRow>, 'id'>,
|
||||
): Promise<ContractRiskRuleRow> {
|
||||
return requestJson('/api/admin/procurement-contract/rules', {
|
||||
method: 'POST',
|
||||
headers: { 'Content-Type': 'application/json' },
|
||||
body: JSON.stringify(data),
|
||||
});
|
||||
}
|
||||
|
||||
/** Admin:更新风险规则 */
|
||||
export async function updateAdminContractRiskRule(
|
||||
id: number,
|
||||
data: Partial<ContractRiskRuleRow>,
|
||||
): Promise<ContractRiskRuleRow> {
|
||||
return requestJson(`/api/admin/procurement-contract/rules/${id}`, {
|
||||
method: 'PATCH',
|
||||
headers: { 'Content-Type': 'application/json' },
|
||||
body: JSON.stringify(data),
|
||||
});
|
||||
}
|
||||
|
||||
/** Admin:删除风险规则 */
|
||||
export async function deleteAdminContractRiskRule(id: number): Promise<void> {
|
||||
await requestJson(`/api/admin/procurement-contract/rules/${id}`, { method: 'DELETE' });
|
||||
}
|
||||
|
||||
/** 会话:启用模板列表 */
|
||||
export async function listChatContractTemplates(): Promise<ContractTemplateRow[]> {
|
||||
return requestJson('/api/procurement-contract/templates');
|
||||
}
|
||||
|
||||
/** 会话:发起审查 */
|
||||
export async function startChatContractReview(payload: {
|
||||
review_mode: 'compare' | 'solo';
|
||||
contract_asset_no: string;
|
||||
/** 模板比对时必填:用户上传的我方原合同资产编号。 */
|
||||
original_contract_asset_no?: string | null;
|
||||
contract_type?: string | null;
|
||||
supplier_name?: string | null;
|
||||
agent_id?: number | null;
|
||||
}): Promise<ContractReviewRow> {
|
||||
return requestJson('/api/procurement-contract/reviews', {
|
||||
method: 'POST',
|
||||
headers: { 'Content-Type': 'application/json' },
|
||||
body: JSON.stringify(payload),
|
||||
});
|
||||
}
|
||||
|
||||
/** 会话:轮询本人合同审查详情 */
|
||||
export async function getChatContractReview(reviewNo: string): Promise<ContractReviewRow> {
|
||||
return requestJson(`/api/procurement-contract/reviews/${encodeURIComponent(reviewNo)}`);
|
||||
}
|
||||
@@ -1,9 +1,8 @@
|
||||
/**
|
||||
* features/admin/components/AdminNav.vue
|
||||
* 管理后台左侧导航,在模块原始顺序中渲染货代手风琴、企微和报表二级菜单。
|
||||
* 管理后台左侧导航,使用子路由跳转。
|
||||
* 依赖:admin-nav.store、modules 常量、vue-router。
|
||||
* 逻辑:报表/企微子菜单默认折叠;当前路由落在对应模块时自动展开;
|
||||
* lg 起固定宽度侧栏,小屏横向滚动导航以免挤占主内容。
|
||||
* 逻辑:报表/企微子菜单默认折叠;当前路由落在对应模块时自动展开以便看到激活项。
|
||||
*/
|
||||
<script setup lang="ts">
|
||||
import { computed, watch } from 'vue';
|
||||
@@ -11,14 +10,13 @@ import { useI18n } from 'vue-i18n';
|
||||
import { useRoute, useRouter } from 'vue-router';
|
||||
import {
|
||||
LayoutDashboard, UserPlus, UserCog, Building, Bot, FileText,
|
||||
Settings2, Megaphone, MessageCircleQuestion, Link2, Users, ShieldCheck, BarChart2, AppWindow, Warehouse,
|
||||
ChevronDown, ChevronRight
|
||||
Settings2, Megaphone, MessageCircleQuestion, Link2, Users, ShieldCheck, BarChart2, AppWindow,
|
||||
ScrollText, ExternalLink,
|
||||
} from 'lucide-vue-next';
|
||||
import type { Component } from 'vue';
|
||||
import { config } from '@/config';
|
||||
import { ADMIN_MODULE_METAS, ADMIN_REPORT_TABLES, SHIPPING_CONFIG_SUB_MODULE_METAS } from '../constants/modules';
|
||||
import { ADMIN_MODULE_METAS, ADMIN_REPORT_TABLES } from '../constants/modules';
|
||||
import { useAdminNavStore } from '../stores/admin-nav.store';
|
||||
import type { ShippingManagementGroupKey } from '../stores/admin-nav.store';
|
||||
import type { AdminModuleId } from '../types/admin.types';
|
||||
|
||||
const { t } = useI18n();
|
||||
@@ -37,9 +35,10 @@ const iconMap: Record<AdminModuleId, Component> = {
|
||||
announcements: Megaphone,
|
||||
questions: MessageCircleQuestion,
|
||||
wecom: Link2,
|
||||
linked_services: ExternalLink,
|
||||
permissions: Users,
|
||||
platform_apps: AppWindow,
|
||||
shipping_inventory: Warehouse,
|
||||
procurement_contract: ScrollText,
|
||||
requests: ShieldCheck,
|
||||
reports: BarChart2,
|
||||
};
|
||||
@@ -48,13 +47,15 @@ const visibleModules = computed(() =>
|
||||
ADMIN_MODULE_METAS.filter((item) => config.admin.modules[item.configKey] !== false),
|
||||
);
|
||||
|
||||
const standardModules = computed(() =>
|
||||
visibleModules.value.filter((item) => item.id !== 'wecom'),
|
||||
);
|
||||
|
||||
const isModuleActive = (moduleId: AdminModuleId): boolean =>
|
||||
route.meta.adminModule === moduleId;
|
||||
|
||||
const isReportsActive = computed(() => route.meta.adminModule === 'reports');
|
||||
const isWecomActive = computed(() => route.meta.adminModule === 'wecom');
|
||||
const isShippingManagementActive = computed(() => route.meta.adminModule === 'shipping_inventory');
|
||||
const shippingNavGroups = [...new Set(SHIPPING_CONFIG_SUB_MODULE_METAS.map((item) => item.groupKey))];
|
||||
|
||||
const wecomSubRoutes = [
|
||||
{ name: 'AdminWecomSettings', labelKey: 'admin.wecom.nav.settings' },
|
||||
@@ -66,26 +67,6 @@ const navigateWecom = (routeName: string): void => {
|
||||
router.push({ name: routeName });
|
||||
};
|
||||
|
||||
/** 判断货代二级菜单当前项;综合工作台按 section 深链高亮,库存字段目录归入库存解析。 */
|
||||
const isShippingNavActive = (item: typeof SHIPPING_CONFIG_SUB_MODULE_METAS[number]): boolean => {
|
||||
if (route.name !== item.routeName) return false;
|
||||
if (!item.query) return true;
|
||||
const section = typeof route.query.section === 'string' ? route.query.section : 'parsing';
|
||||
if (item.query.section === 'parsing') return section === 'parsing' || section === 'inventoryFields';
|
||||
return section === item.query.section;
|
||||
};
|
||||
|
||||
/** 打开货代独立页面或综合工作台区段,保留可收藏的 section 深链。 */
|
||||
const navigateShipping = (item: typeof SHIPPING_CONFIG_SUB_MODULE_METAS[number]): void => {
|
||||
router.push({ name: item.routeName, query: item.query });
|
||||
};
|
||||
|
||||
/** 返回当前货代页面所在分组,用于路由进入时只展开对应手风琴。 */
|
||||
const currentShippingGroup = (): ShippingManagementGroupKey | null => {
|
||||
const currentItem = SHIPPING_CONFIG_SUB_MODULE_METAS.find(isShippingNavActive);
|
||||
return currentItem?.groupKey ?? null;
|
||||
};
|
||||
|
||||
const getReportTableLabel = (table: string): string => {
|
||||
const i18nKey = `admin.report.tables.${table}`;
|
||||
const translated = t(i18nKey);
|
||||
@@ -102,7 +83,7 @@ const navigateReport = (table: string): void => {
|
||||
};
|
||||
|
||||
/**
|
||||
* 进入报表、企微或货代模块时自动展开子菜单,避免当前页在折叠状态下不可见。
|
||||
* 进入报表/企微模块时自动展开子菜单,避免当前页在折叠状态下不可见。
|
||||
*/
|
||||
watch(
|
||||
isReportsActive,
|
||||
@@ -119,132 +100,69 @@ watch(
|
||||
},
|
||||
{ immediate: true },
|
||||
);
|
||||
|
||||
watch(
|
||||
isShippingManagementActive,
|
||||
(active) => {
|
||||
if (!active) return;
|
||||
navStore.shippingManagementExpanded = true;
|
||||
navStore.shippingManagementGroup = currentShippingGroup();
|
||||
},
|
||||
{ immediate: true },
|
||||
);
|
||||
|
||||
watch(
|
||||
() => [route.name, route.query.section],
|
||||
() => {
|
||||
if (isShippingManagementActive.value) navStore.shippingManagementGroup = currentShippingGroup();
|
||||
},
|
||||
);
|
||||
|
||||
</script>
|
||||
|
||||
<template>
|
||||
<aside
|
||||
class="surface-panel rounded-2xl shadow-sm h-fit w-full lg:sticky lg:top-24 overflow-hidden shrink-0 z-10 transition-all duration-300"
|
||||
:class="navStore.sidebarCollapsed ? 'max-h-14 lg:max-h-none lg:w-20' : 'lg:w-64'"
|
||||
class="surface-panel rounded-2xl shadow-sm h-fit md:sticky md:top-24 overflow-hidden shrink-0 z-10 transition-all duration-300"
|
||||
:class="navStore.sidebarCollapsed ? 'w-0 md:w-20' : 'w-full md:w-64'"
|
||||
>
|
||||
<nav class="flex lg:flex-col p-3 gap-1 overflow-x-auto lg:overflow-visible no-scrollbar">
|
||||
<template v-for="item in visibleModules" :key="item.id">
|
||||
<div v-if="item.id === 'shipping_inventory'" class="flex flex-col flex-shrink-0">
|
||||
<button
|
||||
type="button"
|
||||
class="admin-nav-btn group justify-between"
|
||||
:class="{ 'admin-nav-btn--active': isShippingManagementActive }"
|
||||
:title="navStore.sidebarCollapsed ? t(item.labelKey) : ''"
|
||||
@click="navStore.shippingManagementExpanded = !navStore.shippingManagementExpanded"
|
||||
>
|
||||
<div class="flex items-center gap-3">
|
||||
<Warehouse class="w-5 h-5 flex-shrink-0" :class="isShippingManagementActive ? 'text-brand-600' : 'text-muted'" />
|
||||
<span :class="navStore.sidebarCollapsed ? 'lg:hidden' : ''">{{ t(item.labelKey) }}</span>
|
||||
</div>
|
||||
</button>
|
||||
<div
|
||||
v-if="navStore.shippingManagementExpanded && !navStore.sidebarCollapsed"
|
||||
class="mt-1 ml-6 space-y-1 border-l-2 border-subtle pl-3 pb-1"
|
||||
>
|
||||
<section v-for="groupKey in shippingNavGroups" :key="groupKey" class="shipping-nav-group">
|
||||
<button
|
||||
type="button"
|
||||
class="flex w-full items-center justify-between rounded-lg px-3 py-2 text-left text-xs font-semibold text-secondary transition-colors hover:bg-surface-soft"
|
||||
:aria-expanded="navStore.shippingManagementGroup === groupKey"
|
||||
@click="navStore.toggleShippingManagementGroup(groupKey)"
|
||||
>
|
||||
<span>{{ t(groupKey) }}</span>
|
||||
<ChevronDown v-if="navStore.shippingManagementGroup === groupKey" class="h-3.5 w-3.5 text-muted" />
|
||||
<ChevronRight v-else class="h-3.5 w-3.5 text-muted" />
|
||||
</button>
|
||||
<div v-if="navStore.shippingManagementGroup === groupKey" class="ml-2 border-l border-subtle pl-2 py-1 space-y-0.5">
|
||||
<button
|
||||
v-for="sub in SHIPPING_CONFIG_SUB_MODULE_METAS.filter((entry) => entry.groupKey === groupKey)"
|
||||
:key="sub.id"
|
||||
type="button"
|
||||
class="admin-nav-subitem w-[8em] whitespace-nowrap py-1.5 pl-3"
|
||||
:class="{ 'admin-nav-subitem--active': isShippingNavActive(sub) }"
|
||||
@click="navigateShipping(sub)"
|
||||
>
|
||||
{{ t(sub.labelKey) }}
|
||||
</button>
|
||||
</div>
|
||||
</section>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div v-else-if="item.id === 'wecom'" class="flex flex-col flex-shrink-0">
|
||||
<button
|
||||
type="button"
|
||||
class="admin-nav-btn group justify-between"
|
||||
:class="{ 'admin-nav-btn--active': isWecomActive }"
|
||||
@click="navStore.wecomExpanded = !navStore.wecomExpanded"
|
||||
>
|
||||
<div class="flex items-center gap-3">
|
||||
<Link2 class="w-5 h-5 flex-shrink-0" :class="isWecomActive ? 'text-brand-600' : 'text-muted'" />
|
||||
<span :class="navStore.sidebarCollapsed ? 'lg:hidden' : ''">{{ t(item.labelKey) }}</span>
|
||||
</div>
|
||||
</button>
|
||||
<div
|
||||
v-if="navStore.wecomExpanded && !navStore.sidebarCollapsed"
|
||||
class="pl-4 space-y-1 mt-1 border-l-2 border-subtle ml-6"
|
||||
>
|
||||
<button
|
||||
v-for="sub in wecomSubRoutes"
|
||||
:key="sub.name"
|
||||
type="button"
|
||||
class="admin-nav-subitem"
|
||||
:class="{ 'admin-nav-subitem--active': route.name === sub.name }"
|
||||
@click="navigateWecom(sub.name)"
|
||||
>
|
||||
{{ t(sub.labelKey) }}
|
||||
</button>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<button
|
||||
v-else
|
||||
type="button"
|
||||
class="admin-nav-btn group"
|
||||
:class="{ 'admin-nav-btn--active': isModuleActive(item.id) }"
|
||||
:title="navStore.sidebarCollapsed ? t(item.labelKey) : ''"
|
||||
@click="navigateModule(item.routeName)"
|
||||
<nav class="flex md:flex-col p-3 gap-1 overflow-x-auto md:overflow-visible no-scrollbar">
|
||||
<button
|
||||
v-for="item in standardModules"
|
||||
:key="item.id"
|
||||
type="button"
|
||||
class="admin-nav-btn group"
|
||||
:class="{ 'admin-nav-btn--active': isModuleActive(item.id) }"
|
||||
:title="navStore.sidebarCollapsed ? t(item.labelKey) : ''"
|
||||
@click="navigateModule(item.routeName)"
|
||||
>
|
||||
<component
|
||||
:is="iconMap[item.id]"
|
||||
class="w-5 h-5 transition-transform group-hover:scale-110 flex-shrink-0"
|
||||
:class="isModuleActive(item.id) ? 'text-brand-600' : 'text-muted group-hover:text-secondary'"
|
||||
/>
|
||||
<span :class="navStore.sidebarCollapsed ? 'md:hidden' : ''">{{ t(item.labelKey) }}</span>
|
||||
<span
|
||||
v-if="navStore.badgeForModule(item.id) && !navStore.sidebarCollapsed"
|
||||
class="ml-auto bg-red-500 text-white text-[10px] font-bold px-2 py-0.5 rounded-full shadow-sm"
|
||||
>
|
||||
<component
|
||||
:is="iconMap[item.id]"
|
||||
class="w-5 h-5 transition-transform group-hover:scale-110 flex-shrink-0"
|
||||
:class="isModuleActive(item.id) ? 'text-brand-600' : 'text-muted group-hover:text-secondary'"
|
||||
/>
|
||||
<span :class="navStore.sidebarCollapsed ? 'lg:hidden' : ''">{{ t(item.labelKey) }}</span>
|
||||
<span
|
||||
v-if="navStore.badgeForModule(item.id) && !navStore.sidebarCollapsed"
|
||||
class="ml-auto bg-red-500 text-white text-[10px] font-bold px-2 py-0.5 rounded-full shadow-sm"
|
||||
>
|
||||
{{ navStore.badgeForModule(item.id) }}
|
||||
</span>
|
||||
<div
|
||||
v-if="isModuleActive(item.id)"
|
||||
class="absolute left-0 top-1/2 -translate-y-1/2 w-1 h-6 bg-brand-600 rounded-r-full"
|
||||
/>
|
||||
{{ navStore.badgeForModule(item.id) }}
|
||||
</span>
|
||||
<div
|
||||
v-if="isModuleActive(item.id)"
|
||||
class="absolute left-0 top-1/2 -translate-y-1/2 w-1 h-6 bg-brand-600 rounded-r-full"
|
||||
/>
|
||||
</button>
|
||||
|
||||
<div v-if="config.admin.modules.wecom !== false" class="flex flex-col flex-shrink-0">
|
||||
<button
|
||||
type="button"
|
||||
class="admin-nav-btn group justify-between"
|
||||
:class="{ 'admin-nav-btn--active': isWecomActive }"
|
||||
@click="navStore.wecomExpanded = !navStore.wecomExpanded"
|
||||
>
|
||||
<div class="flex items-center gap-3">
|
||||
<Link2 class="w-5 h-5 flex-shrink-0" :class="isWecomActive ? 'text-brand-600' : 'text-muted'" />
|
||||
<span :class="navStore.sidebarCollapsed ? 'md:hidden' : ''">{{ t('admin.nav.wecom') }}</span>
|
||||
</div>
|
||||
</button>
|
||||
</template>
|
||||
<div
|
||||
v-if="navStore.wecomExpanded && !navStore.sidebarCollapsed"
|
||||
class="pl-4 space-y-1 mt-1 border-l-2 border-subtle ml-6"
|
||||
>
|
||||
<button
|
||||
v-for="sub in wecomSubRoutes"
|
||||
:key="sub.name"
|
||||
type="button"
|
||||
class="admin-nav-subitem"
|
||||
:class="{ 'admin-nav-subitem--active': route.name === sub.name }"
|
||||
@click="navigateWecom(sub.name)"
|
||||
>
|
||||
{{ t(sub.labelKey) }}
|
||||
</button>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div v-if="config.admin.modules.reports !== false" class="flex flex-col flex-shrink-0">
|
||||
<button
|
||||
@@ -255,7 +173,7 @@ watch(
|
||||
>
|
||||
<div class="flex items-center gap-3">
|
||||
<BarChart2 class="w-5 h-5 flex-shrink-0" :class="isReportsActive ? 'text-brand-600' : 'text-muted'" />
|
||||
<span :class="navStore.sidebarCollapsed ? 'lg:hidden' : ''">{{ t('admin.nav.reports') }}</span>
|
||||
<span :class="navStore.sidebarCollapsed ? 'md:hidden' : ''">{{ t('admin.nav.reports') }}</span>
|
||||
</div>
|
||||
</button>
|
||||
<div
|
||||
|
||||
@@ -3,7 +3,7 @@
|
||||
* 管理后台模块元数据,AdminNav 与子路由共用。
|
||||
*/
|
||||
|
||||
import type { AdminModuleId, AdminReportTableId, ShippingConfigSubModuleId } from '../types/admin.types';
|
||||
import type { AdminModuleId, AdminReportTableId } from '../types/admin.types';
|
||||
|
||||
export interface AdminModuleMeta {
|
||||
id: AdminModuleId;
|
||||
@@ -13,36 +13,9 @@ export interface AdminModuleMeta {
|
||||
configKey: keyof typeof import('@/config').config.admin.modules;
|
||||
}
|
||||
|
||||
export interface ShippingConfigSubModuleMeta {
|
||||
id: ShippingConfigSubModuleId;
|
||||
routeName:
|
||||
| 'AdminShippingInventory'
|
||||
| 'AdminShippingFieldAssets'
|
||||
| 'AdminShippingOrderSchema'
|
||||
| 'AdminShippingIdentityRules'
|
||||
| 'AdminShippingOrderExtractionRuns'
|
||||
| 'AdminShippingAudit'
|
||||
| 'AdminShippingProcessGates'
|
||||
| 'AdminShippingLegacyStpJobs'
|
||||
| 'AdminShippingOrderDocumentProfiles';
|
||||
path:
|
||||
| 'shipping-notice'
|
||||
| 'shipping-field-assets'
|
||||
| 'shipping-order-schema'
|
||||
| 'shipping-identity-rules'
|
||||
| 'shipping-order-extraction-runs'
|
||||
| 'shipping-audit'
|
||||
| 'shipping-process-gates'
|
||||
| 'shipping-legacy-stp-jobs'
|
||||
| 'shipping-order-document-profiles';
|
||||
labelKey: string;
|
||||
groupKey: 'admin.nav.shippingOrderRecognition' | 'admin.nav.shippingInventoryManagement' | 'admin.nav.shippingRunAudit';
|
||||
query?: { section: 'parsing' | 'profiles' | 'sources' | 'mappings' | 'rules' | 'templates' | 'snapshots' | 'exports' };
|
||||
}
|
||||
|
||||
/** 已独立拆分的模块(全部 admin 模块均已拆分) */
|
||||
export const STANDALONE_ADMIN_MODULES = new Set<AdminModuleId>([
|
||||
'dashboard', 'agents', 'users', 'departments', 'approvals', 'announcements', 'questions', 'requests', 'permissions', 'schedules', 'knowledge_base', 'wecom', 'platform_apps', 'shipping_inventory', 'reports',
|
||||
'dashboard', 'agents', 'users', 'departments', 'approvals', 'announcements', 'questions', 'requests', 'permissions', 'schedules', 'knowledge_base', 'wecom', 'linked_services', 'platform_apps', 'procurement_contract', 'reports',
|
||||
]);
|
||||
|
||||
export const ADMIN_MODULE_METAS: AdminModuleMeta[] = [
|
||||
@@ -53,34 +26,16 @@ export const ADMIN_MODULE_METAS: AdminModuleMeta[] = [
|
||||
{ id: 'agents', routeName: 'AdminAgents', path: 'agents', labelKey: 'admin.nav.agents', configKey: 'agents' },
|
||||
{ id: 'knowledge_base', routeName: 'AdminKnowledgeBase', path: 'knowledge-base', labelKey: 'admin.nav.knowledgeBase', configKey: 'knowledge_base' },
|
||||
{ id: 'schedules', routeName: 'AdminSchedules', path: 'schedules', labelKey: 'admin.nav.schedules', configKey: 'schedules' },
|
||||
{ id: 'shipping_inventory', routeName: 'AdminShippingInventory', path: 'shipping-notice', labelKey: 'admin.nav.shippingConfig', configKey: 'shipping_inventory' },
|
||||
{ id: 'announcements', routeName: 'AdminAnnouncements', path: 'announcements', labelKey: 'admin.nav.announcements', configKey: 'announcements' },
|
||||
{ id: 'questions', routeName: 'AdminQuestions', path: 'questions', labelKey: 'admin.nav.questions', configKey: 'questions' },
|
||||
{ id: 'wecom', routeName: 'AdminWecom', path: 'wecom', labelKey: 'admin.nav.wecom', configKey: 'wecom' },
|
||||
{ id: 'linked_services', routeName: 'AdminLinkedServices', path: 'linked-services', labelKey: 'admin.nav.linkedServices', configKey: 'linked_services' },
|
||||
{ id: 'permissions', routeName: 'AdminPermissions', path: 'permissions', labelKey: 'admin.nav.permissions', configKey: 'permissions' },
|
||||
{ id: 'platform_apps', routeName: 'AdminPlatformApps', path: 'platform-apps', labelKey: 'admin.nav.platformApps', configKey: 'platform_apps' },
|
||||
{ id: 'procurement_contract', routeName: 'AdminProcurementContract', path: 'procurement-contract', labelKey: 'admin.nav.procurementContract', configKey: 'procurement_contract' },
|
||||
{ id: 'requests', routeName: 'AdminRequests', path: 'requests', labelKey: 'admin.nav.requests', configKey: 'requests' },
|
||||
];
|
||||
|
||||
/** 货代管理的业务导航唯一真相源;按基础定义、适配规则、运行任务的依赖顺序排列。 */
|
||||
export const SHIPPING_CONFIG_SUB_MODULE_METAS: ShippingConfigSubModuleMeta[] = [
|
||||
{ id: 'field_assets', routeName: 'AdminShippingFieldAssets', path: 'shipping-field-assets', labelKey: 'admin.nav.shippingFieldAssets', groupKey: 'admin.nav.shippingOrderRecognition' },
|
||||
{ id: 'order_schema', routeName: 'AdminShippingOrderSchema', path: 'shipping-order-schema', labelKey: 'admin.nav.shippingOrderSchema', groupKey: 'admin.nav.shippingOrderRecognition' },
|
||||
{ id: 'order_document_profiles', routeName: 'AdminShippingOrderDocumentProfiles', path: 'shipping-order-document-profiles', labelKey: 'admin.nav.shippingOrderDocumentProfiles', groupKey: 'admin.nav.shippingOrderRecognition' },
|
||||
{ id: 'identity_rules', routeName: 'AdminShippingIdentityRules', path: 'shipping-identity-rules', labelKey: 'admin.nav.shippingIdentityRules', groupKey: 'admin.nav.shippingOrderRecognition' },
|
||||
{ id: 'order_extraction_runs', routeName: 'AdminShippingOrderExtractionRuns', path: 'shipping-order-extraction-runs', labelKey: 'admin.nav.shippingOrderExtractionRuns', groupKey: 'admin.nav.shippingOrderRecognition' },
|
||||
{ id: 'inventory_fields', routeName: 'AdminShippingInventory', path: 'shipping-notice', labelKey: 'admin.shippingInventory.parsingProfiles', groupKey: 'admin.nav.shippingInventoryManagement', query: { section: 'parsing' } },
|
||||
{ id: 'connections', routeName: 'AdminShippingInventory', path: 'shipping-notice', labelKey: 'admin.shippingInventory.connections', groupKey: 'admin.nav.shippingInventoryManagement', query: { section: 'profiles' } },
|
||||
{ id: 'inventory_sites', routeName: 'AdminShippingInventory', path: 'shipping-notice', labelKey: 'admin.shippingInventory.sources', groupKey: 'admin.nav.shippingInventoryManagement', query: { section: 'sources' } },
|
||||
{ id: 'warehouse_mappings', routeName: 'AdminShippingInventory', path: 'shipping-notice', labelKey: 'admin.shippingInventory.externalMappings', groupKey: 'admin.nav.shippingInventoryManagement', query: { section: 'mappings' } },
|
||||
{ id: 'routing_rules', routeName: 'AdminShippingInventory', path: 'shipping-notice', labelKey: 'admin.shippingInventory.rules', groupKey: 'admin.nav.shippingInventoryManagement', query: { section: 'rules' } },
|
||||
{ id: 'shipping_templates', routeName: 'AdminShippingInventory', path: 'shipping-notice', labelKey: 'admin.shippingInventory.excelTemplates', groupKey: 'admin.nav.shippingInventoryManagement', query: { section: 'templates' } },
|
||||
{ id: 'shipping_audit', routeName: 'AdminShippingAudit', path: 'shipping-audit', labelKey: 'admin.nav.shippingAudit', groupKey: 'admin.nav.shippingRunAudit' },
|
||||
{ id: 'process_gates', routeName: 'AdminShippingProcessGates', path: 'shipping-process-gates', labelKey: 'admin.nav.shippingProcessGates', groupKey: 'admin.nav.shippingRunAudit' },
|
||||
{ id: 'inventory_snapshots', routeName: 'AdminShippingInventory', path: 'shipping-notice', labelKey: 'admin.shippingInventory.snapshots', groupKey: 'admin.nav.shippingRunAudit', query: { section: 'snapshots' } },
|
||||
{ id: 'export_records', routeName: 'AdminShippingInventory', path: 'shipping-notice', labelKey: 'admin.shippingInventory.exports', groupKey: 'admin.nav.shippingRunAudit', query: { section: 'exports' } },
|
||||
];
|
||||
|
||||
export const ADMIN_REPORT_TABLES: AdminReportTableId[] = [
|
||||
'usage_analysis',
|
||||
'chat_logs',
|
||||
|
||||
@@ -1,9 +1,9 @@
|
||||
/**
|
||||
* features/admin/modules/agents/components/AgentFormModal.vue
|
||||
*
|
||||
* 用途:应用管理新增/编辑弹窗,集中承载 Agent 基础信息、Dify/Iframe 配置和常见问题表单。
|
||||
* 用途:应用管理新增/编辑弹窗,集中承载 Agent 基础信息(含启用状态)、Dify/Iframe 配置和常见问题表单。
|
||||
* 依赖:agent.types AgentFormState、schedule.types ScheduleTask、AgentToolRunProgressConfig、vue-i18n。
|
||||
* 逻辑:父组件控制 visible/isEditing/isSaving 与保存;本组件直接编辑传入的 form,并通过事件通知关闭、保存、增删常见问题。
|
||||
* 逻辑:父组件控制 visible/isEditing/isSaving 与保存;本组件直接编辑传入的 form(含 is_active),并通过事件通知关闭、保存、增删常见问题。
|
||||
*/
|
||||
|
||||
<script setup lang="ts">
|
||||
@@ -15,8 +15,7 @@ import type { ScheduleTask } from '@/shared/types/schedule.types';
|
||||
import type { AgentTypeCatalogEntry, IntentRouteOption } from '../composables/useAgentsAdminRegistry';
|
||||
import type { AdminContentProfileOption } from '@/features/admin/api/admin.api';
|
||||
import {
|
||||
DEFAULT_TRAINING_EMPLOYEE_CHAT_QUESTIONS,
|
||||
DEFAULT_TRAINING_HR_CHAT_QUESTIONS,
|
||||
getDefaultTrainingChatQuestions,
|
||||
} from '@/features/chat/training/trainingChatQuestions';
|
||||
import {
|
||||
applyCatalogDefaultsToForm,
|
||||
@@ -188,10 +187,10 @@ const handleTrainingWorkspaceToggle = () => {
|
||||
if (props.form.training_workspace_enabled) {
|
||||
props.form.content_profile = 'training';
|
||||
if (!props.form.training_employee_chat_questions_text.trim()) {
|
||||
props.form.training_employee_chat_questions_text = DEFAULT_TRAINING_EMPLOYEE_CHAT_QUESTIONS.join('\n');
|
||||
props.form.training_employee_chat_questions_text = getDefaultTrainingChatQuestions('employee').join('\n');
|
||||
}
|
||||
if (!props.form.training_hr_chat_questions_text.trim()) {
|
||||
props.form.training_hr_chat_questions_text = DEFAULT_TRAINING_HR_CHAT_QUESTIONS.join('\n');
|
||||
props.form.training_hr_chat_questions_text = getDefaultTrainingChatQuestions('hr').join('\n');
|
||||
}
|
||||
} else if (props.form.content_profile === 'training') {
|
||||
props.form.content_profile = '';
|
||||
@@ -208,7 +207,6 @@ watch(
|
||||
},
|
||||
);
|
||||
|
||||
|
||||
watch(
|
||||
() => props.form.is_aggregate,
|
||||
(enabled) => {
|
||||
@@ -303,12 +301,13 @@ const handleTrainingQuestionTypeChange = (form: AgentFormState, index: number) =
|
||||
</option>
|
||||
</select>
|
||||
</div>
|
||||
|
||||
<template v-if="showDifyFields">
|
||||
<div class="space-y-2">
|
||||
<label class="text-xs font-bold text-muted uppercase tracking-wider">Dify应用类型</label>
|
||||
<select v-model="form.dify_app_type" class="w-full input-field text-sm">
|
||||
<option value="chatflow">Chatflow</option>
|
||||
<option value="workflow">Workflow</option>
|
||||
<div class="space-y-2">
|
||||
<label class="text-xs font-bold text-muted uppercase tracking-wider">{{ t('admin.agent.fields.difyAppType') }}</label>
|
||||
<select v-model="form.dify_app_type" class="w-full input-field text-sm">
|
||||
<option value="chatflow">{{ t('admin.agent.fields.difyAppTypes.chatflow') }}</option>
|
||||
<option value="workflow">{{ t('admin.agent.fields.difyAppTypes.workflow') }}</option>
|
||||
</select>
|
||||
</div>
|
||||
<div class="space-y-2">
|
||||
@@ -341,6 +340,23 @@ const handleTrainingQuestionTypeChange = (form: AgentFormState, index: number) =
|
||||
</div>
|
||||
</template>
|
||||
|
||||
<div class="col-span-1 md:col-span-2 space-y-2">
|
||||
<label class="text-xs font-bold text-muted uppercase tracking-wider">{{ t('admin.agent.fields.isActive') }}</label>
|
||||
<div class="flex flex-col gap-2 rounded-xl border border-default bg-surface-soft/40 px-4 py-3 sm:flex-row sm:items-center sm:justify-between">
|
||||
<p class="text-sm leading-6 text-secondary">
|
||||
{{ form.is_active ? t('admin.agent.fields.isActiveHintOn') : t('admin.agent.fields.isActiveHintOff') }}
|
||||
</p>
|
||||
<label class="inline-flex shrink-0 items-center gap-2 rounded-xl border border-default bg-white px-3 py-2 text-sm text-secondary">
|
||||
<input
|
||||
v-model="form.is_active"
|
||||
type="checkbox"
|
||||
class="accent-brand-600"
|
||||
/>
|
||||
<span>{{ t('admin.agent.fields.isActiveEnable') }}</span>
|
||||
</label>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="col-span-1 md:col-span-2 space-y-2">
|
||||
<label class="text-xs font-bold text-muted uppercase tracking-wider">{{ t('admin.agent.fields.description') }}</label>
|
||||
<input
|
||||
@@ -565,30 +581,30 @@ const handleTrainingQuestionTypeChange = (form: AgentFormState, index: number) =
|
||||
|
||||
<div class="col-span-1 md:col-span-2 space-y-3">
|
||||
<div class="flex flex-wrap items-center justify-between gap-3">
|
||||
<label class="text-xs font-bold text-muted uppercase tracking-wider">常见问题</label>
|
||||
<label class="text-xs font-bold text-muted uppercase tracking-wider">{{ t('admin.agent.suggestedQuestions.title') }}</label>
|
||||
<button
|
||||
type="button"
|
||||
class="inline-flex items-center gap-1 rounded-lg border border-default px-3 py-1.5 text-xs font-medium text-secondary transition-colors hover:bg-surface-soft"
|
||||
@click="emit('addSuggestedQuestion')"
|
||||
>
|
||||
<Plus class="h-4 w-4" />
|
||||
添加问题
|
||||
{{ t('admin.agent.suggestedQuestions.add') }}
|
||||
</button>
|
||||
</div>
|
||||
|
||||
<div class="flex flex-wrap items-center gap-3 text-sm">
|
||||
<label class="inline-flex items-center gap-2 text-secondary">
|
||||
<input v-model="form.suggested_questions_style" type="radio" value="plain" class="accent-brand-600" />
|
||||
<span>无样式</span>
|
||||
<span>{{ t('admin.agent.suggestedQuestions.stylePlain') }}</span>
|
||||
</label>
|
||||
<label class="inline-flex items-center gap-2 text-secondary">
|
||||
<input v-model="form.suggested_questions_style" type="radio" value="styled" class="accent-brand-600" />
|
||||
<span>有样式</span>
|
||||
<span>{{ t('admin.agent.suggestedQuestions.styleStyled') }}</span>
|
||||
</label>
|
||||
</div>
|
||||
|
||||
<div v-if="form.suggested_questions.length === 0" class="rounded-xl border border-dashed border-default px-4 py-5 text-sm text-muted">
|
||||
暂未配置常见问题,点击“添加问题”后会同步到对应 Agent 的 Chat 欢迎页。
|
||||
{{ t('admin.agent.suggestedQuestions.empty') }}
|
||||
</div>
|
||||
|
||||
<div v-else class="space-y-3">
|
||||
@@ -602,14 +618,16 @@ const handleTrainingQuestionTypeChange = (form: AgentFormState, index: number) =
|
||||
v-model="item.question"
|
||||
type="text"
|
||||
class="w-full input-field text-sm"
|
||||
placeholder="请输入常见问题,例如:查询我有多少假期?"
|
||||
:placeholder="t('admin.agent.suggestedQuestions.questionPlaceholder')"
|
||||
/>
|
||||
<input
|
||||
v-model="item.group"
|
||||
type="text"
|
||||
class="w-full input-field text-sm"
|
||||
:disabled="form.suggested_questions_style !== 'styled'"
|
||||
:placeholder="form.suggested_questions_style === 'styled' ? '可选:分组标题,例如:考勤与休假' : '无样式下无需分组'"
|
||||
:placeholder="form.suggested_questions_style === 'styled'
|
||||
? t('admin.agent.suggestedQuestions.groupPlaceholderStyled')
|
||||
: t('admin.agent.suggestedQuestions.groupPlaceholderPlain')"
|
||||
/>
|
||||
<button
|
||||
type="button"
|
||||
|
||||
@@ -500,13 +500,13 @@ export function useAgentsAdmin() {
|
||||
payload.dify_api_key = form.value.dify_api_key;
|
||||
}
|
||||
await updateAdminAgent(form.value.id, payload);
|
||||
msg.success('应用更新成功');
|
||||
msg.success(t('admin.agent.updateSuccess'));
|
||||
} else {
|
||||
await createAdminAgent({
|
||||
...registryPayload,
|
||||
dify_api_key: form.value.dify_api_key,
|
||||
});
|
||||
msg.success('应用创建成功');
|
||||
msg.success(t('admin.agent.createSuccess'));
|
||||
}
|
||||
|
||||
await loadAgents();
|
||||
|
||||
@@ -0,0 +1,135 @@
|
||||
/**
|
||||
* features/admin/modules/linked-services/LinkedServicesPage.vue
|
||||
* 关联服务管理独立页面:表格列表 + 新增/编辑弹窗。
|
||||
* 依赖:useLinkedServicesAdmin、LinkedServiceFormModal、DeleteConfirmDialog。
|
||||
* 逻辑:路由 /admin/linked-services;启用项自动出现在 Chat/工作台侧栏底部。
|
||||
*/
|
||||
<script setup lang="ts">
|
||||
import { onMounted } from 'vue';
|
||||
import { useI18n } from 'vue-i18n';
|
||||
import { Edit, Plus, Trash2 } from 'lucide-vue-next';
|
||||
import DeleteConfirmDialog from '@/shared/components/DeleteConfirmDialog.vue';
|
||||
import LinkedServiceFormModal from './components/LinkedServiceFormModal.vue';
|
||||
import { useLinkedServicesAdmin } from './composables/useLinkedServicesAdmin';
|
||||
|
||||
const { t } = useI18n();
|
||||
|
||||
const {
|
||||
services,
|
||||
form,
|
||||
isLoading,
|
||||
isSaving,
|
||||
showFormModal,
|
||||
showDeleteConfirmDialog,
|
||||
deleteConfirmMessage,
|
||||
loadAll,
|
||||
openCreateModal,
|
||||
openEditModal,
|
||||
closeFormModal,
|
||||
saveService,
|
||||
toggleEnabled,
|
||||
deleteServiceItem,
|
||||
closeDeleteConfirm,
|
||||
confirmDelete,
|
||||
} = useLinkedServicesAdmin();
|
||||
|
||||
onMounted(() => {
|
||||
void loadAll();
|
||||
});
|
||||
</script>
|
||||
|
||||
<template>
|
||||
<section class="admin-table-section animate-fade-in-up">
|
||||
<div v-if="isLoading" class="flex items-center justify-center py-20">
|
||||
<div class="animate-spin rounded-full h-10 w-10 border-b-2 border-brand-600" />
|
||||
</div>
|
||||
|
||||
<template v-else>
|
||||
<div class="admin-table-header admin-table-header--stacked">
|
||||
<div>
|
||||
<h2 class="section-title">{{ t('admin.linkedServices.title') }}</h2>
|
||||
<p class="section-desc mt-1">{{ t('admin.linkedServices.subtitle') }}</p>
|
||||
</div>
|
||||
<button
|
||||
type="button"
|
||||
class="flex items-center gap-2 px-4 py-2 bg-brand-600 text-white rounded-xl hover:bg-brand-700 transition-all shadow-lg shadow-brand-200 active:scale-95 text-sm font-medium"
|
||||
@click="openCreateModal"
|
||||
>
|
||||
<Plus class="w-4 h-4" />
|
||||
<span>{{ t('admin.linkedServices.add') }}</span>
|
||||
</button>
|
||||
</div>
|
||||
|
||||
<div class="admin-table-wrap">
|
||||
<table class="admin-table">
|
||||
<thead>
|
||||
<tr>
|
||||
<th class="px-6 py-4 text-left text-xs">{{ t('admin.linkedServices.headers.name') }}</th>
|
||||
<th class="px-6 py-4 text-left text-xs">{{ t('admin.linkedServices.headers.url') }}</th>
|
||||
<th class="px-6 py-4 text-left text-xs w-28">{{ t('admin.linkedServices.headers.status') }}</th>
|
||||
<th class="px-6 py-4 text-left text-xs w-24">{{ t('admin.linkedServices.headers.sortOrder') }}</th>
|
||||
<th class="px-6 py-4 text-right text-xs w-40">{{ t('admin.linkedServices.headers.actions') }}</th>
|
||||
</tr>
|
||||
</thead>
|
||||
<tbody>
|
||||
<tr v-if="services.length === 0">
|
||||
<td colspan="5" class="px-6 admin-table-empty">{{ t('admin.linkedServices.empty') }}</td>
|
||||
</tr>
|
||||
<tr v-for="row in services" :key="row.id">
|
||||
<td class="px-6 py-4 text-sm font-medium text-primary">{{ row.name }}</td>
|
||||
<td class="px-6 py-4 text-sm text-secondary font-mono break-all">{{ row.url }}</td>
|
||||
<td class="px-6 py-4">
|
||||
<button
|
||||
type="button"
|
||||
class="inline-flex items-center rounded-full px-2.5 py-1 text-xs font-medium transition-colors"
|
||||
:class="row.is_enabled
|
||||
? 'bg-emerald-50 text-emerald-700 hover:bg-emerald-100'
|
||||
: 'bg-surface-soft text-muted hover:bg-surface'"
|
||||
@click="toggleEnabled(row)"
|
||||
>
|
||||
{{ row.is_enabled ? t('admin.linkedServices.status.enabled') : t('admin.linkedServices.status.disabled') }}
|
||||
</button>
|
||||
</td>
|
||||
<td class="px-6 py-4 text-sm text-secondary">{{ row.sort_order }}</td>
|
||||
<td class="px-6 py-4 text-right">
|
||||
<div class="inline-flex items-center gap-1">
|
||||
<button
|
||||
type="button"
|
||||
class="p-2 rounded-lg text-muted hover:bg-surface-soft hover:text-secondary"
|
||||
:title="t('admin.edit')"
|
||||
@click="openEditModal(row)"
|
||||
>
|
||||
<Edit class="w-4 h-4" />
|
||||
</button>
|
||||
<button
|
||||
type="button"
|
||||
class="p-2 rounded-lg text-muted hover:bg-red-50 hover:text-red-600"
|
||||
:title="t('admin.delete')"
|
||||
@click="deleteServiceItem(row.id)"
|
||||
>
|
||||
<Trash2 class="w-4 h-4" />
|
||||
</button>
|
||||
</div>
|
||||
</td>
|
||||
</tr>
|
||||
</tbody>
|
||||
</table>
|
||||
</div>
|
||||
</template>
|
||||
|
||||
<LinkedServiceFormModal
|
||||
:visible="showFormModal"
|
||||
:form="form"
|
||||
:is-saving="isSaving"
|
||||
@close="closeFormModal"
|
||||
@save="saveService"
|
||||
/>
|
||||
|
||||
<DeleteConfirmDialog
|
||||
v-model="showDeleteConfirmDialog"
|
||||
:message="deleteConfirmMessage"
|
||||
@cancel="closeDeleteConfirm"
|
||||
@confirm="confirmDelete"
|
||||
/>
|
||||
</section>
|
||||
</template>
|
||||
+70
@@ -0,0 +1,70 @@
|
||||
/**
|
||||
* features/admin/modules/linked-services/components/LinkedServiceFormModal.vue
|
||||
* 关联服务创建/编辑居中弹窗。
|
||||
* 依赖:LinkedServiceFormState、admin 通用 modal 样式。
|
||||
* 逻辑:LinkedServicesPage 打开本组件;提交时 emit save。
|
||||
*/
|
||||
<script setup lang="ts">
|
||||
import { useI18n } from 'vue-i18n';
|
||||
import type { LinkedServiceFormState } from '@/features/admin/types/linked-service.types';
|
||||
|
||||
defineProps<{
|
||||
visible: boolean;
|
||||
form: LinkedServiceFormState;
|
||||
isSaving: boolean;
|
||||
}>();
|
||||
|
||||
const emit = defineEmits<{
|
||||
close: [];
|
||||
save: [];
|
||||
}>();
|
||||
|
||||
const { t } = useI18n();
|
||||
</script>
|
||||
|
||||
<template>
|
||||
<div v-if="visible" class="admin-modal-overlay animate-fade-in items-center">
|
||||
<div class="admin-modal-panel max-w-lg max-h-[92vh] scale-100">
|
||||
<div class="px-5 sm:px-8 pt-5 sm:pt-7 pb-4 border-b border-subtle">
|
||||
<h3 class="section-title">
|
||||
{{ form.id ? t('admin.linkedServices.edit') : t('admin.linkedServices.add') }}
|
||||
</h3>
|
||||
<p class="section-desc mt-1">{{ t('admin.linkedServices.formHint') }}</p>
|
||||
</div>
|
||||
<div class="px-5 sm:px-8 py-5 space-y-5 overflow-y-auto">
|
||||
<div class="space-y-1.5">
|
||||
<label class="label-field">{{ t('admin.linkedServices.fields.name') }}</label>
|
||||
<input
|
||||
v-model="form.name"
|
||||
type="text"
|
||||
class="input-field text-sm"
|
||||
:placeholder="t('admin.linkedServices.placeholders.name')"
|
||||
/>
|
||||
</div>
|
||||
<div class="space-y-1.5">
|
||||
<label class="label-field">{{ t('admin.linkedServices.fields.url') }}</label>
|
||||
<input
|
||||
v-model="form.url"
|
||||
type="url"
|
||||
class="input-field text-sm font-mono"
|
||||
:placeholder="t('admin.linkedServices.placeholders.url')"
|
||||
/>
|
||||
</div>
|
||||
<div class="space-y-1.5">
|
||||
<label class="label-field">{{ t('admin.linkedServices.fields.sortOrder') }}</label>
|
||||
<input v-model.number="form.sort_order" type="number" class="input-field text-sm" min="0" />
|
||||
</div>
|
||||
<label class="inline-flex items-center gap-2 text-sm text-secondary cursor-pointer">
|
||||
<input v-model="form.is_enabled" type="checkbox" class="w-4 h-4 rounded text-brand-600 border-default" />
|
||||
{{ t('admin.linkedServices.fields.enabled') }}
|
||||
</label>
|
||||
</div>
|
||||
<div class="admin-modal-footer">
|
||||
<button type="button" class="btn-ghost" @click="emit('close')">{{ t('admin.cancel') }}</button>
|
||||
<button type="button" class="btn-primary disabled:opacity-70" :disabled="isSaving" @click="emit('save')">
|
||||
{{ isSaving ? t('admin.save') + '...' : form.id ? t('admin.update') : t('admin.add') }}
|
||||
</button>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</template>
|
||||
+198
@@ -0,0 +1,198 @@
|
||||
/**
|
||||
* features/admin/modules/linked-services/composables/useLinkedServicesAdmin.ts
|
||||
* 关联服务管理:列表、新增/编辑弹窗、启用开关、删除。
|
||||
* 依赖:admin.api、linked-service.types、linked-nav.store、useMessage。
|
||||
* 逻辑:LinkedServicesPage 调用本 composable;保存/删除后刷新侧栏入口缓存。
|
||||
*/
|
||||
import { ref } from 'vue';
|
||||
import { useI18n } from 'vue-i18n';
|
||||
import {
|
||||
createLinkedService,
|
||||
deleteLinkedService,
|
||||
listLinkedServices,
|
||||
updateLinkedService,
|
||||
} from '@/features/admin/api/admin.api';
|
||||
import { useLinkedNavStore } from '@/features/sso/stores/linked-nav.store';
|
||||
import { useMessage } from '@/shared/composables/useMessage';
|
||||
import {
|
||||
createEmptyLinkedServiceForm,
|
||||
linkedServiceRowToForm,
|
||||
type AdminLinkedServiceRow,
|
||||
type LinkedServiceFormState,
|
||||
} from '@/features/admin/types/linked-service.types';
|
||||
|
||||
export function useLinkedServicesAdmin() {
|
||||
const { t } = useI18n();
|
||||
const msg = useMessage();
|
||||
const linkedNav = useLinkedNavStore();
|
||||
|
||||
const services = ref<AdminLinkedServiceRow[]>([]);
|
||||
const form = ref<LinkedServiceFormState>(createEmptyLinkedServiceForm());
|
||||
const isLoading = ref(true);
|
||||
const isSaving = ref(false);
|
||||
const showFormModal = ref(false);
|
||||
|
||||
const showDeleteConfirmDialog = ref(false);
|
||||
const deleteConfirmMessage = ref('');
|
||||
let deleteConfirmAction: (() => Promise<void> | void) | null = null;
|
||||
|
||||
/**
|
||||
* 拉取关联服务列表。
|
||||
* @returns Promise<void>
|
||||
*/
|
||||
const loadServices = async (): Promise<void> => {
|
||||
try {
|
||||
services.value = await listLinkedServices();
|
||||
} catch (e) {
|
||||
console.error('Failed to load linked services', e);
|
||||
services.value = [];
|
||||
msg.error((e as Error).message || t('admin.msg.requestFailed'));
|
||||
}
|
||||
};
|
||||
|
||||
/**
|
||||
* 页面初始化:加载列表并结束 loading。
|
||||
* @returns Promise<void>
|
||||
*/
|
||||
const loadAll = async (): Promise<void> => {
|
||||
isLoading.value = true;
|
||||
await loadServices();
|
||||
isLoading.value = false;
|
||||
};
|
||||
|
||||
/** 打开删除确认对话框。 */
|
||||
const openDeleteConfirm = (message: string, action: () => Promise<void> | void): void => {
|
||||
deleteConfirmMessage.value = message;
|
||||
deleteConfirmAction = action;
|
||||
showDeleteConfirmDialog.value = true;
|
||||
};
|
||||
|
||||
/** 关闭删除确认对话框。 */
|
||||
const closeDeleteConfirm = (): void => {
|
||||
showDeleteConfirmDialog.value = false;
|
||||
deleteConfirmAction = null;
|
||||
};
|
||||
|
||||
/** 执行删除确认动作。 */
|
||||
const confirmDelete = async (): Promise<void> => {
|
||||
if (!deleteConfirmAction) return;
|
||||
try {
|
||||
await deleteConfirmAction();
|
||||
} finally {
|
||||
closeDeleteConfirm();
|
||||
}
|
||||
};
|
||||
|
||||
/** 打开「新增关联服务」弹窗。 */
|
||||
const openCreateModal = (): void => {
|
||||
form.value = createEmptyLinkedServiceForm();
|
||||
form.value.sort_order = services.value.length;
|
||||
showFormModal.value = true;
|
||||
};
|
||||
|
||||
/**
|
||||
* 打开「编辑关联服务」弹窗。
|
||||
* @param row - 待编辑行
|
||||
*/
|
||||
const openEditModal = (row: AdminLinkedServiceRow): void => {
|
||||
form.value = linkedServiceRowToForm(row);
|
||||
showFormModal.value = true;
|
||||
};
|
||||
|
||||
/** 关闭表单弹窗。 */
|
||||
const closeFormModal = (): void => {
|
||||
showFormModal.value = false;
|
||||
form.value = createEmptyLinkedServiceForm();
|
||||
};
|
||||
|
||||
/**
|
||||
* 保存关联服务:有 id 则更新,否则新建。
|
||||
* 核心逻辑:校验名称与 URL → 调 API → 刷新列表。
|
||||
*/
|
||||
const saveService = async (): Promise<void> => {
|
||||
if (!form.value.name.trim() || !form.value.url.trim()) {
|
||||
msg.warning(t('admin.linkedServices.msg.fillAll'));
|
||||
return;
|
||||
}
|
||||
isSaving.value = true;
|
||||
try {
|
||||
const payload = {
|
||||
name: form.value.name.trim(),
|
||||
url: form.value.url.trim(),
|
||||
is_enabled: form.value.is_enabled,
|
||||
sort_order: Number(form.value.sort_order || 0),
|
||||
};
|
||||
if (form.value.id) {
|
||||
await updateLinkedService(form.value.id, payload);
|
||||
} else {
|
||||
await createLinkedService(payload);
|
||||
}
|
||||
closeFormModal();
|
||||
await loadServices();
|
||||
void linkedNav.refresh();
|
||||
msg.success(t('admin.linkedServices.msg.saved'));
|
||||
} catch (e) {
|
||||
console.error(e);
|
||||
msg.error((e as Error).message || t('admin.msg.requestFailed'));
|
||||
} finally {
|
||||
isSaving.value = false;
|
||||
}
|
||||
};
|
||||
|
||||
/**
|
||||
* 切换启用状态并立即保存。
|
||||
* @param row - 目标行
|
||||
*/
|
||||
const toggleEnabled = async (row: AdminLinkedServiceRow): Promise<void> => {
|
||||
try {
|
||||
await updateLinkedService(row.id, {
|
||||
name: row.name,
|
||||
url: row.url,
|
||||
is_enabled: !row.is_enabled,
|
||||
sort_order: row.sort_order,
|
||||
});
|
||||
await loadServices();
|
||||
void linkedNav.refresh();
|
||||
} catch (e) {
|
||||
console.error(e);
|
||||
msg.error((e as Error).message || t('admin.msg.requestFailed'));
|
||||
}
|
||||
};
|
||||
|
||||
/**
|
||||
* 删除指定关联服务。
|
||||
* @param id - 主键
|
||||
*/
|
||||
const deleteServiceItem = (id: number): void => {
|
||||
openDeleteConfirm(t('admin.linkedServices.confirmDelete'), async () => {
|
||||
try {
|
||||
await deleteLinkedService(id);
|
||||
await loadServices();
|
||||
void linkedNav.refresh();
|
||||
msg.success(t('admin.linkedServices.msg.deleted'));
|
||||
} catch (e) {
|
||||
console.error(e);
|
||||
msg.error((e as Error).message || t('admin.msg.requestFailed'));
|
||||
}
|
||||
});
|
||||
};
|
||||
|
||||
return {
|
||||
services,
|
||||
form,
|
||||
isLoading,
|
||||
isSaving,
|
||||
showFormModal,
|
||||
showDeleteConfirmDialog,
|
||||
deleteConfirmMessage,
|
||||
loadAll,
|
||||
openCreateModal,
|
||||
openEditModal,
|
||||
closeFormModal,
|
||||
saveService,
|
||||
toggleEnabled,
|
||||
deleteServiceItem,
|
||||
closeDeleteConfirm,
|
||||
confirmDelete,
|
||||
};
|
||||
}
|
||||
@@ -1,9 +1,14 @@
|
||||
/**
|
||||
* features/admin/modules/platform-apps/PlatformAppsPage.vue
|
||||
* 用途:平台应用说明(新手指南)管理——按 Agent 维护指南资料上传、启停与排序。
|
||||
* 依赖:admin.api 指南 CRUD/上传、vue-i18n、lucide 图标。
|
||||
* 逻辑:Admin 路由挂载;选择应用后拉取指南列表,弹窗内上传并保存元数据。
|
||||
*/
|
||||
<script setup lang="ts">
|
||||
import { ref, onMounted, computed } from 'vue';
|
||||
import { useI18n } from 'vue-i18n';
|
||||
import { Plus, Trash2, Edit2, Play, FileText, Image as ImageIcon } from 'lucide-vue-next';
|
||||
import { listAdminAgents, listAdminAgentGuides, createAdminAgentGuide, updateAdminAgentGuide, deleteAdminAgentGuide, uploadAdminAgentGuideFile } from '@/features/admin/api/admin.api';
|
||||
import DeleteConfirmDialog from '@/shared/components/DeleteConfirmDialog.vue';
|
||||
|
||||
const { t } = useI18n();
|
||||
|
||||
@@ -29,9 +34,10 @@ const form = ref({
|
||||
|
||||
const isUploading = ref(false);
|
||||
const uploadError = ref('');
|
||||
const deleteDialogOpen = ref(false);
|
||||
const pendingDeleteGuideId = ref<number | null>(null);
|
||||
|
||||
/**
|
||||
* 拉取 Agent 列表并默认选中第一项,再加载其指南。
|
||||
*/
|
||||
const fetchAgents = async () => {
|
||||
try {
|
||||
agents.value = await listAdminAgents();
|
||||
@@ -44,6 +50,9 @@ const fetchAgents = async () => {
|
||||
}
|
||||
};
|
||||
|
||||
/**
|
||||
* 按当前选中 Agent 拉取指南列表。
|
||||
*/
|
||||
const fetchGuides = async () => {
|
||||
if (!selectedAgentId.value) return;
|
||||
isLoading.value = true;
|
||||
@@ -65,6 +74,9 @@ onMounted(() => {
|
||||
fetchAgents();
|
||||
});
|
||||
|
||||
/**
|
||||
* 打开新建指南弹窗并重置表单。
|
||||
*/
|
||||
const openCreateModal = () => {
|
||||
isEditing.value = false;
|
||||
editingId.value = null;
|
||||
@@ -82,6 +94,10 @@ const openCreateModal = () => {
|
||||
isModalOpen.value = true;
|
||||
};
|
||||
|
||||
/**
|
||||
* 打开编辑指南弹窗并回填行数据。
|
||||
* @param guide - 列表行指南对象
|
||||
*/
|
||||
const openEditModal = (guide: any) => {
|
||||
isEditing.value = true;
|
||||
editingId.value = guide.id;
|
||||
@@ -99,6 +115,10 @@ const openEditModal = (guide: any) => {
|
||||
isModalOpen.value = true;
|
||||
};
|
||||
|
||||
/**
|
||||
* 上传指南文件并回填 path/type/size;必要时校正 guide_usage 与文件类型一致性。
|
||||
* @param event - input file change 事件
|
||||
*/
|
||||
const handleFileUpload = async (event: Event) => {
|
||||
const file = (event.target as HTMLInputElement).files?.[0];
|
||||
if (!file) return;
|
||||
@@ -121,12 +141,15 @@ const handleFileUpload = async (event: Event) => {
|
||||
form.value.file_name = res.file_name;
|
||||
}
|
||||
} catch (err: any) {
|
||||
uploadError.value = err.message || '上传失败';
|
||||
uploadError.value = err.message || t('admin.platformApps.uploadFailed');
|
||||
} finally {
|
||||
isUploading.value = false;
|
||||
}
|
||||
};
|
||||
|
||||
/**
|
||||
* 提交新建或更新指南元数据。
|
||||
*/
|
||||
const submitForm = async () => {
|
||||
if (!selectedAgentId.value || !form.value.file_path || !form.value.file_name) return;
|
||||
|
||||
@@ -146,23 +169,24 @@ const submitForm = async () => {
|
||||
}
|
||||
};
|
||||
|
||||
const deleteGuide = (id: number) => {
|
||||
pendingDeleteGuideId.value = id;
|
||||
deleteDialogOpen.value = true;
|
||||
};
|
||||
const confirmDeleteGuide = async () => {
|
||||
const id = pendingDeleteGuideId.value;
|
||||
if (!id) return;
|
||||
/**
|
||||
* 确认后删除指南。
|
||||
* @param id - 指南主键
|
||||
*/
|
||||
const deleteGuide = async (id: number) => {
|
||||
if (!confirm(t('admin.platformApps.confirmDelete'))) return;
|
||||
try {
|
||||
await deleteAdminAgentGuide(id);
|
||||
await fetchGuides();
|
||||
} catch (error) {
|
||||
console.error('Failed to delete guide:', error);
|
||||
} finally {
|
||||
pendingDeleteGuideId.value = null;
|
||||
}
|
||||
};
|
||||
|
||||
/**
|
||||
* 切换指南启停状态。
|
||||
* @param guide - 列表行指南对象
|
||||
*/
|
||||
const toggleStatus = async (guide: any) => {
|
||||
try {
|
||||
await updateAdminAgentGuide(guide.id, { status: guide.status === 1 ? 0 : 1 });
|
||||
@@ -172,6 +196,11 @@ const toggleStatus = async (guide: any) => {
|
||||
}
|
||||
};
|
||||
|
||||
/**
|
||||
* 将字节数格式化为可读文件大小。
|
||||
* @param bytes - 文件字节数
|
||||
* @returns 如 `1.2 MB`
|
||||
*/
|
||||
const formatSize = (bytes: number) => {
|
||||
if (!bytes) return '0 B';
|
||||
const k = 1024;
|
||||
@@ -180,6 +209,10 @@ const formatSize = (bytes: number) => {
|
||||
return parseFloat((bytes / Math.pow(k, i)).toFixed(2)) + ' ' + sizes[i];
|
||||
};
|
||||
|
||||
/**
|
||||
* 按文件类型返回列表图标组件。
|
||||
* @param type - 文件类型(video/pdf/其它)
|
||||
*/
|
||||
const getIcon = (type: string) => {
|
||||
if (type === 'video') return Play;
|
||||
if (type === 'pdf') return FileText;
|
||||
@@ -195,7 +228,7 @@ const getIcon = (type: string) => {
|
||||
{{ t('admin.nav.platformApps') }}
|
||||
</h2>
|
||||
<p class="text-sm text-muted mt-1">
|
||||
管理应用的新手指南资料(支持视频、PDF等)
|
||||
{{ t('admin.platformApps.subtitle') }}
|
||||
</p>
|
||||
</div>
|
||||
</div>
|
||||
@@ -203,7 +236,7 @@ const getIcon = (type: string) => {
|
||||
<div class="surface-panel rounded-2xl p-6 shadow-sm border border-subtle flex-1 flex flex-col gap-6">
|
||||
<div class="flex items-center justify-between">
|
||||
<div class="flex items-center gap-4">
|
||||
<label class="font-medium text-sm text-default">选择应用:</label>
|
||||
<label class="font-medium text-sm text-default">{{ t('admin.platformApps.selectAgent') }}</label>
|
||||
<select v-model="selectedAgentId" class="input-field w-64" @change="fetchGuides">
|
||||
<option v-for="agent in agents" :key="agent.id" :value="agent.id">
|
||||
{{ agent.name }}
|
||||
@@ -212,7 +245,7 @@ const getIcon = (type: string) => {
|
||||
</div>
|
||||
<button v-if="selectedAgentId" type="button" class="btn-primary" @click="openCreateModal">
|
||||
<Plus class="w-5 h-5 mr-1" />
|
||||
<span>添加指南</span>
|
||||
<span>{{ t('admin.platformApps.addGuide') }}</span>
|
||||
</button>
|
||||
</div>
|
||||
|
||||
@@ -221,25 +254,25 @@ const getIcon = (type: string) => {
|
||||
</div>
|
||||
|
||||
<div v-else-if="!selectedAgentId" class="flex flex-col items-center justify-center py-20 text-muted">
|
||||
请先选择一个应用
|
||||
{{ t('admin.platformApps.selectAgentFirst') }}
|
||||
</div>
|
||||
|
||||
<div v-else-if="guides.length === 0" class="flex flex-col items-center justify-center py-20 text-muted">
|
||||
该应用暂无新手指南资料
|
||||
{{ t('admin.platformApps.emptyGuides') }}
|
||||
</div>
|
||||
|
||||
<div v-else class="overflow-x-auto rounded-xl border border-subtle">
|
||||
<table class="w-full text-left text-sm whitespace-nowrap">
|
||||
<thead class="bg-muted text-muted uppercase text-xs font-semibold tracking-wider border-b border-subtle">
|
||||
<tr>
|
||||
<th class="px-6 py-4">类型</th>
|
||||
<th class="px-6 py-4">资料名称</th>
|
||||
<th class="px-6 py-4">{{ t('admin.platformApps.colType') }}</th>
|
||||
<th class="px-6 py-4">{{ t('admin.platformApps.colFileName') }}</th>
|
||||
<th class="px-6 py-4">{{ t('admin.platformApps.guideUsage') }}</th>
|
||||
<th class="px-6 py-4">Agent应用</th>
|
||||
<th class="px-6 py-4">文件大小</th>
|
||||
<th class="px-6 py-4">排序</th>
|
||||
<th class="px-6 py-4">状态</th>
|
||||
<th class="px-6 py-4 text-right">操作</th>
|
||||
<th class="px-6 py-4">{{ t('admin.platformApps.colAgent') }}</th>
|
||||
<th class="px-6 py-4">{{ t('admin.platformApps.colFileSize') }}</th>
|
||||
<th class="px-6 py-4">{{ t('admin.platformApps.colSort') }}</th>
|
||||
<th class="px-6 py-4">{{ t('admin.platformApps.colStatus') }}</th>
|
||||
<th class="px-6 py-4 text-right">{{ t('admin.platformApps.colActions') }}</th>
|
||||
</tr>
|
||||
</thead>
|
||||
<tbody class="divide-y divide-subtle">
|
||||
@@ -269,14 +302,14 @@ const getIcon = (type: string) => {
|
||||
:class="guide.status === 1 ? 'bg-green-100 text-green-700 hover:bg-green-200' : 'bg-gray-100 text-gray-700 hover:bg-gray-200'"
|
||||
@click="toggleStatus(guide)"
|
||||
>
|
||||
{{ guide.status === 1 ? '已启用' : '已禁用' }}
|
||||
{{ guide.status === 1 ? t('admin.platformApps.statusEnabled') : t('admin.platformApps.statusDisabled') }}
|
||||
</button>
|
||||
</td>
|
||||
<td class="px-6 py-4 text-right space-x-2">
|
||||
<button type="button" class="btn-icon-ds" @click="openEditModal(guide)" title="编辑">
|
||||
<button type="button" class="btn-icon-ds" @click="openEditModal(guide)" :title="t('common.edit')">
|
||||
<Edit2 class="w-4 h-4" />
|
||||
</button>
|
||||
<button type="button" class="btn-icon-ds text-red-500 hover:bg-red-50" @click="deleteGuide(guide.id)" title="删除">
|
||||
<button type="button" class="btn-icon-ds text-red-500 hover:bg-red-50" @click="deleteGuide(guide.id)" :title="t('common.delete')">
|
||||
<Trash2 class="w-4 h-4" />
|
||||
</button>
|
||||
</td>
|
||||
@@ -290,13 +323,13 @@ const getIcon = (type: string) => {
|
||||
<div v-if="isModalOpen" class="fixed inset-0 z-50 flex items-center justify-center p-4 bg-black/50 backdrop-blur-sm">
|
||||
<div class="bg-white dark:bg-gray-800 rounded-2xl shadow-xl w-full max-w-lg overflow-hidden flex flex-col max-h-[90vh]">
|
||||
<div class="px-6 py-4 border-b border-subtle flex justify-between items-center">
|
||||
<h3 class="text-lg font-bold text-default">{{ isEditing ? '编辑指南' : '添加指南' }}</h3>
|
||||
<h3 class="text-lg font-bold text-default">{{ isEditing ? t('admin.platformApps.editGuide') : t('admin.platformApps.addGuide') }}</h3>
|
||||
<button @click="isModalOpen = false" class="text-muted hover:text-default text-xl leading-none">×</button>
|
||||
</div>
|
||||
|
||||
<div class="p-6 overflow-y-auto space-y-4">
|
||||
<div v-if="!isEditing" class="space-y-2">
|
||||
<label class="text-sm font-medium text-default">上传文件</label>
|
||||
<label class="text-sm font-medium text-default">{{ t('admin.platformApps.uploadFile') }}</label>
|
||||
<input
|
||||
type="file"
|
||||
accept="video/mp4,video/webm,application/pdf,image/png,image/jpeg"
|
||||
@@ -304,20 +337,20 @@ const getIcon = (type: string) => {
|
||||
@change="handleFileUpload"
|
||||
/>
|
||||
<div v-if="isUploading" class="text-sm text-blue-600 mt-2 flex items-center gap-2">
|
||||
<div class="animate-spin rounded-full h-4 w-4 border-b-2 border-blue-600"></div> 上传中...
|
||||
<div class="animate-spin rounded-full h-4 w-4 border-b-2 border-blue-600"></div> {{ t('admin.platformApps.uploading') }}
|
||||
</div>
|
||||
<div v-if="uploadError" class="text-sm text-red-500 mt-2">{{ uploadError }}</div>
|
||||
<div v-if="form.file_path && !isUploading" class="text-sm text-green-600 mt-2">已上传文件就绪</div>
|
||||
<div v-if="form.file_path && !isUploading" class="text-sm text-green-600 mt-2">{{ t('admin.platformApps.uploadReady') }}</div>
|
||||
</div>
|
||||
|
||||
<div class="space-y-2">
|
||||
<label class="text-sm font-medium text-default">资料名称</label>
|
||||
<input v-model="form.file_name" type="text" class="input-field w-full" placeholder="如:人事助手使用手册" />
|
||||
<label class="text-sm font-medium text-default">{{ t('admin.platformApps.fileName') }}</label>
|
||||
<input v-model="form.file_name" type="text" class="input-field w-full" :placeholder="t('admin.platformApps.fileNamePlaceholder')" />
|
||||
</div>
|
||||
|
||||
<div class="space-y-2">
|
||||
<label class="text-sm font-medium text-default">备注说明</label>
|
||||
<textarea v-model="form.remark" class="input-field w-full h-20" placeholder="简要说明..."></textarea>
|
||||
<label class="text-sm font-medium text-default">{{ t('admin.platformApps.remark') }}</label>
|
||||
<textarea v-model="form.remark" class="input-field w-full h-20" :placeholder="t('admin.platformApps.remarkPlaceholder')"></textarea>
|
||||
</div>
|
||||
|
||||
<div class="grid grid-cols-2 gap-4">
|
||||
@@ -331,33 +364,32 @@ const getIcon = (type: string) => {
|
||||
<p class="text-xs text-muted">{{ t('admin.platformApps.guideUsageHint') }}</p>
|
||||
</div>
|
||||
<div class="space-y-2">
|
||||
<label class="text-sm font-medium text-default">排序权重</label>
|
||||
<label class="text-sm font-medium text-default">{{ t('admin.platformApps.sortOrder') }}</label>
|
||||
<input v-model.number="form.sort_order" type="number" class="input-field w-full" />
|
||||
<p class="text-xs text-muted">数值越小越靠前</p>
|
||||
<p class="text-xs text-muted">{{ t('admin.platformApps.sortOrderHint') }}</p>
|
||||
</div>
|
||||
<div class="space-y-2">
|
||||
<label class="text-sm font-medium text-default">状态</label>
|
||||
<label class="text-sm font-medium text-default">{{ t('admin.platformApps.status') }}</label>
|
||||
<select v-model="form.status" class="input-field w-full">
|
||||
<option :value="1">启用</option>
|
||||
<option :value="0">禁用</option>
|
||||
<option :value="1">{{ t('admin.platformApps.enable') }}</option>
|
||||
<option :value="0">{{ t('admin.platformApps.disable') }}</option>
|
||||
</select>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="px-6 py-4 border-t border-subtle bg-muted flex justify-end gap-3">
|
||||
<button type="button" class="btn-secondary" @click="isModalOpen = false">取消</button>
|
||||
<button type="button" class="btn-secondary" @click="isModalOpen = false">{{ t('admin.cancel') }}</button>
|
||||
<button
|
||||
type="button"
|
||||
class="btn-primary"
|
||||
@click="submitForm"
|
||||
:disabled="isUploading || !form.file_path || !form.file_name"
|
||||
>
|
||||
保存
|
||||
{{ t('admin.platformApps.save') }}
|
||||
</button>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<DeleteConfirmDialog v-model="deleteDialogOpen" title="删除指南" message="确定要删除该指南吗?删除后不可恢复。" confirm-tone="danger" @confirm="confirmDeleteGuide" />
|
||||
</div>
|
||||
</template>
|
||||
+1066
File diff suppressed because it is too large.
Load diff
+590
@@ -0,0 +1,590 @@
|
||||
/**
|
||||
* features/admin/modules/procurement-contract/components/ContractRiskRulesPanel.vue
|
||||
* 用途:采购合同风险红线规则列表与新增/编辑(含迁移种子默认规则)。
|
||||
* 依赖:procurement-contract.api、DeleteConfirmDialog、useMessage、vue-i18n。
|
||||
* 逻辑:由 ProcurementContractPage「风险规则」Tab 挂载;CRUD 走 Admin rules API。
|
||||
*/
|
||||
<script setup lang="ts">
|
||||
import { computed, onMounted, ref } from 'vue';
|
||||
import { useI18n } from 'vue-i18n';
|
||||
import { CircleHelp, Plus, ShieldAlert, ShieldCheck, SlidersHorizontal } from 'lucide-vue-next';
|
||||
import {
|
||||
createAdminContractRiskRule,
|
||||
deleteAdminContractRiskRule,
|
||||
listAdminContractRiskRules,
|
||||
updateAdminContractRiskRule,
|
||||
type ContractRiskRuleRow,
|
||||
} from '@/features/admin/api/procurement-contract.api';
|
||||
import DeleteConfirmDialog from '@/shared/components/DeleteConfirmDialog.vue';
|
||||
import { useMessage } from '@/shared/composables/useMessage';
|
||||
|
||||
const { t } = useI18n();
|
||||
const msg = useMessage();
|
||||
|
||||
const loading = ref(false);
|
||||
const saving = ref(false);
|
||||
const rules = ref<ContractRiskRuleRow[]>([]);
|
||||
const filterStatus = ref('');
|
||||
|
||||
const showForm = ref(false);
|
||||
const editing = ref<ContractRiskRuleRow | null>(null);
|
||||
const formTitle = ref('');
|
||||
const formCategory = ref('');
|
||||
const formKeywords = ref('');
|
||||
const formTriggerType = ref<'keyword_missing' | 'keyword_present'>('keyword_missing');
|
||||
const formRiskLevel = ref<'high' | 'medium' | 'low'>('medium');
|
||||
const formRiskHint = ref('');
|
||||
const formSuggestion = ref('');
|
||||
const formNegotiation = ref('');
|
||||
const formStatus = ref<'enabled' | 'disabled'>('enabled');
|
||||
const formSortOrder = ref(100);
|
||||
|
||||
const clauseCategories = [
|
||||
'payment',
|
||||
'delivery',
|
||||
'acceptance',
|
||||
'warranty',
|
||||
'liability',
|
||||
'jurisdiction',
|
||||
'dispute',
|
||||
'ip',
|
||||
'other',
|
||||
] as const;
|
||||
|
||||
const showDeleteConfirm = ref(false);
|
||||
const pendingDelete = ref<ContractRiskRuleRow | null>(null);
|
||||
const deleting = ref(false);
|
||||
|
||||
const isEditMode = computed(() => Boolean(editing.value));
|
||||
const formTitleText = computed(() =>
|
||||
isEditMode.value
|
||||
? t('admin.procurementContract.ruleEditTitle')
|
||||
: t('admin.procurementContract.ruleCreateTitle'),
|
||||
);
|
||||
|
||||
const isBuiltinRule = computed(() => editing.value?.rule_kind === 'builtin');
|
||||
|
||||
const keywordLogicHint = computed(() =>
|
||||
formTriggerType.value === 'keyword_present'
|
||||
? t('admin.procurementContract.keywordPresentLogicHint')
|
||||
: t('admin.procurementContract.keywordMissingLogicHint'),
|
||||
);
|
||||
const ruleStats = computed(() => ({
|
||||
total: rules.value.length,
|
||||
enabled: rules.value.filter((rule) => rule.status === 'enabled').length,
|
||||
highRisk: rules.value.filter((rule) => rule.risk_level === 'high').length,
|
||||
}));
|
||||
|
||||
/**
|
||||
* 生成风险规则统计卡片,帮助管理员先扫状态再进入列表维护。
|
||||
*/
|
||||
const ruleSummaryCards = computed(() => [
|
||||
{
|
||||
key: 'total',
|
||||
label: t('admin.procurementContract.ruleStatTotal'),
|
||||
value: ruleStats.value.total,
|
||||
icon: SlidersHorizontal,
|
||||
className: 'border-slate-200 bg-white text-slate-600',
|
||||
},
|
||||
{
|
||||
key: 'enabled',
|
||||
label: t('admin.procurementContract.ruleStatEnabled'),
|
||||
value: ruleStats.value.enabled,
|
||||
icon: ShieldCheck,
|
||||
className: 'border-emerald-100 bg-emerald-50/80 text-emerald-700',
|
||||
},
|
||||
{
|
||||
key: 'highRisk',
|
||||
label: t('admin.procurementContract.ruleStatHighRisk'),
|
||||
value: ruleStats.value.highRisk,
|
||||
icon: ShieldAlert,
|
||||
className: 'border-rose-100 bg-rose-50/80 text-rose-700',
|
||||
},
|
||||
]);
|
||||
|
||||
/**
|
||||
* 加载风险规则列表。
|
||||
* @param options.silent - 为 true 时不切换 loading,避免启停时整表闪烁
|
||||
*/
|
||||
async function loadRules(options?: { silent?: boolean }): Promise<void> {
|
||||
const silent = Boolean(options?.silent);
|
||||
if (!silent) loading.value = true;
|
||||
try {
|
||||
rules.value = await listAdminContractRiskRules({
|
||||
status: filterStatus.value || undefined,
|
||||
});
|
||||
} catch (e: unknown) {
|
||||
console.error(e);
|
||||
msg.error(e instanceof Error ? e.message : t('admin.procurementContract.loadFailed'));
|
||||
} finally {
|
||||
if (!silent) loading.value = false;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 响应筛选条件变更并刷新规则列表。
|
||||
*/
|
||||
async function onFilterStatusChange(): Promise<void> {
|
||||
await loadRules();
|
||||
}
|
||||
|
||||
onMounted(() => {
|
||||
void loadRules();
|
||||
});
|
||||
|
||||
/**
|
||||
* 重置规则表单为新建默认值。
|
||||
*/
|
||||
function resetForm(): void {
|
||||
editing.value = null;
|
||||
formTitle.value = '';
|
||||
formCategory.value = 'payment';
|
||||
formKeywords.value = '';
|
||||
formTriggerType.value = 'keyword_missing';
|
||||
formRiskLevel.value = 'medium';
|
||||
formRiskHint.value = '';
|
||||
formSuggestion.value = '';
|
||||
formNegotiation.value = '';
|
||||
formStatus.value = 'enabled';
|
||||
formSortOrder.value = 100;
|
||||
}
|
||||
|
||||
/**
|
||||
* 打开新建规则弹窗。
|
||||
*/
|
||||
function openCreate(): void {
|
||||
resetForm();
|
||||
showForm.value = true;
|
||||
}
|
||||
|
||||
/**
|
||||
* 打开编辑规则弹窗(种子规则也可改,code 只读)。
|
||||
*/
|
||||
function openEdit(row: ContractRiskRuleRow): void {
|
||||
editing.value = row;
|
||||
formTitle.value = row.title;
|
||||
formCategory.value = row.clause_category;
|
||||
formKeywords.value = (row.keywords || []).join(',');
|
||||
formTriggerType.value = row.trigger_type === 'keyword_present' ? 'keyword_present' : 'keyword_missing';
|
||||
formRiskLevel.value =
|
||||
row.risk_level === 'high' || row.risk_level === 'low' ? row.risk_level : 'medium';
|
||||
formRiskHint.value = row.risk_hint || '';
|
||||
formSuggestion.value = row.suggestion || '';
|
||||
formNegotiation.value = row.negotiation_text || '';
|
||||
formStatus.value = row.status === 'disabled' ? 'disabled' : 'enabled';
|
||||
formSortOrder.value = Number(row.sort_order) || 100;
|
||||
showForm.value = true;
|
||||
}
|
||||
|
||||
/**
|
||||
* 关闭规则表单。
|
||||
*/
|
||||
function closeForm(): void {
|
||||
showForm.value = false;
|
||||
editing.value = null;
|
||||
}
|
||||
|
||||
/**
|
||||
* 提交新建或更新规则。
|
||||
*/
|
||||
async function submitForm(): Promise<void> {
|
||||
if (!formTitle.value.trim() || !formCategory.value.trim()) {
|
||||
msg.error(t('admin.procurementContract.ruleRequiredFields'));
|
||||
return;
|
||||
}
|
||||
if (!formKeywords.value.trim()) {
|
||||
msg.error(t('admin.procurementContract.ruleKeywordsRequired'));
|
||||
return;
|
||||
}
|
||||
if (!formRiskHint.value.trim() || !formSuggestion.value.trim()) {
|
||||
msg.error(t('admin.procurementContract.ruleRequiredFields'));
|
||||
return;
|
||||
}
|
||||
|
||||
saving.value = true;
|
||||
try {
|
||||
// 与后端 _normalize_keywords 一致:逗号/中文逗号分隔
|
||||
const keywords = formKeywords.value
|
||||
.replace(/,/g, ',')
|
||||
.split(',')
|
||||
.map((s) => s.trim())
|
||||
.filter(Boolean);
|
||||
const payload = {
|
||||
title: formTitle.value.trim(),
|
||||
clause_category: formCategory.value.trim(),
|
||||
// 当前采购合同审核只支持通用采购类型,保留固定值以兼容后端规则加载。
|
||||
contract_type: 'general_procurement',
|
||||
keywords,
|
||||
trigger_type: formTriggerType.value,
|
||||
risk_level: formRiskLevel.value,
|
||||
risk_hint: formRiskHint.value.trim(),
|
||||
suggestion: formSuggestion.value.trim(),
|
||||
negotiation_text: formNegotiation.value.trim() || null,
|
||||
status: formStatus.value,
|
||||
sort_order: Number(formSortOrder.value) || 100,
|
||||
};
|
||||
if (isEditMode.value && editing.value) {
|
||||
await updateAdminContractRiskRule(editing.value.id, payload);
|
||||
msg.success(t('admin.procurementContract.ruleEditOk'));
|
||||
} else {
|
||||
await createAdminContractRiskRule(payload);
|
||||
msg.success(t('admin.procurementContract.ruleCreateOk'));
|
||||
}
|
||||
closeForm();
|
||||
await loadRules({ silent: true });
|
||||
} catch (e: unknown) {
|
||||
msg.error(e instanceof Error ? e.message : t('admin.procurementContract.actionFailed'));
|
||||
} finally {
|
||||
saving.value = false;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 切换规则启停(种子与自定义规则均可)。
|
||||
* 核心逻辑:先乐观更新本地行,成功后再静默对齐服务端;失败则回滚。
|
||||
*/
|
||||
async function toggleStatus(row: ContractRiskRuleRow): Promise<void> {
|
||||
const prev = row.status;
|
||||
const next = prev === 'enabled' ? 'disabled' : 'enabled';
|
||||
row.status = next;
|
||||
try {
|
||||
const updated = await updateAdminContractRiskRule(row.id, { status: next });
|
||||
Object.assign(row, updated);
|
||||
// 当前筛选为「启用/停用」时,状态变更后该项应离开列表
|
||||
if (filterStatus.value && filterStatus.value !== next) {
|
||||
rules.value = rules.value.filter((r) => r.id !== row.id);
|
||||
}
|
||||
} catch (e: unknown) {
|
||||
row.status = prev;
|
||||
msg.error(e instanceof Error ? e.message : t('admin.procurementContract.actionFailed'));
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 打开删除确认。
|
||||
*/
|
||||
function openDelete(row: ContractRiskRuleRow): void {
|
||||
pendingDelete.value = row;
|
||||
showDeleteConfirm.value = true;
|
||||
}
|
||||
|
||||
/**
|
||||
* 关闭删除确认。
|
||||
*/
|
||||
function closeDelete(): void {
|
||||
showDeleteConfirm.value = false;
|
||||
pendingDelete.value = null;
|
||||
}
|
||||
|
||||
/**
|
||||
* 确认删除规则。
|
||||
*/
|
||||
async function confirmDelete(): Promise<void> {
|
||||
const row = pendingDelete.value;
|
||||
if (!row) return;
|
||||
deleting.value = true;
|
||||
try {
|
||||
await deleteAdminContractRiskRule(row.id);
|
||||
closeDelete();
|
||||
rules.value = rules.value.filter((r) => r.id !== row.id);
|
||||
} catch (e: unknown) {
|
||||
msg.error(e instanceof Error ? e.message : t('admin.procurementContract.actionFailed'));
|
||||
} finally {
|
||||
deleting.value = false;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 风险等级文案。
|
||||
*/
|
||||
function riskLabel(level: string): string {
|
||||
if (level === 'high') return t('admin.procurementContract.riskHigh');
|
||||
if (level === 'medium') return t('admin.procurementContract.riskMedium');
|
||||
if (level === 'low') return t('admin.procurementContract.riskLow');
|
||||
return level;
|
||||
}
|
||||
|
||||
/**
|
||||
* 触发类型文案。
|
||||
*/
|
||||
function triggerLabel(type: string): string {
|
||||
if (type === 'keyword_present') return t('admin.procurementContract.triggerPresent');
|
||||
return t('admin.procurementContract.triggerMissing');
|
||||
}
|
||||
|
||||
/**
|
||||
* 状态文案。
|
||||
*/
|
||||
function statusLabel(status: string): string {
|
||||
if (status === 'enabled') return t('admin.procurementContract.enable');
|
||||
if (status === 'disabled') return t('admin.procurementContract.disable');
|
||||
return status;
|
||||
}
|
||||
|
||||
/**
|
||||
* 规则关键词展示文本。
|
||||
* @param row - 风险规则行;关键词为空时返回短横线占位,避免表格空洞。
|
||||
*/
|
||||
function keywordText(row: ContractRiskRuleRow): string {
|
||||
const keywords = row.keywords || [];
|
||||
return keywords.length ? keywords.join(',') : '-';
|
||||
}
|
||||
|
||||
/**
|
||||
* 将内部条款分类编码转换为与规则弹窗一致的可读名称。
|
||||
* 核心逻辑:规则仍保存稳定编码,列表仅负责展示本地化文案。
|
||||
* @param category - 后端返回的条款分类编码。
|
||||
* @returns 用户可读的分类名称;历史未知编码保持原样,避免丢失信息。
|
||||
*/
|
||||
function categoryLabel(category: string): string {
|
||||
const key = `admin.procurementContract.category_${category}`;
|
||||
const translated = t(key);
|
||||
return translated === key ? category : translated;
|
||||
}
|
||||
|
||||
defineExpose({ loadRules, openCreate });
|
||||
</script>
|
||||
|
||||
<template>
|
||||
<div class="space-y-5">
|
||||
<div class="grid gap-3 md:grid-cols-3">
|
||||
<div
|
||||
v-for="card in ruleSummaryCards"
|
||||
:key="card.key"
|
||||
class="rounded-xl border px-4 py-3 shadow-sm"
|
||||
:class="card.className"
|
||||
>
|
||||
<div class="flex items-center justify-between gap-3">
|
||||
<div>
|
||||
<div class="text-xs font-medium text-muted">{{ card.label }}</div>
|
||||
<div class="mt-1 text-2xl font-semibold text-primary">{{ card.value }}</div>
|
||||
</div>
|
||||
<span class="inline-flex h-9 w-9 items-center justify-center rounded-lg bg-white/80 shadow-sm">
|
||||
<component :is="card.icon" class="h-4 w-4" />
|
||||
</span>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="flex flex-col gap-3 rounded-xl border border-subtle bg-white px-4 py-3 shadow-sm sm:flex-row sm:items-center sm:justify-between">
|
||||
<div class="flex items-center gap-3">
|
||||
<label class="flex shrink-0 items-center gap-2 text-sm font-medium text-secondary">
|
||||
<span>{{ t('admin.procurementContract.colStatus') }}</span>
|
||||
<select
|
||||
v-model="filterStatus"
|
||||
class="input-field h-10 w-48 min-w-48 py-0 text-sm"
|
||||
@change="onFilterStatusChange"
|
||||
>
|
||||
<option value="">{{ t('admin.procurementContract.all') }}</option>
|
||||
<option value="enabled">{{ t('admin.procurementContract.enable') }}</option>
|
||||
<option value="disabled">{{ t('admin.procurementContract.disable') }}</option>
|
||||
</select>
|
||||
</label>
|
||||
</div>
|
||||
<button type="button" class="btn-primary inline-flex h-10 items-center gap-2 px-4 shadow-sm" @click="openCreate">
|
||||
<Plus class="h-4 w-4" />
|
||||
{{ t('admin.procurementContract.addRule') }}
|
||||
</button>
|
||||
</div>
|
||||
|
||||
<div class="overflow-hidden rounded-xl border border-subtle bg-white shadow-sm">
|
||||
<div class="overflow-auto">
|
||||
<table class="w-full min-w-[1030px] whitespace-nowrap text-sm">
|
||||
<thead class="bg-slate-50/80 text-xs font-semibold text-muted">
|
||||
<tr>
|
||||
<th class="px-5 py-3 text-left">{{ t('admin.procurementContract.colRuleTitle') }}</th>
|
||||
<th class="px-5 py-3 text-left">{{ t('admin.procurementContract.colCategory') }}</th>
|
||||
<th class="px-5 py-3 text-left">{{ t('admin.procurementContract.colKeywords') }}</th>
|
||||
<th class="px-5 py-3 text-left">{{ t('admin.procurementContract.colTrigger') }}</th>
|
||||
<th class="px-5 py-3 text-left">{{ t('admin.procurementContract.colRisk') }}</th>
|
||||
<th class="px-5 py-3 text-left">{{ t('admin.procurementContract.colStatus') }}</th>
|
||||
<th class="px-5 py-3 text-left">{{ t('admin.procurementContract.colSort') }}</th>
|
||||
<th class="px-5 py-3 text-left">{{ t('admin.procurementContract.colActions') }}</th>
|
||||
</tr>
|
||||
</thead>
|
||||
<tbody>
|
||||
<tr v-if="loading">
|
||||
<td colspan="8" class="px-4 py-8 text-center text-muted">
|
||||
{{ t('admin.procurementContract.loading') }}
|
||||
</td>
|
||||
</tr>
|
||||
<tr v-else-if="!rules.length">
|
||||
<td colspan="8" class="px-4 py-8 text-center text-muted">
|
||||
{{ t('admin.procurementContract.emptyRules') }}
|
||||
</td>
|
||||
</tr>
|
||||
<tr v-for="row in rules" :key="row.id" class="border-t border-subtle transition-colors hover:bg-slate-50/70">
|
||||
<td class="px-5 py-4 align-top">
|
||||
<div class="font-semibold text-primary">{{ row.title }}</div>
|
||||
</td>
|
||||
<td class="px-5 py-4 align-top">
|
||||
<span class="inline-flex rounded-md border border-slate-200 bg-slate-50 px-2 py-1 text-xs font-medium text-slate-700">
|
||||
{{ categoryLabel(row.clause_category) }}
|
||||
</span>
|
||||
</td>
|
||||
<td class="max-w-[260px] px-5 py-4 align-top text-xs text-muted" :title="keywordText(row)">
|
||||
<div class="line-clamp-2 whitespace-normal leading-5">{{ keywordText(row) }}</div>
|
||||
</td>
|
||||
<td class="px-5 py-4 align-top text-secondary">{{ triggerLabel(row.trigger_type) }}</td>
|
||||
<td class="px-5 py-4 align-top">
|
||||
<span
|
||||
class="inline-flex rounded-full px-2.5 py-1 text-xs font-semibold"
|
||||
:class="{
|
||||
'bg-rose-50 text-rose-700': row.risk_level === 'high',
|
||||
'bg-amber-50 text-amber-800': row.risk_level === 'medium',
|
||||
'bg-sky-50 text-sky-700': row.risk_level === 'low',
|
||||
}"
|
||||
>
|
||||
{{ riskLabel(row.risk_level) }}
|
||||
</span>
|
||||
</td>
|
||||
<td class="px-5 py-4 align-top">
|
||||
<span
|
||||
class="inline-flex rounded-full px-2.5 py-1 text-xs font-semibold"
|
||||
:class="row.status === 'enabled' ? 'bg-emerald-50 text-emerald-700' : 'bg-slate-100 text-slate-600'"
|
||||
>
|
||||
{{ statusLabel(row.status) }}
|
||||
</span>
|
||||
</td>
|
||||
<td class="px-5 py-4 align-top font-mono text-xs text-muted">{{ row.sort_order }}</td>
|
||||
<td class="px-5 py-4 align-top">
|
||||
<div class="flex items-center gap-2">
|
||||
<button
|
||||
type="button"
|
||||
class="inline-flex h-8 items-center rounded-lg border border-[#d8e0ec] bg-white px-3 text-xs font-semibold text-[#2f80d1] transition-colors hover:border-[#2f80d1] hover:bg-[#eaf4ff]"
|
||||
@click="openEdit(row)"
|
||||
>
|
||||
{{ t('admin.edit') }}
|
||||
</button>
|
||||
<button
|
||||
type="button"
|
||||
class="inline-flex h-8 items-center rounded-lg border border-[#d8e0ec] bg-white px-3 text-xs font-semibold text-[#172033] transition-colors hover:border-[#667792] hover:bg-slate-50"
|
||||
@click="toggleStatus(row)"
|
||||
>
|
||||
{{ row.status === 'enabled' ? t('admin.procurementContract.disable') : t('admin.procurementContract.enable') }}
|
||||
</button>
|
||||
<button
|
||||
type="button"
|
||||
class="inline-flex h-8 items-center rounded-lg border border-rose-200 bg-white px-3 text-xs font-semibold text-rose-600 transition-colors hover:border-rose-300 hover:bg-rose-50"
|
||||
@click="openDelete(row)"
|
||||
>
|
||||
{{ t('admin.delete') }}
|
||||
</button>
|
||||
</div>
|
||||
</td>
|
||||
</tr>
|
||||
</tbody>
|
||||
</table>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div
|
||||
v-if="showForm"
|
||||
class="admin-modal-overlay animate-fade-in"
|
||||
@click.self="closeForm"
|
||||
>
|
||||
<div class="admin-modal-panel max-w-2xl max-h-[92vh] my-auto scale-100" role="dialog" aria-modal="true">
|
||||
<div class="admin-modal-header flex items-center justify-between gap-3">
|
||||
<h3 class="section-title">{{ formTitleText }}</h3>
|
||||
<button type="button" class="btn-ghost h-9 px-3 text-sm" @click="closeForm">
|
||||
{{ t('admin.close') }}
|
||||
</button>
|
||||
</div>
|
||||
<div class="admin-modal-body min-h-0 !space-y-0 grid grid-cols-1 gap-4 sm:grid-cols-2 items-start">
|
||||
<label class="flex flex-col gap-1.5 text-sm">
|
||||
<span class="font-medium text-secondary">{{ t('admin.procurementContract.colRuleTitle') }}</span>
|
||||
<input v-model="formTitle" type="text" class="input-field w-full" />
|
||||
</label>
|
||||
<label class="flex flex-col gap-1.5 text-sm">
|
||||
<span class="font-medium text-secondary">{{ t('admin.procurementContract.colCategory') }}</span>
|
||||
<select v-model="formCategory" class="input-field w-full" :disabled="isBuiltinRule">
|
||||
<option v-for="category in clauseCategories" :key="category" :value="category">
|
||||
{{ t(`admin.procurementContract.category_${category}`) }}
|
||||
</option>
|
||||
</select>
|
||||
</label>
|
||||
<label class="flex flex-col gap-1.5 text-sm sm:col-span-2">
|
||||
<span class="font-medium text-secondary">{{ t('admin.procurementContract.colKeywords') }}</span>
|
||||
<input
|
||||
v-model="formKeywords"
|
||||
type="text"
|
||||
class="input-field w-full"
|
||||
:disabled="isBuiltinRule"
|
||||
:placeholder="t('admin.procurementContract.ruleKeywordsPlaceholder')"
|
||||
/>
|
||||
<span class="text-xs leading-5 text-muted">{{ keywordLogicHint }}</span>
|
||||
</label>
|
||||
<label class="flex flex-col gap-1.5 text-sm">
|
||||
<span class="font-medium text-secondary">{{ t('admin.procurementContract.colTrigger') }}</span>
|
||||
<select v-model="formTriggerType" class="input-field w-full" :disabled="isBuiltinRule">
|
||||
<option value="keyword_missing">{{ t('admin.procurementContract.triggerMissing') }}</option>
|
||||
<option value="keyword_present">{{ t('admin.procurementContract.triggerPresent') }}</option>
|
||||
</select>
|
||||
<span v-if="isBuiltinRule" class="text-xs leading-5 text-amber-700">{{ t('admin.procurementContract.builtinRuleLogicHint') }}</span>
|
||||
</label>
|
||||
<label class="flex flex-col gap-1.5 text-sm">
|
||||
<span class="font-medium text-secondary">{{ t('admin.procurementContract.colRisk') }}</span>
|
||||
<select v-model="formRiskLevel" class="input-field w-full">
|
||||
<option value="high">{{ t('admin.procurementContract.riskHigh') }}</option>
|
||||
<option value="medium">{{ t('admin.procurementContract.riskMedium') }}</option>
|
||||
<option value="low">{{ t('admin.procurementContract.riskLow') }}</option>
|
||||
</select>
|
||||
</label>
|
||||
<label class="flex flex-col gap-1.5 text-sm">
|
||||
<span class="font-medium text-secondary">{{ t('admin.procurementContract.colStatus') }}</span>
|
||||
<select v-model="formStatus" class="input-field w-full">
|
||||
<option value="enabled">{{ t('admin.procurementContract.enable') }}</option>
|
||||
<option value="disabled">{{ t('admin.procurementContract.disable') }}</option>
|
||||
</select>
|
||||
</label>
|
||||
<div class="flex flex-col gap-1.5 text-sm">
|
||||
<div class="flex items-center gap-1.5">
|
||||
<label for="risk-rule-sort-order" class="font-medium text-secondary">{{ t('admin.procurementContract.colSort') }}</label>
|
||||
<span class="group relative inline-flex">
|
||||
<button
|
||||
type="button"
|
||||
class="inline-flex text-muted transition-colors hover:text-brand-600 focus:outline-none focus-visible:text-brand-600"
|
||||
:aria-label="t('admin.procurementContract.ruleSortHint')"
|
||||
>
|
||||
<CircleHelp class="h-4 w-4" />
|
||||
</button>
|
||||
<span class="pointer-events-none absolute bottom-full left-1/2 z-10 mb-2 hidden w-60 -translate-x-1/2 rounded-lg border border-subtle bg-white px-3 py-2 text-xs font-normal leading-5 text-secondary shadow-lg group-hover:block group-focus-within:block">
|
||||
{{ t('admin.procurementContract.ruleSortHint') }}
|
||||
</span>
|
||||
</span>
|
||||
</div>
|
||||
<input id="risk-rule-sort-order" v-model.number="formSortOrder" type="number" class="input-field w-full" min="0" />
|
||||
</div>
|
||||
<label class="flex flex-col gap-1.5 text-sm sm:col-span-2">
|
||||
<span class="font-medium text-secondary">{{ t('admin.procurementContract.colRiskHint') }}</span>
|
||||
<textarea v-model="formRiskHint" rows="2" class="input-field w-full resize-y" />
|
||||
</label>
|
||||
<label class="flex flex-col gap-1.5 text-sm sm:col-span-2">
|
||||
<span class="font-medium text-secondary">{{ t('admin.procurementContract.colSuggestion') }}</span>
|
||||
<textarea v-model="formSuggestion" rows="2" class="input-field w-full resize-y" />
|
||||
</label>
|
||||
<label class="flex flex-col gap-1.5 text-sm sm:col-span-2">
|
||||
<span class="font-medium text-secondary">{{ t('admin.procurementContract.colNegotiation') }}</span>
|
||||
<textarea v-model="formNegotiation" rows="2" class="input-field w-full resize-y" />
|
||||
</label>
|
||||
</div>
|
||||
<div class="admin-modal-footer flex justify-end gap-2">
|
||||
<button type="button" class="btn-ghost h-10 px-4" @click="closeForm">
|
||||
{{ t('admin.cancel') }}
|
||||
</button>
|
||||
<button type="button" class="btn-primary h-10 px-4 disabled:opacity-70" :disabled="saving" @click="submitForm">
|
||||
{{ saving ? t('admin.procurementContract.saving') : t('admin.procurementContract.saveChanges') }}
|
||||
</button>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<DeleteConfirmDialog
|
||||
v-model="showDeleteConfirm"
|
||||
:message="t('admin.procurementContract.confirmDeleteRule', { title: pendingDelete?.title || '' })"
|
||||
:confirm-loading="deleting"
|
||||
@confirm="confirmDelete"
|
||||
@cancel="closeDelete"
|
||||
/>
|
||||
</div>
|
||||
</template>
|
||||
@@ -0,0 +1,20 @@
|
||||
/**
|
||||
* features/admin/modules/procurement-contract/contract-ocr-match-tokens.ts
|
||||
* 用途:采购合同比对区域的 V4 默认 OCR/正文匹配锚点与签章关键词(检测用 token,非 UI 文案)。
|
||||
* 依赖:procurement-contract.api 的 ContractComparisonRegionConfig 类型。
|
||||
* 逻辑:ProcurementContractPage「恢复 V4 默认配置」与新建区域配置时引用;勿当作 i18n 展示文案。
|
||||
*
|
||||
* NOTE: Strings below are OCR match tokens for Chinese contract PDFs. Keep them in Chinese
|
||||
* regardless of UI locale so region recognition against Chinese source documents still works.
|
||||
*/
|
||||
import type { ContractComparisonRegionConfig } from '@/features/admin/api/procurement-contract.api';
|
||||
|
||||
/** V4 默认比对区域配置(锚点/关键词为中文 OCR 匹配 token)。 */
|
||||
export const V4_REGION_CONFIG: ContractComparisonRegionConfig = {
|
||||
metadata_fields: ['contract_no', 'buyer', 'seller', 'version'],
|
||||
body_start_anchors: ['兹因甲方向乙方购买设备'],
|
||||
body_end_anchors: ['本合同一式两份', '以下无正文', '本页以下无正文'],
|
||||
signature_terms: ['甲方', '乙方', '盖章', '签署日期', '合同专用章'],
|
||||
attachment_start_anchors: ['附件', '性能需求表', '技术协议', '设备配置清单'],
|
||||
attachment_policy: 'page_count_only',
|
||||
};
|
||||
@@ -74,7 +74,6 @@ const {
|
||||
getApplicationSortMark,
|
||||
handleApplicationSearchChange,
|
||||
openApplicationChatLogs,
|
||||
openApplicationPermissionRequests,
|
||||
isLoading,
|
||||
currentTable,
|
||||
tableData,
|
||||
@@ -139,7 +138,6 @@ const applicationSortableKeys: ApplicationSortKey[] = [
|
||||
'unique_users',
|
||||
'last_active_at',
|
||||
'authorized_users',
|
||||
'pending_requests',
|
||||
'avg_score',
|
||||
];
|
||||
|
||||
@@ -531,7 +529,7 @@ onBeforeUnmount(() => {
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div v-if="applicationSummary" class="grid grid-cols-2 gap-3 md:grid-cols-4">
|
||||
<div v-if="applicationSummary" class="grid grid-cols-1 gap-3 sm:grid-cols-3">
|
||||
<button type="button" class="rounded-xl border border-default bg-surface p-4 text-left" @click="setApplicationUsageFilter('all')">
|
||||
<div class="text-sm text-muted">{{ t('admin.report.appOps.summaryActive') }}</div>
|
||||
<div class="mt-2 text-2xl font-bold text-primary">{{ applicationSummary.active_agents }}</div>
|
||||
@@ -545,25 +543,20 @@ onBeforeUnmount(() => {
|
||||
<div class="text-sm text-muted">{{ t('admin.report.appOps.summaryUnused') }}</div>
|
||||
<div class="mt-2 text-2xl font-bold text-primary">{{ applicationSummary.unused_agents }}</div>
|
||||
</button>
|
||||
<div class="rounded-xl border border-default bg-surface p-4">
|
||||
<div class="text-sm text-muted">{{ t('admin.report.appOps.summaryPending') }}</div>
|
||||
<div class="mt-2 text-2xl font-bold text-primary">{{ applicationSummary.pending_permission_total }}</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="admin-report-table-wrap">
|
||||
<table class="admin-report-table admin-report-table--app-ops w-full table-fixed border-collapse">
|
||||
<colgroup>
|
||||
<col class="w-[14%]" />
|
||||
<col class="w-[7%]" />
|
||||
<col class="w-[7%]" />
|
||||
<col class="w-[16%]" />
|
||||
<col class="w-[7%]" />
|
||||
<col class="w-[7%]" />
|
||||
<col class="w-[8%]" />
|
||||
<col class="w-[8%]" />
|
||||
<col class="w-[8%]" />
|
||||
<col class="w-[18%]" />
|
||||
<col class="w-[8%]" />
|
||||
<col class="w-[10%]" />
|
||||
<col class="w-[10%]" />
|
||||
<col class="w-[10%]" />
|
||||
<col class="w-[12%]" />
|
||||
</colgroup>
|
||||
<thead>
|
||||
<tr>
|
||||
@@ -588,7 +581,7 @@ onBeforeUnmount(() => {
|
||||
</thead>
|
||||
<tbody>
|
||||
<tr v-if="applicationItems.length === 0">
|
||||
<td colspan="10" class="text-center text-muted py-12">
|
||||
<td colspan="9" class="text-center text-muted py-12">
|
||||
{{ t('admin.report.appOps.empty') }}
|
||||
</td>
|
||||
</tr>
|
||||
@@ -600,7 +593,6 @@ onBeforeUnmount(() => {
|
||||
{{ row.last_active_at ? formatLocalDateTime(row.last_active_at) : '-' }}
|
||||
</td>
|
||||
<td class="px-3 py-3 text-left align-middle font-mono tabular-nums">{{ row.authorized_users }}</td>
|
||||
<td class="px-3 py-3 text-left align-middle font-mono tabular-nums">{{ row.pending_requests }}</td>
|
||||
<td class="px-3 py-3 text-left align-middle font-mono tabular-nums whitespace-nowrap">
|
||||
{{ row.avg_score == null ? '-' : row.avg_score }}
|
||||
<span v-if="row.feedback_count" class="text-xs text-muted">({{ row.feedback_count }})</span>
|
||||
@@ -612,14 +604,9 @@ onBeforeUnmount(() => {
|
||||
</span>
|
||||
</td>
|
||||
<td class="px-3 py-3 text-left align-middle">
|
||||
<div class="flex flex-wrap gap-1">
|
||||
<button type="button" class="btn-secondary text-xs px-2 py-1" @click="openApplicationChatLogs(row)">
|
||||
{{ t('admin.report.appOps.actionLogs') }}
|
||||
</button>
|
||||
<button type="button" class="btn-secondary text-xs px-2 py-1" @click="openApplicationPermissionRequests(row)">
|
||||
{{ t('admin.report.appOps.actionRequests') }}
|
||||
</button>
|
||||
</div>
|
||||
<button type="button" class="btn-secondary text-xs px-2 py-1" @click="openApplicationChatLogs(row)">
|
||||
{{ t('admin.report.appOps.actionLogs') }}
|
||||
</button>
|
||||
</td>
|
||||
</tr>
|
||||
</tbody>
|
||||
|
||||
@@ -207,18 +207,6 @@ export function useReportsAdmin() {
|
||||
});
|
||||
};
|
||||
|
||||
/**
|
||||
* 下钻到权限申请列表,按 agent_id 精确过滤。
|
||||
* @param row - 应用运营行
|
||||
*/
|
||||
const openApplicationPermissionRequests = (row: ApplicationReportItem): void => {
|
||||
void router.push({
|
||||
name: 'AdminReports',
|
||||
params: { table: 'permission_requests' },
|
||||
query: { agent_id: String(row.agent_id) },
|
||||
});
|
||||
};
|
||||
|
||||
/**
|
||||
* 导出应用运营报表 Excel(仅运营字段)。
|
||||
*/
|
||||
@@ -237,7 +225,6 @@ export function useReportsAdmin() {
|
||||
? formatLocalDateTime(row.last_active_at)
|
||||
: '-',
|
||||
[t('admin.report.appOps.columns.authorized_users')]: row.authorized_users,
|
||||
[t('admin.report.appOps.columns.pending_requests')]: row.pending_requests,
|
||||
[t('admin.report.appOps.columns.avg_score')]: row.avg_score ?? '-',
|
||||
[t('admin.report.appOps.columns.feedback_count')]: row.feedback_count,
|
||||
[t('admin.report.appOps.columns.tokens_used')]: row.tokens_used,
|
||||
@@ -405,7 +392,7 @@ const dataSourceTable = computed<Exclude<AdminReportTableId, 'usage_analysis'>>(
|
||||
});
|
||||
|
||||
/**
|
||||
* 从路由 query 灌入列筛选(用于应用运营下钻到聊天日志 / 权限申请)。
|
||||
* 从路由 query 灌入列筛选(用于应用运营下钻到聊天日志)。
|
||||
*/
|
||||
const applyRouteQueryFilters = (): void => {
|
||||
const next: Record<string, string> = {};
|
||||
@@ -1218,7 +1205,6 @@ watch([reportPageSize, sortedTableData], () => {
|
||||
getApplicationSortMark,
|
||||
handleApplicationSearchChange,
|
||||
openApplicationChatLogs,
|
||||
openApplicationPermissionRequests,
|
||||
isLoading,
|
||||
currentTable,
|
||||
tableData,
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
/**
|
||||
* features/admin/stores/admin-nav.store.ts
|
||||
* 管理后台导航 UI 状态(侧栏折叠、货代/报表/企微子菜单展开、角标)。
|
||||
* 管理后台导航 UI 状态(侧栏折叠、报表/企微子菜单展开、角标)。
|
||||
*
|
||||
* 角标数据来自 GET /api/admin/dashboard/badges,在 store 内做 TTL 缓存与 in-flight 去重,
|
||||
* 避免切换 admin 子路由时重复请求(AdminLayout 挂载一次即可)。
|
||||
@@ -11,11 +11,6 @@ import { ref } from 'vue';
|
||||
import { getAdminDashboardBadges } from '@/features/admin/api/admin.api';
|
||||
import type { AdminModuleId } from '../types/admin.types';
|
||||
|
||||
export type ShippingManagementGroupKey =
|
||||
| 'admin.nav.shippingOrderRecognition'
|
||||
| 'admin.nav.shippingInventoryManagement'
|
||||
| 'admin.nav.shippingRunAudit';
|
||||
|
||||
/** 角标缓存有效期(毫秒):此时间内 ensureBadges 直接复用内存中的计数 */
|
||||
const BADGE_CACHE_TTL_MS = 60_000;
|
||||
|
||||
@@ -25,10 +20,6 @@ export const useAdminNavStore = defineStore('adminNav', () => {
|
||||
const reportsExpanded = ref(false);
|
||||
/** 企业微信子菜单:默认折叠 */
|
||||
const wecomExpanded = ref(false);
|
||||
/** 货代管理二级菜单:默认折叠,进入货代页面时自动展开。 */
|
||||
const shippingManagementExpanded = ref(false);
|
||||
/** 货代手风琴当前展开分组;单值约束保证同一时间最多展开一组。 */
|
||||
const shippingManagementGroup = ref<ShippingManagementGroupKey | null>(null);
|
||||
/** 「用户审批」导航角标:pending 注册用户数 */
|
||||
const pendingApprovalsCount = ref(0);
|
||||
/** 「权限申请」导航角标:pending 权限申请数 */
|
||||
@@ -43,11 +34,6 @@ export const useAdminNavStore = defineStore('adminNav', () => {
|
||||
sidebarCollapsed.value = !sidebarCollapsed.value;
|
||||
};
|
||||
|
||||
/** 展开指定货代分组;再次点击当前分组时收起全部功能项。 */
|
||||
const toggleShippingManagementGroup = (groupKey: ShippingManagementGroupKey): void => {
|
||||
shippingManagementGroup.value = shippingManagementGroup.value === groupKey ? null : groupKey;
|
||||
};
|
||||
|
||||
const setBadgeCounts = (approvals: number, requests: number): void => {
|
||||
pendingApprovalsCount.value = approvals;
|
||||
pendingRequestsCount.value = requests;
|
||||
@@ -102,12 +88,9 @@ export const useAdminNavStore = defineStore('adminNav', () => {
|
||||
sidebarCollapsed,
|
||||
reportsExpanded,
|
||||
wecomExpanded,
|
||||
shippingManagementExpanded,
|
||||
shippingManagementGroup,
|
||||
pendingApprovalsCount,
|
||||
pendingRequestsCount,
|
||||
toggleSidebar,
|
||||
toggleShippingManagementGroup,
|
||||
setBadgeCounts,
|
||||
badgeForModule,
|
||||
ensureBadges,
|
||||
|
||||
@@ -14,31 +14,13 @@ export type AdminModuleId =
|
||||
| 'announcements'
|
||||
| 'questions'
|
||||
| 'wecom'
|
||||
| 'linked_services'
|
||||
| 'permissions'
|
||||
| 'requests'
|
||||
| 'platform_apps'
|
||||
| 'shipping_inventory'
|
||||
| 'procurement_contract'
|
||||
| 'reports';
|
||||
|
||||
/** 货代管理领域下可由侧栏展示和高亮的稳定业务页面。 */
|
||||
export type ShippingConfigSubModuleId =
|
||||
| 'field_assets'
|
||||
| 'order_schema'
|
||||
| 'order_document_profiles'
|
||||
| 'identity_rules'
|
||||
| 'order_extraction_runs'
|
||||
| 'shipping_audit'
|
||||
| 'process_gates'
|
||||
| 'legacy_stp_jobs'
|
||||
| 'inventory_fields'
|
||||
| 'connections'
|
||||
| 'inventory_sites'
|
||||
| 'warehouse_mappings'
|
||||
| 'routing_rules'
|
||||
| 'shipping_templates'
|
||||
| 'inventory_snapshots'
|
||||
| 'export_records';
|
||||
|
||||
export type AdminReportTableId =
|
||||
| 'usage_analysis'
|
||||
| 'users'
|
||||
|
||||
@@ -0,0 +1,44 @@
|
||||
/**
|
||||
* features/admin/types/linked-service.types.ts
|
||||
* 关联服务管理表单与行数据类型。
|
||||
*/
|
||||
|
||||
export interface AdminLinkedServiceRow {
|
||||
id: number;
|
||||
name: string;
|
||||
url: string;
|
||||
is_enabled: boolean;
|
||||
sort_order: number;
|
||||
created_at?: string | null;
|
||||
updated_at?: string | null;
|
||||
}
|
||||
|
||||
export interface LinkedServiceFormState {
|
||||
id: number | null;
|
||||
name: string;
|
||||
url: string;
|
||||
is_enabled: boolean;
|
||||
sort_order: number;
|
||||
}
|
||||
|
||||
/** 创建空的关联服务表单。 */
|
||||
export function createEmptyLinkedServiceForm(): LinkedServiceFormState {
|
||||
return {
|
||||
id: null,
|
||||
name: '',
|
||||
url: '',
|
||||
is_enabled: true,
|
||||
sort_order: 0,
|
||||
};
|
||||
}
|
||||
|
||||
/** 将列表行回填为编辑表单。 */
|
||||
export function linkedServiceRowToForm(row: AdminLinkedServiceRow): LinkedServiceFormState {
|
||||
return {
|
||||
id: row.id,
|
||||
name: row.name,
|
||||
url: row.url,
|
||||
is_enabled: Boolean(row.is_enabled),
|
||||
sort_order: Number(row.sort_order || 0),
|
||||
};
|
||||
}
|
||||
@@ -45,7 +45,6 @@ export type ApplicationSortKey =
|
||||
| 'unique_users'
|
||||
| 'last_active_at'
|
||||
| 'authorized_users'
|
||||
| 'pending_requests'
|
||||
| 'avg_score'
|
||||
| 'tokens_used';
|
||||
|
||||
@@ -58,7 +57,8 @@ export interface ApplicationReportItem {
|
||||
unique_users: number;
|
||||
last_active_at: string | null;
|
||||
authorized_users: number;
|
||||
pending_requests: number;
|
||||
/** 后端仍返回;应用运营页已不再展示待审列 */
|
||||
pending_requests?: number;
|
||||
avg_score: number | null;
|
||||
feedback_count: number;
|
||||
tokens_used: number;
|
||||
@@ -70,7 +70,8 @@ export interface ApplicationReportSummary {
|
||||
active_agents: number;
|
||||
used_agents: number;
|
||||
unused_agents: number;
|
||||
pending_permission_total: number;
|
||||
/** 后端仍返回;应用运营页已不再展示待审摘要卡 */
|
||||
pending_permission_total?: number;
|
||||
}
|
||||
|
||||
export interface ApplicationReport {
|
||||
|
||||
@@ -1,9 +1,7 @@
|
||||
/**
|
||||
* features/admin/views/AdminLayout.vue
|
||||
* 管理后台壳层:顶栏 + 左侧导航 + 子路由出口。
|
||||
* 依赖:AdminNav、vue-router、admin-nav.store。
|
||||
* 逻辑:AdminNav 统一承担模块和二级目录导航;lg 起侧栏与内容并排,
|
||||
* 小于 lg(含 768px)上下堆叠,避免运维诊断页主区被侧栏挤窄。
|
||||
* 管理后台壳层:顶栏 + AdminNav + 子路由出口。
|
||||
* 角标仅在 Layout 首次挂载时 ensureBadges(store 内 60s TTL 缓存)。
|
||||
*/
|
||||
<script setup lang="ts">
|
||||
import { onMounted } from 'vue';
|
||||
@@ -28,7 +26,7 @@ onMounted(() => {
|
||||
<div class="page-shell min-h-screen font-sans flex flex-col">
|
||||
<header class="app-header px-6">
|
||||
<div class="flex items-center gap-4">
|
||||
<button type="button" class="btn-icon-ds lg:block hidden" @click="navStore.toggleSidebar()">
|
||||
<button type="button" class="btn-icon-ds md:block hidden" @click="navStore.toggleSidebar()">
|
||||
<svg xmlns="http://www.w3.org/2000/svg" width="24" height="24" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2"><rect width="18" height="18" x="3" y="3" rx="2"/><path d="M9 3v18"/></svg>
|
||||
</button>
|
||||
<button type="button" class="btn-icon-ds" @click="router.push('/workspace')">
|
||||
@@ -44,10 +42,9 @@ onMounted(() => {
|
||||
<AppHeaderTools />
|
||||
</header>
|
||||
|
||||
<!-- lg 起才并排侧栏;768px 平板保持上下堆叠,避免诊断等运维页主内容被挤窄 -->
|
||||
<main class="flex-1 w-full mx-auto px-4 md:px-8 py-6 md:py-8 flex flex-col lg:flex-row gap-6 lg:gap-8 items-start">
|
||||
<main class="flex-1 w-full mx-auto px-4 md:px-8 py-6 md:py-8 flex flex-col md:flex-row gap-8 items-start">
|
||||
<AdminNav />
|
||||
<section class="flex-1 min-w-0 w-full space-y-8">
|
||||
<section class="flex-1 min-w-0 space-y-8 w-full">
|
||||
<router-view />
|
||||
</section>
|
||||
</main>
|
||||
|
||||
Reference in new issue
Block a user