123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778 |
- BemsWebApplication.ConstructionCodeType = function (params, viewInfo) {
- "use strict";
- var FmsConstructionCodeTypeDataSource = BemsWebApplication.db.createDataSource('FmsConstructionCodeType');
- var ConstructionCodeType = ko.observableArray();
- var RowName;
- var viewModel = BWA.DataGrid.createViewWithDataGrid(params, viewInfo, 'FmsConstructionCodeType', {
- columns: [
- { dataField: 'ConstructionTypeId', caption: $G('number'), width: '20%', alignment: 'center', sortOrder:'desc' },
- { dataField: 'Name', caption: $G('constructionTypeName'), width: '80%', alignment: 'center' },
- ],
- popupWidth: 480,
- searchViewItems: [{ id: 'Name' }],
- handleViewShown: function () {
- },
- // 이름 중복 방지
- handlePopupShowing: function () {
- //2015 11 12 hcLee 필터추가
- FmsConstructionCodeTypeDataSource.filter([
- ['SiteId', '=', BWA.UserInfo.SiteId()]
- ]);
- FmsConstructionCodeTypeDataSource.load().done(function (result) {
- ConstructionCodeType(result);
- });
- },
- handleDataGridRowClick: function (id, dataGrid, clickRow, popupVisible) {
- var data = clickRow.data;
- var dataModel = viewModel.dataModel;
- RowName = data.Name;
- popupVisible(true);
- },
- beforeInsertingDataViewModel: function (dataModel, dbModelId) {
- var dfd = $.Deferred();
- var isDuplicated = false;
- for (var i = 0; i < ConstructionCodeType().length; i++) {
- if (dataModel.Name() == ConstructionCodeType()[i].Name()) {
- isDuplicated = true;
- }
- }
- if (!BWA.DataUtil.isValidInputValue(dataModel.Name()))
- return dfd.resolve(false, '저장 혹은 수정 반드시 필수 입력 정보를 모두 입력하셔야 합니다 (앞뒤공백 허용안함)');
- else {
- if (isDuplicated)
- return dfd.resolve(false, '이미 동일 이름이 존재합니다.');
- else
- return dfd.resolve(true);
- }
- },
- beforeUpdateDataViewModel: function () {
- var isDuplicated = false;
- for (var i = 0; i < ConstructionCodeType().length; i++) {
- if (viewModel.dataModel.Name() == ConstructionCodeType()[i].Name() && RowName() != ConstructionCodeType()[i].Name()) {
- isDuplicated = true;
- }
- }
- if (!BWA.DataUtil.isValidInputValue(viewModel.dataModel.Name())) {
- utils.toast.show('저장 혹은 수정 반드시 필수 입력 정보를 모두 입력하셔야 합니다 (앞뒤공백 허용안함)', 'error');
- return 0;
- }
- else {
- if (isDuplicated) {
- utils.toast.show('이미 동일 이름이 존재합니다.', 'error');
- return 0;
- }
- else
- return 2;
- }
- }
- });
- return viewModel;
- };
|