8148f92ebf26ada09fff3404c5ebf467fc5d91d0.svn-base 9.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222
  1. BemsWebApplication.PartnerEstimateList = function (params, viewInfo) {
  2. "use strict";
  3. var imagefileUrl1 = ko.observable(),
  4. imagefileUrl2 = ko.observable(),
  5. uploadedFileInfo = {};
  6. var eq = BWA.DataUtil.constructEqualFilter,
  7. and = BWA.DataUtil.andFilter,
  8. noteq = BWA.DataUtil.constructNotEqualFilter;
  9. // 공사업체 데이터 소스...
  10. var partnerDataSource = BemsWebApplication.db.createDataSource('CmPartner', true, false, true),
  11. constructionTypeDataSource = BemsWebApplication.db.createDataSource('FmsConstructionCodeType', true, false, true);
  12. var partners = ko.observableArray(),
  13. constructionTypes = ko.observableArray();
  14. var constructionTypesForSearch = ko.observableArray(),
  15. partnerTypesForSearch = ko.observableArray();
  16. var deferredForSearch = new $.Deferred();
  17. var dataSourceOptions = {
  18. select: [
  19. 'SiteId',
  20. 'ConstructionId',
  21. 'Name',
  22. 'StartDate',
  23. 'EndDate',
  24. 'PartnerId',
  25. 'ConstructionTypeId',
  26. 'ConstructLocation',
  27. 'OwnerShipName',
  28. 'CommitmentMan',
  29. 'OwnerShipPhoneNo',
  30. 'WeldWorkStartTime',
  31. 'WeldWorkEndTime',
  32. 'GasWorkStartTime',
  33. 'GasWorkEndTime',
  34. 'PaintWorkStartTime',
  35. 'PaintWorkEndTime',
  36. 'Comment',
  37. 'ProgressId',
  38. 'AddDate',
  39. 'UpdateDate',
  40. 'FmsConstructionCodeProgress/Name',
  41. 'CmPartner/Name',
  42. 'CmPartner/PhoneNo',
  43. 'FmsConstructionCodeType/Name',
  44. 'ConstructionDetail',
  45. 'InOutStockName',
  46. 'FileId1',
  47. 'FileId2',
  48. 'FileId3',
  49. 'CmFile/Name',
  50. 'CmFile1/Name',
  51. 'CmFile2/Name',
  52. 'FmsConstructionEstimation/Comment',
  53. 'FmsConstructionEstimation/SafetyScore',
  54. 'FmsConstructionEstimation/AbilityScore',
  55. 'FmsConstructionEstimation/ServiceScore',
  56. 'FmsConstructionEstimation/TotalEstimateScore',
  57. 'FmsConstructionEstimation/SafetyScore',
  58. 'FmsConstructionEstimation/AbilityScore',
  59. 'FmsConstructionEstimation/ServiceScore',
  60. 'FmsConstructionEstimation/TotalEstimateScore',
  61. ],
  62. expand: [
  63. 'FmsConstructionCodeProgress',
  64. 'CmPartner',
  65. 'FmsConstructionEstimation',
  66. 'FmsConstructionCodeType',
  67. 'CmFile',
  68. 'CmFile1',
  69. 'CmFile2'
  70. ],
  71. extendOptions: {
  72. forceOriginalField: true
  73. },
  74. filter: [
  75. eq('SiteId', BWA.UserInfo.SiteId()),
  76. 'and',
  77. eq('ProgressId', 4)// 공사완료단계 항목 까지만 가져옴
  78. ]
  79. };
  80. var viewModel = BWA.DataGrid.createViewWithDataGrid(params, viewInfo, 'FmsConstruction', {
  81. dataSourceOptions: dataSourceOptions,
  82. columns: [
  83. { dataField: 'Number', caption: $G('number'), width: '10%', alignment: 'center' },
  84. { dataField: 'FmsConstructionCodeType/Name', caption: '공사구분', width: '20%', alignment: 'center' },
  85. { dataField: 'Name', caption: '공사명', width: '60%', alignment: 'center' },
  86. { dataField: 'CmPartner/Name', caption: '공사업체', width: '20%', alignment: 'center' },
  87. { dataField: 'FmsConstructionEstimation/SafetyScore', caption: '안전수칙준수점수', width: '20%', alignment: 'center' },
  88. { dataField: 'FmsConstructionEstimation/AbilityScore', caption: '공사수행능력점수', width: '20%', alignment: 'center' },
  89. { dataField: 'FmsConstructionEstimation/ServiceScore', caption: '용역수행능력점수', width: '20%', alignment: 'center' },
  90. { dataField: 'FmsConstructionEstimation/TotalEstimateScore', caption: '종합평가점수', width: '20%', alignment: 'center' },
  91. { dataField: 'StartDate', caption: '시작일', width: '20%', alignment: 'center', sortOrder: 'desc' },
  92. { dataField: 'EndDate', caption: '종료일', width: '20%', alignment: 'center' },
  93. ],
  94. popupWidth: '740px',
  95. promiseDataInSearchView: deferredForSearch.promise(),
  96. searchViewItems: [
  97. { id: 'Name' },
  98. { id: 'ConstructionTypeId', ignoreValue: 0, defaultValue: 0, dataSource: constructionTypesForSearch },
  99. { id: 'PartnerId', ignoreValue: 0, defaultValue: 0, dataSource: partnerTypesForSearch },
  100. { id: 'StartDate', type: 'dateRange', isOnlyDate: true },
  101. { id: 'EndDate', type: 'dateRange', isOnlyDate: true }
  102. ],
  103. handleAfterLoadingModelByKey: function (data, dataViewModel, isNewInPopup) {
  104. viewModel.visibleEditButton(false);
  105. viewModel.visibleDeleteButton(false);
  106. if (isNewInPopup() == false) {
  107. if (_.isNull(dataViewModel.FileId1()) === false) {
  108. imagefileUrl1('{0}/CmFile(SiteId={1},FileId={2})/$value'.formati(BWA.db._url, dataViewModel.SiteId(), dataViewModel.FileId1()));
  109. }
  110. else {
  111. imagefileUrl1(undefined);
  112. }
  113. if (_.isNull(dataViewModel.FileId2()) === false) {
  114. imagefileUrl2('{0}/CmFile(SiteId={1},FileId={2})/$value'.formati(BWA.db._url, dataViewModel.SiteId(), dataViewModel.FileId2()));
  115. }
  116. else {
  117. imagefileUrl2(undefined);
  118. }
  119. }
  120. },
  121. handleDataGridRowClick: function (id, dataGrid, clickRow, popupVisible) {
  122. dataGrid.clearSelection();
  123. var data = clickRow.data;
  124. var dataModel = viewModel.dataModel;
  125. //dataModel.PartnerName = data['CmPartner/Name']();
  126. //dataModel.PartnerPhoneNo = data['CmPartner/PhoneNo']();
  127. dataModel.PartnerName = $KoSet(dataModel.PartnerName, data['CmPartner/Name']());
  128. dataModel.PartnerPhoneNo = $KoSet(dataModel.PartnerPhoneNo, data['CmPartner/PhoneNo']());
  129. dataModel.ConstructionTypeName = $KoSet(dataModel.ConstructionTypeName, data['FmsConstructionCodeType/Name']());
  130. dataModel.EstimateComment = $KoSet(dataModel.EstimateComment, data['FmsConstructionEstimation/Comment']());
  131. dataModel.EstimateSafetyScore = $KoSet(dataModel.EstimateSafetyScore, data['FmsConstructionEstimation/SafetyScore']());
  132. dataModel.EstimateAbilityScore = $KoSet(dataModel.EstimateAbilityScore, data['FmsConstructionEstimation/AbilityScore']());
  133. dataModel.EstimateServiceScore = $KoSet(dataModel.EstimateServiceScore, data['FmsConstructionEstimation/ServiceScore']());
  134. dataModel.EstimateTotalEstimateScore = $KoSet(dataModel.EstimateTotalEstimateScore, data['FmsConstructionEstimation/TotalEstimateScore']());
  135. if (data['FileId1']() != null)
  136. dataModel.AttachmentFileName1(data['CmFile/Name']());
  137. else dataModel.AttachmentFileName1('');
  138. if (data['FileId2']() != null)
  139. dataModel.AttachmentFileName2(data['CmFile1/Name']());
  140. else dataModel.AttachmentFileName2('');
  141. popupVisible(true);
  142. },
  143. handleViewShowing: function (dataModel) {
  144. partnerDataSource.filter([
  145. eq('PartnerTypeId', 1), // 공사업체 유형 필터링
  146. and,
  147. eq('SiteId', BWA.UserInfo.SiteId())
  148. ])
  149. $.when(
  150. partnerDataSource.load(),
  151. constructionTypeDataSource.load()
  152. )
  153. .done(function (dbPartners, dbConstructions) {
  154. partners(dbPartners[0]);
  155. constructionTypes(dbConstructions[0]);
  156. constructionTypesForSearch($SearchView.createArrayOfSelectBox('ConstructionTypeId', constructionTypes()));
  157. partnerTypesForSearch($SearchView.createArrayOfSelectBox('PartnerId', partners()));
  158. deferredForSearch.resolve();
  159. });
  160. },
  161. handlePopupShown: function (isEditMode, isNew, dataViewModel) {
  162. var partners = viewModel.partners();
  163. var constructionTypes = viewModel.constructionTypes();
  164. if (isNew) { // 신규등록인 경우
  165. dataViewModel.ProgressId(2); // 공사계획 상태를 '진행' 단계로 초기화
  166. dataViewModel.AddDate($G.date(new Date()));
  167. dataViewModel.UpdateDate($G.date(new Date()));
  168. if (!_.isEmpty(partners)) {
  169. dataViewModel.PartnerId(partners[0].PartnerId());
  170. }
  171. if (!_.isEmpty(constructionTypes)) {
  172. dataViewModel.ConstructionTypeId(constructionTypes[0].ConstructionTypeId());
  173. }
  174. }
  175. }
  176. });
  177. viewModel.imagefileUrl1 = imagefileUrl1;
  178. viewModel.imagefileUrl2 = imagefileUrl2;
  179. viewModel.constructionTypes = constructionTypes;
  180. viewModel.partners = partners;
  181. viewModel.dataModel.ConstructionTypeName = ko.observable();
  182. viewModel.dataModel.PartnerName = ko.observable();
  183. viewModel.dataModel.PartnerPhoneNo = ko.observable();
  184. viewModel.dataModel.AttachmentFileName1 = ko.observable();
  185. viewModel.dataModel.AttachmentFileName2 = ko.observable();
  186. viewModel.dataModel.AttachmentFileName3 = ko.observable();
  187. return viewModel;
  188. };