|
@@ -23,6 +23,17 @@ function findNotJoinLeafXmj(x, type = '') {
|
|
|
});
|
|
|
}
|
|
|
|
|
|
+function findNotChangeLeafXmj(x, type = '') {
|
|
|
+ if (type === 'index') {
|
|
|
+ return notChangeList.findIndex(function (item) {
|
|
|
+ return item.gcl_id === x.gcl_id && item.xmj_id === x.id && (x.mx_id === undefined || (x.mx_id !== undefined && x.mx_id === item.mx_id));
|
|
|
+ });
|
|
|
+ }
|
|
|
+ return notChangeList.find(function (item) {
|
|
|
+ return item.gcl_id === x.gcl_id && item.xmj_id === x.id && (x.mx_id === undefined || (x.mx_id !== undefined && x.mx_id === item.mx_id));
|
|
|
+ });
|
|
|
+}
|
|
|
+
|
|
|
function findSelfLeafXmj(x, type = '') {
|
|
|
if (type === 'index') {
|
|
|
return selfList.findIndex(function (item) {
|
|
@@ -57,8 +68,15 @@ function calcOneBQJC(xmj) {
|
|
|
const notx = findNotJoinLeafXmj(xmj);
|
|
|
if (notx === undefined) {
|
|
|
const list = xmj.mx_id !== undefined ? getMaterialListByLeafXmj(xmj.gcl_id, xmj.id, xmj.mx_id) : getMaterialListByLeafXmj(xmj.gcl_id, xmj.id);
|
|
|
- for (const l of list) {
|
|
|
- jiacha = ZhCalc.add(jiacha, ZhCalc.mul(ZhCalc.mul(xmj.gather_qty, l.quantity), getMpSpreadByMBData(l.mb_id)));
|
|
|
+ const notx2 = findNotChangeLeafXmj(xmj);
|
|
|
+ if (notx2 !== undefined) {
|
|
|
+ for (const l of list) {
|
|
|
+ jiacha = ZhCalc.add(jiacha, ZhCalc.mul(ZhCalc.mul(xmj.contract_qty, l.quantity), getMpSpreadByMBData(l.mb_id)));
|
|
|
+ }
|
|
|
+ } else {
|
|
|
+ for (const l of list) {
|
|
|
+ jiacha = ZhCalc.add(jiacha, ZhCalc.mul(ZhCalc.mul(xmj.gather_qty, l.quantity), getMpSpreadByMBData(l.mb_id)));
|
|
|
+ }
|
|
|
}
|
|
|
}
|
|
|
return ZhCalc.round(jiacha, materialDecimal.tp);
|
|
@@ -264,6 +282,7 @@ $(document).ready(() => {
|
|
|
materialListData = result.materialListData;
|
|
|
gclList = result.gclList;
|
|
|
notJoinList = result.materialNotJoinListData;
|
|
|
+ notChangeList = result.materialNotChangeListData;
|
|
|
selfList = result.materialSelfListData;
|
|
|
materialChecklistData = result.materialChecklistData;
|
|
|
if (isStageSelf) {
|
|
@@ -473,8 +492,8 @@ $(document).ready(() => {
|
|
|
selfSheet.suspendPaint();
|
|
|
selfSheet.setCellType(1, 3, new TipCellType(), spreadNS.SheetArea.colHeader);
|
|
|
selfSheet.resumePaint();
|
|
|
- checkNotJoinMaterialData();
|
|
|
ledgerSpread.getActiveSheet().setSelection(0, 0, 1, 1);
|
|
|
+ checkNotJoinMaterialData();
|
|
|
}
|
|
|
}
|
|
|
|
|
@@ -684,7 +703,7 @@ $(document).ready(() => {
|
|
|
// sheet.suspendPaint();
|
|
|
// sheet.setCellType(1, 3, new TipCellType(), spreadNS.SheetArea.colHeader);
|
|
|
// sheet.resumePaint();
|
|
|
- // 不参与调差数据值变灰
|
|
|
+ // 不参与调差数据值变灰, 数量变更不参与调差数据值变黄
|
|
|
function checkNotJoinMaterialData() {
|
|
|
const sheet = ledgerSpread.getActiveSheet();
|
|
|
const select = SpreadJsObj.getSelectObject(sheet);
|
|
@@ -698,6 +717,9 @@ $(document).ready(() => {
|
|
|
const notx = findNotJoinLeafXmj(x);
|
|
|
const color = notx === undefined ? '' : '#d6d8db';
|
|
|
leafXmjSheet.getRange(iRow, -1, 1, -1).backColor(color);
|
|
|
+ const notx2 = findNotChangeLeafXmj(x);
|
|
|
+ const color2 = notx2 === undefined ? '' : '#FFE699';
|
|
|
+ leafXmjSheet.getRange(iRow, -1, 1, -1).backColor(color2);
|
|
|
}
|
|
|
}
|
|
|
}
|
|
@@ -745,11 +767,12 @@ $(document).ready(() => {
|
|
|
const datas = [];
|
|
|
for (const xmj of gcl) {
|
|
|
const notx = findNotJoinLeafXmj(xmj);
|
|
|
+ const notx2 = findNotChangeLeafXmj(xmj);
|
|
|
const data = {
|
|
|
xmj_id: xmj.id,
|
|
|
gcl_id: xmj.gcl_id,
|
|
|
mx_id: xmj.mx_id ? xmj.mx_id : '',
|
|
|
- gather_qty: xmj.gather_qty,
|
|
|
+ gather_qty: notx2 === undefined ? xmj.gather_qty : xmj.contract_qty,
|
|
|
is_join: notx === undefined ? 1 : 0,
|
|
|
};
|
|
|
if (ms_id) data.ms_id = ms_id;
|
|
@@ -765,11 +788,12 @@ $(document).ready(() => {
|
|
|
const leafXmjs = gclOther.leafXmjs.filter(item => item.gather_qty !== null && item.gather_qty !== undefined);
|
|
|
for (const xmj of leafXmjs) {
|
|
|
const notx = findNotJoinLeafXmj(xmj);
|
|
|
+ const notx2 = findNotChangeLeafXmj(xmj);
|
|
|
const data = {
|
|
|
xmj_id: xmj.id,
|
|
|
gcl_id: xmj.gcl_id,
|
|
|
mx_id: xmj.mx_id ? xmj.mx_id : '',
|
|
|
- gather_qty: xmj.gather_qty,
|
|
|
+ gather_qty: notx2 === undefined ? xmj.gather_qty : xmj.contract_qty,
|
|
|
is_join: notx === undefined ? 1 : 0,
|
|
|
ms_id: ms.id,
|
|
|
};
|
|
@@ -805,12 +829,13 @@ $(document).ready(() => {
|
|
|
const leafXmjIndex = gcl.indexOf(leafXmjSelect);
|
|
|
const xmj = gcl[leafXmjIndex];
|
|
|
const notx = findNotJoinLeafXmj(xmj);
|
|
|
+ const notx2 = findNotChangeLeafXmj(xmj);
|
|
|
const data = {
|
|
|
xmj_id: xmj.id,
|
|
|
gcl_id: xmj.gcl_id,
|
|
|
mx_id: xmj.mx_id ? xmj.mx_id : '',
|
|
|
mb_id: mb_id,
|
|
|
- gather_qty: xmj.gather_qty,
|
|
|
+ gather_qty: notx2 === undefined ? xmj.gather_qty : xmj.contract_qty,
|
|
|
is_join: notx === undefined ? 1 : 0,
|
|
|
};
|
|
|
console.log(data);
|
|
@@ -844,6 +869,7 @@ $(document).ready(() => {
|
|
|
const data = {
|
|
|
type: type,
|
|
|
select: type === 'join' ? findNotJoinLeafXmj(select) : select,
|
|
|
+ gather_qty: select.gather_qty,
|
|
|
ms_id: $('#myTab').find('.active').data('msid') || null,
|
|
|
};
|
|
|
// 添加到
|
|
@@ -853,6 +879,33 @@ $(document).ready(() => {
|
|
|
notJoinList.splice(index, 1);
|
|
|
} else {
|
|
|
notJoinList.push(result);
|
|
|
+ const index = findNotChangeLeafXmj(select, 'index');
|
|
|
+ notChangeList.splice(index, 1);
|
|
|
+ }
|
|
|
+ gclGatherData[iGclRow].leafXmjs[iRow].jiacha = calcOneBQJC(select);
|
|
|
+ calculateJiaCha(gclGatherData, iGclRow);
|
|
|
+ SpreadJsObj.reLoadRowData(sheet, nRow);
|
|
|
+ sheet.getRange(nRow, -1, 1, -1).backColor(color);
|
|
|
+ loadMaterialData(iGclRow);
|
|
|
+ SpreadJsObj.reLoadRowData(ledgerSpread.getActiveSheet(), iGclRow);
|
|
|
+ });
|
|
|
+ },
|
|
|
+ checkChangeMaterial: function (type) {
|
|
|
+ const [iGclRow, iRow, nRow, sheet, select] = leafXmjSpreadObj.getSelect();
|
|
|
+ const color = type === 'change' ? '' : '#FFE699';
|
|
|
+ const data = {
|
|
|
+ type: type,
|
|
|
+ select: type === 'change' ? findNotChangeLeafXmj(select) : select,
|
|
|
+ gather_qty: type === 'change' ? select.gather_qty : select.contract_qty,
|
|
|
+ ms_id: $('#myTab').find('.active').data('msid') || null,
|
|
|
+ };
|
|
|
+ // 添加到
|
|
|
+ postData(window.location.pathname + '/save', data, function (result) {
|
|
|
+ if (type === 'change') {
|
|
|
+ const index = findNotChangeLeafXmj(select, 'index');
|
|
|
+ notChangeList.splice(index, 1);
|
|
|
+ } else {
|
|
|
+ notChangeList.push(result);
|
|
|
}
|
|
|
gclGatherData[iGclRow].leafXmjs[iRow].jiacha = calcOneBQJC(select);
|
|
|
calculateJiaCha(gclGatherData, iGclRow);
|
|
@@ -926,7 +979,7 @@ $(document).ready(() => {
|
|
|
},
|
|
|
items: {
|
|
|
'stop': {
|
|
|
- name: '不参与调差',
|
|
|
+ name: '当前节点不参与调差',
|
|
|
icon: 'fa-remove',
|
|
|
callback: function (key, opt) {
|
|
|
leafXmjSpreadObj.checkJoinMaterial('notjoin');
|
|
@@ -947,7 +1000,7 @@ $(document).ready(() => {
|
|
|
}
|
|
|
},
|
|
|
'start': {
|
|
|
- name: '参与调差',
|
|
|
+ name: '当前节点参与调差',
|
|
|
icon: 'fa-sign-in',
|
|
|
callback: function (key, opt) {
|
|
|
leafXmjSpreadObj.checkJoinMaterial('join');
|
|
@@ -967,6 +1020,56 @@ $(document).ready(() => {
|
|
|
}
|
|
|
},
|
|
|
},
|
|
|
+ 'stop2': {
|
|
|
+ name: '数量变更不参与调差',
|
|
|
+ icon: 'fa-remove',
|
|
|
+ callback: function (key, opt) {
|
|
|
+ leafXmjSpreadObj.checkChangeMaterial('notchange');
|
|
|
+ },
|
|
|
+ visible: function (key, opt) {
|
|
|
+ const sheet = leafXmjSpread.getActiveSheet();
|
|
|
+ const select = SpreadJsObj.getSelectObject(sheet);
|
|
|
+ const sel = sheet.getSelections()[0];
|
|
|
+ if (!select || sel.rowCount !== 1) {
|
|
|
+ return false;
|
|
|
+ }
|
|
|
+ const notx = findNotJoinLeafXmj(select);
|
|
|
+ if (!(!readOnly && select && notx === undefined)) {
|
|
|
+ return false;
|
|
|
+ }
|
|
|
+ const notx2 = findNotChangeLeafXmj(select);
|
|
|
+ if (!readOnly && select && notx2 === undefined) {
|
|
|
+ return true;
|
|
|
+ } else {
|
|
|
+ return false;
|
|
|
+ }
|
|
|
+ }
|
|
|
+ },
|
|
|
+ 'start2': {
|
|
|
+ name: '数量变更参与调差',
|
|
|
+ icon: 'fa-sign-in',
|
|
|
+ callback: function (key, opt) {
|
|
|
+ leafXmjSpreadObj.checkChangeMaterial('change');
|
|
|
+ },
|
|
|
+ visible: function (key, opt) {
|
|
|
+ const sheet = leafXmjSpread.getActiveSheet();
|
|
|
+ const select = SpreadJsObj.getSelectObject(sheet);
|
|
|
+ const sel = sheet.getSelections()[0];
|
|
|
+ if (!select || sel.rowCount !== 1) {
|
|
|
+ return false;
|
|
|
+ }
|
|
|
+ const notx = findNotJoinLeafXmj(select);
|
|
|
+ if (!(!readOnly && select && notx === undefined)) {
|
|
|
+ return false;
|
|
|
+ }
|
|
|
+ const notx2 = findNotChangeLeafXmj(select);
|
|
|
+ if (!readOnly && select && notx2 === undefined) {
|
|
|
+ return false;
|
|
|
+ } else {
|
|
|
+ return true;
|
|
|
+ }
|
|
|
+ },
|
|
|
+ },
|
|
|
'self': {
|
|
|
name: '单独添加工料',
|
|
|
icon: 'fa-sign-in',
|