|
@@ -137,7 +137,6 @@ $(function () {
|
|
|
const newLedgerList = setMonthToLedger(data.bills, data.slm);
|
|
|
baseLedgerTree.loadDatas(newLedgerList);
|
|
|
treeCalc.calculateAll(baseLedgerTree);
|
|
|
- console.log(baseLedgerTree);
|
|
|
for (const d of baseLedgerTree.nodes) {
|
|
|
if (!d.b_code) {
|
|
|
const one = _.find(selectedLedgerList, function (item) {
|
|
@@ -148,7 +147,6 @@ $(function () {
|
|
|
}
|
|
|
}
|
|
|
}
|
|
|
- // console.log(ledgerTree);
|
|
|
ledgerTree.sortTreeNode(true);
|
|
|
treeCalc.calculateAll(ledgerTree);
|
|
|
console.log(ledgerTree);
|
|
@@ -253,7 +251,6 @@ $(function () {
|
|
|
plan_gcl,
|
|
|
plan_tp,
|
|
|
};
|
|
|
- console.log(updateData);
|
|
|
postData(window.location.pathname + '/save', {type: 'ledger_edit', postData: updateData}, function (result) {
|
|
|
if (mode === 'tp') {
|
|
|
select[yearmonth + '_gcl'] = plan_gcl;
|
|
@@ -272,48 +269,49 @@ $(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 = [];
|
|
|
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];
|
|
|
+ const modes = col.field.split('_')[1];
|
|
|
+ if(col.readOnly === true || !node.is_leaf || mode[modes] !== schedule.mode) {
|
|
|
+ continue;
|
|
|
+ }
|
|
|
+ const updateData = {
|
|
|
+ lid: node.ledger_id,
|
|
|
+ yearmonth,
|
|
|
+ plan_gcl: null,
|
|
|
+ plan_tp: null,
|
|
|
+ };
|
|
|
+ datas.push(updateData);
|
|
|
+ node[yearmonth+'_gcl'] = null;
|
|
|
+ node[yearmonth+'_tp'] = null;
|
|
|
+ bDel = true;
|
|
|
+ }
|
|
|
+ if (bDel) filterNodes.push(node);
|
|
|
}
|
|
|
- const yearmonth = col.field.split('_')[0];
|
|
|
- const modes = col.field.split('_')[1];
|
|
|
- if(col.readOnly === true || !select.is_leaf || mode[modes] !== schedule.mode) {
|
|
|
- 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);
|
|
|
+ }
|
|
|
+ SpreadJsObj.reLoadSheetData(sheet);
|
|
|
+ }, function () {
|
|
|
+ SpreadJsObj.reLoadSheetData(sheet);
|
|
|
+ });
|
|
|
}
|
|
|
- let plan_gcl = 0;
|
|
|
- let plan_tp = 0;
|
|
|
- select[col.field] = 0;
|
|
|
- const updateData = {
|
|
|
- lid: select.ledger_id,
|
|
|
- yearmonth,
|
|
|
- plan_gcl,
|
|
|
- plan_tp,
|
|
|
- };
|
|
|
- postData(window.location.pathname + '/save', {type: 'ledger_edit', postData: updateData}, function (result) {
|
|
|
- if (modes === 'tp') {
|
|
|
- select[yearmonth + '_gcl'] = plan_gcl;
|
|
|
- } else {
|
|
|
- select[yearmonth + '_tp'] = plan_tp;
|
|
|
- }
|
|
|
- const nodes = treeCalc.calculateParent(sheet.zh_tree, select);
|
|
|
- const refreshNode = ledgerTree.loadPostData({update: nodes});
|
|
|
- ledgerSpreadObj.refreshTree(sheet, refreshNode);
|
|
|
- },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) {
|
|
@@ -321,76 +319,79 @@ $(function () {
|
|
|
cellError: {type: 'error', msg: '粘贴内容超出了表格范围'},
|
|
|
numberExpr: {type: 'error', msg: '不能粘贴其它非数字类型字符'},
|
|
|
};
|
|
|
- console.log(info);
|
|
|
- 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;
|
|
|
- }
|
|
|
- if (isNaN(validText)) {
|
|
|
- toastr.error('不能粘贴其它非数字类型字符');
|
|
|
- SpreadJsObj.reLoadRowData(info.sheet, info.cellRange.row, info.cellRange.rowCount);
|
|
|
- return;
|
|
|
- }
|
|
|
- const yearmonth = col.field.split('_')[0];
|
|
|
- const mode = col.field.split('_')[1];
|
|
|
- let plan_gcl = 0;
|
|
|
- let plan_tp = 0;
|
|
|
- // 判断输入位数,提示
|
|
|
- if (mode === 'tp') {
|
|
|
- const reg = new RegExp('^([-]?)\\d+$');
|
|
|
- if (validText !== null && (!reg.test(validText))) {
|
|
|
- // toastr.error('粘贴的金额小数位数不能大于0位');
|
|
|
- // SpreadJsObj.reLoadRowData(info.sheet, info.cellRange.row, info.cellRange.rowCount);
|
|
|
- // return;
|
|
|
- validText = ZhCalc.round(validText, 0);
|
|
|
+ const tree = info.sheet.zh_tree;
|
|
|
+ if (!tree) { return; }
|
|
|
+
|
|
|
+ const sortData = info.sheet.zh_tree.nodes;
|
|
|
+ const datas = [], filterNodes = [];
|
|
|
+
|
|
|
+ for (let iRow = 0; iRow < info.cellRange.rowCount; iRow ++) {
|
|
|
+ let bPaste = false;
|
|
|
+ const curRow = info.cellRange.row + iRow;
|
|
|
+ const node = sortData[curRow];
|
|
|
+ if (node) {
|
|
|
+ const updateData = {
|
|
|
+ lid: node.ledger_id,
|
|
|
+ };
|
|
|
+ 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 mode = colSetting.field.split('_')[1];
|
|
|
+ let plan_gcl = 0;
|
|
|
+ let plan_tp = 0;
|
|
|
+ // 判断输入位数,提示
|
|
|
+ if (mode === 'tp') {
|
|
|
+ const reg = new RegExp('^([-]?)\\d+$');
|
|
|
+ if (validText !== null && (!reg.test(validText))) {
|
|
|
+ validText = ZhCalc.round(validText, 0);
|
|
|
+ }
|
|
|
+ plan_gcl = node.dgn_price && node.dgn_price !== 0 ? ZhCalc.round(ZhCalc.div(validText, node.dgn_price), 3) : 0;
|
|
|
+ plan_tp = validText;
|
|
|
+ } else {
|
|
|
+ const reg = new RegExp('^([-]?)\\d+$');
|
|
|
+ if (validText !== null && (!reg.test(validText))) {
|
|
|
+ validText = ZhCalc.round(validText, 3);
|
|
|
+ }
|
|
|
+ plan_gcl = validText;
|
|
|
+ plan_tp = node.dgn_price && node.dgn_price !== 0 ? ZhCalc.round(ZhCalc.mul(validText, node.dgn_price), 0) : 0;
|
|
|
+ }
|
|
|
+ updateData.yearmonth = yearmonth;
|
|
|
+ updateData.plan_gcl = plan_gcl;
|
|
|
+ updateData.plan_tp = plan_tp;
|
|
|
+ datas.push(updateData);
|
|
|
+ node[yearmonth+'_gcl'] = plan_gcl;
|
|
|
+ node[yearmonth+'_tp'] = plan_tp;
|
|
|
+ bPaste = true;
|
|
|
+ }
|
|
|
+ if (bPaste) {
|
|
|
+ filterNodes.push(node);
|
|
|
+ }
|
|
|
}
|
|
|
- plan_gcl = select.dgn_price && select.dgn_price !== 0 ? ZhCalc.round(ZhCalc.div(validText, select.dgn_price), 3) : 0;
|
|
|
- plan_tp = validText;
|
|
|
+ }
|
|
|
+ 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);
|
|
|
+ }
|
|
|
+ SpreadJsObj.reLoadSheetData(info.sheet);
|
|
|
+ }, function () {
|
|
|
+ SpreadJsObj.reLoadRowData(info.sheet, info.cellRange.row, info.cellRange.rowCount);
|
|
|
+ });
|
|
|
} else {
|
|
|
- // const reg = new RegExp('^([-]?)\\d+(\\.\\d{0,3})?$');
|
|
|
- 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);
|
|
|
- }
|
|
|
- plan_gcl = validText;
|
|
|
- plan_tp = select.dgn_price && select.dgn_price !== 0 ? ZhCalc.round(ZhCalc.mul(validText, select.dgn_price), 0) : 0;
|
|
|
+ SpreadJsObj.reLoadRowData(info.sheet, info.cellRange.row, info.cellRange.rowCount);
|
|
|
}
|
|
|
- select[col.field] = validText;
|
|
|
- const updateData = {
|
|
|
- lid: select.ledger_id,
|
|
|
- yearmonth,
|
|
|
- plan_gcl,
|
|
|
- plan_tp,
|
|
|
- };
|
|
|
- postData(window.location.pathname + '/save', {type: 'ledger_edit', postData: updateData}, function (result) {
|
|
|
- if (mode === 'tp') {
|
|
|
- select[yearmonth + '_gcl'] = plan_gcl;
|
|
|
- } else {
|
|
|
- select[yearmonth + '_tp'] = plan_tp;
|
|
|
- }
|
|
|
- const nodes = treeCalc.calculateParent(info.sheet.zh_tree, select);
|
|
|
- const refreshNode = ledgerTree.loadPostData({update: nodes});
|
|
|
- ledgerSpreadObj.refreshTree(info.sheet, refreshNode);
|
|
|
- },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);
|
|
|
- })
|
|
|
},
|
|
|
};
|
|
|
|
|
@@ -436,7 +437,7 @@ $(function () {
|
|
|
}
|
|
|
}
|
|
|
}
|
|
|
- console.log(update_under_ledger);
|
|
|
+
|
|
|
postData(window.location.pathname + '/save', {type: 'mode', postData: {mode: this_mode, update_under_ledger}}, function (result) {
|
|
|
_self.addClass('disabled').attr('disabled', true);
|
|
|
_self.text('当前');
|
|
@@ -496,7 +497,7 @@ $(function () {
|
|
|
const hadmonth = [];
|
|
|
for (const m of addMonthList) {
|
|
|
const one = _.find(scheduleMonth, { yearmonth: m });
|
|
|
- console.log(one, m);
|
|
|
+
|
|
|
if (one) {
|
|
|
hadmonth.push(m);
|
|
|
}
|