20261116 #24

Merged
zzh merged 9 commits from test into master 2026-11-16 09:08:51 +08:00
30 changed files with 3775 additions and 1448 deletions
Showing only changes of commit 57d506ee89 - Show all commits

View File

@ -62,6 +62,7 @@ export const AI_SKILL_SCENES = [
{ value: 'pricePublish', label: '价格发布风险' },
{ value: 'pricingWorkbench', label: '定价工作台' },
{ value: 'autoTriggerFormula', label: '自动触发公式' },
{ value: 'billingConditionFormula', label: '计费条件公式' },
{ value: 'receiverAddressParse', label: '收件地址解析' },
{ value: 'itfxPrefixScript', label: '接口通前置脚本' },
{ value: 'itfxParameterMap', label: '接口通参数映射' },

View File

@ -19,6 +19,8 @@ export interface DataResourceMeta {
name: string
mainTable?: string
filterableFields?: string[]
/** 业务列表是否已真正接入过滤 */
isEnforced?: boolean
}
export interface DataPermMetaDto {
@ -109,14 +111,32 @@ export interface EffectiveDataScopeDto {
userId: string
isAdmin: boolean
dataResourceCode?: string
isEnforced?: boolean
organizationIds?: string[]
organizationNames?: string[]
dataScope?: number
dataScopeLabel?: string
bizFilters?: { bizType: string; bizIds: string[] }[]
secretLevels?: number[]
summaryText?: string
}
export interface OrderScopePreviewItem {
orderId: number
serviceNo: string
clientNo?: string
orderStatus?: string
}
export interface OrderScopePreviewDto {
userId: string
isAdmin: boolean
enforced: boolean
totalCount: number
samples: OrderScopePreviewItem[]
summaryText?: string
}
export interface RoleDataPermDto {
roleId: string
roleName?: string
@ -218,6 +238,14 @@ export async function getEffectiveDataScope(userId: string, dataResourceCode = '
return res.data
}
/** 按目标用户生效范围预览订单可见量(抽样) */
export async function previewOrderScope(userId: string, sampleSize = 5) {
const res = await axiosInstance.get<OrderScopePreviewDto>(rbacDataPermUrl('/preview-order-scope'), {
params: { userId, sampleSize },
})
return res.data
}
export async function saveUserDataPerm(userId: string, body: SaveUserDataPermInput) {
const res = await axiosInstance.put<UserDataPermDto>(rbacDataPermUrl('/save-user'), body, { params: { userId } })
return res.data

View File

@ -86,6 +86,17 @@ export async function confirmNoticeRead(id: number | string) {
notifyNoticeUnreadChanged()
}
/** 一键清扫当前主体可见未读(默认站内信) */
export async function confirmNoticeReadAll(noticeType: 'notice' | 'message' = 'message') {
const res = await axiosInstance.post(omsUrl('/system/notice/read-confirm-all'), { noticeType })
assertBusinessOk(res.data)
notifyNoticeUnreadChanged()
const payload = res.data?.data ?? res.data?.Data ?? res.data ?? {}
return {
clearedCount: Number(payload.clearedCount ?? payload.ClearedCount ?? 0) || 0,
}
}
export interface NoticeReceiverOption {
value: number
label: string

View File

@ -357,6 +357,9 @@
</a-button>
</div>
</div>
<div v-if="$slots['search-extra']" class="search-extra">
<slot name="search-extra" />
</div>
</div>
<div
@ -627,8 +630,13 @@
border-bottom: 1px solid var(--clm-border);
min-height: 40px;
display: flex;
align-items: center;
flex-direction: column;
align-items: stretch;
justify-content: center;
gap: 8px;
flex-shrink: 0;
padding-top: 8px;
padding-bottom: 8px;
}
.search-box {
@ -638,6 +646,10 @@
width: 100%;
}
.search-extra {
width: 100%;
}
.search-input {
flex: 1;
min-width: 0;
@ -728,6 +740,8 @@
.interface-tree {
flex: 1;
min-height: 0;
display: flex;
flex-direction: column;
padding: 6px 2px;
overflow-x: hidden;
overflow-y: auto;
@ -1073,13 +1087,17 @@
.loading-state,
.empty-state {
flex: 1;
display: flex;
flex-direction: column;
align-items: center;
justify-content: center;
min-height: 100px;
min-height: 0;
width: 100%;
padding: 10px 8px;
color: var(--clm-muted);
text-align: center;
box-sizing: border-box;
p {
margin: 6px 0 0;

View File

@ -91,16 +91,7 @@
@pointerdown="onFloatChromePointerDown"
>
<template v-if="mode === 'float'">
<EdiAvatar class="ai-float-avatar" size="sm" :pulse="false" />
<div class="ai-float-heading">
<div class="ai-float-title">
{{ isOpsAudience ? t('ediAssistant.ops.actionAdvisor') : t('ediAssistant.title') }}
</div>
<p class="ai-float-sub">
{{ isOpsAudience ? t('ediAssistant.ops.hint') : t('ediAssistant.hint') }}
</p>
</div>
<div class="ai-app-bar__actions" @pointerdown.stop>
<div class="ai-app-bar__actions ai-app-bar__actions--float-only" @pointerdown.stop>
<button
type="button"
class="ai-float-icon-btn"

View File

@ -112,24 +112,45 @@
z-index: 1;
border: none;
border-radius: 0;
box-shadow: none;
box-shadow: none !important;
background: transparent;
backdrop-filter: none;
-webkit-backdrop-filter: none;
padding: 0;
width: 100%;
}
/* 浮窗内去掉 inset 内阴影,只保留外层浮窗外阴影 */
.ai-advisor-shell--float .ai-composer,
.ai-advisor-shell--float .ai-quick-card,
.ai-advisor-shell--float .ai-quick-card:hover,
.ai-advisor-shell--float .ai-mcp-card,
.ai-advisor-shell--float .ai-followup-chip,
.ai-advisor-shell--float .ai-msg-bubble {
box-shadow: none;
}
.ai-advisor-shell--float .ai-app-bar--float {
align-self: flex-end;
width: auto;
max-width: none;
margin: 0;
gap: 10px;
padding: 12px 14px 10px;
border-bottom: 1px solid color-mix(in srgb, var(--color-text-1, #1d2129) 7%, transparent);
margin: 10px 12px 0;
gap: 0;
padding: 4px;
border: 1px solid color-mix(in srgb, var(--color-text-1, #1d2129) 8%, transparent);
border-radius: 999px;
cursor: grab;
user-select: none;
touch-action: none;
background: color-mix(in srgb, var(--ai-shell-surface) 88%, transparent);
backdrop-filter: blur(8px);
background: color-mix(in srgb, var(--ai-shell-surface, #fff) 92%, transparent);
backdrop-filter: blur(10px);
-webkit-backdrop-filter: blur(10px);
box-shadow: 0 6px 18px rgba(15, 23, 42, 0.08);
justify-content: flex-end;
}
.ai-advisor-shell--float .ai-app-bar__actions--float-only {
margin-left: 0;
}
.ai-advisor-shell--float .ai-app-bar--float:active {
@ -177,18 +198,18 @@
.ai-advisor-shell--float .ai-app-bar__actions {
display: inline-flex;
align-items: center;
gap: 4px;
margin-left: auto;
gap: 2px;
margin-left: 0;
}
.ai-advisor-shell--float .ai-float-icon-btn {
display: inline-flex;
align-items: center;
justify-content: center;
width: 34px;
height: 34px;
width: 32px;
height: 32px;
border: none;
border-radius: 10px;
border-radius: 999px;
background: transparent;
color: var(--color-text-2, #4e5969);
cursor: pointer;
@ -297,9 +318,7 @@
border-radius: 18px;
padding: 10px 12px;
border: 1px solid color-mix(in srgb, var(--color-text-1, #1d2129) 10%, transparent);
box-shadow:
0 1px 0 rgba(255, 255, 255, 0.7) inset,
0 10px 24px rgba(27, 42, 107, 0.07);
box-shadow: none;
}
.ai-advisor-shell--float .ai-composer-hint {

View File

@ -920,9 +920,7 @@ onUnmounted(() => {
border-radius: 20px;
border: 1px solid color-mix(in srgb, var(--color-text-1, #1d2129) 8%, transparent);
background: var(--app-elevated-bg, #fff);
box-shadow:
0 24px 64px rgba(15, 23, 42, 0.18),
0 4px 14px rgba(15, 23, 42, 0.06);
box-shadow: 0 16px 40px rgba(15, 23, 42, 0.14);
overflow: hidden;
}

View File

@ -28,8 +28,8 @@
>
{{ tag.label }}
</a-tag>
<span v-if="subtitle" class="header-subtitle">{{ subtitle }}</span>
</div>
<p v-if="subtitle" class="header-subtitle">{{ subtitle }}</p>
</div>
</div>
<div v-if="stats.length" class="header-stats">
@ -168,8 +168,8 @@ const modelTab = computed({
.shell-header {
display: flex;
flex-direction: column;
gap: 14px;
padding: 16px 24px;
gap: 10px;
padding: 12px 20px;
border-bottom: 1px solid var(--color-border-2);
flex-shrink: 0;
}
@ -177,16 +177,17 @@ const modelTab = computed({
.header-main {
display: flex;
align-items: center;
gap: 16px;
flex-wrap: wrap;
gap: 12px 16px;
flex-wrap: nowrap;
min-height: 32px;
}
.header-left {
display: flex;
align-items: center;
gap: 14px;
gap: 10px;
flex: 1;
min-width: 200px;
min-width: 0;
}
.header-icon {
@ -196,22 +197,28 @@ const modelTab = computed({
.header-title-row {
display: flex;
align-items: center;
flex-wrap: wrap;
flex-wrap: nowrap;
gap: 8px;
min-width: 0;
}
.header-title {
margin: 0;
font-size: 18px;
font-size: 16px;
font-weight: 600;
line-height: 1.3;
color: var(--color-text-1);
white-space: nowrap;
overflow: hidden;
text-overflow: ellipsis;
}
.header-subtitle {
margin: 4px 0 0;
margin: 0;
font-size: 13px;
line-height: 1.3;
color: var(--color-text-3);
white-space: nowrap;
}
.header-extra {
@ -220,30 +227,31 @@ const modelTab = computed({
.header-stats {
display: flex;
gap: 12px;
align-items: center;
gap: 8px;
flex-shrink: 0;
}
.stat-item {
min-width: 72px;
padding: 8px 14px;
border-radius: 8px;
display: inline-flex;
align-items: baseline;
gap: 4px;
padding: 4px 10px;
border-radius: 6px;
background: var(--color-fill-2);
text-align: center;
white-space: nowrap;
.stat-value {
display: block;
font-size: 18px;
font-size: 14px;
font-weight: 600;
color: var(--app-primary-color, #2d8c8c);
line-height: 1.2;
}
.stat-label {
display: block;
font-size: 11px;
font-size: 12px;
color: var(--color-text-3);
margin-top: 2px;
line-height: 1.2;
}
}
@ -266,6 +274,7 @@ const modelTab = computed({
}
.tabs-extra {
margin-left: auto;
padding: 0;
display: flex;
align-items: center;

View File

@ -252,14 +252,9 @@
<RightTopMessage />
</div>
<!-- 语言 -->
<div class="top-nav-right-item top-nav-right-item--icon">
<SelectLang />
</div>
<!-- 用户 -->
<!-- 用户(语言收进下拉) -->
<div class="top-nav-right-item user-menu-item">
<RightTopUser />
<RightTopUser show-language-menu />
</div>
</div>
</div>
@ -281,7 +276,6 @@ import { useRbacUserStore } from '@/store/modules/rbac-user';
import TabBar from '@/components/tab-bar/index.vue';
import RightTopUser from './RightTopUser.vue';
import RightTopMessage from './RightTopMessage.vue';
import SelectLang from './SelectLang.vue';
import ContactService from '@/components/ContactService/index.vue';
import { IconPrinter, IconDownload } from '@arco-design/web-vue/es/icon';
import { Message } from '@arco-design/web-vue';

View File

@ -1439,6 +1439,8 @@ export default {
'system.aiSkills.refresh': 'Refresh',
'system.aiSkills.create': 'Create',
'system.aiSkills.sceneFilter': 'Filter by scene',
'system.aiSkills.searchPlaceholder': 'Search name or Skill Key',
'system.aiSkills.listEmpty': 'No skills yet',
'system.aiSkills.selectHint': 'Select a skill on the left, or create one',
'system.aiSkills.editTitle': 'Edit Skill',
'system.aiSkills.createTitle': 'Create Skill',
@ -1448,9 +1450,17 @@ export default {
'system.aiSkills.description': 'Description',
'system.aiSkills.sortOrder': 'Sort',
'system.aiSkills.content': 'Content (sent to model)',
'system.aiSkills.contentPlaceholder': 'Write the prompt / rules sent to the model…',
'system.aiSkills.save': 'Save',
'system.aiSkills.delete': 'Delete',
'system.aiSkills.cancel': 'Cancel',
'system.aiSkills.unsaved': 'Unsaved',
'system.aiSkills.unsavedTitle': 'Unsaved changes',
'system.aiSkills.unsavedContent':
'This skill has unsaved changes. Continuing will discard them.',
'system.aiSkills.unsavedLeave':
'This skill has unsaved changes. Leaving will discard them.',
'system.aiSkills.discard': 'Discard',
'system.aiSkills.saveOk': 'Saved',
'system.aiSkills.saveFail': 'Save failed',
'system.aiSkills.loadFail': 'Load failed',
@ -1465,10 +1475,25 @@ export default {
'system.mcpTools.pageDesc':
'Manage lightweight MCP tools: price check, channel customer guide, and tracking. Enable, test, and try AI Agent.',
'system.mcpTools.refresh': 'Refresh',
'system.mcpTools.searchPlaceholder': 'Search name or Tool Key',
'system.mcpTools.listEmpty': 'No tools yet',
'system.mcpTools.tabConfig': 'Config',
'system.mcpTools.tabTest': 'Test',
'system.mcpTools.tabAgent': 'AI Agent',
'system.mcpTools.displayName': 'Display name',
'system.mcpTools.description': 'Description (for the model)',
'system.mcpTools.descriptionPlaceholder':
'Describe purpose and args so the model can pick this tool…',
'system.mcpTools.sortOrder': 'Sort',
'system.mcpTools.save': 'Save',
'system.mcpTools.cancel': 'Cancel',
'system.mcpTools.unsaved': 'Unsaved',
'system.mcpTools.unsavedTitle': 'Unsaved changes',
'system.mcpTools.unsavedContent':
'This tool has unsaved changes. Continuing will discard them.',
'system.mcpTools.unsavedLeave':
'This tool has unsaved changes. Leaving will discard them.',
'system.mcpTools.discard': 'Discard',
'system.mcpTools.saveOk': 'Saved',
'system.mcpTools.saveFail': 'Save failed',
'system.mcpTools.loadFail': 'Load failed',
@ -1590,13 +1615,16 @@ export default {
'system.approval.inbox.col.createTime': 'Submitted at',
'system.dataPerm.users.title': 'User Data Permission',
'system.dataPerm.users.desc': 'Configure direct five-dimension permissions for internal users',
'system.dataPerm.users.desc':
'Prefer job templates; use this page for personal exceptions. Runtime = role ∪ user direct',
'system.dataPerm.users.loading': 'Loading users...',
'system.dataPerm.users.emptySelect': 'Select a user on the left',
'system.dataPerm.users.emptyDesc': 'Configure org, data scope, biz tags, secret level and custom filters for internal users',
'system.dataPerm.users.emptyDesc':
'Recommended: configure and apply a template first; here review effective scope and override exceptions only',
'system.dataPerm.panel.primaryOrg': 'Primary organization',
'system.dataPerm.panel.configType': 'Config type',
'system.dataPerm.panel.configTypeDirect': 'Direct user config',
'system.dataPerm.panel.configTypeException': 'Personal exception',
'system.dataPerm.panel.previewModule': 'Preview module',
'system.dataPerm.panel.cannotEditSelf': 'You cannot edit your own data permissions',
'system.dataPerm.panel.stat.total': 'Direct items',
@ -1606,11 +1634,56 @@ export default {
'system.dataPerm.panel.tab.secret': 'Secret level',
'system.dataPerm.panel.tab.filter': 'Custom filter',
'system.dataPerm.panel.tabsAria': 'Data permission dimensions',
'system.dataPerm.panel.save': 'Save permissions',
'system.dataPerm.panel.saveDirty': 'Save permissions (unsaved)',
'system.dataPerm.panel.saveSuccess': 'Permissions saved',
'system.dataPerm.panel.dirtyTag': 'Unsaved',
'system.dataPerm.panel.quickTitle': 'Quick setup',
'system.dataPerm.panel.quickHint':
'Prefer Apply template or a scenario. Scenarios set Order scope/secret; org/biz tags go under Advanced',
'system.dataPerm.panel.exceptionNote': 'Direct config is an exception; use templates for job roles',
'system.dataPerm.panel.advancedTitle': 'Advanced: five dimensions (exceptions)',
'system.dataPerm.panel.advancedHint':
'Expand only when templates/scenarios are not enough. “Not enforced” modules do not filter lists yet',
'system.dataPerm.scenario.label': 'Common scenarios (then save at top-right)',
'system.dataPerm.scenario.personal': 'Own orders only',
'system.dataPerm.scenario.personalDesc': 'Personal + public/internal',
'system.dataPerm.scenario.department': 'Department orders',
'system.dataPerm.scenario.departmentDesc': 'Department + levels 1-3',
'system.dataPerm.scenario.orgTree': 'Org tree orders',
'system.dataPerm.scenario.orgTreeDesc': 'Org tree + levels 1-3',
'system.dataPerm.scenario.global': 'All orders (careful)',
'system.dataPerm.scenario.globalDesc': 'Global + all levels',
'system.dataPerm.scenario.applied': 'Applied “{name}”; save at top-right',
'system.dataPerm.scenario.confirmTitle': 'Replace current scope/secret?',
'system.dataPerm.scenario.confirmContent':
'This replaces Data scope and Secret level rows; org and biz tags stay unchanged',
'system.dataPerm.banner.title': 'Effective scope',
'system.dataPerm.banner.hint': 'Merged role + user direct config; Order supports sample preview',
'system.dataPerm.banner.admin': 'Admin: no data limits',
'system.dataPerm.banner.noOrgLimit': 'No org limit',
'system.dataPerm.banner.orgMore': '… {count} orgs',
'system.dataPerm.banner.bizUnlimited': 'Unlimited',
'system.dataPerm.banner.bizCount': '{count} tag types',
'system.dataPerm.banner.previewOrders': 'Preview visible orders',
'system.dataPerm.banner.previewResult': 'About {count} visible orders (sample)',
'system.dataPerm.banner.previewAdminNote': 'Admin skips filters',
'system.dataPerm.banner.previewEmpty': 'No orders under this scope',
'system.dataPerm.resource.enforced': 'Enforced',
'system.dataPerm.resource.notEnforced': 'Not enforced',
'system.dataPerm.resource.notEnforcedHint':
'This module is not wired into list filters yet; config is reserved and will not change visibility',
'system.dataPerm.filter.tip': 'Conditions are AND; fields/operators are localized; backend validates whitelist on save',
'system.dataPerm.filter.addCondition': 'Add condition',
'system.dataPerm.filter.andHint': 'AND between conditions',
'system.dataPerm.filter.empty': 'No filter conditions',
'system.dataPerm.filter.field': 'Field',
'system.dataPerm.filter.valuePlaceholder': 'Value (comma-separated for in/between)',
'system.dataPerm.audit.tabsAria': 'Audit log types',
'system.dataPerm.audit.tab.change': 'Config change log',
'system.dataPerm.audit.tab.access': 'Data access log',
'system.dataPerm.audit.accessTip':
'Access logs are not written automatically in P1; this page is reserved until internal audit is enabled.',
'Sampling is live: ~10% for order/finance list APIs, 100% for exports. Only internal users with data scope produce rows; filter by user GUID, module, and time.',
'system.dataPerm.audit.targetType': 'Target type',
'system.dataPerm.audit.targetId': 'Target ID',
'system.dataPerm.audit.userId': 'User GUID',
@ -1625,6 +1698,7 @@ export default {
'system.dataPerm.audit.col.targetId': 'Target ID',
'system.dataPerm.audit.col.action': 'Action',
'system.dataPerm.audit.col.operatorMapId': 'Operator mapId',
'system.dataPerm.audit.col.userId': 'User GUID',
'system.dataPerm.audit.col.module': 'Module',
'system.dataPerm.audit.col.api': 'API',
'system.dataPerm.audit.col.rowCount': 'Rows',
@ -1721,20 +1795,22 @@ export default {
'order.batchJobs.action.importRow': 'Order Import',
'order.batchJobs.action.unknown': 'Other',
'system.dataPerm.templates.section.identity': '① What this template is',
'system.dataPerm.templates.section.identity': 'Template identity',
'system.dataPerm.templates.section.identityHint':
'Name and code help you find it in the list; you can configure rules before saving',
'system.dataPerm.templates.section.bindApply': '③ Link role & apply (after save)',
'Name is for the list; avoid changing the code after save',
'system.dataPerm.templates.section.bindApply': 'Link role & apply',
'system.dataPerm.templates.section.applyNow': 'Apply now',
'system.dataPerm.templates.bindApplyHint':
'Linking a role ≠ granting access. Save and finish rules first, then use A for the role or B for users.',
'Linking a role is only a tag. To take effect, write to role or apply to users (save first).',
'system.dataPerm.templates.flow.step1': 'Identity',
'system.dataPerm.templates.flow.step2': 'Rules',
'system.dataPerm.templates.flow.step3': 'Apply',
'system.dataPerm.templates.flow.goItemsTitle': 'Next: configure permission rules',
'system.dataPerm.templates.flow.goItemsDesc':
'Rules define org / data scope / secret level access. Come back here to apply after editing.',
'system.dataPerm.templates.flow.goItemsTitle': 'Next: rules',
'system.dataPerm.templates.flow.goItemsDesc': 'Set scope and secret level, then apply',
'system.dataPerm.templates.flow.goItemsBtn': 'Configure rules',
'system.dataPerm.templates.flow.goApplyTitle': 'Next: apply',
'system.dataPerm.templates.flow.goApplyDesc': 'Write to linked role, or batch-apply to users',
'system.dataPerm.templates.flow.goApplyBtn': 'Go apply',
'system.dataPerm.templates.applyToRole': 'A. Sync to linked role',
'system.dataPerm.templates.applyToRoleDesc':
'Write current rules into the role data permissions (replaces role direct config)',
@ -1760,11 +1836,11 @@ export default {
'system.dataPerm.templates.applyPartial': '{success} succeeded, {fail} failed',
'system.dataPerm.templates.roleCodePlaceholder': 'Optional, auto-apply when role is assigned',
'system.dataPerm.templates.itemsTitle': 'Template items',
'system.dataPerm.templates.itemsGuideTitle': '② How to configure rules',
'system.dataPerm.templates.itemsGuideTitle': 'Permission rules',
'system.dataPerm.templates.itemsHintForm':
'Each rule picks a dimension (org / data scope / biz tag / secret / filter). Fill the form — no JSON. Use presets for common job roles.',
'Each rule is one dimension. Use a preset if unsure, then tweak.',
'system.dataPerm.templates.itemsEmptyHint':
'Unsure? Start from the “Sales staff” preset, then tweak for your job role',
'Start from “Sales staff”, then tweak for the job',
'system.dataPerm.templates.itemIndex': 'Rule {index}',
'system.dataPerm.templates.addExample': 'Generate from preset',
'system.dataPerm.templates.exampleAdded': 'Added example "{name}"',
@ -1814,8 +1890,9 @@ export default {
'system.dataPerm.templates.deleteSuccess': 'Deleted',
'system.dataPerm.templates.builtinDeleteDenied': 'Built-in templates cannot be deleted',
'system.dataPerm.templates.deleteConfirm': 'Delete template "{name}"?',
'system.dataPerm.templates.tab.basic': 'Basics',
'system.dataPerm.templates.tab.items': 'Rules',
'system.dataPerm.templates.tab.basic': '① Identity',
'system.dataPerm.templates.tab.items': '② Rules',
'system.dataPerm.templates.tab.apply': '③ Apply',
'system.dataPerm.templates.itemsHint': 'Each row is a JSON config for one permission dimension',
'system.dataPerm.templates.itemsEmpty': 'No permission rules yet',
'system.dataPerm.templates.jsonPreset': 'JSON preset',
@ -2938,9 +3015,15 @@ export default {
'order.placeOrder.batch.addressTip': 'Choose sender here, not in Excel.',
'order.placeOrder.batch.block.noSender': 'Please select a default sender address',
'order.placeOrder.batchOrder': 'Batch order',
'order.placeOrder.batchOrderBadge': 'Excel',
'order.placeOrder.batchTip.title': 'Placing many orders?',
'order.placeOrder.batchTip.desc': 'Import an Excel file to place them in batch.',
'order.placeOrder.batchTip.action': 'Go to batch order',
'order.placeOrder.batchTip.dismiss': 'Got it',
'order.placeOrder.fromPriceCheck.filled':
'Quote details applied. Continue with recipient info.',
'order.placeOrder.fromPriceCheck.bannerTitle': 'Details carried over from price check',
'order.placeOrder.fromPriceCheck.headerTip': 'Please finish recipient and declaration details',
'order.placeOrder.fromPriceCheck.filledLabel': 'Applied:',
'order.placeOrder.fromPriceCheck.pendingLabel': 'Still needed:',
'order.placeOrder.fromPriceCheck.item.product': 'Shipping method',
@ -2948,7 +3031,7 @@ export default {
'order.placeOrder.fromPriceCheck.item.warehouse': 'Warehouse',
'order.placeOrder.fromPriceCheck.item.weight': 'Weight',
'order.placeOrder.fromPriceCheck.item.dimensions': 'Dimensions',
'order.placeOrder.fromPriceCheck.item.destCountry': 'Destination destCountry',
'order.placeOrder.fromPriceCheck.item.destCountry': 'Destination country',
'order.placeOrder.fromPriceCheck.item.zip': 'Postal code',
'order.placeOrder.fromPriceCheck.item.clientNo': 'Customer order No.',
'order.placeOrder.fromPriceCheck.item.receiverName': 'Recipient name',
@ -3527,8 +3610,18 @@ export default {
'system.role.actions.edit': 'Edit',
'system.role.actions.delete': 'Delete',
'system.role.actions.save': 'Save',
'system.role.actions.saveDirty': 'Save (unsaved)',
'system.role.emptySelect': 'Select a role on the left, or click Add',
'system.role.emptyDesc': 'Edit basic info and assign permissions after selecting a role',
'system.role.emptyDesc': 'Fill basic info, then assign menu permissions; save at top-right',
'system.role.section.identity': 'Role identity',
'system.role.section.identityHint':
'Name for display; code cannot change after create; optional default warehouse',
'system.role.flow.goPermTitle': 'Next: assign permissions',
'system.role.flow.goPermDesc': 'Pick menus and buttons for this role, then save at top-right',
'system.role.flow.goPermBtn': 'Assign permissions',
'system.role.tag.dirty': 'Unsaved',
'system.role.tag.admin': 'Full admin access',
'system.role.permission.noAssignRight': 'No permission to assign',
'system.role.pageTitle': 'Role management',
'system.role.tab.info': 'Basic info',
'system.role.loading': 'Loading roles...',
@ -5508,6 +5601,9 @@ export default {
'channel.labelDesign.resetSuccess': 'Config reset',
'channel.labelDesign.searchPlaceholder': 'Search by name',
'channel.labelDesign.typePlaceholder': 'Template type',
'channel.labelDesign.typeFilterAll': 'All types',
'channel.labelDesign.listEmpty': 'No templates',
'channel.labelDesign.updatedAt': 'Updated: {time}',
'channel.labelDesign.namePlaceholder': 'Template name',
'channel.labelDesign.loadingDesigner': 'Loading designer…',
'channel.labelDesign.total': '{n} total',
@ -5531,11 +5627,18 @@ export default {
'channel.labelDesign.actions.startDesign': 'Start design',
'channel.labelDesign.actions.confirm': 'OK',
'channel.labelDesign.actions.cancel': 'Cancel',
'channel.labelDesign.actions.collapseSidebar': 'Collapse template list',
'channel.labelDesign.actions.expandSidebar': 'Expand template list',
'channel.labelDesign.loadingList': 'Loading templates…',
'channel.labelDesign.emptySelect': 'Select a template on the left, or create one',
'channel.labelDesign.untitled': 'Untitled template',
'channel.labelDesign.unsaved': 'Unsaved',
'channel.labelDesign.componentPanelTitle': 'Fields & components',
'channel.labelDesign.modal.deleteConfirm': 'Delete template "{name}"? This cannot be undone.',
'channel.labelDesign.openModal.title': 'Open system template',
'channel.labelDesign.openModal.confirmTitle': 'Switch template',
'channel.labelDesign.openModal.confirmContent': 'Unsaved canvas changes will be lost. Open the selected template?',
'channel.labelDesign.openModal.confirmTitle': 'Unsaved changes',
'channel.labelDesign.openModal.confirmContent': 'You have unsaved canvas changes. Continue and discard them?',
'channel.labelDesign.openModal.leaveContent': 'You have unsaved canvas changes. Leave this page and discard them?',
'channel.labelDesign.message.loadFailed': 'Failed to load templates',
'channel.labelDesign.message.saveSuccess': 'Template saved',
'channel.labelDesign.message.saveFailed': 'Save failed',

View File

@ -1431,6 +1431,8 @@ export default {
'system.aiSkills.refresh': '刷新',
'system.aiSkills.create': '新建',
'system.aiSkills.sceneFilter': '按场景筛选',
'system.aiSkills.searchPlaceholder': '搜索名称或 Skill Key',
'system.aiSkills.listEmpty': '暂无 Skill',
'system.aiSkills.selectHint': '请选择左侧 Skill,或点击新建',
'system.aiSkills.editTitle': '编辑 Skill',
'system.aiSkills.createTitle': '新建 Skill',
@ -1440,9 +1442,15 @@ export default {
'system.aiSkills.description': '简介',
'system.aiSkills.sortOrder': '排序',
'system.aiSkills.content': '正文(发给模型)',
'system.aiSkills.contentPlaceholder': '在此编写发给模型的提示词 / 规范…',
'system.aiSkills.save': '保存',
'system.aiSkills.delete': '删除',
'system.aiSkills.cancel': '取消',
'system.aiSkills.unsaved': '未保存',
'system.aiSkills.unsavedTitle': '未保存的修改',
'system.aiSkills.unsavedContent': '当前 Skill 有未保存的修改,继续将丢弃这些改动。',
'system.aiSkills.unsavedLeave': '当前 Skill 有未保存的修改,离开页面将丢弃这些改动。',
'system.aiSkills.discard': '放弃修改',
'system.aiSkills.saveOk': '已保存',
'system.aiSkills.saveFail': '保存失败',
'system.aiSkills.loadFail': '加载失败',
@ -1457,10 +1465,22 @@ export default {
'system.mcpTools.pageDesc': '管理轻量 MCP 工具:查价格、查渠道对客说明、查轨迹。可启用/试跑,并用 AI Agent 联调。',
'system.mcpTools.refresh': '刷新',
'system.mcpTools.searchPlaceholder': '搜索名称或 Tool Key',
'system.mcpTools.listEmpty': '暂无工具',
'system.mcpTools.tabConfig': '配置',
'system.mcpTools.tabTest': '试跑',
'system.mcpTools.tabAgent': 'AI Agent',
'system.mcpTools.displayName': '显示名称',
'system.mcpTools.description': '描述(给 AI 看)',
'system.mcpTools.descriptionPlaceholder': '描述用途与参数,供模型选择工具时参考…',
'system.mcpTools.sortOrder': '排序',
'system.mcpTools.save': '保存',
'system.mcpTools.cancel': '取消',
'system.mcpTools.unsaved': '未保存',
'system.mcpTools.unsavedTitle': '未保存的修改',
'system.mcpTools.unsavedContent': '当前工具有未保存的修改,继续将丢弃这些改动。',
'system.mcpTools.unsavedLeave': '当前工具有未保存的修改,离开页面将丢弃这些改动。',
'system.mcpTools.discard': '放弃修改',
'system.mcpTools.saveOk': '已保存',
'system.mcpTools.saveFail': '保存失败',
'system.mcpTools.loadFail': '加载失败',
@ -2792,8 +2812,14 @@ export default {
'order.placeOrder.batch.addressTip': '发件人在此选择,不必写入 Excel。',
'order.placeOrder.batch.block.noSender': '请选择默认发件地址',
'order.placeOrder.batchOrder': '批量下单',
'order.placeOrder.batchOrderBadge': 'Excel',
'order.placeOrder.batchTip.title': '一次要下很多单?',
'order.placeOrder.batchTip.desc': '可用 Excel 批量导入,更快完成下单。',
'order.placeOrder.batchTip.action': '去批量下单',
'order.placeOrder.batchTip.dismiss': '知道了',
'order.placeOrder.fromPriceCheck.filled': '已带入查价所选渠道与包裹信息,请继续完善收件人',
'order.placeOrder.fromPriceCheck.bannerTitle': '已从查价带入部分信息',
'order.placeOrder.fromPriceCheck.headerTip': '请继续完善收件与申报等信息',
'order.placeOrder.fromPriceCheck.filledLabel': '已带入:',
'order.placeOrder.fromPriceCheck.pendingLabel': '请继续填写:',
'order.placeOrder.fromPriceCheck.item.product': '运输方式',
@ -3382,8 +3408,17 @@ export default {
'system.role.actions.edit': '修改',
'system.role.actions.delete': '删除',
'system.role.actions.save': '保存',
'system.role.actions.saveDirty': '保存(有改动)',
'system.role.emptySelect': '请从左侧选择角色,或点击新增',
'system.role.emptyDesc': '选择角色后可编辑基本信息与分配功能权限',
'system.role.emptyDesc': '先填基本信息,再分配菜单权限;右上角统一保存',
'system.role.section.identity': '角色身份',
'system.role.section.identityHint': '名称用于辨认,编码创建后不可改;可绑定默认仓库',
'system.role.flow.goPermTitle': '下一步:分配菜单权限',
'system.role.flow.goPermDesc': '勾选该角色可用的菜单与按钮,改完点右上角保存',
'system.role.flow.goPermBtn': '去分配权限',
'system.role.tag.dirty': '未保存',
'system.role.tag.admin': '超管全量权限',
'system.role.permission.noAssignRight': '当前账号无分配权限',
'system.role.pageTitle': '角色管理',
'system.role.tab.info': '基本信息',
'system.role.loading': '正在加载角色列表...',
@ -3845,13 +3880,15 @@ export default {
'system.dict.actions.batchExport': '批量导出',
'system.dataPerm.users.title': '用户数据权限',
'system.dataPerm.users.desc': '配置内部用户直配五维权限;运行时 = 角色继承 ∪ 用户直配',
'system.dataPerm.users.desc': '优先套用岗位模板;本页只做个人例外直配。运行时 = 角色继承 ∪ 用户直配',
'system.dataPerm.users.loading': '正在加载用户列表...',
'system.dataPerm.users.emptySelect': '请从左侧选择用户',
'system.dataPerm.users.emptyDesc': '选择内部用户后,可配置组织、数据范围、业务标签、密级与自定义过滤五维权限',
'system.dataPerm.users.emptyDesc':
'推荐:先在「权限模板」配岗位规则并套用;本页查看生效范围,必要时再改个人例外',
'system.dataPerm.panel.primaryOrg': '主归属组织',
'system.dataPerm.panel.configType': '配置类型',
'system.dataPerm.panel.configTypeDirect': '用户直配',
'system.dataPerm.panel.configTypeException': '个人例外',
'system.dataPerm.panel.previewModule': '预览模块',
'system.dataPerm.panel.cannotEditSelf': '不能修改自己的数据权限',
'system.dataPerm.panel.stat.total': '直配项',
@ -3861,11 +3898,55 @@ export default {
'system.dataPerm.panel.tab.secret': '密级',
'system.dataPerm.panel.tab.filter': '自定义过滤',
'system.dataPerm.panel.tabsAria': '数据权限维度',
'system.dataPerm.panel.save': '保存权限',
'system.dataPerm.panel.saveDirty': '保存权限(有改动)',
'system.dataPerm.panel.saveSuccess': '权限已保存',
'system.dataPerm.panel.dirtyTag': '未保存',
'system.dataPerm.panel.quickTitle': '快速配置',
'system.dataPerm.panel.quickHint':
'优先「套用模板」或点选场景;场景写入订单范围/密级,组织与业务标签在高级里补',
'system.dataPerm.panel.exceptionNote': '本页直配是例外;日常岗位请走模板',
'system.dataPerm.panel.advancedTitle': '高级:五维明细(例外)',
'system.dataPerm.panel.advancedHint':
'模板/场景不够时再展开。标「未接入」的模块当前不会过滤业务列表',
'system.dataPerm.scenario.label': '常用场景(改完请点右上角保存)',
'system.dataPerm.scenario.personal': '只看自己的单',
'system.dataPerm.scenario.personalDesc': '个人级 + 公开/内部',
'system.dataPerm.scenario.department': '看本部门订单',
'system.dataPerm.scenario.departmentDesc': '部门级 + 密级 1-3',
'system.dataPerm.scenario.orgTree': '看本组织树',
'system.dataPerm.scenario.orgTreeDesc': '组织树级 + 密级 1-3',
'system.dataPerm.scenario.global': '全局订单(慎用)',
'system.dataPerm.scenario.globalDesc': '全局级 + 全部密级',
'system.dataPerm.scenario.applied': '已套用「{name}」,请点右上角保存',
'system.dataPerm.scenario.confirmTitle': '覆盖现有范围/密级?',
'system.dataPerm.scenario.confirmContent': '将替换当前「数据范围」与「密级」直配,组织与业务标签不变',
'system.dataPerm.banner.title': '当前生效范围',
'system.dataPerm.banner.hint': '含角色继承与用户直配合并结果;订单模块可抽样预览可见量',
'system.dataPerm.banner.admin': '超级管理员,无数据限制',
'system.dataPerm.banner.noOrgLimit': '无组织限制',
'system.dataPerm.banner.orgMore': '等 {count} 个',
'system.dataPerm.banner.bizUnlimited': '不限制',
'system.dataPerm.banner.bizCount': '{count} 类标签',
'system.dataPerm.banner.previewOrders': '预览可见订单',
'system.dataPerm.banner.previewResult': '可见约 {count} 单(抽样)',
'system.dataPerm.banner.previewAdminNote': '管理员跳过过滤',
'system.dataPerm.banner.previewEmpty': '当前范围下暂无订单',
'system.dataPerm.resource.enforced': '已接入',
'system.dataPerm.resource.notEnforced': '未接入业务过滤',
'system.dataPerm.resource.notEnforcedHint':
'该模块尚未在业务列表落地过滤,配置仅预留,不会改变当前可见数据',
'system.dataPerm.filter.tip': '条件之间为 AND;字段与算子已中文化,保存时后端校验白名单',
'system.dataPerm.filter.addCondition': '添加条件',
'system.dataPerm.filter.andHint': '条件之间 AND',
'system.dataPerm.filter.empty': '暂无过滤条件',
'system.dataPerm.filter.field': '字段',
'system.dataPerm.filter.valuePlaceholder': '值(属于/介于 用逗号分隔)',
'system.dataPerm.audit.tabsAria': '审计日志类型',
'system.dataPerm.audit.tab.change': '配置变更日志',
'system.dataPerm.audit.tab.access': '数据访问日志',
'system.dataPerm.audit.accessTip':
'P1 后端暂不自动写入访问日志;本页为预留查询界面,待内审需求启用后再对接。',
'已落地采样写入:订单/财务列表约 10%、导出 100%。仅内部账号(已套用数据权限)会产生记录;可按用户 GUID、模块与时间筛选。',
'system.dataPerm.audit.targetType': '目标类型',
'system.dataPerm.audit.targetId': '目标 ID',
'system.dataPerm.audit.userId': '用户 GUID',
@ -3880,6 +3961,7 @@ export default {
'system.dataPerm.audit.col.targetId': '目标 ID',
'system.dataPerm.audit.col.action': '动作',
'system.dataPerm.audit.col.operatorMapId': '操作人 mapId',
'system.dataPerm.audit.col.userId': '用户 GUID',
'system.dataPerm.audit.col.module': '模块',
'system.dataPerm.audit.col.api': '接口',
'system.dataPerm.audit.col.rowCount': '行数',
@ -3903,18 +3985,21 @@ export default {
'system.dataPerm.templates.field.bindRolePlaceholder': '选择要打标的 RBAC 角色(可空)',
'system.dataPerm.templates.field.bindRoleExtra':
'只是给模板打上「属于哪个岗位」的标签,不会自动改权限;真正生效请用下方 A / B 操作',
'system.dataPerm.templates.section.identity': '① 模板是什么',
'system.dataPerm.templates.section.identityHint': '先起好名称和编码,方便在左侧列表里辨认;保存前可先去配置规则',
'system.dataPerm.templates.section.bindApply': '③ 关联角色并套用(保存后才能生效)',
'system.dataPerm.templates.section.identity': '模板身份',
'system.dataPerm.templates.section.identityHint': '名称用于列表辨认,编码保存后尽量不要改',
'system.dataPerm.templates.section.bindApply': '关联角色并套用',
'system.dataPerm.templates.section.applyNow': '立即生效',
'system.dataPerm.templates.bindApplyHint':
'关联角色 ≠ 已授权。请先保存模板并配好「权限规则」,再选 A 写入角色,或选 B 套用到具体用户。',
'关联角色只是打标。要生效请「写入角色」或「套用到用户」(需先保存模板)。',
'system.dataPerm.templates.flow.step1': '填身份',
'system.dataPerm.templates.flow.step2': '配规则',
'system.dataPerm.templates.flow.step3': '套用生效',
'system.dataPerm.templates.flow.goItemsTitle': '下一步:配置权限规则',
'system.dataPerm.templates.flow.goItemsDesc': '规则决定「能看哪些组织 / 数据范围 / 密级」等,配完再回来套用',
'system.dataPerm.templates.flow.goItemsTitle': '下一步:配置规则',
'system.dataPerm.templates.flow.goItemsDesc': '配好范围与密级后再去套用',
'system.dataPerm.templates.flow.goItemsBtn': '去配置规则',
'system.dataPerm.templates.flow.goApplyTitle': '下一步:套用',
'system.dataPerm.templates.flow.goApplyDesc': '写入关联角色,或批量套到指定用户',
'system.dataPerm.templates.flow.goApplyBtn': '去套用',
'system.dataPerm.templates.applyToRole': 'A. 同步到关联角色',
'system.dataPerm.templates.applyToRoleDesc': '把当前规则写入该角色的数据权限(覆盖角色上原有直配)',
'system.dataPerm.templates.applyToRoleBtn': '写入角色权限',
@ -3947,13 +4032,14 @@ export default {
'system.dataPerm.templates.deleteSuccess': '删除成功',
'system.dataPerm.templates.builtinDeleteDenied': '内置模板不可删除',
'system.dataPerm.templates.deleteConfirm': '确定删除模板「{name}」?',
'system.dataPerm.templates.tab.basic': '基本信息',
'system.dataPerm.templates.tab.items': '权限规则',
'system.dataPerm.templates.itemsGuideTitle': '② 权限规则怎么配',
'system.dataPerm.templates.itemsHint': '每条明细对应一个维度的权限 JSON 配置',
'system.dataPerm.templates.tab.basic': '① 身份',
'system.dataPerm.templates.tab.items': '② 规则',
'system.dataPerm.templates.tab.apply': '③ 套用',
'system.dataPerm.templates.itemsGuideTitle': '权限规则',
'system.dataPerm.templates.itemsHint': '每条明细对应一个维度的权限配置',
'system.dataPerm.templates.itemsHintForm':
'每条规则选一种维度(组织 / 数据范围 / 业务标签 / 密级 / 过滤),填表即可,不用写 JSON。可先用「示例配置」一键生成常用岗位。',
'system.dataPerm.templates.itemsEmptyHint': '不会配时可先点「普通销售」示例,再按实际岗位微调',
'每条选一个维度填表;不会配可先用「示例」生成岗位规则再改。',
'system.dataPerm.templates.itemsEmptyHint': '可先点「普通销售」示例,再按岗位微调',
'system.dataPerm.templates.itemIndex': '规则 {index}',
'system.dataPerm.templates.addExample': '用示例快速生成',
'system.dataPerm.templates.exampleAdded': '已添加示例「{name}」',
@ -4686,6 +4772,7 @@ export default {
'system.announcement.actions.view': '查看',
'system.announcement.actions.delete': '删除',
'system.announcement.actions.readConfirm': '确认已读',
'system.announcement.actions.clearUnread': '一键清扫未读',
'system.announcement.actions.openApproval': '打开审批单',
'system.announcement.messageType.inform': '通知',
'system.announcement.messageType.message': '消息',
@ -4755,11 +4842,15 @@ export default {
'system.announcement.message.addSuccess': '新增成功',
'system.announcement.message.editSuccess': '编辑成功',
'system.announcement.message.readSuccess': '已确认已读',
'system.announcement.message.clearUnreadSuccess': '已清扫 {count} 条未读',
'system.announcement.message.clearUnreadEmpty': '当前没有未读站内信',
'system.announcement.message.cannotEditSent': '已发送的消息不能修改',
'system.announcement.message.selectDataToDelete': '请选择要删除的数据',
'system.announcement.message.deleteSuccess': '删除成功',
'system.announcement.message.deleteFailed': '删除失败',
'system.announcement.modal.deleteConfirmTitle': '温馨提示',
'system.announcement.modal.clearUnreadTitle': '一键清扫未读',
'system.announcement.modal.clearUnreadContent': '将当前账号可见的未读站内信全部标记为已读,是否继续?',
'system.announcement.modal.deleteConfirmContentSingle': '确定删除【{subject}】信息吗?',
'system.announcement.modal.deleteConfirmContentBatch': '确定删除所选 {count} 条信息吗?',
@ -5528,6 +5619,9 @@ export default {
'channel.labelDesign.resetSuccess': '配置已重置',
'channel.labelDesign.searchPlaceholder': '搜索模板名称',
'channel.labelDesign.typePlaceholder': '模板类型',
'channel.labelDesign.typeFilterAll': '全部类型',
'channel.labelDesign.listEmpty': '暂无模板',
'channel.labelDesign.updatedAt': '修改:{time}',
'channel.labelDesign.namePlaceholder': '模板名称',
'channel.labelDesign.loadingDesigner': '正在加载设计器…',
'channel.labelDesign.total': '共 {n} 条',
@ -5551,11 +5645,18 @@ export default {
'channel.labelDesign.actions.startDesign': '开始设计',
'channel.labelDesign.actions.confirm': '确定',
'channel.labelDesign.actions.cancel': '取消',
'channel.labelDesign.actions.collapseSidebar': '收起模板列表',
'channel.labelDesign.actions.expandSidebar': '展开模板列表',
'channel.labelDesign.loadingList': '正在加载模板…',
'channel.labelDesign.emptySelect': '请在左侧选择模板,或新建一个',
'channel.labelDesign.untitled': '未命名模板',
'channel.labelDesign.unsaved': '未保存',
'channel.labelDesign.componentPanelTitle': '字段与组件',
'channel.labelDesign.modal.deleteConfirm': '确定删除模板「{name}」?删除后不可恢复。',
'channel.labelDesign.openModal.title': '打开系统模板',
'channel.labelDesign.openModal.confirmTitle': '切换模板',
'channel.labelDesign.openModal.confirmContent': '当前画布未保存的修改将丢失,确定打开所选模板?',
'channel.labelDesign.openModal.confirmTitle': '未保存的修改',
'channel.labelDesign.openModal.confirmContent': '当前画布有未保存的修改,继续将丢失这些改动,是否继续?',
'channel.labelDesign.openModal.leaveContent': '当前画布有未保存的修改,离开页面将丢失这些改动,是否离开?',
'channel.labelDesign.message.loadFailed': '加载模板失败',
'channel.labelDesign.message.saveSuccess': '模板已保存',
'channel.labelDesign.message.saveFailed': '保存失败',

View File

@ -35,12 +35,11 @@
import { systemInterfaceColumns } from './models/tableColumns';
import CustomLeftMenu from '@/components/CustomLeftMenu/index.vue';
import SlidingTabs from '@/components/SlidingTabs/index.vue';
/** 中间映射栏进页即展示,同步引入,避免异步分包造成「后加载」空白 */
import MapServiceProvider from './components/map-service-provider.vue';
/** 明细含 InterfaceDetail(~200KB)、调试含 CodeMirror:按需分包,避免进页就解析 */
const EnteredMap = defineAsyncComponent(() => import('./components/EnteredMap.vue'));
const MapServiceProvider = defineAsyncComponent(
() => import('./components/map-service-provider.vue'),
);
const ApiDebugger = defineAsyncComponent(() => import('./components/ApiDebugger.vue'));
const UpstreamInterfaceModal = defineAsyncComponent(
() => import('./components/UpstreamInterfaceModal.vue'),

View File

@ -4,6 +4,7 @@ import { computed, nextTick, onMounted, reactive, ref } from 'vue'
import { useI18n } from 'vue-i18n'
import { $baseMessage } from '@/utils'
import HandsontablePro from '@/components/HandsontablePro/index.vue'
import PaginationPro from '@/components/PaginationPro/index.vue'
import { useTableContainerHeight } from '@/composables/useTableContainerHeight'
import ModalPro from '@/components/ModalPro/index.vue'
import useModal from '@/components/ModalPro/useModal'
@ -566,32 +567,13 @@ onMounted(async () => {
</div>
</div>
<div class="toolbar-right">
<div class="pagination-controls">
<span class="total-records">{{ t('channel.issueTemplate.pagination.total', { count: totalCount }) }}</span>
<a-button size="small" :disabled="currentPage <= 1" @click="handlePageChange(currentPage - 1)">
{{ t('channel.issueTemplate.pagination.prev') }}
</a-button>
<span class="current-page">{{ currentPage }}</span>
<a-button
size="small"
:disabled="currentPage * pageSize >= totalCount"
@click="handlePageChange(currentPage + 1)"
>
{{ t('channel.issueTemplate.pagination.next') }}
</a-button>
<a-select
:model-value="pageSize"
size="small"
style="width: 88px"
:options="[
{ label: '10', value: 10 },
{ label: '30', value: 30 },
{ label: '50', value: 50 },
{ label: '100', value: 100 },
]"
@change="handlePageSizeChange"
/>
</div>
<PaginationPro
:total-count="totalCount"
v-model:current-page="currentPage"
v-model:page-size="pageSize"
@page-change="handlePageChange"
@page-size-change="handlePageSizeChange"
/>
</div>
</div>

View File

@ -11,7 +11,13 @@
:initial-template="initialTemplate"
@save="onDesignerSave"
>
<template #headerLeft></template>
<template #headerLeft>
<div class="ld-editing-meta">
<span class="ld-editing-name">{{ props.name || t('channel.labelDesign.untitled') }}</span>
<span v-if="props.templateTypeLabel" class="ld-editing-type">{{ props.templateTypeLabel }}</span>
<span v-if="dirtyHint" class="ld-editing-dirty">{{ t('channel.labelDesign.unsaved') }}</span>
</div>
</template>
<template #headerRight></template>
</component>
</a-spin>
@ -20,7 +26,16 @@
</template>
<script lang="ts" setup>
import { getCurrentInstance, nextTick, onBeforeUnmount, onMounted, shallowRef, ref } from 'vue'
import {
computed,
getCurrentInstance,
nextTick,
onBeforeUnmount,
onMounted,
shallowRef,
ref,
watch,
} from 'vue'
import { useI18n } from 'vue-i18n'
import { Message } from '@arco-design/web-vue'
import { ensureElementPlusForPrint } from '@/plugins/elementPlusForPrint'
@ -35,11 +50,13 @@ const props = defineProps<{
templateId?: number
name?: string
templateType?: string
templateTypeLabel?: string
templateJson?: unknown
}>()
const emit = defineEmits<{
(e: 'saved', payload: { id: number }): void
(e: 'dirty-change', dirty: boolean): void
}>()
const { t } = useI18n()
@ -56,6 +73,22 @@ const ready = ref(false)
const editingId = ref(0)
const fieldGroups = ref<LabelFieldGroup[]>([])
const fieldsInjected = ref(false)
const baselineJson = ref<string | null>(null)
const dirtyHint = ref(false)
let dirtyPollTimer: ReturnType<typeof setInterval> | null = null
let baselineTimer: ReturnType<typeof setTimeout> | null = null
/** 按模板类型收口字段分组,避免无关字段刷屏 */
const TYPE_FIELD_GROUPS: Record<string, string[]> = {
lastMile: ['numbers', 'product', 'recipient', 'weight', 'system'],
customer: ['numbers', 'product', 'recipient', 'weight', 'system'],
outbound: ['numbers', 'product', 'weight', 'system'],
inbound: ['inboundBox', 'system'],
box: ['inboundBox', 'system'],
sku: ['warehouseSku', 'system'],
shipBag: ['shipBag', 'system'],
shipMaster: ['shipMaster', 'system'],
}
const EMPTY_LABEL_TEMPLATE = {
panels: [
@ -140,10 +173,95 @@ const MOCK_BY_FIELD: Record<string, string> = {
function groupPanelTitle(g: LabelFieldGroup): string {
if (g.code === 'inboundBox') return '入库预报'
if (g.code === 'warehouseSku') return '库内SKU'
if (g.code === 'shipBag') return '出库大包'
if (g.code === 'shipMaster') return '内部主单'
if (g.code === 'system') return '系统'
return `订单·${g.title}`
}
function filterGroupsByTemplateType(groups: LabelFieldGroup[], templateType?: string) {
const type = templateType || 'lastMile'
const allowed = TYPE_FIELD_GROUPS[type]
if (!allowed?.length) return groups
const allowSet = new Set(allowed)
return groups.filter((g) => allowSet.has(g.code))
}
const activeFieldGroups = computed(() =>
filterGroupsByTemplateType(fieldGroups.value, props.templateType),
)
function stableStringify(value: unknown) {
try {
return JSON.stringify(value)
} catch {
return null
}
}
function readDesignerJson(): unknown | null {
const d = designerRef.value as any
if (!d) return null
try {
if (typeof d.getJson === 'function') return d.getJson()
if (typeof d.hiprintTemplate?.getJson === 'function') return d.hiprintTemplate.getJson()
if (typeof d.template?.getJson === 'function') return d.template.getJson()
} catch {
/* ignore */
}
return null
}
function captureBaseline() {
const raw = readDesignerJson()
const text = stableStringify(raw)
if (!text) return
baselineJson.value = text
setDirty(false)
}
function setDirty(next: boolean) {
if (dirtyHint.value === next) return
dirtyHint.value = next
emit('dirty-change', next)
}
function refreshDirtyState() {
if (baselineJson.value == null) return
const text = stableStringify(readDesignerJson())
if (!text) return
setDirty(text !== baselineJson.value)
}
function isDirty() {
if (baselineJson.value == null) return dirtyHint.value
const text = stableStringify(readDesignerJson())
if (!text) return dirtyHint.value
return text !== baselineJson.value
}
function markClean() {
captureBaseline()
}
function startDirtyWatch() {
stopDirtyWatch()
dirtyPollTimer = setInterval(refreshDirtyState, 1200)
bodyRef.value?.addEventListener('mouseup', refreshDirtyState)
bodyRef.value?.addEventListener('keyup', refreshDirtyState)
}
function stopDirtyWatch() {
if (dirtyPollTimer) {
clearInterval(dirtyPollTimer)
dirtyPollTimer = null
}
bodyRef.value?.removeEventListener('mouseup', refreshDirtyState)
bodyRef.value?.removeEventListener('keyup', refreshDirtyState)
}
defineExpose({ isDirty, markClean })
let hiprintRegistered = false
let injectTimer: ReturnType<typeof setTimeout> | null = null
let injectAttempts = 0
@ -321,7 +439,7 @@ function stripBuiltinTemplates() {
}
}
/** 去掉自带「平台」「自定义」分组,保留表格/辅助 */
/** 去掉自带「平台」「自定义」及冷门组件,保留表格/辅助基础项 */
function removeBuiltinGroups(host: Element) {
host.querySelectorAll('ul.hiprint-printElement-type > li').forEach((li) => {
if (
@ -339,10 +457,52 @@ function removeBuiltinGroups(host: Element) {
/^custom$/i.test(title)
) {
li.remove()
return
}
li.querySelectorAll('a.ep-draggable-item').forEach((a) => {
const tid = (a.getAttribute('tid') || '').toLowerCase()
const text = (a.textContent || '').trim().toLowerCase()
if (
tid.includes('e2table') ||
tid.includes('w2html') ||
text === 'e2table' ||
text === 'w2html'
) {
a.parentElement?.remove()
}
})
})
}
function retitleComponentPanel() {
const body = bodyRef.value
if (!body) return
const header = body.querySelector('.left-sider-header') as HTMLElement | null
if (!header) return
const label = t('channel.labelDesign.componentPanelTitle')
const textEl =
(header.querySelector('span, .title, .el-text') as HTMLElement | null) || header
if (textEl.childNodes.length === 1 && textEl.childNodes[0].nodeType === Node.TEXT_NODE) {
textEl.textContent = label
return
}
for (const node of Array.from(textEl.childNodes)) {
if (node.nodeType === Node.TEXT_NODE && node.textContent?.trim()) {
node.textContent = label
return
}
}
if (!header.querySelector('.ld-panel-title')) {
const span = document.createElement('span')
span.className = 'ld-panel-title'
span.textContent = label
header.insertBefore(span, header.firstChild)
} else {
;(header.querySelector('.ld-panel-title') as HTMLElement).textContent = label
}
}
function clearPreviousOmsDom(host: Element) {
host.querySelectorAll('ul.hiprint-printElement-type').forEach((ul) => {
const hasBuiltin = ul.querySelector('a.ep-draggable-item[tid^="taskProviderModule."]')
@ -403,7 +563,10 @@ function injectOmsFields(groups: LabelFieldGroup[]): boolean {
stripBuiltinTemplates()
fieldsInjected.value = true
watchEpHost(host, groups)
nextTick(() => fixLeftPanelScroll())
nextTick(() => {
fixLeftPanelScroll()
retitleComponentPanel()
})
return true
} catch (e) {
console.warn('[labelDesign] inject oms fields failed', e)
@ -441,13 +604,24 @@ function scheduleInject(groups: LabelFieldGroup[]) {
}
injectAttempts = 0
omsTypesRegistered = false
fieldsInjected.value = false
const tryInject = () => {
injectAttempts += 1
fixLeftPanelScroll()
if (injectOmsFields(groups)) return
retitleComponentPanel()
if (injectOmsFields(groups)) {
if (baselineTimer) clearTimeout(baselineTimer)
baselineTimer = setTimeout(() => {
captureBaseline()
startDirtyWatch()
}, 600)
return
}
if (injectAttempts >= 30) {
Message.warning(t('channel.labelDesign.fieldsInjectFailed'))
captureBaseline()
startDirtyWatch()
return
}
injectTimer = setTimeout(tryInject, 300)
@ -479,6 +653,7 @@ async function onDesignerSave(payload: { template: unknown; data: unknown }) {
})
editingId.value = Number(saved?.id ?? saved?.Id ?? editingId.value) || editingId.value
Message.success(t('channel.labelDesign.message.saveSuccess'))
markClean()
emit('saved', { id: editingId.value })
} catch (e: any) {
Message.error(e?.message || t('channel.labelDesign.message.saveFailed'))
@ -506,7 +681,7 @@ onMounted(async () => {
booting.value = false
nextTick(() => {
startPanelResizeWatch()
scheduleInject(fieldGroups.value)
scheduleInject(activeFieldGroups.value)
})
})
} catch (e: any) {
@ -515,11 +690,24 @@ onMounted(async () => {
}
})
watch(
() => props.templateType,
() => {
if (!ready.value || !fieldGroups.value.length) return
scheduleInject(activeFieldGroups.value)
},
)
onBeforeUnmount(() => {
if (injectTimer) {
clearTimeout(injectTimer)
injectTimer = null
}
if (baselineTimer) {
clearTimeout(baselineTimer)
baselineTimer = null
}
stopDirtyWatch()
if (hostObserver) {
hostObserver.disconnect()
hostObserver = null
@ -698,11 +886,44 @@ onBeforeUnmount(() => {
flex-direction: column;
}
.ld-designer__body :deep(.header-left),
.ld-designer__body :deep(.btn-feedback) {
display: none !important;
}
.ld-editing-meta {
display: inline-flex;
align-items: center;
gap: 8px;
max-width: min(420px, 40vw);
min-width: 0;
padding-left: 4px;
color: #fff;
}
.ld-editing-name {
font-size: 14px;
font-weight: 600;
overflow: hidden;
text-overflow: ellipsis;
white-space: nowrap;
}
.ld-editing-type {
flex-shrink: 0;
padding: 0 8px;
height: 22px;
line-height: 22px;
border-radius: 11px;
background: rgba(255, 255, 255, 0.18);
font-size: 12px;
}
.ld-editing-dirty {
flex-shrink: 0;
font-size: 12px;
opacity: 0.92;
}
.ld-designer__body :deep(.left-sider .el-tabs__header) {
display: none !important;
}

View File

@ -1,43 +1,87 @@
<template>
<div class="labelDesign-container">
<div class="left-sidebar">
<CustomLeftMenu
:tree-data="templateTreeData"
:selected-keys="selectedKeys"
v-model:expanded-keys="expandedKeys"
v-model:search-keyword="keyword"
:loading="loading"
:search-placeholder="$t('channel.labelDesign.searchPlaceholder')"
:refresh-title="$t('channel.labelDesign.actions.refresh')"
:add-title="$t('channel.labelDesign.actions.create')"
:loading-text="$t('channel.labelDesign.loadingList')"
:delete-label="$t('channel.labelDesign.actions.delete')"
:show-node-index="true"
:show-method="false"
:show-map-count="false"
:show-node-code="true"
:show-node-actions="true"
:hierarchical="true"
:page-size="30"
width="280px"
@search="loadList"
@refresh="loadList"
@add="openCreateModal"
@select="handleMenuSelect"
@delete-node="handleDeleteNode"
>
<template #node-menu="{ nodeData }">
<a-doption @click="openRenameModal(nodeData)">
<icon-edit />
{{ $t('channel.labelDesign.actions.editTemplate') }}
</a-doption>
<a-doption @click="handleDeleteNode(nodeData)">
<icon-delete />
{{ $t('channel.labelDesign.actions.delete') }}
</a-doption>
</template>
</CustomLeftMenu>
</div>
<div class="labelDesign-container" :class="{ 'is-sidebar-collapsed': sidebarCollapsed && designerReady }">
<aside class="left-sidebar" :class="{ 'is-collapsed': sidebarCollapsed && designerReady }">
<div v-show="!(sidebarCollapsed && designerReady)" class="tpl-panel">
<div class="tpl-panel__toolbar">
<a-input
v-model="keyword"
allow-clear
:placeholder="$t('channel.labelDesign.searchPlaceholder')"
@press-enter="loadList"
@clear="loadList"
/>
<a-button :title="$t('channel.labelDesign.actions.refresh')" @click="loadList">
<template #icon><icon-refresh /></template>
</a-button>
<a-button
class="app-btn-primary-soft"
:title="$t('channel.labelDesign.actions.create')"
@click="openCreateModal"
>
<template #icon><icon-plus /></template>
</a-button>
</div>
<div class="tpl-panel__meta">
{{ $t('channel.labelDesign.total', { n: rows.length }) }}
</div>
<a-spin :loading="loading" class="tpl-panel__spin">
<div v-if="!rows.length" class="tpl-panel__empty">
{{ $t('channel.labelDesign.listEmpty') }}
</div>
<ul v-else class="tpl-list">
<li
v-for="item in rows"
:key="item.id"
class="tpl-item"
:class="{ 'is-active': String(item.id) === selectedKey }"
@click="handleSelectTemplate(item)"
>
<div class="tpl-item__main">
<div class="tpl-item__name" :title="item.name">{{ item.name }}</div>
<div class="tpl-item__sub">
<span class="tpl-item__type">{{ typeLabel(item.templateType) }}</span>
<span v-if="item.updateTime" class="tpl-item__time">
{{ $t('channel.labelDesign.updatedAt', { time: formatTime(item.updateTime) }) }}
</span>
</div>
</div>
<a-dropdown trigger="click" position="br" @click.stop>
<a-button class="tpl-item__more" type="text" size="mini" @click.stop>
<template #icon><icon-more-vertical /></template>
</a-button>
<template #content>
<a-doption @click="openRenameModal(item)">
<icon-edit />
{{ $t('channel.labelDesign.actions.editTemplate') }}
</a-doption>
<a-doption class="tpl-item__danger" @click="handleDeleteTemplate(item)">
<icon-delete />
{{ $t('channel.labelDesign.actions.delete') }}
</a-doption>
</template>
</a-dropdown>
</li>
</ul>
</a-spin>
</div>
</aside>
<button
v-if="designerReady"
type="button"
class="sidebar-toggle"
:title="
sidebarCollapsed
? $t('channel.labelDesign.actions.expandSidebar')
: $t('channel.labelDesign.actions.collapseSidebar')
"
@click="sidebarCollapsed = !sidebarCollapsed"
>
<icon-left v-if="!sidebarCollapsed" />
<icon-right v-else />
</button>
<div class="right-panel">
<div v-if="!designerReady" class="ld-empty">
@ -50,12 +94,15 @@
<LabelDesignerPanel
v-else
:key="designerKey"
ref="designerPanelRef"
:visible="true"
:template-id="editing.id"
:name="editing.name"
:template-type="editing.templateType"
:template-type-label="typeLabel(editing.templateType)"
:template-json="editing.templateJson"
@saved="onSaved"
@dirty-change="onDirtyChange"
/>
</div>
@ -85,7 +132,7 @@
/>
</a-form-item>
<a-form-item field="templateType" :label="$t('channel.labelDesign.table.type')">
<a-select v-model="createForm.templateType">
<a-select v-model="createForm.templateType" @change="onCreateTypeChange">
<a-option v-for="opt in typeOptions" :key="opt.value" :value="opt.value">
{{ opt.label }}
</a-option>
@ -136,13 +183,21 @@
</template>
<script lang="ts" setup>
import { computed, defineAsyncComponent, onMounted, reactive, ref } from 'vue'
import { computed, defineAsyncComponent, onBeforeUnmount, onMounted, reactive, ref } from 'vue'
import { h } from 'vue'
import { onBeforeRouteLeave } from 'vue-router'
import { useI18n } from 'vue-i18n'
import dayjs from 'dayjs'
import { Modal, Message, Spin } from '@arco-design/web-vue'
import { IconDelete, IconEdit } from '@arco-design/web-vue/es/icon'
import CustomLeftMenu from '@/components/CustomLeftMenu/index.vue'
import type { CustomLeftMenuTreeNode } from '@/components/CustomLeftMenu/types'
import {
IconDelete,
IconEdit,
IconLeft,
IconMoreVertical,
IconPlus,
IconRefresh,
IconRight,
} from '@arco-design/web-vue/es/icon'
import {
deleteLabelTemplate,
getLabelTemplate,
@ -171,8 +226,8 @@ const LabelDesignerPanel = defineAsyncComponent({
const loading = ref(false)
const keyword = ref('')
const rows = ref<LabelTemplateListItem[]>([])
const selectedKeys = ref<string[]>([])
const expandedKeys = ref<string[]>([])
const selectedKey = ref('')
const sidebarCollapsed = ref(false)
const createModalVisible = ref(false)
const createForm = reactive({
name: '',
@ -192,6 +247,8 @@ const editing = reactive<{
}>({})
const designerReady = ref(false)
const designerKey = ref('idle')
const designerPanelRef = ref<{ isDirty?: () => boolean } | null>(null)
const canvasDirty = ref(false)
let selecting = false
const typeOptions = computed(() => [
@ -210,35 +267,45 @@ function typeLabel(type?: string) {
return hit?.label || type || '-'
}
const templateTreeData = computed<CustomLeftMenuTreeNode[]>(() => {
const groups = new Map<string, LabelTemplateListItem[]>()
for (const row of rows.value) {
const type = row.templateType || 'lastMile'
if (!groups.has(type)) groups.set(type, [])
groups.get(type)!.push(row)
function formatTime(value?: string) {
if (!value) return ''
const d = dayjs(value)
return d.isValid() ? d.format('YYYY-MM-DD HH:mm') : value
}
function defaultCreateName(templateType: string) {
const label = typeLabel(templateType).replace(/标签$/, '')
const stamp = new Date()
const y = stamp.getFullYear()
const m = String(stamp.getMonth() + 1).padStart(2, '0')
const d = String(stamp.getDate()).padStart(2, '0')
return `${label}-${y}${m}${d}`
}
function hasUnsavedChanges() {
if (!designerReady.value) return false
if (typeof designerPanelRef.value?.isDirty === 'function') {
return designerPanelRef.value.isDirty()
}
return canvasDirty.value
}
const orderedTypes = typeOptions.value.map((o) => o.value)
const typeKeys = [
...orderedTypes.filter((k) => groups.has(k)),
...[...groups.keys()].filter((k) => !orderedTypes.includes(k)),
]
function onDirtyChange(dirty: boolean) {
canvasDirty.value = dirty
}
return typeKeys.map((type) => ({
key: `type-${type}`,
title: typeLabel(type),
isLeaf: false,
children: (groups.get(type) || []).map((it) => ({
key: String(it.id),
title: it.name,
id: it.id,
name: it.name,
code: typeLabel(it.templateType),
isLeaf: true,
templateType: it.templateType,
})),
}))
})
function confirmLeaveIfDirty(onOk: () => void | Promise<void>, onCancel?: () => void) {
if (!hasUnsavedChanges()) {
void onOk()
return
}
Modal.confirm({
title: t('channel.labelDesign.openModal.confirmTitle'),
content: t('channel.labelDesign.openModal.confirmContent'),
onOk,
onCancel,
})
}
async function loadList() {
loading.value = true
@ -246,7 +313,6 @@ async function loadList() {
rows.value = await getLabelTemplateList({
keyword: keyword.value || undefined,
})
expandedKeys.value = templateTreeData.value.map((g) => g.key)
} catch (e: any) {
Message.error(e?.message || t('channel.labelDesign.message.loadFailed'))
rows.value = []
@ -255,9 +321,19 @@ async function loadList() {
}
}
function onCreateTypeChange(
value: string | number | boolean | Record<string, unknown> | (string | number | boolean | Record<string, unknown>)[],
) {
const type = String(value || 'lastMile')
createForm.templateType = type
if (!createForm.name?.trim() || /^(.+?)-\d{8}$/.test(createForm.name.trim())) {
createForm.name = defaultCreateName(type)
}
}
function openCreateModal() {
createForm.name = `label-${Date.now()}`
createForm.templateType = 'lastMile'
createForm.name = defaultCreateName(createForm.templateType)
createModalVisible.value = true
}
@ -267,13 +343,29 @@ function confirmCreate() {
Message.warning(t('channel.labelDesign.message.nameRequired'))
return false
}
editing.id = 0
editing.name = name
editing.templateType = createForm.templateType || 'lastMile'
editing.templateJson = undefined
selectedKeys.value = []
designerKey.value = `new-${Date.now()}`
designerReady.value = true
const start = () => {
editing.id = 0
editing.name = name
editing.templateType = createForm.templateType || 'lastMile'
editing.templateJson = undefined
selectedKey.value = ''
canvasDirty.value = false
designerKey.value = `new-${Date.now()}`
designerReady.value = true
sidebarCollapsed.value = false
}
if (designerReady.value && hasUnsavedChanges()) {
Modal.confirm({
title: t('channel.labelDesign.openModal.confirmTitle'),
content: t('channel.labelDesign.openModal.confirmContent'),
onOk: () => {
start()
createModalVisible.value = false
},
})
return false
}
start()
return true
}
@ -285,7 +377,8 @@ async function openTemplate(id: number) {
editing.name = detail.name
editing.templateType = detail.templateType || 'lastMile'
editing.templateJson = detail.templateJson
selectedKeys.value = [String(detail.id)]
selectedKey.value = String(detail.id)
canvasDirty.value = false
designerKey.value = `tpl-${detail.id}`
designerReady.value = true
} catch (e: any) {
@ -295,39 +388,28 @@ async function openTemplate(id: number) {
}
}
function handleMenuSelect(keys: string[]) {
function handleSelectTemplate(item: LabelTemplateListItem) {
if (selecting) return
const key = keys?.[0]
if (!key || key.startsWith('type-')) {
selectedKeys.value = editing.id ? [String(editing.id)] : []
const id = Number(item.id)
if (!id) return
if (id === editing.id) {
selectedKey.value = String(id)
return
}
const id = Number(key)
if (!id || id === editing.id) {
selectedKeys.value = [key]
return
}
if (designerReady.value) {
Modal.confirm({
title: t('channel.labelDesign.openModal.confirmTitle'),
content: t('channel.labelDesign.openModal.confirmContent'),
onOk: () => openTemplate(id),
onCancel: () => {
selectedKeys.value = editing.id ? [String(editing.id)] : []
},
})
return
}
openTemplate(id)
confirmLeaveIfDirty(
() => openTemplate(id),
() => {
selectedKey.value = editing.id ? String(editing.id) : ''
},
)
}
function openRenameModal(nodeData: any) {
const id = Number(nodeData?.id)
function openRenameModal(item: LabelTemplateListItem) {
const id = Number(item.id)
if (!id) return
renameForm.id = id
renameForm.name = String(nodeData?.name || nodeData?.title || '')
renameForm.templateType = String(nodeData?.templateType || 'lastMile')
renameForm.name = String(item.name || '')
renameForm.templateType = String(item.templateType || 'lastMile')
renameModalVisible.value = true
}
@ -365,13 +447,13 @@ async function confirmRename() {
}
}
function handleDeleteNode(nodeData: any) {
const id = Number(nodeData?.id)
const name = String(nodeData?.name || nodeData?.title || '')
function handleDeleteTemplate(item: LabelTemplateListItem) {
const id = Number(item.id)
const name = String(item.name || '')
if (!id) return
Modal.confirm({
title: t('channel.labelDesign.actions.delete'),
content: name,
content: t('channel.labelDesign.modal.deleteConfirm', { name }),
onOk: async () => {
await deleteLabelTemplate(id)
Message.success(t('channel.labelDesign.message.deleteSuccess'))
@ -380,8 +462,10 @@ function handleDeleteNode(nodeData: any) {
editing.id = undefined
editing.name = undefined
editing.templateJson = undefined
selectedKeys.value = []
selectedKey.value = ''
designerKey.value = 'idle'
canvasDirty.value = false
sidebarCollapsed.value = false
}
await loadList()
},
@ -389,20 +473,41 @@ function handleDeleteNode(nodeData: any) {
}
async function onSaved(payload?: { id?: number }) {
canvasDirty.value = false
await loadList()
const id = Number(payload?.id || editing.id || 0)
if (id > 0) {
editing.id = id
selectedKeys.value = [String(id)]
selectedKey.value = String(id)
}
}
onMounted(async () => {
await loadList()
const first = rows.value[0]
if (first) {
await openTemplate(first.id)
function onBeforeUnload(e: BeforeUnloadEvent) {
if (!hasUnsavedChanges()) return
e.preventDefault()
e.returnValue = ''
}
onBeforeRouteLeave((_to, _from, next) => {
if (!hasUnsavedChanges()) {
next()
return
}
Modal.confirm({
title: t('channel.labelDesign.openModal.confirmTitle'),
content: t('channel.labelDesign.openModal.leaveContent'),
onOk: () => next(),
onCancel: () => next(false),
})
})
onMounted(async () => {
window.addEventListener('beforeunload', onBeforeUnload)
await loadList()
})
onBeforeUnmount(() => {
window.removeEventListener('beforeunload', onBeforeUnload)
})
</script>
@ -413,8 +518,9 @@ onMounted(async () => {
flex: 1;
min-height: 0;
display: flex;
gap: 16px;
gap: 0;
overflow: hidden;
position: relative;
}
.left-sidebar {
@ -424,6 +530,181 @@ onMounted(async () => {
min-height: 0;
display: flex;
flex-direction: column;
margin-right: 16px;
transition: width 0.2s ease, margin 0.2s ease, opacity 0.2s ease;
&.is-collapsed {
width: 0;
margin-right: 0;
opacity: 0;
overflow: hidden;
pointer-events: none;
}
}
.tpl-panel {
flex: 1;
min-height: 0;
display: flex;
flex-direction: column;
background: #fff;
border-radius: 8px;
overflow: hidden;
box-sizing: border-box;
}
.tpl-panel__toolbar {
display: flex;
align-items: center;
gap: 8px;
padding: 12px 12px 0;
flex-shrink: 0;
.arco-input-wrapper {
flex: 1;
min-width: 0;
}
}
.tpl-panel__meta {
padding: 10px 12px 6px;
color: var(--color-text-3);
font-size: 12px;
flex-shrink: 0;
}
.tpl-panel__spin {
flex: 1;
min-height: 0;
display: flex;
flex-direction: column;
padding: 0 8px 12px;
:deep(.arco-spin-children) {
flex: 1;
min-height: 0;
display: flex;
flex-direction: column;
overflow: hidden;
}
}
.tpl-panel__empty {
flex: 1;
display: flex;
align-items: center;
justify-content: center;
color: var(--color-text-3);
font-size: 13px;
padding: 24px 8px;
}
.tpl-list {
list-style: none;
margin: 0;
padding: 0;
overflow: auto;
flex: 1;
min-height: 0;
}
.tpl-item {
display: flex;
align-items: flex-start;
gap: 4px;
padding: 10px 8px 10px 10px;
margin-bottom: 6px;
border-radius: 6px;
border: 1px solid transparent;
background: var(--color-fill-1, #f7f8fa);
cursor: pointer;
transition: background 0.15s ease, border-color 0.15s ease;
&:hover {
background: color-mix(in srgb, var(--app-primary-color) 6%, #fff);
}
&.is-active {
background: color-mix(in srgb, var(--app-primary-color) 10%, #fff);
border-color: color-mix(in srgb, var(--app-primary-color) 28%, transparent);
}
}
.tpl-item__main {
flex: 1;
min-width: 0;
}
.tpl-item__name {
font-size: 14px;
font-weight: 600;
color: var(--color-text-1);
line-height: 1.35;
overflow: hidden;
text-overflow: ellipsis;
white-space: nowrap;
}
.tpl-item__sub {
display: flex;
align-items: center;
justify-content: space-between;
gap: 8px;
margin-top: 4px;
line-height: 1.3;
}
.tpl-item__type,
.tpl-item__time {
font-size: 11px;
font-weight: 400;
color: var(--color-text-3);
line-height: 1.3;
}
.tpl-item__type {
overflow: hidden;
text-overflow: ellipsis;
white-space: nowrap;
min-width: 0;
}
.tpl-item__time {
flex-shrink: 0;
opacity: 0.85;
}
.tpl-item__more {
flex-shrink: 0;
color: var(--color-text-3);
margin-top: -2px;
}
.tpl-item__danger {
color: rgb(var(--danger-6));
}
.sidebar-toggle {
flex-shrink: 0;
align-self: center;
width: 20px;
height: 48px;
margin-right: 8px;
padding: 0;
border: 1px solid var(--color-border-2, #e5e6eb);
border-radius: 4px;
background: #fff;
color: var(--color-text-2);
cursor: pointer;
display: inline-flex;
align-items: center;
justify-content: center;
z-index: 2;
&:hover {
color: var(--app-primary-color);
border-color: color-mix(in srgb, var(--app-primary-color) 40%, transparent);
}
}
.right-panel {

View File

@ -299,117 +299,129 @@
<template>
<div class="ops-page bag-pack-page">
<div class="ops-col ops-col--main">
<!-- 未开袋:引导开袋 / 加载 -->
<section v-if="!hasSession" class="ops-card ops-card--scan">
<section class="ops-card ops-card--scan">
<div class="ops-card__body ops-scan">
<div class="ops-idle-title">装袋作业</div>
<p class="ops-scan-hint ops-idle-hint">开新袋后连续扫运单入袋;也可加载装袋中的大包继续作业。</p>
<div class="ops-scan__row ops-scan__row--setup">
<a-button type="primary" class="ops-setup-btn" :loading="creating" @click="openTypeModal">
开新袋
</a-button>
<div v-if="hasSession" class="ops-session-bar">
<div class="ops-session-bar__left">
<span class="bag-type-badge" :class="isBox ? 'is-box' : 'is-sack'" :title="bagTypeLabel">
<IconStorage v-if="isBox" />
<IconGift v-else />
<span>{{ bagTypeLabel }}</span>
</span>
<button type="button" class="ops-session-bar__no" @click="copyBagNo">
{{ activeBag!.bagNo }}
</button>
<a-tag size="small" :color="isOpen ? 'arcoblue' : isSealed ? 'orangered' : 'gray'">
{{ activeBag!.statusName || activeBag!.status }}
</a-tag>
<span class="ops-session-bar__meta">{{ activeBag!.parcelCount }} 件</span>
</div>
<div class="ops-session-bar__right">
<a-button size="mini" @click="() => refreshBag(false)">刷新</a-button>
<a-button size="mini" @click="handleClearSession">切换大包</a-button>
</div>
</div>
<div class="ops-scan__row ops-scan__row--setup">
<div class="ops-scan__row">
<a-input
v-if="!hasSession"
ref="scanInputRef"
v-model="resumeBagNo"
class="ops-resume-input ops-resume-input--wide"
placeholder="继续装袋:输入大包号回车"
class="ops-scan-input"
placeholder="扫描或输入大包号并回车"
allow-clear
@press-enter="() => loadByNo(false)"
/>
<a-button class="ops-setup-btn" :loading="loadingBag" @click="() => loadByNo(false)">
加载
</a-button>
<a-input
v-else
ref="scanInputRef"
v-model="waybillNo"
class="ops-scan-input"
:placeholder="isOpen ? '扫描运单号入袋(回车)' : '已封袋,不可再扫入'"
allow-clear
:disabled="!isOpen"
@press-enter="handleScanEnter"
@focus="selectScanInput"
/>
</div>
<p
v-if="feedbackMessage"
class="ops-feedback ops-feedback--block"
:class="`is-${feedbackType}`"
>
{{ feedbackMessage }}
</p>
</div>
</section>
<!-- 已开袋:扫描为主 -->
<template v-else>
<section class="ops-card ops-card--scan">
<div class="ops-card__body ops-scan">
<div class="ops-session-bar">
<div class="ops-session-bar__left">
<span class="bag-type-badge" :class="isBox ? 'is-box' : 'is-sack'" :title="bagTypeLabel">
<IconStorage v-if="isBox" />
<IconGift v-else />
<span>{{ bagTypeLabel }}</span>
</span>
<button type="button" class="ops-session-bar__no" @click="copyBagNo">
{{ activeBag!.bagNo }}
</button>
<a-tag size="small" :color="isOpen ? 'arcoblue' : isSealed ? 'orangered' : 'gray'">
{{ activeBag!.statusName || activeBag!.status }}
</a-tag>
<span class="ops-session-bar__meta">{{ activeBag!.parcelCount }} 件</span>
</div>
<div class="ops-session-bar__right">
<a-button size="mini" @click="() => refreshBag(false)">刷新</a-button>
<a-button size="mini" @click="handleClearSession">切换大包</a-button>
</div>
<div class="ops-scan__row ops-scan__row--tools">
<div class="ops-scan__opts">
<a-checkbox v-model="keepScanFocus" class="ops-opt">
{{ $t('operation.common.keepScanFocus') }}
</a-checkbox>
<a-checkbox v-model="voiceEnabled" class="ops-opt">
{{ $t('operation.common.voiceBroadcast') }}
</a-checkbox>
</div>
<div class="ops-scan__row">
<a-input
ref="scanInputRef"
v-model="waybillNo"
class="ops-scan-input"
:placeholder="isOpen ? '扫描运单号入袋(回车)' : '已封袋,不可再扫入'"
allow-clear
:disabled="!isOpen"
@press-enter="handleScanEnter"
@focus="selectScanInput"
/>
</div>
<div class="ops-scan__row ops-scan__row--tools">
<div class="ops-scan__opts">
<a-checkbox v-model="keepScanFocus" class="ops-opt">保持扫描焦点</a-checkbox>
<a-checkbox v-model="voiceEnabled" class="ops-opt">语音播报</a-checkbox>
</div>
<div class="ops-scan__actions">
<div class="ops-scan__actions">
<template v-if="!hasSession">
<a-button
class="ops-btn ops-btn--ghost"
:loading="creating"
@click="openTypeModal"
>
开新袋
</a-button>
<a-button
v-if="isOpen"
type="primary"
class="ops-btn ops-btn--primary"
:loading="loadingBag"
@click="() => loadByNo(false)"
>
加载
</a-button>
</template>
<template v-else-if="isOpen">
<a-button
type="primary"
class="ops-btn ops-btn--primary"
:loading="scanning"
@click="handleScanEnter"
>
入袋
</a-button>
<a-button
v-if="isOpen"
type="primary"
status="warning"
class="ops-btn"
:disabled="!activeBag!.parcelCount"
:loading="sealing"
@click="handleSeal"
>
封袋
</a-button>
<a-button v-if="isSealed" type="primary" @click="handleNextBag">开下一袋</a-button>
</div>
</template>
<a-button
v-else-if="isSealed"
type="primary"
class="ops-btn ops-btn--primary"
@click="handleNextBag"
>
开下一袋
</a-button>
</div>
<p
v-if="feedbackMessage"
class="ops-feedback ops-feedback--block"
:class="`is-${feedbackType}`"
>
{{ feedbackMessage }}
</p>
<p v-else class="ops-scan-hint">同袋建议同目的国;小包也可不装袋直接出库。</p>
</div>
</section>
<p class="ops-scan-hint">
{{
hasSession
? '同袋建议同目的国;小包也可不装袋直接出库。'
: '开新袋后连续扫运单入袋;也可加载装袋中的大包继续作业。'
}}
</p>
</div>
</section>
<section class="ops-card ops-card--verify">
<div class="ops-card__body ops-verify">
<section class="ops-card ops-card--verify">
<div class="ops-card__body ops-verify">
<p
v-if="feedbackMessage"
class="ops-feedback"
:class="`is-${feedbackType}`"
>
{{ feedbackMessage }}
</p>
<div v-if="hasSession" class="ops-panel">
<div class="ops-hero ops-hero--with-type">
<div class="bag-type-icon" :class="isBox ? 'is-box' : 'is-sack'" :title="bagTypeLabel">
<IconStorage v-if="isBox" :size="36" />
@ -449,8 +461,12 @@
</div>
</div>
</div>
</section>
</template>
<div v-else class="ops-empty">
<p class="ops-empty__title">请开新袋或加载大包</p>
<p class="ops-empty__tip">扫描大包号回车加载,或点「开新袋」开始作业。</p>
</div>
</div>
</section>
</div>
<aside class="ops-card ops-card--recent-wide">
@ -515,27 +531,6 @@
<style lang="less" scoped>
@import '@/views/operation/styles/ops-scan-page.less';
.ops-idle-title {
font-size: 16px;
font-weight: 600;
color: var(--color-text-1);
}
.ops-idle-hint {
margin-top: -4px;
}
.ops-resume-input--wide {
flex: 1 1 240px;
max-width: none;
}
.ops-feedback--block {
margin: 0;
max-width: 100%;
white-space: normal;
}
.ops-session-bar {
display: flex;
align-items: center;

View File

@ -2,7 +2,6 @@
import { computed, nextTick, onMounted, ref, watch } from 'vue'
import { Modal } from '@arco-design/web-vue'
import HandsontablePro from '@/components/HandsontablePro/index.vue'
import SlidingTabs from '@/components/SlidingTabs/index.vue'
import { useTableContainerHeight } from '@/composables/useTableContainerHeight'
import { useOperationScanFocus } from '@/composables/useOperationScanFocus'
import { useOperationScanFeedback } from '@/composables/useOperationScanFeedback'
@ -29,10 +28,6 @@
const sealing = ref(false)
const loadingMaster = ref(false)
const scanMode = ref<'bag' | 'parcel'>('bag')
const scanModeTabs = [
{ key: 'bag', label: '扫大包' },
{ key: 'parcel', label: '扫小包' },
]
const scanNo = ref('')
const lastScanNo = ref('')
const active = ref<ShipMaster | null>(null)
@ -338,126 +333,135 @@
<template>
<div class="ops-page master-board-page">
<div class="ops-col ops-col--main">
<section v-if="!hasSession" class="ops-card ops-card--scan">
<section class="ops-card ops-card--scan">
<div class="ops-card__body ops-scan">
<div class="ops-idle-title">打板作业</div>
<p class="ops-scan-hint ops-idle-hint">开主单后扫大包或散货小包上板;也可加载打板中主单继续。</p>
<div class="ops-scan__row ops-scan__row--setup">
<a-button
type="primary"
class="ops-setup-btn"
:loading="creating"
@click="() => confirmCreateMaster(false)"
>
开主单
</a-button>
<div v-if="hasSession" class="ops-session-bar">
<div class="ops-session-bar__left">
<span class="ops-session-bar__label">当前</span>
<button type="button" class="ops-session-bar__no" @click="copyMasterNo">
{{ active!.masterNo }}
</button>
<a-tag size="small" :color="isOpen ? 'arcoblue' : isSealed ? 'orangered' : 'gray'">
{{ active!.statusName || active!.status }}
</a-tag>
<span class="ops-session-bar__meta">
大包 {{ active!.bagCount }} · 小包 {{ active!.parcelCount }}
</span>
</div>
<div class="ops-session-bar__right">
<a-button size="mini" @click="refreshMaster">刷新</a-button>
<a-button size="mini" @click="handleClearSession">切换主单</a-button>
</div>
</div>
<div class="ops-scan__row ops-scan__row--setup">
<div v-if="hasSession" class="ops-scan__row">
<a-radio-group v-model="scanMode" type="button" size="small" class="ops-mode">
<a-radio value="bag">扫大包</a-radio>
<a-radio value="parcel">扫小包</a-radio>
</a-radio-group>
</div>
<div class="ops-scan__row">
<a-input
v-if="!hasSession"
ref="scanInputRef"
v-model="resumeMasterNo"
class="ops-resume-input ops-resume-input--wide"
placeholder="继续打板:内部主单号回车"
class="ops-scan-input"
placeholder="扫描或输入内部主单号并回车"
allow-clear
@press-enter="() => loadMaster(false)"
/>
<a-button class="ops-setup-btn" :loading="loadingMaster" @click="() => loadMaster(false)">
加载
</a-button>
<a-input
v-else
ref="scanInputRef"
v-model="scanNo"
class="ops-scan-input"
:placeholder="scanPlaceholder"
allow-clear
:disabled="!isOpen"
@press-enter="handleScan"
@focus="selectScanInput"
/>
</div>
<p
v-if="feedbackMessage"
class="ops-feedback ops-feedback--block"
:class="`is-${feedbackType}`"
>
{{ feedbackMessage }}
</p>
</div>
</section>
<template v-else>
<section class="ops-card ops-card--scan">
<div class="ops-card__body ops-scan">
<div class="ops-session-bar">
<div class="ops-session-bar__left">
<span class="ops-session-bar__label">当前</span>
<button type="button" class="ops-session-bar__no" @click="copyMasterNo">
{{ active!.masterNo }}
</button>
<a-tag size="small" :color="isOpen ? 'arcoblue' : isSealed ? 'orangered' : 'gray'">
{{ active!.statusName || active!.status }}
</a-tag>
<span class="ops-session-bar__meta">
大包 {{ active!.bagCount }} · 小包 {{ active!.parcelCount }}
</span>
</div>
<div class="ops-session-bar__right">
<a-button size="mini" @click="refreshMaster">刷新</a-button>
<a-button size="mini" @click="handleClearSession">切换主单</a-button>
</div>
<div class="ops-scan__row ops-scan__row--tools">
<div class="ops-scan__opts">
<a-checkbox v-model="keepScanFocus" class="ops-opt">
{{ $t('operation.common.keepScanFocus') }}
</a-checkbox>
<a-checkbox v-model="voiceEnabled" class="ops-opt">
{{ $t('operation.common.voiceBroadcast') }}
</a-checkbox>
</div>
<div class="ops-scan__row">
<SlidingTabs
v-model="scanMode"
size="mini"
:items="scanModeTabs"
aria-label="上板模式"
/>
</div>
<div class="ops-scan__row">
<a-input
ref="scanInputRef"
v-model="scanNo"
class="ops-scan-input"
:placeholder="scanPlaceholder"
allow-clear
:disabled="!isOpen"
@press-enter="handleScan"
@focus="selectScanInput"
/>
</div>
<div class="ops-scan__row ops-scan__row--tools">
<div class="ops-scan__opts">
<a-checkbox v-model="keepScanFocus" class="ops-opt">保持扫描焦点</a-checkbox>
<a-checkbox v-model="voiceEnabled" class="ops-opt">语音播报</a-checkbox>
</div>
<div class="ops-scan__actions">
<a-button v-if="isOpen" type="primary" :loading="scanning" @click="handleScan">
<div class="ops-scan__actions">
<template v-if="!hasSession">
<a-button
class="ops-btn ops-btn--ghost"
:loading="creating"
@click="() => confirmCreateMaster(false)"
>
开主单
</a-button>
<a-button
type="primary"
class="ops-btn ops-btn--primary"
:loading="loadingMaster"
@click="() => loadMaster(false)"
>
加载
</a-button>
</template>
<template v-else-if="isOpen">
<a-button
type="primary"
class="ops-btn ops-btn--primary"
:loading="scanning"
@click="handleScan"
>
上板
</a-button>
<a-button
v-if="isOpen"
type="primary"
status="warning"
class="ops-btn"
:disabled="!items.length"
:loading="sealing"
@click="handleSeal"
>
封板
</a-button>
<a-button v-if="isSealed" type="primary" :loading="creating" @click="handleNextMaster">
开下一主单
</a-button>
</div>
</template>
<a-button
v-else-if="isSealed"
type="primary"
class="ops-btn ops-btn--primary"
:loading="creating"
@click="handleNextMaster"
>
开下一主单
</a-button>
</div>
<p
v-if="feedbackMessage"
class="ops-feedback ops-feedback--block"
:class="`is-${feedbackType}`"
>
{{ feedbackMessage }}
</p>
<p v-else class="ops-scan-hint">
大包须已封袋;散货可不装袋上板。小包也可不走主单单独出库。
</p>
</div>
</section>
<p class="ops-scan-hint">
{{
hasSession
? '大包须已封袋;散货可不装袋上板。小包也可不走主单单独出库。'
: '开主单后扫大包或散货小包上板;也可加载打板中主单继续。'
}}
</p>
</div>
</section>
<section class="ops-card ops-card--verify">
<div class="ops-card__body ops-verify">
<section class="ops-card ops-card--verify">
<div class="ops-card__body ops-verify">
<p
v-if="feedbackMessage"
class="ops-feedback"
:class="`is-${feedbackType}`"
>
{{ feedbackMessage }}
</p>
<div v-if="hasSession" class="ops-panel">
<div class="ops-hero">
<div class="ops-hero__nos">
<div class="ops-hero__waybill">{{ active!.masterNo }}</div>
@ -490,8 +494,12 @@
</div>
</div>
</div>
</section>
</template>
<div v-else class="ops-empty">
<p class="ops-empty__title">请开主单或加载主单</p>
<p class="ops-empty__tip">扫描主单号回车加载,或点「开主单」开始打板。</p>
</div>
</div>
</section>
</div>
<aside class="ops-card ops-card--recent-wide">
@ -522,27 +530,6 @@
<style lang="less" scoped>
@import '@/views/operation/styles/ops-scan-page.less';
.ops-idle-title {
font-size: 16px;
font-weight: 600;
color: var(--color-text-1);
}
.ops-idle-hint {
margin-top: -4px;
}
.ops-resume-input--wide {
flex: 1 1 240px;
max-width: none;
}
.ops-feedback--block {
margin: 0;
max-width: 100%;
white-space: normal;
}
.ops-session-bar {
display: flex;
align-items: center;

View File

@ -95,6 +95,7 @@
});
const PRICE_CHECK_ORDER_DRAFT_KEY = 'oms_price_check_order_draft';
const BATCH_TIP_DISMISS_KEY = 'oms.placeOrder.batchTipDismissed';
const { t } = useI18n();
const router = useRouter();
@ -127,8 +128,27 @@
const activeOrderMode = ref<'batch' | 'single'>('single');
const orderModeTabItems = computed(() => [
{ key: 'single', label: t('order.placeOrder.singleOrder') },
{ key: 'batch', label: t('order.placeOrder.batchOrder') },
{
key: 'batch',
label: t('order.placeOrder.batchOrder'),
badge: t('order.placeOrder.batchOrderBadge'),
},
]);
const showBatchTip = ref(localStorage.getItem(BATCH_TIP_DISMISS_KEY) !== '1');
function dismissBatchTip() {
showBatchTip.value = false;
try {
localStorage.setItem(BATCH_TIP_DISMISS_KEY, '1');
} catch {
/* ignore */
}
}
function goBatchFromTip() {
dismissBatchTip();
activeOrderMode.value = 'batch';
}
const uploadDragActive = ref(false);
const priceCheckHandoff = ref<{
visible: boolean;
@ -2889,7 +2909,7 @@
}
if (countryCode) {
singleForm.receiver.countryCode = countryCode;
filled.push(t('order.placeOrder.fromPriceCheck.item.country'));
filled.push(t('order.placeOrder.fromPriceCheck.item.destCountry'));
}
if (zipCode) {
singleForm.receiver.zipCode = zipCode;
@ -3953,38 +3973,38 @@
<div class="tabs-slot">
<SlidingTabs v-model="activeOrderMode" :items="orderModeTabItems" />
</div>
<div
v-if="priceCheckHandoff?.visible && activeOrderMode === 'single'"
class="header-tip-banner"
>
<div class="header-tip-banner__text">
<strong>{{ t('order.placeOrder.fromPriceCheck.bannerTitle') }}</strong>
<span>{{ t('order.placeOrder.fromPriceCheck.headerTip') }}</span>
</div>
<a-button type="text" size="small" @click="priceCheckHandoff = null">
{{ t('order.placeOrder.batchTip.dismiss') }}
</a-button>
</div>
<div
v-else-if="showBatchTip && activeOrderMode === 'single'"
class="header-tip-banner"
>
<div class="header-tip-banner__text">
<strong>{{ t('order.placeOrder.batchTip.title') }}</strong>
<span>{{ t('order.placeOrder.batchTip.desc') }}</span>
</div>
<div class="header-tip-banner__actions">
<a-button class="app-btn-primary-soft" size="small" @click="goBatchFromTip">
{{ t('order.placeOrder.batchTip.action') }}
</a-button>
<a-button type="text" size="small" @click="dismissBatchTip">
{{ t('order.placeOrder.batchTip.dismiss') }}
</a-button>
</div>
</div>
</div>
<div v-show="activeOrderMode === 'single'" class="place-order-pane">
<div class="single-tab">
<a-alert
v-if="priceCheckHandoff?.visible"
type="info"
class="price-check-handoff-alert"
closable
@close="priceCheckHandoff = null"
>
<template #title>{{ t('order.placeOrder.fromPriceCheck.bannerTitle') }}</template>
<div class="handoff-body">
<p v-if="priceCheckHandoff.filled.length" class="handoff-line">
<span class="handoff-label">{{ t('order.placeOrder.fromPriceCheck.filledLabel') }}</span>
{{ priceCheckHandoff.filled.join('、') }}
</p>
<p class="handoff-line">
<span class="handoff-label">{{ t('order.placeOrder.fromPriceCheck.pendingLabel') }}</span>
{{ priceCheckHandoff.pending.join('、') }}
</p>
<p
v-if="priceCheckHandoff.quoteLevel === 'estimated' || priceCheckHandoff.disclaimers?.length"
class="handoff-line handoff-quote-warning"
>
{{ t('order.placeOrder.fromPriceCheck.quoteWarning') }}
<template v-if="priceCheckHandoff.disclaimers?.length">
{{ priceCheckHandoff.disclaimers.join(';') }}
</template>
</p>
</div>
</a-alert>
<div class="single-toolbar table-toolbar liquid-card">
<div class="toolbar-left batch-steps">
<template v-for="(step, idx) in singleFlowSteps" :key="step.key">
@ -5517,30 +5537,47 @@
}
}
.price-check-handoff-alert {
margin-bottom: 12px;
border-radius: 12px;
flex-shrink: 0;
.header-tip-banner {
display: flex;
align-items: center;
justify-content: flex-end;
gap: 10px;
flex-wrap: wrap;
margin: 0;
margin-left: auto;
padding: 6px 12px;
max-width: min(720px, 100%);
border-radius: 10px;
background: color-mix(in srgb, var(--app-primary-color) 8%, #fff);
border: 1px solid color-mix(in srgb, var(--app-primary-color) 16%, transparent);
flex: 1 1 280px;
min-width: 0;
}
.handoff-body {
margin-top: 4px;
}
.header-tip-banner__text {
display: flex;
flex-wrap: wrap;
align-items: baseline;
justify-content: flex-end;
gap: 4px 8px;
min-width: 0;
flex: 1 1 auto;
font-size: 13px;
line-height: 1.4;
color: var(--color-text-2);
text-align: right;
.handoff-line {
margin: 0 0 4px;
font-size: 13px;
line-height: 1.5;
color: var(--color-text-2);
}
.handoff-label {
strong {
color: var(--color-text-1);
font-weight: 600;
}
}
.handoff-quote-warning {
color: #d48806;
}
.header-tip-banner__actions {
display: flex;
align-items: center;
gap: 4px;
flex-shrink: 0;
}
.single-toolbar-right {
@ -5902,14 +5939,19 @@
background: var(--app-page-bg);
padding: 0 0 12px;
min-width: 0;
display: flex;
align-items: center;
justify-content: space-between;
gap: 12px;
flex-wrap: wrap;
}
.tabs-slot {
flex: 1 1 auto;
flex: 0 1 auto;
min-width: 0;
display: flex;
align-items: center;
justify-content: center;
justify-content: flex-start;
overflow: hidden;
}
@ -5918,6 +5960,49 @@
min-width: 0;
width: max-content;
max-width: 100%;
height: 44px;
padding: 4px;
gap: 4px;
border-radius: 12px;
background: color-mix(in srgb, var(--app-primary-color) 8%, #fff);
border: 1px solid color-mix(in srgb, var(--app-primary-color) 16%, transparent);
box-shadow: 0 1px 2px rgba(15, 23, 42, 0.04);
}
:deep(.t-tab) {
height: 36px;
min-height: 36px;
max-height: 36px;
padding: 0 18px;
font-size: 15px;
font-weight: 600;
border-radius: 10px;
}
:deep(.t-tabs-pill) {
top: 4px;
height: 36px;
border-radius: 10px;
box-shadow:
0 2px 8px color-mix(in srgb, var(--app-primary-color) 18%, transparent),
0 1px 2px rgba(15, 23, 42, 0.06);
}
:deep(.t-tab__badge) {
min-width: auto;
height: 20px;
padding: 0 7px;
border-radius: 10px;
font-size: 11px;
font-weight: 600;
letter-spacing: 0.02em;
background: color-mix(in srgb, var(--app-primary-color) 14%, #fff);
color: var(--app-primary-color);
}
:deep(.t-tab[aria-selected='true'] .t-tab__badge) {
background: color-mix(in srgb, var(--app-primary-color) 18%, #fff);
color: var(--app-primary-color);
}
:deep(.t-tab[aria-selected='true'] .t-tab__label) {

View File

@ -1,111 +1,161 @@
<template>
<div class="ai-skills-container">
<div class="page-head">
<div>
<h2 class="page-title">{{ t('menu.system.aiSkills') }}</h2>
<p class="page-desc">{{ t('system.aiSkills.pageDesc') }}</p>
</div>
<div class="head-actions">
<a-select
v-model="sceneFilter"
allow-clear
:placeholder="t('system.aiSkills.sceneFilter')"
style="width: 200px"
@change="loadSkills"
>
<a-option
v-for="s in AI_SKILL_SCENES"
:key="s.value"
:value="s.value"
:label="s.label"
/>
</a-select>
<a-button :loading="loading" @click="loadSkills">{{ t('system.aiSkills.refresh') }}</a-button>
<a-button class="btn-add app-btn-primary-soft" @click="startCreate">{{ t('system.aiSkills.create') }}</a-button>
</div>
</div>
<div class="layout">
<div class="skill-list liquid-card">
<div
v-for="skill in skills"
:key="skill.id"
class="skill-card"
:class="{ active: selectedId === skill.id, disabled: !skill.enabled }"
@click="selectSkill(skill)"
>
<div class="skill-card-top">
<span class="skill-name">{{ skill.name }}</span>
<a-switch
:model-value="skill.enabled"
size="small"
@click.stop
@change="(v: boolean | string | number) => toggleEnabled(skill, Boolean(v))"
/>
</div>
<div class="skill-meta">
<a-tag size="small">{{ sceneLabel(skill.scene) }}</a-tag>
<span class="skill-key">{{ skill.skillKey }}</span>
</div>
<p class="skill-desc">{{ skill.description || '—' }}</p>
<aside class="skill-list liquid-card">
<div class="list-toolbar">
<a-input
v-model="keyword"
allow-clear
:placeholder="t('system.aiSkills.searchPlaceholder')"
/>
<a-button
:loading="loading"
:title="t('system.aiSkills.refresh')"
@click="() => loadSkills({ preferSelected: true })"
>
<template #icon><icon-refresh /></template>
</a-button>
<a-button
class="app-btn-primary-soft"
:title="t('system.aiSkills.create')"
@click="requestCreate"
>
<template #icon><icon-plus /></template>
</a-button>
</div>
<a-empty v-if="!loading && !skills.length" />
</div>
<div class="skill-detail liquid-card">
<template v-if="editing">
<div class="detail-title">
{{ editForm.id ? t('system.aiSkills.editTitle') : t('system.aiSkills.createTitle') }}
<a-spin :loading="loading" class="list-spin">
<div v-if="!loading && !filteredSkills.length" class="list-empty">
<a-empty :description="t('system.aiSkills.listEmpty')">
<a-button class="app-btn-primary-soft" size="small" @click="requestCreate">
{{ t('system.aiSkills.create') }}
</a-button>
</a-empty>
</div>
<a-form layout="vertical" class="detail-form">
<a-form-item :label="t('system.aiSkills.skillKey')" required>
<a-input v-model="editForm.skillKey" :disabled="!!editForm.id" placeholder="oms-xxx" />
</a-form-item>
<a-form-item :label="t('system.aiSkills.scene')" required>
<a-select v-model="editForm.scene">
<a-option
v-for="s in AI_SKILL_SCENES"
:key="s.value"
:value="s.value"
:label="s.label"
<div v-else class="skill-cards">
<div
v-for="skill in filteredSkills"
:key="skill.id"
class="skill-card"
:class="{
active: selectedId === skill.id && editForm.id === skill.id,
disabled: !skill.enabled,
}"
@click="requestSelect(skill)"
>
<div class="skill-card-top">
<span class="skill-name" :title="skill.name">{{ skill.name }}</span>
<a-switch
:model-value="skill.enabled"
size="small"
@click.stop
@change="(v: boolean | string | number) => toggleEnabled(skill, Boolean(v))"
/>
</a-select>
</a-form-item>
<a-form-item :label="t('system.aiSkills.name')" required>
<a-input v-model="editForm.name" />
</a-form-item>
<a-form-item :label="t('system.aiSkills.description')">
<a-textarea v-model="editForm.description" :auto-size="{ minRows: 2, maxRows: 4 }" />
</a-form-item>
<a-form-item :label="t('system.aiSkills.sortOrder')">
<a-input-number v-model="editForm.sortOrder" :min="0" style="width: 160px" />
</a-form-item>
<a-form-item :label="t('system.aiSkills.content')" required>
</div>
<div class="skill-meta">
<a-tag size="small">{{ sceneLabel(skill.scene) }}</a-tag>
<span class="skill-key" :title="skill.skillKey">{{ skill.skillKey }}</span>
</div>
<p class="skill-desc">{{ skill.description || '—' }}</p>
</div>
</div>
</a-spin>
</aside>
<section class="skill-detail liquid-card">
<template v-if="editing">
<div class="detail-header">
<div class="detail-header__meta">
<div class="detail-title">
{{ editForm.id ? t('system.aiSkills.editTitle') : t('system.aiSkills.createTitle') }}
<span v-if="isDirty" class="dirty-dot">{{ t('system.aiSkills.unsaved') }}</span>
</div>
<div v-if="editForm.name || editForm.skillKey" class="detail-subtitle">
{{ editForm.name || editForm.skillKey }}
</div>
</div>
<div class="detail-header__actions">
<a-button @click="cancelEdit">{{ t('system.aiSkills.cancel') }}</a-button>
<a-button
v-if="editForm.id"
status="danger"
:loading="deleting"
@click="confirmDelete"
>
{{ t('system.aiSkills.delete') }}
</a-button>
<a-button type="primary" :loading="saving" :disabled="!isDirty" @click="saveSelected">
{{ t('system.aiSkills.save') }}
</a-button>
</div>
</div>
<div class="detail-body">
<a-form layout="vertical" class="meta-form" :label-col-props="{ span: 24 }">
<a-row :gutter="16">
<a-col :span="12">
<a-form-item :label="t('system.aiSkills.skillKey')" required>
<a-input
v-model="editForm.skillKey"
:disabled="!!editForm.id"
placeholder="oms-xxx"
/>
</a-form-item>
</a-col>
<a-col :span="12">
<a-form-item :label="t('system.aiSkills.scene')" required>
<a-select v-model="editForm.scene">
<a-option
v-for="s in AI_SKILL_SCENES"
:key="s.value"
:value="s.value"
:label="s.label"
/>
</a-select>
</a-form-item>
</a-col>
<a-col :span="12">
<a-form-item :label="t('system.aiSkills.name')" required>
<a-input v-model="editForm.name" />
</a-form-item>
</a-col>
<a-col :span="12">
<a-form-item :label="t('system.aiSkills.sortOrder')">
<a-input-number v-model="editForm.sortOrder" :min="0" style="width: 100%" />
</a-form-item>
</a-col>
<a-col :span="24">
<a-form-item :label="t('system.aiSkills.description')">
<a-textarea
v-model="editForm.description"
:auto-size="{ minRows: 2, maxRows: 3 }"
/>
</a-form-item>
</a-col>
</a-row>
</a-form>
<div class="content-block">
<div class="content-label">
{{ t('system.aiSkills.content') }}
<span class="required-mark">*</span>
</div>
<a-textarea
v-model="editForm.content"
:auto-size="{ minRows: 16, maxRows: 32 }"
class="content-area"
:placeholder="t('system.aiSkills.contentPlaceholder')"
/>
</a-form-item>
<a-form-item>
<div class="row-actions">
<a-button type="primary" :loading="saving" @click="saveSelected">
{{ t('system.aiSkills.save') }}
</a-button>
<a-button
v-if="editForm.id"
status="danger"
:loading="deleting"
@click="confirmDelete"
>
{{ t('system.aiSkills.delete') }}
</a-button>
</div>
</a-form-item>
</a-form>
</div>
</div>
</template>
<a-empty v-else :description="t('system.aiSkills.selectHint')" />
</div>
<div v-else class="detail-empty">
<a-empty :description="t('system.aiSkills.selectHint')">
<a-button class="app-btn-primary-soft" @click="requestCreate">
{{ t('system.aiSkills.create') }}
</a-button>
</a-empty>
</div>
</section>
</div>
</div>
</template>
@ -113,26 +163,29 @@
<script setup lang="ts">
defineOptions({ name: 'SystemAiSkills' })
import { Message, Modal } from '@arco-design/web-vue';
import { onMounted, reactive, ref } from 'vue';
import { useI18n } from 'vue-i18n';
import { Message, Modal } from '@arco-design/web-vue'
import { IconPlus, IconRefresh } from '@arco-design/web-vue/es/icon'
import { computed, onBeforeUnmount, onMounted, reactive, ref } from 'vue'
import { onBeforeRouteLeave } from 'vue-router'
import { useI18n } from 'vue-i18n'
import {
AI_SKILL_SCENES,
deleteAiSkill,
listAiSkills,
saveAiSkill,
type AiSkillItem,
} from '@/api/ai';
} from '@/api/ai'
const { t } = useI18n();
const { t } = useI18n()
const loading = ref(false);
const saving = ref(false);
const deleting = ref(false);
const skills = ref<AiSkillItem[]>([]);
const selectedId = ref<number | null>(null);
const sceneFilter = ref<string | undefined>();
const editing = ref(false);
const loading = ref(false)
const saving = ref(false)
const deleting = ref(false)
const skills = ref<AiSkillItem[]>([])
const selectedId = ref<number | null>(null)
const keyword = ref('')
const editing = ref(false)
const baselineJson = ref<string | null>(null)
const editForm = reactive({
id: 0,
@ -143,74 +196,161 @@ const editForm = reactive({
content: '',
sortOrder: 0,
enabled: true,
});
})
const filteredSkills = computed(() => {
const kw = keyword.value.trim().toLowerCase()
if (!kw) return skills.value
return skills.value.filter((s) => {
const name = (s.name || '').toLowerCase()
const key = (s.skillKey || '').toLowerCase()
const desc = (s.description || '').toLowerCase()
return name.includes(kw) || key.includes(kw) || desc.includes(kw)
})
})
function sceneLabel(scene: string) {
return AI_SKILL_SCENES.find((s) => s.value === scene)?.label ?? scene;
return AI_SKILL_SCENES.find((s) => s.value === scene)?.label ?? scene
}
function snapshotForm() {
return JSON.stringify({
id: editForm.id,
skillKey: editForm.skillKey,
scene: editForm.scene,
name: editForm.name,
description: editForm.description,
content: editForm.content,
sortOrder: editForm.sortOrder,
enabled: editForm.enabled,
})
}
function captureBaseline() {
baselineJson.value = snapshotForm()
}
const isDirty = computed(() => {
if (!editing.value || baselineJson.value == null) return false
return snapshotForm() !== baselineJson.value
})
function confirmLeaveIfDirty(onOk: () => void) {
if (!isDirty.value) {
onOk()
return
}
Modal.confirm({
title: t('system.aiSkills.unsavedTitle'),
content: t('system.aiSkills.unsavedContent'),
okText: t('system.aiSkills.discard'),
cancelText: t('system.aiSkills.cancel'),
onOk,
})
}
function fillForm(skill: AiSkillItem) {
editForm.id = skill.id;
editForm.skillKey = skill.skillKey;
editForm.scene = skill.scene;
editForm.name = skill.name;
editForm.description = skill.description || '';
editForm.content = skill.content || '';
editForm.sortOrder = skill.sortOrder ?? 0;
editForm.enabled = skill.enabled;
editing.value = true;
editForm.id = skill.id
editForm.skillKey = skill.skillKey
editForm.scene = skill.scene
editForm.name = skill.name
editForm.description = skill.description || ''
editForm.content = skill.content || ''
editForm.sortOrder = skill.sortOrder ?? 0
editForm.enabled = skill.enabled
editing.value = true
selectedId.value = skill.id
captureBaseline()
}
function selectSkill(skill: AiSkillItem) {
selectedId.value = skill.id;
fillForm(skill);
function applyCreateForm() {
selectedId.value = null
editForm.id = 0
editForm.skillKey = ''
editForm.scene = 'pricePublish'
editForm.name = ''
editForm.description = ''
editForm.content = ''
editForm.sortOrder = 0
editForm.enabled = true
editing.value = true
captureBaseline()
}
function startCreate() {
selectedId.value = null;
editForm.id = 0;
editForm.skillKey = '';
editForm.scene = sceneFilter.value || 'pricePublish';
editForm.name = '';
editForm.description = '';
editForm.content = '';
editForm.sortOrder = 0;
editForm.enabled = true;
editing.value = true;
function requestSelect(skill: AiSkillItem) {
if (selectedId.value === skill.id && editForm.id === skill.id) return
confirmLeaveIfDirty(() => fillForm(skill))
}
async function loadSkills() {
loading.value = true;
function requestCreate() {
confirmLeaveIfDirty(() => applyCreateForm())
}
function cancelEdit() {
if (editForm.id && baselineJson.value) {
try {
const base = JSON.parse(baselineJson.value) as typeof editForm
Object.assign(editForm, base)
captureBaseline()
return
} catch {
/* fallthrough */
}
}
if (editForm.id) {
const found = skills.value.find((s) => s.id === editForm.id)
if (found) {
fillForm(found)
return
}
}
editing.value = false
selectedId.value = null
baselineJson.value = null
}
async function loadSkills(opts?: { preferSelected?: boolean; autoSelectFirst?: boolean }) {
const preferSelected = opts?.preferSelected !== false
const autoSelectFirst = opts?.autoSelectFirst !== false
loading.value = true
try {
skills.value = await listAiSkills({
scene: sceneFilter.value,
includeContent: true,
});
if (selectedId.value) {
const found = skills.value.find((s) => s.id === selectedId.value);
if (found) fillForm(found);
else {
selectedId.value = null;
editing.value = false;
})
if (preferSelected && selectedId.value) {
const found = skills.value.find((s) => s.id === selectedId.value)
if (found) {
if (!isDirty.value) fillForm(found)
return
}
selectedId.value = null
if (!isDirty.value) {
editing.value = false
baselineJson.value = null
}
}
if (autoSelectFirst && !editing.value && filteredSkills.value.length) {
fillForm(filteredSkills.value[0])
} else if (autoSelectFirst && !editing.value && skills.value.length) {
fillForm(skills.value[0])
}
} catch (e: any) {
Message.error(e?.message || t('system.aiSkills.loadFail'));
Message.error(e?.message || t('system.aiSkills.loadFail'))
} finally {
loading.value = false;
loading.value = false
}
}
async function saveSelected() {
if (!editForm.skillKey.trim() || !editForm.name.trim() || !editForm.scene) {
Message.warning(t('system.aiSkills.required'));
return;
Message.warning(t('system.aiSkills.required'))
return
}
if (!editForm.content.trim()) {
Message.warning(t('system.aiSkills.contentRequired'));
return;
Message.warning(t('system.aiSkills.contentRequired'))
return
}
saving.value = true;
saving.value = true
try {
const saved = await saveAiSkill({
id: editForm.id || undefined,
@ -221,14 +361,17 @@ async function saveSelected() {
content: editForm.content,
sortOrder: editForm.sortOrder,
enabled: editForm.enabled,
});
Message.success(t('system.aiSkills.saveOk'));
selectedId.value = saved.id;
await loadSkills();
})
Message.success(t('system.aiSkills.saveOk'))
selectedId.value = saved.id
await loadSkills({ preferSelected: true, autoSelectFirst: false })
const found = skills.value.find((s) => s.id === saved.id)
if (found) fillForm(found)
else captureBaseline()
} catch (e: any) {
Message.error(e?.message || t('system.aiSkills.saveFail'));
Message.error(e?.message || t('system.aiSkills.saveFail'))
} finally {
saving.value = false;
saving.value = false
}
}
@ -243,40 +386,72 @@ async function toggleEnabled(skill: AiSkillItem, enabled: boolean) {
content: skill.content,
sortOrder: skill.sortOrder,
enabled,
});
skill.enabled = enabled;
if (selectedId.value === skill.id) editForm.enabled = enabled;
Message.success(enabled ? t('system.aiSkills.enabled') : t('system.aiSkills.disabled'));
})
skill.enabled = enabled
if (selectedId.value === skill.id && editForm.id === skill.id) {
editForm.enabled = enabled
captureBaseline()
}
Message.success(enabled ? t('system.aiSkills.enabled') : t('system.aiSkills.disabled'))
} catch (e: any) {
Message.error(e?.message || t('system.aiSkills.saveFail'));
Message.error(e?.message || t('system.aiSkills.saveFail'))
}
}
function confirmDelete() {
if (!editForm.id) return;
if (!editForm.id) return
Modal.confirm({
title: t('system.aiSkills.deleteTitle'),
content: t('system.aiSkills.deleteConfirm', { name: editForm.name }),
okText: t('system.aiSkills.delete'),
cancelText: t('system.aiSkills.cancel'),
onOk: async () => {
deleting.value = true;
deleting.value = true
try {
await deleteAiSkill(editForm.id);
Message.success(t('system.aiSkills.deleteOk'));
selectedId.value = null;
editing.value = false;
await loadSkills();
await deleteAiSkill(editForm.id)
Message.success(t('system.aiSkills.deleteOk'))
selectedId.value = null
editing.value = false
baselineJson.value = null
await loadSkills({ preferSelected: false, autoSelectFirst: true })
} catch (e: any) {
Message.error(e?.message || t('system.aiSkills.deleteFail'));
Message.error(e?.message || t('system.aiSkills.deleteFail'))
} finally {
deleting.value = false;
deleting.value = false
}
},
});
})
}
onMounted(loadSkills);
function onBeforeUnload(e: BeforeUnloadEvent) {
if (!isDirty.value) return
e.preventDefault()
e.returnValue = ''
}
onBeforeRouteLeave((_to, _from, next) => {
if (!isDirty.value) {
next()
return
}
Modal.confirm({
title: t('system.aiSkills.unsavedTitle'),
content: t('system.aiSkills.unsavedLeave'),
okText: t('system.aiSkills.discard'),
cancelText: t('system.aiSkills.cancel'),
onOk: () => next(),
onCancel: () => next(false),
})
})
onMounted(() => {
window.addEventListener('beforeunload', onBeforeUnload)
void loadSkills({ preferSelected: false, autoSelectFirst: true })
})
onBeforeUnmount(() => {
window.removeEventListener('beforeunload', onBeforeUnload)
})
</script>
<style scoped lang="less">
@ -285,36 +460,9 @@ onMounted(loadSkills);
padding: 16px;
display: flex;
flex-direction: column;
gap: 12px;
background: var(--app-page-bg);
min-height: 0;
}
.page-head {
display: flex;
align-items: flex-start;
justify-content: space-between;
gap: 12px;
}
.page-title {
margin: 0;
font-size: 18px;
font-weight: 600;
color: var(--color-text-1);
}
.page-desc {
margin: 4px 0 0;
font-size: 13px;
color: var(--color-text-3);
}
.head-actions {
display: flex;
gap: 8px;
flex-wrap: wrap;
align-items: center;
box-sizing: border-box;
}
.layout {
@ -327,32 +475,93 @@ onMounted(loadSkills);
.liquid-card {
background: var(--app-card-bg);
border-radius: 4px;
padding: 12px;
border-radius: 8px;
min-height: 0;
overflow: auto;
overflow: hidden;
}
.skill-list {
display: flex;
flex-direction: column;
gap: 10px;
padding: 12px;
}
.list-toolbar {
display: flex;
align-items: center;
gap: 8px;
margin-bottom: 12px;
flex-shrink: 0;
.arco-input-wrapper {
flex: 1;
min-width: 0;
}
}
.list-spin {
flex: 1;
min-height: 0;
display: flex;
flex-direction: column;
:deep(.arco-spin-children) {
flex: 1;
min-height: 0;
display: flex;
flex-direction: column;
overflow: hidden;
}
}
.list-empty {
flex: 1;
display: flex;
align-items: center;
justify-content: center;
}
.skill-cards {
flex: 1;
min-height: 0;
overflow: auto;
display: flex;
flex-direction: column;
gap: 8px;
padding-right: 2px;
}
.skill-card {
padding: 12px;
position: relative;
padding: 12px 12px 12px 14px;
border: 1px solid var(--color-border-2);
border-radius: 4px;
border-radius: 6px;
cursor: pointer;
transition: all 0.15s;
transition: border-color 0.15s, background 0.15s;
background: var(--color-fill-1, #f7f8fa);
&::before {
content: '';
position: absolute;
left: 0;
top: 8px;
bottom: 8px;
width: 3px;
border-radius: 0 2px 2px 0;
background: transparent;
}
&:hover {
border-color: var(--app-primary-color);
border-color: color-mix(in srgb, var(--app-primary-color) 40%, transparent);
}
&.active {
border-color: var(--app-primary-color);
background: color-mix(in srgb, var(--app-primary-color) 8%, var(--app-card-bg));
background: color-mix(in srgb, var(--app-primary-color) 8%, #fff);
&::before {
background: var(--app-primary-color);
}
}
&.disabled {
@ -371,6 +580,9 @@ onMounted(loadSkills);
font-size: 14px;
font-weight: 600;
color: var(--color-text-1);
overflow: hidden;
text-overflow: ellipsis;
white-space: nowrap;
}
.skill-meta {
@ -378,12 +590,17 @@ onMounted(loadSkills);
display: flex;
align-items: center;
gap: 8px;
min-width: 0;
}
.skill-key {
font-size: 11px;
color: var(--color-text-3);
font-family: Consolas, monospace;
overflow: hidden;
text-overflow: ellipsis;
white-space: nowrap;
min-width: 0;
}
.skill-desc {
@ -391,22 +608,121 @@ onMounted(loadSkills);
font-size: 12px;
color: var(--color-text-2);
line-height: 1.5;
display: -webkit-box;
-webkit-line-clamp: 2;
-webkit-box-orient: vertical;
overflow: hidden;
}
.skill-detail {
display: flex;
flex-direction: column;
}
.detail-header {
display: flex;
align-items: flex-start;
justify-content: space-between;
gap: 12px;
padding: 12px 16px;
border-bottom: 1px solid var(--color-border-2);
flex-shrink: 0;
}
.detail-header__meta {
min-width: 0;
}
.detail-title {
font-size: 16px;
font-weight: 600;
margin-bottom: 12px;
}
.row-actions {
color: var(--color-text-1);
display: flex;
align-items: center;
gap: 8px;
}
.dirty-dot {
font-size: 12px;
font-weight: 500;
color: var(--app-primary-color);
padding: 0 8px;
height: 20px;
line-height: 20px;
border-radius: 10px;
background: color-mix(in srgb, var(--app-primary-color) 12%, #fff);
}
.detail-subtitle {
margin-top: 4px;
font-size: 13px;
color: var(--color-text-3);
overflow: hidden;
text-overflow: ellipsis;
white-space: nowrap;
}
.detail-header__actions {
display: flex;
align-items: center;
gap: 8px;
flex-shrink: 0;
}
.detail-body {
flex: 1;
min-height: 0;
display: flex;
flex-direction: column;
padding: 12px 16px 16px;
gap: 4px;
}
.meta-form {
flex-shrink: 0;
:deep(.arco-form-item) {
margin-bottom: 12px;
}
}
.content-block {
flex: 1;
min-height: 0;
display: flex;
flex-direction: column;
gap: 8px;
}
.content-label {
font-size: 14px;
color: var(--color-text-2);
flex-shrink: 0;
}
.required-mark {
color: rgb(var(--danger-6));
margin-left: 2px;
}
.content-area {
flex: 1;
min-height: 240px;
font-family: Consolas, 'Courier New', monospace;
font-size: 12px;
line-height: 1.5;
:deep(textarea) {
height: 100% !important;
min-height: 240px;
resize: none;
}
}
.detail-empty {
flex: 1;
display: flex;
align-items: center;
justify-content: center;
}
</style>

View File

@ -23,6 +23,13 @@
<a-button class="app-btn-search" @click="handleSearch">
{{ t('common.search') }}
</a-button>
<a-button
v-if="activeTab === 'message'"
:loading="clearUnreadLoading"
@click="handleClearUnread"
>
{{ t('system.announcement.actions.clearUnread') }}
</a-button>
<a-button v-if="canManage" class="btn-add app-btn-primary-soft" @click="handleAdd">{{ addButtonLabel }}
</a-button>
</a-space>
@ -219,6 +226,7 @@ import {
getNoticeReceiverOptions,
updateNotice,
confirmNoticeRead,
confirmNoticeReadAll,
type NoticeDto,
type NoticeReceiverOption,
} from '@/api/system/notice'
@ -280,6 +288,7 @@ async function openApprovalFromNotice() {
router.push(buildApprovalInboxLocation(link))
}
const readLoading = ref(false)
const clearUnreadLoading = ref(false)
const addButtonLabel = computed(() =>
activeTab.value === 'message'
@ -617,6 +626,27 @@ async function handleRead(row: NoticeDto) {
reloadTable()
}
function handleClearUnread() {
Modal.confirm({
title: t('system.announcement.modal.clearUnreadTitle'),
content: t('system.announcement.modal.clearUnreadContent'),
onOk: async () => {
clearUnreadLoading.value = true
try {
const { clearedCount } = await confirmNoticeReadAll('message')
Message.success(
clearedCount > 0
? t('system.announcement.message.clearUnreadSuccess', { count: clearedCount })
: t('system.announcement.message.clearUnreadEmpty'),
)
reloadTable()
} finally {
clearUnreadLoading.value = false
}
},
})
}
async function handleDrawerRead() {
if (!viewRecord.value?.id) return
readLoading.value = true

View File

@ -10,9 +10,18 @@
/>
</div>
<div v-show="activeTab === 'change'" class="audit-pane">
<div class="table-toolbar">
<a-space wrap>
<a-alert
v-if="activeTab === 'access'"
type="info"
:show-icon="false"
class="audit-access-tip"
>
{{ t('system.dataPerm.audit.accessTip') }}
</a-alert>
<div class="table-toolbar">
<div class="toolbar-left">
<template v-if="activeTab === 'change'">
<a-select
v-model="changeQuery.targetType"
:placeholder="t('system.dataPerm.audit.targetType')"
@ -28,81 +37,61 @@
:placeholder="t('system.dataPerm.audit.targetId')"
allow-clear
style="width: 200px"
@press-enter="handleSearch"
/>
<a-range-picker v-model="changeQuery.timeRange" show-time style="width: 360px" />
<a-button class="app-btn-search" @click="loadChangeLog">{{ t('common.search') }}</a-button>
</a-space>
<PaginationPro
:total-count="changePagination.total"
v-model:current-page="changePagination.current"
v-model:page-size="changePagination.pageSize"
@page-change="(p) => { changePagination.current = p; loadChangeLog() }"
@page-size-change="(s) => { changePagination.pageSize = s; changePagination.current = 1; loadChangeLog() }"
/>
</div>
<a-table :data="changeLogs" :loading="changeLoading" :pagination="false" row-key="id" size="small">
<template #columns>
<a-table-column :title="t('system.dataPerm.audit.col.time')" data-index="createTime" :width="180" />
<a-table-column :title="t('system.dataPerm.audit.col.target')" :width="100">
<template #cell="{ record }">{{ record.targetType }}</template>
</a-table-column>
<a-table-column :title="t('system.dataPerm.audit.col.targetId')" data-index="targetId" ellipsis />
<a-table-column :title="t('system.dataPerm.audit.col.action')" data-index="action" :width="100" />
<a-table-column
:title="t('system.dataPerm.audit.col.operatorMapId')"
data-index="operatorMapId"
:width="110"
/>
</template>
</a-table>
</div>
<div v-show="activeTab === 'access'" class="audit-pane">
<a-alert type="info" :show-icon="false" class="modal-form-tip">
{{ t('system.dataPerm.audit.accessTip') }}
</a-alert>
<div class="table-toolbar">
<a-space wrap>
<template v-else>
<a-input
v-model="accessQuery.userId"
:placeholder="t('system.dataPerm.audit.userId')"
allow-clear
style="width: 220px"
@press-enter="handleSearch"
/>
<a-select
v-model="accessQuery.dataResourceCode"
:placeholder="t('system.dataPerm.audit.module')"
allow-clear
style="width: 140px"
:options="[
{ value: 'Order', label: t('system.dataPerm.audit.module.order') },
{ value: 'Customer', label: t('system.dataPerm.audit.module.customer') },
]"
:options="moduleOptions"
/>
<a-range-picker v-model="accessQuery.timeRange" show-time style="width: 360px" />
<a-button class="app-btn-search" @click="loadAccessLog">{{ t('common.search') }}</a-button>
</a-space>
</template>
<a-button class="app-btn-search" @click="handleSearch">{{ t('common.search') }}</a-button>
</div>
<div class="toolbar-right">
<PaginationPro
:total-count="accessPagination.total"
v-model:current-page="accessPagination.current"
v-model:page-size="accessPagination.pageSize"
@page-change="(p) => { accessPagination.current = p; loadAccessLog() }"
@page-size-change="(s) => { accessPagination.pageSize = s; accessPagination.current = 1; loadAccessLog() }"
:total-count="pagination.total"
v-model:current-page="pagination.current"
v-model:page-size="pagination.pageSize"
@page-change="(p) => { pagination.current = p; loadCurrent() }"
@page-size-change="(s) => { pagination.pageSize = s; pagination.current = 1; loadCurrent() }"
/>
</div>
<a-table :data="accessLogs" :loading="accessLoading" :pagination="false" row-key="id" size="small">
<template #columns>
<a-table-column :title="t('system.dataPerm.audit.col.time')" data-index="createTime" :width="180" />
<a-table-column :title="t('system.dataPerm.audit.col.module')" data-index="dataResourceCode" :width="100" />
<a-table-column :title="t('system.dataPerm.audit.col.api')" data-index="apiPath" ellipsis />
<a-table-column
:title="t('system.dataPerm.audit.col.rowCount')"
data-index="rowCount"
:width="80"
align="center"
/>
</template>
</a-table>
</div>
<div ref="tableContainerRef" class="list-wrap">
<a-spin :loading="loading" class="list-spin">
<HandsontablePro
:key="activeTab"
:columns="hotColumns"
:data="tableRows"
:total="pagination.total"
:current-page="pagination.current"
:page-size="pagination.pageSize"
:show-action-column="false"
:stretch-columns="true"
:height="handsontableHeight"
:read-only="true"
:enable-column-filter="false"
:enable-header-search="false"
:auto-hybrid-header="false"
:enable-header-sort="false"
:enable-header-filter="false"
:show-active-filter-bar="false"
/>
</a-spin>
</div>
</div>
</div>
@ -113,45 +102,85 @@ defineOptions({ name: 'SystemDataPermAudit' })
import { computed, reactive, ref, watch } from 'vue'
import { useI18n } from 'vue-i18n'
import HandsontablePro from '@/components/HandsontablePro/index.vue'
import PaginationPro from '@/components/PaginationPro/index.vue'
import SlidingTabs from '@/components/SlidingTabs/index.vue'
import { useTableContainerHeight } from '@/composables/useTableContainerHeight'
import { getAccessLogList, getChangeLogList, type AccessLogItem, type ChangeLogItem } from '@/api/rbac/data-perm'
import { handleApiError } from '@/utils/rbac-error-handler'
const { t } = useI18n()
const activeTab = ref('change')
const { tableContainerRef, tableHeight } = useTableContainerHeight()
const handsontableHeight = computed(() => Math.max(tableHeight.value || 0, 400))
const activeTab = ref<'change' | 'access'>('change')
const auditTabs = computed(() => [
{ key: 'change', label: t('system.dataPerm.audit.tab.change') },
{ key: 'access', label: t('system.dataPerm.audit.tab.access') },
])
const changeLoading = ref(false)
const moduleOptions = computed(() => [
{ value: 'Order', label: t('system.dataPerm.audit.module.order') },
{ value: 'Customer', label: t('system.dataPerm.audit.module.customer') },
])
const loading = ref(false)
const changeLogs = ref<ChangeLogItem[]>([])
const accessLogs = ref<AccessLogItem[]>([])
const accessLoaded = ref(false)
const changeQuery = reactive({
targetType: '',
targetId: '',
timeRange: [] as string[],
})
const changePagination = reactive({ current: 1, pageSize: 50, total: 0 })
const accessLoading = ref(false)
const accessLogs = ref<AccessLogItem[]>([])
const accessQuery = reactive({
userId: '',
dataResourceCode: '',
timeRange: [] as string[],
})
const changePagination = reactive({ current: 1, pageSize: 50, total: 0 })
const accessPagination = reactive({ current: 1, pageSize: 50, total: 0 })
const accessLoaded = ref(false)
const pagination = computed({
get: () => (activeTab.value === 'change' ? changePagination : accessPagination),
set: () => {},
})
const tableRows = computed(() => (activeTab.value === 'change' ? changeLogs.value : accessLogs.value))
const hotColumns = computed(() => {
if (activeTab.value === 'change') {
return [
{ key: 'createTime', label: t('system.dataPerm.audit.col.time'), width: 180 },
{ key: 'targetType', label: t('system.dataPerm.audit.col.target'), width: 100 },
{ key: 'targetId', label: t('system.dataPerm.audit.col.targetId'), width: 260 },
{ key: 'action', label: t('system.dataPerm.audit.col.action'), width: 120 },
{ key: 'operatorMapId', label: t('system.dataPerm.audit.col.operatorMapId'), width: 120 },
]
}
return [
{ key: 'createTime', label: t('system.dataPerm.audit.col.time'), width: 180 },
{ key: 'userId', label: t('system.dataPerm.audit.col.userId'), width: 260 },
{ key: 'dataResourceCode', label: t('system.dataPerm.audit.col.module'), width: 100 },
{ key: 'apiPath', label: t('system.dataPerm.audit.col.api'), width: 280 },
{ key: 'rowCount', label: t('system.dataPerm.audit.col.rowCount'), width: 80 },
]
})
function buildTimeParams(range: string[]) {
if (!range?.length || range.length < 2) return {}
return { startTime: range[0], endTime: range[1] }
}
function handleSearch() {
pagination.value.current = 1
loadCurrent()
}
async function loadChangeLog() {
changeLoading.value = true
loading.value = true
try {
const res = await getChangeLogList({
targetType: changeQuery.targetType || undefined,
@ -166,12 +195,12 @@ async function loadChangeLog() {
changeLogs.value = []
handleApiError(e)
} finally {
changeLoading.value = false
loading.value = false
}
}
async function loadAccessLog() {
accessLoading.value = true
loading.value = true
try {
const res = await getAccessLogList({
userId: accessQuery.userId || undefined,
@ -187,10 +216,17 @@ async function loadAccessLog() {
accessLogs.value = []
handleApiError(e)
} finally {
accessLoading.value = false
loading.value = false
}
}
function loadCurrent() {
if (activeTab.value === 'change') {
return loadChangeLog()
}
return loadAccessLog()
}
watch(activeTab, (tab) => {
if (tab === 'access' && !accessLoaded.value) {
loadAccessLog()
@ -202,22 +238,30 @@ loadChangeLog()
<style scoped lang="less">
.data-perm-audit-container {
width: 100%;
box-sizing: border-box;
padding: 16px;
background: var(--app-page-bg);
display: flex;
flex-direction: column;
background: var(--app-page-bg, #f0f3f4);
flex: 1;
min-height: 0;
box-sizing: border-box;
overflow: hidden;
}
.data-perm-audit-card {
background: var(--app-card-bg);
flex: 1;
min-height: 0;
display: flex;
flex-direction: column;
background: #fff;
border-radius: 8px;
padding: 16px;
box-sizing: border-box;
overflow: hidden;
}
.audit-page-header {
margin-bottom: 16px;
padding: 12px 16px 0;
flex-shrink: 0;
}
.audit-tabs {
@ -225,8 +269,9 @@ loadChangeLog()
max-width: 100%;
}
.modal-form-tip {
margin-bottom: 16px;
.audit-access-tip {
margin: 12px 16px 0;
flex-shrink: 0;
border-radius: 6px;
background: color-mix(in srgb, var(--app-primary-color) 8%, #fff);
border: 1px solid color-mix(in srgb, var(--app-primary-color) 18%, transparent);
@ -238,9 +283,49 @@ loadChangeLog()
.table-toolbar {
display: flex;
justify-content: space-between;
align-items: flex-start;
align-items: center;
padding: 12px 16px 0;
margin-bottom: 16px;
flex-shrink: 0;
flex-wrap: wrap;
gap: 12px;
gap: 8px;
.toolbar-left,
.toolbar-right {
display: flex;
align-items: center;
gap: 8px;
flex-wrap: wrap;
}
}
.list-wrap {
flex: 1;
min-height: 0;
padding: 0 16px 16px;
display: flex;
flex-direction: column;
overflow: hidden;
:deep(.handsontable-pro-container) {
flex: 1;
min-height: 0;
display: flex;
flex-direction: column;
}
}
.list-spin {
flex: 1;
min-height: 0;
display: flex;
flex-direction: column;
:deep(.arco-spin-children) {
flex: 1;
min-height: 0;
display: flex;
flex-direction: column;
}
}
</style>

View File

@ -10,8 +10,12 @@
<a-descriptions :column="2" size="small" bordered>
<a-descriptions-item :label="t('system.user.table.account')">{{ targetUser.account }}</a-descriptions-item>
<a-descriptions-item :label="t('system.user.table.realName')">{{ targetUser.name }}</a-descriptions-item>
<a-descriptions-item :label="t('system.dataPerm.panel.primaryOrg')">{{ permDto?.organizationName || '—' }}</a-descriptions-item>
<a-descriptions-item :label="t('system.dataPerm.panel.configType')">{{ t('system.dataPerm.panel.configTypeDirect') }}</a-descriptions-item>
<a-descriptions-item :label="t('system.dataPerm.panel.primaryOrg')">{{
permDto?.organizationName || '—'
}}</a-descriptions-item>
<a-descriptions-item :label="t('system.dataPerm.panel.configType')">{{
t('system.dataPerm.panel.configTypeDirect')
}}</a-descriptions-item>
</a-descriptions>
</div>
@ -24,65 +28,103 @@
/>
</div>
<div class="sticky-toolbar">
<a-space wrap>
<a-select
v-model="previewResource"
:options="resourceOptions"
style="width: 160px"
:placeholder="t('system.dataPerm.panel.previewModule')"
/>
<a-button @click="reload">{{ t('system.user.actions.refresh') }}</a-button>
<a-button v-if="canUpdate" @click="applyModalVisible = true">
{{ t('system.dataPerm.templates.apply') }}
</a-button>
</a-space>
<a-space v-if="canUpdate">
<a-button v-if="showClose" @click="emit('close')">{{ t('system.role.modal.cancel') }}</a-button>
<a-button type="primary" :loading="saving" @click="handleSave">
{{ t('system.dataPerm.templates.save') }}
</a-button>
</a-space>
<div class="section-card quick-card">
<div class="quick-card__head">
<div>
<h3 class="quick-card__title">{{ t('system.dataPerm.panel.quickTitle') }}</h3>
<p class="quick-card__hint">{{ t('system.dataPerm.panel.quickHint') }}</p>
</div>
<a-space wrap>
<a-select
v-model="previewResource"
:options="previewResourceOptions"
style="width: 180px"
:placeholder="t('system.dataPerm.panel.previewModule')"
/>
<a-button @click="reload">{{ t('system.user.actions.refresh') }}</a-button>
<a-button v-if="canUpdate" type="primary" @click="applyModalVisible = true">
{{ t('system.dataPerm.templates.apply') }}
</a-button>
</a-space>
</div>
<div v-if="canUpdate" class="scenario-row">
<span class="scenario-row__label">{{ t('system.dataPerm.scenario.label') }}</span>
<div class="scenario-chips">
<button
v-for="preset in SCENARIO_PRESETS"
:key="preset.key"
type="button"
class="scenario-chip"
:title="t(preset.descKey)"
@click="applyScenario(preset)"
>
<span class="scenario-chip__title">{{ t(preset.labelKey) }}</span>
<span class="scenario-chip__desc">{{ t(preset.descKey) }}</span>
</button>
</div>
<p class="quick-card__note">{{ t('system.dataPerm.panel.exceptionNote') }}</p>
</div>
</div>
<div class="perm-tabs-wrap">
<SlidingTabs
v-model="activeTab"
class="perm-tabs"
:items="slidingTabItems"
:aria-label="t('system.dataPerm.panel.tabsAria')"
/>
</div>
<a-collapse v-model:active-key="advancedKeys" :bordered="false" class="advanced-collapse">
<a-collapse-item key="advanced">
<template #header>
<div class="advanced-head">
<span>{{ t('system.dataPerm.panel.advancedTitle') }}</span>
<a-tag size="small" color="gray">{{ directTotal }}</a-tag>
</div>
</template>
<p class="advanced-hint">{{ t('system.dataPerm.panel.advancedHint') }}</p>
<div class="tab-pane section-card">
<OrgPermPanel
v-show="activeTab === 'org'"
v-model="form.orgPerms"
:org-tree="orgTree"
:org-scope-options="orgScopeOptions"
/>
<DataScopePanel
v-show="activeTab === 'scope'"
v-model="form.dataScopes"
:data-scope-options="dataScopeOptions"
:data-resources="meta.dataResources"
/>
<BizPermPanel
v-show="activeTab === 'biz'"
v-model="form.bizPerms"
:biz-type-options="meta.bizTypes"
/>
<SecretPermPanel
v-show="activeTab === 'secret'"
v-model="form.secretPerms"
:secret-level-options="meta.secretLevels"
:data-resources="meta.dataResources"
/>
<FilterRulePanel
v-show="activeTab === 'filter'"
v-model="form.filterRules"
:data-resources="meta.dataResources"
/>
<div class="perm-tabs-wrap">
<SlidingTabs
v-model="activeTab"
class="perm-tabs"
:items="slidingTabItems"
:aria-label="t('system.dataPerm.panel.tabsAria')"
/>
</div>
<div class="tab-pane section-card">
<OrgPermPanel
v-show="activeTab === 'org'"
v-model="form.orgPerms"
:org-tree="orgTree"
:org-scope-options="orgScopeOptions"
/>
<DataScopePanel
v-show="activeTab === 'scope'"
v-model="form.dataScopes"
:data-scope-options="dataScopeOptions"
:data-resources="advancedResources"
/>
<BizPermPanel
v-show="activeTab === 'biz'"
v-model="form.bizPerms"
:biz-type-options="meta.bizTypes"
/>
<SecretPermPanel
v-show="activeTab === 'secret'"
v-model="form.secretPerms"
:secret-level-options="meta.secretLevels"
:data-resources="advancedResources"
/>
<FilterRulePanel
v-show="activeTab === 'filter'"
v-model="form.filterRules"
:data-resources="advancedResources"
/>
</div>
</a-collapse-item>
</a-collapse>
<!-- 抽屉等非嵌入态:底部保存;嵌入页由外层 header 放保存 -->
<div v-if="!embedded && canUpdate" class="panel-footer-bar">
<a-button v-if="showClose" @click="emit('close')">{{ t('system.role.modal.cancel') }}</a-button>
<a-button type="primary" :loading="saving" @click="handleSave">
{{ t('system.dataPerm.panel.save') }}
</a-button>
</div>
</a-spin>
</template>
@ -99,7 +141,7 @@
<script setup lang="ts">
import { computed, onMounted, reactive, ref, watch } from 'vue'
import { useI18n } from 'vue-i18n'
import { Message } from '@arco-design/web-vue'
import { Message, Modal } from '@arco-design/web-vue'
import type { UserDto } from '@/api/rbac'
import {
getDataPermMeta,
@ -118,7 +160,12 @@ import {
DEFAULT_DATA_SCOPES,
DEFAULT_SECRET_LEVELS,
DEFAULT_BIZ_TYPES,
SCENARIO_PRESETS,
buildScenarioPatch,
emptySaveInput,
isResourceEnforced,
resourceOptionLabel,
type ScenarioPreset,
} from '../constants'
import EffectiveScopeBanner from './EffectiveScopeBanner.vue'
import OrgPermPanel from './OrgPermPanel.vue'
@ -147,6 +194,7 @@ const emit = defineEmits<{
saved: []
close: []
'stats-change': [Record<string, number>]
'dirty-change': [boolean]
}>()
const { t } = useI18n()
@ -155,20 +203,24 @@ const canUpdate = computed(() => hasPermission('Rbac.DataPerm.Update'))
const loading = ref(false)
const saving = ref(false)
const dirty = ref(false)
const activeTab = ref('org')
const previewResource = ref('Order')
const applyModalVisible = ref(false)
const advancedKeys = ref<string[]>([])
const bannerRef = ref<InstanceType<typeof EffectiveScopeBanner>>()
const permDto = ref<Awaited<ReturnType<typeof getUserDataPerm>> | null>(null)
const orgTree = ref<{ key: string; title: string; value: string; children?: unknown[] }[]>([])
const metaLoaded = ref(false)
let baselineJson = ''
let dirtyWatchReady = false
const meta = reactive<DataPermMetaDto>({
orgScopes: DEFAULT_ORG_SCOPES,
dataScopes: DEFAULT_DATA_SCOPES,
secretLevels: DEFAULT_SECRET_LEVELS,
bizTypes: DEFAULT_BIZ_TYPES,
dataResources: [{ code: 'Order', name: '订单', filterableFields: ['CreateTime', 'OrderStatus', 'IsPaid'] }],
dataResources: [{ code: 'Order', name: '订单', filterableFields: ['CreateTime', 'OrderStatus', 'IsPaid'], isEnforced: true }],
filterOperators: [],
})
@ -180,6 +232,15 @@ const form = reactive({
filterRules: [] as any[],
})
const directTotal = computed(
() =>
form.orgPerms.length +
form.dataScopes.length +
form.bizPerms.length +
form.secretPerms.length +
form.filterRules.length
)
const tabItems = computed(() => [
{ key: 'org', label: t('system.dataPerm.panel.tab.org'), count: form.orgPerms.length },
{ key: 'scope', label: t('system.dataPerm.panel.tab.scope'), count: form.dataScopes.length },
@ -202,10 +263,28 @@ const orgScopeOptions = computed(() =>
const dataScopeOptions = computed(() =>
meta.dataScopes.map((o) => ({ value: Number(o.value), label: String(o.label) }))
)
const resourceOptions = computed(() =>
meta.dataResources.map((r) => ({ value: r.code, label: r.name }))
const enrichedResources = computed(() =>
(meta.dataResources || []).map((r) => ({
...r,
isEnforced: isResourceEnforced(r.code, r.isEnforced),
name: resourceOptionLabel(r.code, r.name, r.isEnforced),
}))
)
/** 高级配置可用全部模块(未接入会标名);预览只给已接入模块,避免假验收 */
const previewResourceOptions = computed(() => {
const enforced = enrichedResources.value.filter((r) => r.isEnforced)
const list = enforced.length ? enforced : enrichedResources.value
return list.map((r) => ({ value: r.code, label: r.name.replace(/(未接入)$/, '') }))
})
const advancedResources = computed(() => {
const list = [...enrichedResources.value]
list.sort((a, b) => Number(b.isEnforced) - Number(a.isEnforced))
return list
})
function emitStats() {
emit('stats-change', {
org: form.orgPerms.length,
@ -216,6 +295,22 @@ function emitStats() {
})
}
function setDirty(next: boolean) {
if (dirty.value === next) return
dirty.value = next
emit('dirty-change', next)
}
function captureBaseline() {
baselineJson = JSON.stringify(toSavePayload())
setDirty(false)
}
function refreshDirty() {
if (!dirtyWatchReady || loading.value || saving.value) return
setDirty(JSON.stringify(toSavePayload()) !== baselineJson)
}
function convertOrgTree(data: OrganizationTreeDto[]): typeof orgTree.value {
return data.map((item) => ({
key: item.id!,
@ -260,6 +355,28 @@ function parseFilterValue(op: string, raw: unknown) {
return raw
}
function applyScenario(preset: ScenarioPreset) {
const run = () => {
const patch = buildScenarioPatch(preset)
form.dataScopes = patch.dataScopes
form.secretPerms = patch.secretPerms
advancedKeys.value = ['advanced']
activeTab.value = 'scope'
Message.success(t('system.dataPerm.scenario.applied', { name: t(preset.labelKey) }))
refreshDirty()
}
if (form.dataScopes.length || form.secretPerms.length) {
Modal.confirm({
title: t('system.dataPerm.scenario.confirmTitle'),
content: t('system.dataPerm.scenario.confirmContent'),
onOk: run,
})
return
}
run()
}
async function loadMeta() {
if (metaLoaded.value) return
try {
@ -280,6 +397,7 @@ async function loadMeta() {
async function loadPerm() {
if (!props.targetUser?.id) return
loading.value = true
dirtyWatchReady = false
try {
const dto = await getUserDataPerm(props.targetUser.id)
permDto.value = dto
@ -288,13 +406,18 @@ async function loadPerm() {
form.bizPerms = mapRows(dto.bizPerms, 'biz')
form.secretPerms = mapRows(dto.secretPerms, 'secret')
form.filterRules = mapRows(dto.filterRules, 'filter')
advancedKeys.value = directTotal.value > 0 ? ['advanced'] : []
emitStats()
captureBaseline()
} catch (e) {
Object.assign(form, emptySaveInput())
advancedKeys.value = []
emitStats()
captureBaseline()
handleApiError(e)
} finally {
loading.value = false
dirtyWatchReady = true
}
}
@ -312,9 +435,10 @@ async function handleSave() {
saving.value = true
try {
await saveUserDataPerm(props.targetUser.id, toSavePayload())
Message.success(t('system.dataPerm.templates.updateSuccess'))
Message.success(t('system.dataPerm.panel.saveSuccess'))
emit('saved')
await reload()
captureBaseline()
} catch (e) {
handleApiError(e)
} finally {
@ -337,6 +461,12 @@ watch(
() => emitStats()
)
watch(
form,
() => refreshDirty(),
{ deep: true }
)
watch(
() => props.targetUser?.id,
async (userId) => {
@ -344,6 +474,7 @@ watch(
permDto.value = null
Object.assign(form, emptySaveInput())
emitStats()
captureBaseline()
return
}
activeTab.value = 'org'
@ -357,7 +488,15 @@ onMounted(() => {
loadMeta()
})
defineExpose({ permDto, loading })
defineExpose({
permDto,
loading,
saving,
dirty,
canUpdate,
save: handleSave,
reload,
})
</script>
<style scoped lang="less">
@ -389,11 +528,132 @@ defineExpose({ permDto, loading })
font-size: 14px;
}
.scope-card {
margin-bottom: 0;
.scope-card,
.quick-card {
margin-bottom: 12px;
padding: 12px 16px;
}
.quick-card__head {
display: flex;
align-items: flex-start;
justify-content: space-between;
gap: 12px;
flex-wrap: wrap;
}
.quick-card__title {
margin: 0;
font-size: 14px;
font-weight: 600;
}
.quick-card__hint {
margin: 4px 0 0;
font-size: 12px;
color: var(--color-text-3);
line-height: 1.4;
max-width: 560px;
}
.scenario-row {
margin-top: 12px;
display: flex;
flex-direction: column;
gap: 8px;
}
.scenario-row__label {
font-size: 12px;
color: var(--color-text-2);
}
.scenario-chips {
display: grid;
grid-template-columns: repeat(4, minmax(0, 1fr));
gap: 8px;
}
@media (max-width: 1200px) {
.scenario-chips {
grid-template-columns: repeat(2, minmax(0, 1fr));
}
}
.scenario-chip {
text-align: left;
border: 1px solid var(--color-border-2);
border-radius: 8px;
background: #fff;
padding: 10px 12px;
cursor: pointer;
transition: border-color 0.15s ease, box-shadow 0.15s ease;
&:hover {
border-color: var(--app-primary-color, #1d7281);
box-shadow: 0 0 0 2px color-mix(in srgb, var(--app-primary-color, #1d7281) 12%, #fff);
}
}
.scenario-chip__title {
display: block;
font-size: 13px;
font-weight: 600;
color: var(--color-text-1);
}
.scenario-chip__desc {
display: block;
margin-top: 4px;
font-size: 12px;
color: var(--color-text-3);
line-height: 1.35;
}
.quick-card__note {
margin: 4px 0 0;
font-size: 12px;
color: var(--color-text-3);
line-height: 1.4;
}
.panel-footer-bar {
display: flex;
justify-content: flex-end;
gap: 8px;
margin-top: 16px;
padding-top: 12px;
border-top: 1px solid var(--color-border-2);
}
.advanced-collapse {
background: transparent;
:deep(.arco-collapse-item-header) {
background: #fff;
border: 1px solid var(--color-border-2);
border-radius: 8px;
padding: 10px 14px;
}
:deep(.arco-collapse-item-content-box) {
padding: 12px 0 0;
}
}
.advanced-head {
display: inline-flex;
align-items: center;
gap: 8px;
font-weight: 600;
}
.advanced-hint {
margin: 0 0 12px;
font-size: 12px;
color: var(--color-text-3);
}
.tab-pane {
min-height: 280px;
}

View File

@ -1,37 +1,137 @@
<template>
<a-alert v-if="loading" type="info">正在加载生效范围…</a-alert>
<a-alert v-else-if="effective?.isAdmin" type="success">
{{ effective.summaryText || '超级管理员,无数据限制' }}
</a-alert>
<a-alert v-else type="normal">
<template #title>当前生效范围(预览)</template>
{{ effective?.summaryText || '—' }}
<template v-if="effective?.secretLevels?.length" #action>
<a-tag v-for="lv in effective.secretLevels" :key="lv" size="small">密级 {{ lv }}</a-tag>
</template>
</a-alert>
<div class="scope-banner">
<div class="scope-banner__head">
<div>
<p class="scope-banner__title">{{ t('system.dataPerm.banner.title') }}</p>
<p class="scope-banner__hint">{{ t('system.dataPerm.banner.hint') }}</p>
</div>
<a-space wrap>
<a-tag v-if="effective?.isAdmin" color="green" size="small">Admin</a-tag>
<a-tag v-if="effective && !resourceEnforced" color="orangered" size="small">
{{ t('system.dataPerm.resource.notEnforced') }}
</a-tag>
<a-tag v-else-if="effective && resourceEnforced" color="arcoblue" size="small">
{{ t('system.dataPerm.resource.enforced') }}
</a-tag>
<a-button
v-if="userId && (previewResource === 'Order' || !previewResource)"
size="mini"
:loading="previewLoading"
@click="runPreview"
>
{{ t('system.dataPerm.banner.previewOrders') }}
</a-button>
</a-space>
</div>
<a-spin :loading="loading" style="width: 100%">
<a-alert v-if="effective?.isAdmin" type="success" class="scope-banner__alert">
{{ effective.summaryText || t('system.dataPerm.banner.admin') }}
</a-alert>
<template v-else>
<div class="scope-cards">
<div class="scope-card-item">
<span class="scope-card-item__label">{{ t('system.dataPerm.panel.tab.org') }}</span>
<span class="scope-card-item__value">{{ orgText }}</span>
</div>
<div class="scope-card-item">
<span class="scope-card-item__label">{{ t('system.dataPerm.panel.tab.scope') }}</span>
<span class="scope-card-item__value">{{ scopeText }}</span>
</div>
<div class="scope-card-item">
<span class="scope-card-item__label">{{ t('system.dataPerm.panel.tab.secret') }}</span>
<span class="scope-card-item__value">
<a-space v-if="effective?.secretLevels?.length" :size="4" wrap>
<a-tag v-for="lv in effective.secretLevels" :key="lv" size="small">{{ secretLabel(lv) }}</a-tag>
</a-space>
<template v-else>—</template>
</span>
</div>
<div class="scope-card-item">
<span class="scope-card-item__label">{{ t('system.dataPerm.panel.tab.biz') }}</span>
<span class="scope-card-item__value">{{ bizText }}</span>
</div>
</div>
<p v-if="effective?.summaryText" class="scope-banner__summary">{{ effective.summaryText }}</p>
</template>
<div v-if="preview" class="preview-box">
<div class="preview-box__head">
<strong>{{ t('system.dataPerm.banner.previewResult', { count: preview.totalCount }) }}</strong>
<span v-if="preview.isAdmin" class="preview-box__note">{{ t('system.dataPerm.banner.previewAdminNote') }}</span>
</div>
<ul v-if="preview.samples?.length" class="preview-box__list">
<li v-for="item in preview.samples" :key="item.orderId">
<span class="mono">{{ item.serviceNo }}</span>
<span v-if="item.clientNo" class="muted"> / {{ item.clientNo }}</span>
<span v-if="item.orderStatus" class="muted"> · {{ item.orderStatus }}</span>
</li>
</ul>
<p v-else class="preview-box__empty">{{ t('system.dataPerm.banner.previewEmpty') }}</p>
</div>
</a-spin>
</div>
</template>
<script setup lang="ts">
import { ref, watch } from 'vue'
import { getEffectiveDataScope, type EffectiveDataScopeDto } from '@/api/rbac/data-perm'
import { computed, ref, watch } from 'vue'
import { useI18n } from 'vue-i18n'
import {
getEffectiveDataScope,
previewOrderScope,
type EffectiveDataScopeDto,
type OrderScopePreviewDto,
} from '@/api/rbac/data-perm'
import { DEFAULT_SECRET_LEVELS, isResourceEnforced } from '../constants'
import { handleApiError } from '@/utils/rbac-error-handler'
const props = defineProps<{
userId?: string
dataResourceCode?: string
}>()
const { t } = useI18n()
const loading = ref(false)
const previewLoading = ref(false)
const effective = ref<EffectiveDataScopeDto | null>(null)
const preview = ref<OrderScopePreviewDto | null>(null)
const previewResource = computed(() => props.dataResourceCode || 'Order')
const resourceEnforced = computed(() =>
isResourceEnforced(previewResource.value, effective.value?.isEnforced)
)
const orgText = computed(() => {
const names = effective.value?.organizationNames || []
if (!names.length) return t('system.dataPerm.banner.noOrgLimit')
if (names.length <= 3) return names.join('、')
return `${names.slice(0, 3).join('、')} ${t('system.dataPerm.banner.orgMore', { count: names.length })}`
})
const scopeText = computed(
() => effective.value?.dataScopeLabel || effective.value?.summaryText?.match(/范围:([^;]+)/)?.[1] || '—'
)
const bizText = computed(() => {
const groups = effective.value?.bizFilters || []
if (!groups.length) return t('system.dataPerm.banner.bizUnlimited')
return t('system.dataPerm.banner.bizCount', { count: groups.length })
})
function secretLabel(level: number) {
return DEFAULT_SECRET_LEVELS.find((x) => x.value === level)?.label || String(level)
}
async function load() {
preview.value = null
if (!props.userId) {
effective.value = null
return
}
loading.value = true
try {
effective.value = await getEffectiveDataScope(props.userId, props.dataResourceCode || 'Order')
effective.value = await getEffectiveDataScope(props.userId, previewResource.value)
} catch {
effective.value = null
} finally {
@ -39,7 +139,137 @@ async function load() {
}
}
async function runPreview() {
if (!props.userId) return
previewLoading.value = true
try {
preview.value = await previewOrderScope(props.userId, 5)
} catch (e) {
preview.value = null
handleApiError(e)
} finally {
previewLoading.value = false
}
}
watch(() => [props.userId, props.dataResourceCode], load, { immediate: true })
defineExpose({ reload: load })
</script>
<style scoped lang="less">
.scope-banner {
display: flex;
flex-direction: column;
gap: 12px;
}
.scope-banner__head {
display: flex;
align-items: flex-start;
justify-content: space-between;
gap: 12px;
flex-wrap: wrap;
}
.scope-banner__title {
margin: 0;
font-size: 14px;
font-weight: 600;
color: var(--color-text-1);
}
.scope-banner__hint {
margin: 4px 0 0;
font-size: 12px;
color: var(--color-text-3);
line-height: 1.4;
}
.scope-banner__alert {
margin: 0;
}
.scope-cards {
display: grid;
grid-template-columns: repeat(4, minmax(0, 1fr));
gap: 8px;
}
@media (max-width: 1100px) {
.scope-cards {
grid-template-columns: repeat(2, minmax(0, 1fr));
}
}
.scope-card-item {
border: 1px solid var(--color-border-2);
border-radius: 8px;
background: var(--color-fill-1);
padding: 10px 12px;
min-height: 64px;
}
.scope-card-item__label {
display: block;
font-size: 12px;
color: var(--color-text-3);
margin-bottom: 4px;
}
.scope-card-item__value {
font-size: 13px;
color: var(--color-text-1);
line-height: 1.4;
word-break: break-word;
}
.scope-banner__summary {
margin: 0;
font-size: 12px;
color: var(--color-text-3);
line-height: 1.5;
}
.preview-box {
border: 1px dashed color-mix(in srgb, var(--app-primary-color, #1d7281) 35%, #fff);
border-radius: 8px;
background: color-mix(in srgb, var(--app-primary-color, #1d7281) 6%, #fff);
padding: 10px 12px;
}
.preview-box__head {
display: flex;
align-items: center;
gap: 8px;
flex-wrap: wrap;
font-size: 13px;
color: var(--color-text-1);
}
.preview-box__note {
font-size: 12px;
color: var(--color-text-3);
}
.preview-box__list {
margin: 8px 0 0;
padding-left: 18px;
font-size: 12px;
color: var(--color-text-2);
}
.preview-box__empty {
margin: 8px 0 0;
font-size: 12px;
color: var(--color-text-3);
}
.mono {
font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
}
.muted {
color: var(--color-text-3);
}
</style>

View File

@ -1,23 +1,43 @@
<template>
<div class="filter-rule-panel">
<a-alert type="normal" class="filter-tip">
{{ t('system.dataPerm.filter.tip') }}
</a-alert>
<a-tabs v-model:active-key="activeResource" type="rounded">
<a-tab-pane v-for="res in dataResources" :key="res.code" :title="res.name">
<div class="panel-toolbar">
<a-button type="primary" size="small" @click="addCondition(res.code)">添加条件
</a-button>
<span class="hint">条件之间 AND;保存时由后端校验字段白名单</span>
<div v-if="!isResourceEnforced(res.code, res.isEnforced)" class="not-enforced">
{{ t('system.dataPerm.resource.notEnforcedHint') }}
</div>
<a-empty v-if="!getRule(res.code).conditions.length" description="暂无过滤条件" />
<div class="panel-toolbar">
<a-button type="primary" size="small" @click="addCondition(res.code)">
{{ t('system.dataPerm.filter.addCondition') }}
</a-button>
<span class="hint">{{ t('system.dataPerm.filter.andHint') }}</span>
</div>
<a-empty
v-if="!getRule(res.code).conditions.length"
:description="t('system.dataPerm.filter.empty')"
/>
<div v-for="(cond, idx) in getRule(res.code).conditions" :key="idx" class="cond-row">
<a-select
v-model="cond.field"
:options="fieldOptions(res.code)"
placeholder="字段"
:placeholder="t('system.dataPerm.filter.field')"
style="width: 160px"
/>
<a-select v-model="cond.op" :options="operatorOptions" style="width: 120px" />
<a-input v-model="cond.value" placeholder="值(in/between 用逗号分隔)" style="flex: 1" />
<a-button type="text" status="danger" @click="removeCondition(res.code, idx)">删除</a-button>
<a-select
v-model="cond.op"
:options="operatorOptions"
style="width: 120px"
/>
<a-input
v-model="cond.value"
:placeholder="t('system.dataPerm.filter.valuePlaceholder')"
style="flex: 1"
/>
<a-button type="text" status="danger" @click="removeCondition(res.code, idx)">
{{ t('system.dataPerm.templates.removeItem') }}
</a-button>
</div>
</a-tab-pane>
</a-tabs>
@ -25,10 +45,16 @@
</template>
<script setup lang="ts">
import { ref, watch } from 'vue'
import { IconPlus } from '@arco-design/web-vue/es/icon'
import { computed, ref, watch } from 'vue'
import { useI18n } from 'vue-i18n'
import type { FilterRuleItem, FilterContent, DataResourceMeta } from '@/api/rbac/data-perm'
import { FILTER_OPERATORS, emptyFilterContent } from '../constants'
import {
FILTER_FIELD_LABELS,
FILTER_OP_LABELS,
FILTER_OPERATORS,
emptyFilterContent,
isResourceEnforced,
} from '../constants'
type Row = FilterRuleItem & { _key: string }
@ -38,10 +64,16 @@ const props = defineProps<{
}>()
const emit = defineEmits<{ 'update:modelValue': [Row[]] }>()
const { t } = useI18n()
const activeResource = ref(props.dataResources[0]?.code || 'Order')
const operatorOptions = FILTER_OPERATORS.map((op) => ({ value: op, label: op }))
const operatorOptions = computed(() =>
FILTER_OPERATORS.map((op) => ({
value: op,
label: FILTER_OP_LABELS[op] || op,
}))
)
watch(
() => props.dataResources,
@ -64,7 +96,10 @@ function getRule(code: string): FilterContent {
function fieldOptions(code: string) {
const res = props.dataResources.find((r) => r.code === code)
return (res?.filterableFields || ['CreateTime', 'OrderStatus']).map((f) => ({ value: f, label: f }))
return (res?.filterableFields || ['CreateTime', 'OrderStatus']).map((f) => ({
value: f,
label: FILTER_FIELD_LABELS[f] || f,
}))
}
function upsertRule(code: string, content: FilterContent) {
@ -100,6 +135,17 @@ function removeCondition(code: string, index: number) {
</script>
<style scoped>
.filter-tip {
margin-bottom: 12px;
}
.not-enforced {
margin-bottom: 10px;
padding: 8px 10px;
border-radius: 6px;
background: #fff7e8;
color: #ad6800;
font-size: 12px;
}
.panel-toolbar {
display: flex;
align-items: center;

View File

@ -146,7 +146,12 @@
import { computed, ref, watch } from 'vue'
import { useI18n } from 'vue-i18n'
import { getBizOptions } from '@/api/rbac/data-perm'
import { DEFAULT_BIZ_TYPES, FILTER_OPERATORS } from '../constants'
import {
DEFAULT_BIZ_TYPES,
FILTER_FIELD_LABELS,
FILTER_OP_LABELS,
FILTER_OPERATORS,
} from '../constants'
import type { TemplateItemFormModel } from '../templates/templateItemContent'
const props = defineProps<{
@ -173,12 +178,15 @@ const resourceOptions = computed(() =>
props.dataResources.map((r) => ({ value: r.code, label: r.name }))
)
const operatorOptions = FILTER_OPERATORS.map((op) => ({ value: op, label: op }))
const operatorOptions = FILTER_OPERATORS.map((op) => ({
value: op,
label: FILTER_OP_LABELS[op] || op,
}))
const filterFieldOptions = computed(() => {
const res = props.dataResources.find((r) => r.code === model.value.filterResourceCode)
const fields = res?.filterableFields || ['CreateTime', 'OrderStatus', 'IsPaid']
return fields.map((f) => ({ value: f, label: f }))
return fields.map((f) => ({ value: f, label: FILTER_FIELD_LABELS[f] || f }))
})
const dimensionTip = computed(() => {

View File

@ -29,6 +29,96 @@ export const DEFAULT_BIZ_TYPES = [
export const FILTER_OPERATORS = ['eq', 'ne', 'in', 'notIn', 'gt', 'gte', 'lt', 'lte', 'between', 'like']
/** 已真正接入业务列表过滤的模块(与后端 EnforcedResourceCodes 对齐) */
export const ENFORCED_RESOURCE_CODES = new Set(['Order'])
export const FILTER_FIELD_LABELS: Record<string, string> = {
CreateTime: '创建时间',
OrderStatus: '订单状态',
DeclaredSum: '申报金额',
CustomerId: '客户 ID',
WarehouseId: '仓库 ID',
ProductCode: '产品编码',
SecretLevel: '密级',
IsPaid: '是否已付款',
CustomerGroup: '客户分组',
Salesman: '业务员',
ProductGroup: '产品分组',
IsActive: '是否启用',
Status: '状态',
}
export const FILTER_OP_LABELS: Record<string, string> = {
eq: '等于',
ne: '不等于',
in: '属于',
notIn: '不属于',
gt: '大于',
gte: '大于等于',
lt: '小于',
lte: '小于等于',
between: '介于',
like: '包含',
isNull: '为空',
isNotNull: '非空',
}
export interface ScenarioPreset {
key: string
labelKey: string
descKey: string
dataScope: number
secretLevels: number[]
dataResourceCode: string
}
/** 运营常用场景:一键写入「数据范围 + 密级」,组织/业务标签仍可在高级里补 */
export const SCENARIO_PRESETS: ScenarioPreset[] = [
{
key: 'personal',
labelKey: 'system.dataPerm.scenario.personal',
descKey: 'system.dataPerm.scenario.personalDesc',
dataScope: 1,
secretLevels: [1, 2],
dataResourceCode: 'Order',
},
{
key: 'department',
labelKey: 'system.dataPerm.scenario.department',
descKey: 'system.dataPerm.scenario.departmentDesc',
dataScope: 3,
secretLevels: [1, 2, 3],
dataResourceCode: 'Order',
},
{
key: 'orgTree',
labelKey: 'system.dataPerm.scenario.orgTree',
descKey: 'system.dataPerm.scenario.orgTreeDesc',
dataScope: 4,
secretLevels: [1, 2, 3],
dataResourceCode: 'Order',
},
{
key: 'global',
labelKey: 'system.dataPerm.scenario.global',
descKey: 'system.dataPerm.scenario.globalDesc',
dataScope: 5,
secretLevels: [1, 2, 3, 4],
dataResourceCode: 'Order',
},
]
export function isResourceEnforced(code?: string | null, metaFlag?: boolean) {
if (typeof metaFlag === 'boolean') return metaFlag
if (!code) return false
return ENFORCED_RESOURCE_CODES.has(code)
}
export function resourceOptionLabel(code: string, name: string, isEnforced?: boolean) {
const enforced = isResourceEnforced(code, isEnforced)
return enforced ? name : `${name}(未接入)`
}
export function emptySaveInput() {
return {
orgPerms: [] as any[],
@ -42,3 +132,23 @@ export function emptySaveInput() {
export function emptyFilterContent() {
return { logic: 'and' as const, conditions: [] as { field: string; op: string; value?: unknown }[] }
}
export function buildScenarioPatch(preset: ScenarioPreset) {
const now = Date.now()
return {
dataScopes: [
{
_key: `scope-scenario-${now}`,
dataScope: preset.dataScope,
dataResourceCode: preset.dataResourceCode,
expireTime: null,
},
],
secretPerms: preset.secretLevels.map((level, i) => ({
_key: `secret-scenario-${now}-${i}`,
secretLevel: level,
dataResourceCode: preset.dataResourceCode,
expireTime: null,
})),
}
}

View File

@ -45,33 +45,6 @@
v-model:active-tab="activeTab"
:loading="detailLoading"
>
<template #icon>
<div class="icon-badge-circle">
<icon-file />
</div>
</template>
<template #header-extra>
<ol class="tpl-flow">
<li
class="tpl-flow__item"
:class="{ 'is-active': activeTab === 'basic', 'is-done': !!form.name && !!form.code }"
>
<span class="tpl-flow__num">1</span>
<span class="tpl-flow__text">{{ t('system.dataPerm.templates.flow.step1') }}</span>
</li>
<li
class="tpl-flow__item"
:class="{ 'is-active': activeTab === 'items', 'is-done': form.items.length > 0 }"
>
<span class="tpl-flow__num">2</span>
<span class="tpl-flow__text">{{ t('system.dataPerm.templates.flow.step2') }}</span>
</li>
<li class="tpl-flow__item" :class="{ 'is-done': canApply && !!bindForm.boundRoleId }">
<span class="tpl-flow__num">3</span>
<span class="tpl-flow__text">{{ t('system.dataPerm.templates.flow.step3') }}</span>
</li>
</ol>
</template>
<template #actions>
<a-button
v-if="hasPermission('Rbac.DataPerm.Template')"
@ -137,7 +110,90 @@
<template v-if="form.items.length">({{ form.items.length }})</template>
</a-button>
</section>
</div>
<div v-show="activeTab === 'items'" class="tpl-pane">
<div class="tpl-items-guide">
<div class="tpl-items-guide__text">
<p class="tpl-items-guide__title">{{ t('system.dataPerm.templates.itemsGuideTitle') }}</p>
<p class="tpl-items-guide__desc">{{ t('system.dataPerm.templates.itemsHintForm') }}</p>
</div>
<a-space wrap>
<a-dropdown @select="applyExamplePreset">
<a-button>
{{ t('system.dataPerm.templates.addExample') }}
<icon-down />
</a-button>
<template #content>
<a-doption v-for="preset in examplePresets" :key="preset.key" :value="preset.key">
<div class="preset-option">
<span class="preset-label">{{ t(preset.labelKey) }}</span>
<span class="preset-desc">{{ t(preset.descKey) }}</span>
</div>
</a-doption>
</template>
</a-dropdown>
<a-button type="primary" @click="addItem">
{{ t('system.dataPerm.templates.addItem') }}
</a-button>
</a-space>
</div>
<div v-if="form.items.length === 0" class="tpl-items-empty">
<p class="tpl-items-empty__title">{{ t('system.dataPerm.templates.itemsEmpty') }}</p>
<p class="tpl-items-empty__desc">{{ t('system.dataPerm.templates.itemsEmptyHint') }}</p>
<a-space>
<a-button type="primary" @click="addItem">{{ t('system.dataPerm.templates.addItem') }}</a-button>
<a-button @click="applyExamplePreset('salesStaff')">
{{ t('system.dataPerm.templates.example.salesStaff') }}
</a-button>
</a-space>
</div>
<div v-for="(item, idx) in form.items" :key="item._key" class="item-card">
<div class="item-card-head">
<div class="item-card-head-left">
<span class="item-index">{{ t('system.dataPerm.templates.itemIndex', { index: idx + 1 }) }}</span>
<a-select
v-model="item.form.dimensionType"
:options="dimensionOptions"
style="width: 168px"
:placeholder="t('system.dataPerm.templates.dimensionPlaceholder')"
@change="(v: string) => onDimensionChange(item, v)"
/>
</div>
<a-button type="text" status="danger" size="mini" @click="form.items.splice(idx, 1)">
{{ t('system.dataPerm.templates.removeItem') }}
</a-button>
</div>
<div class="item-card-body">
<p v-if="dimensionTip(item.form.dimensionType)" class="item-tip">
{{ dimensionTip(item.form.dimensionType) }}
</p>
<TemplateItemForm
v-model="item.form"
:org-tree="orgTree"
:org-scope-options="orgScopeOptions"
:data-scope-options="dataScopeOptions"
:secret-level-options="secretLevelOptions"
:data-resources="enrichedResources"
:biz-type-options="bizTypeOptions"
/>
</div>
</div>
<section class="tpl-next-card">
<div class="tpl-next-card__main">
<p class="tpl-next-card__title">{{ t('system.dataPerm.templates.flow.goApplyTitle') }}</p>
<p class="tpl-next-card__desc">{{ t('system.dataPerm.templates.flow.goApplyDesc') }}</p>
</div>
<a-button type="primary" :disabled="!canApply" @click="activeTab = 'apply'">
{{ t('system.dataPerm.templates.flow.goApplyBtn') }}
</a-button>
</section>
</div>
<div v-show="activeTab === 'apply'" class="tpl-pane">
<section class="tpl-card">
<div class="tpl-card__head">
<div>
@ -265,77 +321,6 @@
</div>
</section>
</div>
<div v-show="activeTab === 'items'" class="tpl-pane">
<div class="tpl-items-guide">
<div class="tpl-items-guide__text">
<p class="tpl-items-guide__title">{{ t('system.dataPerm.templates.itemsGuideTitle') }}</p>
<p class="tpl-items-guide__desc">{{ t('system.dataPerm.templates.itemsHintForm') }}</p>
</div>
<a-space wrap>
<a-dropdown @select="applyExamplePreset">
<a-button>
{{ t('system.dataPerm.templates.addExample') }}
<icon-down />
</a-button>
<template #content>
<a-doption v-for="preset in examplePresets" :key="preset.key" :value="preset.key">
<div class="preset-option">
<span class="preset-label">{{ t(preset.labelKey) }}</span>
<span class="preset-desc">{{ t(preset.descKey) }}</span>
</div>
</a-doption>
</template>
</a-dropdown>
<a-button type="primary" @click="addItem">
{{ t('system.dataPerm.templates.addItem') }}
</a-button>
</a-space>
</div>
<div v-if="form.items.length === 0" class="tpl-items-empty">
<p class="tpl-items-empty__title">{{ t('system.dataPerm.templates.itemsEmpty') }}</p>
<p class="tpl-items-empty__desc">{{ t('system.dataPerm.templates.itemsEmptyHint') }}</p>
<a-space>
<a-button type="primary" @click="addItem">{{ t('system.dataPerm.templates.addItem') }}</a-button>
<a-button @click="applyExamplePreset('salesStaff')">
{{ t('system.dataPerm.templates.example.salesStaff') }}
</a-button>
</a-space>
</div>
<div v-for="(item, idx) in form.items" :key="item._key" class="item-card">
<div class="item-card-head">
<div class="item-card-head-left">
<span class="item-index">{{ t('system.dataPerm.templates.itemIndex', { index: idx + 1 }) }}</span>
<a-select
v-model="item.form.dimensionType"
:options="dimensionOptions"
style="width: 168px"
:placeholder="t('system.dataPerm.templates.dimensionPlaceholder')"
@change="(v: string) => onDimensionChange(item, v)"
/>
</div>
<a-button type="text" status="danger" size="mini" @click="form.items.splice(idx, 1)">
{{ t('system.dataPerm.templates.removeItem') }}
</a-button>
</div>
<div class="item-card-body">
<p v-if="dimensionTip(item.form.dimensionType)" class="item-tip">
{{ dimensionTip(item.form.dimensionType) }}
</p>
<TemplateItemForm
v-model="item.form"
:org-tree="orgTree"
:org-scope-options="orgScopeOptions"
:data-scope-options="dataScopeOptions"
:secret-level-options="secretLevelOptions"
:data-resources="meta.dataResources"
:biz-type-options="bizTypeOptions"
/>
</div>
</div>
</div>
</RbacDetailShell>
</div>
</div>
@ -347,7 +332,7 @@ defineOptions({ name: 'SystemDataPermTemplates' })
import { computed, onMounted, reactive, ref, watch } from 'vue'
import { useI18n } from 'vue-i18n'
import { Message, Modal } from '@arco-design/web-vue'
import { IconFile, IconDown } from '@arco-design/web-vue/es/icon'
import { IconDown } from '@arco-design/web-vue/es/icon'
import CustomLeftMenu from '@/components/CustomLeftMenu/index.vue'
import RbacDetailShell from '@/components/RbacSplit/RbacDetailShell.vue'
import type { RbacDetailTag } from '@/components/RbacSplit/RbacDetailShell.vue'
@ -372,6 +357,8 @@ import {
DEFAULT_ORG_SCOPES,
DEFAULT_SECRET_LEVELS,
DEFAULT_BIZ_TYPES,
isResourceEnforced,
resourceOptionLabel,
} from '../constants'
import TemplateItemForm from '../components/TemplateItemForm.vue'
import {
@ -493,8 +480,20 @@ const templateTabs = computed(() => [
label: t('system.dataPerm.templates.tab.items'),
badge: form.items.length || undefined,
},
{
key: 'apply',
label: t('system.dataPerm.templates.tab.apply'),
},
])
const enrichedResources = computed(() =>
(meta.dataResources || []).map((r) => ({
...r,
isEnforced: isResourceEnforced(r.code, r.isEnforced),
name: resourceOptionLabel(r.code, r.name, r.isEnforced),
}))
)
function dimensionTip(type: string) {
const key = `system.dataPerm.templates.form.tip.${type}`
const text = t(key)
@ -833,10 +832,12 @@ async function handleSave() {
if (created?.id) {
selectedTemplate.value = dataSource.value.find((x) => x.id === created.id) || null
}
activeTab.value = 'apply'
} else if (selectedTemplate.value?.id) {
await updateTemplate(selectedTemplate.value.id, body)
Message.success(t('system.dataPerm.templates.updateSuccess'))
await loadData()
activeTab.value = 'apply'
}
} catch (e) {
handleApiError(e)
@ -908,66 +909,6 @@ onMounted(async () => {
white-space: nowrap;
}
.tpl-flow {
display: flex;
flex-wrap: wrap;
align-items: center;
gap: 8px 16px;
margin: 0;
padding: 0;
list-style: none;
}
.tpl-flow__item {
display: inline-flex;
align-items: center;
gap: 8px;
color: var(--color-text-3);
}
.tpl-flow__num {
width: 20px;
height: 20px;
border-radius: 50%;
display: inline-flex;
align-items: center;
justify-content: center;
font-size: 11px;
font-weight: 600;
color: var(--color-text-3);
background: var(--color-fill-2);
border: 1px solid var(--color-border-2);
}
.tpl-flow__text {
font-size: 12px;
line-height: 1.3;
}
.tpl-flow__item.is-active {
color: var(--color-text-1);
.tpl-flow__num {
color: #fff;
background: var(--app-primary-color, #1d7281);
border-color: var(--app-primary-color, #1d7281);
}
.tpl-flow__text {
font-weight: 600;
}
}
.tpl-flow__item.is-done:not(.is-active) {
color: var(--color-text-2);
.tpl-flow__num {
color: var(--app-primary-color, #1d7281);
background: color-mix(in srgb, var(--app-primary-color, #1d7281) 12%, #fff);
border-color: color-mix(in srgb, var(--app-primary-color, #1d7281) 28%, #fff);
}
}
.tpl-pane {
display: flex;
flex-direction: column;

View File

@ -21,7 +21,19 @@
@refresh="loadData"
@select="handleUserSelect"
@node-click="handleUserNodeClick"
/>
>
<template #search-extra>
<a-tree-select
v-model="filterOrganizationId"
:placeholder="t('system.user.search.organizationPlaceholder')"
:data="organizationTreeData"
allow-clear
allow-search
style="width: 100%"
@change="handleSearch"
/>
</template>
</CustomLeftMenu>
<div class="right-panel">
<RbacDetailShell
@ -30,28 +42,31 @@
:empty-desc="t('system.dataPerm.users.emptyDesc')"
:title="selectedUser?.name || ''"
:subtitle="selectedUser?.account || ''"
:tags="userTags"
:tags="userHeaderTags"
:stats="userStats"
>
<template #icon>
<div class="avatar-circle">{{ userInitials }}</div>
</template>
<template #actions>
<a-tree-select
v-model="filterOrganizationId"
:placeholder="t('system.user.search.organizationPlaceholder')"
:data="organizationTreeData"
allow-clear
style="width: 200px"
@change="handleSearch"
/>
<a-button
v-if="selectedUser && hasPermission('Rbac.DataPerm.Update')"
type="primary"
:loading="panelSaving"
@click="handleSavePerm"
>
{{
panelDirty
? t('system.dataPerm.panel.saveDirty')
: t('system.dataPerm.panel.save')
}}
</a-button>
</template>
<DataPermPanel
ref="panelRef"
embedded
:target-user="selectedUser"
@saved="loadData"
@saved="onPanelSaved"
@stats-change="onStatsChange"
@dirty-change="onDirtyChange"
/>
</RbacDetailShell>
</div>
@ -69,6 +84,7 @@ import type { RbacDetailStat, RbacDetailTag } from '@/components/RbacSplit/RbacD
import { getInternalUserList, OrganizationService } from '@/api/rbac'
import type { UserDto, OrganizationTreeDto } from '@/api/rbac'
import { handleApiError } from '@/utils/rbac-error-handler'
import { hasPermission } from '@/utils/rbac-permission'
import { buildFlatLeftMenuTree, findLeftMenuItemByKey } from '@/utils/rbacLeftMenuTree'
import DataPermPanel from '../components/DataPermPanel.vue'
@ -82,6 +98,28 @@ const organizationTree = ref<OrganizationTreeDto[]>([])
const selectedUser = ref<UserDto | null>(null)
const expandedKeys = ref(['category-users'])
const permCounts = ref({ org: 0, scope: 0, biz: 0, secret: 0, filter: 0 })
const panelRef = ref<InstanceType<typeof DataPermPanel> | null>(null)
const panelSaving = ref(false)
const panelDirty = ref(false)
async function handleSavePerm() {
if (!panelRef.value?.save) return
panelSaving.value = true
try {
await panelRef.value.save()
} finally {
panelSaving.value = false
}
}
function onDirtyChange(dirty: boolean) {
panelDirty.value = dirty
}
function onPanelSaved() {
panelDirty.value = false
loadData()
}
const organizationTreeData = computed(() => {
const convert = (data: OrganizationTreeDto[]): any[] =>
@ -105,16 +143,14 @@ const selectedKeys = computed(() =>
selectedUser.value?.id ? [`item-${selectedUser.value.id}`] : []
)
const userInitials = computed(() => {
const name = selectedUser.value?.name || selectedUser.value?.account || '?'
return name.slice(0, 1).toUpperCase()
})
const userTags = computed((): RbacDetailTag[] => {
const userHeaderTags = computed((): RbacDetailTag[] => {
if (!selectedUser.value) return []
const tags: RbacDetailTag[] = [
{ label: t('system.dataPerm.panel.configTypeDirect'), color: 'arcoblue' },
{ label: t('system.dataPerm.panel.configTypeException'), color: 'arcoblue' },
]
if (panelDirty.value) {
tags.push({ label: t('system.dataPerm.panel.dirtyTag'), color: 'orangered' })
}
selectedUser.value.roles?.slice(0, 3).forEach((role) => {
if (role.name) tags.push({ label: role.name, color: 'gray' })
})
@ -150,7 +186,10 @@ function onStatsChange(counts: Record<string, number>) {
function selectUserFromKey(key: string) {
const user = findLeftMenuItemByKey(key, dataSource.value)
if (user) selectedUser.value = user
if (user) {
panelDirty.value = false
selectedUser.value = user
}
}
function handleUserSelect(keys: string[]) {

File diff suppressed because it is too large Load Diff

View File

@ -39,11 +39,6 @@
v-model:active-tab="activeTab"
:loading="permissionLoading && activeTab === 'permissions'"
>
<template #icon>
<div class="icon-badge-circle">
<icon-user-group />
</div>
</template>
<template #actions>
<a-button
v-if="hasPermission('Rbac.Roles.Update') || isCreating"
@ -51,64 +46,77 @@
:loading="modalLoading || permissionSaving"
@click="handleSaveAll"
>
{{ t('system.role.actions.save') }}
{{ dirty ? t('system.role.actions.saveDirty') : t('system.role.actions.save') }}
</a-button>
</template>
<template #header-extra>
<a-form
ref="formRef"
:model="formState"
:rules="formRules"
layout="inline"
class="role-header-form"
>
<a-form-item :label="t('system.role.form.name')" field="name">
<a-input
v-model="formState.name"
:placeholder="t('system.role.form.namePlaceholder')"
style="width: 160px"
/>
</a-form-item>
<a-form-item :label="t('system.role.form.code')" field="code">
<a-input
v-model="formState.code"
:placeholder="t('system.role.form.codePlaceholder')"
:disabled="!isCreating"
style="width: 160px"
/>
</a-form-item>
<a-form-item :label="t('system.role.form.boundWarehouse')" field="boundWarehouseId">
<a-select
v-model="formState.boundWarehouseId"
:placeholder="t('system.role.form.boundWarehousePlaceholder')"
allow-clear
:options="warehouseOptions"
style="width: 180px"
/>
</a-form-item>
<a-form-item v-if="!isCreating" :label="t('system.role.table.createTime')">
<span class="role-create-time">{{ formatTime(selectedRole?.createdAt) }}</span>
</a-form-item>
</a-form>
</template>
<div v-show="activeTab === 'basic'" class="role-pane">
<section class="role-card">
<div class="role-card__head">
<h3 class="role-card__title">{{ t('system.role.section.identity') }}</h3>
<p class="role-card__hint">{{ t('system.role.section.identityHint') }}</p>
</div>
<div class="role-card__body">
<a-form
ref="formRef"
:model="formState"
:rules="formRules"
layout="vertical"
class="role-basic-form"
>
<a-row :gutter="16">
<a-col :span="12">
<a-form-item :label="t('system.role.form.name')" field="name" required>
<a-input
v-model="formState.name"
:placeholder="t('system.role.form.namePlaceholder')"
allow-clear
/>
</a-form-item>
</a-col>
<a-col :span="12">
<a-form-item :label="t('system.role.form.code')" field="code" required>
<a-input
v-model="formState.code"
:placeholder="t('system.role.form.codePlaceholder')"
:disabled="!isCreating"
allow-clear
/>
</a-form-item>
</a-col>
<a-col :span="12">
<a-form-item :label="t('system.role.form.boundWarehouse')" field="boundWarehouseId">
<a-select
v-model="formState.boundWarehouseId"
:placeholder="t('system.role.form.boundWarehousePlaceholder')"
allow-clear
:options="warehouseOptions"
/>
</a-form-item>
</a-col>
<a-col v-if="!isCreating" :span="12">
<a-form-item :label="t('system.role.table.createTime')">
<span class="role-create-time">{{ formatTime(selectedRole?.createdAt) }}</span>
</a-form-item>
</a-col>
</a-row>
</a-form>
</div>
</section>
<template v-if="activeTab === 'permissions' && !isSelectedAdminRole" #tabs-extra>
<a-space wrap :size="8">
<a-input
v-model="permissionKeyword"
:placeholder="t('system.role.permission.search')"
allow-clear
style="width: 220px"
/>
<a-button class="app-btn-toolbar" @click="checkAllPermissions">
{{ t('system.role.permission.checkAll') }}
<section v-if="canAssignPermissions" class="role-next-card">
<div class="role-next-card__main">
<p class="role-next-card__title">{{ t('system.role.flow.goPermTitle') }}</p>
<p class="role-next-card__desc">{{ t('system.role.flow.goPermDesc') }}</p>
</div>
<a-button type="primary" @click="activeTab = 'permissions'">
{{ t('system.role.flow.goPermBtn') }}
<template v-if="!isSelectedAdminRole && totalPermissionCount">
({{ selectedPermissionCount }}/{{ totalPermissionCount }})
</template>
</a-button>
<a-button class="app-btn-toolbar" @click="uncheckAllPermissions">
{{ t('system.role.permission.uncheckAll') }}
</a-button>
</a-space>
</template>
</section>
</div>
<div v-show="activeTab === 'permissions'" class="permission-body">
<a-alert
@ -117,7 +125,21 @@
show-icon
:title="t('system.role.permission.adminAllHint')"
/>
<template v-else>
<template v-else-if="canAssignPermissions">
<div class="permission-toolbar">
<a-input
v-model="permissionKeyword"
:placeholder="t('system.role.permission.search')"
allow-clear
class="permission-toolbar__search"
/>
<a-button class="app-btn-toolbar" @click="checkAllPermissions">
{{ t('system.role.permission.checkAll') }}
</a-button>
<a-button class="app-btn-toolbar" @click="uncheckAllPermissions">
{{ t('system.role.permission.uncheckAll') }}
</a-button>
</div>
<a-table
v-if="filteredPermissionRows.length > 0"
class="permission-table"
@ -183,6 +205,7 @@
}}
</div>
</template>
<a-empty v-else :description="t('system.role.permission.noAssignRight')" />
</div>
</RbacDetailShell>
</div>
@ -195,7 +218,6 @@ defineOptions({ name: 'SystemRoles' })
import { computed, onMounted, reactive, ref, watch } from 'vue'
import { useI18n } from 'vue-i18n'
import { Message, Modal } from '@arco-design/web-vue'
import { IconUserGroup } from '@arco-design/web-vue/es/icon'
import CustomLeftMenu from '@/components/CustomLeftMenu/index.vue'
import RbacDetailShell from '@/components/RbacSplit/RbacDetailShell.vue'
import type { RbacDetailTag } from '@/components/RbacSplit/RbacDetailShell.vue'
@ -231,9 +253,12 @@ const searchKeyword = ref('')
const selectedRole = ref<RoleDto | null>(null)
const isCreating = ref(false)
const expandedKeys = ref(['category-roles'])
const activeTab = ref('permissions')
const activeTab = ref('basic')
const formRef = ref()
const permissionKeyword = ref('')
const dirty = ref(false)
let baselineJson = ''
let dirtyWatchReady = false
const pagination = reactive({ current: 1, pageSize: 100 })
@ -256,7 +281,9 @@ const permissionLoading = ref(false)
const permissionSaving = ref(false)
const permissionTree = ref<PermissionGroupDto[]>([])
const selectedPermissions = ref<string[]>([])
const permissionTableScrollY = 'calc(100vh - 300px)'
const permissionTableScrollY = 'calc(100vh - 280px)'
const canAssignPermissions = computed(() => hasPermission('Rbac.Roles.AssignPermissions'))
const roleTreeData = computed(() =>
buildFlatLeftMenuTree('category-roles', t('system.role.pageTitle'), dataSource.value, {
@ -315,13 +342,16 @@ const headerSubtitle = computed(() => {
})
const roleTags = computed((): RbacDetailTag[] => {
if (!selectedRole.value) return []
if (!selectedRole.value && !isCreating.value) return []
const tags: RbacDetailTag[] = []
if (isCreating.value) {
tags.push({ label: t('system.role.tag.creating'), color: 'orangered' })
}
if (dirty.value) {
tags.push({ label: t('system.role.tag.dirty'), color: 'orangered' })
}
if (isAdminRole(selectedRole.value)) {
tags.push({ label: 'Admin', color: 'purple' })
tags.push({ label: t('system.role.tag.admin'), color: 'purple' })
}
if (isCustomerRole(selectedRole.value)) {
tags.push({ label: t('system.role.category.system'), color: 'arcoblue' })
@ -333,21 +363,45 @@ const roleTags = computed((): RbacDetailTag[] => {
})
const roleTabs = computed(() => {
if (!hasPermission('Rbac.Roles.AssignPermissions')) return []
const tabs: { key: string; label: string; badge?: string | number }[] = [
{ key: 'basic', label: t('system.role.tab.info') },
]
if (!canAssignPermissions.value) return tabs
if (isSelectedAdminRole.value) {
return [{ key: 'permissions', label: t('system.role.modal.assignPermissions') }]
tabs.push({ key: 'permissions', label: t('system.role.modal.assignPermissions') })
return tabs
}
const selected = selectedPermissionCount.value
const total = totalPermissionCount.value
return [
{
key: 'permissions',
label: t('system.role.modal.assignPermissions'),
badge: `${selected}/${total}`,
},
]
tabs.push({
key: 'permissions',
label: t('system.role.modal.assignPermissions'),
badge: total ? `${selected}/${total}` : undefined,
})
return tabs
})
function snapshotState() {
return JSON.stringify({
name: formState.name || '',
code: formState.code || '',
boundWarehouseId: formState.boundWarehouseId || '',
permissions: [...selectedPermissions.value].sort(),
})
}
function captureBaseline() {
baselineJson = snapshotState()
dirty.value = false
}
function refreshDirty() {
if (!dirtyWatchReady || loading.value || modalLoading.value || permissionSaving.value) return
dirty.value = snapshotState() !== baselineJson
}
function permissionSpanMethod({
rowIndex,
columnIndex,
@ -390,6 +444,7 @@ function formatTime(value?: string | null) {
function selectRoleFromKey(key: string) {
const role = findLeftMenuItemByKey(key, dataSource.value)
if (role) {
dirty.value = false
isCreating.value = false
selectedRole.value = role
}
@ -445,14 +500,18 @@ async function loadPermissionTree() {
async function loadRolePermissions(roleId: string) {
permissionLoading.value = true
dirtyWatchReady = false
try {
await loadPermissionTree()
const loaded = (await RoleService.getRbacRoleGetRolePermissions(roleId)) || []
selectedPermissions.value = normalizeSelectedPermissions(loaded, permissionRows.value)
captureBaseline()
} catch (error) {
handleApiError(error)
captureBaseline()
} finally {
permissionLoading.value = false
dirtyWatchReady = true
}
}
@ -470,11 +529,14 @@ function handleSearch() {
}
function handleAdd() {
dirtyWatchReady = false
isCreating.value = true
selectedRole.value = { name: '', code: '' }
Object.assign(formState, { name: '', code: '', boundWarehouseId: undefined })
activeTab.value = 'permissions'
activeTab.value = 'basic'
selectedPermissions.value = []
captureBaseline()
dirtyWatchReady = true
}
async function handleDelete(id?: string) {
@ -537,7 +599,10 @@ async function handleSaveRole() {
}
return null
} catch (error: any) {
if (error?.fields) return null
if (error?.fields) {
activeTab.value = 'basic'
return null
}
handleApiError(error)
return null
} finally {
@ -549,7 +614,7 @@ async function handleSavePermissions(roleId?: string) {
const id = roleId || selectedRole.value?.id
if (!id || isCreating.value) return false
if (isAdminRole(selectedRole.value)) return true
if (!hasPermission('Rbac.Roles.AssignPermissions')) return true
if (!canAssignPermissions.value) return true
permissionSaving.value = true
try {
@ -577,17 +642,21 @@ async function handleSaveAll() {
const roleId = await handleSaveRole()
if (!roleId) return
// 新建已提示成功;Admin 无需写权限
if (wasCreating || isAdminRole(selectedRole.value)) {
if (!wasCreating) {
Message.success(t('system.role.message.updateSuccess'))
}
captureBaseline()
if (wasCreating && canAssignPermissions.value) {
activeTab.value = 'permissions'
}
return
}
const ok = await handleSavePermissions(roleId)
if (ok) {
Message.success(t('system.role.message.updateSuccess'))
captureBaseline()
}
}
@ -595,13 +664,20 @@ watch(
() => selectedRole.value?.id,
async (roleId) => {
if (!roleId || isCreating.value) return
dirtyWatchReady = false
syncFormFromRole(selectedRole.value!)
activeTab.value = 'permissions'
activeTab.value = canAssignPermissions.value ? 'permissions' : 'basic'
permissionKeyword.value = ''
await loadRolePermissions(roleId)
}
)
watch(
[() => formState.name, () => formState.code, () => formState.boundWarehouseId, selectedPermissions],
() => refreshDirty(),
{ deep: true }
)
onMounted(async () => {
await loadData()
await loadPermissionTree()
@ -611,31 +687,81 @@ onMounted(async () => {
<style scoped lang="less">
@import '@/components/RbacSplit/rbac-split-layout.less';
.role-header-form {
.role-pane {
display: flex;
flex-wrap: wrap;
gap: 4px 8px;
width: 100%;
flex-direction: column;
gap: 14px;
max-width: 880px;
}
.role-card {
border: 1px solid var(--color-border-2);
border-radius: 10px;
background: #fff;
overflow: hidden;
}
.role-card__head {
padding: 14px 18px 0;
}
.role-card__title {
margin: 0;
font-size: 14px;
font-weight: 600;
color: var(--color-text-1);
}
.role-card__hint {
margin: 4px 0 0;
font-size: 12px;
color: var(--color-text-3);
line-height: 1.4;
}
.role-card__body {
padding: 12px 18px 16px;
}
.role-basic-form {
:deep(.arco-form-item) {
margin-bottom: 0;
margin-right: 12px;
}
:deep(.arco-form-item-label-col > label) {
color: var(--color-text-3);
font-size: 13px;
margin-bottom: 12px;
}
}
.role-create-time {
display: inline-block;
min-width: 150px;
font-size: 13px;
color: var(--color-text-2);
line-height: 32px;
}
.role-next-card {
display: flex;
align-items: center;
justify-content: space-between;
gap: 16px;
flex-wrap: wrap;
padding: 14px 16px;
border-radius: 10px;
border: 1px solid color-mix(in srgb, var(--app-primary-color, #1d7281) 28%, #fff);
background: color-mix(in srgb, var(--app-primary-color, #1d7281) 8%, #fff);
}
.role-next-card__title {
margin: 0;
font-size: 14px;
font-weight: 600;
color: var(--color-text-1);
}
.role-next-card__desc {
margin: 4px 0 0;
font-size: 12px;
color: var(--color-text-3);
line-height: 1.4;
}
.permission-body {
display: flex;
flex-direction: column;
@ -643,6 +769,19 @@ onMounted(async () => {
height: 100%;
}
.permission-toolbar {
display: flex;
align-items: center;
justify-content: center;
flex-wrap: wrap;
gap: 8px;
margin-bottom: 12px;
}
.permission-toolbar__search {
width: 220px;
}
.permission-table {
width: 100%;