Commit e301fc30 by linjinhong

fix:适配新流程

parent 3dcb6d83
export const pathMap = { export const pathMap = {
//查询接口 //查询接口
findByPodProductionNo: { findByPodProductionNo: "factory/podOrderOperation/getByOperationNo",
CN: "factory/podJomallOrderProductCn/getProductCnByFactorySubOrderNumber",
US: "factory/podJomallOrderProductUs/getProductUsByFactorySubOrderNumber",
GC: "factory/podJomallOrderProduct/getSubOrderByThirdSubOrderNumber",
},
//下载素材接口 //下载素材接口
downloadBySubOrderNumber: { downloadBySubOrderNumber: {
CN: "factory/podJomallOrderProductCn/downloadDesignImages", XD: "factory/podOrderOperation/downloadDesignImages",
US: "factory/podJomallOrderProductUs/downloadDesignImages", HLC: "factory/podOrderOperation/downloadCompatibleDesignImages",
GC: "factory/podJomallOrder/downloadByProduction",
USHLC: "factory/podJomallOrderProductUs/downloadCompatibleDesignImages",
CNHLC: "factory/podJomallOrderProductCn/downloadCompatibleDesignImages",
}, },
//生产完成接口 //生产完成接口
completeDelivery: { completeDelivery: "factory/podOrderOperation/printerCompleteDelivery",
CN: "factory/podJomallOrderProductCn/completeDelivery",
US: "factory/podJomallOrderProductUs/completeDelivery",
GC: "factory/podJomallOrderProduct/completeDelivery",
},
//惠立彩素材下载接口
processTransparentBackground: {
CN: "factory/podJomallOrderProductCn/processTransparentBackground",
US: "factory/podJomallOrderProductUs/processTransparentBackground",
},
}; };
export function autoRegisterRouter(router, funcKey, handler) { export function autoRegisterRouter(router, funcKey, handler) {
const configGroup = pathMap[funcKey]; const config = pathMap[funcKey];
const pathList =
typeof config === "string" ? [config] : Object.values(config);
// 遍历配置自动注册路由 // 遍历配置自动注册路由
Object.values(configGroup).forEach((el) => { pathList.forEach((path) => {
router.post(`/${el}`, (req, res) => { // 拼接完整路径(兼容首尾斜杠)
handler(req, res); const fullPath = `/${path.replace(/^\//, "")}`;
}); router.post(fullPath, handler);
}); });
} }
...@@ -157,16 +157,14 @@ export default { ...@@ -157,16 +157,14 @@ export default {
const forceProduction = params.forceProduction || false; const forceProduction = params.forceProduction || false;
const downloadBySubOrderNumber = pathMap["downloadBySubOrderNumber"]; const downloadBySubOrderNumber = pathMap["downloadBySubOrderNumber"];
try { try {
let url = downloadBySubOrderNumber[params.orderType]; let url = downloadBySubOrderNumber["XD"];
let postUrl = `${env}/${url}`; let postUrl = `${env}/${url}`;
if (params.device == 3) { if (params.device == 3) {
url = url = downloadBySubOrderNumber["HLC"];
params.orderType == "CN"
? downloadBySubOrderNumber["CNHLC"]
: downloadBySubOrderNumber["USHLC"];
postUrl = `${env}/${url}?forceProduction=${forceProduction}`; postUrl = `${env}/${url}?forceProduction=${forceProduction}`;
} }
console.log("postUrl", postUrl);
const { data } = await axios.post(postUrl, [...params.ids], { const { data } = await axios.post(postUrl, [...params.ids], {
headers: { "jwt-token": token }, headers: { "jwt-token": token },
}); });
...@@ -174,7 +172,7 @@ export default { ...@@ -174,7 +172,7 @@ export default {
if (data.code !== 200) { if (data.code !== 200) {
return res.json(data); return res.json(data);
} }
console.log("data", data); console.log("data200", data);
let path, processDesignA, processDesignB; let path, processDesignA, processDesignB;
if (data.data) { if (data.data) {
path = data.data.path || data.data[0]; path = data.data.path || data.data[0];
...@@ -214,29 +212,11 @@ export default { ...@@ -214,29 +212,11 @@ export default {
const params = req.body; const params = req.body;
try { try {
const urlArr = { let url = pathMap["findByPodProductionNo"];
CN: {
field: "factorySubOrderNumber",
url:
"factory/podJomallOrderProductCn/getProductCnByFactorySubOrderNumber",
},
US: {
field: "factorySubOrderNumber",
url:
"factory/podJomallOrderProductUs/getProductUsByFactorySubOrderNumber",
},
GC: {
field: "thirdSubOrderNumber",
url: "factory/podJomallOrderProduct/getSubOrderByThirdSubOrderNumber",
},
};
let url = urlArr[params.orderType].url;
let paramsField = urlArr[params.orderType].field;
let { data } = await axios.get(`${env}/${url}`, { let { data } = await axios.get(`${env}/${url}`, {
params: { params: {
[paramsField]: params.thirdSubOrderNumber, operationNo: params.thirdSubOrderNumber,
resizable: params.resizable,
}, },
headers: { "jwt-token": token }, headers: { "jwt-token": token },
}); });
...@@ -262,30 +242,10 @@ export default { ...@@ -262,30 +242,10 @@ export default {
completeDelivery: async (req, res) => { completeDelivery: async (req, res) => {
env = getHostApi().apiApiHost; env = getHostApi().apiApiHost;
const token = req.headers["jwt-token"]; const token = req.headers["jwt-token"];
const params = req.body; const postData = req.body;
const urlArr = {
CN: { let url = pathMap["completeDelivery"];
data: {
id: params.id,
podJomallOrderCnId: params.podJomallOrderCnId || "",
},
url: "factory/podJomallOrderProductCn/completeDelivery",
},
US: {
data: {
id: params.id,
podJomallOrderUsId: params.podJomallOrderUsId || "",
},
url: "factory/podJomallOrderProductUs/completeDelivery",
},
GC: {
data: { id: params.id },
url: "factory/podJomallOrderProduct/completeDelivery",
},
};
let url = urlArr[params.orderType].url;
let postData = urlArr[params.orderType].data;
// console.log("postData", postData); // console.log("postData", postData);
// console.log("240url", url); // console.log("240url", url);
...@@ -597,37 +557,4 @@ export default { ...@@ -597,37 +557,4 @@ export default {
res.json({ code: 500, msg: error }); res.json({ code: 500, msg: error });
} }
}, },
processTransparentBackground: async (req, res) => {
env = getHostApi().apiApiHost;
const token = req.headers["jwt-token"];
const { imgUrl, subOrderNumber, orderType } = req.body;
const processTransparentBackground =
pathMap["processTransparentBackground"];
let url = processTransparentBackground[orderType];
let postData = { url: imgUrl, subOrderNumber };
try {
let { data } = await axios.get(`${env}/${url}`, {
params: postData,
headers: { "jwt-token": token },
});
console.log("processTransparentBackground", data);
if (data.message) {
data.message = encodeURIComponent(data.message);
}
let files = data.data || [data.message];
files = files.map((el) => ({ url: `${fileEnv}${el}` }));
console.log("processTransparentBackground,files", files);
const result = await downloadImage(files);
res.json({ code: 200, data: result });
} catch (err) {
console.log(err);
res.json({ code: 500, msg: err });
}
},
}; };
...@@ -58,9 +58,4 @@ router.post("/copySingleImageFn", fn.copySingleImageFn); ...@@ -58,9 +58,4 @@ router.post("/copySingleImageFn", fn.copySingleImageFn);
// 根据生产单号查询详情 // 根据生产单号查询详情
autoRegisterRouter(router, "findByPodProductionNo", fn.findByPodProductionNo); autoRegisterRouter(router, "findByPodProductionNo", fn.findByPodProductionNo);
autoRegisterRouter(
router,
"processTransparentBackground",
fn.processTransparentBackground,
);
export { router as default }; export { router as default };
...@@ -232,8 +232,7 @@ export default { ...@@ -232,8 +232,7 @@ export default {
async setData(data) { async setData(data) {
if (!data) return this.$message.warning("请扫描生产单号"); if (!data) return this.$message.warning("请扫描生产单号");
const params = { const params = {
id: data.id, ...this.detail,
orderType: this.orderType,
}; };
if (this.orderType === "CN") { if (this.orderType === "CN") {
params.podJomallOrderCnId = data.podJomallOrderCnId; params.podJomallOrderCnId = data.podJomallOrderCnId;
...@@ -485,16 +484,18 @@ export default { ...@@ -485,16 +484,18 @@ export default {
// 根据生产单号查找 素材图片 下载到本地 然后返回本地地址去显示 // 根据生产单号查找 素材图片 下载到本地 然后返回本地地址去显示
if (!imageResList.length && !bool) { if (!imageResList.length && !bool) {
try { try {
let newType = this.orderType; let newType = "XD";
if (this.orderType == "CN" && this.desktopDevice == 3) { if (this.desktopDevice == 3) {
newType = this.orderType == "CN" ? "CNHLC" : "USHLC"; newType = "HLC";
} }
console.log("this.detail", this.detail);
let res = await this.$api.post( let res = await this.$api.post(
pathMap["downloadBySubOrderNumber"][newType], pathMap["downloadBySubOrderNumber"][newType],
{ {
ids: [this.detail.id], ids: [this.detail.podOrderProductId],
device: this.desktopDevice, device: this.desktopDevice,
orderType: this.orderType,
forceProduction: forceProduction:
this.isForcedProduction || isForcedProduction || false, this.isForcedProduction || isForcedProduction || false,
}, },
...@@ -649,8 +650,6 @@ export default { ...@@ -649,8 +650,6 @@ export default {
let findByPodProductionNo; let findByPodProductionNo;
const apiRequestParams = { const apiRequestParams = {
thirdSubOrderNumber: this.productionNo, thirdSubOrderNumber: this.productionNo,
orderType: this.orderType,
resizable: this.desktopDevice == 3 ? true : false,
}; };
//判断是否为惠立彩 //判断是否为惠立彩
...@@ -662,12 +661,12 @@ export default { ...@@ -662,12 +661,12 @@ export default {
findByPodProductionNo = findByPodProductionNo =
localItem || localItem ||
(await this.$api.post( (await this.$api.post(
pathMap["findByPodProductionNo"][this.orderType], pathMap["findByPodProductionNo"],
apiRequestParams, apiRequestParams,
)); ));
} else { } else {
findByPodProductionNo = await this.$api.post( findByPodProductionNo = await this.$api.post(
pathMap["findByPodProductionNo"][this.orderType], pathMap["findByPodProductionNo"],
apiRequestParams, apiRequestParams,
); );
} }
......
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