829d92b4b15ce448213064c5d2ff1ff01de3492e.svn-base 4.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127
  1. $(function () {
  2. 'use strict';
  3. BWA.Popup.BudgetExecute = BWA.Popup.BudgetExecute || {};
  4. BWA.Popup.BudgetExecute.create = function (viewModel, options) {
  5. options = options || {};
  6. var onSelectedBudgets = options.onSelectedBudgets;
  7. var popupVisible = ko.observable(false);
  8. var budgetDataSource = BWA.DataUtil.createDataSource({
  9. dataSourceOptions: {
  10. store: BemsWebApplication.odata.FmsBudgetDetailExecutionEx,
  11. select: ['SiteId', 'Year', 'Month']
  12. }
  13. });
  14. var selectedYear = ko.observable();
  15. var selectedMonth = ko.observable();
  16. var dataViewModel = new BemsWebApplication.FmsBudgetViewModel(),
  17. initialized = false,
  18. gridView;
  19. //
  20. // equipmentFactory = BemsWebApplication.Factory.Equipment,
  21. // dataSource = BWA.DataUtil.createDataSource({ dataSourceOptions: equipmentFactory.getDataSourceForDataGrid() }, 'FmsEquipmentEx');
  22. var eq = BWA.DataUtil.constructEqualFilter,
  23. and = BWA.DataUtil.andFilter;
  24. // 자재 검색시 나타나는 팝업은 공통 및 자신이 포함된 비즈니스 영역만 해당됨
  25. var userInfo = BWA.UserInfo;
  26. var dataGridOptions = utils.datagrid.defaultOptions({
  27. pager: {
  28. showPageSizeSelector: false,
  29. allowedPageSizes: []
  30. },
  31. dxDataSource: budgetDataSource,
  32. // 아래들이 동작하지 않음
  33. selectedSourceItem: dataViewModel,
  34. handleDataGridRowClick: function () {
  35. },
  36. columns: [
  37. { dataField: 'Year', caption: 'Year', alignment: 'center', sortOrder: 'desc' },
  38. { dataField: 'Month', caption: 'Month', alignment: 'center', sortOrder: 'desc' },
  39. ],
  40. wordWrapEnabled: true
  41. // cellPrepared: BemsWebApplication.Factory.Equipment.cellPrepared
  42. });
  43. dataGridOptions.handleDataGridRowClick = function (id, dataGrid, clickRow) {
  44. var data = clickRow.data;
  45. if (!_.isUndefined(onSelectedBudgets)) {
  46. onSelectedBudgets([BWA.DataUtil.convertViewModelToJS(data)]);
  47. }
  48. popupVisible(false);
  49. }
  50. var toolbarItems = [
  51. { location: 'before', text: '실적등록 월 선택' },
  52. { location: 'after', widget: 'button', options: { text: $G('select'), icon: 'save', clickAction: handlePopupButtonSelect } }, //, visible: isMultipleSelect,
  53. { location: 'after', widget: 'button', options: { text: $G('close'), icon: 'close', clickAction: handlePopupButtonClose } } //
  54. ];
  55. var popupOptions = {
  56. width: '400px',
  57. height: 'auto',
  58. visible: popupVisible,
  59. closeOnOutsideClick: true,
  60. //showingAction: handlePopupShowing,
  61. shownAction: handlePopupShown,
  62. animation: window.utils.popup.createAnimation()
  63. };
  64. function handlePopupShown() {
  65. if (initialized === false) {
  66. gridView = $('#budgetDataGridForYear').dxDataGrid('instance');
  67. initialized = true;
  68. }
  69. gridView.clearSelection();
  70. gridView.refresh();
  71. }
  72. function handlePopupButtonSelect() {
  73. //dataViewModel = gridView.getSelectedRowsData()[0];
  74. //selectedYear = dataViewModel.Year();
  75. //popupVisible(false);
  76. var array = gridView.getSelectedRowsData()[0];
  77. if (!_.isUndefined(onSelectedBudgets)) {
  78. onSelectedBudgets(array);
  79. }
  80. popupVisible(false);
  81. }
  82. function handlePopupButtonClose() {
  83. popupVisible(false);
  84. }
  85. return {
  86. dataModel: dataViewModel,
  87. //dataSource: dataSource,
  88. selectedYear: selectedYear,
  89. selectedMonth: selectedMonth,
  90. popupOptions: popupOptions,
  91. toolbarItems: toolbarItems,
  92. dataGridOptions: dataGridOptions,
  93. popupVisible: popupVisible,
  94. onSelectedBudgets:onSelectedBudgets, // hcLee 2015 12 09
  95. show: function () {
  96. popupVisible(true);
  97. }
  98. };
  99. };
  100. });