|
|
@@ -120,33 +120,6 @@ function getPasteHint (str, row = '') {
|
|
|
return returnObj;
|
|
|
}
|
|
|
|
|
|
-// 重新计算列表的价差
|
|
|
-function calculateJiaCha(data, index) {
|
|
|
- // 计算单条的
|
|
|
- if (index) {
|
|
|
- const gcld = data[index]
|
|
|
- let total_jiacha = 0;
|
|
|
- for (const [index, xmj] of gcld.leafXmjs.entries()) {
|
|
|
- const jiacha = calcOneBQJC(xmj);
|
|
|
- gcld.leafXmjs[index].jiacha = jiacha !== 0 ? jiacha : null;
|
|
|
- gcld.leafXmjs[index].qty = getOneQtyByLeafXmj(xmj);
|
|
|
- total_jiacha += jiacha;
|
|
|
- }
|
|
|
- gcld.total_jiacha = ZhCalc.round(total_jiacha, materialDecimal.tp)
|
|
|
- } else {
|
|
|
- for(const gcld of data) {
|
|
|
- let total_jiacha = 0;
|
|
|
- for (const [index, xmj] of gcld.leafXmjs.entries()) {
|
|
|
- const jiacha = calcOneBQJC(xmj);
|
|
|
- gcld.leafXmjs[index].jiacha = jiacha !== 0 ? jiacha : null;
|
|
|
- gcld.leafXmjs[index].qty = getOneQtyByLeafXmj(xmj);
|
|
|
- total_jiacha += jiacha;
|
|
|
- }
|
|
|
- gcld.total_jiacha = ZhCalc.round(total_jiacha, materialDecimal.tp)
|
|
|
- }
|
|
|
- }
|
|
|
-}
|
|
|
-
|
|
|
const is_numeric = (value) => {
|
|
|
if (typeof(value) === 'object') {
|
|
|
return false;
|
|
|
@@ -217,6 +190,7 @@ $(document).ready(() => {
|
|
|
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: 'total_qty', 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 = {
|
|
|
@@ -257,6 +231,64 @@ $(document).ready(() => {
|
|
|
}
|
|
|
}
|
|
|
ledgerSpreadSetting.cols = ledgerCols;
|
|
|
+ const totalQtyColIndex = _.findIndex(ledgerCols, {field: 'total_qty'});
|
|
|
+ // 重新计算列表的价差
|
|
|
+ function calculateJiaCha(data, index) {
|
|
|
+ // 计算单条的
|
|
|
+ if (index) {
|
|
|
+ const gcld = data[index]
|
|
|
+ let total_jiacha = 0;
|
|
|
+ let total_qty = 0;
|
|
|
+ let edit_qty = false;
|
|
|
+ for (const [index, xmj] of gcld.leafXmjs.entries()) {
|
|
|
+ const jiacha = calcOneBQJC(xmj);
|
|
|
+ gcld.leafXmjs[index].jiacha = jiacha !== 0 ? jiacha : null;
|
|
|
+ gcld.leafXmjs[index].qty = getOneQtyByLeafXmj(xmj);
|
|
|
+ total_jiacha += jiacha;
|
|
|
+ total_qty = ZhCalc.add(total_qty, gcld.leafXmjs[index].qty);
|
|
|
+ if (findQtyLeafXmj(xmj)) {
|
|
|
+ edit_qty = true;
|
|
|
+ }
|
|
|
+ }
|
|
|
+ gcld.total_jiacha = ZhCalc.round(total_jiacha, materialDecimal.tp);
|
|
|
+ gcld.total_qty = ZhCalc.round(total_qty, materialDecimal.qty);
|
|
|
+ gcld.edit_qty = edit_qty;
|
|
|
+ } else {
|
|
|
+ if (!data || data.length === 0) {
|
|
|
+ return;
|
|
|
+ }
|
|
|
+ for(const [row, gcld] of data.entries()) {
|
|
|
+ let total_jiacha = 0;
|
|
|
+ let total_qty = 0;
|
|
|
+ let edit_qty = false;
|
|
|
+ for (const [index, xmj] of gcld.leafXmjs.entries()) {
|
|
|
+ const jiacha = calcOneBQJC(xmj);
|
|
|
+ gcld.leafXmjs[index].jiacha = jiacha !== 0 ? jiacha : null;
|
|
|
+ gcld.leafXmjs[index].qty = getOneQtyByLeafXmj(xmj);
|
|
|
+ total_jiacha += jiacha;
|
|
|
+ total_qty = ZhCalc.add(total_qty, gcld.leafXmjs[index].qty);
|
|
|
+ if (findQtyLeafXmj(xmj)) {
|
|
|
+ edit_qty = true;
|
|
|
+ }
|
|
|
+ }
|
|
|
+ gcld.total_jiacha = ZhCalc.round(total_jiacha, materialDecimal.tp);
|
|
|
+ gcld.total_qty = ZhCalc.round(total_qty, materialDecimal.qty);
|
|
|
+ gcld.edit_qty = edit_qty;
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ function refreshTotalQtyColor(datas, row = null) {
|
|
|
+ const ledgerSheet = ledgerSpread.getActiveSheet();
|
|
|
+ console.log(datas);
|
|
|
+ if (row !== null && datas && datas.edit_qty) {
|
|
|
+ ledgerSheet.getCell(row, totalQtyColIndex).backColor('#f8d7da');
|
|
|
+ } else if (row === null && datas && datas.length > 0) {
|
|
|
+ for (const [gcldIndex, gcld] of datas.entries()) {
|
|
|
+ if (gcld.edit_qty) ledgerSheet.getCell(gcldIndex, totalQtyColIndex).backColor('#f8d7da');
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
// let gclGatherData = gclGatherModel.gatherGclData()
|
|
|
// 获取项目节数据
|
|
|
function loadLeafXmjData(iGclRow) {
|
|
|
@@ -530,10 +562,12 @@ $(document).ready(() => {
|
|
|
});
|
|
|
}
|
|
|
calculateJiaCha(gclGatherData);
|
|
|
+ console.log(gclGatherData);
|
|
|
SpreadJsObj.initSpreadSettingEvents(leafXmjSpreadSetting, leafXmjCol);
|
|
|
SpreadJsObj.initSheet(leafXmjSpread.getActiveSheet(), leafXmjSpreadSetting);
|
|
|
// 加载清单数据
|
|
|
SpreadJsObj.loadSheetData(ledgerSpread.getActiveSheet(), SpreadJsObj.DataType.Data, gclGatherData);
|
|
|
+ refreshTotalQtyColor(gclGatherData);
|
|
|
loadLeafXmjData(0);
|
|
|
loadMaterialData(0);
|
|
|
loadXmjMaterialData(0, 0);
|
|
|
@@ -656,6 +690,7 @@ $(document).ready(() => {
|
|
|
SpreadJsObj.initSheet(leafXmjSpread.getActiveSheet(), leafXmjSpreadSetting);
|
|
|
// 加载清单数据
|
|
|
SpreadJsObj.loadSheetData(ledgerSpread.getActiveSheet(), SpreadJsObj.DataType.Data, gclGatherData);
|
|
|
+ refreshTotalQtyColor(gclGatherData);
|
|
|
loadLeafXmjData(0);
|
|
|
loadMaterialData(0);
|
|
|
loadXmjMaterialData(0, 0);
|
|
|
@@ -668,6 +703,7 @@ $(document).ready(() => {
|
|
|
selfSheet.setCellType(1, 3, new TipCellType(), spreadNS.SheetArea.colHeader);
|
|
|
selfSheet.resumePaint();
|
|
|
ledgerSpread.getActiveSheet().setSelection(0, 0, 1, 1);
|
|
|
+
|
|
|
checkNotJoinMaterialData();
|
|
|
}
|
|
|
}
|
|
|
@@ -1008,6 +1044,7 @@ $(document).ready(() => {
|
|
|
// const xmjIndex = gclGatherData[index].leafXmjs.indexOf(xmjSelect);
|
|
|
loadMaterialData(index);
|
|
|
SpreadJsObj.reLoadRowData(ledgerSpread.getActiveSheet(), index);
|
|
|
+ refreshTotalQtyColor(gclGatherData[index], index);
|
|
|
$('#addgl').modal('hide');
|
|
|
});
|
|
|
} else if (type === 'self') {
|
|
|
@@ -1087,6 +1124,7 @@ $(document).ready(() => {
|
|
|
leafXmjSpreadObj.refreshQtyColor(select, nRow);
|
|
|
loadMaterialData(iGclRow);
|
|
|
SpreadJsObj.reLoadRowData(ledgerSpread.getActiveSheet(), iGclRow);
|
|
|
+ refreshTotalQtyColor(gclGatherData[iGclRow], iGclRow);
|
|
|
});
|
|
|
},
|
|
|
checkChangeMaterial: function (type) {
|
|
|
@@ -1114,6 +1152,7 @@ $(document).ready(() => {
|
|
|
leafXmjSpreadObj.refreshQtyColor(select, nRow);
|
|
|
loadMaterialData(iGclRow);
|
|
|
SpreadJsObj.reLoadRowData(ledgerSpread.getActiveSheet(), iGclRow);
|
|
|
+ refreshTotalQtyColor(gclGatherData[iGclRow], iGclRow);
|
|
|
});
|
|
|
},
|
|
|
checkSelfMaterial: function (type) {
|
|
|
@@ -1187,6 +1226,7 @@ $(document).ready(() => {
|
|
|
leafXmjSpreadObj.refreshQtyColor(select, nRow);
|
|
|
loadXmjMaterialData(iGclRow, nRow);
|
|
|
SpreadJsObj.reLoadRowData(ledgerSpread.getActiveSheet(), iGclRow);
|
|
|
+ refreshTotalQtyColor(gclGatherData[iGclRow], iGclRow);
|
|
|
});
|
|
|
},
|
|
|
refreshQtyColor(xmj, row) {
|
|
|
@@ -1209,11 +1249,13 @@ $(document).ready(() => {
|
|
|
const orgValue = select[col.field];
|
|
|
if (orgValue == validText || ((orgValue === '' || orgValue === null) && (validText === '' || validText === null))) {
|
|
|
SpreadJsObj.reLoadRowData(info.sheet, info.row);
|
|
|
+ leafXmjSpreadObj.refreshQtyColor(select, nRow);
|
|
|
return;
|
|
|
}
|
|
|
if (isNaN(validText)) {
|
|
|
toastr.error('不能输入其它非数字类型字符');
|
|
|
SpreadJsObj.reLoadRowData(info.sheet, info.row);
|
|
|
+ leafXmjSpreadObj.refreshQtyColor(select, nRow);
|
|
|
return;
|
|
|
}
|
|
|
const qty = parseFloat(validText) !== 0 ? ZhCalc.round(parseFloat(validText), materialDecimal.qty) : 0;
|
|
|
@@ -1253,8 +1295,10 @@ $(document).ready(() => {
|
|
|
leafXmjSpreadObj.refreshQtyColor(select, nRow);
|
|
|
loadXmjMaterialData(iGclRow, nRow);
|
|
|
SpreadJsObj.reLoadRowData(ledgerSpread.getActiveSheet(), iGclRow);
|
|
|
+ refreshTotalQtyColor(gclGatherData[iGclRow], iGclRow);
|
|
|
}, function () {
|
|
|
SpreadJsObj.reLoadRowData(info.sheet, info.row);
|
|
|
+ leafXmjSpreadObj.refreshQtyColor(select, nRow);
|
|
|
});
|
|
|
return;
|
|
|
}
|
|
|
@@ -1333,6 +1377,7 @@ $(document).ready(() => {
|
|
|
loadMaterialData(index);
|
|
|
checkNotJoinMaterialData();
|
|
|
SpreadJsObj.reLoadRowData(ledgerSpread.getActiveSheet(), index);
|
|
|
+ refreshTotalQtyColor(gclGatherData[index], index);
|
|
|
// leafXmjSpread.getActiveSheet().setSelection(info.cellRange.row, info.cellRange.col, info.cellRange.rowCount, info.cellRange.colCount);
|
|
|
}, function () {
|
|
|
SpreadJsObj.reLoadRowData(info.sheet, info.row);
|
|
|
@@ -1373,6 +1418,7 @@ $(document).ready(() => {
|
|
|
loadMaterialData(index);
|
|
|
checkNotJoinMaterialData();
|
|
|
SpreadJsObj.reLoadRowData(ledgerSpread.getActiveSheet(), index);
|
|
|
+ refreshTotalQtyColor(gclGatherData[index], index);
|
|
|
}, function () {
|
|
|
SpreadJsObj.reLoadRowData(info.sheet, info.row);
|
|
|
});
|
|
|
@@ -1393,11 +1439,15 @@ $(document).ready(() => {
|
|
|
$.contextMenu({
|
|
|
selector: '#leaf-xmj-spread',
|
|
|
build: function ($trigger, e) {
|
|
|
+ const oldSelections = SpreadJsObj.getSelectObject(leafXmjSpread.getActiveSheet());
|
|
|
+ const selections = leafXmjSpread.getActiveSheet().getSelections();
|
|
|
+ const oldRow = selections && selections.length > 0 ? selections[0].row : null;
|
|
|
const target = SpreadJsObj.safeRightClickSelection($trigger, e, leafXmjSpread);
|
|
|
const sheet = ledgerSpread.getActiveSheet();
|
|
|
const select = SpreadJsObj.getSelectObject(sheet);
|
|
|
const index = gclGatherData.indexOf(select);
|
|
|
const xmj = target.row !== undefined ? gclGatherData[index].leafXmjs[target.row] : null;
|
|
|
+ if (oldSelections && oldRow !== null) leafXmjSpreadObj.refreshQtyColor(oldSelections, oldRow);
|
|
|
if (xmj) leafXmjSpreadObj.refreshQtyColor(xmj, target.row);
|
|
|
return target.hitTestType === GC.Spread.Sheets.SheetArea.viewport || target.hitTestType === GC.Spread.Sheets.SheetArea.rowHeader;
|
|
|
},
|
|
|
@@ -1645,6 +1695,7 @@ $(document).ready(() => {
|
|
|
// const xmjIndex = gclGatherData[index].leafXmjs.indexOf(xmjSelect);
|
|
|
loadMaterialData(index);
|
|
|
SpreadJsObj.reLoadRowData(ledgerSpread.getActiveSheet(), index);
|
|
|
+ refreshTotalQtyColor(gclGatherData[index], index);
|
|
|
});
|
|
|
// postData(window.location.pathname + '/save', {type: 'del', id: select.id, mb_id: select.mb_id}, function (result) {
|
|
|
// const index = materialList.indexOf(select);
|
|
|
@@ -1772,6 +1823,7 @@ $(document).ready(() => {
|
|
|
// const xmjIndex = gclGatherData[index].leafXmjs.indexOf(xmjSelect);
|
|
|
loadMaterialData(index);
|
|
|
SpreadJsObj.reLoadRowData(ledgerSpread.getActiveSheet(), index);
|
|
|
+ refreshTotalQtyColor(gclGatherData[index], index);
|
|
|
materialSpread.getActiveSheet().setSelection(info.row + 1, info.col, 1, 1);
|
|
|
}, function () {
|
|
|
SpreadJsObj.reLoadRowData(info.sheet, info.row);
|
|
|
@@ -1927,6 +1979,7 @@ $(document).ready(() => {
|
|
|
// const xmjIndex = gclGatherData[index].leafXmjs.indexOf(xmjSelect);
|
|
|
loadMaterialData(index);
|
|
|
SpreadJsObj.reLoadRowData(ledgerSpread.getActiveSheet(), index);
|
|
|
+ refreshTotalQtyColor(gclGatherData[index], index);
|
|
|
materialSpread.getActiveSheet().setSelection(info.cellRange.row, info.cellRange.col, info.cellRange.rowCount, info.cellRange.colCount);
|
|
|
}, function () {
|
|
|
SpreadJsObj.reLoadRowData(info.sheet, info.row);
|
|
|
@@ -2100,6 +2153,7 @@ $(document).ready(() => {
|
|
|
lsheet.getRange(nRow, -1, 1, -1).backColor(color);
|
|
|
leafXmjSpreadObj.refreshQtyColor(lselect, nRow);
|
|
|
SpreadJsObj.reLoadRowData(ledgerSpread.getActiveSheet(), iGclRow);
|
|
|
+ refreshTotalQtyColor(gclGatherData[iGclRow], iGclRow);
|
|
|
});
|
|
|
},
|
|
|
deletePress: function (sheet) {
|
|
|
@@ -2185,6 +2239,7 @@ $(document).ready(() => {
|
|
|
sheet.getRange(nRow, -1, 1, -1).backColor(color);
|
|
|
leafXmjSpreadObj.refreshQtyColor(lselect, nRow);
|
|
|
SpreadJsObj.reLoadRowData(ledgerSpread.getActiveSheet(), iGclRow);
|
|
|
+ refreshTotalQtyColor(gclGatherData[iGclRow], iGclRow);
|
|
|
}, function () {
|
|
|
SpreadJsObj.reLoadRowData(info.sheet, info.row);
|
|
|
});
|
|
|
@@ -2282,6 +2337,7 @@ $(document).ready(() => {
|
|
|
calculateJiaCha(gclGatherData, iGclRow);
|
|
|
SpreadJsObj.reLoadRowData(sheet, nRow);
|
|
|
SpreadJsObj.reLoadRowData(ledgerSpread.getActiveSheet(), iGclRow);
|
|
|
+ refreshTotalQtyColor(gclGatherData[iGclRow], iGclRow);
|
|
|
loadXmjMaterialData(iGclRow, nRow);
|
|
|
}, function () {
|
|
|
SpreadJsObj.reLoadRowData(info.sheet, info.cellRange.row, info.cellRange.rowCount);
|
|
|
@@ -2441,6 +2497,7 @@ $(document).ready(() => {
|
|
|
// const xmjIndex = gclGatherData[index].leafXmjs.indexOf(xmjSelect);
|
|
|
loadMaterialData(index);
|
|
|
SpreadJsObj.reLoadRowData(ledgerSpread.getActiveSheet(), index);
|
|
|
+ refreshTotalQtyColor(gclGatherData[index], index);
|
|
|
});
|
|
|
});
|
|
|
|
|
|
@@ -2514,6 +2571,7 @@ $(document).ready(() => {
|
|
|
}
|
|
|
calculateJiaCha(gclGatherData);
|
|
|
SpreadJsObj.loadSheetData(ledgerSpread.getActiveSheet(), SpreadJsObj.DataType.Data, gclGatherData);
|
|
|
+ refreshTotalQtyColor(gclGatherData);
|
|
|
loadLeafXmjData(0);
|
|
|
loadMaterialData(0);
|
|
|
loadXmjMaterialData(0, 0);
|