08a29a006feca9062462d05db3b4568dc10aabe3.svn-base 4.0 KB

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