|
@@ -68,20 +68,34 @@ 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);
|
|
|
- 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)));
|
|
|
- }
|
|
|
+ // 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(calcQty(xmj, l.is_join), l.quantity), getMpSpreadByMBData(l.mb_id)));
|
|
|
}
|
|
|
+ // }
|
|
|
}
|
|
|
return ZhCalc.round(jiacha, materialDecimal.tp);
|
|
|
}
|
|
|
|
|
|
+function calcQty(info, is_join) {
|
|
|
+ let qty = '';
|
|
|
+ switch (qtySource) {
|
|
|
+ case qtySourceValueConst.gather_qty: qty = info.gather_qty; break;
|
|
|
+ case qtySourceValueConst.contract_qty: qty = info.contract_qty; break;
|
|
|
+ case qtySourceValueConst.gather_minus_qty: qty = ZhCalc.add(info.gather_qty, info.qc_minus_qty); break;
|
|
|
+ default: throw '未配置计量来源出错';
|
|
|
+ }
|
|
|
+ if (qtySource !== qtySourceValueConst.contract_qty && is_join === 2) {
|
|
|
+ qty = ZhCalc.sub(qty, info.qc_qty);
|
|
|
+ }
|
|
|
+ return qty;
|
|
|
+}
|
|
|
+
|
|
|
function getPasteHint (str, row = '') {
|
|
|
let returnObj = str;
|
|
|
if (row) {
|
|
@@ -173,19 +187,19 @@ $(document).ready(() => {
|
|
|
{title: '单位', colSpan: '1', rowSpan: '2', field: 'unit', hAlign: 1, width: 80, formatter: '@'},
|
|
|
{title: '单价', colSpan: '1', rowSpan: '2', field: 'unit_price', hAlign: 2, width: 110, type: 'Number'},
|
|
|
];
|
|
|
- if (materialQtySource === 1) {
|
|
|
+ if (qtySource === qtySourceValueConst.gather_qty) {
|
|
|
ledgerCols.push({title: '本期计量数量|合同', colSpan: '3|1', rowSpan: '1|1', field: 'contract_qty', hAlign: 2, width: 110, type: 'Number'});
|
|
|
ledgerCols.push({title: '|数量变更', colSpan: '|1', rowSpan: '|1', field: 'qc_qty', hAlign: 2, width: 110, type: 'Number'});
|
|
|
ledgerCols.push({title: '|小计', colSpan: '|1', rowSpan: '|1', field: 'gather_qty', hAlign: 2, width: 110, type: 'Number'});
|
|
|
- } else if (materialQtySource === 2) {
|
|
|
+ } else if (qtySource === qtySourceValueConst.contract_qty) {
|
|
|
ledgerCols.push({title: '本期计量数量|合同', colSpan: '1|1', rowSpan: '1|1', field: 'contract_qty', hAlign: 2, width: 110, type: 'Number'});
|
|
|
- } else if (materialQtySource === 3) {
|
|
|
+ } else if (qtySource === qtySourceValueConst.gather_minus_qty) {
|
|
|
ledgerCols.push({title: '本期计量数量|合同', colSpan: '4|1', rowSpan: '1|1', field: 'contract_qty', hAlign: 2, width: 110, type: 'Number'});
|
|
|
ledgerCols.push({title: '|数量变更', colSpan: '|1', rowSpan: '|1', field: 'qc_qty', hAlign: 2, width: 110, type: 'Number'});
|
|
|
ledgerCols.push({title: '|不计价', colSpan: '|1', rowSpan: '|1', field: 'qc_minus_qty', hAlign: 2, width: 110, type: 'Number'});
|
|
|
ledgerCols.push({title: '|小计', colSpan: '|1', rowSpan: '|1', field: 'gather_qty', hAlign: 2, width: 110, type: 'Number', getValue: 'getValue.gather_qty'});
|
|
|
}
|
|
|
- ledgerCols.push({title: '本期完成金额', colSpan: '1', rowSpan: '2', field: 'gather_tp', hAlign: 2, width: 110, type: 'Number'});
|
|
|
+ ledgerCols.push({title: '本期完成金额', colSpan: '1', rowSpan: '2', field: 'gather_tp', hAlign: 2, width: 110, type: 'Number', getValue: 'getValue.gather_tp'});
|
|
|
ledgerCols.push({title: '本期价差', colSpan: '1', rowSpan: '2', field: 'total_jiacha', hAlign:3, width: 110, type: 'Number'});
|
|
|
const ledgerSpreadSetting = {
|
|
|
// cols: [
|
|
@@ -211,10 +225,17 @@ $(document).ready(() => {
|
|
|
const ledgerCol = {
|
|
|
getValue: {
|
|
|
gather_qty: function (data) {
|
|
|
- if (materialQtySource === 3) {
|
|
|
+ if (qtySource === qtySourceValueConst.gather_minus_qty) {
|
|
|
return ZhCalc.add(data.gather_qty, data.qc_minus_qty);
|
|
|
}
|
|
|
},
|
|
|
+ gather_tp: function (data) {
|
|
|
+ if (qtySource === qtySourceValueConst.contract_qty) {
|
|
|
+ return data.contract_tp;
|
|
|
+ } else {
|
|
|
+ return data.gather_tp;
|
|
|
+ }
|
|
|
+ },
|
|
|
}
|
|
|
}
|
|
|
ledgerSpreadSetting.cols = ledgerCols;
|
|
@@ -228,7 +249,7 @@ $(document).ready(() => {
|
|
|
gcl.leafXmjs[index].jiacha = jiacha !== 0 ? ZhCalc.round(jiacha, materialDecimal.tp) : null;
|
|
|
}
|
|
|
const leafXmjs = gcl.leafXmjs.filter(item => {
|
|
|
- return item.qc_qty || item.contract_qty
|
|
|
+ return item.qc_qty || item.contract_qty || item.qc_minus_qty;
|
|
|
});
|
|
|
console.log(leafXmjs);
|
|
|
SpreadJsObj.loadSheetData(leafXmjSpread.getActiveSheet(), SpreadJsObj.DataType.Data, leafXmjs);
|
|
@@ -255,13 +276,13 @@ $(document).ready(() => {
|
|
|
{title: '|分部工程', colSpan: '|1', rowSpan: '|1', field: 'fbgc', hAlign: 0, width: 100, formatter: '@'},
|
|
|
{title: '|分项工程', colSpan: '|1', rowSpan: '|1', field: 'fxgc', hAlign: 0, width: 180, formatter: '@'},
|
|
|
];
|
|
|
- if (materialQtySource === 1) {
|
|
|
+ if (qtySource === qtySourceValueConst.gather_qty) {
|
|
|
leafXmjCols.push({title: '本期计量数量|合同', colSpan: '3|1', rowSpan: '1|1', field: 'contract_qty', hAlign: 2, width: 60, type: 'Number'});
|
|
|
leafXmjCols.push({title: '|数量变更', colSpan: '|1', rowSpan: '|1', field: 'qc_qty', hAlign: 2, width: 60, type: 'Number'});
|
|
|
leafXmjCols.push({title: '|小计', colSpan: '|1', rowSpan: '|1', field: 'gather_qty', hAlign: 2, width: 60, type: 'Number'});
|
|
|
- } else if (materialQtySource === 2) {
|
|
|
+ } else if (qtySource === qtySourceValueConst.contract_qty) {
|
|
|
leafXmjCols.push({title: '本期计量数量|合同', colSpan: '1|1', rowSpan: '1|1', field: 'contract_qty', hAlign: 2, width: 100, type: 'Number'});
|
|
|
- } else if (materialQtySource === 3) {
|
|
|
+ } else if (qtySource === qtySourceValueConst.gather_minus_qty) {
|
|
|
leafXmjCols.push({title: '本期计量数量|合同', colSpan: '4|1', rowSpan: '1|1', field: 'contract_qty', hAlign: 2, width: 60, type: 'Number'});
|
|
|
leafXmjCols.push({title: '|数量变更', colSpan: '|1', rowSpan: '|1', field: 'qc_qty', hAlign: 2, width: 60, type: 'Number'});
|
|
|
leafXmjCols.push({title: '|不计价', colSpan: '|1', rowSpan: '|1', field: 'qc_minus_qty', hAlign: 2, width: 60, type: 'Number'});
|
|
@@ -310,7 +331,7 @@ $(document).ready(() => {
|
|
|
const leafXmjCol = {
|
|
|
getValue: {
|
|
|
gather_qty: function (data) {
|
|
|
- if (materialQtySource === 3) {
|
|
|
+ if (qtySource === qtySourceValueConst.gather_minus_qty) {
|
|
|
return ZhCalc.add(data.gather_qty, data.qc_minus_qty);
|
|
|
}
|
|
|
},
|
|
@@ -354,11 +375,13 @@ $(document).ready(() => {
|
|
|
updateBillsData(ms_id);
|
|
|
const newGclGatherListData = [];
|
|
|
for (const [index, s] of result.ledgerListData.entries()) {
|
|
|
+ // gclGatherModel.clearGatherData();
|
|
|
gclGatherModel.loadLedgerData(_.cloneDeep(ledger), s);
|
|
|
gclGatherModel.loadPosData(_.cloneDeep(pos), result.posListData[index]);
|
|
|
const oneGclGatherData = gclGatherModel.gatherGclData().filter(item => {
|
|
|
return item.qc_qty || item.contract_qty || item.qc_minus_qty
|
|
|
});
|
|
|
+ console.log(oneGclGatherData);
|
|
|
newGclGatherListData.push(oneGclGatherData);
|
|
|
}
|
|
|
gclGatherListData = newGclGatherListData;
|
|
@@ -835,7 +858,7 @@ $(document).ready(() => {
|
|
|
const color = notx === undefined ? '' : '#d6d8db';
|
|
|
// leafXmjSheet.getRange(iRow, -1, 1, -1).backColor(color);
|
|
|
const notx2 = findNotChangeLeafXmj(x);
|
|
|
- const color2 = notx2 === undefined ? color : '#FFE699';
|
|
|
+ const color2 = notx2 === undefined || qtySource === qtySourceValueConst.contract_qty ? color : '#FFE699';
|
|
|
leafXmjSheet.getRange(iRow, -1, 1, -1).backColor(color2);
|
|
|
}
|
|
|
}
|
|
@@ -893,7 +916,7 @@ $(document).ready(() => {
|
|
|
qc_qty: xmj.qc_qty,
|
|
|
qc_minus_qty: xmj.qc_minus_qty,
|
|
|
gather_qty: xmj.gather_qty,
|
|
|
- is_join: notx === undefined ? 1 : 0,
|
|
|
+ is_join: notx !== undefined ? 0 : notx2 !== undefined ? 2 : 1,
|
|
|
};
|
|
|
if (ms_id) data.ms_id = ms_id;
|
|
|
datas.push(data);
|
|
@@ -920,7 +943,7 @@ $(document).ready(() => {
|
|
|
qc_qty: xmj.qc_qty,
|
|
|
qc_minus_qty: xmj.qc_minus_qty,
|
|
|
gather_qty: xmj.gather_qty,
|
|
|
- is_join: notx === undefined ? 1 : 0,
|
|
|
+ is_join: notx !== undefined ? 0 : notx2 !== undefined ? 2 : 1,
|
|
|
ms_id: ms.id,
|
|
|
};
|
|
|
datas.push(data);
|
|
@@ -967,7 +990,7 @@ $(document).ready(() => {
|
|
|
qc_qty: xmj.qc_qty,
|
|
|
qc_minus_qty: xmj.qc_minus_qty,
|
|
|
gather_qty: xmj.gather_qty,
|
|
|
- is_join: notx === undefined ? 1 : 0,
|
|
|
+ is_join: notx !== undefined ? 0 : notx2 !== undefined ? 2 : 1,
|
|
|
};
|
|
|
console.log(data);
|
|
|
postData(window.location.pathname + '/save', {type: 'add', postData: data, ms_id: $('#myTab').find('.active').data('msid') || null }, function (result) {
|
|
@@ -1000,7 +1023,7 @@ $(document).ready(() => {
|
|
|
const data = {
|
|
|
type: type,
|
|
|
select: type === 'join' ? findNotJoinLeafXmj(select) : select,
|
|
|
- gather_qty: select.gather_qty,
|
|
|
+ // gather_qty: select.gather_qty,
|
|
|
ms_id: $('#myTab').find('.active').data('msid') || null,
|
|
|
};
|
|
|
// 添加到
|
|
@@ -1027,7 +1050,7 @@ $(document).ready(() => {
|
|
|
const data = {
|
|
|
type: type,
|
|
|
select: type === 'change' ? findNotChangeLeafXmj(select) : select,
|
|
|
- gather_qty: type === 'change' ? select.gather_qty : select.contract_qty,
|
|
|
+ // gather_qty: type === 'change' ? select.gather_qty : select.contract_qty,
|
|
|
ms_id: $('#myTab').find('.active').data('msid') || null,
|
|
|
};
|
|
|
// 添加到
|
|
@@ -1065,6 +1088,9 @@ $(document).ready(() => {
|
|
|
for (const [index, ms] of materialStageData.entries()) {
|
|
|
const gclOther = _.find(gclGatherListData[index], { b_code: gclData.b_code, name: gclData.name, unit: gclData.unit, unit_price: gclData.unit_price });
|
|
|
let gather_qty = null;
|
|
|
+ let contract_qty = null;
|
|
|
+ let qc_qty = null;
|
|
|
+ let qc_minus_qty = null;
|
|
|
if (gclOther) {
|
|
|
const leafXmjs = gclOther.leafXmjs.filter(item => {
|
|
|
return item.qc_qty || item.contract_qty || item.qc_minus_qty
|
|
@@ -1072,12 +1098,23 @@ $(document).ready(() => {
|
|
|
const oneXmj = _.find(leafXmjs, function (item) {
|
|
|
return item.gcl_id === select.gcl_id && item.id === select.id && (select.mx_id === undefined || item.mx_id === select.mx_id);
|
|
|
});
|
|
|
- if (oneXmj) gather_qty = oneXmj.gather_qty;
|
|
|
+ if (oneXmj) {
|
|
|
+ gather_qty = oneXmj.gather_qty;
|
|
|
+ contract_qty = oneXmj.contract_qty;
|
|
|
+ qc_qty = oneXmj.qc_qty;
|
|
|
+ qc_minus_qty = oneXmj.qc_minus_qty ? oneXmj.qc_minus_qty : null;
|
|
|
+ }
|
|
|
}
|
|
|
data.select.gather_qty['ms_id_' + ms.id] = gather_qty;
|
|
|
+ data.select.contract_qty['ms_id_' + ms.id] = contract_qty;
|
|
|
+ data.select.qc_qty['ms_id_' + ms.id] = qc_qty;
|
|
|
+ data.select.qc_minus_qty['ms_id_' + ms.id] = qc_minus_qty;
|
|
|
}
|
|
|
} else {
|
|
|
data.select.gather_qty = select.gather_qty ? select.gather_qty : null;
|
|
|
+ data.select.contract_qty = select.contract_qty ? select.contract_qty : null;
|
|
|
+ data.select.qc_qty = select.qc_qty ? select.qc_qty : null;
|
|
|
+ data.select.qc_minus_qty = select.qc_minus_qty ? select.qc_minus_qty : null;
|
|
|
}
|
|
|
}
|
|
|
console.log(data);
|
|
@@ -1166,12 +1203,15 @@ $(document).ready(() => {
|
|
|
if (!select || sel.rowCount !== 1) {
|
|
|
return false;
|
|
|
}
|
|
|
+ if (qtySource === qtySourceValueConst.contract_qty) {
|
|
|
+ return false;
|
|
|
+ }
|
|
|
const notx = findNotJoinLeafXmj(select);
|
|
|
if (!(!readOnly && select && notx === undefined)) {
|
|
|
return false;
|
|
|
}
|
|
|
const notx2 = findNotChangeLeafXmj(select);
|
|
|
- if (!readOnly && select && notx2 === undefined && materialQtySource !== qtySourceValueConst.contract_qty) {
|
|
|
+ if (!readOnly && select && notx2 === undefined) {
|
|
|
return true;
|
|
|
} else {
|
|
|
return false;
|
|
@@ -1191,6 +1231,9 @@ $(document).ready(() => {
|
|
|
if (!select || sel.rowCount !== 1) {
|
|
|
return false;
|
|
|
}
|
|
|
+ if (qtySource === qtySourceValueConst.contract_qty) {
|
|
|
+ return false;
|
|
|
+ }
|
|
|
const notx = findNotJoinLeafXmj(select);
|
|
|
if (!(!readOnly && select && notx === undefined)) {
|
|
|
return false;
|