20260511173242
This commit is contained in:
1 parent
56f5ba4e6b
commit
364d29dbaa
20 files changed
+2992
-88
No files matched your search
@@ -54,9 +54,16 @@ function handleChooseBox() {
|
||||
|
||||
imageCompress(tempFile.path).then((compressRes) => {
|
||||
form.value.b_container_img = compressRes.path
|
||||
const fileName = tempFile.name || `image_${Date.now()}.jpg`
|
||||
boxImage.value = {
|
||||
...tempFile,
|
||||
name: fileName,
|
||||
path: compressRes.path,
|
||||
size: compressRes.size,
|
||||
}
|
||||
|
||||
uploadTempFileApi(compressRes.path, {
|
||||
fileName: tempFile.name,
|
||||
fileName,
|
||||
}).then((res) => {
|
||||
if (res.success) {
|
||||
recognizeOcrBoxApi({
|
||||
@@ -92,12 +99,15 @@ const computedOcrScore = computed(() => {
|
||||
function resetForm() {
|
||||
boxImage.value = null
|
||||
form.value.b_container_no = ''
|
||||
form.value.b_container_img = ''
|
||||
form.value.ocrNo = ''
|
||||
form.value.ocrScore = 0.00
|
||||
|
||||
showResult.value = false
|
||||
isError.value = false
|
||||
ocrFinish.value = false
|
||||
subFileList.value = []
|
||||
subFileList2.value = []
|
||||
}
|
||||
|
||||
function handleDeleteBoxImage() {
|
||||
@@ -140,7 +150,7 @@ function beforeRemove(_index: number, _fileItem: UploadFileItem): boolean | Prom
|
||||
}
|
||||
|
||||
async function handleConfirm() {
|
||||
if (form.value.b_container_img === '') {
|
||||
if (!boxImage.value) {
|
||||
toast.fail('集装箱号图片不能为空')
|
||||
return
|
||||
}
|
||||
@@ -258,6 +268,13 @@ async function handleConfirm() {
|
||||
tipContainerNo.value = form.value.b_container_no
|
||||
showResult.value = true
|
||||
}
|
||||
else {
|
||||
toast.fail('保存失败')
|
||||
}
|
||||
}).catch(() => {
|
||||
toast.fail('保存失败')
|
||||
}).finally(() => {
|
||||
toast.hide()
|
||||
})
|
||||
}
|
||||
|
||||
@@ -279,19 +296,8 @@ async function continueAdd() {
|
||||
const idRes = await getUniqueIdApi()
|
||||
|
||||
if (idRes.success) {
|
||||
boxImage.value = null
|
||||
|
||||
ocrFinish.value = false
|
||||
isError.value = false
|
||||
|
||||
resetForm()
|
||||
form.value.b_id = idRes.data
|
||||
|
||||
subFileList.value = []
|
||||
subFileList2.value = []
|
||||
|
||||
showResult.value = false
|
||||
|
||||
tipContainerNo.value = ''
|
||||
}
|
||||
}
|
||||
|
||||
@@ -6,26 +6,45 @@ import { joinUrl } from '@/utils/common'
|
||||
|
||||
import { isH5 } from '@/utils/platform'
|
||||
|
||||
let dbJsonCache: Record<string, string> | null = null
|
||||
let dbJsonPromise: Promise<Record<string, string>> | null = null
|
||||
|
||||
/**
|
||||
* ======================
|
||||
* 读取机构配置
|
||||
* 读取机构配置(带缓存)
|
||||
* ======================
|
||||
*/
|
||||
function readDbJson(): Promise<Record<string, string>> {
|
||||
return new Promise((resolve, reject) => {
|
||||
if (dbJsonCache) {
|
||||
return Promise.resolve(dbJsonCache)
|
||||
}
|
||||
|
||||
if (dbJsonPromise) {
|
||||
return dbJsonPromise
|
||||
}
|
||||
|
||||
dbJsonPromise = new Promise((resolve, reject) => {
|
||||
if (isH5) {
|
||||
const timestamp = Date.now()
|
||||
uni.request({
|
||||
url: `/g3ocr-app/static/db.json?t=${timestamp}`,
|
||||
url: '/g3ocr-app/static/db.json',
|
||||
method: 'GET',
|
||||
success: r => resolve(r.data as Record<string, string>),
|
||||
fail: err => reject(err),
|
||||
success: (r) => {
|
||||
dbJsonCache = r.data as Record<string, string>
|
||||
resolve(dbJsonCache)
|
||||
},
|
||||
fail: (err) => {
|
||||
dbJsonPromise = null
|
||||
reject(err)
|
||||
},
|
||||
})
|
||||
}
|
||||
else {
|
||||
resolve(dbJson as Record<string, string>)
|
||||
dbJsonCache = dbJson as Record<string, string>
|
||||
resolve(dbJsonCache)
|
||||
}
|
||||
})
|
||||
|
||||
return dbJsonPromise
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -38,23 +57,7 @@ export async function getOrgBaseUrl(orgid: string): Promise<string> {
|
||||
return ''
|
||||
}
|
||||
|
||||
let dbRes: Record<string, string> = {}
|
||||
|
||||
// 读取配置(和你原逻辑保持一致)
|
||||
if (isH5) {
|
||||
const timestamp = Date.now()
|
||||
dbRes = await new Promise((resolve, reject) => {
|
||||
uni.request({
|
||||
url: `/g3ocr-app/static/db.json?t=${timestamp}`,
|
||||
method: 'GET',
|
||||
success: res => resolve(res.data as Record<string, string>),
|
||||
fail: err => reject(err),
|
||||
})
|
||||
})
|
||||
}
|
||||
else {
|
||||
dbRes = dbJson as Record<string, string>
|
||||
}
|
||||
const dbRes = await readDbJson()
|
||||
|
||||
if (!dbRes || Object.keys(dbRes).length === 0) {
|
||||
throw new Error('机构配置获取失败')
|
||||
@@ -66,7 +69,6 @@ export async function getOrgBaseUrl(orgid: string): Promise<string> {
|
||||
throw new Error('机构码无效')
|
||||
}
|
||||
|
||||
// 👉 关键:只返回原始 JSON 里的值
|
||||
return baseUrl
|
||||
}
|
||||
|
||||
|
||||
Reference in new issue
Block a user