| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468 | 
							- $(function () {
 
-     "use strict";
 
-     var TEXTAREA_HEIGHT_MAX = 420,
 
-         TEXTAREA_HEIGHT_MIN = 240;
 
-     var dropZone = null;
 
-     var historyViewModel = new BemsWebApplication.FmsManualHistoryViewModel();
 
-     var uploadedFileInfo = {};
 
-     //2019-11-25 변경
 
-     var backUpFileId, RowHistoryId = null;
 
-     var eq = BWA.DataUtil.constructEqualFilter;
 
-     var and = BWA.DataUtil.andFilter;
 
-     var manualHistoryDataSource = BemsWebApplication.DataUtil.createDataSource({
 
-         dataSourceOptions: {
 
-             select: [
 
-                 'SiteId', 'ManualId', 'HistoryId', 'FileId', 'Description', 'RevisionNo',
 
-                 'UpdatedDate', 'UpdatedUserId',
 
-                 'CmFile/Name', 'CmFile/FileSize', 'CmUser/Name'
 
-             ],
 
-             expand: ['CmUser', 'CmFile'],
 
-             extendOptions: {
 
-                 forceOriginalField: true
 
-             }
 
-         }
 
-     }, 'FmsManualHistory');
 
-     //2019-11-25 변경
 
-     BWA.Popup = BWA.Popup || {};
 
-     BWA.Popup.ManualHistory = {
 
-         create: function (viewModel, params, drawingHistories, reloadManualHistory) {
 
-             // 다운로드 기능은 다른 창으로 url를 열면 될 듯하다.
 
-             //            var historyViewModel = new BemsWebApplication.FmsManualHistoryViewModel(),
 
-             var drawingId = viewModel.dataModel.ManualId,
 
-             popupVisible = ko.observable(false),
 
-             position = ko.observable(),
 
-             isNewData = ko.observable(false),
 
-             IsPrevImg = ko.observable(false),
 
-             textAreaHistoryNoteHeight = ko.observable(TEXTAREA_HEIGHT_MAX),
 
-             uploadedFileInfo = {},
 
-             isVisibleDropZone = ko.observable('hidden'),
 
- //                isVisibleDeleteButton = ko.observable(true),
 
-             isEditMode = ko.observable(false),
 
-             isVisibleCancelButton = ko.observable(true),
 
-             isVisibleEditButton = ko.observable(true),
 
- //                isVisibleHistoryInsertButton = ko.observable(false),
 
-             isVisibleSaveButton = ko.observable(false),
 
-             selectedHistory = null,
 
-             historyGridView = null,
 
-             timerObj = { timer: null },
 
-             mainPopupElement = params.mainPopupElement
 
-             ;
 
-             historyViewModel.UpdatedUserName = ko.observable();
 
-             historyViewModel.FileName = ko.observable();
 
-             //hcLee 2016 03 25
 
-             historyViewModel.FildIdBackUp = ko.observable();
 
-             BWA.db.FmsManualHistory.modified.add(function () {
 
-                 reloadManualHistory(drawingId());
 
-                 $('#gridContainer').dxDataGrid('instance').refresh();
 
-             });
 
-             function handleButtonSave() {
 
-                 historyViewModel.SiteId(BWA.UserInfo.SiteId());
 
-                 historyViewModel.ManualId(drawingId());
 
-                 if (isNewData()) {
 
-                     if (manualHistoryFileUpload.dropzone.files.length == 0) {
 
-                         utils.toast.show('매뉴얼 파일을 업로드하여 주십시오.', 'error');
 
-                         return;
 
-                     }
 
-                     //2019-11-25 변경
 
-                     if (_.isNull(dropZone) === false) { //추가
 
-                         if (historyViewModel.FileId() == null) {
 
-                             dropZone.processQueue();
 
-                         }
 
-                     }
 
-                     //2019-11-25 변경
 
-                     backUpFileId = historyViewModel.FileId();
 
-                     historyViewModel.UpdatedDate(new Date());
 
-                     historyViewModel.UpdatedUserId(BWA.UserInfo.UserId());
 
-                     BWA.db.FmsManualHistory.insert(historyViewModel.toJS()).done(function (res) {
 
-                         utils.toast.show('매뉴얼 이력 항목이 성공적으로 저장되었습니다.');
 
-                         dropZone.resetUploadedFileInfo();
 
-                         //dropZone.options.startLoadFileCount = 0;
 
-                         reloadManualHistory(drawingId());
 
-                         $('#gridContainer').dxDataGrid('instance').refresh();
 
-                         isNewData(false);
 
-                         ChangeMode(false);
 
-                         popupVisible(false);
 
-                         IsPrevImg(false);
 
-                     });
 
-                 }
 
-                 else {
 
-                     // hcLee 2016 03 27
 
-                     if (_.isUndefined(historyViewModel.FileId()) || historyViewModel.FileId() == null) {
 
-                         utils.toast.show('매뉴얼 파일을 업로드하여 주십시오.', 'error');
 
-                         return;
 
-                     }
 
-                     historyViewModel.RevisionNo(undefined);
 
-                     //historyViewModel.FileId(undefined); // hcLee
 
-                     historyViewModel.UpdatedDate(new Date());
 
-                     historyViewModel.UpdatedUserId(BWA.UserInfo.UserId());
 
-                     //2019-11-25 변경
 
-                     backUpFileId = historyViewModel.FileId();
 
-                     if (_.isNull(dropZone) === false) {
 
-                         dropZone.processQueue();
 
-                     }
 
-                     //2019-11-25 변경
 
-                     var keys = BWA.db.extractKeysObject('FmsManualHistory', historyViewModel);
 
-                     BWA.db.FmsManualHistory.update(keys, historyViewModel.toJS()).done(function (res) {
 
-                         utils.toast.show('매뉴얼 이력 항목이 성공적으로 저장되었습니다.');
 
-                         dropZone.resetUploadedFileInfo();
 
-                         reloadManualHistory(drawingId());
 
-                         $('#gridContainer').dxDataGrid('instance').refresh();
 
-                         ChangeMode(false);
 
-                         popupVisible(false);
 
-                         IsPrevImg(true);
 
-                     });
 
-                 }
 
-             }
 
-             function ChangeMode(bEdit) {
 
-                 if (bEdit) {
 
-                     setupDropzone(bEdit); // 업로드된 파일을 지운후 저장하지 않고 취소만 하고 다시 수정을 시작한 경우를 위하여 hcLee 2016 03 25
 
-                     isEditMode(true);
 
-                     isVisibleEditButton(false);
 
-                     isVisibleSaveButton(true);
 
-                     isVisibleCancelButton(true);
 
-                 }
 
-                 else {
 
-                     setupDropzone(false); // 업로드된 파일을 지운후 저장하지 않고 취소만 하고 다시 수정을 시작한 경우를 위하여 hcLee 2016 03 25
 
-                     isEditMode(false);
 
-                     isVisibleEditButton(true);
 
-                     isVisibleSaveButton(false);
 
-                     isVisibleCancelButton(false);
 
-                 }
 
-             }
 
-             /*
 
-             
 
-             function handleButtonDelete() {
 
-                 var keys = BWA.db.extractKeysObject('FmsManualHistory', historyViewModel);
 
-                 BWA.db.FmsManualHistory.remove(keys).done(function () {
 
-                     BWA.db.CmFile.remove({
 
-                         SiteId: historyViewModel.SiteId(),
 
-                         FileId: historyViewModel.FileId()
 
-                     }).done(function() {
 
-                         utils.toast.show('도면 이력 항목 삭제 처리가 성공하였습니다.');
 
-                         popupVisible(false);
 
-                     });
 
-                 });
 
-             }
 
-             */
 
-             function handleEditDrawingHistory() {
 
-                 ChangeMode(true);
 
-             }
 
-             function setupDropzone(bEdit) {
 
-                 //                var clone2 = $("div.dz-preview").clone(); // making zeh' clones!
 
-                 if (bEdit) {
 
-                     //                    var clone2 = $("div.dz-preview").clone(); // making zeh' clones!
 
-                     if (dropZone) {
 
-                         dropZone.removeAllFiles();
 
-                         dropZone.options.startLoadFileCount = 0;
 
-                         $('div.dz-preview').remove();
 
-                     }
 
-                     historyViewModel.FileId(historyViewModel.FildIdBackUp()); // hcLee 2016 03 25
 
-                     if (_.isNull(dropZone)) {
 
-                         dropZone = BWA.DropZone.create({
 
-                             id: '#manualHistoryFileUpload',
 
-                             categoryId: $Code.FileCategory.MANUAL,
 
-                             uploadedFileInfo: uploadedFileInfo,
 
-                             previewTemplate: "...",
 
-                             handleSuccess: function (fileInfo) {
 
-                                 //2019-11-25 변경
 
-                                 historyViewModel.FileId(fileInfo.FileId);
 
-                                 var tempFileID = fileInfo.FileId;
 
-                                 if (uploadedFileInfo.FileId) {
 
-                                     manualHistoryDataSource.filter([
 
-                                         eq('SiteId', BWA.UserInfo.SiteId()),
 
-                                         and,
 
-                                         eq('ManualId', historyViewModel.ManualId())
 
-                                     ]);
 
-                                     manualHistoryDataSource.load().done(function (histories) {
 
-                                         drawingHistories(histories);
 
-                                         var len = drawingHistories().length;
 
-                                         if (RowHistoryId != null)
 
-                                             historyViewModel.HistoryId(RowHistoryId);
 
-                                         else
 
-                                             historyViewModel.HistoryId(drawingHistories()[len - 1].HistoryId());
 
-                                         var keys = BWA.db.extractKeysObject('FmsManualHistory', historyViewModel);
 
-                                         
 
-                                         if (keys.HistoryId != null) {
 
-                                             return BWA.db.FmsManualHistory.update(keys, { FileId: tempFileID })
 
-                                                 .done(function (res) {
 
-                                                     $('#gridContainer').dxDataGrid('instance').refresh();
 
-                                                     if (IsPrevImg() == true) { // 그림삭제
 
-                                                         var temp = {
 
-                                                             SiteId: BWA.UserInfo.SiteId(),
 
-                                                             FileId: backUpFileId
 
-                                                         }
 
-                                                         BWA.db.CmFile.byKey(temp).done(function (data) {
 
-                                                             dropZone.removeFile(data);
 
-                                                         });
 
-                                                     }
 
-                                                 });
 
-                                             if (fileInfo.FileId != null)
 
-                                                 IsPrevImg(true);
 
-                                             else
 
-                                                 IsPrevImg(false);
 
-                                         }
 
-                                     });
 
-                                 }
 
-                             },
 
-                             handleRemovedFile: function () {
 
-                                 historyViewModel.FileId(null);
 
-                                 //dropZone.options.startLoadFileCount = 0;
 
-                             },
 
-                         });
 
-                     }
 
-                 }
 
-             }
 
-             popupVisible.subscribe(utils.popup.getAttachFunc('#popupDetail', timerObj, position));
 
-             position.subscribe(function (value) {
 
-             });
 
-             isNewData.subscribe(function (isNew) {
 
-                 //                isVisibleDeleteButton(isNew === false);
 
-                 textAreaHistoryNoteHeight(isNew ? TEXTAREA_HEIGHT_MIN : TEXTAREA_HEIGHT_MAX);
 
-                 if (isNew && popupVisible()) {
 
-                     isVisibleDropZone('visible');
 
-                 }
 
-                 else {
 
-                     isVisibleDropZone('hidden');
 
-                 }
 
-             });
 
-             viewModel.popupVisible.subscribe(function (value) {
 
-                 if (value === false) {
 
-                     popupVisible(false);
 
-                 }
 
-             });
 
-             viewModel.isEditModeInPopup.subscribe(function (value) {
 
-             });
 
-             return {
 
-                 visible: popupVisible,
 
-                 isNewData: isNewData,
 
-                 dataModel: historyViewModel,
 
-                 isVisibleDropZone: isVisibleDropZone,
 
-                 isEditMode: isEditMode,
 
-                 handleInsertDrawingHistory: function () {
 
-                     ChangeMode(false);
 
-                     popupVisible(false);
 
-                     isNewData(true);
 
-                     BWA.DataUtil.resetDataModel(_.omit(historyViewModel, 'ManualId'));
 
-                     var maxHistory = _.max(drawingHistories(), function (x) {
 
-                         return x.RevisionNo();
 
-                     });
 
-                     historyViewModel.RevisionNo(maxHistory.RevisionNo() + 1);
 
-                     historyViewModel.UpdatedUserName(BWA.UserInfo.Name());
 
-                     popupVisible(true);
 
-                     ChangeMode(true);
 
-                     isVisibleCancelButton(false);
 
-                 },
 
-                 textAreaHistoryNoteHeight: textAreaHistoryNoteHeight,
 
-                 show: function () {
 
-                     popupVisible(true);
 
-                 },
 
-                 hide: function () {
 
-                     popupVisible(false);
 
-                 },
 
-                 popupOptions: {
 
-                     width: '480px',
 
-                     height: '616px',
 
-                     dragEnabled: false,
 
-                     position: position,
 
-                     visible: popupVisible,
 
-                     showingAction: function () { },
 
-                     closeOnOutsideClick: false,
 
-                     shading: false,
 
-                     //shading: true,
 
-                     /*
 
-                     animation: {
 
-                         show: { type: "slide", duration: 150, from: { left: '-=10', opacity: 0 }, to: { opacity: 1 } },
 
-                         hide: { type: "slide", duration: 150, from: { left: '-=10', opacity: 1 }, to: { opacity: 0 } }
 
-                     },*/
 
-                     shownAction: function () {
 
-                         if (isNewData()) {
 
-                             isVisibleDropZone('visible');
 
-                         }
 
-                         else {
 
-                             isVisibleDropZone('hidden');
 
-                         }
 
-                         setupDropzone();
 
-                     },
 
-                     hidingAction: function () {
 
-                         //dropZone = null;
 
-                         //dropZone.dispose(uploadedFileInfo);
 
-                         //dropZone.options.startLoadFileCount = 0;
 
-                     }
 
-                 },
 
-                 toolbarItems: [
 
-                     { location: 'before', text: '이력 상세정보' },
 
-                     {
 
-                         location: 'after',
 
-                         widget: 'button',
 
-                         options: {
 
-                             text: '수정',
 
-                             icon: 'edit',
 
-                             visible: isVisibleEditButton,
 
-                             disabled: viewModel.hasnotModificationPermission,
 
-                             clickAction: handleEditDrawingHistory
 
-                         }
 
-                     },
 
-                     {
 
-                         location: 'after',
 
-                         widget: 'button',
 
-                         options: {
 
-                             text: '취소',
 
-                             icon: 'cancel',
 
-                             visible: isVisibleCancelButton,
 
-                             disabled: viewModel.hasnotModificationPermission,
 
-                             clickAction: function () {
 
-                                 // 파일 id를 다시 설정해야 한다. hcLee 2016 03 25
 
-                                 historyViewModel.FileId(historyViewModel.FildIdBackUp()); // hcLee 2016 03 25
 
-                                 //dropZone = null;
 
-                                 //dropZone.dispose(uploadedFileInfo);
 
-                                 //dropZone.options.startLoadFileCount = 0;
 
-                                 ChangeMode(false);
 
-                             }
 
-                         }
 
-                     },
 
- /*                    {
 
-                         location: 'after',
 
-                         widget: 'button',
 
-                         options: {
 
-                             text: '매뉴얼이력추가',
 
-                             icon: 'plus',
 
-                             visible: isVisibleHistoryInsertButton,
 
-                             disabled: viewModel.hasnotModificationPermission,
 
-                             clickAction: handleInsertDrawingHistory,
 
-                         }
 
-                     },*/
 
-                     {
 
-                         location: 'after', widget: 'button', options: {
 
-                             text: $G('save'),
 
-                             icon: 'save',
 
-                             visible: isVisibleSaveButton,
 
-                             disabled: viewModel.hasnotModificationPermission,
 
-                             clickAction: handleButtonSave
 
-                         }
 
-                     },
 
- /*                    { // 이력 삭제는 없는 것으로 두소장과 결정  2016 03 28
 
-                         location: 'after', widget: 'button', options: {
 
-                             text: $G('delete'),
 
-                             icon: 'remove',
 
-                             type: 'danger',
 
-                             visible: isVisibleDeleteButton,
 
-                             disabled: viewModel.hasnotModificationPermission,
 
-                             clickAction: handleButtonDelete
 
-                         }
 
-                     },*/
 
-                     {
 
-                         location: 'after', widget: 'button', options: {
 
-                             text: $G('close'),
 
-                             icon: 'close',
 
-                             clickAction: function () {
 
-                                 isNewData(false);
 
-                                 ChangeMode(false);
 
-                                 /*
 
-                                 isEditMode(false);
 
-                                 isVisibleEditButton(true);
 
-                                 isVisibleHistoryInsertButton(false);
 
-                                 isVisibleSaveButton(false);
 
-                                 isVisibleDeleteButton(true); */
 
-                                 popupVisible(false);
 
-                             }
 
-                         }
 
-                     }
 
-                 ],
 
-                 setDrawingHistoryGridViewInstance: function (instance) {
 
-                     historyGridView = instance;
 
-                 },
 
-                 setSelectedDrawingHistory: function (history) {
 
-                     isNewData(false);
 
-                     RowHistoryId = history.HistoryId();
 
-                     BWA.DataUtil.copyViewModel(history, historyViewModel);
 
-                     historyViewModel.FildIdBackUp(history.FileId()); // hcLee 2016 03 25
 
-                     historyViewModel.FileName(history['CmFile/Name']());
 
-                     historyViewModel.UpdatedUserName(history['CmUser/Name']());
 
-                     historyViewModel.Description(history['Description']());
 
-                     ChangeMode(false);
 
-                 },
 
-             };
 
-         }
 
-     }
 
- });
 
 
  |