u
This commit is contained in:
1 parent
f9eaacf02a
commit
69eda8b8ad
27 files changed
+2797
-616
No files matched your search
@@ -45,8 +45,6 @@ export function recognizeOcrBoxApi(params: OcrBoxRequest) {
|
||||
export function deleteFileApi(subid) {
|
||||
return httpPost(`file/delete`, {
|
||||
subid,
|
||||
tableName: 'bf_file',
|
||||
bucketName: aliyunBucket,
|
||||
})
|
||||
}
|
||||
|
||||
@@ -76,8 +74,8 @@ export function getUniqueIdApi() {
|
||||
interface LoadDataParams {
|
||||
viewName: string
|
||||
searchCondition: string
|
||||
orderField: string
|
||||
searchColumns: string[]
|
||||
orderField?: string
|
||||
searchColumns?: string[]
|
||||
}
|
||||
|
||||
export function loadDataApi(params: LoadDataParams) {
|
||||
@@ -109,6 +107,28 @@ export function loadPageDataApi(params: PageParams) {
|
||||
)
|
||||
}
|
||||
|
||||
export function uploadTempFileApi(filePath: string, fileName: string) {
|
||||
return httpUpload('/file/uploadTemp', filePath, fileName)
|
||||
interface UpdateTempFileParams {
|
||||
fileName: string
|
||||
}
|
||||
|
||||
export function uploadTempFileApi(filePath: string, params: UpdateTempFileParams) {
|
||||
return httpUpload<{
|
||||
url: string
|
||||
path: string
|
||||
}>('/file/uploadTemp', filePath, params)
|
||||
}
|
||||
|
||||
interface UpdateContainerFileParams {
|
||||
jobId: string | number
|
||||
containerNo: string
|
||||
fileName: string
|
||||
}
|
||||
|
||||
export function uploadContainerFileApi(filePath: string, params: UpdateContainerFileParams) {
|
||||
return httpUpload<{
|
||||
url: string
|
||||
path: string
|
||||
uid: number
|
||||
fileName: string
|
||||
}>('/file/uploadContainer', filePath, params)
|
||||
}
|
||||
@@ -3,6 +3,7 @@ import { toast } from 'sard-uniapp'
|
||||
import * as dbJson from '@/static/db.json'
|
||||
import { useUserStore } from '@/store'
|
||||
import { joinUrl } from '@/utils/common'
|
||||
|
||||
import { isH5 } from '@/utils/platform'
|
||||
|
||||
/**
|
||||
@@ -27,6 +28,48 @@ function readDbJson(): Promise<Record<string, string>> {
|
||||
})
|
||||
}
|
||||
|
||||
/**
|
||||
* 根据机构码获取原始 baseUrl(不拼接)
|
||||
* @param orgid 机构码
|
||||
* @returns Promise<string>
|
||||
*/
|
||||
export async function getOrgBaseUrl(orgid: string): Promise<string> {
|
||||
if (!orgid) {
|
||||
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>
|
||||
}
|
||||
|
||||
if (!dbRes || Object.keys(dbRes).length === 0) {
|
||||
throw new Error('机构配置获取失败')
|
||||
}
|
||||
|
||||
const baseUrl = dbRes[orgid]
|
||||
|
||||
if (!baseUrl) {
|
||||
throw new Error('机构码无效')
|
||||
}
|
||||
|
||||
// 👉 关键:只返回原始 JSON 里的值
|
||||
return baseUrl
|
||||
}
|
||||
|
||||
/**
|
||||
* ======================
|
||||
* 获取 baseUrl + headers
|
||||
@@ -200,7 +243,6 @@ function request<T = any>(
|
||||
export function httpUpload<T = any>(
|
||||
url: string,
|
||||
filePath: string,
|
||||
fileName: string,
|
||||
formData?: Record<string, any>,
|
||||
option?: UniApp.UploadFileOption,
|
||||
) {
|
||||
@@ -217,17 +259,12 @@ export function httpUpload<T = any>(
|
||||
|
||||
const fullUrl = joinUrl(baseUrl, url)
|
||||
|
||||
const mergedFormData = {
|
||||
...formData,
|
||||
fileName,
|
||||
}
|
||||
|
||||
return new Promise<IResData<T>>((resolve, reject) => {
|
||||
task = uni.uploadFile({
|
||||
url: fullUrl,
|
||||
filePath,
|
||||
name: 'file',
|
||||
formData: mergedFormData,
|
||||
formData,
|
||||
header: {
|
||||
...headers,
|
||||
...(option?.header || {}),
|
||||
|
||||
Reference in new issue
Block a user