|
@@ -22,11 +22,22 @@ $(function () {
|
|
|
level: 'level',
|
|
|
rootId: -1,
|
|
|
fullPath: 'full_path',
|
|
|
+ calcFun: function (node) {
|
|
|
+ node.dgn_price = ZhCalc.round(ZhCalc.div(node.total_price, node.dgn_qty1), 2);
|
|
|
+ if (node.children && node.children.length > 0) {
|
|
|
+ for (const sm of scheduleMonth) {
|
|
|
+ if (sm.stage_gcl_used === 1) {
|
|
|
+ node[sm.yearmonth + '_plan_gcl'] = ZhCalc.round(ZhCalc.div(node[sm.yearmonth + '_plan_tp'], node.dgn_price), 3);
|
|
|
+ node[sm.yearmonth + '_sj_gcl'] = ZhCalc.round(ZhCalc.div(node[sm.yearmonth + '_sj_tp'], node.dgn_price), 3);
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
//treeCacheKey: 'ledger_bills_fold' + '_' + getTenderId(),
|
|
|
// markFoldKey: 'bills-fold',
|
|
|
// markFoldSubKey: window.location.pathname.split('/')[2],
|
|
|
};
|
|
|
- const ledgerTree = createNewPathTree('filter', treeSetting);
|
|
|
+
|
|
|
|
|
|
const static_cols = [
|
|
|
{title: '编号', colSpan: '1', rowSpan: '2', field: 'code', hAlign: 0, width: 145, formatter: '@', readOnly: true, cellType: 'tree'},
|
|
@@ -34,7 +45,7 @@ $(function () {
|
|
|
{title: '单位', colSpan: '1', rowSpan: '2', field: 'unit', hAlign: 1, width: 50, formatter: '@', readOnly: true},
|
|
|
{title: '经济指标', colSpan: '1', rowSpan: '2', field: 'dgn_price', hAlign: 2, width: 60, type: 'Number', readOnly: true},
|
|
|
{title: '总设计|工程量', colSpan: '2|1', rowSpan: '1|1', field: 'dgn_qty1', hAlign: 2, width: 70, type: 'Number', readOnly: true},
|
|
|
- {title: '|金额(万元)', colSpan: '|1', rowSpan: '|1', field: 'total_price', hAlign: 2, width: 70, type: 'Number', readOnly: true},
|
|
|
+ {title: '|金额(元)', colSpan: '|1', rowSpan: '|1', field: 'total_price', hAlign: 2, width: 70, type: 'Number', readOnly: true},
|
|
|
];
|
|
|
|
|
|
const ledgerSpreadSetting = {
|
|
@@ -46,33 +57,40 @@ $(function () {
|
|
|
font: '12px 微软雅黑',
|
|
|
// readOnly: true,
|
|
|
localCache: {
|
|
|
- key: 'ledger-bills',
|
|
|
+ key: 'ledger-gcl',
|
|
|
colWidth: true,
|
|
|
}
|
|
|
};
|
|
|
const monthsCols = [];
|
|
|
+ const calcCols = ['total_price'];
|
|
|
if(scheduleMonth.length > 0) {
|
|
|
for (const sm of scheduleMonth) {
|
|
|
if (sm.stage_gcl_used === 1) {
|
|
|
const yearmonth = sm.yearmonth.split('-')[0] + '年' + parseInt(sm.yearmonth.split('-')[1]) + '月';
|
|
|
const cols = {title: yearmonth + '|计划工程量', colSpan: '4|1', rowSpan: '1|1', field: sm.yearmonth+'_plan_gcl', hAlign: 2, width: 90, type: 'Number', readOnly: true};
|
|
|
- const cols2 = {title: '|计划金额(万元)', colSpan: '|1', rowSpan: '|1', field: sm.yearmonth+'_plan_tp', hAlign: 2, width: 90, type: 'Number', readOnly: true};
|
|
|
+ const cols2 = {title: '|计划金额(元)', colSpan: '|1', rowSpan: '|1', field: sm.yearmonth+'_plan_tp', hAlign: 2, width: 90, type: 'Number', readOnly: true};
|
|
|
const cols3 = {title: '|计量工程量', colSpan: '|1', rowSpan: '|1', field: sm.yearmonth+'_sj_gcl', hAlign: 2, width: 90, type: 'Number', readOnly: 'readOnly.gcl'};
|
|
|
- const cols4 = {title: '|计量金额(万元)', colSpan: '|1', rowSpan: '|1', field: sm.yearmonth+'_sj_tp', hAlign: 2, width: 90, type: 'Number', readOnly : true};
|
|
|
+ const cols4 = {title: '|计量金额(元)', colSpan: '|1', rowSpan: '|1', field: sm.yearmonth+'_sj_tp', hAlign: 2, width: 90, type: 'Number', readOnly : true};
|
|
|
monthsCols.push(cols);
|
|
|
monthsCols.push(cols2);
|
|
|
monthsCols.push(cols3);
|
|
|
monthsCols.push(cols4);
|
|
|
+ // calcCols.push(sm.yearmonth + '_plan_gcl');
|
|
|
+ calcCols.push(sm.yearmonth + '_plan_tp');
|
|
|
+ // calcCols.push(sm.yearmonth + '_sj_gcl');
|
|
|
+ calcCols.push(sm.yearmonth + '_sj_tp');
|
|
|
}
|
|
|
}
|
|
|
}
|
|
|
+ treeSetting.calcFields = calcCols;
|
|
|
+ const ledgerTree = createNewPathTree('filter', treeSetting);
|
|
|
const spreadHeaderCols = static_cols.concat(monthsCols);
|
|
|
ledgerSpreadSetting.cols = spreadHeaderCols;
|
|
|
|
|
|
const ledgerCol = {
|
|
|
readOnly: {
|
|
|
gcl: function (data) {
|
|
|
- return !data.is_leaf;
|
|
|
+ return !(data.is_leaf && !revising);
|
|
|
},
|
|
|
},
|
|
|
};
|
|
@@ -82,6 +100,8 @@ $(function () {
|
|
|
SpreadJsObj.initSpreadSettingEvents(ledgerSpreadSetting, ledgerCol);
|
|
|
SpreadJsObj.initSheet(ledgerSpread.getActiveSheet(), ledgerSpreadSetting);
|
|
|
SpreadJsObj.selChangedRefreshBackColor(ledgerSpread.getActiveSheet());
|
|
|
+ ledgerSpread.getActiveSheet().frozenColumnCount(6);
|
|
|
+ ledgerSpread.getActiveSheet().options.frozenlineColor = '#93b5e4';
|
|
|
|
|
|
postData('/tender/' + getTenderId() + '/schedule/ledger/load', {}, function (data) {
|
|
|
// let treeData = [];
|
|
@@ -133,6 +153,7 @@ $(function () {
|
|
|
}
|
|
|
console.log(ledgerTree);
|
|
|
ledgerTree.sortTreeNode(true);
|
|
|
+ treeCalc.calculateAll(ledgerTree);
|
|
|
// console.log(ledgerTree);
|
|
|
SpreadJsObj.loadSheetData(ledgerSpread.getActiveSheet(), SpreadJsObj.DataType.Tree, ledgerTree);
|
|
|
}, null, true);
|
|
@@ -187,11 +208,33 @@ $(function () {
|
|
|
}
|
|
|
});
|
|
|
},
|
|
|
+ reCalcHuizong: function(row, yearmonth, orgValue, validText) {
|
|
|
+ // 下方汇总sjs实时更新计量数据
|
|
|
+ // 先判断当前修改月份与汇总sjs月份是否一致或更大,获取修改的对应台账行
|
|
|
+ const huizongSelect = SpreadJsObj.getRowObject(huizongSpread.getActiveSheet(), row);
|
|
|
+ if (yearmonth.split('-')[0] === curScheduleMonth.yearmonth.split('-')[0]) {
|
|
|
+ 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) {
|
|
|
+ // 判断是否同年同月,是则修改本年,截至本月,本月计量数据,否则只修改截至本月计量数据
|
|
|
+ huizongSelect.sj_gcl = validText;
|
|
|
+ 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 = 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);
|
|
|
+ const refreshNode = huizongTree.loadPostData({update: nodes});
|
|
|
+ huizongObj.refreshTree(huizongSpread.getActiveSheet(), refreshNode);
|
|
|
+ },
|
|
|
editEnded: function (e, info) {
|
|
|
if (info.sheet.zh_setting) {
|
|
|
const select = SpreadJsObj.getSelectObject(info.sheet);
|
|
|
const col = info.sheet.zh_setting.cols[info.col];
|
|
|
- const validText = is_numeric(info.editingText) ? parseFloat(info.editingText) : (info.editingText ? trimInvalidChar(info.editingText) : null);
|
|
|
+ let validText = is_numeric(info.editingText) ? parseFloat(info.editingText) : (info.editingText ? trimInvalidChar(info.editingText) : null);
|
|
|
const orgValue = select[col.field];
|
|
|
if (orgValue == validText || ((!orgValue || orgValue === '') && (validText === ''))) {
|
|
|
SpreadJsObj.reLoadRowData(info.sheet, info.row);
|
|
@@ -204,14 +247,15 @@ $(function () {
|
|
|
}
|
|
|
const yearmonth = col.field.split('_')[0];
|
|
|
// 判断输入位数,提示
|
|
|
- const reg = new RegExp('^([-]?)\\d+(\\.\\d{0,'+ parseInt(tenderInfo.decimal.up) +'})?$');
|
|
|
+ const reg = new RegExp('^([-]?)\\d+$');
|
|
|
if (validText !== null && (!reg.test(validText))) {
|
|
|
- toastr.error('输入工程量小数位数不能大于' + tenderInfo.decimal.up + '位');
|
|
|
- SpreadJsObj.reLoadRowData(info.sheet, info.row);
|
|
|
- return;
|
|
|
+ // toastr.error('输入工程量小数位数不能大于3位');
|
|
|
+ // SpreadJsObj.reLoadRowData(info.sheet, info.row);
|
|
|
+ // 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), tenderInfo.decimal.tp) : 0;
|
|
|
+ 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,
|
|
@@ -222,66 +266,136 @@ $(function () {
|
|
|
console.log(updateData);
|
|
|
postData(window.location.pathname + '/save', {type: 'ledger_edit', postData: updateData}, function (result) {
|
|
|
select[yearmonth + '_sj_tp'] = sj_tp;
|
|
|
- SpreadJsObj.reLoadRowData(info.sheet, info.row);
|
|
|
+ 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;
|
|
|
- SpreadJsObj.reLoadRowData(info.sheet, info.row);
|
|
|
+ const nodes = treeCalc.calculateParent(info.sheet.zh_tree, select);
|
|
|
+ const refreshNode = ledgerTree.loadPostData({update: nodes});
|
|
|
+ ledgerSpreadObj.refreshTree(info.sheet, refreshNode);
|
|
|
})
|
|
|
}
|
|
|
},
|
|
|
deletePress: function (sheet) {
|
|
|
- return;
|
|
|
+ if (!sheet.zh_setting) return;
|
|
|
+ if (sheet.zh_setting && sheet.zh_tree) {
|
|
|
+ const sel = sheet.getSelections()[0], datas = [], filterNodes = [], huizongNodes = [];
|
|
|
+ if (!sel) 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);
|
|
|
+ }
|
|
|
+ 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);
|
|
|
+ });
|
|
|
+ }
|
|
|
+ }
|
|
|
},
|
|
|
clipboardPasted(e, info) {
|
|
|
const hint = {
|
|
|
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];
|
|
|
- const 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 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);
|
|
|
+ }
|
|
|
+ }
|
|
|
}
|
|
|
- const yearmonth = col.field.split('_')[0];
|
|
|
- // 判断输入位数,提示
|
|
|
- const reg = new RegExp('^([-]?)\\d+(\\.\\d{0,'+ parseInt(tenderInfo.decimal.up) +'})?$');
|
|
|
- if (validText !== null && (!reg.test(validText))) {
|
|
|
- toastr.error('粘贴的工程量小数位数不能大于' + tenderInfo.decimal.up + '位');
|
|
|
+ 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 sj_gcl = validText;
|
|
|
- const sj_tp = select.dgn_price && select.dgn_price !== 0 ? ZhCalc.round(ZhCalc.mul(validText, select.dgn_price), tenderInfo.decimal.tp) : 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;
|
|
|
- SpreadJsObj.reLoadRowData(info.sheet, info.cellRange.row, info.cellRange.rowCount);
|
|
|
- },function () {
|
|
|
- select[col.field] = orgValue;
|
|
|
- SpreadJsObj.reLoadRowData(info.sheet, info.cellRange.row, info.cellRange.rowCount);
|
|
|
- })
|
|
|
},
|
|
|
};
|
|
|
|
|
@@ -299,7 +413,19 @@ $(function () {
|
|
|
level: 'level',
|
|
|
rootId: -1,
|
|
|
fullPath: 'full_path',
|
|
|
- calcFields: ['plan_gcl', 'plan_tp', 'next_plan_gcl', 'next_plan_tp', 'end_plan_gcl', 'end_plan_tp', 'year_plan_gcl', 'year_plan_tp'],
|
|
|
+ calcFun: function (node) {
|
|
|
+ node.dgn_price = ZhCalc.round(ZhCalc.div(node.total_price, node.dgn_qty1), 2);
|
|
|
+ if (node.children && node.children.length > 0) {
|
|
|
+ node.end_plan_gcl = ZhCalc.round(ZhCalc.div(node.end_plan_tp, node.dgn_price), 3);
|
|
|
+ node.year_plan_gcl = ZhCalc.round(ZhCalc.div(node.year_plan_tp, node.dgn_price), 3);
|
|
|
+ node.plan_gcl = ZhCalc.round(ZhCalc.div(node.plan_tp, node.dgn_price), 3);
|
|
|
+ node.next_plan_gcl = ZhCalc.round(ZhCalc.div(node.next_plan_tp, node.dgn_price), 3);
|
|
|
+ node.end_sj_gcl = ZhCalc.round(ZhCalc.div(node.end_sj_tp, node.dgn_price), 3);
|
|
|
+ node.year_sj_gcl = ZhCalc.round(ZhCalc.div(node.year_sj_tp, node.dgn_price), 3);
|
|
|
+ node.sj_gcl = ZhCalc.round(ZhCalc.div(node.sj_tp, node.dgn_price), 3);
|
|
|
+ }
|
|
|
+ },
|
|
|
+ calcFields: ['plan_tp', 'next_plan_tp', 'end_plan_tp', 'year_plan_tp', 'total_price', 'end_sj_tp', 'year_sj_tp', 'sj_tp'],
|
|
|
};
|
|
|
|
|
|
const huizong_static_cols = [
|
|
@@ -308,19 +434,21 @@ $(function () {
|
|
|
{title: '单位', colSpan: '1', rowSpan: '2', field: 'unit', hAlign: 1, width: 50, formatter: '@', readOnly: true},
|
|
|
{title: '经济指标', colSpan: '1', rowSpan: '2', field: 'dgn_price', hAlign: 2, width: 60, type: 'Number', readOnly: true},
|
|
|
{title: '总设计|工程量', colSpan: '2|1', rowSpan: '1|1', field: 'dgn_qty1', hAlign: 2, width: 70, type: 'Number', readOnly: true},
|
|
|
- {title: '|金额(万元)', colSpan: '|1', rowSpan: '|1', field: 'total_price', hAlign: 2, width: 70, type: 'Number', readOnly: true},
|
|
|
+ {title: '|金额(元)', colSpan: '|1', rowSpan: '|1', field: 'total_price', hAlign: 2, width: 70, type: 'Number', readOnly: true},
|
|
|
{title: '自开工至本月计划完成|工程量', colSpan: '2|1', rowSpan: '1|1', field: 'end_plan_gcl', hAlign: 2, width: 70, type: 'Number', readOnly: true},
|
|
|
- {title: '|金额(万元)', colSpan: '|1', rowSpan: '|1', field: 'end_plan_tp', hAlign: 2, width: 70, type: 'Number', readOnly: true},
|
|
|
- {title: '截止本月完成计量|工程量', colSpan: '2|1', rowSpan: '1|1', field: 'end_gather_qty', hAlign: 2, width: 70, type: 'Number', readOnly: true},
|
|
|
- {title: '|金额(万元)', colSpan: '|1', rowSpan: '|1', field: 'end_gather_tp', hAlign: 2, width: 70, type: 'Number', readOnly: true},
|
|
|
+ {title: '|金额(元)', colSpan: '|1', rowSpan: '|1', field: 'end_plan_tp', hAlign: 2, width: 70, type: 'Number', readOnly: true},
|
|
|
+ {title: '截止本月完成计量|工程量', colSpan: '2|1', rowSpan: '1|1', field: 'end_sj_gcl', hAlign: 2, width: 70, type: 'Number', readOnly: true},
|
|
|
+ {title: '|金额(元)', colSpan: '|1', rowSpan: '|1', field: 'end_sj_tp', hAlign: 2, width: 70, type: 'Number', readOnly: true},
|
|
|
{title: '本年计划完成|工程量', colSpan: '2|1', rowSpan: '1|1', field: 'year_plan_gcl', hAlign: 2, width: 70, type: 'Number', readOnly: true},
|
|
|
- {title: '|金额(万元)', colSpan: '|1', rowSpan: '|1', field: 'year_plan_tp', hAlign: 2, width: 70, type: 'Number', readOnly: true},
|
|
|
- {title: '本年累计完成|工程量', colSpan: '2|1', rowSpan: '1|1', field: 'year_contract_qty', hAlign: 2, width: 70, type: 'Number', readOnly: true},
|
|
|
- {title: '|金额(万元)', colSpan: '|1', rowSpan: '|1', field: 'year_gather_tp', hAlign: 2, width: 70, type: 'Number', readOnly: true},
|
|
|
+ {title: '|金额(元)', colSpan: '|1', rowSpan: '|1', field: 'year_plan_tp', hAlign: 2, width: 70, type: 'Number', readOnly: true},
|
|
|
+ {title: '本年累计完成|工程量', colSpan: '2|1', rowSpan: '1|1', field: 'year_sj_gcl', hAlign: 2, width: 70, type: 'Number', readOnly: true},
|
|
|
+ {title: '|金额(元)', colSpan: '|1', rowSpan: '|1', field: 'year_sj_tp', hAlign: 2, width: 70, type: 'Number', readOnly: true},
|
|
|
{title: '本月计划完成|工程量', colSpan: '2|1', rowSpan: '1|1', field: 'plan_gcl', hAlign: 2, width: 70, type: 'Number', readOnly: true},
|
|
|
- {title: '|金额(万元)', colSpan: '|1', rowSpan: '|1', field: 'plan_tp', hAlign: 2, width: 70, type: 'Number', readOnly: true},
|
|
|
+ {title: '|金额(元)', colSpan: '|1', rowSpan: '|1', field: 'plan_tp', hAlign: 2, width: 70, type: 'Number', readOnly: true},
|
|
|
+ {title: '本月计量完成|工程量', colSpan: '2|1', rowSpan: '1|1', field: 'sj_gcl', hAlign: 2, width: 70, type: 'Number', readOnly: true},
|
|
|
+ {title: '|金额(元)', colSpan: '|1', rowSpan: '|1', field: 'sj_tp', hAlign: 2, width: 70, type: 'Number', readOnly: true},
|
|
|
{title: '下月计划|工程量', colSpan: '2|1', rowSpan: '1|1', field: 'next_plan_gcl', hAlign: 2, width: 70, type: 'Number', readOnly: true},
|
|
|
- {title: '|金额(万元)', colSpan: '|1', rowSpan: '|1', field: 'next_plan_tp', hAlign: 2, width: 70, type: 'Number', readOnly: true},
|
|
|
+ {title: '|金额(元)', colSpan: '|1', rowSpan: '|1', field: 'next_plan_tp', hAlign: 2, width: 70, type: 'Number', readOnly: true},
|
|
|
];
|
|
|
|
|
|
const huizongSpreadSetting = {
|
|
@@ -332,7 +460,7 @@ $(function () {
|
|
|
font: '12px 微软雅黑',
|
|
|
// readOnly: true,
|
|
|
localCache: {
|
|
|
- key: 'ledger-bills',
|
|
|
+ key: 'ledger-huizong',
|
|
|
colWidth: true,
|
|
|
}
|
|
|
};
|
|
@@ -342,94 +470,136 @@ $(function () {
|
|
|
if (thousandth) sjsSettingObj.setTpThousandthFormat(huizongSpreadSetting);
|
|
|
SpreadJsObj.initSheet(huizongSpread.getActiveSheet(), huizongSpreadSetting);
|
|
|
SpreadJsObj.selChangedRefreshBackColor(huizongSpread.getActiveSheet());
|
|
|
+ huizongSpread.getActiveSheet().frozenColumnCount(6);
|
|
|
+ huizongSpread.getActiveSheet().options.frozenlineColor = '#93b5e4';
|
|
|
+
|
|
|
+ let huizongTree = '';
|
|
|
|
|
|
const huizongObj = {
|
|
|
- setSjs: function (order) {
|
|
|
- postData('/tender/' + getTenderId() + '/measure/stage/' + order + '/load', { filter: 'ledger' }, function (data) {
|
|
|
- postData('/tender/' + getTenderId() + '/schedule/stage/' + order + '/load', {}, function (data2) {
|
|
|
- const calcList = ['year_contract_qty', 'year_gather_tp',
|
|
|
- 'contract_qty', 'end_gather_qty', 'contract_tp', 'qc_qty', 'qc_tp', 'total_price', 'contract_tp', 'qc_tp', 'gather_tp',
|
|
|
- 'pre_contract_tp', 'pre_qc_tp', 'pre_gather_tp', 'end_contract_tp', 'end_qc_tp', 'end_gather_tp', 'end_correct_tp'];
|
|
|
- const showList = ['plan_gcl', 'plan_tp', 'next_plan_gcl', 'next_plan_tp', 'end_plan_gcl', 'end_plan_tp', 'year_plan_gcl', 'year_plan_tp',
|
|
|
- 'year_contract_qty', 'year_gather_tp',
|
|
|
- 'contract_qty', 'end_gather_qty', 'contract_tp', 'qc_qty', 'qc_tp', 'ledger_id', 'ledger_pid', 'order', 'level', 'tender_id', 'full_path',
|
|
|
- 'code', 'name', 'unit', 'dgn_qty1', 'dgn_qty2', 'dgn_price', 'quantity', 'total_price', 'contract_tp', 'qc_tp', 'gather_tp',
|
|
|
- 'pre_contract_tp', 'pre_qc_tp', 'pre_gather_tp', 'end_contract_tp', 'end_qc_tp', 'end_gather_tp', 'end_correct_tp'];
|
|
|
- const baseLedgerTreeSetting = {
|
|
|
- id: 'ledger_id',
|
|
|
- pid: 'ledger_pid',
|
|
|
- order: 'order',
|
|
|
- level: 'level',
|
|
|
- rootId: -1,
|
|
|
- fullPath: 'full_path',
|
|
|
- calcFields: calcList,
|
|
|
- };
|
|
|
- baseLedgerTreeSetting.updateFields = ['year_contract_qty', 'year_gather_tp', 'contract_qty', 'end_gather_qty', 'contract_tp', 'qc_qty', 'qc_tp', 'postil', 'used', 'contract_expr'];
|
|
|
- baseLedgerTreeSetting.calcFun = function (node) {
|
|
|
- if (!node.children || node.children.length === 0) {
|
|
|
- node.pre_gather_qty = ZhCalc.add(node.pre_contract_qty, node.pre_qc_qty);
|
|
|
- node.gather_qty = ZhCalc.add(node.contract_qty, node.qc_qty);
|
|
|
- node.end_contract_qty = ZhCalc.add(node.pre_contract_qty, node.contract_qty);
|
|
|
- node.end_qc_qty = ZhCalc.add(node.pre_qc_qty, node.qc_qty);
|
|
|
- node.end_gather_qty = ZhCalc.add(node.pre_gather_qty, node.gather_qty);
|
|
|
+ refreshTree: function (sheet, data) {
|
|
|
+ SpreadJsObj.massOperationSheet(sheet, function () {
|
|
|
+ const tree = sheet.zh_tree;
|
|
|
+ // 处理删除
|
|
|
+ if (data.delete) {
|
|
|
+ data.delete.sort(function (x, y) {
|
|
|
+ return y.deleteIndex - x.deleteIndex;
|
|
|
+ });
|
|
|
+ for (const d of data.delete) {
|
|
|
+ sheet.deleteRows(d.deleteIndex, 1);
|
|
|
+ }
|
|
|
+ }
|
|
|
+ // 处理新增
|
|
|
+ if (data.create) {
|
|
|
+ const newNodes = data.create;
|
|
|
+ if (newNodes) {
|
|
|
+ newNodes.sort(function (a, b) {
|
|
|
+ return a.index - b.index;
|
|
|
+ });
|
|
|
+
|
|
|
+ for (const node of newNodes) {
|
|
|
+ sheet.addRows(node.index, 1);
|
|
|
+ SpreadJsObj.reLoadRowData(sheet, tree.nodes.indexOf(node), 1);
|
|
|
}
|
|
|
- node.pre_gather_tp = ZhCalc.add(node.pre_contract_tp, node.pre_qc_tp);
|
|
|
- node.gather_tp = ZhCalc.add(node.contract_tp, node.qc_tp);
|
|
|
- node.end_contract_tp = ZhCalc.add(node.pre_contract_tp, node.contract_tp);
|
|
|
- node.end_qc_tp = ZhCalc.add(node.pre_qc_tp, node.qc_tp);
|
|
|
- node.end_gather_tp = ZhCalc.add(node.pre_gather_tp, node.gather_tp);
|
|
|
- node.end_final_tp = ZhCalc.add(node.end_qc_tp, node.total_price);
|
|
|
- if (!node.children || node.children.length === 0) {
|
|
|
- if (node.end_contract_qty) {
|
|
|
- node.end_correct_tp = ZhCalc.add(node.end_qc_tp, ZhCalc.mul(node.end_contract_qty, node.unit_price, tenderInfo.decimal.tp));
|
|
|
- } else {
|
|
|
- node.end_correct_tp = node.end_gather_tp;
|
|
|
+ }
|
|
|
+ }
|
|
|
+ // 处理更新
|
|
|
+ if (data.update) {
|
|
|
+ const rows = [];
|
|
|
+ for (const u of data.update) {
|
|
|
+ rows.push(tree.nodes.indexOf(u));
|
|
|
+ }
|
|
|
+ SpreadJsObj.reLoadRowsData(sheet, rows);
|
|
|
+ }
|
|
|
+ // 处理展开
|
|
|
+ if (data.expand) {
|
|
|
+ const expanded = [];
|
|
|
+ for (const e of data.expand) {
|
|
|
+ if (expanded.indexOf(e) === -1) {
|
|
|
+ const posterity = tree.getPosterity(e);
|
|
|
+ for (const p of posterity) {
|
|
|
+ sheet.setRowVisible(tree.nodes.indexOf(p), p.visible);
|
|
|
+ expanded.push(p);
|
|
|
}
|
|
|
}
|
|
|
- node.end_gather_percent = ZhCalc.mul(ZhCalc.div(node.end_gather_tp, node.end_final_tp), 100, 2);
|
|
|
- node.end_correct_percent = ZhCalc.mul(ZhCalc.div(node.end_correct_tp, node.end_final_tp), 100, 2);
|
|
|
- node.final_dgn_price = ZhCalc.round(ZhCalc.div(node.end_gather_tp, ZhCalc.add(node.deal_dgn_qty1, node.c_dgn_qty1)), tenderInfo.decimal.up);
|
|
|
- node.dgn_price = ZhCalc.round(ZhCalc.div(node.total_price, node.dgn_qty1), 2);
|
|
|
- };
|
|
|
- const baseLedgerTree = createNewPathTree('base', baseLedgerTreeSetting);
|
|
|
- const newLedgerList = setTpMonthToLedger(data.ledgerData, data2.slmList, data2.nextSlmList, data2.endSlmList, data2.yearSlmList, data2.curYearStageData);
|
|
|
- baseLedgerTree.loadDatas(newLedgerList);
|
|
|
- treeCalc.calculateAll(baseLedgerTree);
|
|
|
- const huizongTree = createNewPathTree('filter', huizongTreeSetting);
|
|
|
- for (const d of baseLedgerTree.nodes) {
|
|
|
- if (!d.b_code) {
|
|
|
- const one = _.find(selectedLedgerList, function (item) {
|
|
|
- return item === d.ledger_id;
|
|
|
- });
|
|
|
- if (one) {
|
|
|
- huizongTree.addData(d, showList);
|
|
|
- }
|
|
|
+ }
|
|
|
+ }
|
|
|
+ });
|
|
|
+ },
|
|
|
+ setSjs: function (order) {
|
|
|
+ postData('/tender/' + getTenderId() + '/schedule/stage/gcl/' + order + '/load', {}, function (data) {
|
|
|
+ const calcList = ['total_price'];
|
|
|
+ const showList = ['plan_gcl', 'plan_tp', 'next_plan_gcl', 'next_plan_tp', 'end_plan_gcl', 'end_plan_tp', 'year_plan_gcl', 'year_plan_tp',
|
|
|
+ 'sj_gcl', 'sj_tp', 'year_sj_gcl', 'year_sj_tp', 'end_sj_gcl', 'end_sj_tp',
|
|
|
+ 'ledger_id', 'ledger_pid', 'order', 'level', 'tender_id', 'full_path',
|
|
|
+ 'code', 'name', 'unit', 'dgn_qty1', 'dgn_qty2', 'dgn_price', 'quantity', 'total_price'];
|
|
|
+ const baseLedgerTreeSetting = {
|
|
|
+ id: 'ledger_id',
|
|
|
+ pid: 'ledger_pid',
|
|
|
+ order: 'order',
|
|
|
+ level: 'level',
|
|
|
+ rootId: -1,
|
|
|
+ fullPath: 'full_path',
|
|
|
+ calcFields: calcList,
|
|
|
+ };
|
|
|
+ // baseLedgerTreeSetting.updateFields = ['year_sj_qty', 'year_gather_tp', 'contract_qty', 'end_gather_qty', 'contract_tp', 'qc_qty', 'qc_tp', 'postil', 'used', 'contract_expr'];
|
|
|
+ baseLedgerTreeSetting.calcFun = function (node) {
|
|
|
+ node.dgn_price = ZhCalc.round(ZhCalc.div(node.total_price, node.dgn_qty1), 2);
|
|
|
+ };
|
|
|
+ const baseLedgerTree = createNewPathTree('base', baseLedgerTreeSetting);
|
|
|
+ console.log(data.slmList);
|
|
|
+ const newLedgerList = setGclMonthToLedger(data.ledgerData, data.slmList, data.nextSlmList, data.endSlmList, data.yearSlmList);
|
|
|
+ baseLedgerTree.loadDatas(newLedgerList);
|
|
|
+ treeCalc.calculateAll(baseLedgerTree);
|
|
|
+ huizongTree = createNewPathTree('filter', huizongTreeSetting);
|
|
|
+ for (const d of baseLedgerTree.nodes) {
|
|
|
+ if (!d.b_code) {
|
|
|
+ const one = _.find(selectedLedgerList, function (item) {
|
|
|
+ return item === d.ledger_id;
|
|
|
+ });
|
|
|
+ if (one) {
|
|
|
+ huizongTree.addData(d, showList);
|
|
|
}
|
|
|
}
|
|
|
- huizongTree.sortTreeNode(true);
|
|
|
- treeCalc.calculateAll(huizongTree);
|
|
|
- console.log(huizongTree);
|
|
|
- SpreadJsObj.loadSheetData(huizongSpread.getActiveSheet(), SpreadJsObj.DataType.Tree, huizongTree);
|
|
|
- }, null, true);
|
|
|
+ }
|
|
|
+ huizongTree.sortTreeNode(true);
|
|
|
+ treeCalc.calculateAll(huizongTree);
|
|
|
+ console.log(huizongTree);
|
|
|
+ SpreadJsObj.loadSheetData(huizongSpread.getActiveSheet(), SpreadJsObj.DataType.Tree, huizongTree);
|
|
|
+ // huizongSpread.refresh();
|
|
|
}, null, true);
|
|
|
+ },
|
|
|
+ dropDownHtml: function (order) {
|
|
|
+ let html = '';
|
|
|
+ for (const ss of gclScheduleMonth) {
|
|
|
+ if (ss.id !== order) {
|
|
|
+ html += '<a class="dropdown-item change-tp" data-order="'+ ss.id +'" href="javascript:void(0);">'+ ss.yearmonth.split('-')[0] + '年' + parseInt(ss.yearmonth.split('-')[1]) +'月</a>';
|
|
|
+ } else {
|
|
|
+ $('#stageDropdownMenuButton').text(ss.yearmonth.split('-')[0] + '年' + parseInt(ss.yearmonth.split('-')[1]) +'月');
|
|
|
+ }
|
|
|
+ }
|
|
|
+ $('#stageDropdownMenu').html(html);
|
|
|
}
|
|
|
};
|
|
|
|
|
|
- if (curScheduleStage && curScheduleStage.order) {
|
|
|
- huizongObj.setSjs(curScheduleStage.order);
|
|
|
+ if (curScheduleMonth && curScheduleMonth.id) {
|
|
|
+ let order = parseInt(localStorage.getItem('tender_' + getTenderId() + '_schedule_tp_sjs') ? localStorage.getItem('tender_' + getTenderId() + '_schedule_tp_sjs') : curScheduleMonth.id);
|
|
|
+ const ssinfo = _.find(gclScheduleMonth, { id: order });
|
|
|
+ if (!ssinfo) {
|
|
|
+ order = curScheduleMonth.id;
|
|
|
+ } else {
|
|
|
+ curScheduleMonth = ssinfo;
|
|
|
+ }
|
|
|
+ huizongObj.dropDownHtml(order);
|
|
|
+ huizongObj.setSjs(order);
|
|
|
}
|
|
|
|
|
|
// 汇总切换
|
|
|
$('body').on('click', '.change-tp', function () {
|
|
|
const order = parseInt($(this).data('order'));
|
|
|
- $('#dropdownMenuButton').text($(this).text());
|
|
|
- let html = '';
|
|
|
- for (const ss of scheduleStage) {
|
|
|
- if (ss.order !== order)
|
|
|
- html += '<a class="dropdown-item change-tp" data-order="'+ ss.order +'" href="javascript:void(0);">'+ ss.yearmonth.split('-')[0] + '年' + parseInt(ss.yearmonth.split('-')[1]) +'月(第'+ ss.order +'期)</a>';
|
|
|
- }
|
|
|
- $('.dropdown-menu').html(html);
|
|
|
+ huizongObj.dropDownHtml(order);
|
|
|
huizongObj.setSjs(order);
|
|
|
+ localStorage.setItem('tender_' + getTenderId() + '_schedule_tp_sjs', order);
|
|
|
+ curScheduleMonth = _.find(gclScheduleMonth, { id: order });
|
|
|
});
|
|
|
|
|
|
// 月份添加
|
|
@@ -441,6 +611,7 @@ $(function () {
|
|
|
}
|
|
|
const _self = $(this);
|
|
|
postData(window.location.pathname + '/save', {type: 'add_stage', postData: { id: id }}, function (result) {
|
|
|
+ localStorage.setItem('tender_' + getTenderId() + '_schedule_tp_sjs', id);
|
|
|
_self.addClass('disabled').attr('disabled', true);
|
|
|
toastr.success('创建成功');
|
|
|
setTimeout(function () {
|
|
@@ -475,6 +646,7 @@ $(function () {
|
|
|
}
|
|
|
const _self = $(this);
|
|
|
postData(window.location.pathname + '/save', {type: 'del_stage', postData: selectedMonth}, function (result) {
|
|
|
+ localStorage.removeItem('tender_' + getTenderId() + '_schedule_tp_sjs');
|
|
|
_self.addClass('disabled').attr('disabled', true);
|
|
|
toastr.success('删除成功');
|
|
|
setTimeout(function () {
|
|
@@ -541,13 +713,15 @@ function setMonthToLedger(ledgerList, slm) {
|
|
|
}
|
|
|
return ledgerList;
|
|
|
}
|
|
|
-function setTpMonthToLedger(ledgerList, slm, nextSlm, endSlm, yearSlm, yearLedgerData) {
|
|
|
+function setGclMonthToLedger(ledgerList, slm, nextSlm, endSlm, yearSlm) {
|
|
|
if (slm.length > 0) {
|
|
|
for(const s of slm) {
|
|
|
const index = _.findIndex(ledgerList, { 'ledger_id': s.lid });
|
|
|
if (index && index !== -1) {
|
|
|
ledgerList[index].plan_tp = s.plan_tp;
|
|
|
ledgerList[index].plan_gcl = s.plan_gcl;
|
|
|
+ ledgerList[index].sj_tp = s.sj_tp;
|
|
|
+ ledgerList[index].sj_gcl = s.sj_gcl;
|
|
|
}
|
|
|
}
|
|
|
}
|
|
@@ -566,6 +740,8 @@ function setTpMonthToLedger(ledgerList, slm, nextSlm, endSlm, yearSlm, yearLedge
|
|
|
if (index && index !== -1) {
|
|
|
ledgerList[index].end_plan_tp = es.plan_tp;
|
|
|
ledgerList[index].end_plan_gcl = es.plan_gcl;
|
|
|
+ ledgerList[index].end_sj_tp = es.sj_tp;
|
|
|
+ ledgerList[index].end_sj_gcl = es.sj_gcl;
|
|
|
}
|
|
|
}
|
|
|
}
|
|
@@ -575,15 +751,8 @@ function setTpMonthToLedger(ledgerList, slm, nextSlm, endSlm, yearSlm, yearLedge
|
|
|
if (index && index !== -1) {
|
|
|
ledgerList[index].year_plan_tp = ys.plan_tp;
|
|
|
ledgerList[index].year_plan_gcl = ys.plan_gcl;
|
|
|
- }
|
|
|
- }
|
|
|
- }
|
|
|
- if (yearLedgerData.length > 0) {
|
|
|
- for (const yl of yearLedgerData) {
|
|
|
- const index = _.findIndex(ledgerList, {'id': yl.lid});
|
|
|
- if (index && index !== -1) {
|
|
|
- ledgerList[index].year_contract_qty = ZhCalc.add(yl.contract_qty, yl.qc_qty);
|
|
|
- ledgerList[index].year_gather_tp = ZhCalc.add(yl.contract_tp, yl.qc_tp);
|
|
|
+ ledgerList[index].year_sj_tp = ys.sj_tp;
|
|
|
+ ledgerList[index].year_sj_gcl = ys.sj_gcl;
|
|
|
}
|
|
|
}
|
|
|
}
|