Commit cfb8c760 by 王悦

add尼斯过滤

parent 07dbc509
...@@ -2,6 +2,7 @@ var system = require("../../system") ...@@ -2,6 +2,7 @@ var system = require("../../system")
var settings = require("../../../config/settings"); var settings = require("../../../config/settings");
const CtlBase = require("../ctl.base"); const CtlBase = require("../ctl.base");
const uuidv4 = require('uuid/v4'); const uuidv4 = require('uuid/v4');
class DrafthistoryCtl extends CtlBase { class DrafthistoryCtl extends CtlBase {
constructor() { constructor() {
...@@ -12,12 +13,12 @@ class DrafthistoryCtl extends CtlBase { ...@@ -12,12 +13,12 @@ class DrafthistoryCtl extends CtlBase {
//post //post
async createDraft(q, body, req) { async createDraft(q, body, req) {
try{ try {
body.userId = req.session.user.id; body.userId = req.session.user.id;
console.log('create draft========', body); console.log('create draft========', body);
let result = await this.service.createOne(body); let result = await this.service.createOne(body);
return system.getResult2(result, req); return system.getResult2(result, req);
}catch(e) { } catch (e) {
return system.getErrResult2(e); return system.getErrResult2(e);
} }
...@@ -47,6 +48,37 @@ class DrafthistoryCtl extends CtlBase { ...@@ -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 前端需要创建两个接口,一个是获取所有,一个是按名称索引所有 //get 前端需要创建两个接口,一个是获取所有,一个是按名称索引所有
//查询当前用户所有草稿版本例:obj = {'userId': '333'} //查询当前用户所有草稿版本例:obj = {'userId': '333'}
//查询当前用户的某个名字草稿版本例:obj = {'userId': '333', 'draftName': '测试2'} //查询当前用户的某个名字草稿版本例:obj = {'userId': '333', 'draftName': '测试2'}
...@@ -73,4 +105,5 @@ class DrafthistoryCtl extends CtlBase { ...@@ -73,4 +105,5 @@ class DrafthistoryCtl extends CtlBase {
} }
} }
module.exports = DrafthistoryCtl; module.exports = DrafthistoryCtl;
\ No newline at end of file
...@@ -1051,7 +1051,7 @@ ...@@ -1051,7 +1051,7 @@
}, },
reuseDraft: function(row) { reuseDraft: function(row) {
console.log('=========row', row.draftId, row.draftName); 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); console.log("findOneDraft return :", d);
var data = d.data.draftData; var data = d.data.draftData;
if (data.checkedNcl) { if (data.checkedNcl) {
...@@ -1061,7 +1061,15 @@ ...@@ -1061,7 +1061,15 @@
this.form = data.form; this.form = data.form;
} }
if (data.nclOne) { 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) { if (data.apply) {
this.apply = data.apply; this.apply = data.apply;
...@@ -1171,27 +1179,50 @@ ...@@ -1171,27 +1179,50 @@
importHistoryNcl: function() { importHistoryNcl: function() {
if (this.historyOrderNum) { if (this.historyOrderNum) {
this.$root.showMask(); 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");
console.log(d); d.data = await this.filterDraft(d.data);
if (d && d.code == 1) { if (d && d.code == 1) {
var tms = d.data; 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 = []; var nclOne = [];
for (var i = 0; i < tms.length; i++) { for (var i = 0; i < tms.length; i++) {
var t = tms[i]; var t = tms[i];
console.log(t, ",t.t.....t...............");
console.log(t.nclOneCodes, ",t.nclOneCode...............");
if (!t.nclOneCodes) {
continue;
}
var nclThree = null; var nclThree = null;
if (t.nclSmallCodes.indexOf("nclthree") < 0) { if (t.nclSmallCodes.indexOf("nclthree") < 0) {
nclThree = JSON.parse(t.nclSmallCodes); nclThree = t.nclSmallCodes;
} else { } else {
var tmpNclThree = JSON.parse(t.nclSmallCodes); debugger;
var tmpNclThree = t.nclSmallCodes;
var sources = []; var sources = [];
for (var j = 0; j < tmpNclThree.nclthree.length; j++) { for (var j = 0; j < tmpNclThree.nclthree.length; j++) {
var tmpItem = tmpNclThree.nclthree[j]; var tmpItem = tmpNclThree.nclthree[j];
if (tmpItem) { if (tmpItem) {
var source = { var source = {
"code": tmpNclThree.nclthree[j].code, "code": tmpNclThree.nclthree[j].code,
"name": tmpNclThree.nclthree[j].name, "name": tmpNclThree.nclthree[j].name || "",
"fullname": tmpNclThree.nclthree[j].code + " " + tmpNclThree.nclthree[j].name, "fullname": tmpNclThree.nclthree[j].code + " " + tmpNclThree.nclthree[j].name || "",
"pcode": tmpNclThree.nclthree[j].pcode, "pcode": tmpNclThree.nclthree[j].pcode,
"disabled": false "disabled": false
}; };
...@@ -1200,26 +1231,15 @@ ...@@ -1200,26 +1231,15 @@
} }
nclThree = sources; 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 }; var o = { code: t.nclOneCodes, name: name, nclThree: nclThree, price: (nclThree.length - 10) * 30 + 300 };
nclOne.push(o); 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 @@ ...@@ -1120,7 +1120,7 @@
}, },
reuseDraft: function(row) { reuseDraft: function(row) {
console.log('=========row', row.draftId, row.draftName); 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); console.log("findOneDraft return :", d);
var data = d.data.draftData; var data = d.data.draftData;
if (data.checkedNcl) { if (data.checkedNcl) {
...@@ -1130,7 +1130,15 @@ ...@@ -1130,7 +1130,15 @@
this.form = data.form; this.form = data.form;
} }
if (data.nclOne) { 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) { if (data.apply) {
this.apply = data.apply; this.apply = data.apply;
...@@ -1225,10 +1233,28 @@ ...@@ -1225,10 +1233,28 @@
importHistoryNcl: function() { importHistoryNcl: function() {
if (this.historyOrderNum) { if (this.historyOrderNum) {
this.$root.showMask(); 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.."); console.log(d, "getHistoryNclByChannelOrderNum............return..");
d.data = await this.filterDraft(d.data);
if (d && d.code == 1) { if (d && d.code == 1) {
var tms = d.data; 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 = []; var nclOne = [];
for (var i = 0; i < tms.length; i++) { for (var i = 0; i < tms.length; i++) {
var t = tms[i]; var t = tms[i];
...@@ -1239,10 +1265,10 @@ ...@@ -1239,10 +1265,10 @@
} }
var nclThree = null; var nclThree = null;
if (t.nclSmallCodes.indexOf("nclthree") < 0) { if (t.nclSmallCodes.indexOf("nclthree") < 0) {
nclThree = JSON.parse(t.nclSmallCodes); nclThree = t.nclSmallCodes;
} else { } else {
debugger; debugger;
var tmpNclThree = JSON.parse(t.nclSmallCodes); var tmpNclThree = t.nclSmallCodes;
var sources = []; var sources = [];
for (var j = 0; j < tmpNclThree.nclthree.length; j++) { for (var j = 0; j < tmpNclThree.nclthree.length; j++) {
var tmpItem = tmpNclThree.nclthree[j]; var tmpItem = tmpNclThree.nclthree[j];
...@@ -1262,23 +1288,12 @@ ...@@ -1262,23 +1288,12 @@
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 }; var o = { code: t.nclOneCodes, name: name, nclThree: nclThree, price: (nclThree.length - 10) * 30 + 300 };
nclOne.push(o); 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