feat:食堂菜品购买统计(按天)
This commit is contained in:
1 parent
2def987861
commit
4c74d5a410
2 files changed
+69
-5
No files matched your search
+63
-5
@@ -265,8 +265,26 @@ export function downBlobFile(url: any, query: any, fileName: string) {
|
||||
.then((response) => {
|
||||
handleBlobFile(response, fileName)
|
||||
})
|
||||
.catch((error) => {
|
||||
useMessage().error(error.msg || "下载失败")
|
||||
.catch(async (error) => {
|
||||
let msg = "下载失败"
|
||||
try {
|
||||
if (error instanceof Blob) {
|
||||
const text = typeof (error as any).text === "function" ? await (error as any).text() : ""
|
||||
if (text) {
|
||||
try {
|
||||
const json = JSON.parse(text)
|
||||
msg = json.msg || json.message || msg
|
||||
} catch {
|
||||
msg = text || msg
|
||||
}
|
||||
}
|
||||
} else if (typeof error === "object") {
|
||||
msg = (error as any).msg || (error as any).message || msg
|
||||
}
|
||||
} catch {
|
||||
msg = "下载失败"
|
||||
}
|
||||
useMessage().error(msg)
|
||||
})
|
||||
}
|
||||
|
||||
@@ -286,8 +304,26 @@ export function postDownBlobFile(url: any, data: any, fileName: string) {
|
||||
.then((response) => {
|
||||
handleBlobFile(response, fileName)
|
||||
})
|
||||
.catch((error) => {
|
||||
useMessage().error(error.msg || "下载失败")
|
||||
.catch(async (error) => {
|
||||
let msg = "下载失败"
|
||||
try {
|
||||
if (error instanceof Blob) {
|
||||
const text = typeof (error as any).text === "function" ? await (error as any).text() : ""
|
||||
if (text) {
|
||||
try {
|
||||
const json = JSON.parse(text)
|
||||
msg = json.msg || json.message || msg
|
||||
} catch {
|
||||
msg = text || msg
|
||||
}
|
||||
}
|
||||
} else if (typeof error === "object") {
|
||||
msg = (error as any).msg || (error as any).message || msg
|
||||
}
|
||||
} catch {
|
||||
msg = "下载失败"
|
||||
}
|
||||
useMessage().error(msg)
|
||||
})
|
||||
}
|
||||
|
||||
@@ -334,7 +370,6 @@ export function handleBlobFile(response: any, fileName: string) {
|
||||
} else if (response.data && response.data instanceof Blob) {
|
||||
blob = response.data
|
||||
} else {
|
||||
// 尝试构造安全的blob
|
||||
const safeData = Array.isArray(response) ? response : [response]
|
||||
blob = new Blob(safeData, { type: "application/octet-stream" })
|
||||
}
|
||||
@@ -344,6 +379,29 @@ export function handleBlobFile(response: any, fileName: string) {
|
||||
return
|
||||
}
|
||||
|
||||
if (blob.type === "application/json" || blob.type === "text/plain") {
|
||||
try {
|
||||
const handleText = (t: string) => {
|
||||
try {
|
||||
const json = JSON.parse(t)
|
||||
useMessage().error(json.msg || json.message || "下载失败")
|
||||
} catch {
|
||||
useMessage().error(t || "下载失败")
|
||||
}
|
||||
}
|
||||
if (typeof (blob as any).text === "function") {
|
||||
;(blob as any).text().then((t: string) => handleText(t))
|
||||
} else {
|
||||
const reader = new FileReader()
|
||||
reader.onload = () => handleText(String(reader.result || ""))
|
||||
reader.readAsText(blob)
|
||||
}
|
||||
} catch {
|
||||
useMessage().error("下载失败")
|
||||
}
|
||||
return
|
||||
}
|
||||
|
||||
// 3. 验证文件大小 (防止过大文件)
|
||||
const MAX_FILE_SIZE = 100 * 1024 * 1024 // 100MB限制
|
||||
if (blob.size > MAX_FILE_SIZE) {
|
||||
|
||||
@@ -105,6 +105,12 @@ watch(() => [activeTab.value, productTotalTableByDayRef.value, productTotalTable
|
||||
}
|
||||
})
|
||||
|
||||
onMounted(() => {
|
||||
nextTick(() => {
|
||||
search()
|
||||
})
|
||||
})
|
||||
|
||||
// 清空搜索条件
|
||||
const resetQuery = () => {
|
||||
// 清空搜索条件
|
||||
|
||||
Reference in new issue
Block a user