166baeaad7f6f9f48274ce751ded713b80ceb5d9.svn-base 3.1 KB

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