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,15 +13,15 @@ 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);
}
}
//get
......@@ -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
......@@ -375,7 +375,7 @@
that.$message.warning("请填写客户联系人");
return;
}
that.$root.showMask();
var params = this.apply.type + ";" + this.apply.applyName + ";" + this.apply.identityCard + ";" + this.form.tmFormType
+ ";" + this.form.colorizedPicUrl + ";" + this.form.picUrl + ";" + this.apply.applyAddr;
......@@ -383,7 +383,7 @@
console.log(params);
var url = window.location.href.split("/autosubmitinside")[0] + "/mobile2?" + "params=" + params + "#/createwts2";
console.log(url);
let tm_name = "";
if(this.form.tmFormType == 3 || this.form.tmFormType == 5) {
tm_name = this.form.tmName;
......@@ -393,8 +393,8 @@
}
if(this.form.tmFormType)
this.$root.getReq("/web/calculatepriceCtl/tmtrust", {
assignor: this.apply.applyName,
tm_name: tm_name,
assignor: this.apply.applyName,
tm_name: tm_name,
address: this.apply.applyAddr,
company: this.apply.principal,
}).then(function (d) {
......@@ -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,41 +1179,12 @@
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;
var nclOne = [];
for (var i = 0; i < tms.length; i++) {
var t = tms[i];
var nclThree = null;
if (t.nclSmallCodes.indexOf("nclthree") < 0) {
nclThree = JSON.parse(t.nclSmallCodes);
} else {
var tmpNclThree = JSON.parse(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,
"pcode": tmpNclThree.nclthree[j].pcode,
"disabled": false
};
sources.push(source);
}
}
nclThree = sources;
}
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.nclOne = this.formatnclone(tms);
this.$message.success("导入成功");
} else {
this.$message.warning(d.msg);
......@@ -1220,7 +1199,48 @@
} 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 = t.nclSmallCodes;
} else {
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 || "",
"pcode": tmpNclThree.nclthree[j].pcode,
"disabled": false
};
sources.push(source);
}
}
nclThree = sources;
}
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);
}
return nclOne
},
async filterDraft(nclOne){
let d = await this.$root.postReq("/web/drafthistoryCtl/filterDraft", nclOne);
return d
}
},
vname: "gsb-automatictmsubmitedit"
......
......@@ -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,46 +1233,12 @@
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;
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);
} else {
debugger;
var tmpNclThree = JSON.parse(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 || "",
"pcode": tmpNclThree.nclthree[j].pcode,
"disabled": false
};
sources.push(source);
}
}
nclThree = sources;
}
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.nclOne = this.formatnclone(tms);
this.$message.success("导入成功");
} else {
this.$message.warning(d.msg);
......@@ -1279,6 +1253,47 @@
} 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 = t.nclSmallCodes;
} else {
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 || "",
"pcode": tmpNclThree.nclthree[j].pcode,
"disabled": false
};
sources.push(source);
}
}
nclThree = sources;
}
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);
}
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