f2c151b1308db96de3c3162f60447edbb988352d.svn-base 9.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235
  1. BemsWebApplication.CivilComplaint = function (params, viewInfo, executionPlanOptions) {
  2. "use strict";
  3. var businessFieldDataSource = BemsWebApplication.db.createDataSource('CmBusinessField', true, true, true),
  4. workTypeDataSource = BemsWebApplication.db.createDataSource('FmsWorkCodeType'),
  5. progressDataSource = BemsWebApplication.db.createDataSource('FmsWorkCodeProgress'),
  6. businessFields = ko.observableArray(),
  7. workTypes = ko.observableArray(),
  8. progresses = ko.observableArray();
  9. var deferredForSearch = new $.Deferred();
  10. var workTypesForSearch = ko.observableArray(),
  11. businessFieldsForSearch = ko.observableArray(),
  12. progressesForSearch = ko.observableArray();
  13. var SiteId = BWA.UserInfo.SiteId();
  14. var popup;
  15. var eq = BWA.DataUtil.constructEqualFilter,
  16. and = BWA.DataUtil.andFilter,
  17. or = BWA.DataUtil.orFilter,
  18. noteq = BWA.DataUtil.constructNotEqualFilter;
  19. var workTypeId = $Code.WorkType.CIVIL_COMPLAINT;
  20. var executionPlanViewOptions = undefined,
  21. executionPlanPopupOptions = undefined;
  22. if (executionPlanOptions) {
  23. executionPlanViewOptions = executionPlanOptions.viewOptions;
  24. executionPlanPopupOptions = executionPlanOptions.popupOptions;
  25. }
  26. var selectedFacilityData = ko.observable(),
  27. selectedUserData = params.selectedUserData || ko.observable();
  28. var dataSourceOptions = {
  29. select: [
  30. 'SiteId', 'WorkRequestId', 'WorkTypeId', 'Title', 'RequestDate', 'WorkProgressId', 'StartWorkDate',
  31. 'CmUser/Name', // 신청자
  32. 'CmUser1/Name', // 반려자
  33. 'FmsWorkCodeType/Name', 'CmBusinessField/Name', 'FmsWorkCodeProgress/Name',
  34. 'FmsWorkSchedule/IsUse'
  35. ],
  36. expand: ['FmsWorkCodeType', 'CmBusinessField', 'FmsWorkCodeProgress', 'CmUser', 'CmUser1', 'FmsWorkSchedule'],
  37. extendOptions: {
  38. forceOriginalField: true
  39. }
  40. };
  41. if (_.isUndefined(executionPlanViewOptions)) {
  42. dataSourceOptions.filter = [
  43. eq('SiteId', SiteId),
  44. and,
  45. eq('WorkTypeId', $Code.WorkType.CIVIL_COMPLAINT)
  46. ];
  47. }
  48. else {
  49. // 시설관리 > 실행계획조회 화면에서는 작업계획 상태만 가져옴
  50. dataSourceOptions.filter = [
  51. eq('SiteId', SiteId),
  52. and,
  53. eq('WorkProgressId', $Code.WorkProgress.WORK_PLAN),
  54. and,
  55. [("WorkTypeId", "<=", $Code.WorkType.LEGAL_CHECK, and, eq('FmsWorkSchedule/IsUse', true)),
  56. or,
  57. ["WorkTypeId", ">", $Code.WorkType.LEGAL_CHECK]]
  58. ];
  59. }
  60. var viewModel = BWA.DataGrid.createViewWithDataGrid(params, viewInfo, 'FmsWorkRequest', {
  61. popupWidth: 1200,
  62. dataSourceOptions: dataSourceOptions,
  63. columns: [
  64. { dataField: 'WorkRequestId', caption: $G('number'), width: '8%', alignment: 'center' },
  65. { dataField: 'CmBusinessField/Name', caption: $G('businessFieldName'), width: '10%', alignment: 'center' },
  66. { dataField: 'FmsWorkCodeProgress/Name', caption: $G('workProgressName'), width: '10%', alignment: 'center', visible: false },
  67. { dataField: 'FmsWorkCodeType/Name', caption: $G('workTypeName'), width: '10%', alignment: 'center' },
  68. { dataField: 'Title', caption: '작업명', width: '45%', alignment: 'center' },
  69. {
  70. dataField: 'StartWorkDate', caption: '작업예정일', width: '12%', alignment: 'center', sortOrder: 'asc',
  71. customizeText: function (cellInfo) {
  72. return $G.date(cellInfo.value);
  73. }
  74. },
  75. { dataField: 'CmUser/Name', caption: $G('requesterName'), width: '15%', alignment: 'center' }
  76. ],
  77. promiseDataInSearchView: deferredForSearch.promise(),
  78. searchViewItems: _.compact([
  79. { id: 'WorkProgressId', ignoreValue: 0, defaultValue: 0, dataSource: progressesForSearch },
  80. { id: 'WorkTypeId', ignoreValue: 0, defaultValue: 0, dataSource: workTypesForSearch },
  81. { id: 'Title' },
  82. { id: 'CmUser/Name' },
  83. { id: 'BusinessFieldId', ignoreValue: 0, defaultValue: 0, dataSource: businessFieldsForSearch },
  84. { id: 'StartWorkDate', type: 'dateRange', isOnlyDate: true }
  85. ]),
  86. handleDataGridRowClick: function (id, dataGrid, clickRow, popupVisible) {
  87. dataGrid.clearSelection();
  88. var data = clickRow.data;
  89. var dataModel = viewModel.dataModel;
  90. // 정기, 법정인 경우는 반려가 안보이게 2016 06 16 hcLee
  91. if (!_.isUndefined(viewModel.executionPlanPopupOptions)) {
  92. if (data.WorkTypeId() < 3)
  93. viewModel.executionPlanPopupOptions.isVisibleRejectButtons(false);
  94. else
  95. viewModel.executionPlanPopupOptions.isVisibleRejectButtons(true);
  96. }
  97. if (popup && popup.handleBeforeShowingPopupForEdit) {
  98. popup.handleBeforeShowingPopupForEdit(data, dataModel);
  99. }
  100. popupVisible(true);
  101. },
  102. handleBeforePopupShowingPromise: function () {
  103. if (popup && popup.handleBeforePopupShowingPromise) {
  104. popup.handleBeforePopupShowingPromise.apply(popup, arguments);
  105. }
  106. },
  107. handleAfterLoadingModelByKey: function () {
  108. if (popup && popup.handleAfterLoadingModelByKey) {
  109. popup.handleAfterLoadingModelByKey.apply(popup, arguments);
  110. }
  111. },
  112. handlePopupShowing: function () {
  113. if (popup && popup.handlePopupShowing) {
  114. popup.handlePopupShowing.apply(this, arguments);
  115. }
  116. },
  117. handlePopupShown: function (editMode, isNewInPopup, dataModel) {
  118. if (popup && popup.handlePopupShown) {
  119. popup.handlePopupShown.apply(this, arguments);
  120. }
  121. },
  122. handleSaveButtonInPopup: function (isInsert) {
  123. if (isInsert === false) {
  124. if (popup && popup.handleAfterSave) {
  125. popup.handleAfterSave(undefined);
  126. }
  127. }
  128. },
  129. handleAfterSaveInPopup: function (responseKey, response) {
  130. if (popup && popup.handleAfterSave) {
  131. popup.handleAfterSave(responseKey, response);
  132. }
  133. },
  134. getAddedToolbarItemsInPopup: function (e) {
  135. var isEditModeInPopup = e.isEditModeInPopup;
  136. var addedTooolbarItems = [
  137. {
  138. location: 'after', widget: 'button', options: {
  139. text: $G('facilityInsertion'), icon: 'search', visible: isEditModeInPopup,
  140. clickAction: function () { popup.facilitySearchPopup.show(); }
  141. }
  142. },
  143. {
  144. location: 'after', widget: 'button', options: {
  145. text: $G('facilityDeletion'), icon: 'remove', type: 'danger', visible: isEditModeInPopup,
  146. clickAction: function () {
  147. if (popup && popup.handleDeleteSelectedFacilities) { popup.handleDeleteSelectedFacilities(); }
  148. }
  149. }
  150. }];
  151. // 실행계획조회 인 경우 툴바아이템 추가
  152. if (!_.isUndefined(executionPlanPopupOptions)) {
  153. var executionToolbarItems = executionPlanPopupOptions.getAddedToolbarItemsInPopup(e);
  154. var resultToolbarItems = addedTooolbarItems.concat(executionToolbarItems);
  155. return resultToolbarItems;
  156. }
  157. return addedTooolbarItems;
  158. },
  159. beforeInsertingDataViewModel: function (dataModel) {
  160. //if (popup && popup.beforeInsertingDataViewModel) {
  161. // popup.beforeInsertingDataViewModel();
  162. //}
  163. //dataModel.ProgressId($Code.WorkProgress.WORK_PLAN);
  164. //dataModel.RequestDate(new Date());
  165. return true; // hcLee 2015 11 30
  166. },
  167. handleViewShowing: function (dataModel) {
  168. var useBusinessFiltering = BWA.UserInfo.isDependBusinessField(viewInfo.viewName)
  169. if (useBusinessFiltering) {
  170. dataSourceOptions.filter.push('and');
  171. dataSourceOptions.filter.push([eq('BusinessFieldId', BWA.UserInfo.BusinessFieldId()), 'or', eq('BusinessFieldId', 1)]);
  172. businessFieldDataSource.filter([
  173. eq('SiteId', SiteId),
  174. and,
  175. [eq('BusinessFieldId', BWA.UserInfo.BusinessFieldId()), 'or', eq('BusinessFieldId', 1)]
  176. ]);
  177. }
  178. $.when(
  179. businessFieldDataSource.load(),
  180. workTypeDataSource.load(),
  181. progressDataSource.load()
  182. ).done(function (businessFieldResult, workTypeResult, progressResult) {
  183. businessFields(businessFieldResult[0]);
  184. workTypes(workTypeResult[0]);
  185. progresses(progressResult[0]);
  186. businessFieldsForSearch($SearchView.createArrayOfSelectBox('BusinessFieldId', businessFields()));
  187. workTypesForSearch($SearchView.createArrayOfSelectBox('WorkTypeId', workTypes()));
  188. progressesForSearch($SearchView.createArrayOfSelectBox('ProgressId', progresses()));
  189. deferredForSearch.resolve();
  190. });
  191. },
  192. handleViewShown: function () {
  193. }
  194. });
  195. viewModel.businessFields = businessFields;
  196. viewModel.workTypes = workTypes;
  197. viewModel.executionPlanViewOptions = executionPlanViewOptions;
  198. viewModel.executionPlanPopupOptions = executionPlanPopupOptions; // hcLee 2016 06 16
  199. popup = viewModel.popup = BWA.Popup.CivilComplaint.create(viewInfo, viewModel, executionPlanPopupOptions);
  200. return viewModel;
  201. };