|
@@ -351,13 +351,53 @@ $(function () {
|
|
|
// 进度计算方式选择
|
|
|
$('.mode-select').on('click', function () {
|
|
|
const _self = $(this);
|
|
|
- postData(window.location.pathname + '/save', {type: 'mode', postData: $(this).data('mode')}, function (result) {
|
|
|
+ const this_mode = _self.data('mode');
|
|
|
+ // 重新计算所有月份数据
|
|
|
+ const under_ledger = _.filter(ledgerTree.nodes, { is_leaf: true});
|
|
|
+ const update_nodes = [];
|
|
|
+ for (const ul of under_ledger) {
|
|
|
+ for (const m of monthList) {
|
|
|
+ if (ul[m+'_tp'] || ul[m+'_gcl']) {
|
|
|
+ update_nodes.push(ul);
|
|
|
+ break;
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+ const update_under_ledger = [];
|
|
|
+ if(update_nodes.length > 0) {
|
|
|
+ for (const un of update_nodes) {
|
|
|
+ if (this_mode === mode.gcl) {
|
|
|
+ for (const m of monthList) {
|
|
|
+ if(un[m+'_tp']) {
|
|
|
+ un[m+'_tp'] = un.dgn_price && un.dgn_price !== 0 ? ZhCalc.round(ZhCalc.mul(un[m+'_gcl'], un.dgn_price), 0) : 0;
|
|
|
+ update_under_ledger.push({lid: un.ledger_id, yearmonth: m, plan_tp: un[m+'_tp'], plan_gcl: un[m+'_gcl']});
|
|
|
+ }
|
|
|
+ }
|
|
|
+ } else {
|
|
|
+ for (const m of monthList) {
|
|
|
+ if(un[m+'_gcl']) {
|
|
|
+ un[m+'_gcl'] = un.dgn_price && un.dgn_price !== 0 ? ZhCalc.round(ZhCalc.div(un[m+'_tp'], un.dgn_price), 3) : 0;
|
|
|
+ update_under_ledger.push({lid: un.ledger_id, yearmonth: m, plan_tp: un[m+'_tp'], plan_gcl: un[m+'_gcl']});
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+ 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.parents('.col-6').siblings('.col-6').find('button').removeClass('disabled').removeAttr('disabled');
|
|
|
$('#mode-tips').show();
|
|
|
$('#mode-cancel').show();
|
|
|
$('#mode').modal('hide');
|
|
|
- schedule.mode = _self.data('mode');
|
|
|
+ schedule.mode = this_mode;
|
|
|
+ if (update_nodes.length > 0) {
|
|
|
+ for (const uul of update_nodes) {
|
|
|
+ const nodes = treeCalc.calculateParent(ledgerSpread.getActiveSheet().zh_tree, uul);
|
|
|
+ const refreshNode = ledgerTree.loadPostData({update: nodes});
|
|
|
+ ledgerSpreadObj.refreshTree(ledgerSpread.getActiveSheet(), refreshNode);
|
|
|
+ }
|
|
|
+ }
|
|
|
SpreadJsObj.reLoadSheetData(ledgerSpread.getActiveSheet());
|
|
|
})
|
|
|
});
|