7bdfc0c9293f0763b965e352a4ea206fe47922bb.svn-base 5.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145
  1. $PatrolPosSearchPopup = function (viewModel, selectPatrolPosData, isMultipleSelect, onSelectedPatrolPoss, datagridId) {
  2. //isMultipleSelect 추가 hcLee 2016 02 15
  3. var isMultipleSelect = isMultipleSelect;
  4. // 멀티선택기능 추가 hcLee2016 02 15
  5. //var onSelectedUsers = options.onSelectedUsers;
  6. var onSelectedPatrolPoss = onSelectedPatrolPoss;
  7. var datagridId = datagridId;
  8. var dataViewModel = new BemsWebApplication.CmPatrolPosViewModel(),
  9. gridView,
  10. popupVisible = ko.observable(false),
  11. dataSource;
  12. // _Name 작업을 original로 수정해야 한다.
  13. dataSource = BWA.DataUtil.createDataSource({
  14. dataSourceOptions: {
  15. select: ['SiteId',
  16. 'BuildingId',
  17. 'FloorId',
  18. 'PosId',
  19. 'Name',
  20. 'TagId',
  21. 'PosDesc',
  22. 'CmBuilding/Name',
  23. 'CmFloor/Name',
  24. ],
  25. expand: ["CmBuilding", "CmFloor"],
  26. extendOptions: { forceOriginalField: true },
  27. filter: [
  28. ['SiteId', '=', BWA.UserInfo.SiteId()]
  29. ]
  30. }
  31. }, 'CmPatrolPos');
  32. var dataGridOptions = utils.datagrid.defaultOptions({
  33. dxDataSource: dataSource,
  34. selectedSourceItem: dataViewModel,
  35. datagridId: 'gridPatrolPosContainer',
  36. dbId: 'CmPatrolPos',
  37. useNumberColumn: true,
  38. columns: [
  39. { dataField: 'PosId', caption: $G('number'), width: '10%', alignment: 'center', allowFiltering: false },
  40. // { dataField: 'UserId', caption: $G('userId'), width: '15%', alignment: 'center' },
  41. { dataField: 'Name', caption: '순찰지점명', width: '35%', alignment: 'center' },
  42. { dataField: 'CmBuilding/Name', caption: '빌딩', width: '20%', alignment: 'center' },
  43. { dataField: 'CmFloor/Name', caption: '층', width: '20%', alignment: 'center' },
  44. { dataField: 'TagId', caption: 'TagId', width: '30%', alignment: 'center' },
  45. ],
  46. searchPanelPlaceHolder: '순찰지점 검색',
  47. paging: {
  48. pageSize: 11,
  49. enabled: true
  50. },
  51. pager: { visible: true }
  52. });
  53. if (isMultipleSelect) {
  54. dataGridOptions.selection = { mode: 'multiple', allowSelectAll: true };
  55. dataGridOptions.handleDataGridRowClick = function (id, dataGrid, clickRow) {
  56. /*
  57. var data = clickRow.data;
  58. if (!_.isUndefined(onSelectedUsers)) {
  59. onSelectedUsers([BWA.DataUtil.convertViewModelToJS(data)]);
  60. }*/
  61. };
  62. }
  63. else {
  64. /*
  65. dataGridOptions.handleDataGridRowClick = function (id, dataGrid, clickRow) {
  66. var data = clickRow.data;
  67. selectUserData({
  68. SiteId: data.SiteId(),
  69. UserId: data.UserId(),
  70. CompanyId: data.CompanyId(),
  71. DepartmentId: data.DepartmentId(),
  72. CompanyName: data.CmCompany_Name(),
  73. MobilePhoneNo: data.MobilePhoneNo(),
  74. Name: data.Name()
  75. });
  76. if (data.CmDepartment_Name !== undefined)
  77. selectUserData.DepartmentName = data.CmDepartment_Name();
  78. popupVisible(false);
  79. }*/
  80. }
  81. function handlePopupShowing(e) {
  82. gridView = $('#gridPatrolPosContainer').dxDataGrid('instance');
  83. }
  84. function handlePopupShown() {
  85. }
  86. function handlePopupButtonSelect() {
  87. var array = utils.datagrid.getSelectedRowsData('gridPatrolPosContainer');
  88. if (!_.isUndefined(onSelectedPatrolPoss)) {
  89. onSelectedPatrolPoss(array);
  90. }
  91. $('#gridPatrolPosContainer').dxDataGrid('instance').clearSelection();
  92. popupVisible(false);
  93. }
  94. function handlePopupButtonClose() {
  95. $('#gridPatrolPosContainer').dxDataGrid('instance').clearSelection();
  96. popupVisible(false);
  97. }
  98. var toolbarItems = [
  99. { location: 'before', text: '찾기' },
  100. { location: 'after', widget: 'button', options: { text: $G('select'), icon: 'save', visible: isMultipleSelect, clickAction: handlePopupButtonSelect } },
  101. { location: 'after', widget: 'button', options: { text: $G('close'), icon: 'close', clickAction: handlePopupButtonClose } }
  102. ];
  103. var popupOptions = {
  104. width: isMultipleSelect ? '800px' : '600px',
  105. height: 'auto',
  106. visible: popupVisible,
  107. closeOnOutsideClick: true,
  108. shading: false,
  109. showingAction: handlePopupShowing,
  110. shownAction: handlePopupShown,
  111. animation: {
  112. show: { type: "pop", duration: 200, from: { opacity: 1, scale: 0.4 }, to: { scale: 1 } },
  113. hide: { type: "fade", duration: 200, from: 1, to: 0 }
  114. }
  115. };
  116. return {
  117. dataModel: dataViewModel,
  118. dataSource: dataSource,
  119. popupOptions: popupOptions,
  120. toolbarItems: toolbarItems,
  121. dataGridOptions: dataGridOptions,
  122. show: function () {
  123. popupVisible(true);
  124. }
  125. };
  126. }