refactor(webapp): 优化发票验证流程和界面

- 修改验证流程初始步骤为第3步- 更新验证结果展示方式,使用 Ant Design Result 组件
-优化上传页面样式,增加顶部间距
- 调整验证接口返回格式,统一错误处理
This commit is contained in:
liuxiaoqing 2025-08-19 22:42:38 +08:00
parent 8c7422dc68
commit 31404cf225
6 changed files with 18 additions and 22 deletions

View File

@ -44,15 +44,15 @@ def verify():
file_path = request.args.get('filePath') file_path = request.args.get('filePath')
invoice_id = request.args.get('invoiceId') invoice_id = request.args.get('invoiceId')
if file_path is None: if file_path is None:
return "请选择文件" return {"msg":"请选择文件","status":'fail'}
service = Service() service = Service()
data = dataservice.get_invoice(file_path=file_path,invice_id=invoice_id) data = dataservice.get_invoice(file_path=file_path,invice_id=invoice_id)
if data is not None: if data is not None:
if data.get('status') == 'yes': if data.get('status') == 'yes':
return "已报销发票!!" return {"msg":"请勿重复验证","status":'fail'}
return service.verify(data=data,file_path=file_path) return service.verify(data=data,file_path=file_path)
else: else:
return "请选择文件" return {"msg":"请先识别发票","status":'fail'}
# 发票复验 # 发票复验
@app.route('/reverify', methods=['GET']) @app.route('/reverify', methods=['GET'])
def reverify(): def reverify():

View File

@ -105,13 +105,14 @@ class Service:
resdata = {'cyjgxx': "未查询到发票信息", 'inspectionAmount': -1,'status': 'fail'} resdata = {'cyjgxx': "未查询到发票信息", 'inspectionAmount': -1,'status': 'fail'}
else: else:
resdata.update({'status': 'success'}) resdata.update({'status': 'success'})
resdata['status'] = 'success'
dataservice.insert_verify_log(resdata.get('inspectionAmount'), resdata.get('cyjgxx'), file_path) dataservice.insert_verify_log(resdata.get('inspectionAmount'), resdata.get('cyjgxx'), file_path)
dataservice.update_invoice_status(data.get('id'), resdata.get('status'), resdata.get('inspectionAmount')) dataservice.update_invoice_status(data.get('id'), resdata.get('status'), resdata.get('inspectionAmount'))
return resdata return resdata
except Exception as error: except Exception as error:
# 此处仅做打印展示,请谨慎对待异常处理,在工程项目中切勿直接忽略异常。 # 此处仅做打印展示,请谨慎对待异常处理,在工程项目中切勿直接忽略异常。
# 错误 message # 错误 message
print(error.message) print(error)
# 诊断地址 # 诊断地址
print(error.data.get("Recommend")) print(error.data.get("Recommend"))
UtilClient.assert_as_string(error.message) UtilClient.assert_as_string(error.message)

Binary file not shown.

View File

@ -27,7 +27,7 @@ const items = [
] as StepProps[]; ] as StepProps[];
// //
const filePath = ref(''); const filePath = ref('');
const current = ref<number>(0); const current = ref<number>(3);
// //
const nextPage = () => { const nextPage = () => {
current.value ++; current.value ++;
@ -59,7 +59,6 @@ const formState = ref<string>('');
<a-space> <a-space>
<a-button type="default" v-if="current > 0" @click="previousPage">上一步</a-button> <a-button type="default" v-if="current > 0" @click="previousPage">上一步</a-button>
<a-button type="primary" v-if="current < items.length-1 " @click="nextPage">下一步</a-button> <a-button type="primary" v-if="current < items.length-1 " @click="nextPage">下一步</a-button>
<a-button type="primary" v-if="current == items.length-1" @click="saveReport">报销</a-button>
<a-button type="dashed" v-if="current == items.length-1" @click="saveReport">完成</a-button> <a-button type="dashed" v-if="current == items.length-1" @click="saveReport">完成</a-button>
</a-space> </a-space>
</a-col> </a-col>

View File

@ -1,16 +1,14 @@
<template> <template>
<a-layout-content> <a-layout-content>
<a-row > <a-result
<a-col :span="8"> :status="formState.status"
查验结果{{formState.cyjgxx}} :title="formState.cyjgxx"
</a-col> >
<a-col :span="8"> <template #subTitle >
查验次数{{formState.inspectionAmount}} <p v-if="formState.status === 'success'">查验次数: {{formState.inspectionAmount}}</p>
</a-col> <p v-if="formState.status === 'success'">已存入发票库</p>
<a-col :span="8"> </template>
查验时间{{formState.verify_time}} </a-result>
</a-col>
</a-row>
</a-layout-content> </a-layout-content>
</template> </template>
<script lang="ts" setup> <script lang="ts" setup>
@ -26,11 +24,7 @@ onMounted(() => {
fileType.value = props.filePath.split('.').pop() ==='pdf'?'pdf':'img' fileType.value = props.filePath.split('.').pop() ==='pdf'?'pdf':'img'
request.get('/verify?filePath='+encodeURIComponent(props.filePath)).then((res) => { request.get('/verify?filePath='+encodeURIComponent(props.filePath)).then((res) => {
console.log(res) console.log(res)
if(res.data){ formState.value = res.data
formState.value = res.data
}else{
formState.value.cyjgxx ="失败"
}
}) })
fileUrl.value = baseURL+"/"+props.filePath fileUrl.value = baseURL+"/"+props.filePath
} }
@ -40,6 +34,7 @@ onMounted(() => {
const fileUrl = ref('') const fileUrl = ref('')
let formState = ref({ let formState = ref({
status:"",
inspectionAmount: "", inspectionAmount: "",
cyjgxx: "", cyjgxx: "",
verify_time: "", verify_time: "",

View File

@ -74,6 +74,7 @@ const handleUpload = (options: any) => {
<style scoped> <style scoped>
.container { .container {
margin-top: 50px;
height: 100%; height: 100%;
} }
</style> </style>