|
@@ -213,7 +213,8 @@ $(function () {
|
|
|
// 先判断当前修改月份与汇总sjs月份是否一致或更大,获取修改的对应台账行
|
|
|
const huizongSelect = SpreadJsObj.getRowObject(huizongSpread.getActiveSheet(), row);
|
|
|
if (yearmonth.split('-')[0] === curScheduleMonth.yearmonth.split('-')[0]) {
|
|
|
- huizongSelect.year_sj_gcl = ZhCalc.add(ZhCalc.sub(huizongSelect.year_sj_gcl, orgValue), validText);
|
|
|
+ console.log(huizongSelect, row);
|
|
|
+ huizongSelect.year_sj_gcl = huizongSelect.year_sj_gcl ? ZhCalc.add(ZhCalc.sub(huizongSelect.year_sj_gcl, orgValue), validText) : validText;
|
|
|
huizongSelect.year_sj_tp = huizongSelect.dgn_price && huizongSelect.dgn_price !== 0 ? ZhCalc.round(ZhCalc.mul(huizongSelect.year_sj_gcl, huizongSelect.dgn_price), 0) : 0;
|
|
|
}
|
|
|
if (yearmonth === curScheduleMonth.yearmonth) {
|
|
@@ -222,7 +223,7 @@ $(function () {
|
|
|
huizongSelect.sj_tp = huizongSelect.dgn_price && huizongSelect.dgn_price !== 0 ? ZhCalc.round(ZhCalc.mul(huizongSelect.sj_gcl, huizongSelect.dgn_price), 0) : 0;
|
|
|
}
|
|
|
if (yearmonth <= curScheduleMonth.yearmonth) {
|
|
|
- huizongSelect.end_sj_gcl = ZhCalc.add(ZhCalc.sub(huizongSelect.end_sj_gcl, orgValue), validText);
|
|
|
+ huizongSelect.end_sj_gcl = huizongSelect.end_sj_gcl ? ZhCalc.add(ZhCalc.sub(huizongSelect.end_sj_gcl, orgValue), validText) : validText;
|
|
|
huizongSelect.end_sj_tp = huizongSelect.dgn_price && huizongSelect.dgn_price !== 0 ? ZhCalc.round(ZhCalc.mul(huizongSelect.end_sj_gcl, huizongSelect.dgn_price), 0) : 0;
|
|
|
}
|
|
|
const nodes = treeCalc.calculateParent(huizongSpread.getActiveSheet().zh_tree, huizongSelect);
|
|
@@ -278,44 +279,52 @@ $(function () {
|
|
|
}
|
|
|
},
|
|
|
deletePress: function (sheet) {
|
|
|
- if (!sheet.zh_setting || sheet.zh_setting.readOnly) return;
|
|
|
+ if (!sheet.zh_setting) return;
|
|
|
if (sheet.zh_setting && sheet.zh_tree) {
|
|
|
- const sel = sheet.getSelections()[0];
|
|
|
+ const sel = sheet.getSelections()[0], datas = [], filterNodes = [], huizongNodes = [];
|
|
|
if (!sel) return;
|
|
|
- if(sel.rowCount > 1 || sel.colCount > 1) {
|
|
|
- return;
|
|
|
- }
|
|
|
- const select = SpreadJsObj.getSelectObject(sheet);
|
|
|
- const col = sheet.zh_setting.cols[sel.col];
|
|
|
- const orgValue = select[col.field];
|
|
|
- if (!orgValue) {
|
|
|
- return;
|
|
|
+ for (let iRow = sel.row; iRow < sel.row + sel.rowCount; iRow++) {
|
|
|
+ let bDel = false;
|
|
|
+ const node = sheet.zh_tree.nodes[iRow];
|
|
|
+ for (let iCol = sel.col; iCol < sel.col + sel.colCount; iCol++) {
|
|
|
+ const col = sheet.zh_setting.cols[iCol];
|
|
|
+ const orgValue = node[col.field];
|
|
|
+ if (!orgValue) {
|
|
|
+ continue;
|
|
|
+ }
|
|
|
+ const yearmonth = col.field.split('_')[0];
|
|
|
+ if(col.readOnly === true || !node.is_leaf) {
|
|
|
+ continue;
|
|
|
+ }
|
|
|
+ const updateData = {
|
|
|
+ lid: node.ledger_id,
|
|
|
+ yearmonth,
|
|
|
+ sj_gcl: null,
|
|
|
+ sj_tp: null,
|
|
|
+ };
|
|
|
+ datas.push(updateData);
|
|
|
+ huizongNodes.push({row: iRow, yearmonth, orgValue, nowValue: null});
|
|
|
+ node[yearmonth+'_sj_gcl'] = null;
|
|
|
+ node[yearmonth+'_sj_tp'] = null;
|
|
|
+ bDel = true;
|
|
|
+ }
|
|
|
+ if (bDel) filterNodes.push(node);
|
|
|
}
|
|
|
- const yearmonth = col.field.split('_')[0];
|
|
|
- if(col.readOnly === true || !select.is_leaf) {
|
|
|
- return;
|
|
|
+ if (datas.length > 0) {
|
|
|
+ postData(window.location.pathname + '/save', {type: 'ledger_paste', postData: datas}, function (result) {
|
|
|
+ for (const uul of filterNodes) {
|
|
|
+ const nodes = treeCalc.calculateParent(sheet.zh_tree, uul);
|
|
|
+ const refreshNode = ledgerTree.loadPostData({update: nodes});
|
|
|
+ ledgerSpreadObj.refreshTree(sheet, refreshNode);
|
|
|
+ }
|
|
|
+ for (const hz of huizongNodes) {
|
|
|
+ ledgerSpreadObj.reCalcHuizong(hz.row, hz.yearmonth, hz.orgValue, hz.nowValue);
|
|
|
+ }
|
|
|
+ SpreadJsObj.reLoadSheetData(sheet);
|
|
|
+ }, function () {
|
|
|
+ SpreadJsObj.reLoadSheetData(sheet);
|
|
|
+ });
|
|
|
}
|
|
|
- let sj_gcl = 0;
|
|
|
- let sj_tp = 0;
|
|
|
- select[col.field] = 0;
|
|
|
- const updateData = {
|
|
|
- lid: select.ledger_id,
|
|
|
- yearmonth,
|
|
|
- sj_gcl,
|
|
|
- sj_tp,
|
|
|
- };
|
|
|
- postData(window.location.pathname + '/save', {type: 'ledger_edit', postData: updateData}, function (result) {
|
|
|
- select[yearmonth + '_sj_tp'] = sj_tp;
|
|
|
- const nodes = treeCalc.calculateParent(sheet.zh_tree, select);
|
|
|
- const refreshNode = ledgerTree.loadPostData({update: nodes});
|
|
|
- ledgerSpreadObj.refreshTree(sheet, refreshNode);
|
|
|
- ledgerSpreadObj.reCalcHuizong(info.row, yearmonth, orgValue, validText);
|
|
|
- },function () {
|
|
|
- select[col.field] = orgValue;
|
|
|
- const nodes = treeCalc.calculateParent(sheet.zh_tree, select);
|
|
|
- const refreshNode = ledgerTree.loadPostData({update: nodes});
|
|
|
- ledgerSpreadObj.refreshTree(sheet, refreshNode);
|
|
|
- })
|
|
|
}
|
|
|
},
|
|
|
clipboardPasted(e, info) {
|
|
@@ -323,57 +332,70 @@ $(function () {
|
|
|
cellError: {type: 'error', msg: '粘贴内容超出了表格范围'},
|
|
|
numberExpr: {type: 'error', msg: '不能粘贴其它非数字类型字符'},
|
|
|
};
|
|
|
- const range = info.cellRange;
|
|
|
- if (range.rowCount > 1 || range.colCount > 1) {
|
|
|
- toastMessageUniq(hint.cellError);
|
|
|
- SpreadJsObj.reLoadSheetHeader(ledgerSpread.getActiveSheet());
|
|
|
- SpreadJsObj.reLoadSheetData(ledgerSpread.getActiveSheet());
|
|
|
- return;
|
|
|
- }
|
|
|
- const select = SpreadJsObj.getSelectObject(info.sheet);
|
|
|
- const col = info.sheet.zh_setting.cols[range.col];
|
|
|
- let validText = is_numeric(info.pasteData.text) ? parseFloat(info.pasteData.text) : (info.pasteData.text ? trimInvalidChar(info.pasteData.text) : null);
|
|
|
- const orgValue = select[col.field];
|
|
|
- if (orgValue == validText || ((!orgValue || orgValue === '') && (validText === ''))) {
|
|
|
- SpreadJsObj.reLoadRowData(info.sheet, info.row);
|
|
|
- return;
|
|
|
+ const tree = info.sheet.zh_tree;
|
|
|
+ if (!tree) { return; }
|
|
|
+ const sortData = info.sheet.zh_tree.nodes;
|
|
|
+ const datas = [], filterNodes = [], huizongNodes = [];
|
|
|
+
|
|
|
+ for (let iRow = 0; iRow < info.cellRange.rowCount; iRow ++) {
|
|
|
+ let bPaste = false;
|
|
|
+ const curRow = info.cellRange.row + iRow;
|
|
|
+ const node = sortData[curRow];
|
|
|
+ if (node) {
|
|
|
+ for (let iCol = 0; iCol < info.cellRange.colCount; iCol++) {
|
|
|
+ const curCol = info.cellRange.col + iCol;
|
|
|
+ const colSetting = info.sheet.zh_setting.cols[curCol];
|
|
|
+ let validText = is_numeric(info.sheet.getText(curRow, curCol)) ? parseFloat(info.sheet.getText(curRow, curCol)) : (info.sheet.getText(curRow, curCol) ? trimInvalidChar(info.sheet.getText(curRow, curCol)) : null);
|
|
|
+ const orgValue = node[colSetting.field];
|
|
|
+ if (orgValue == validText || ((!orgValue || orgValue === '') && (validText === ''))) {
|
|
|
+ continue;
|
|
|
+ }
|
|
|
+ if (isNaN(validText)) {
|
|
|
+ toastMessageUniq(hint.numberExpr);
|
|
|
+ continue;
|
|
|
+ }
|
|
|
+ const yearmonth = colSetting.field.split('_')[0];
|
|
|
+ // 判断输入位数,提示
|
|
|
+ const reg = new RegExp('^([-]?)\\d+$');
|
|
|
+ if (validText !== null && (!reg.test(validText))) {
|
|
|
+ validText = ZhCalc.round(validText, 3);
|
|
|
+ }
|
|
|
+ const sj_gcl = validText;
|
|
|
+ const sj_tp = node.dgn_price && node.dgn_price !== 0 ? ZhCalc.round(ZhCalc.mul(validText, node.dgn_price), 0) : 0;
|
|
|
+ const updateData = {
|
|
|
+ lid: node.ledger_id,
|
|
|
+ yearmonth,
|
|
|
+ sj_gcl,
|
|
|
+ sj_tp,
|
|
|
+ };
|
|
|
+ datas.push(updateData);
|
|
|
+ huizongNodes.push({row: info.cellRange.row + iRow, yearmonth, orgValue, nowValue: validText});
|
|
|
+ node[yearmonth+'_sj_gcl'] = sj_gcl;
|
|
|
+ node[yearmonth+'_sj_tp'] = sj_tp;
|
|
|
+ bPaste = true;
|
|
|
+ }
|
|
|
+ if (bPaste) {
|
|
|
+ filterNodes.push(node);
|
|
|
+ }
|
|
|
+ }
|
|
|
}
|
|
|
- if (isNaN(validText)) {
|
|
|
- toastr.error('不能粘贴其它非数字类型字符');
|
|
|
+ if (datas.length > 0) {
|
|
|
+ postData(window.location.pathname + '/save', {type: 'ledger_paste', postData: datas}, function (result) {
|
|
|
+ for (const uul of filterNodes) {
|
|
|
+ const nodes = treeCalc.calculateParent(info.sheet.zh_tree, uul);
|
|
|
+ const refreshNode = ledgerTree.loadPostData({update: nodes});
|
|
|
+ ledgerSpreadObj.refreshTree(info.sheet, refreshNode);
|
|
|
+ }
|
|
|
+ for (const hz of huizongNodes) {
|
|
|
+ ledgerSpreadObj.reCalcHuizong(hz.row, hz.yearmonth, hz.orgValue, hz.nowValue);
|
|
|
+ }
|
|
|
+ SpreadJsObj.reLoadSheetData(info.sheet);
|
|
|
+ }, function () {
|
|
|
+ SpreadJsObj.reLoadRowData(info.sheet, info.cellRange.row, info.cellRange.rowCount);
|
|
|
+ });
|
|
|
+ } else {
|
|
|
SpreadJsObj.reLoadRowData(info.sheet, info.cellRange.row, info.cellRange.rowCount);
|
|
|
- return;
|
|
|
}
|
|
|
- const yearmonth = col.field.split('_')[0];
|
|
|
- // 判断输入位数,提示
|
|
|
- const reg = new RegExp('^([-]?)\\d+$');
|
|
|
- if (validText !== null && (!reg.test(validText))) {
|
|
|
- // toastr.error('粘贴的工程量小数位数不能大于3位');
|
|
|
- // SpreadJsObj.reLoadRowData(info.sheet, info.cellRange.row, info.cellRange.rowCount);
|
|
|
- // return;
|
|
|
- validText = ZhCalc.round(validText, 3);
|
|
|
- }
|
|
|
- const sj_gcl = validText;
|
|
|
- const sj_tp = select.dgn_price && select.dgn_price !== 0 ? ZhCalc.round(ZhCalc.mul(validText, select.dgn_price), 0) : 0;
|
|
|
- select[col.field] = validText;
|
|
|
- const updateData = {
|
|
|
- lid: select.ledger_id,
|
|
|
- yearmonth,
|
|
|
- sj_gcl,
|
|
|
- sj_tp,
|
|
|
- };
|
|
|
- console.log(updateData);
|
|
|
- postData(window.location.pathname + '/save', {type: 'ledger_edit', postData: updateData}, function (result) {
|
|
|
- select[yearmonth + '_sj_tp'] = sj_tp;
|
|
|
- const nodes = treeCalc.calculateParent(info.sheet.zh_tree, select);
|
|
|
- const refreshNode = ledgerTree.loadPostData({update: nodes});
|
|
|
- ledgerSpreadObj.refreshTree(info.sheet, refreshNode);
|
|
|
- ledgerSpreadObj.reCalcHuizong(info.row, yearmonth, orgValue, validText);
|
|
|
- },function () {
|
|
|
- select[col.field] = orgValue;
|
|
|
- const nodes = treeCalc.calculateParent(info.sheet.zh_tree, select);
|
|
|
- const refreshNode = ledgerTree.loadPostData({update: nodes});
|
|
|
- ledgerSpreadObj.refreshTree(info.sheet, refreshNode);
|
|
|
- })
|
|
|
},
|
|
|
};
|
|
|
|