74c9ee5e2ee30cdfa19e99024c24e3317a2caaf3.svn-base 7.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215
  1. BemsWebApplication.WorkList = function (params, viewInfo) {
  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 popup;
  10. var deferredForSearch = new $.Deferred();
  11. var workTypesForSearch = ko.observableArray(),
  12. businessFieldsForSearch = ko.observableArray(),
  13. progressesForSearch = ko.observableArray();
  14. var eq = BWA.DataUtil.constructEqualFilter,
  15. and = BWA.DataUtil.andFilter,
  16. noteq = BWA.DataUtil.constructNotEqualFilter;
  17. var selectedFacilityData = ko.observable(),
  18. selectedUserData = params.selectedUserData || ko.observable();
  19. var dataSourceOptions = {
  20. select: [
  21. 'SiteId', 'WorkRequestId',
  22. 'FmsWorkRequest/WorkTypeId', 'Title', 'OrderDate', 'FmsWorkRequest/WorkProgressId',
  23. 'CmUser/Name', // 작업지시자
  24. //'CmUser1/Name', // 반려자
  25. 'FmsWorkRequest/FmsWorkCodeType/Name',
  26. 'CmBusinessField/Name',
  27. 'FmsWorkRequest/FmsWorkCodeProgress/Name'
  28. ],
  29. expand: [
  30. 'FmsWorkRequest',
  31. 'FmsWorkRequest/FmsWorkCodeType',
  32. 'FmsWorkRequest/FmsWorkCodeProgress',
  33. 'CmBusinessField', 'CmUser'],
  34. //expand: ['FmsWorkCodeType', 'CmBusinessField', 'FmsWorkCodeProgress', 'CmUser', 'CmUser1'],
  35. extendOptions: {
  36. forceOriginalField: true
  37. },
  38. filter: [
  39. eq('SiteId', BWA.UserInfo.SiteId()),
  40. and,
  41. ['FmsWorkRequest/WorkProgressId', '>=', 3]
  42. ]
  43. };
  44. var viewModel = BWA.DataGrid.createViewWithDataGrid(params, viewInfo, 'FmsWorkOrder', {
  45. popupWidth: 1200,
  46. dataSourceOptions: dataSourceOptions,
  47. columns: [
  48. { dataField: 'WorkRequestId', caption: $G('number'), width: '8%', alignment: 'center' },
  49. {
  50. dataField: 'OrderDate', caption: $G('orderedDate'), width: '12%', alignment: 'center',visible:false,
  51. customizeText: function (cellInfo) {
  52. return $G.date(cellInfo.value);
  53. }
  54. },
  55. { dataField: 'FmsWorkRequest/FmsWorkCodeProgress/Name', caption: $G('workProgressName'), width: '10%', alignment: 'center' },
  56. { dataField: 'FmsWorkRequest/FmsWorkCodeType/Name', caption: $G('workTypeName'), width: '10%', alignment: 'center' },
  57. { dataField: 'CmBusinessField/Name', caption: $G('businessFieldName'), width: '10%', alignment: 'center' },
  58. { dataField: 'Title', caption: '작업명', width: '35%', alignment: 'center' },
  59. { dataField: 'CmUser/Name', caption: '작업지시자', width: '15%', alignment: 'center' }
  60. ],
  61. promiseDataInSearchView: deferredForSearch.promise(),
  62. //searchViewItems: _.compact([
  63. // executionPlanViewOptions ? null : { id: 'BusinessFieldId', ignoreValue: 0, defaultValue: 0, dataSource: businessFieldsForSearch },
  64. // executionPlanViewOptions ? null : { id: 'WorkTypeId', ignoreValue: 0, defaultValue: 0, dataSource: workTypesForSearch },
  65. // { id: 'CmUser/Name' },
  66. // { id: 'Title' },
  67. // { id: 'WorkProgressId', ignoreValue: 0, defaultValue: 0, dataSource: progressesForSearch },
  68. // { id: 'RequestDate', type: 'dateRange' }
  69. //]),
  70. getAddedToolbarItemsInPopup: function (e) {
  71. var isEditModeInPopup = e.isEditModeInPopup;
  72. return [{
  73. location: 'after', widget: 'button', options: {
  74. text: $G('facilityInsertion'), icon: 'search', visible: isEditModeInPopup,
  75. clickAction: function () {
  76. popup.facilitySearchPopup.show();
  77. }
  78. }
  79. },
  80. {
  81. location: 'after', widget: 'button', options: {
  82. text: $G('facilityDeletion'), icon: 'remove', type: 'danger', visible: isEditModeInPopup,
  83. clickAction: function () {
  84. if (popup && popup.handleDeleteSelectedFacilities) {
  85. popup.handleDeleteSelectedFacilities();
  86. }
  87. }
  88. }
  89. }];
  90. },
  91. beforeInsertingDataViewModel: function (dataModel) {
  92. //if (popup && popup.beforeInsertingDataViewModel) {
  93. // popup.beforeInsertingDataViewModel();
  94. //}
  95. //dataModel.ProgressId($Code.WorkProgress.WORK_PLAN);
  96. //dataModel.RequestDate(new Date());
  97. return true;
  98. },
  99. handleDataGridRowClick: function (id, dataGrid, clickRow, popupVisible) {
  100. dataGrid.clearSelection();
  101. var data = clickRow.data;
  102. var dataModel = viewModel.dataModel;
  103. if (popup && popup.handleBeforeShowingPopupForEdit) {
  104. popup.handleBeforeShowingPopupForEdit(data, dataModel);
  105. }
  106. popupVisible(true);
  107. },
  108. handleBeforePopupShowingPromise: function () {
  109. if (popup && popup.handleBeforePopupShowingPromise) {
  110. popup.handleBeforePopupShowingPromise.apply(popup, arguments);
  111. }
  112. },
  113. handleAfterLoadingModelByKey: function () {
  114. if (popup && popup.handleAfterLoadingModelByKey) {
  115. popup.handleAfterLoadingModelByKey.apply(popup, arguments);
  116. }
  117. },
  118. handlePopupShowing: function () {
  119. if (popup && popup.handlePopupShowing) {
  120. //viewModel.toolbarItems[4].options.visible = false;
  121. popup.handlePopupShowing.apply(this, arguments);
  122. }
  123. },
  124. handlePopupShown: function (editMode, isNewInPopup, dataModel) {
  125. if (popup && popup.handlePopupShowing) {
  126. popup.handlePopupShown.apply(this, arguments);
  127. }
  128. },
  129. handleSaveButtonInPopup: function (isInsert) {
  130. if (isInsert === false) {
  131. if (popup && popup.handleAfterSave) {
  132. popup.handleAfterSave(undefined);
  133. }
  134. }
  135. },
  136. handleAfterSaveInPopup: function (responseKey, response) {
  137. if (popup && popup.handleAfterSave) {
  138. popup.handleAfterSave(responseKey, response);
  139. }
  140. },
  141. handleViewShowing: function (dataModel) {
  142. $.when(
  143. businessFieldDataSource.load(),
  144. workTypeDataSource.load(),
  145. progressDataSource.load()
  146. ).done(function (businessFieldResult, workTypeResult, progressResult) {
  147. businessFields(businessFieldResult[0]);
  148. workTypes(workTypeResult[0]);
  149. progresses(progressResult[0]);
  150. businessFieldsForSearch($SearchView.createArrayOfSelectBox('BusinessFieldId', businessFields()));
  151. workTypesForSearch($SearchView.createArrayOfSelectBox('WorkTypeId', workTypes()));
  152. progressesForSearch($SearchView.createArrayOfSelectBox('ProgressId', progresses()));
  153. deferredForSearch.resolve();
  154. });
  155. },
  156. handleViewShown: function () {
  157. }
  158. });
  159. viewModel.businessFields = businessFields;
  160. viewModel.workTypes = workTypes;
  161. popup = viewModel.popup = BWA.Popup.WorkList.create(viewInfo, viewModel);
  162. //popup = viewModel.popup = BWA.Popup.WorkList.create(viewModel, params);
  163. return viewModel;
  164. };