ed0fbd9fe3e229066188389175f7cfc0dede2bfd.svn-base 3.0 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980
  1. BemsWebApplication.Position = function( params, viewInfo ) {
  2. "use strict";
  3. var PositionInfo = ko.observableArray();
  4. var CmPositionDataSource = BemsWebApplication.db.createDataSource('CmPosition');
  5. var RowName;
  6. var viewModel = BWA.DataGrid.createViewWithDataGrid( params, viewInfo, 'CmPosition', {
  7. columns: [
  8. { dataField: 'PositionId', caption: $G( 'number' ), width: '20%', alignment: 'center' , sortOrder: 'desc'},
  9. { dataField: 'Name', caption: $G( 'positionName' ), width: '60%', alignment: 'center' },
  10. utils.datagrid.columnIsUse( '20%' )
  11. ],
  12. popupWidth: 480,
  13. NoSearchView: true, // 2019.07.25 kgpark 검색버튼 삭제
  14. handleDataGridRowClick: function (id, dataGrid, clickRow, popupVisible) {
  15. dataGrid.clearSelection();
  16. var data = clickRow.data;
  17. RowName = data.Name;
  18. popupVisible(true);
  19. },
  20. // 이름 중복 방지
  21. handlePopupShowing: function () {
  22. CmPositionDataSource.filter([
  23. ["SiteId", "=", BWA.UserInfo.SiteId()]
  24. ]);
  25. CmPositionDataSource.load().done(function (result) {
  26. PositionInfo(result);
  27. });
  28. },
  29. beforeInsertingDataViewModel: function (dataModel, dbModelId) {
  30. var dfd = $.Deferred();
  31. var isDuplicated = false;
  32. for (var i = 0; i < PositionInfo().length; i++) {
  33. if (dataModel.Name() == PositionInfo()[i].Name()) {
  34. isDuplicated = true;
  35. }
  36. }
  37. if (!BWA.DataUtil.isValidInputValue(dataModel.Name()))
  38. return dfd.resolve(false, '저장 혹은 수정 반드시 필수 입력 정보를 모두 입력하셔야 합니다 (앞뒤공백 허용안함)');
  39. else {
  40. if (isDuplicated)
  41. return dfd.resolve(false, '이미 동일 이름이 존재합니다.');
  42. else
  43. return dfd.resolve(true);
  44. }
  45. },
  46. beforeUpdateDataViewModel: function () {
  47. var isDuplicated = false;
  48. for (var i = 0; i < PositionInfo().length; i++) {
  49. if (viewModel.dataModel.Name() == PositionInfo()[i].Name() && RowName() != PositionInfo()[i].Name()) {
  50. isDuplicated = true;
  51. }
  52. }
  53. if (!BWA.DataUtil.isValidInputValue(viewModel.dataModel.Name())) {
  54. utils.toast.show('저장 혹은 수정 반드시 필수 입력 정보를 모두 입력하셔야 합니다 (앞뒤공백 허용안함)', 'error');
  55. return 0;
  56. }
  57. else {
  58. if (isDuplicated) {
  59. utils.toast.show('이미 동일 이름이 존재합니다.', 'error');
  60. return 0;
  61. }
  62. else
  63. return 2;
  64. }
  65. }
  66. });
  67. return viewModel;
  68. };