Commit e301fc30 by linjinhong

fix:适配新流程

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