f95108375e36cfbdd2e253ec7df857464df13b5c.svn-base 6.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194
  1. 
  2. $(function () {
  3. 'use strict';
  4. BemsWebApplication.Popup.WorkApprovalMaterial = {
  5. create: function (viewInfo, viewModel) {
  6. var overlayVisible = ko.observable(false),
  7. position = ko.observable(),
  8. timer = null
  9. ;
  10. var materialGridView2 = ko.observable();
  11. var materials2 = ko.observableArray();
  12. var materialFactory2 = BWA.Factory.Material;
  13. var materialColumns2 = materialFactory2.getColumns([
  14. { dataField: 'MaterialCode', width: '30%' , visible:false},
  15. { dataField: 'Standard', width: '40%' },
  16. { dataField: 'Name', width: '40%' }
  17. ]);
  18. var materials2DataSource = BemsWebApplication.db.createDataSource('FmsWorkResultCheckItemMaterial', true, true, false);
  19. var modifiableMaterialDataGridOptions2 = null;
  20. overlayVisible.subscribe(function (value) {
  21. if (value) {
  22. if (timer !== null) {
  23. clearInterval(timer);
  24. }
  25. var top, left;
  26. //var element = $('#popupWorkContentsDetail').offsetParent();
  27. var element = $('#currentWorkpopupDetail').offsetParent();
  28. position({ my: 'left top', at: 'right top', of: element });
  29. timer = setInterval(function () {
  30. var offset = element.offset();
  31. if (top !== offset.top || left !== offset.left) {
  32. top = offset.top;
  33. left = offset.left;
  34. position({ my: 'left top', at: 'right top', of: element });
  35. }
  36. }, 100);
  37. }
  38. else {
  39. if (timer !== null) {
  40. clearInterval(timer);
  41. timer = null;
  42. }
  43. }
  44. });
  45. position.subscribe(function (value) {
  46. });
  47. viewModel.popupVisible.subscribe(function (value) {
  48. if (value === false) {
  49. overlayVisible(false);
  50. }
  51. //workProgressDataSource.load().done(function (result) {
  52. // progresses(result);
  53. //});
  54. });
  55. viewModel.workResultContentsViewOptions = {
  56. width: '530px',
  57. height: '538px',
  58. dragEnabled: false,
  59. position: position,
  60. visible: overlayVisible,
  61. showingAction: function () {
  62. },
  63. closeOnOutsideClick: false,
  64. shading: false,
  65. animation: {
  66. show: { type: "slide", duration: 150, from: { left: '-=10', opacity: 0 }, to: { opacity: 1 } },
  67. hide: { type: "slide", duration: 150, from: { left: '-=10', opacity: 1 }, to: { opacity: 0 } }
  68. }
  69. };
  70. //var popup = e.component;
  71. viewModel.toolbarItemsInWorkResult = [
  72. { location: 'before', text: '자재사용내역' },
  73. {
  74. location: 'after', widget: 'button', options: {
  75. text: $G('materialInsertion'), icon: 'search',
  76. clickAction: function () {
  77. viewModel.isAddPopup(false);
  78. viewModel.materialSearchPopup.show();
  79. }
  80. }
  81. },
  82. {
  83. location: 'after', widget: 'button', options: {
  84. text: $G('materialDeletion'), icon: 'remove', type: 'danger',
  85. clickAction: function () { handleDeleteSelectedMaterials(); }
  86. }
  87. },
  88. {
  89. location: 'after', widget: 'button', options: {
  90. text: $G('save'), icon: 'save',
  91. clickAction: function () {
  92. saveApprovalMaterials();
  93. }
  94. }
  95. }
  96. ];
  97. modifiableMaterialDataGridOptions2 = utils.datagrid.defaultOptions({
  98. width: 500,
  99. pager: {
  100. showPageSizeSelector: false,
  101. allowedPageSizes: []
  102. },
  103. // visible: viewModel.isEditModeInPopup,
  104. dataSource: materials2,
  105. selection: { mode: 'multiple', allowSelectAll: true },
  106. columns: materialColumns2.concat([{
  107. dataField: 'MaterialCount', width: '20%', type: 'number',
  108. caption: $G('materialCount'), alignment: 'center',
  109. cellTemplate: utils.datagrid.getNumberBoxDataGridTemplateFunc({
  110. min: 1,
  111. max: 1000000,
  112. dataField: 'MaterialCount',
  113. convertValueWhenValueChanged: function (value) {
  114. return Math.max(1, value);
  115. }
  116. })
  117. }]),
  118. cellClick: function (e) {
  119. utils.datagrid.cellClickEventForDataGridTemplate(e, 'MaterialCount');
  120. },
  121. contentReadyAction: function (e) {
  122. materialGridView2(e.component);
  123. },
  124. });
  125. function handleDeleteSelectedMaterials() {
  126. var rows = materialGridView2().getSelectedRowsData();
  127. if (_.isEmpty(rows)) {
  128. utils.toast.show('선택된 자재가 없습니다.', 'error');
  129. return;
  130. }
  131. _.each(rows, function (row) {
  132. var array = materials2();
  133. var length = array.length;
  134. var id = row.MaterialId();
  135. for (var i = 0 ; i < length ; i++) {
  136. if (id === array[i].MaterialId()) {
  137. materials2().splice(i, 1);
  138. break;
  139. }
  140. }
  141. });
  142. materialGridView2().refresh();
  143. }
  144. function saveApprovalMaterials() {
  145. utils.toast.show('자재수정클릭');
  146. }
  147. return {
  148. visible: overlayVisible,
  149. materials2: materials2,
  150. materialGridView2: materialGridView2,
  151. materials2DataSource: materials2DataSource,
  152. modifiableMaterialDataGridOptions2: modifiableMaterialDataGridOptions2
  153. };
  154. }
  155. }
  156. });