refactor: refactor smart entry as standalone modal overlay
- Convert TravelReimbursementCreateView from page to modal overlay - Simplify App.vue navigation flow with smartEntryOpen state - Add create-request button in RequestsView Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>
This commit is contained in:
44
src/App.vue
44
src/App.vue
@@ -72,12 +72,7 @@
|
||||
|
||||
<PersonalWorkbenchView
|
||||
v-else-if="activeView === 'workbench'"
|
||||
@open-assistant="handleOpenChat"
|
||||
/>
|
||||
|
||||
<TravelReimbursementCreateView
|
||||
v-else-if="activeView === 'chat' && travelCreateMode"
|
||||
@back-to-requests="backToRequests"
|
||||
@open-assistant="openSmartEntry"
|
||||
/>
|
||||
|
||||
<ChatView
|
||||
@@ -102,6 +97,7 @@
|
||||
v-else-if="activeView === 'requests' && detailMode"
|
||||
:request="selectedTravelRequest"
|
||||
@back-to-requests="closeRequestDetail"
|
||||
@open-assistant="openSmartEntry"
|
||||
/>
|
||||
|
||||
<RequestsView
|
||||
@@ -121,6 +117,14 @@
|
||||
</section>
|
||||
</main>
|
||||
|
||||
<TravelReimbursementCreateView
|
||||
v-if="smartEntryOpen"
|
||||
:key="smartEntrySessionId"
|
||||
:initial-prompt="smartEntryContext.prompt"
|
||||
:entry-source="smartEntryContext.source"
|
||||
:request-context="smartEntryContext.request"
|
||||
@close="closeSmartEntry"
|
||||
/>
|
||||
</div>
|
||||
|
||||
<ToastNotification :toast-text="toastText" />
|
||||
@@ -155,6 +159,9 @@ const loggedIn = ref(false)
|
||||
const travelCreateMode = ref(false)
|
||||
const detailMode = ref(false)
|
||||
const selectedTravelRequest = ref(null)
|
||||
const smartEntryOpen = ref(false)
|
||||
const smartEntryContext = ref({ prompt: '', source: 'requests', request: null })
|
||||
const smartEntrySessionId = ref(0)
|
||||
|
||||
function handleLogin(credentials) {
|
||||
if (credentials.username && credentials.password) {
|
||||
@@ -180,7 +187,7 @@ const customRange = ref({ start: '2024-07-06', end: '2024-07-12' })
|
||||
const travelPrompts = ['帮我提交出差申请', '预订机票', '预订酒店', '预订火车票', '查询差旅政策']
|
||||
|
||||
const topBarView = computed(() => {
|
||||
if (travelCreateMode.value || detailMode.value) {
|
||||
if (detailMode.value) {
|
||||
return {
|
||||
title: '差旅报销详情',
|
||||
desc: '查看报销单据详情、票据识别与审批进度'
|
||||
@@ -211,6 +218,7 @@ function handleNavigate(view) {
|
||||
travelCreateMode.value = false
|
||||
detailMode.value = false
|
||||
selectedTravelRequest.value = null
|
||||
smartEntryOpen.value = false
|
||||
setView(view)
|
||||
}
|
||||
|
||||
@@ -220,15 +228,29 @@ function handleOpenChat(request) {
|
||||
}
|
||||
|
||||
function openTravelCreate() {
|
||||
travelCreateMode.value = true
|
||||
smartEntryOpen.value = true
|
||||
travelCreateMode.value = false
|
||||
detailMode.value = false
|
||||
selectedTravelRequest.value = null
|
||||
activeView.value = 'chat'
|
||||
smartEntryContext.value = { prompt: '', source: 'topbar', request: null }
|
||||
smartEntrySessionId.value += 1
|
||||
}
|
||||
|
||||
function backToRequests() {
|
||||
function openSmartEntry(payload = {}) {
|
||||
smartEntryOpen.value = true
|
||||
travelCreateMode.value = false
|
||||
activeView.value = 'requests'
|
||||
detailMode.value = false
|
||||
selectedTravelRequest.value = null
|
||||
smartEntryContext.value = {
|
||||
prompt: payload.prompt ?? '',
|
||||
source: payload.source ?? 'workbench',
|
||||
request: payload.request ?? null
|
||||
}
|
||||
smartEntrySessionId.value += 1
|
||||
}
|
||||
|
||||
function closeSmartEntry() {
|
||||
smartEntryOpen.value = false
|
||||
}
|
||||
|
||||
function openRequestDetail(request) {
|
||||
|
||||
@@ -20,12 +20,17 @@
|
||||
<p>自动识别报销类别、核对附件完整性,并生成可继续提交的报销草稿。</p>
|
||||
|
||||
<div class="assistant-input">
|
||||
<span>例如:我昨天请客户吃饭花了 860 元,还打车去了客户公司</span>
|
||||
<button type="button" class="hero-action" @click="emit('openAssistant')">开始识别</button>
|
||||
<textarea
|
||||
v-model="assistantDraft"
|
||||
rows="2"
|
||||
placeholder="例如:我昨天请客户吃饭花了 860 元,还打车去了客户公司"
|
||||
@keydown.ctrl.enter.prevent="openAssistantWithDraft"
|
||||
/>
|
||||
<button type="button" class="hero-action" @click="openAssistantWithDraft">开始识别</button>
|
||||
</div>
|
||||
|
||||
<div class="assistant-tools">
|
||||
<button type="button" class="ghost-action" @click="emit('openAssistant')">
|
||||
<button type="button" class="ghost-action" @click="emit('openAssistant', { prompt: '', source: 'upload' })">
|
||||
<i class="mdi mdi-upload-outline"></i>
|
||||
<span>上传票据</span>
|
||||
</button>
|
||||
@@ -117,6 +122,7 @@
|
||||
</template>
|
||||
|
||||
<script setup>
|
||||
import { ref } from 'vue'
|
||||
import PanelHead from '../shared/PanelHead.vue'
|
||||
import robotAssistant from '../../assets/robot-assistant.png'
|
||||
|
||||
@@ -125,6 +131,14 @@ defineProps({
|
||||
})
|
||||
|
||||
const emit = defineEmits(['openAssistant'])
|
||||
const assistantDraft = ref('')
|
||||
|
||||
function openAssistantWithDraft() {
|
||||
emit('openAssistant', {
|
||||
prompt: assistantDraft.value.trim(),
|
||||
source: 'workbench'
|
||||
})
|
||||
}
|
||||
|
||||
const assistantSkills = ['识别报销类别', '检查缺少材料', '生成报销草稿']
|
||||
|
||||
@@ -350,22 +364,33 @@ const policyItems = [
|
||||
display: flex;
|
||||
align-items: center;
|
||||
gap: 14px;
|
||||
min-height: 58px;
|
||||
padding: 10px 10px 10px 18px;
|
||||
min-height: 68px;
|
||||
padding: 10px 10px 10px 14px;
|
||||
border: 1px solid rgba(148, 163, 184, 0.28);
|
||||
border-radius: 12px;
|
||||
background: rgba(255, 255, 255, 0.92);
|
||||
box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.7);
|
||||
}
|
||||
|
||||
.assistant-input span {
|
||||
.assistant-input textarea {
|
||||
min-width: 0;
|
||||
flex: 1;
|
||||
color: #94a3b8;
|
||||
min-height: 42px;
|
||||
resize: none;
|
||||
border: 0;
|
||||
padding: 4px 0;
|
||||
background: transparent;
|
||||
color: #0f172a;
|
||||
font-size: 15px;
|
||||
white-space: nowrap;
|
||||
overflow: hidden;
|
||||
text-overflow: ellipsis;
|
||||
line-height: 1.55;
|
||||
}
|
||||
|
||||
.assistant-input textarea::placeholder {
|
||||
color: #94a3b8;
|
||||
}
|
||||
|
||||
.assistant-input textarea:focus {
|
||||
outline: none;
|
||||
}
|
||||
|
||||
.hero-action,
|
||||
@@ -719,8 +744,8 @@ const policyItems = [
|
||||
padding: 14px;
|
||||
}
|
||||
|
||||
.assistant-input span {
|
||||
white-space: normal;
|
||||
.assistant-input textarea {
|
||||
min-height: 72px;
|
||||
}
|
||||
|
||||
.hero-action,
|
||||
|
||||
@@ -92,7 +92,7 @@
|
||||
</div>
|
||||
</div>
|
||||
<div class="topbar-spacer"></div>
|
||||
<button class="create-top-btn" type="button">
|
||||
<button class="create-top-btn" type="button" @click="emit('newApplication')">
|
||||
<i class="mdi mdi-plus"></i>
|
||||
<span>发起报销</span>
|
||||
</button>
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
<template>
|
||||
<PersonalWorkbench :show-header="false" @open-assistant="emit('openAssistant')" />
|
||||
<PersonalWorkbench :show-header="false" @open-assistant="emit('openAssistant', $event)" />
|
||||
</template>
|
||||
|
||||
<script setup>
|
||||
|
||||
@@ -52,6 +52,10 @@
|
||||
<i class="mdi mdi-chevron-down"></i>
|
||||
</button>
|
||||
</div>
|
||||
<button class="create-request-btn" type="button" @click="emit('create-request')">
|
||||
<i class="mdi mdi-plus-circle-outline"></i>
|
||||
<span>发起报销</span>
|
||||
</button>
|
||||
</div>
|
||||
|
||||
<p class="hint"><i class="mdi mdi-information-outline"></i> 点击任意行可查看单据详情</p>
|
||||
@@ -125,7 +129,7 @@ defineProps({
|
||||
filteredRequests: { type: Array, required: true }
|
||||
})
|
||||
|
||||
const emit = defineEmits(['ask', 'approve', 'reject'])
|
||||
const emit = defineEmits(['ask', 'approve', 'reject', 'create-request'])
|
||||
|
||||
const activeTab = ref('全部')
|
||||
const tabs = ['全部', '待提交', '审批中', '待出行', '已完成']
|
||||
@@ -311,6 +315,30 @@ watch(activeTab, () => { currentPage.value = 1 })
|
||||
flex-wrap: wrap;
|
||||
}
|
||||
|
||||
.create-request-btn {
|
||||
min-height: 40px;
|
||||
display: inline-flex;
|
||||
align-items: center;
|
||||
justify-content: center;
|
||||
gap: 8px;
|
||||
padding: 0 18px;
|
||||
border: 0;
|
||||
border-radius: 10px;
|
||||
background: linear-gradient(135deg, #10b981, #059669);
|
||||
color: #fff;
|
||||
font-size: 14px;
|
||||
font-weight: 800;
|
||||
white-space: nowrap;
|
||||
box-shadow: 0 10px 24px rgba(5, 150, 105, 0.2);
|
||||
transition: transform 160ms ease, box-shadow 160ms ease, filter 160ms ease;
|
||||
}
|
||||
|
||||
.create-request-btn:hover {
|
||||
transform: translateY(-1px);
|
||||
box-shadow: 0 14px 28px rgba(5, 150, 105, 0.24);
|
||||
filter: saturate(1.02);
|
||||
}
|
||||
|
||||
.filter-btn,
|
||||
.page-size {
|
||||
min-height: 38px;
|
||||
|
||||
File diff suppressed because it is too large
Load Diff
@@ -322,7 +322,7 @@ const props = defineProps({
|
||||
}
|
||||
})
|
||||
|
||||
const emit = defineEmits(['backToRequests'])
|
||||
const emit = defineEmits(['backToRequests', 'openAssistant'])
|
||||
|
||||
const expandedExpenseId = ref(null)
|
||||
const aiEntryOpen = ref(false)
|
||||
@@ -492,7 +492,12 @@ function showExpenseRisk(item) {
|
||||
}
|
||||
|
||||
function openAiEntry() {
|
||||
aiEntryOpen.value = true
|
||||
aiEntryOpen.value = false
|
||||
emit('openAssistant', {
|
||||
source: 'detail',
|
||||
prompt: '',
|
||||
request: request.value
|
||||
})
|
||||
}
|
||||
|
||||
function closeAiEntry() {
|
||||
|
||||
Reference in New Issue
Block a user