Commit cfb8c760 by 王悦

add尼斯过滤

parent 07dbc509
......@@ -2,6 +2,7 @@ var system = require("../../system")
var settings = require("../../../config/settings");
const CtlBase = require("../ctl.base");
const uuidv4 = require('uuid/v4');
class DrafthistoryCtl extends CtlBase {
constructor() {
......@@ -12,12 +13,12 @@ class DrafthistoryCtl extends CtlBase {
//post
async createDraft(q, body, req) {
try{
try {
body.userId = req.session.user.id;
console.log('create draft========', body);
let result = await this.service.createOne(body);
return system.getResult2(result, req);
}catch(e) {
} catch (e) {
return system.getErrResult2(e);
}
......@@ -47,6 +48,37 @@ class DrafthistoryCtl extends CtlBase {
}
}
//尼斯过滤
async filterDraft(q, body, req) {
try {
let channelCode = body.channelCode || "gsbh5";
let channelApiUrl = settings.channelApiUrl(channelCode);
let url = channelApiUrl + "/api/action/tmTools/springBoard";
let rc = system.getObject("util.execClient");
try {
let rtn = [];
for (let dra of body) {
if (typeof (dra.nclSmallCodes) === "string") {
dra.nclSmallCodes = JSON.parse(dra.nclSmallCodes)
}
if (dra.nclSmallCodes.hasOwnProperty("nclthree"))
dra.nclSmallCodes = dra.nclSmallCodes.nclthree;
let param = {
"actionType": "getTmNclFilterSearch",
"actionBody": dra
};
let res = await rc.execPost(param, url);
rtn.push(JSON.parse(res.stdout).data);
}
return rtn;
} catch (e) {
return system.getResult2(null, null);
}
} catch (e) {
return system.getErrResult2(e);
}
}
//get 前端需要创建两个接口,一个是获取所有,一个是按名称索引所有
//查询当前用户所有草稿版本例:obj = {'userId': '333'}
//查询当前用户的某个名字草稿版本例:obj = {'userId': '333', 'draftName': '测试2'}
......@@ -73,4 +105,5 @@ class DrafthistoryCtl extends CtlBase {
}
}
module.exports = DrafthistoryCtl;
\ No newline at end of file
......@@ -1051,7 +1051,7 @@
},
reuseDraft: function(row) {
console.log('=========row', row.draftId, row.draftName);
this.$root.getReq("web/drafthistoryCtl/findOneDraft", { id: row.draftId }).then(d => {
this.$root.getReq("web/drafthistoryCtl/findOneDraft", { id: row.draftId }).then(async d => {
console.log("findOneDraft return :", d);
var data = d.data.draftData;
if (data.checkedNcl) {
......@@ -1061,7 +1061,15 @@
this.form = data.form;
}
if (data.nclOne) {
this.nclOne = data.nclOne;
let nlc = [];
for (let n of data.nclOne){
nlc.push({
nclOneCodes:n.code,
nclSmallCodes:n.nclThree
})
}
let tms = await this.filterDraft(nlc);
this.nclOne = this.formatnclone(tms);
}
if (data.apply) {
this.apply = data.apply;
......@@ -1171,27 +1179,50 @@
importHistoryNcl: function() {
if (this.historyOrderNum) {
this.$root.showMask();
this.$root.getReq("/web/trademarkCtl/getHistoryNclByChannelOrderNum", { channelOrderNum: this.historyOrderNum }).then(d => {
this.$root.getReq("/web/trademarkCtl/getHistoryNclByChannelOrderNum", { channelOrderNum: this.historyOrderNum }).then(async d => {
console.log("d");
console.log(d);
d.data = await this.filterDraft(d.data);
if (d && d.code == 1) {
var tms = d.data;
this.nclOne = this.formatnclone(tms);
this.$message.success("导入成功");
} else {
this.$message.warning(d.msg);
}
this.$root.hideMask();
}).catch(e => {
console.log(e);
this.$root.hideMask();
this.$message.warning("操作失败")
});
} else {
this.$message.warning("请填写历史订单号");
}
},
formatnclone(tms){
var nclOne = [];
for (var i = 0; i < tms.length; i++) {
var t = tms[i];
console.log(t, ",t.t.....t...............");
console.log(t.nclOneCodes, ",t.nclOneCode...............");
if (!t.nclOneCodes) {
continue;
}
var nclThree = null;
if (t.nclSmallCodes.indexOf("nclthree") < 0) {
nclThree = JSON.parse(t.nclSmallCodes);
nclThree = t.nclSmallCodes;
} else {
var tmpNclThree = JSON.parse(t.nclSmallCodes);
debugger;
var tmpNclThree = t.nclSmallCodes;
var sources = [];
for (var j = 0; j < tmpNclThree.nclthree.length; j++) {
var tmpItem = tmpNclThree.nclthree[j];
if (tmpItem) {
var source = {
"code": tmpNclThree.nclthree[j].code,
"name": tmpNclThree.nclthree[j].name,
"fullname": tmpNclThree.nclthree[j].code + " " + tmpNclThree.nclthree[j].name,
"name": tmpNclThree.nclthree[j].name || "",
"fullname": tmpNclThree.nclthree[j].code + " " + tmpNclThree.nclthree[j].name || "",
"pcode": tmpNclThree.nclthree[j].pcode,
"disabled": false
};
......@@ -1200,26 +1231,15 @@
}
nclThree = sources;
}
var name = this.ncldata[Number(t.nclOneCodes) - 1].name;
var name = this.ncldata[Number(t.nclOneCodes) - 1].name || "";
var o = { code: t.nclOneCodes, name: name, nclThree: nclThree, price: (nclThree.length - 10) * 30 + 300 };
nclOne.push(o);
}
this.nclOne = nclOne;
this.$message.success("导入成功");
} else {
this.$message.warning(d.msg);
}
this.$root.hideMask();
}).catch(e => {
console.log(e);
this.$root.hideMask();
this.$message.warning("操作失败")
});
} else {
this.$message.warning("请填写历史订单号");
}
return nclOne
},
async filterDraft(nclOne){
let d = await this.$root.postReq("/web/drafthistoryCtl/filterDraft", nclOne);
return d
}
},
......
......@@ -1120,7 +1120,7 @@
},
reuseDraft: function(row) {
console.log('=========row', row.draftId, row.draftName);
this.$root.getReq("web/drafthistoryCtl/findOneDraft", {id: row.draftId}).then(d => {
this.$root.getReq("web/drafthistoryCtl/findOneDraft", {id: row.draftId}).then(async d => {
console.log("findOneDraft return :", d);
var data = d.data.draftData;
if (data.checkedNcl) {
......@@ -1130,7 +1130,15 @@
this.form = data.form;
}
if (data.nclOne) {
this.nclOne = data.nclOne;
let nlc = [];
for (let n of data.nclOne){
nlc.push({
nclOneCodes:n.code,
nclSmallCodes:n.nclThree
})
}
let tms = await this.filterDraft(nlc);
this.nclOne = this.formatnclone(tms);
}
if (data.apply) {
this.apply = data.apply;
......@@ -1225,10 +1233,28 @@
importHistoryNcl: function() {
if (this.historyOrderNum) {
this.$root.showMask();
this.$root.getReq("/web/trademarkCtl/getHistoryNclByChannelOrderNum", { channelOrderNum: this.historyOrderNum }).then(d => {
this.$root.getReq("/web/trademarkCtl/getHistoryNclByChannelOrderNum", { channelOrderNum: this.historyOrderNum }).then(async d => {
console.log(d, "getHistoryNclByChannelOrderNum............return..");
d.data = await this.filterDraft(d.data);
if (d && d.code == 1) {
var tms = d.data;
this.nclOne = this.formatnclone(tms);
this.$message.success("导入成功");
} else {
this.$message.warning(d.msg);
}
this.$root.hideMask();
}).catch(e => {
console.log(e);
this.$root.hideMask();
this.$message.warning("操作失败")
});
} else {
this.$message.warning("请填写历史订单号");
}
},
formatnclone(tms){
var nclOne = [];
for (var i = 0; i < tms.length; i++) {
var t = tms[i];
......@@ -1239,10 +1265,10 @@
}
var nclThree = null;
if (t.nclSmallCodes.indexOf("nclthree") < 0) {
nclThree = JSON.parse(t.nclSmallCodes);
nclThree = t.nclSmallCodes;
} else {
debugger;
var tmpNclThree = JSON.parse(t.nclSmallCodes);
var tmpNclThree = t.nclSmallCodes;
var sources = [];
for (var j = 0; j < tmpNclThree.nclthree.length; j++) {
var tmpItem = tmpNclThree.nclthree[j];
......@@ -1262,23 +1288,12 @@
var name = this.ncldata[Number(t.nclOneCodes) - 1].name || "";
var o = { code: t.nclOneCodes, name: name, nclThree: nclThree, price: (nclThree.length - 10) * 30 + 300 };
nclOne.push(o);
}
this.nclOne = nclOne;
this.$message.success("导入成功");
} else {
this.$message.warning(d.msg);
}
this.$root.hideMask();
}).catch(e => {
console.log(e);
this.$root.hideMask();
this.$message.warning("操作失败")
});
} else {
this.$message.warning("请填写历史订单号");
}
return nclOne
},
async filterDraft(nclOne){
let d = await this.$root.postReq("/web/drafthistoryCtl/filterDraft", nclOne);
return d
}
},
......
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