f766dcb216dfd414f9343508d799cd6dfa3caac7.svn-base 27 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663
  1. BemsWebApplication.FloorPlan = function (params, viewInfo) {
  2. "use strict";
  3. var FloorInPopUpForSearch = ko.observableArray(),
  4. FloorInPopUp = ko.observableArray();
  5. var imagefileUrl = ko.observable(), uploadedFileInfo = {}, dropZone = null;
  6. var deferredForSearch = new $.Deferred();
  7. var floorplan = ko.observableArray();
  8. var isImageUpload = ko.observableArray();
  9. var RowClicked = ko.observable(false); // 처음 열 클릭 확인
  10. var enableDataBoxInPopup = ko.observable(false);
  11. var visibleEditButton = ko.observable(false); // 수정 버튼 활성화 여부 플래그
  12. var hasnotModificationPermission = ko.observable(true); // 수정버튼 비활성화 플래그
  13. var visibleDeleteButton = ko.observable(false); // 삭제버튼 활성화 플래그
  14. var visibleCancelButton = ko.observable(false); // 취소버튼 활성화 플래그
  15. var isEditModeInPopup = ko.observable(); // 저장버튼 활성화 플래그
  16. var isNotModifyMode = ko.observable(false); // 저장버튼 비활성화 플래그
  17. var backupDataViewModel = new BemsWebApplication.BemsFloorPlanViewModel();
  18. var backup_data;
  19. var floorAll;
  20. var endpointSelector = "";
  21. if (BemsWebApplication.config.mode == "production") {
  22. endpointSelector = new DevExpress.EndpointSelector(BemsWebApplication.config.endpoints).config.db.production;
  23. } else {
  24. endpointSelector = new DevExpress.EndpointSelector(BemsWebApplication.config.endpoints).config.db.local;
  25. }
  26. var floorplanPopupToolbarItems = [
  27. { location: 'before', text: '평면도 등록' },
  28. { location: 'after', widget: 'button', options: { text: $G('edit'), icon: 'edit', visible: visibleEditButton, disabled: hasnotModificationPermission, clickAction: handlePopupButtonEdit } },
  29. { location: 'after', widget: 'button', options: { text: $G('delete'), type: 'danger', icon: 'remove', visible: visibleDeleteButton, disabled: hasnotModificationPermission, clickAction: handlePopupButtonDelete } },
  30. { location: 'after', widget: 'button', options: { text: $G('cancel'), icon: 'cancel', visible: visibleCancelButton, clickAction: handlePopupButtonCancel } },
  31. { location: 'after', widget: 'button', options: { text: $G('save'), icon: 'save', visible: isEditModeInPopup, disabled: isNotModifyMode, clickAction: handlePopupButtonSave } },
  32. { location: 'after', widget: 'button', options: { text: $G('close'), icon: 'close', clickAction: PopupButtonClose } }
  33. ];
  34. function setupDropZone(dataViewModel) {
  35. var timer = null;
  36. viewModel.isEditModeInPopup.subscribe(function (value) {
  37. if (value) {
  38. if (timer) {
  39. clearInterval(timer);
  40. }
  41. timer = setInterval(function () {
  42. if ($('#FloorPlanDropZone').length) {
  43. if (_.isNull(dropZone)) {
  44. dropZone = BWA.DropZone.create({
  45. id: '#FloorPlanDropZone',
  46. categoryId: $Code.FileCategory.FLOOR,
  47. uploadedFileInfo: uploadedFileInfo,
  48. handleRemoveBeforePromise: function () {
  49. var keys = BWA.db.extractKeysObject('BemsFloorPlan', dataViewModel);
  50. utils.toast.show($G('successDatabaseInsertionMsg'));
  51. PopupButtonClose();
  52. return BWA.db.BemsFloorPlan.update(keys, { ImageFileId: null });
  53. },
  54. handleSuccess: function (fileInfo) {
  55. if (uploadedFileInfo.FileId) {
  56. dataViewModel.ImageFileId(uploadedFileInfo.FileId);
  57. var keys = BWA.db.extractKeysObject('BemsFloorPlan', dataViewModel);
  58. var insert_data = {
  59. SiteId: BWA.UserInfo.SiteId(),
  60. FloorId: backup_data.FloorId,
  61. Name: dataViewModel.Name(),
  62. ImageFileId: uploadedFileInfo.FileId
  63. };
  64. if (keys.Name != null) {
  65. //update(insert_data, tmp_data);
  66. BemsWebApplication.db['BemsFloorPlan'].remove(backup_data).done(function () {
  67. var store = new DevExpress.data.ODataStore({
  68. url: endpointSelector + "/BemsFloorPlan",
  69. key: ["SiteId", "Name"],
  70. keyType: {
  71. SiteId: "Int32", Name: "String"
  72. }
  73. });
  74. store.insert(insert_data).done(function (key, result) {
  75. utils.toast.show($G('successDatabaseInsertionMsg'));
  76. PopupButtonClose();
  77. })
  78. .fail(function (error) {
  79. utils.toast.show(error);
  80. });
  81. viewModel.refreshList();
  82. setTimeout(function () {
  83. GetGridData();
  84. }, 500);
  85. });
  86. }
  87. }
  88. },
  89. handleRemovedFile: function () {
  90. dataViewModel.ImageFileId(null);
  91. }
  92. });
  93. }
  94. }
  95. }, 100);
  96. }
  97. else {
  98. if (timer) {
  99. clearInterval(timer);
  100. timer = null;
  101. }
  102. dropZone = null;
  103. }
  104. });
  105. }
  106. function update(postData, backupData) {
  107. var floorplanDataModel = new BemsWebApplication.BemsFloorPlanViewModel();
  108. if (FloorPlanDropZone.dropzone.files.length == 0) {
  109. utils.toast.show("첨부 파일을 업로드하여 주십시오.", 'error');
  110. return;
  111. }
  112. else if (_.isNull(dropZone) === false
  113. && (dropZone.files[0].type == 'image/jpeg'
  114. || dropZone.files[0].type == 'image/jpg'
  115. || dropZone.files[0].type == 'image/gif'
  116. || dropZone.files[0].type == 'image/png'
  117. || dropZone.files[0].type == 'image/bmp')) {
  118. dropZone.processQueue();
  119. }
  120. else {
  121. utils.toast.show("그림파일(jpeg, jpg, gif, png, bmp)만 등록 가능합니다.", 'error');
  122. return;
  123. }
  124. backup_data = {
  125. SiteId: BWA.UserInfo.SiteId(),
  126. FloorId: backupData.FloorId,
  127. Name: backupData.Name,
  128. ImageFileId: backupData.ImageFileId
  129. };
  130. var temp = {
  131. SiteId: BWA.UserInfo.SiteId(),
  132. FileId: backupData.ImageFileId
  133. }
  134. if (backupData.ImageFileId != null) {
  135. BWA.db.CmFile.byKey(temp).done(function (data) {
  136. dropZone.removeFile(data);
  137. });
  138. }
  139. dropZone.processQueue();
  140. }
  141. function insert(postData) {
  142. if (postData.Name == null || postData.FloorId == null) {
  143. utils.toast.show("층 정보가 입력되지 않았습니다.", 'error');
  144. return;
  145. }
  146. else if (FloorPlanDropZone.dropzone.files.length == 0) {
  147. utils.toast.show("첨부 파일을 업로드하여 주십시오.", 'error');
  148. return;
  149. }
  150. else if (_.isNull(dropZone) === false
  151. && viewModel.dataModel.ImageFileId() == null
  152. && (dropZone.files[0].type == 'image/jpeg'
  153. || dropZone.files[0].type == 'image/jpg'
  154. || dropZone.files[0].type == 'image/gif'
  155. || dropZone.files[0].type == 'image/png'
  156. || dropZone.files[0].type == 'image/bmp')) {
  157. dropZone.processQueue();
  158. }
  159. else {
  160. utils.toast.show("그림파일(jpeg, jpg, gif, png, bmp)만 등록 가능합니다.", 'error');
  161. return;
  162. }
  163. backup_data = {
  164. SiteId: BWA.UserInfo.SiteId(),
  165. FloorId: viewModel.dataModel.FloorId(),
  166. Name: viewModel.dataModel.Name(),
  167. ImageFileId: null
  168. };
  169. var store = new DevExpress.data.ODataStore({
  170. url: endpointSelector + "/BemsFloorPlan",
  171. key: ["SiteId", "Name"],
  172. keyType: {
  173. SiteId: "Int32", Name: "String"
  174. }
  175. });
  176. store.insert(postData).done(function (key, result) {
  177. utils.toast.show($G('successDatabaseInsertionMsg'));
  178. PopupButtonClose();
  179. })
  180. .fail(function (error) {
  181. utils.toast.show(error);
  182. });
  183. }
  184. //저장버튼
  185. function handlePopupButtonSave() {
  186. var dataViewModel = viewModel.dataModel;
  187. var postViewModel = new BemsWebApplication.BemsFloorPlanViewModel();
  188. postViewModel.SiteId(dataViewModel.SiteId());
  189. postViewModel.FloorId(dataViewModel.FloorId());
  190. postViewModel.Name(dataViewModel.Name());
  191. postViewModel.ImageFileId(dataViewModel.ImageFileId());
  192. var postData = postViewModel.toJS();
  193. if (viewModel.isNewInPopup())
  194. insert(postData);
  195. else
  196. update(postData, backupDataViewModel);
  197. //예외 처리(ImageFileId가 기존과 수정버전 모두 null인 경우)
  198. if (dataViewModel.ImageFileId() == null && backupDataViewModel.ImageFileId == null) {
  199. utils.toast.show($G('successDatabaseInsertionMsg'));
  200. PopupButtonClose();
  201. }
  202. //DB 저장에 시간이 걸리기때문에 딜레이 후 데이터 로드
  203. setTimeout(function () {
  204. UpdateSelectBoxInPopUp();
  205. GetGridData();
  206. }, 500);
  207. }
  208. function getBackupDataViewModel(model) {
  209. var object = {};
  210. $.each(model, function (name, value) {
  211. if (ko.isObservable(value)) {
  212. object[name] = value();
  213. }
  214. });
  215. return object;
  216. }
  217. function restoreDataViewModelFromBackup(model, backupModel) {
  218. $.each(backupModel, function (name, value) {
  219. model[name](value);
  220. });
  221. }
  222. // 수정버튼 클릭
  223. function handlePopupButtonEdit() {
  224. viewModel.isNewInPopup(false);
  225. viewModel.visibleEditButton(false);
  226. viewModel.visibleDeleteButton(false);
  227. viewModel.visibleCancelButton(true);
  228. viewModel.isEditModeInPopup(true);
  229. viewModel.isNotModifyMode(false);
  230. viewModel.enableDataBoxInPopup(false);
  231. viewModel.isImageUpload(true);
  232. backupDataViewModel = getBackupDataViewModel(viewModel.dataModel);
  233. dropZone = null;
  234. }
  235. //////
  236. // 삭제버튼 클릭
  237. function handlePopupButtonDelete() {
  238. DevExpress.ui.dialog.confirm($G('deleteConfirmMsg'), "삭제").then(function (result) {
  239. if (result) {
  240. var temp = {
  241. SiteId: BWA.UserInfo.SiteId(),
  242. FileId: viewModel.dataModel.ImageFileId()
  243. }
  244. if (viewModel.dataModel.ImageFileId() != null) {
  245. BWA.db.CmFile.byKey(temp).done(function (data) {
  246. if ($('#FloorPlanDropZone1').length) {
  247. if (_.isNull(dropZone)) {
  248. dropZone = BWA.DropZone.create({
  249. id: '#FloorPlanDropZone1',
  250. categoryId: $Code.FileCategory.FLOOR
  251. });
  252. dropZone.removeFile(data);
  253. dropZone = null;
  254. }
  255. }
  256. });
  257. }
  258. var selectedId = {};
  259. selectedId.SiteId = viewModel.dataModel.SiteId();
  260. selectedId.FloorId = viewModel.dataModel.FloorId();
  261. selectedId.Name = viewModel.dataModel.Name();
  262. selectedId.ImageFileId = viewModel.dataModel.ImageFileId();
  263. BemsWebApplication.db['BemsFloorPlan'].remove(selectedId).done(function () {
  264. viewModel.refreshList();
  265. setTimeout(function () {
  266. GetGridData();
  267. UpdateSelectBoxInPopUp();
  268. }, 500);
  269. PopupButtonClose();
  270. utils.toast.show('데이터베이스 항목 삭제 작업이 성공하였습니다.');
  271. }).fail(function () {
  272. utils.toast.show('데이터베이스 항목 삭제 작업이 실패하였습니다.', 'error');
  273. });
  274. //층별 관제점도 같이 지워준다
  275. var dataSource = new DevExpress.data.DataSource({
  276. store: {
  277. type: "odata",
  278. url: endpointSelector + "/BemsFloorStatus",
  279. },
  280. requireTotalCount: true
  281. });
  282. dataSource.filter([
  283. ["SiteId", "=", BWA.UserInfo.SiteId()],
  284. "and",
  285. ["FloorId", "=", viewModel.dataModel.FloorId()]
  286. ]);
  287. dataSource.load()
  288. .done(function (result) {
  289. for (var i = 0; i < result.length; i++) {
  290. var num = 0;
  291. var removeData = {
  292. SiteId: result[i].SiteId,
  293. FloorId: result[i].FloorId,
  294. FloorName: result[i].FloorName,
  295. ImageFileId: result[i].ImageFileId,
  296. Xvalue: result[i].Xvalue,
  297. Yvalue: result[i].Yvalue,
  298. ZoneId: result[i].ZoneId,
  299. FacilityTypeId: result[i].FacilityTypeId,
  300. FacilityCode: result[i].FacilityCode,
  301. PropertyId: result[i].PropertyId,
  302. FacilityName: result[i].FacilityName,
  303. };
  304. BemsWebApplication.db['BemsFloorStatus'].remove(removeData);
  305. }
  306. })
  307. }
  308. });
  309. }
  310. // 취소버튼
  311. function handlePopupButtonCancel() {
  312. viewModel.visibleEditButton(true);
  313. viewModel.visibleDeleteButton(true);
  314. viewModel.visibleCancelButton(false);
  315. viewModel.isEditModeInPopup(false);
  316. viewModel.isNotModifyMode(true);
  317. viewModel.isImageUpload(false);
  318. restoreDataViewModelFromBackup(viewModel.dataModel, backupDataViewModel);
  319. }
  320. // 닫기버튼
  321. function PopupButtonClose() {
  322. viewModel.isNewInPopup(false);
  323. viewModel.visibleEditButton(false);
  324. viewModel.visibleDeleteButton(false);
  325. viewModel.visibleCancelButton(false);
  326. viewModel.isEditModeInPopup(false);
  327. viewModel.isNotModifyMode(false);
  328. viewModel.dataModel.ImageFileId(null);
  329. viewModel.imagefileUrl(undefined);
  330. viewModel.popupVisible(false);
  331. dropZone = null;
  332. }
  333. function GetGridData() {
  334. var gridData = new Array();
  335. var dataSource = new DevExpress.data.DataSource({
  336. store: {
  337. type: "odata",
  338. url: endpointSelector + "/BemsFloorPlan",
  339. },
  340. requireTotalCount: true,
  341. pageSize: 9999,
  342. });
  343. dataSource.filter([
  344. ["SiteId", "=", BWA.UserInfo.SiteId()]
  345. ]);
  346. dataSource.sort({ getter: "Name", asc: true });
  347. dataSource.load()
  348. .done(function (result) {
  349. for (var i = 0; i < result.length; i++) {
  350. gridData[i] = {
  351. "SiteId": 0,
  352. "FloorId": 0,
  353. "Name": "",
  354. "ImageFileId": null
  355. };
  356. gridData[i].SiteId = result[i].SiteId;
  357. gridData[i].FloorId = result[i].FloorId;
  358. gridData[i].Name = result[i].Name;
  359. gridData[i].ImageFileId = result[i].ImageFileId;
  360. }
  361. $("#gridContainer").dxDataGrid("instance").option('dataSource', gridData);
  362. //$("#gridContainer").dxDataGrid("instance").refresh();
  363. })
  364. .fail(function (error) {
  365. utils.toast.show(error);
  366. });
  367. }
  368. function UpdateSelectBoxInPopUp() {
  369. var dataSource_GridData = new DevExpress.data.DataSource({
  370. store: {
  371. type: "odata",
  372. url: endpointSelector + "/BemsFloorPlan",
  373. },
  374. requireTotalCount: true,
  375. pageSize: 100
  376. });
  377. dataSource_GridData.filter([
  378. ["SiteId", "=", BWA.UserInfo.SiteId()]
  379. ]);
  380. dataSource_GridData.load()
  381. .done(function (gridData) {
  382. var tmp = new Array(floorAll.length);
  383. for (var i = 0; i < floorAll.length; i++) {
  384. tmp[i] = 0;
  385. for (var j = 0; j < gridData.length; j++) {
  386. if (floorAll[i].FloorId == gridData[j].FloorId) {
  387. tmp[i] = 1;
  388. break;
  389. }
  390. }
  391. }
  392. var dbfloor = new Array();
  393. var idx = 0;
  394. for (var i = 0; i < floorAll.length; i++) {
  395. if (tmp[i] == 0)
  396. dbfloor.push(floorAll[i]);
  397. }
  398. FloorInPopUp(dbfloor);
  399. FloorInPopUpForSearch($SearchView.createArrayOfSelectBox('FloorId', FloorInPopUp));
  400. });
  401. }
  402. function getImageSize(width, height) {
  403. var viewIndoor = $('#viewIndoor');
  404. var maxWidth = parseFloat(viewIndoor.css('width')), maxHeight = parseFloat(viewIndoor.css('height'));
  405. var widthRatio = width / maxWidth;
  406. var heightRatio = height / maxHeight;
  407. var maxRatio = max(widthRatio, heightRatio);
  408. if (maxRatio > 1) {
  409. return { width: width / maxRatio, height: height / maxRatio }
  410. }
  411. return { width: width, height: height }
  412. }
  413. function max(x, y) {
  414. if (x > y) return x;
  415. return y;
  416. }
  417. function loadImage(imageUrl) {
  418. $('#imageContext').find('text').remove();
  419. //var imageUrl = url;//'/Images/Blueprint/' + viewModel.dataModel.FloorId() + '.jpg';
  420. var image = document.getElementById("image");
  421. var newImage = new Image();
  422. newImage.onload = function () {
  423. var imageSize = getImageSize(newImage.width, newImage.height);
  424. $('#imageContext').css('width', imageSize.width).css('height', imageSize.height);
  425. $('#image').attr('width', imageSize.width).attr('height', imageSize.height); // 2016 05 30 추가, IE 문제해결, 종화
  426. }
  427. newImage.src = imageUrl;
  428. image.setAttributeNS('http://www.w3.org/1999/xlink', 'href', newImage.src);
  429. }
  430. var viewModel = BWA.DataGrid.createViewWithDataGrid(params, viewInfo, 'BemsFloorPlan', {
  431. dataSourceOptions: {
  432. select: [
  433. 'SiteId',
  434. 'FloorId',
  435. 'Name',
  436. 'ImageFileId'
  437. ],
  438. filter: [
  439. ['SiteId', '=', BWA.UserInfo.SiteId()]
  440. ],
  441. extendOptions: {
  442. forceOriginalField: true
  443. },
  444. },
  445. columns: [
  446. { dataField: 'SiteId', caption: '번호', width: '30%', alignment: 'center' },
  447. { dataField: 'Name', caption: '층 명칭', width: '70%', alignment: 'center', sortOrder: 'desc' },
  448. { dataField: 'FloorId', caption: '', width: '30%', alignment: 'center', visible: false },
  449. { dataField: 'ImageFileId', caption: '', width: '70%', alignment: 'center', visible: false }
  450. ],
  451. NoSearchView: true, // 2019.07.25 kgpark 검색버튼 삭제
  452. paging: {
  453. pageSize: 20,
  454. enabled: true
  455. },
  456. pager: {
  457. },
  458. handlePopupShowing: function (isNewInPopup, dataViewModel) {
  459. // 저장 버튼
  460. if (isNewInPopup() == false) {
  461. imagefileUrl(undefined);
  462. dropZone = null; // 신규등록인 경우
  463. } else {
  464. dataViewModel.Name('');
  465. dataViewModel.ImageFileId(null);
  466. viewModel.imagefileUrl(undefined);
  467. viewModel.isNewInPopup(true);
  468. viewModel.isEditModeInPopup(true);
  469. imagefileUrl('');
  470. loadImage(imagefileUrl());
  471. }
  472. // 탭으로 표시하지 않음
  473. isImageUpload(false);
  474. enableDataBoxInPopup(true);
  475. // tabsVisible(isNewInPopup() == false);
  476. $("#Floor_Info").dxSelectBox({
  477. onValueChanged: function () {
  478. if (isNewInPopup() == false) {
  479. // 이전 이미지 잔상 문제로 인한 방어코드
  480. // 이미지 경로 강제 초기화
  481. imagefileUrl(undefined);
  482. }
  483. isImageUpload(true);
  484. enableDataBoxInPopup(true);
  485. var floor = $("#Floor_Info").dxSelectBox('instance').option('value');
  486. var dataSource = new DevExpress.data.DataSource({
  487. store: {
  488. type: "odata",
  489. url: endpointSelector + "/CmFloor",
  490. },
  491. requireTotalCount: true
  492. });
  493. dataSource.filter([
  494. ["SiteId", "=", BWA.UserInfo.SiteId()]
  495. ]);
  496. dataSource.load()
  497. .done(function (result) {
  498. for (var i = 0; i < result.length; i++) {
  499. if (result[i].FloorId == floor) {
  500. viewModel.dataModel.Name(result[i].Name);
  501. break;
  502. }
  503. }
  504. });
  505. }
  506. });
  507. },
  508. handleViewShowing: function () {
  509. //권한설정
  510. hasnotModificationPermission(!BWA.UserInfo.hasPermissionOfModification(viewInfo.viewName));
  511. var dataSource_FloorInfo = new DevExpress.data.DataSource({
  512. store: {
  513. type: "odata",
  514. url: endpointSelector + "/CmFloor",
  515. },
  516. requireTotalCount: true
  517. });
  518. dataSource_FloorInfo.filter([
  519. ["SiteId", "=", BWA.UserInfo.SiteId()]
  520. ]);
  521. dataSource_FloorInfo.load()
  522. .done(function (floorInfo) {
  523. floorAll = floorInfo;
  524. });
  525. UpdateSelectBoxInPopUp();
  526. GetGridData();
  527. enableDataBoxInPopup(true);
  528. },
  529. handleDataGridRowClick: function (id, dataGrid, clickRow, popupVisible) {
  530. dataGrid.clearSelection();
  531. viewModel.visibleEditButton(true);
  532. viewModel.visibleDeleteButton(true);
  533. viewModel.isNotModifyMode(true);
  534. viewModel.enableDataBoxInPopup(false);
  535. viewModel.isImageUpload(false);
  536. viewModel.isNewInPopup(false);
  537. var data = clickRow.data;
  538. viewModel.dataModel.Name(data.Name);
  539. viewModel.dataModel.FloorId(data.FloorId);
  540. viewModel.dataModel.ImageFileId(data.ImageFileId);
  541. viewModel.dataModel.SiteId(data.SiteId);
  542. // 이미지 width, height를 제대로 설정하지 못하는 문제 해결
  543. if (RowClicked() == false) {
  544. popupVisible(true);
  545. setTimeout(function () {
  546. imagefileUrl('{0}/CmFile(SiteId={1},FileId={2})/$value'.formati(BWA.db._url, BWA.UserInfo.SiteId(), data.ImageFileId));
  547. loadImage(imagefileUrl());
  548. }, 100)
  549. RowClicked(true);
  550. }
  551. else {
  552. imagefileUrl('{0}/CmFile(SiteId={1},FileId={2})/$value'.formati(BWA.db._url, BWA.UserInfo.SiteId(), data.ImageFileId));
  553. loadImage(imagefileUrl());
  554. setTimeout(function () {
  555. popupVisible(true);
  556. },100)
  557. }
  558. // 이미지 width, height를 제대로 설정하지 못하는 문제 해결
  559. },
  560. handleViewShown: function (dataViewModel, isEditModeInPopup) {
  561. setupDropZone(dataViewModel);
  562. },
  563. handleSaveSuccess: function () {
  564. if (_.isNull(dropZone) === false) {
  565. dropZone.resetUploadedFileInfo();
  566. }
  567. },
  568. handleAfterLoadingModelByKey: function (data, dataViewModel, isNewInPopup) {
  569. if (isNewInPopup() == false) {
  570. if (_.isNull(dataViewModel.ImageFileId()) === false) {
  571. imagefileUrl('{0}/CmFile(SiteId={1},FileId={2})/$value'.formati(BWA.db._url, dataViewModel.SiteId(), dataViewModel.ImageFileId()));
  572. }
  573. else {
  574. imagefileUrl("images/default.png");
  575. }
  576. }
  577. }
  578. });
  579. viewModel.floorplanPopupToolbarItems = floorplanPopupToolbarItems;
  580. viewModel.imagefileUrl = imagefileUrl;
  581. viewModel.FloorInPopUp = FloorInPopUp;
  582. viewModel.dataModel.FloorId = ko.observable();
  583. viewModel.isImageUpload = isImageUpload;
  584. viewModel.backupDataViewModel = backupDataViewModel;
  585. viewModel.enableDataBoxInPopup = enableDataBoxInPopup;
  586. viewModel.visibleEditButton = visibleEditButton;
  587. viewModel.hasnotModificationPermission = hasnotModificationPermission;
  588. viewModel.visibleDeleteButton = visibleDeleteButton;
  589. viewModel.visibleCancelButton = visibleCancelButton;
  590. viewModel.isEditModeInPopup = isEditModeInPopup;
  591. viewModel.isNotModifyMode = isNotModifyMode;
  592. return viewModel;
  593. };