Toggle navigation
Toggle navigation
This project
Loading...
Sign in
Fedex
/
EcomWeb
Go to a project
Toggle navigation
Toggle navigation pinning
Projects
Groups
Snippets
Help
Project
Activity
Repository
Pipelines
Graphs
Issues
0
Merge Requests
0
Wiki
Snippets
Network
Create a new issue
Builds
Commits
Issue Boards
Authored by
jinhui.wang
2026-04-09 17:45:07 +0800
Browse Files
Options
Browse Files
Download
Email Patches
Plain Diff
Commit
1e2fc03859da15e1e48dae80bf025139dae4353a
1e2fc038
1 parent
63763c4d
pdd数据查询增加导出功能,编辑详情返回关闭当前tag
Show whitespace changes
Inline
Side-by-side
Showing
5 changed files
with
255 additions
and
26 deletions
.env.development
src/api/pdd-info.js
src/utils/zipdownload.js
src/views/editReportingData/index.vue
src/views/pdd-info/index.vue
.env.development
View file @
1e2fc03
...
...
@@ -5,7 +5,7 @@ VUE_APP_BASE_ENV = "dev"
VUE_APP_Version = '1.0.11'
VUE_APP_BASE_URL = 'http://101.132.100.41:700
8
/EcomExp'
VUE_APP_BASE_URL = 'http://101.132.100.41:700
1
/EcomExp'
# FedEx 在线申报工具/开发环境
# http://101.132.100.41:7001/EcomExp
VUE_APP_BASE_API = /EcomExp
...
...
src/api/pdd-info.js
View file @
1e2fc03
...
...
@@ -29,3 +29,12 @@ export function getResend({ id }) {
method
:
"get"
,
});
}
//提交广州客户申报数据异步导出任务
export
function
getSubmitExportTask
(
data
)
{
return
request
({
url
:
`/bus-customer/customerDeclareData/submitExportTask`
,
method
:
"post"
,
data
:
data
,
});
}
\ No newline at end of file
...
...
src/utils/zipdownload.js
View file @
1e2fc03
...
...
@@ -2,7 +2,7 @@ import axios from "axios";
import
store
from
"@/store"
;
import
{
getToken
}
from
"@/utils/auth"
;
import
{
getDownLoadFileStatus
}
from
"@/utils/iClearExp.js"
;
import
{
alertWarningMsg
}
from
"@/utils/index.js"
;
import
{
alertWarningMsg
,
formatDateNew
}
from
"@/utils/index.js"
;
const
mimeMap
=
{
xlsx
:
"application/vnd.openxmlformats-officedocument.spreadsheetml.sheet"
,
...
...
@@ -91,6 +91,96 @@ export function downLoadZip(urlStatus, str, filename, type, method, data) {
});
});
}
// 按 taskId 下载异步导出文件,支持 10103 状态重试
export
function
downloadAsyncExportByTaskId
(
taskId
,
options
=
{})
{
const
{
retryCount
=
0
,
maxRetry
=
50
,
retryDelay
=
5000
,
mimeType
=
mimeMap
.
xlsx
,
onRetryExhausted
,
onWarning
,
onSuccess
,
}
=
options
;
const
warningHandler
=
onWarning
||
alertWarningMsg
;
const
url
=
`
${
baseUrl
}${
apiUrl
.
customDownloadXls
}
/
${
taskId
}
`
;
return
axios
({
method
:
"get"
,
url
,
responseType
:
"blob"
,
headers
:
{
Authorization
:
"Bearer "
+
getToken
(),
Ver
:
process
.
env
.
VUE_APP_APIVERSION
,
},
})
.
then
((
res
)
=>
{
const
aLink
=
document
.
createElement
(
"a"
);
const
blob
=
new
Blob
([
res
.
data
],
{
type
:
mimeType
});
if
(
blob
.
size
<
500
)
{
return
new
Promise
((
resolve
,
reject
)
=>
{
const
reader
=
new
FileReader
();
reader
.
readAsText
(
blob
,
"utf-8"
);
reader
.
onloadend
=
()
=>
{
if
(
reader
.
result
&&
reader
.
result
!=
null
&&
reader
.
result
!=
""
)
{
try
{
const
jsonData
=
JSON
.
parse
(
reader
.
result
);
if
(
jsonData
.
code
==
"10103"
)
{
if
(
retryCount
<
maxRetry
)
{
setTimeout
(()
=>
{
downloadAsyncExportByTaskId
(
taskId
,
{
...
options
,
retryCount
:
retryCount
+
1
,
})
.
then
(
resolve
)
.
catch
(
reject
);
},
retryDelay
);
}
else
{
if
(
typeof
onRetryExhausted
===
"function"
)
{
onRetryExhausted
();
}
else
{
warningHandler
(
"导出失败"
);
}
reject
(
new
Error
(
"Async export retry exceeded."
));
}
return
;
}
warningHandler
(
jsonData
.
message
||
"文件无法下载,请重新生成后再试!"
);
reject
(
new
Error
(
jsonData
.
message
||
"Download failed."
));
}
catch
(
error
)
{
warningHandler
(
"文件无法下载,请重新生成后再试!"
);
reject
(
error
);
}
}
else
{
warningHandler
(
"文件无法下载,请重新生成后再试!"
);
reject
(
new
Error
(
"Blob response is empty."
));
}
};
reader
.
onerror
=
()
=>
{
warningHandler
(
"文件无法下载,请重新生成后再试!"
);
reject
(
new
Error
(
"Blob read failed."
));
};
});
}
const
fileName
=
`
${
formatDateNew
(
new
Date
())}
.xlsx`
;
aLink
.
href
=
URL
.
createObjectURL
(
blob
);
aLink
.
setAttribute
(
"download"
,
fileName
);
document
.
body
.
appendChild
(
aLink
);
aLink
.
click
();
document
.
body
.
removeChild
(
aLink
);
if
(
typeof
onSuccess
===
"function"
)
{
onSuccess
();
}
return
res
;
})
.
catch
((
error
)
=>
{
return
Promise
.
reject
(
error
);
});
}
/**
* 解析blob响应内容并下载
* @param {*} res blob响应内容
...
...
src/views/editReportingData/index.vue
View file @
1e2fc03
...
...
@@ -1104,7 +1104,9 @@ export default {
this.logtableType = !this.logtableType;
},
back() {
this.$store.dispatch("tagsView/delView", this.$route).finally(() => {
this.$router.go(-1);
});
},
//添加新商品
...
...
src/views/pdd-info/index.vue
View file @
1e2fc03
...
...
@@ -125,7 +125,17 @@
</el-col>
</el-row>
</el-form>
<div style="height: 20px"></div>
<div style="text-align: right; padding: 5px">
<el-button
class="entrySaveButton"
size="small"
icon="el-icon-download"
:loading="loadings.exportDeclareLoading"
@click="downloadData"
>
导出
</el-button>
</div>
<Table
class="fedexDetialTable fedexSreachTable"
ref="entryTable"
...
...
@@ -140,9 +150,11 @@
:totalCount="page.total"
@sizeChange="sizeChange"
@currentChange="currentChange"
:selection="
fals
e"
:selection="
tru
e"
:selectFixed="false"
:rowSelectDataType="false"
@tableSelect="tableSelect"
@tableSelectAll="tableSelectAll"
>
<template v-slot:logisticsNo="scope">
<el-button type="text" @click="view(scope.row)">{{
...
...
@@ -167,7 +179,9 @@
</template>
<script>
import { getPddInfo, getResend } from "@/api/pdd-info";
import { getPddInfo, getResend, getSubmitExportTask } from "@/api/pdd-info";
import { getTaskStatus } from "@/api/exportList-api.js";
import { downloadAsyncExportByTaskId } from "@/utils/zipdownload";
export default {
name: "PddList",
components: {},
...
...
@@ -187,7 +201,6 @@ export default {
total: 0,
},
tableData: [],
headerData: [
{
name: "物流运单编号",
...
...
@@ -248,8 +261,14 @@ export default {
],
loadings: {
searchLoading: false,
exportDeclareLoading: false,
},
tableMaxheight: null,
selected: [],
currentTaskId: null,
pollTimer: null,
isPolling: false,
pollInterval: 5000, // 轮询间隔(5秒)
};
},
created() {
...
...
@@ -290,6 +309,32 @@ export default {
};
this.originalLogisticsNo = "";
},
//导出
downloadData() {
let obj = {
...this.searchInfo(JSON.parse(JSON.stringify(this.sreachFormData))),
ids: [],
};
obj.ids = this.selected.map((item) => item.id);
this.loadings.exportDeclareLoading = true;
this.$confirm(`正在导出中,请稍候!`, "提示", {
confirmButtonText: "确定",
cancelButtonText: "取消",
type: "warning",
})
.then(() => {
getSubmitExportTask(obj).then((res) => {
if (res.code === "200") {
this.currentTaskId = res.data;
this.startPolling();
}
});
})
.catch(() => {
this.loadings.exportDeclareLoading = false;
});
},
showAgain(row) {
this.$confirm("是否确认操作重新发送?", "提示", {
confirmButtonText: "确定",
...
...
@@ -314,7 +359,27 @@ export default {
if (val == 0) {
this.page.pageIndex = 1;
}
let obj = { ...this.sreachFormData }; // 使用对象展开运算符复制 sreachFormData
let obj = this.searchInfo(JSON.parse(JSON.stringify(this.sreachFormData)));
getPddInfo(obj)
.then((res) => {
if (res.code === "200") {
this.tableData = res.data.value;
this.page.total = res.data.totalItems;
this.tableData.forEach((item, idx) => {
item.index = idx;
});
} else {
this.alertWarningMsg(res.message);
}
this.loadings.searchLoading = false;
})
.catch((err) => {
console.log(err);
this.loadings.searchLoading = false;
});
},
searchInfo(obj) {
obj.pageIndex = this.page.pageIndex;
obj.pageSize = this.page.pageSize;
obj.logisticsNo = this.originalLogisticsNo;
...
...
@@ -334,26 +399,8 @@ export default {
obj.startTime = obj.createTime[0];
obj.endTime = obj.createTime[1];
}
getPddInfo(obj)
.then((res) => {
if (res.code === "200") {
this.tableData = res.data.value;
this.page.total = res.data.totalItems;
this.tableData.forEach((item, idx) => {
item.index = idx;
});
} else {
this.alertWarningMsg(res.message);
}
this.loadings.searchLoading = false;
})
.catch((err) => {
console.log(err);
this.loadings.searchLoading = false;
});
return obj;
},
//分页
currentChange(val) {
this.page.pageIndex = val.page;
...
...
@@ -366,6 +413,87 @@ export default {
input() {
this.$forceUpdate();
},
tableSelect(selection, row) {
this.selected = selection.selection;
},
tableSelectAll(selection) {
this.selected = selection;
},
// 轮询查询状态
async pollStatus() {
try {
const result = await getTaskStatus({ taskId: this.currentTaskId });
if (+result.code === 200) {
// PENDING, PROCESSING, COMPLETED, FAILED
if (result.data.status === "COMPLETED") {
this.stopPolling(); // 停止轮询
await this.callOtherApi(); // 调用其他接口
} else if (result.data.status === "FAILED") {
this.stopPolling();
this.handleFailure();
this.alertWarningMsg(result.data.errorMessage);
} else {
this.startPolling(); // 启动轮询
}
} else {
this.stopPolling();
this.handleFailure();
}
// 其他状态继续轮询
} catch (error) {
console.error("轮询查询失败:", error);
this.stopPolling();
}
},
// 启动轮询
startPolling() {
if (this.isPolling) return;
this.isPolling = true;
this.pollTimer = setInterval(() => {
this.pollStatus();
}, this.pollInterval);
},
// 停止轮询
stopPolling() {
if (this.pollTimer) {
clearInterval(this.pollTimer);
this.pollTimer = null;
}
this.isPolling = false;
this.loadings.searchLoading = false;
},
// 查询成功后调用的其他接口
async callOtherApi() {
try {
this.downLoadZip();
// const fileName = `${formatDateNew(new Date())}.xlsx`;
// this.fileDownload
// .downLoadZip("task", "customDownloadXls", fileName, "xlsx", "get", {
// taskId: this.currentTaskId,
// })
// .finally(() => {
// // this.cancelDownload();
// this.loadings.searchLoading = false;
// });
} catch (error) {
console.error("后续接口调用失败:", error);
}
},
downLoadZip() {
downloadAsyncExportByTaskId(this.currentTaskId, {
maxRetry: 50,
retryDelay: 5000,
onRetryExhausted: () => {
this.alertWarningMsg("导出失败");
},
onWarning: (msg) => {
this.alertWarningMsg(msg);
},
}).finally(() => {
this.loadings.searchLoading = false;
});
},
},
};
</script>
...
...
Please
register
or
login
to post a comment