11d33227e238bf5a87aaa6f9288ce604fa6862ba.svn-base 4.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152
  1. $(function () {
  2. 'use strict';
  3. BWA.Popup.PurchaseOrderSearch = BWA.Popup.PurchaseOrderSearch || {};
  4. BWA.Popup.PurchaseOrderSearch.create = function (viewModel, options) {
  5. options = options || {};
  6. options.datagridId = options.datagridId ||
  7. 'purchaseOrderDataGridForSearch';
  8. var onSelectedPurchaseOrder = options.onSelectedPurchaseOrder;
  9. var dataViewModel = new BemsWebApplication.FmsMaterialPurchaseOrderViewModel(),
  10. initialized = false,
  11. gridView,
  12. popupVisible = ko.observable(false),
  13. purchaseOrderFactory = BemsWebApplication.Factory.PurchaseOrder,
  14. dataSource = BWA.DataUtil.createDataSource({
  15. dataSourceOptions: purchaseOrderFactory.getDataSourceForDataGrid()
  16. }, 'FmsMaterialPurchaseOrder');
  17. options.filter.push('and');
  18. options.filter.push(['FmsMaterialPurchaseRequest/ProgressId', '=', 3]);
  19. dataSource.filter(options.filter);
  20. var dataGridOptions = utils.datagrid.defaultOptions({
  21. dxDataSource: dataSource,
  22. selectedSourceItem: dataViewModel,
  23. datagridId: options.datagridId,
  24. dbId: 'FmsPurchaseOrder',
  25. handleDataGridRowClick: function () {
  26. },
  27. columns: purchaseOrderFactory.getColumns([
  28. { dataField: 'PurchaseOrderId', width: '15%' },
  29. { dataField: 'OrderDate', width: '20%' },
  30. { dataField: 'Title', width: '60%' },
  31. { dataField: 'CmUser/Name', caption: '발주자명', width: '15%' }
  32. ]),
  33. height: 560,
  34. paging: {
  35. pageSize: 15,
  36. enabled: true
  37. },
  38. pager: {
  39. allowedPageSizes: false,
  40. visible: true
  41. },
  42. wordWrapEnabled: true
  43. });
  44. dataGridOptions.handleDataGridRowClick = function (id, dataGrid, clickRow) {
  45. var data = clickRow.data;
  46. if (!_.isUndefined(onSelectedPurchaseOrder)) {
  47. onSelectedPurchaseOrder({
  48. SiteId: data.SiteId(),
  49. BusinessFieldId: data.BusinessFieldId(),
  50. PurchaseOrderId: data.PurchaseOrderId(),
  51. Title: data.Title(),
  52. Reason: data.Reason() // hcLee 2016 01 11
  53. });
  54. }
  55. popupVisible(false);
  56. };
  57. function handlePopupShown() {
  58. if (initialized === false) {
  59. gridView = $('#purchaseOrderDataGridForSearch').dxDataGrid('instance');
  60. initialized = true;
  61. }
  62. gridView.refresh();
  63. // refreshList();
  64. searchView.show();
  65. }
  66. function handlePopupButtonClose() {
  67. popupVisible(false);
  68. }
  69. var toolbarItems = [
  70. { location: 'before', text: '발주등록 선택' },
  71. { location: 'after', widget: 'button', options: { text: $G('close'), icon: 'close', clickAction: handlePopupButtonClose } }
  72. ];
  73. var popupOptions = {
  74. width: '680px',
  75. height: '600px',
  76. visible: popupVisible,
  77. closeOnOutsideClick: true,
  78. //showingAction: handlePopupShowing,
  79. shownAction: handlePopupShown,
  80. animation: window.utils.popup.createAnimation(),
  81. };
  82. var searchView = BWA.Popup.SearchView.create({
  83. parentPopupId: 'popupSearchPurchaseOrder',
  84. parentPopupVisible: popupVisible,
  85. searchItems: [
  86. { id: 'OrderDate', type: 'dateRange', isOnlyDate: true },
  87. { id: 'Title' },
  88. { id: 'CmUser/Name' },
  89. { id: 'FmsMaterial/Name', filterFormatString: 'FmsMaterialPurchaseOrderMaterial/any(c: substringof(\'{0}\', c/FmsMaterial/Name))', type: 'formatting' },
  90. ],
  91. handleInitializeUpdate: function () {
  92. },
  93. handleSearch: function (filter, searchItems) {
  94. var eq = BWA.DataUtil.constructEqualFilter;
  95. var and = BWA.DataUtil.andFilter;
  96. filter = [
  97. eq('SiteId', BWA.UserInfo.SiteId()),
  98. and,
  99. ['FmsMaterialPurchaseRequest/ProgressId', '=', 3]
  100. ].concat(filter);
  101. gridView.filter(filter);
  102. // console.log(filter);
  103. }
  104. });
  105. return {
  106. dataModel: dataViewModel,
  107. dataSource: dataSource,
  108. popupOptions: popupOptions,
  109. toolbarItems: toolbarItems,
  110. dataGridOptions: dataGridOptions,
  111. searchView: searchView,
  112. show: function () {
  113. popupVisible(true);
  114. }
  115. };
  116. };
  117. });