Commit 5a6add14 by qinjianhui

fix: 操作单详情下载素材修改

parent 6d844a0d
......@@ -12,6 +12,7 @@ export const pathMap = {
US: "factory/podJomallOrderProductUs/downloadDesignImages",
GC: "factory/podJomallOrder/downloadByProduction",
OP: "factory/podOrderOperation/downloadDesignImages",
DTF: "factory/podOrderOperation/softwareProduction-downloadDesignImages",
USHLC: "factory/podJomallOrderProductUs/downloadCompatibleDesignImages",
CNHLC: "factory/podJomallOrderProductCn/downloadCompatibleDesignImages",
OPHLC: "factory/podOrderOperation/downloadCompatibleDesignImages"
......
......@@ -156,11 +156,20 @@ export default {
env = getHostApi().apiApiHost;
fileEnv = getHostApi().fileApiUrl;
const params = req.body;
const targetDir = params.targetDir || "";
const token = req.headers["jwt-token"];
const forceProduction = params.forceProduction || false;
const downloadBySubOrderNumber = pathMap["downloadBySubOrderNumber"];
try {
if (Array.isArray(params)) {
const routePath = req.path.replace(/^\//, "");
const postUrl = `${env}/${routePath}`;
const { data } = await axios.post(postUrl, params, {
headers: { "jwt-token": token }
});
return res.json(data);
}
const targetDir = params.targetDir || "";
const forceProduction = params.forceProduction || false;
let url = downloadBySubOrderNumber[params.orderType];
let postUrl = `${env}/${url}`;
if (params.device == 3) {
......
......@@ -6,6 +6,11 @@ const { pathMap } = require("@/config/index.js");
const { getUser } = require("@/server/utils/store");
var path = require("path");
import bus from "@/bus";
import {
submitDownload,
getDownloadStatus,
onDownloadStatusChange
} from "@/utils/download-api";
export default {
props: {
selection: { type: Array, default: () => [] },
......@@ -19,11 +24,13 @@ export default {
curBatchArrangeNum: "",
searchForm: {},
statusMap: statusMap,
userData: getUser()
userData: getUser(),
isDownloading: false,
removeStatusListener: null
};
},
mounted() {
async mounted() {
const params = this.$route.params;
this.curBatchArrangeNum = params.batchArrangeNum;
bus.$on("downLoadFile", async v => {
......@@ -49,6 +56,13 @@ export default {
this.$message.error(error);
}
});
this.removeStatusListener = onDownloadStatusChange(status => {
this.handleDownloadStatus(status);
});
await this.syncDownloadStatus();
},
beforeDestroy() {
if (this.removeStatusListener) this.removeStatusListener();
},
created() {},
......@@ -94,29 +108,62 @@ export default {
if (!this.podOrderProductIds.length) {
return this.$message.warning("请选择操作单");
}
if (this.isDownloading) {
return this.$message.warning("正在下载中,请等待完成后再操作");
}
try {
this.isDownloading = true;
const res = await this.$api.post(
pathMap["downloadBySubOrderNumber"]["OP"],
{
ids: this.podOrderProductIds,
device: 4,
orderType: "OP",
targetDir: path.join(
pathMap["downloadBySubOrderNumber"]["DTF"],
this.podOrderProductIds
);
if (res.code !== 200 || !res.data || res.data.length === 0) {
this.$message.warning(res.msg || "暂无素材可下载");
this.isDownloading = false;
return;
}
const urls = res.data.map(item => ({
url: item.fileUrl,
fileName: item.fileName
}));
const downloadRes = await submitDownload({
urls,
targetPath: path.join(
getDTFSetting().downloadDir,
`批次号:${this.curBatchArrangeNum}`,
"原素材"
)
),
batchArrangeNum: this.curBatchArrangeNum
});
if (downloadRes.code !== 200) {
this.isDownloading = false;
this.$message.error(downloadRes.msg);
}
);
if (res.code === 200) {
} catch (error) {
console.error(error.message || "下载失败");
this.$message.error("下载提交失败,请重试");
this.isDownloading = false;
}
},
handleDownloadStatus(status) {
this.isDownloading = status.isRunning;
if (!status.isRunning && status.result) {
const { success, failed } = status.result;
const { currentBatchNo } = status;
this.$message.success(
`批次号:${this.curBatchArrangeNum},素材下载成功`
`批次号:${currentBatchNo},下载完成:成功 ${success.length} 个,失败 ${failed.length}`
);
} else {
this.$message.error(res.msg || "下载失败");
if (failed.length > 0) {
console.warn("下载失败明细:", failed);
}
} catch (error) {
this.$message.error(error.message || "下载失败");
}
},
async syncDownloadStatus() {
try {
const res = await getDownloadStatus();
this.isDownloading = res.data.isRunning;
} catch (err) {
console.error("同步下载状态失败", err);
}
},
getDataInfo() {
......
......@@ -144,26 +144,18 @@ export default {
label: "全部选择",
click: () => {
const cardIds = this.cardList.map(el => el.id);
const cardProIds = this.cardList.map(el => el.podOrderProductId);
this.podOrderProductIds = Array.from(
new Set([...this.podOrderProductIds, ...cardProIds])
);
this.selection = Array.from(
new Set([...this.selection, ...cardIds])
);
this.rebuildPodOrderProductIds();
}
},
{
label: "取消选择",
click: () => {
const cardIdSet = new Set(this.cardList.map(el => el.id));
const cardProIdsSet = new Set(
this.cardList.map(el => el.podOrderProductId)
);
this.selection = this.selection.filter(id => !cardIdSet.has(id));
this.podOrderProductIds = this.selection.filter(
id => !cardProIdsSet.has(id)
);
this.rebuildPodOrderProductIds();
}
}
];
......@@ -215,17 +207,18 @@ export default {
},
changeActive(item) {
const index = this.selection.indexOf(item.id);
const podIndex = this.podOrderProductIds.indexOf(item.podOrderProductId);
if (podIndex > -1) {
this.podOrderProductIds.splice(podIndex, 1);
} else {
this.podOrderProductIds.push(item.podOrderProductId);
}
if (index > -1) {
this.selection.splice(index, 1);
} else {
this.selection.push(item.id);
}
this.rebuildPodOrderProductIds();
},
rebuildPodOrderProductIds() {
const selectedSet = new Set(this.selection);
this.podOrderProductIds = this.cardList
.filter(card => selectedSet.has(card.id))
.map(card => card.podOrderProductId);
},
isSelected(item) {
return this.selection.includes(item.id);
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment