|
@@ -13,7 +13,7 @@ const stageIm = (function () {
|
|
const resetFields = ['peg', 'bw', 'xm', 'drawing_code', 'calc_memo', 'position', 'jldy'];
|
|
const resetFields = ['peg', 'bw', 'xm', 'drawing_code', 'calc_memo', 'position', 'jldy'];
|
|
const splitChar = '-';
|
|
const splitChar = '-';
|
|
const mergeChar = ';';
|
|
const mergeChar = ';';
|
|
- let stage, imType, decimal, details, changes, ImData, pre, orgImData;
|
|
|
|
|
|
+ let stage, imType, decimal, details, changes, detailsAtt, ImData, pre, orgImData;
|
|
const gsTreeSetting = {
|
|
const gsTreeSetting = {
|
|
id: 'ledger_id',
|
|
id: 'ledger_id',
|
|
pid: 'ledger_pid',
|
|
pid: 'ledger_pid',
|
|
@@ -66,7 +66,7 @@ const stageIm = (function () {
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
|
|
- function loadData (ledger, pos, stageDetail, stageChange) {
|
|
|
|
|
|
+ function loadData (ledger, pos, stageDetail, stageChange, stageDetailAtt) {
|
|
gsTree.loadDatas(ledger);
|
|
gsTree.loadDatas(ledger);
|
|
treeCalc.calculateAll(gsTree);
|
|
treeCalc.calculateAll(gsTree);
|
|
|
|
|
|
@@ -77,9 +77,11 @@ const stageIm = (function () {
|
|
details = stageDetail;
|
|
details = stageDetail;
|
|
|
|
|
|
changes = stageChange;
|
|
changes = stageChange;
|
|
|
|
+
|
|
|
|
+ detailsAtt = stageDetailAtt;
|
|
}
|
|
}
|
|
|
|
|
|
- function loadData4Rela(ledger, pos, stageDetail, stageChange) {
|
|
|
|
|
|
+ function loadData4Rela(ledger, pos, stageDetail, stageChange, stageDetailAtt) {
|
|
gsTree.loadDatas(ledger);
|
|
gsTree.loadDatas(ledger);
|
|
treeCalc.calculateAll(gsTree);
|
|
treeCalc.calculateAll(gsTree);
|
|
|
|
|
|
@@ -89,6 +91,8 @@ const stageIm = (function () {
|
|
details = stageDetail;
|
|
details = stageDetail;
|
|
|
|
|
|
changes = stageChange;
|
|
changes = stageChange;
|
|
|
|
+
|
|
|
|
+ detailsAtt = stageDetailAtt;
|
|
}
|
|
}
|
|
|
|
|
|
// function loadData (ledger, curStage, pos, curPosStage, stageDetail) {
|
|
// function loadData (ledger, curStage, pos, curPosStage, stageDetail) {
|
|
@@ -286,54 +290,81 @@ const stageIm = (function () {
|
|
im.calc_img_org = detail.calc_img_org;
|
|
im.calc_img_org = detail.calc_img_org;
|
|
im.calc_img_remark = detail.calc_img_remark;
|
|
im.calc_img_remark = detail.calc_img_remark;
|
|
}
|
|
}
|
|
|
|
+ function loadAtt(im, att) {
|
|
|
|
+ im.att_uuid = att.uuid;
|
|
|
|
+ im.attachment = att.attachment;
|
|
|
|
+ }
|
|
|
|
|
|
- function checkTzCustomDetail(im) {
|
|
|
|
- const cd = _.find(details, function (d) {
|
|
|
|
- return im.lid === d.lid &&
|
|
|
|
- (!im.code || im.code === d.code) &&
|
|
|
|
- (!im.name || im.name === d.name) &&
|
|
|
|
- (!im.unit || im.unit === d.unit) &&
|
|
|
|
- (!im.pid || im.pid === d.pid) &&
|
|
|
|
- (!im.pos_name || im.pos_name === d.pos_name);
|
|
|
|
|
|
+ function findTzRela(rela, data) {
|
|
|
|
+ return _.find(rela, function (d) {
|
|
|
|
+ return data.lid === d.lid &&
|
|
|
|
+ (!data.code || data.code === d.code) &&
|
|
|
|
+ (!data.name || data.name === d.name) &&
|
|
|
|
+ (!data.unit || data.unit === d.unit) &&
|
|
|
|
+ (!data.pid || data.pid === d.pid) &&
|
|
|
|
+ (!data.pos_name || data.pos_name === d.pos_name);
|
|
|
|
+ });
|
|
|
|
+ }
|
|
|
|
+ function findZlRela(rela, data) {
|
|
|
|
+ return _.find(rela, function (d) {
|
|
|
|
+ return data.lid === d.lid &&
|
|
|
|
+ (!data.code || data.code === d.code) &&
|
|
|
|
+ (!data.name || data.name === d.name) &&
|
|
|
|
+ (!data.unit || data.unit === d.unit) &&
|
|
|
|
+ checkZero(ZhCalc.sub(data.unit_price, d.unit_price)) &&
|
|
|
|
+ (!data.pid || data.pid === d.pid) &&
|
|
|
|
+ (!data.pos_name || data.pos_name === d.pos_name);
|
|
|
|
+ });
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ function findBwRela(rela, data) {
|
|
|
|
+ return _.find(rela, function (d) {
|
|
|
|
+ return data.lid === d.lid &&
|
|
|
|
+ (!data.code || data.code === d.code) &&
|
|
|
|
+ (!data.name || data.name === d.name) &&
|
|
|
|
+ (!data.unit || data.unit === d.unit) &&
|
|
|
|
+ checkZero(ZhCalc.sub(data.unit_price, d.unit_price)) &&
|
|
|
|
+ (!data.pid || data.pid === d.pid) &&
|
|
|
|
+ (!data.pos_name || data.pos_name === d.pos_name);
|
|
});
|
|
});
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ function findBbRela(rela, data) {
|
|
|
|
+ return _.find(rela, function (d) {
|
|
|
|
+ return data.lid === d.lid &&
|
|
|
|
+ (!data.name || data.name === d.name) &&
|
|
|
|
+ (!data.unit || data.unit === d.unit) &&
|
|
|
|
+ (!data.pid || data.pid === d.pid) &&
|
|
|
|
+ (!data.pos_name || data.pos_name === d.pos_name);
|
|
|
|
+ });
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ function checkTzCustomDetail(im, details) {
|
|
|
|
+ const cd = findTzRela(details, im);
|
|
if (cd) loadCustomDetail(im, cd);
|
|
if (cd) loadCustomDetail(im, cd);
|
|
|
|
+ const att = findTzRela(detailsAtt, im);
|
|
|
|
+ if (att) loadAtt(im, att);
|
|
}
|
|
}
|
|
|
|
|
|
function checkZlCustomDetail(im) {
|
|
function checkZlCustomDetail(im) {
|
|
- const cd = _.find(details, function (d) {
|
|
|
|
- return im.lid === d.lid &&
|
|
|
|
- (!im.code || im.code === d.code) &&
|
|
|
|
- (!im.name || im.name === d.name) &&
|
|
|
|
- (!im.unit || im.unit === d.unit) &&
|
|
|
|
- checkZero(ZhCalc.sub(im.unit_price, d.unit_price)) &&
|
|
|
|
- (!im.pid || im.pid === d.pid) &&
|
|
|
|
- (!im.pos_name || im.pos_name === d.pos_name);
|
|
|
|
- });
|
|
|
|
|
|
+ const cd = findZlRela(details, im);
|
|
if (cd) loadCustomDetail(im, cd);
|
|
if (cd) loadCustomDetail(im, cd);
|
|
|
|
+ const att = findZlRela(detailsAtt, im);
|
|
|
|
+ if (att) loadAtt(im, att);
|
|
}
|
|
}
|
|
|
|
|
|
function checkBwCustomDetail(im) {
|
|
function checkBwCustomDetail(im) {
|
|
- const cd = _.find(details, function (d) {
|
|
|
|
- return im.lid === d.lid &&
|
|
|
|
- (!im.code || im.code === d.code) &&
|
|
|
|
- (!im.name || im.name === d.name) &&
|
|
|
|
- (!im.unit || im.unit === d.unit) &&
|
|
|
|
- checkZero(ZhCalc.sub(im.unit_price, d.unit_price)) &&
|
|
|
|
- (!im.pid || im.pid === d.pid) &&
|
|
|
|
- (!im.pos_name || im.pos_name === d.pos_name);
|
|
|
|
- });
|
|
|
|
|
|
+ const cd = findBwRela(details, im);
|
|
if (cd) loadCustomDetail(im, cd);
|
|
if (cd) loadCustomDetail(im, cd);
|
|
|
|
+ const att = findBwRela(detailsAtt, im);
|
|
|
|
+ if (att) loadAtt(im, att);
|
|
}
|
|
}
|
|
|
|
|
|
function checkBbCustomDetail(im) {
|
|
function checkBbCustomDetail(im) {
|
|
- const cd = _.find(details, function (d) {
|
|
|
|
- return im.lid === d.lid &&
|
|
|
|
- (!im.name || im.name === d.name) &&
|
|
|
|
- (!im.unit || im.unit === d.unit) &&
|
|
|
|
- (!im.pid || im.pid === d.pid) &&
|
|
|
|
- (!im.pos_name || im.pos_name === d.pos_name);
|
|
|
|
- });
|
|
|
|
|
|
+ const cd = findBbRela(details, im);
|
|
if (cd) loadCustomDetail(im, cd);
|
|
if (cd) loadCustomDetail(im, cd);
|
|
|
|
+ const att = findBbRela(detailsAtt, im);
|
|
|
|
+ if (att) loadAtt(im, att);
|
|
}
|
|
}
|
|
|
|
|
|
function checkCustomDetail(im) {
|
|
function checkCustomDetail(im) {
|
|
@@ -1027,6 +1058,38 @@ const stageIm = (function () {
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
|
|
|
|
+ function loadUpdateDetailAtt (data) {
|
|
|
|
+ const datas = data instanceof Array ? data : [data];
|
|
|
|
+ for (const d of datas) {
|
|
|
|
+ const detail = _.find(detailsAtt, {uuid: d.uuid});
|
|
|
|
+ if (detail) {
|
|
|
|
+ _.assignInWith(detail, d, function (oV, sV) {
|
|
|
|
+ return !_.isUndefined(sV) ? sV : oV;
|
|
|
|
+ });
|
|
|
|
+ } else {
|
|
|
|
+ details.push(d);
|
|
|
|
+ }
|
|
|
|
+ let imData = _.find(ImData, {lid: d.lid, att_uuid: d.uuid});
|
|
|
|
+ if (!imData) {
|
|
|
|
+ switch (stage.im_type) {
|
|
|
|
+ case imType.tz.value:
|
|
|
|
+ imData = findTzRela(ImData, d);
|
|
|
|
+ break;
|
|
|
|
+ case imType.zl.value:
|
|
|
|
+ imData = findZlRela(ImData, d);
|
|
|
|
+ break;
|
|
|
|
+ case imType.bw.value:
|
|
|
|
+ imData = findBwRela(ImData, d);
|
|
|
|
+ break;
|
|
|
|
+ case imType.bb.value:
|
|
|
|
+ imData = findBbRela(ImData, d);
|
|
|
|
+ break;
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+ if (imData) loadAtt(imData, d);
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+
|
|
function loadUpdateLedgerData(data, refreshNodes) {
|
|
function loadUpdateLedgerData(data, refreshNodes) {
|
|
gsTree.loadPostStageData(data);
|
|
gsTree.loadPostStageData(data);
|
|
if (data.change) {
|
|
if (data.change) {
|
|
@@ -1115,6 +1178,7 @@ const stageIm = (function () {
|
|
loadData4Rela,
|
|
loadData4Rela,
|
|
buildImData,
|
|
buildImData,
|
|
loadUpdateDetailData,
|
|
loadUpdateDetailData,
|
|
|
|
+ loadUpdateDetailAtt,
|
|
loadUpdateLedgerData,
|
|
loadUpdateLedgerData,
|
|
loadUpdatePosData,
|
|
loadUpdatePosData,
|
|
loadUpdateChangeData,
|
|
loadUpdateChangeData,
|