| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420 | 
							- BemsWebApplication.Manual = function (params, viewInfo) {
 
-     "use strict";
 
-     //2019-11-25 변경
 
-     var dropZone = null;
 
-     var eq = BWA.DataUtil.constructEqualFilter;
 
-     var and = BWA.DataUtil.andFilter;
 
-     var drawingHistory;
 
-     var historyViewModel = new BemsWebApplication.FmsManualHistoryViewModel();
 
-     var endpointSelector = "";
 
-     if (BemsWebApplication.config.mode == "production") {
 
-         endpointSelector = new DevExpress.EndpointSelector(BemsWebApplication.config.endpoints).config.db.production;
 
-     } else {
 
-         endpointSelector = new DevExpress.EndpointSelector(BemsWebApplication.config.endpoints).config.db.local;
 
-     }
 
-     //2019-11-25 변경
 
-     //drawingGroupDataSource = BemsWebApplication.db.createDataSource('FmsDrawingCodeGroup', true),
 
-     var drawingTypeDataSource = BemsWebApplication.db.createDataSource('FmsManualType', true),
 
-         drawingHistoryDataSource = BemsWebApplication.DataUtil.createDataSource({
 
-             dataSourceOptions: {
 
-                 select: [
 
-                     'SiteId', 'ManualId', 'HistoryId', 'FileId', 'Description', 'RevisionNo',
 
-                     'UpdatedDate', 'UpdatedUserId',
 
-                     'CmFile/Name', 'CmFile/FileSize', 'CmUser/Name'
 
-                 ],
 
-                 expand: ['CmFile', 'CmUser'],
 
-                 extendOptions: {
 
-                     forceOriginalField: true
 
-                 }
 
-             }
 
-         }, 'FmsManualHistory');
 
-     var drawingHistories = ko.observableArray(),
 
-         //drawingGroups = ko.observableArray(),
 
-         drawingTypes = ko.observableArray(),
 
-         //drawingGroupsForSearch = ko.observableArray(),
 
-         drawingTypesForSearch = ko.observableArray(),
 
-         tabsVisible = ko.observable(false),
 
-         textAreaNoteHeightInPopup = ko.observable(),
 
-         isVisibleHistoryInsertButton = ko.observable(false),
 
-         uploadedFileInfo = {},
 
-         drawingHistoryPopup,
 
-         deferredForSearch = new $.Deferred();
 
-     params.popupPosition = { offset: '-200 0' };
 
-     var viewModel = BWA.DataGrid.createViewWithDataGrid(params, viewInfo, 'FmsManual', {
 
-         popupWidth: 720,
 
-         dataSourceOptions: {
 
-             select: [
 
-                 'SiteId', 'ManualId', 'ManualNo', 'Name', 'ManualTypeId',
 
-                 'FmsManualType/Name', 'Description'
 
-             ],
 
-             expand: ['FmsManualType'],
 
-             extendOptions: {
 
-                 forceOriginalField: true
 
-             }
 
-         },
 
-         columns: [
 
-             { dataField: 'ManualId', caption: '번호', width: '10%', alignment: 'center', sortOrder: 'desc' },
 
-             { dataField: 'FmsManualType/Name', caption: '매뉴얼 유형', width: '15%', alignment: 'center' },
 
-             { dataField: 'ManualNo', caption: '매뉴얼 번호', width: '25%', alignment: 'center' },
 
-             { dataField: 'Name', caption: '매뉴얼 명', width: '35%', alignment: 'center' }
 
-         ],
 
-         searchViewItems: [
 
-             { id: 'ManualTypeId', ignoreValue: 0, defaultValue: 0, dataSource: drawingTypesForSearch },
 
-             { id: 'Name' }
 
-         ],
 
-         getAddedToolbarItemsInPopup: function (e) {
 
-             var isEditModeInPopup = e.isEditModeInPopup,
 
-                 hasnotModificationPermission = e.hasnotModificationPermission;
 
-             isEditModeInPopup.subscribe(function (isEditMode) {
 
-                 tabIndex(0); // 왼쪽 수정은 무조건 매뉴얼 hcLee 2016 03 24추가
 
-                 //isVisibleHistoryInsertButton(tabIndex() === 1 && isEditMode);
 
-             });
 
-             return [
 
-                 {
 
-                     location: 'after',
 
-                     widget: 'button',
 
-                     options: {
 
-                         text: '매뉴얼이력추가',
 
-                         icon: 'plus',
 
-                         visible: isVisibleHistoryInsertButton,
 
-                         disabled: hasnotModificationPermission,
 
-                         clickAction: function () {
 
-                             drawingHistoryPopup.handleInsertDrawingHistory();
 
-                         }
 
-                     }
 
-                 },
 
-             ]
 
-         },
 
-         promiseDataInSearchView: deferredForSearch.promise(),
 
-         handlePopupShowing: function (isNewInPopup) {
 
-             tabIndex(0);
 
-             tabsVisible(isNewInPopup() == false);
 
-         },
 
-         // hcLee 2016 03 28
 
-         beforeInsertingDataViewModel: function (dataModel, dbModelId) {
 
-             var dfd = $.Deferred();
 
-             if (BWA.DataUtil.isValidInputValue(dataModel.ManualTypeId()) == false ||
 
-                 BWA.DataUtil.isValidInputValue(dataModel.ManualNo()) == false ||
 
-                 BWA.DataUtil.isValidInputValue(dataModel.Name()) == false ||
 
-                 manualFileUpload.dropzone.files.length == 0)//2019-11-25 변경
 
-                 dfd.resolve(false, '(*) 표시 항목은 필수 입력 사항 입니다!');
 
-             return dfd.resolve(true);
 
-         },
 
-         beforeUpdateDataViewModel: function () {
 
-             var dataModel = viewModel.dataModel;
 
-             if (BWA.DataUtil.isValidInputValue(dataModel.ManualTypeId()) == false ||
 
-                 BWA.DataUtil.isValidInputValue(dataModel.ManualNo()) == false ||
 
-                 BWA.DataUtil.isValidInputValue(dataModel.Name()) == false) {
 
-                 utils.toast.show('(*) 표시 항목은 필수 입력 사항 입니다!', 'error');
 
-                 return 0;
 
-             }
 
-             return 2; // 2016 01 19 BaseClass 에서 update한다.
 
-         },
 
-         handleAfterSaveInPopup: function (responseKey) {
 
-             var fileId = uploadedFileInfo.FileId;
 
-             if (_.isUndefined(fileId)) return;
 
-             var dataViewModel = viewModel.dataModel;//2019-11-25 변경
 
-             drawingHistory = new BWA.FmsManualHistoryViewModel();
 
-             drawingHistory.SiteId(responseKey.SiteId);
 
-             drawingHistory.ManualId(responseKey.ManualId);
 
-             drawingHistory.FileId(fileId);
 
-             drawingHistory.RevisionNo(0); // 2016 03 28 hcLee 추가
 
-             drawingHistory.UpdatedDate(new Date());
 
-             drawingHistory.UpdatedUserId(BWA.UserInfo.UserId());
 
-             
 
-             //2019-11-25 변경
 
-             if (viewModel.isNewInPopup() === false) {//추가, 변경 여부
 
-                 if (_.isNull(dropZone) === false) {
 
-                     if (drawingHistory.FileId() != null) { //변경 - 그림삭제
 
-                         var temp = {
 
-                             SiteId: BWA.UserInfo.SiteId(),
 
-                             FileId: drawingHistory.FileId()
 
-                         }
 
-                         BWA.db.CmFile.byKey(temp).done(function (data) {
 
-                             dropZone.removeFile(data);
 
-                             dropZone.processQueue();
 
-                         });
 
-                     }
 
-                     else {
 
-                         dropZone.processQueue();//변경 - 그림 삭제 필요없음
 
-                     }
 
-                 }
 
-             }
 
-             else {
 
-                 if (_.isNull(dropZone) === false) { //추가
 
-                     if (drawingHistory.FileId() == null) {
 
-                         dropZone.processQueue();
 
-                     }
 
-                 }
 
-             }
 
-             BWA.db.FmsManualHistory.insert(drawingHistory.toJS()).done(function () {
 
-                 //                utils.toast.show('데이터베이스 항목 등록 작업이 성공하였습니다.');
 
-             });
 
-             //console.log('handleAfterSaveInPopup');
 
-             //console.log(response);
 
-         },
 
-         //2019-11-25 변경
 
-         handleBeforeDelete: function () {
 
-             for (var i = 0; i < drawingHistories().length; i++) {
 
-                 var temp1 = {
 
-                     SiteId: BWA.UserInfo.SiteId(),
 
-                     FileId: drawingHistories()[i].FileId()
 
-                 }
 
-                 if (temp1.FileId != null) {
 
-                     BWA.db.CmFile.byKey(temp1).done(function (data) {
 
-                         if (_.isNull(dropZone)) {
 
-                             dropZone = BWA.DropZone.create({
 
-                                 id: '#manualFileUpload1',
 
-                                 categoryId: $Code.FileCategory.MANUAL
 
-                             });
 
-                         }
 
-                         dropZone.removeFile(data);
 
-                     });
 
-                 }
 
-                 var store = new DevExpress.data.ODataStore({
 
-                     url: endpointSelector + "/FmsManualHistory",
 
-                     key: ["SiteId", "ManualId", "HistoryId"],
 
-                     keyType: {
 
-                         SiteId: "Int32",
 
-                         ManualId: "Int32",
 
-                         HistoryId: "Int32"
 
-                     }
 
-                 });
 
-                 var removeData = {
 
-                     SiteId: BWA.UserInfo.SiteId(), ManualId: drawingHistories()[i].ManualId(), HistoryId: drawingHistories()[i].HistoryId(),
 
-                     RevisionNo: drawingHistories()[i].RevisionNo(), FileId: drawingHistories()[i].FileId(),
 
-                     Description: drawingHistories()[i].Description(), UpdatedDate: drawingHistories()[i].UpdatedDate(), UpdatedUserId: drawingHistories()[i].UpdatedUserId
 
-                 };
 
-                 store.remove(removeData).done(function (values, key) {
 
-                     utils.toast.show("삭제 되었습니다.");
 
-                 })
 
-                 .fail(function (error) {
 
-                     utils.toast.show(error);
 
-                 });
 
-                 if (i == drawingHistories().length) {
 
-                     dropZone = null;
 
-                 }
 
-             }
 
-         },
 
-         //handleInitializedInPopup: function() {
 
-         handlePopupShown: function (isEditModeInPopup, isNewInPopup, dataViewModel) {
 
-             if (isNewInPopup) {
 
-                 uploadedFileInfo.FileId = null;
 
-                 textAreaNoteHeightInPopup(170);
 
-                 dropZone = BWA.DropZone.create({
 
-                     categoryId: $Code.FileCategory.MANUAL,
 
-                     id: '#manualFileUpload',
 
-                     uploadedFileInfo: uploadedFileInfo,
 
-                     maxFiles: 1,
 
-                     handleSuccess: function (fileInfo) {
 
-                         if (uploadedFileInfo.FileId) {
 
-                             historyViewModel.FileId(fileInfo.FileId);
 
-                             drawingHistoryDataSource.filter([
 
-                                 eq('SiteId', BWA.UserInfo.SiteId()),
 
-                                 and,
 
-                                 eq('ManualId', drawingHistory.ManualId())
 
-                             ]);
 
-                             drawingHistoryDataSource.load().done(function (histories) {
 
-                                 drawingHistories(histories);
 
-                                 if (drawingHistories()[0].HistoryId() != null) {
 
-                                     return BWA.db.FmsManualHistory.update({ SiteId: drawingHistories()[0].SiteId(), HistoryId: drawingHistories()[0].HistoryId(), ManualId: drawingHistories()[0].ManualId() }, { FileId: fileInfo.FileId })
 
-                                         .done(function (res) {
 
-                                             $('#gridContainer').dxDataGrid('instance').refresh();
 
-                                         });
 
-                                 }
 
-                             });
 
-                         }
 
-                     },
 
-                     handleRemovedFile: function () {
 
-                         historyViewModel.FileId(null);
 
-                     }
 
-                 });
 
-             }
 
-             else {
 
-                 textAreaNoteHeightInPopup(340);
 
-                 reloadDrawingHistory(dataViewModel.ManualId());
 
-             }
 
-         },
 
-         handleViewShowing: function (that) {
 
-             $.when(
 
-                 //drawingGroupDataSource.load(),
 
-                 drawingTypeDataSource.load())
 
-             //.done(function(dbGroups, dbTypes) {
 
-             .done(function (dbTypes) {
 
-                 //drawingGroups(dbGroups[0]);
 
-                 //drawingTypes(dbTypes[0]);
 
-                 drawingTypes(dbTypes);
 
-                 //drawingGroupsForSearch($SearchView.createDefaultArray('DrawingGroupId').concat(dbGroups[0]));
 
-                 drawingTypesForSearch($SearchView.createDefaultArray('ManualTypeId').concat(dbTypes));
 
-                 deferredForSearch.resolve();
 
-             });
 
-         },
 
-         //2016 03 24 hcLee 추가
 
-         handleCancelInPopup: function () {
 
-             //tabIndex(1);
 
-             tabIndex(0);
 
-             tabIndex(0);
 
-         },
 
-         handleDataGridRowClick: function (id, dataGrid, clickRow, popupVisible) {
 
-             dataGrid.clearSelection();
 
-             var data = clickRow.data;
 
-             var dataModel = viewModel.dataModel;
 
-             // dataModel.DrawingGroupName = $KoSet(dataModel.DrawingGroupName, data['FmsDrawingCodeGroup/Name']);
 
-             dataModel.ManualTypeName = $KoSet(dataModel.ManualTypeName, data['FmsManualType/Name']);
 
-             popupVisible(true);
 
-         },
 
-         handleViewShown: function () {
 
-         }
 
-     });
 
-     function reloadDrawingHistory(drawingId) {
 
-         drawingHistoryDataSource.filter([
 
-             eq('SiteId', BWA.UserInfo.SiteId()),
 
-             and,
 
-             eq('ManualId', drawingId)
 
-         ]);
 
-         drawingHistoryDataSource.load().done(function (histories) {
 
-             drawingHistories(histories);
 
-         });
 
-     }
 
-     drawingHistoryPopup = BWA.Popup.ManualHistory.create(viewModel, params, drawingHistories, reloadDrawingHistory);
 
-     //viewModel.drawingGroups = drawingGroups;
 
-     viewModel.drawingTypes = drawingTypes;
 
-     //viewModel.drawingGroupsForSearch = drawingGroupsForSearch;
 
-     viewModel.drawingTypesForSearch = drawingTypesForSearch;
 
-     var tabIndex = ko.observable(0);
 
-     viewModel.tabsOptions = {
 
-         visible: tabsVisible,
 
-         selectedIndex: tabIndex,
 
-         dataSource: [
 
-             { text: '매뉴얼정보' },
 
-             { text: '매뉴얼이력' }
 
-         ]
 
-     };
 
-     tabIndex.subscribe(function (index) {
 
-         // 왼쪽 수정은 무조건 매뉴얼 hcLee 2016 03 24추가
 
-         //if (viewModel.isEditModeInPopup()) return;
 
-         if (viewModel.isEditModeInPopup() == false) {
 
-             isVisibleHistoryInsertButton(index === 1);
 
-             viewModel.visibleEditButton(index === 0);
 
-             viewModel.visibleDeleteButton(index === 0);
 
-         }
 
-         if (index == 0) drawingHistoryPopup.hide();
 
-         //if (index == 0 &&  tabIndex() == 0) return;
 
-         // hcLee 2016 03 24
 
-         if (viewModel.isEditModeInPopup()) {
 
-             tabIndex(0);
 
-             return;
 
-         }
 
-     });
 
-     viewModel.multiViewOptions = {
 
-         dataSource: [
 
-             {
 
-                 template: 'drawing',
 
-                 viewModel: viewModel,
 
-                 dataModel: viewModel.dataModel,
 
-             },
 
-             {
 
-                 template: 'drawingHistory',
 
-                 viewModel: viewModel,
 
-                 dataGridOptions: {
 
-                     dataSource: drawingHistories,
 
-                     columns: [
 
-                         { dataField: 'RevisionNo', caption: $G('revisionNo'), width: '13%' },
 
-                         { dataField: 'UpdatedDate', caption: $G('updatedDate'), width: '30%', dataType: 'date', format: 'yyyy-MM-dd HH:mm:ss' },
 
-                         { dataField: 'CmUser/Name', caption: $G('modifier'), width: '22%' },
 
-                         {
 
-                             dataField: 'CmFile/Name', caption: $G('fileName'), alignment: 'center', width: '45%',
 
-                             cellTemplate: function (cellElement, cellInfo) {
 
-                                 var data = cellInfo.data;
 
-                                 var url = [
 
-                                     BWA.db._url,
 
-                                     '/CmFile(SiteId={0},FileId={1})/$value'.formati(data.SiteId(), data.FileId())
 
-                                 ].join('');
 
-                                 $('<a>')
 
-                                     .prop('href', url)
 
-                                     .prop('download', cellInfo.value)
 
-                                     .attr('style', 'color: {0} !important; text-decoration: underline;'.formati('purple'))
 
-                                     //.style('color', '#333 !important')
 
-                                     .attr('target', '_blank')
 
-                                     .text(cellInfo.value)
 
-                                     .appendTo(cellElement);
 
-                             }
 
-                         }
 
-                     ],
 
-                     paging: {
 
-                         pageSize: 10,
 
-                         enabled: true
 
-                     },
 
-                     pager: { visible: true },
 
-                     hoverStateEnabled: true,
 
-                     contentReadyAction: function (e) {
 
-                         drawingHistoryPopup.setDrawingHistoryGridViewInstance(e.component);
 
-                     },
 
-                     selection: { mode: 'single' },
 
-                     rowClick: function (clickRow) {
 
-                         if (drawingHistoryPopup.isNewData()) {
 
-                             utils.toast.show('매뉴얼이력추가 중 입니다.'); // hcLee 2016 03 28
 
-                             return;
 
-                         }
 
-                         drawingHistoryPopup.setSelectedDrawingHistory(clickRow.data);
 
-                         //drawingHistoryPopup.hide();
 
-                         drawingHistoryPopup.show();
 
-                     },
 
-                     height: 405
 
-                 }
 
-             }
 
-         ],
 
-         swipeEnabled: false,
 
-         selectedIndex: tabIndex,
 
-         height: '520px'
 
-     };
 
-     viewModel.dataModel.ManualTypeName = $KoSet(viewModel.dataModel.ManualTypeName, '');
 
-     viewModel.isEditModeInPopup.subscribe(function (isEditMode) {
 
-         tabIndex(0); // 왼쪽 수정은 무조건 매뉴얼 hcLee 2016 03 24추가
 
-         //isVisibleHistoryInsertButton(tabIndex() === 1 && isEditMode);
 
-     });
 
-     viewModel.textAreaNoteHeightInPopup = textAreaNoteHeightInPopup;
 
-     viewModel.drawingHistoryPopup = drawingHistoryPopup;
 
-     return viewModel;
 
- };
 
 
  |