feat(web): update composables and utils

- useAppShell.js: update app shell composable
- useNavigation.js: update navigation composable
- utils/accessControl.js: update access control utility
This commit is contained in:
caoxiaozhu
2026-05-14 02:59:54 +00:00
parent 736cc6b52b
commit b9cb6d9253
3 changed files with 15 additions and 71 deletions

View File

@@ -3,16 +3,13 @@ import { useRoute, useRouter } from 'vue-router'
import { useNavigation, navItems } from './useNavigation.js'
import { useRequests } from './useRequests.js'
import { useChat } from './useChat.js'
import { useToast } from './useToast.js'
import { documents } from '../data/requests.js'
import { normalizeRequestForUi } from '../utils/requestViewModel.js'
export function useAppShell() {
const route = useRoute()
const router = useRouter()
const travelCreateMode = ref(false)
const smartEntryOpen = ref(false)
const smartEntryContext = ref({ prompt: '', source: 'requests', request: null, files: [], conversation: null })
const smartEntrySessionId = ref(0)
@@ -31,24 +28,9 @@ export function useAppShell() {
rejectRequest,
reload: reloadRequests
} = useRequests()
const {
messages,
draft,
uploadedFiles,
messageList,
activeCase,
prompts,
sending,
sendMessage,
handleUpload,
openChat,
openNewChat
} = useChat(activeView)
const { toast } = useToast()
const docSearch = ref('')
const customRange = ref({ start: '2024-07-06', end: '2024-07-12' })
const travelPrompts = ['生成差旅摘要', '识别报销风险', '核对审批链', '提取随附票据', '生成沟通建议']
const selectedRequest = computed(() => {
const requestId = String(route.params.requestId || '')
@@ -102,11 +84,6 @@ export function useAppShell() {
)
)
const filteredDocuments = computed(() => {
const key = docSearch.value.trim().toLowerCase()
return documents.filter((doc) => !key || `${doc.id}${doc.applicant}${doc.destination}${doc.type}`.toLowerCase().includes(key))
})
function handleApprove(request) {
const message = approveRequest(request)
toast(message)
@@ -118,26 +95,18 @@ export function useAppShell() {
}
function handleNavigate(view) {
travelCreateMode.value = false
smartEntryOpen.value = false
setView(view)
}
function handleOpenChat(request) {
travelCreateMode.value = false
openChat(request)
}
function openTravelCreate() {
smartEntryOpen.value = true
travelCreateMode.value = false
smartEntryContext.value = { prompt: '', source: 'topbar', request: null, files: [], conversation: null }
smartEntrySessionId.value += 1
}
function openSmartEntry(payload = {}) {
smartEntryOpen.value = true
travelCreateMode.value = false
smartEntryContext.value = {
prompt: payload.prompt ?? '',
@@ -190,28 +159,18 @@ export function useAppShell() {
currentView,
customRange,
detailMode,
docSearch,
draft,
filteredDocuments,
filteredRequests,
filters,
handleApprove,
handleDraftSaved,
handleNavigate,
handleOpenChat,
handleReject,
handleRequestDeleted,
handleRequestUpdated,
handleUpload,
messageList,
messages,
navItems,
openChat,
openNewChat,
openRequestDetail,
openSmartEntry,
openTravelCreate,
prompts,
ranges,
requestSummary,
requestsError,
@@ -220,16 +179,11 @@ export function useAppShell() {
requests,
search,
selectedRequest,
sendMessage,
sending,
setView,
smartEntryContext,
smartEntryOpen,
smartEntrySessionId,
toast,
topBarView,
travelCreateMode,
travelPrompts,
uploadedFiles
topBarView
}
}

View File

@@ -3,7 +3,7 @@ import { useRoute, useRouter } from 'vue-router'
import { icons } from '../data/icons.js'
export const appViews = ['overview', 'workbench', 'requests', 'approval', 'chat', 'policies', 'audit', 'employees', 'settings']
export const appViews = ['overview', 'workbench', 'requests', 'approval', 'policies', 'audit', 'employees', 'settings']
export const navItems = [
{
@@ -38,21 +38,13 @@ export const navItems = [
title: '审批中心',
desc: '按优先级处理待审批事项,控制时效与风险。'
},
{
id: 'chat',
label: '财务知识问答',
navHint: '进入财务知识问答',
icon: icons.message,
title: '财务知识问答',
desc: '围绕制度、票据、审批、报销与财务规则进行快速问答。'
},
{
id: 'policies',
label: '制度知识',
navHint: '查看制度与知识库',
icon: icons.file,
title: '制度与知识库',
desc: '统一管理制度文档、知识问答和搜索入口。'
desc: '统一管理制度文档、检索入口与知识资产。'
},
{
id: 'audit',
@@ -85,7 +77,6 @@ const viewRouteNames = {
workbench: 'app-workbench',
requests: 'app-requests',
approval: 'app-approval',
chat: 'app-chat',
policies: 'app-policies',
audit: 'app-audit',
employees: 'app-employees',

View File

@@ -1,16 +1,15 @@
export const DEFAULT_APP_VIEW_ORDER = [
'overview',
'workbench',
'requests',
'approval',
'chat',
'policies',
'audit',
'employees',
'settings'
]
const ALWAYS_VISIBLE_VIEWS = new Set(['workbench', 'requests', 'chat', 'policies'])
export const DEFAULT_APP_VIEW_ORDER = [
'overview',
'workbench',
'requests',
'approval',
'policies',
'audit',
'employees',
'settings'
]
const ALWAYS_VISIBLE_VIEWS = new Set(['workbench', 'requests', 'policies'])
const VIEW_ROLE_RULES = {
overview: ['finance', 'executive'],
approval: ['approver'],