feat(报销/拨款): 进入页面检测OCR服务状态
- 后端新增 GET /ocr-health 端点,探测 Python OCR 服务 /health - 前端页面 created 时调用健康检查,服务不可用时顶部显示红色警告 "发票识别服务已停止,请联系信息化部门" - 服务不可用时禁用附件上传区域(FileUpload 新增 disabled prop) Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
This commit is contained in:
@@ -9,6 +9,10 @@
|
||||
</div>
|
||||
|
||||
<el-form ref="formRef" :model="form" :rules="rules" label-width="120px" size="small" class="metal-form">
|
||||
<el-alert v-if="ocrAvailable === false" type="error" :closable="false" show-icon style="margin-bottom:14px">
|
||||
<span slot="title">发票识别服务已停止,请联系信息化部门。在服务恢复前,您暂时无法上传发票附件。</span>
|
||||
</el-alert>
|
||||
|
||||
<div class="form-summary">
|
||||
<div class="summary-left">
|
||||
<div class="summary-title">发起拨款申请</div>
|
||||
@@ -57,8 +61,11 @@
|
||||
<el-form-item label="拨款单据附件" prop="accessoryApplyIds">
|
||||
<file-upload v-model="form.accessoryApplyIds" :limit="50" :file-size="50"
|
||||
:file-type="['pdf', 'jpg', 'jpeg', 'png', 'doc', 'docx']" multiple
|
||||
:disabled="ocrAvailable === false"
|
||||
@delete="onFileDelete" />
|
||||
<div class="hint-text">上传发票、收据、付款截图等(支持 PDF/图片,上传后自动识别明细)</div>
|
||||
<div class="hint-text">
|
||||
{{ ocrAvailable === false ? '识别服务不可用,暂时无法上传' : '上传发票、收据、付款截图等(支持 PDF/图片,上传后自动识别明细)' }}
|
||||
</div>
|
||||
</el-form-item>
|
||||
|
||||
<!-- OCR 识别中提示 -->
|
||||
@@ -247,7 +254,7 @@
|
||||
</template>
|
||||
|
||||
<script>
|
||||
import { addAppropriationReq, listFlowNode, listFlowTemplate, ocrAppropriationInvoice } from '@/api/hrm';
|
||||
import { addAppropriationReq, checkAppropriationOcrHealth, listFlowNode, listFlowTemplate, ocrAppropriationInvoice } from '@/api/hrm';
|
||||
import { getEmployeeByUserId } from '@/api/hrm/employee';
|
||||
import { ccFlowTask } from '@/api/hrm/flow';
|
||||
import FileUpload from '@/components/FileUpload';
|
||||
@@ -271,6 +278,9 @@ export default {
|
||||
assigneeUserName: '',
|
||||
appropriationTypeOptions: ['差旅费', '招待费', '办公费', '交通费', '通讯费', '其他'],
|
||||
// 发票明细条目
|
||||
// OCR服务状态:null=检测中,true=正常,false=不可用
|
||||
ocrAvailable: null,
|
||||
// 发票明细条目
|
||||
invoiceItems: [],
|
||||
// OCR加载状态 { ossId: true/false }
|
||||
ocrLoadingMap: {},
|
||||
@@ -309,6 +319,7 @@ export default {
|
||||
created () {
|
||||
this.loadCurrentEmployee()
|
||||
this.loadTemplates()
|
||||
this.checkOcrHealth()
|
||||
},
|
||||
computed: {
|
||||
currentApplicantText () {
|
||||
@@ -346,6 +357,15 @@ export default {
|
||||
onCcUsersSelected (users) { this.ccForm.selectedUsers = users || [] },
|
||||
removeCcUser (user) { this.ccForm.selectedUsers = this.ccForm.selectedUsers.filter(u => u.userId !== user.userId) },
|
||||
|
||||
async checkOcrHealth () {
|
||||
try {
|
||||
const res = await checkAppropriationOcrHealth()
|
||||
this.ocrAvailable = res.code === 200 && res.data === true
|
||||
} catch (e) {
|
||||
this.ocrAvailable = false
|
||||
}
|
||||
},
|
||||
|
||||
async triggerOcr (ossId) {
|
||||
if (this.ocrDoneSet.has(ossId)) return
|
||||
this.$set(this.ocrLoadingMap, ossId, true)
|
||||
|
||||
@@ -9,6 +9,10 @@
|
||||
</div>
|
||||
|
||||
<el-form ref="formRef" :model="form" :rules="rules" label-width="120px" size="small" class="metal-form">
|
||||
<el-alert v-if="ocrAvailable === false" type="error" :closable="false" show-icon style="margin-bottom:14px">
|
||||
<span slot="title">发票识别服务已停止,请联系信息化部门。在服务恢复前,您暂时无法上传发票附件。</span>
|
||||
</el-alert>
|
||||
|
||||
<div class="form-summary">
|
||||
<div class="summary-left">
|
||||
<div class="summary-title">发起日常报销</div>
|
||||
@@ -57,8 +61,11 @@
|
||||
<el-form-item label="报销单据附件" prop="accessoryApplyIds">
|
||||
<file-upload v-model="form.accessoryApplyIds" :limit="200" :file-size="50"
|
||||
:file-type="['pdf', 'jpg', 'jpeg', 'png', 'doc', 'docx']" multiple
|
||||
:disabled="ocrAvailable === false"
|
||||
@delete="onFileDelete" />
|
||||
<div class="hint-text">上传发票、收据、付款截图等(支持 PDF/图片,上传后自动识别明细)</div>
|
||||
<div class="hint-text">
|
||||
{{ ocrAvailable === false ? '识别服务不可用,暂时无法上传' : '上传发票、收据、付款截图等(支持 PDF/图片,上传后自动识别明细)' }}
|
||||
</div>
|
||||
</el-form-item>
|
||||
|
||||
<!-- OCR 识别中提示 -->
|
||||
@@ -224,7 +231,7 @@
|
||||
</template>
|
||||
|
||||
<script>
|
||||
import { addReimburseReq, listFlowNode, listFlowTemplate, ocrReimburseInvoice } from '@/api/hrm';
|
||||
import { addReimburseReq, checkReimburseOcrHealth, listFlowNode, listFlowTemplate, ocrReimburseInvoice } from '@/api/hrm';
|
||||
import { getEmployeeByUserId } from '@/api/hrm/employee';
|
||||
import { ccFlowTask } from '@/api/hrm/flow';
|
||||
import FileUpload from '@/components/FileUpload';
|
||||
@@ -247,6 +254,8 @@ export default {
|
||||
assigneeUserId: null,
|
||||
assigneeUserName: '',
|
||||
reimburseTypeOptions: ['差旅费', '招待费', '办公费', '交通费', '通讯费', '其他'],
|
||||
// OCR服务状态:null=检测中,true=正常,false=不可用
|
||||
ocrAvailable: null,
|
||||
// 发票明细条目
|
||||
invoiceItems: [],
|
||||
// OCR加载状态 { ossId: true/false }
|
||||
@@ -284,6 +293,7 @@ export default {
|
||||
created () {
|
||||
this.loadCurrentEmployee()
|
||||
this.loadTemplates()
|
||||
this.checkOcrHealth()
|
||||
},
|
||||
computed: {
|
||||
currentApplicantText () {
|
||||
@@ -321,6 +331,15 @@ export default {
|
||||
onCcUsersSelected (users) { this.ccForm.selectedUsers = users || [] },
|
||||
removeCcUser (user) { this.ccForm.selectedUsers = this.ccForm.selectedUsers.filter(u => u.userId !== user.userId) },
|
||||
|
||||
async checkOcrHealth () {
|
||||
try {
|
||||
const res = await checkReimburseOcrHealth()
|
||||
this.ocrAvailable = res.code === 200 && res.data === true
|
||||
} catch (e) {
|
||||
this.ocrAvailable = false
|
||||
}
|
||||
},
|
||||
|
||||
async triggerOcr (ossId) {
|
||||
if (this.ocrDoneSet.has(ossId)) return
|
||||
this.$set(this.ocrLoadingMap, ossId, true)
|
||||
|
||||
Reference in New Issue
Block a user