| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222 | 
							- BemsWebApplication.PartnerEstimateList = function (params, viewInfo) {
 
-     "use strict";
 
-     var imagefileUrl1 = ko.observable(),
 
-         imagefileUrl2 = ko.observable(),
 
-         uploadedFileInfo = {};
 
-     var eq = BWA.DataUtil.constructEqualFilter,
 
-         and = BWA.DataUtil.andFilter,
 
-         noteq = BWA.DataUtil.constructNotEqualFilter;
 
-     // 공사업체 데이터 소스...
 
-     var partnerDataSource = BemsWebApplication.db.createDataSource('CmPartner', true, false, true),
 
-         constructionTypeDataSource = BemsWebApplication.db.createDataSource('FmsConstructionCodeType', true, false, true);
 
-     var partners = ko.observableArray(),
 
-          constructionTypes = ko.observableArray();
 
-     var constructionTypesForSearch = ko.observableArray(),
 
-         partnerTypesForSearch = ko.observableArray();
 
-     var deferredForSearch = new $.Deferred();
 
-     var dataSourceOptions = {
 
-         select: [
 
-             'SiteId',
 
-             'ConstructionId',
 
-             'Name',
 
-             'StartDate',
 
-             'EndDate',
 
-             'PartnerId',
 
-             'ConstructionTypeId',
 
-             'ConstructLocation',
 
-             'OwnerShipName',
 
-             'CommitmentMan',
 
-             'OwnerShipPhoneNo',
 
-             'WeldWorkStartTime',
 
-             'WeldWorkEndTime',
 
-             'GasWorkStartTime',
 
-             'GasWorkEndTime',
 
-             'PaintWorkStartTime',
 
-             'PaintWorkEndTime',
 
-             'Comment',
 
-             'ProgressId',
 
-             'AddDate',
 
-             'UpdateDate',
 
-             'FmsConstructionCodeProgress/Name',
 
-             'CmPartner/Name',
 
-             'CmPartner/PhoneNo',
 
-             'FmsConstructionCodeType/Name',
 
-             'ConstructionDetail',
 
-             'InOutStockName',
 
-             'FileId1',
 
-             'FileId2',
 
-             'FileId3',
 
-             'CmFile/Name',
 
-             'CmFile1/Name',
 
-             'CmFile2/Name',
 
-             'FmsConstructionEstimation/Comment',
 
-             'FmsConstructionEstimation/SafetyScore',
 
-             'FmsConstructionEstimation/AbilityScore',
 
-             'FmsConstructionEstimation/ServiceScore',
 
-             'FmsConstructionEstimation/TotalEstimateScore',
 
-             'FmsConstructionEstimation/SafetyScore',
 
-             'FmsConstructionEstimation/AbilityScore',
 
-             'FmsConstructionEstimation/ServiceScore',
 
-             'FmsConstructionEstimation/TotalEstimateScore',
 
-         ],
 
-         expand: [
 
-             'FmsConstructionCodeProgress',
 
-             'CmPartner',
 
-             'FmsConstructionEstimation',
 
-             'FmsConstructionCodeType',
 
-             'CmFile',
 
-             'CmFile1',
 
-             'CmFile2'
 
-         ],
 
-         extendOptions: {
 
-             forceOriginalField: true
 
-         },
 
-         filter: [
 
-             eq('SiteId', BWA.UserInfo.SiteId()),
 
-             'and',
 
-             eq('ProgressId', 4)// 공사완료단계 항목 까지만 가져옴 
 
-         ]
 
-     };
 
-     var viewModel = BWA.DataGrid.createViewWithDataGrid(params, viewInfo, 'FmsConstruction', {
 
-         dataSourceOptions: dataSourceOptions,
 
-         columns: [
 
-             { dataField: 'Number', caption: $G('number'), width: '10%', alignment: 'center' },
 
-             { dataField: 'FmsConstructionCodeType/Name', caption: '공사구분', width: '20%', alignment: 'center' },
 
-             { dataField: 'Name', caption: '공사명', width: '60%', alignment: 'center' },
 
-             { dataField: 'CmPartner/Name', caption: '공사업체', width: '20%', alignment: 'center' },
 
-             { dataField: 'FmsConstructionEstimation/SafetyScore', caption: '안전수칙준수점수', width: '20%', alignment: 'center' },
 
-             { dataField: 'FmsConstructionEstimation/AbilityScore', caption: '공사수행능력점수', width: '20%', alignment: 'center' },
 
-             { dataField: 'FmsConstructionEstimation/ServiceScore', caption: '용역수행능력점수', width: '20%', alignment: 'center' },
 
-             { dataField: 'FmsConstructionEstimation/TotalEstimateScore', caption: '종합평가점수', width: '20%', alignment: 'center' },
 
-             { dataField: 'StartDate', caption: '시작일', width: '20%', alignment: 'center', sortOrder: 'desc' },
 
-             { dataField: 'EndDate', caption: '종료일', width: '20%', alignment: 'center' },
 
-         ],
 
-         popupWidth: '740px',
 
-         promiseDataInSearchView: deferredForSearch.promise(),
 
-         searchViewItems: [
 
-             { id: 'Name' },
 
-             { id: 'ConstructionTypeId', ignoreValue: 0, defaultValue: 0, dataSource: constructionTypesForSearch },
 
-             { id: 'PartnerId', ignoreValue: 0, defaultValue: 0, dataSource: partnerTypesForSearch },
 
-             { id: 'StartDate', type: 'dateRange', isOnlyDate: true },
 
-             { id: 'EndDate', type: 'dateRange', isOnlyDate: true }
 
-         ],
 
-         handleAfterLoadingModelByKey: function (data, dataViewModel, isNewInPopup) {
 
-             viewModel.visibleEditButton(false);
 
-             viewModel.visibleDeleteButton(false);
 
-             if (isNewInPopup() == false) {
 
-                 if (_.isNull(dataViewModel.FileId1()) === false) {
 
-                     imagefileUrl1('{0}/CmFile(SiteId={1},FileId={2})/$value'.formati(BWA.db._url, dataViewModel.SiteId(), dataViewModel.FileId1()));
 
-                 }
 
-                 else {
 
-                     imagefileUrl1(undefined);
 
-                 }
 
-                 if (_.isNull(dataViewModel.FileId2()) === false) {
 
-                     imagefileUrl2('{0}/CmFile(SiteId={1},FileId={2})/$value'.formati(BWA.db._url, dataViewModel.SiteId(), dataViewModel.FileId2()));
 
-                 }
 
-                 else {
 
-                     imagefileUrl2(undefined);
 
-                 }
 
-             }
 
-         },
 
-         handleDataGridRowClick: function (id, dataGrid, clickRow, popupVisible) {
 
-             dataGrid.clearSelection();
 
-             var data = clickRow.data;
 
-             var dataModel = viewModel.dataModel;
 
-             //dataModel.PartnerName = data['CmPartner/Name']();
 
-             //dataModel.PartnerPhoneNo = data['CmPartner/PhoneNo']();
 
-             dataModel.PartnerName = $KoSet(dataModel.PartnerName, data['CmPartner/Name']());
 
-             dataModel.PartnerPhoneNo = $KoSet(dataModel.PartnerPhoneNo, data['CmPartner/PhoneNo']());
 
-             dataModel.ConstructionTypeName = $KoSet(dataModel.ConstructionTypeName, data['FmsConstructionCodeType/Name']());
 
-             dataModel.EstimateComment = $KoSet(dataModel.EstimateComment, data['FmsConstructionEstimation/Comment']());
 
-             dataModel.EstimateSafetyScore = $KoSet(dataModel.EstimateSafetyScore, data['FmsConstructionEstimation/SafetyScore']());
 
-             dataModel.EstimateAbilityScore = $KoSet(dataModel.EstimateAbilityScore, data['FmsConstructionEstimation/AbilityScore']());
 
-             dataModel.EstimateServiceScore = $KoSet(dataModel.EstimateServiceScore, data['FmsConstructionEstimation/ServiceScore']());
 
-             dataModel.EstimateTotalEstimateScore = $KoSet(dataModel.EstimateTotalEstimateScore, data['FmsConstructionEstimation/TotalEstimateScore']());
 
-             if (data['FileId1']() != null)
 
-                 dataModel.AttachmentFileName1(data['CmFile/Name']());
 
-             else dataModel.AttachmentFileName1('');
 
-             if (data['FileId2']() != null)
 
-                 dataModel.AttachmentFileName2(data['CmFile1/Name']());
 
-             else dataModel.AttachmentFileName2('');
 
-             popupVisible(true);
 
-         },
 
-         handleViewShowing: function (dataModel) {
 
-             partnerDataSource.filter([
 
-                 eq('PartnerTypeId', 1), // 공사업체 유형 필터링
 
-                 and,
 
-                 eq('SiteId', BWA.UserInfo.SiteId())
 
-             ])
 
-             $.when(
 
-                 partnerDataSource.load(),
 
-                 constructionTypeDataSource.load()
 
-             )
 
-             .done(function (dbPartners, dbConstructions) {
 
-                 partners(dbPartners[0]);
 
-                 constructionTypes(dbConstructions[0]);
 
-                 constructionTypesForSearch($SearchView.createArrayOfSelectBox('ConstructionTypeId', constructionTypes()));
 
-                 partnerTypesForSearch($SearchView.createArrayOfSelectBox('PartnerId', partners()));
 
-                 deferredForSearch.resolve();
 
-             });
 
-         },
 
-         handlePopupShown: function (isEditMode, isNew, dataViewModel) {
 
-             var partners = viewModel.partners();
 
-             var constructionTypes = viewModel.constructionTypes();
 
-             if (isNew) { // 신규등록인 경우 
 
-                 dataViewModel.ProgressId(2); // 공사계획 상태를 '진행' 단계로 초기화
 
-                 dataViewModel.AddDate($G.date(new Date()));
 
-                 dataViewModel.UpdateDate($G.date(new Date()));
 
-                 if (!_.isEmpty(partners)) {
 
-                     dataViewModel.PartnerId(partners[0].PartnerId());
 
-                 }
 
-                 if (!_.isEmpty(constructionTypes)) {
 
-                     dataViewModel.ConstructionTypeId(constructionTypes[0].ConstructionTypeId());
 
-                 }
 
-             }
 
-         }
 
-     });
 
-     viewModel.imagefileUrl1 = imagefileUrl1;
 
-     viewModel.imagefileUrl2 = imagefileUrl2;
 
-     viewModel.constructionTypes = constructionTypes;
 
-     viewModel.partners = partners;
 
-     viewModel.dataModel.ConstructionTypeName = ko.observable();
 
-     viewModel.dataModel.PartnerName = ko.observable();
 
-     viewModel.dataModel.PartnerPhoneNo = ko.observable();
 
-     viewModel.dataModel.AttachmentFileName1 = ko.observable();
 
-     viewModel.dataModel.AttachmentFileName2 = ko.observable();
 
-     viewModel.dataModel.AttachmentFileName3 = ko.observable();
 
-     return viewModel;
 
- };
 
 
  |