|
@@ -78,6 +78,27 @@ const budgetSummaryObj = (() => {
|
|
|
await ajaxPost('/bills/bulkOperation', { bulkData });
|
|
|
};
|
|
|
|
|
|
+ // 计算节点
|
|
|
+ const calcNodes = async (sheet, nodes) => {
|
|
|
+ try {
|
|
|
+ $.bootstrapLoading.start();
|
|
|
+ debugger;
|
|
|
+ const changedNodes = projectObj.project.calcProgram.calcNodes(nodes, false);
|
|
|
+ const dataArr = [];
|
|
|
+ for (const node of changedNodes) {
|
|
|
+ if (node.changed) {
|
|
|
+ const data = calcTools.cutNodeForSave(node);
|
|
|
+ dataArr.push(data);
|
|
|
+ }
|
|
|
+ }
|
|
|
+ console.log(dataArr);
|
|
|
+ } catch (err) {
|
|
|
+ alert(err);
|
|
|
+ } finally {
|
|
|
+ $.bootstrapLoading.end();
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
// 编辑相关
|
|
|
const edit = async (sheet, changedCells) => {
|
|
|
if (!changedCells.length) {
|
|
@@ -92,7 +113,8 @@ const budgetSummaryObj = (() => {
|
|
|
if (!isValid) {
|
|
|
recover(sheet, changedCells);
|
|
|
}
|
|
|
- console.log(changedCells);
|
|
|
+ let needCalc = false;
|
|
|
+ const nodes = [];
|
|
|
try {
|
|
|
$.bootstrapLoading.start();
|
|
|
const IDMap = {};
|
|
@@ -102,9 +124,24 @@ const budgetSummaryObj = (() => {
|
|
|
if (!node) {
|
|
|
return;
|
|
|
}
|
|
|
+ if (!nodes.find(n => n.data.ID !== node.data.ID)) {
|
|
|
+ nodes.push(node);
|
|
|
+ }
|
|
|
const field = getFieldByCol(col);
|
|
|
+ const value = sheet.getValue(row, col) || '';
|
|
|
+ if (field === 'calcBase') {
|
|
|
+ debugger;
|
|
|
+ node.data.userCalcBase = value;
|
|
|
+ projectObj.project.calcBase.calculate(node, null, false);
|
|
|
+ if (!projectObj.project.calcBase.success) {
|
|
|
+ throw projectObj.project.calcBase.errMsg;
|
|
|
+ }
|
|
|
+ }
|
|
|
const data = (IDMap[node.data.ID] || (IDMap[node.data.ID] = {}));
|
|
|
- data[field] = sheet.getValue(row, col);
|
|
|
+ data[field] = value;
|
|
|
+ if (['quantity', 'feesIndex.common.unitFee', 'calcBase', 'feeRate'].includes(field)) {
|
|
|
+ needCalc = true;
|
|
|
+ }
|
|
|
});
|
|
|
Object
|
|
|
.entries(IDMap)
|
|
@@ -116,7 +153,12 @@ const budgetSummaryObj = (() => {
|
|
|
const node = tree.findNode(item.data.ID);
|
|
|
Object.assign(node.data, item.data);
|
|
|
});
|
|
|
+ // 重算节点
|
|
|
+ /* if (needCalc && nodes.length) {
|
|
|
+ await calcNodes(sheet, nodes);
|
|
|
+ } */
|
|
|
} catch (err) {
|
|
|
+ recover(sheet, changedCells);
|
|
|
alert(err);
|
|
|
} finally {
|
|
|
$.bootstrapLoading.end();
|
|
@@ -685,7 +727,9 @@ const budgetSummaryObj = (() => {
|
|
|
// 对外暴露
|
|
|
return {
|
|
|
getTree: () => tree,
|
|
|
+ getSheet: () => spread.getSheet(0),
|
|
|
calcSetting,
|
|
|
+ edit,
|
|
|
};
|
|
|
|
|
|
})();
|