cf6a7f03c7bf5f0bb2cd95268033e6f970dcb397.svn-base 2.9 KB

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