| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206 | 
							- BemsWebApplication.BudgetPlan = function (params, viewInfo) {
 
-     'use strict';
 
-     var budgetPlanDataGridOptions,
 
-         modifiableBudgetPlanDataGridOptions = undefined
 
-     ;
 
-     var budgets = ko.observableArray(),
 
-         budgetsInView = ko.observableArray()
 
-     ;
 
-     var budgetGridView  = undefined;
 
-     var budgetCodeDataSource = BWA.DataUtil.createDataSource({
 
-         dataSourceOptions: {
 
-             paginate: false,
 
-             store: BemsWebApplication.odata.FmsBudgetCodeClassEx,
 
-             select: [
 
-                 'FirstBudgetClassId',
 
-                 'SecondBudgetClassId',
 
-                 'ThirdBudgetClassId',
 
-                 'FirstBudgetName',
 
-                 'SecondBudgetName',
 
-                 'ThirdBudgetName',
 
-                 'YearlyBudget',
 
-                 'MonthlyBudget',
 
-                 'FirstBudgetNameWithSum',
 
-                 'SecondBudgetNameWithSum',
 
-             ],
 
-         },
 
-     });
 
-     modifiableBudgetPlanDataGridOptions = utils.datagrid.defaultOptions({
 
-         //pager: {
 
-         //    showPageSizeSelector: false,
 
-         //    allowedPageSizes: []
 
-         //},
 
-         //pager: {
 
-         //    allowedPageSizes: false,
 
-         //},
 
-         //paging: {
 
-         //    enabled: false
 
-         //},
 
-         dataSource: budgetsInView,
 
-         columns: [
 
-             { dataField: 'FirstBudgetNameWithSum', caption: '대분류' , width: '1%', alignment: 'center', groupIndex: 0 },
 
-             { dataField: 'SecondBudgetNameWithSum', caption: '중분류', width: '1%', alignment: 'center', groupIndex: 1 },
 
-             { dataField: 'ThirdBudgetName', caption: '소분류', width: '50%', alignment: 'center', allowEditing: false },
 
-             {
 
-                 dataField: 'YearlyBudget', caption: '연간예산', alignment: 'center'
 
-                 , cellTemplate: utils.datagrid.getNumberBoxDataGridTemplateFunc({
 
-                     min: 0,
 
-                     max: Number.MAX_SAFE_INTEGER,
 
-                     //max: 100000000,
 
-                     dataField: 'YearlyBudget'
 
-                     , convertValueWhenValueChanged: function (data, value) {
 
-                         var monthlyValue = value / 12;
 
-                         data.MonthlyBudget(monthlyValue);
 
-                         reCalculateSummaryValue();
 
-                         return Math.max(0, value);
 
-                     }
 
-                 })
 
-             },
 
-             {
 
-                 dataField: 'MonthlyBudget', caption: '월간예산', alignment: 'center'
 
-                 , cellTemplate: utils.datagrid.getNumberBoxDataGridTemplateFunc({
 
-                     min: 0,
 
-                     max: Number.MAX_SAFE_INTEGER,
 
-                     //max: 100000000,
 
-                     dataField: 'MonthlyBudget'
 
-                     , convertValueWhenValueChanged: function (data, value) {
 
-                         var yearlyValue = value * 12;
 
-                         data.YearlyBudget(yearlyValue);
 
-                         reCalculateSummaryValue();
 
-                         return Math.max(0, value);
 
-                     }
 
-                 })
 
-             },
 
-         ],
 
-         cellClick: function (e) {
 
-             if(e.column.dataField === 'YearlyBudget' || e.column.dataField === 'MonthlyBudget' ){
 
-                 utils.datagrid.cellClickEventForDataGridTemplate(e, e.column.dataField);
 
-             }
 
-         },
 
-       
 
-         contentReadyAction: function (e) {
 
-             budgetGridView = e.component;
 
-         },
 
-     });
 
-     var dataSourceOptions = {
 
-         select: [
 
-             'SiteId',
 
-             'Year',
 
-         ],
 
-         expand: [
 
-             'FmsBudgetDetail',
 
-             'FmsBudgetDetail/FmsBudgetCodeClass', // FirstBudgetClass
 
-             'FmsBudgetDetail/FmsBudgetCodeClass1', // SecondBudgetClass
 
-             'FmsBudgetDetail/FmsBudgetCodeClass2', // ThridBudgetClass
 
-         ],
 
-         extendOptions: {
 
-             forceOriginalField: true
 
-         },
 
-         filter: [
 
-             ['SiteId', '=', BWA.UserInfo.SiteId()]
 
-         ]
 
-     };
 
-     var viewModel = BWA.DataGrid.createViewWithDataGrid(params, viewInfo, 'FmsBudget', {
 
-         dataSourceOptions: dataSourceOptions,
 
-         columns: [
 
-             { dataField: 'Year', caption: $G('year'), width: '100%', alignment: 'center', allowFiltering: false, sortOrder: 'desc' },
 
-         ],
 
-         //searchViewItems: [{ id: 'Name' }],
 
-         handleViewShowing: function (dataModel) {
 
-             $.when(
 
-                 budgetCodeDataSource.load()
 
-             ).done(function (budgetCodeResult) {
 
-                 budgetsInView(budgetCodeResult);
 
-             });
 
-             viewModel.popupOptions.position = { offset: '0, -200' };
 
-         },
 
-         handlePopupShowing: function (isNewInPopup, dataViewModel) {
 
-             //if (isNewInPopup()) { // 신규등록인 경우 
 
-             //    // UI 에는별도로 표시하지 않음
 
-             //    dataViewModel.PartnerTypeId(1);
 
-             //}
 
-         },
 
-     });
 
-     function reCalculateSummaryValue() {
 
-         // budgetsInView
 
-         var firstCodeList = _.keys(_.countBy(budgetsInView(), function (data) { return data.FirstBudgetClassId(); }));
 
-         var secondCodeList = _.keys(_.countBy(budgetsInView(), function (data) { return data.SecondBudgetClassId(); }));
 
-         //var firstCodeData = [];
 
-         //var secondCodeData = [];
 
-         var firstCodeYearlySumValue = 0;
 
-         var firstCodeMonthlySumValue = 0;
 
-         var secondCodeYearlySumValue = 0;
 
-         var secondCodeMonthlySumValue = 0;
 
-         // 1차 코드에 대한 계산 
 
-         _.each(firstCodeList, function (x) {
 
-             _.each(budgetsInView(), function (b) {
 
-                 if (x == b.FirstBudgetClassId()) {
 
-                     firstCodeYearlySumValue += b.YearlyBudget();
 
-                     firstCodeMonthlySumValue += b.MonthlyBudget();
 
-                 }
 
-             });
 
-             //firstCodeData.push({
 
-             //    FirstBudgetClassId: x,
 
-             //    YearlyBudgetSum: firstCodeYearlySumValue,
 
-             //    MonthlyBudgetSum: firstCodeMonthlySumValue
 
-             //});
 
-             _.each(budgetsInView(), function (b) {
 
-                 if (x == b.FirstBudgetClassId()) {
 
-                     b.FirstBudgetNameWithSum(b.FirstBudgetName() + '( 년간: \\' + firstCodeYearlySumValue + ') / (월간: \\' + firstCodeMonthlySumValue + ') ');
 
-                 }
 
-             });
 
-             firstCodeYearlySumValue = 0;
 
-             firstCodeMonthlySumValue = 0;
 
-         });
 
-         // 2차 코드에 대한 계산 
 
-         _.each(secondCodeList, function (x) {
 
-             _.each(budgetsInView(), function (b) {
 
-                 if (x == b.SecondBudgetClassId()) {
 
-                     secondCodeYearlySumValue += b.YearlyBudget();
 
-                     secondCodeMonthlySumValue += b.MonthlyBudget();
 
-                 }
 
-             });
 
-             _.each(budgetsInView(), function (b) {
 
-                 if (x == b.SecondBudgetClassId()) {
 
-                     b.SecondBudgetNameWithSum(b.SecondBudgetName() + '(년간: \\' + secondCodeYearlySumValue + ') / (월간: \\' + secondCodeMonthlySumValue + ') ');
 
-                 }
 
-             });
 
-             secondCodeYearlySumValue = 0;
 
-             secondCodeMonthlySumValue = 0;
 
-         });
 
-    
 
-         budgetGridView.refresh();
 
-     }
 
-     // viewModel.budgetPlanDataGridOptions = budgetPlanDataGridOptions;
 
-     viewModel.modifiableBudgetPlanDataGridOptions = modifiableBudgetPlanDataGridOptions;
 
-     
 
-     return viewModel;
 
- };
 
 
  |