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:
@@ -3,16 +3,13 @@ import { useRoute, useRouter } from 'vue-router'
|
|||||||
|
|
||||||
import { useNavigation, navItems } from './useNavigation.js'
|
import { useNavigation, navItems } from './useNavigation.js'
|
||||||
import { useRequests } from './useRequests.js'
|
import { useRequests } from './useRequests.js'
|
||||||
import { useChat } from './useChat.js'
|
|
||||||
import { useToast } from './useToast.js'
|
import { useToast } from './useToast.js'
|
||||||
import { documents } from '../data/requests.js'
|
|
||||||
import { normalizeRequestForUi } from '../utils/requestViewModel.js'
|
import { normalizeRequestForUi } from '../utils/requestViewModel.js'
|
||||||
|
|
||||||
export function useAppShell() {
|
export function useAppShell() {
|
||||||
const route = useRoute()
|
const route = useRoute()
|
||||||
const router = useRouter()
|
const router = useRouter()
|
||||||
|
|
||||||
const travelCreateMode = ref(false)
|
|
||||||
const smartEntryOpen = ref(false)
|
const smartEntryOpen = ref(false)
|
||||||
const smartEntryContext = ref({ prompt: '', source: 'requests', request: null, files: [], conversation: null })
|
const smartEntryContext = ref({ prompt: '', source: 'requests', request: null, files: [], conversation: null })
|
||||||
const smartEntrySessionId = ref(0)
|
const smartEntrySessionId = ref(0)
|
||||||
@@ -31,24 +28,9 @@ export function useAppShell() {
|
|||||||
rejectRequest,
|
rejectRequest,
|
||||||
reload: reloadRequests
|
reload: reloadRequests
|
||||||
} = useRequests()
|
} = useRequests()
|
||||||
const {
|
|
||||||
messages,
|
|
||||||
draft,
|
|
||||||
uploadedFiles,
|
|
||||||
messageList,
|
|
||||||
activeCase,
|
|
||||||
prompts,
|
|
||||||
sending,
|
|
||||||
sendMessage,
|
|
||||||
handleUpload,
|
|
||||||
openChat,
|
|
||||||
openNewChat
|
|
||||||
} = useChat(activeView)
|
|
||||||
const { toast } = useToast()
|
const { toast } = useToast()
|
||||||
|
|
||||||
const docSearch = ref('')
|
|
||||||
const customRange = ref({ start: '2024-07-06', end: '2024-07-12' })
|
const customRange = ref({ start: '2024-07-06', end: '2024-07-12' })
|
||||||
const travelPrompts = ['生成差旅摘要', '识别报销风险', '核对审批链', '提取随附票据', '生成沟通建议']
|
|
||||||
|
|
||||||
const selectedRequest = computed(() => {
|
const selectedRequest = computed(() => {
|
||||||
const requestId = String(route.params.requestId || '')
|
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) {
|
function handleApprove(request) {
|
||||||
const message = approveRequest(request)
|
const message = approveRequest(request)
|
||||||
toast(message)
|
toast(message)
|
||||||
@@ -118,26 +95,18 @@ export function useAppShell() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
function handleNavigate(view) {
|
function handleNavigate(view) {
|
||||||
travelCreateMode.value = false
|
|
||||||
smartEntryOpen.value = false
|
smartEntryOpen.value = false
|
||||||
setView(view)
|
setView(view)
|
||||||
}
|
}
|
||||||
|
|
||||||
function handleOpenChat(request) {
|
|
||||||
travelCreateMode.value = false
|
|
||||||
openChat(request)
|
|
||||||
}
|
|
||||||
|
|
||||||
function openTravelCreate() {
|
function openTravelCreate() {
|
||||||
smartEntryOpen.value = true
|
smartEntryOpen.value = true
|
||||||
travelCreateMode.value = false
|
|
||||||
smartEntryContext.value = { prompt: '', source: 'topbar', request: null, files: [], conversation: null }
|
smartEntryContext.value = { prompt: '', source: 'topbar', request: null, files: [], conversation: null }
|
||||||
smartEntrySessionId.value += 1
|
smartEntrySessionId.value += 1
|
||||||
}
|
}
|
||||||
|
|
||||||
function openSmartEntry(payload = {}) {
|
function openSmartEntry(payload = {}) {
|
||||||
smartEntryOpen.value = true
|
smartEntryOpen.value = true
|
||||||
travelCreateMode.value = false
|
|
||||||
|
|
||||||
smartEntryContext.value = {
|
smartEntryContext.value = {
|
||||||
prompt: payload.prompt ?? '',
|
prompt: payload.prompt ?? '',
|
||||||
@@ -190,28 +159,18 @@ export function useAppShell() {
|
|||||||
currentView,
|
currentView,
|
||||||
customRange,
|
customRange,
|
||||||
detailMode,
|
detailMode,
|
||||||
docSearch,
|
|
||||||
draft,
|
|
||||||
filteredDocuments,
|
|
||||||
filteredRequests,
|
filteredRequests,
|
||||||
filters,
|
filters,
|
||||||
handleApprove,
|
handleApprove,
|
||||||
handleDraftSaved,
|
handleDraftSaved,
|
||||||
handleNavigate,
|
handleNavigate,
|
||||||
handleOpenChat,
|
|
||||||
handleReject,
|
handleReject,
|
||||||
handleRequestDeleted,
|
handleRequestDeleted,
|
||||||
handleRequestUpdated,
|
handleRequestUpdated,
|
||||||
handleUpload,
|
|
||||||
messageList,
|
|
||||||
messages,
|
|
||||||
navItems,
|
navItems,
|
||||||
openChat,
|
|
||||||
openNewChat,
|
|
||||||
openRequestDetail,
|
openRequestDetail,
|
||||||
openSmartEntry,
|
openSmartEntry,
|
||||||
openTravelCreate,
|
openTravelCreate,
|
||||||
prompts,
|
|
||||||
ranges,
|
ranges,
|
||||||
requestSummary,
|
requestSummary,
|
||||||
requestsError,
|
requestsError,
|
||||||
@@ -220,16 +179,11 @@ export function useAppShell() {
|
|||||||
requests,
|
requests,
|
||||||
search,
|
search,
|
||||||
selectedRequest,
|
selectedRequest,
|
||||||
sendMessage,
|
|
||||||
sending,
|
|
||||||
setView,
|
setView,
|
||||||
smartEntryContext,
|
smartEntryContext,
|
||||||
smartEntryOpen,
|
smartEntryOpen,
|
||||||
smartEntrySessionId,
|
smartEntrySessionId,
|
||||||
toast,
|
toast,
|
||||||
topBarView,
|
topBarView
|
||||||
travelCreateMode,
|
|
||||||
travelPrompts,
|
|
||||||
uploadedFiles
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -3,7 +3,7 @@ import { useRoute, useRouter } from 'vue-router'
|
|||||||
|
|
||||||
import { icons } from '../data/icons.js'
|
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 = [
|
export const navItems = [
|
||||||
{
|
{
|
||||||
@@ -38,21 +38,13 @@ export const navItems = [
|
|||||||
title: '审批中心',
|
title: '审批中心',
|
||||||
desc: '按优先级处理待审批事项,控制时效与风险。'
|
desc: '按优先级处理待审批事项,控制时效与风险。'
|
||||||
},
|
},
|
||||||
{
|
|
||||||
id: 'chat',
|
|
||||||
label: '财务知识问答',
|
|
||||||
navHint: '进入财务知识问答',
|
|
||||||
icon: icons.message,
|
|
||||||
title: '财务知识问答',
|
|
||||||
desc: '围绕制度、票据、审批、报销与财务规则进行快速问答。'
|
|
||||||
},
|
|
||||||
{
|
{
|
||||||
id: 'policies',
|
id: 'policies',
|
||||||
label: '制度知识',
|
label: '制度知识',
|
||||||
navHint: '查看制度与知识库',
|
navHint: '查看制度与知识库',
|
||||||
icon: icons.file,
|
icon: icons.file,
|
||||||
title: '制度与知识库',
|
title: '制度与知识库',
|
||||||
desc: '统一管理制度文档、知识问答和搜索入口。'
|
desc: '统一管理制度文档、检索入口与知识资产。'
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
id: 'audit',
|
id: 'audit',
|
||||||
@@ -85,7 +77,6 @@ const viewRouteNames = {
|
|||||||
workbench: 'app-workbench',
|
workbench: 'app-workbench',
|
||||||
requests: 'app-requests',
|
requests: 'app-requests',
|
||||||
approval: 'app-approval',
|
approval: 'app-approval',
|
||||||
chat: 'app-chat',
|
|
||||||
policies: 'app-policies',
|
policies: 'app-policies',
|
||||||
audit: 'app-audit',
|
audit: 'app-audit',
|
||||||
employees: 'app-employees',
|
employees: 'app-employees',
|
||||||
|
|||||||
@@ -1,16 +1,15 @@
|
|||||||
export const DEFAULT_APP_VIEW_ORDER = [
|
export const DEFAULT_APP_VIEW_ORDER = [
|
||||||
'overview',
|
'overview',
|
||||||
'workbench',
|
'workbench',
|
||||||
'requests',
|
'requests',
|
||||||
'approval',
|
'approval',
|
||||||
'chat',
|
'policies',
|
||||||
'policies',
|
'audit',
|
||||||
'audit',
|
'employees',
|
||||||
'employees',
|
'settings'
|
||||||
'settings'
|
]
|
||||||
]
|
|
||||||
|
const ALWAYS_VISIBLE_VIEWS = new Set(['workbench', 'requests', 'policies'])
|
||||||
const ALWAYS_VISIBLE_VIEWS = new Set(['workbench', 'requests', 'chat', 'policies'])
|
|
||||||
const VIEW_ROLE_RULES = {
|
const VIEW_ROLE_RULES = {
|
||||||
overview: ['finance', 'executive'],
|
overview: ['finance', 'executive'],
|
||||||
approval: ['approver'],
|
approval: ['approver'],
|
||||||
|
|||||||
Reference in New Issue
Block a user