5fe27420ae229ac8e7c3dd5b5dfd9cbc9ae7380a.svn-base 31 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786
  1. BemsWebApplication.FloorStatus = function (params, viewInfo) {
  2. "use strict";
  3. var facilityTypeId_fin = 0, facilityCode_fin = 0, propertyId_fin = 0, facilityName_fin = "", controlPoint_fin = "", zoneId_fin = 0, serviceTypeId_fin = 0;
  4. var BemsFloorStatusDataSource = BemsWebApplication.db.createDataSource('BemsFloorStatus'),
  5. FloorInPopUpForSearch = ko.observableArray(),
  6. FloorInPopUp = ko.observableArray();
  7. var imagefileUrl = ko.observable();
  8. var controlIdDataSource = ko.observableArray();
  9. var controlIdforFloor = new Array();
  10. var floorstatus = ko.observableArray();
  11. var RowClicked = ko.observable(false); // 처음 열 클릭 확인
  12. var visiblePopup = ko.observable(false);
  13. var imageArray_prev = new Array();
  14. var markerArray_prev = new Array();
  15. var markerArray_prev_forDelete = new Array();
  16. var markerInfo_prev = new Array();
  17. var endpointSelector = "";
  18. if (BemsWebApplication.config.mode == "production") {
  19. endpointSelector = new DevExpress.EndpointSelector(BemsWebApplication.config.endpoints).config.db.production;
  20. } else {
  21. endpointSelector = new DevExpress.EndpointSelector(BemsWebApplication.config.endpoints).config.db.local;
  22. }
  23. var treeViewData = [
  24. {
  25. id: 0,
  26. items: [],
  27. text: "온도"
  28. },
  29. {
  30. id: 1,
  31. items: [],
  32. text: "습도"
  33. },
  34. {
  35. id: 2,
  36. items: [],
  37. text: "CO2"
  38. },
  39. {
  40. id: 3,
  41. items: [],
  42. text: "CO"
  43. },
  44. {
  45. id: 4,
  46. items: [],
  47. text: "O3"
  48. },
  49. {
  50. id: 5,
  51. items: [],
  52. text: "미세먼지"
  53. }
  54. ];
  55. var mapType = {
  56. coordinate: { font: "fill: black; font-weight: bold; font-size: 15px;", fixed: 1 },
  57. temperature: { font: "fill: red; font-weight: bold; font-size: 20px;", fixed: 1 },
  58. humidity: { font: "fill: blue; font-weight: bold; font-size: 20px;", fixed: 0 },
  59. carboneDioxide: { font: "fill: green ; font-weight: bold; font-size: 20px;", fixed: 1 },
  60. concentration: { font: "fill: darkgreen; font-weight: bold; font-size: 20px;", fixed: 1 },
  61. ozone: { font: "fill: purple ; font-weight: bold; font-size: 20px;", fixed: 2 },
  62. dust: { font: "fill: orangered ; font-weight: bold; font-size: 20px;", fixed: 0 }
  63. };
  64. function GetSelectData() {
  65. treeViewData = [
  66. {
  67. id: 0,
  68. items: [],
  69. text: "온도",
  70. value: 100
  71. },
  72. {
  73. id: 1,
  74. items: [],
  75. text: "습도",
  76. value: 110
  77. },
  78. {
  79. id: 2,
  80. items: [],
  81. text: "CO2",
  82. value: 130
  83. },
  84. {
  85. id: 3,
  86. items: [],
  87. text: "CO",
  88. value: 140
  89. },
  90. {
  91. id: 4,
  92. items: [],
  93. text: "O3",
  94. value: 150
  95. },
  96. {
  97. id: 5,
  98. items: [],
  99. text: "미세먼지",
  100. value: 160
  101. }
  102. ];
  103. var dataSource = new DevExpress.data.DataSource({
  104. store: {
  105. type: "odata",
  106. url: endpointSelector + "/BemsMonitoringPoint",
  107. },
  108. requireTotalCount: true,
  109. pageSize: 5000,
  110. });
  111. dataSource.filter([
  112. ["SiteId", "=", BWA.UserInfo.SiteId()],
  113. "and",
  114. ["FacilityTypeId", "=", 99]
  115. ]);
  116. dataSource.load()
  117. .done(function (result) {
  118. for (var i = 0; i < result.length; i++) {
  119. if (result[i].FloorId != null) {
  120. if (result[i].ServiceTypeId == 100) { // 온도
  121. treeViewData[0].items.push({
  122. facilityTypeId: result[i].FacilityTypeId, facilityCode: result[i].FacilityCode, propertyId: result[i].PropertyId,
  123. text: result[i].Name, floorId: result[i].FloorId, zoneId: result[i].ZoneId,
  124. serviceTypeId: result[i].ServiceTypeId
  125. });
  126. }
  127. else if (result[i].ServiceTypeId == 110) // 습도
  128. treeViewData[1].items.push({
  129. facilityTypeId: result[i].FacilityTypeId, facilityCode: result[i].FacilityCode, propertyId: result[i].PropertyId,
  130. text: result[i].Name, floorId: result[i].FloorId, zoneId: result[i].ZoneId,
  131. serviceTypeId: result[i].ServiceTypeId
  132. });
  133. else if (result[i].ServiceTypeId == 130) // CO2
  134. treeViewData[2].items.push({
  135. facilityTypeId: result[i].FacilityTypeId, facilityCode: result[i].FacilityCode, propertyId: result[i].PropertyId,
  136. text: result[i].Name, floorId: result[i].FloorId, zoneId: result[i].ZoneId,
  137. serviceTypeId: result[i].ServiceTypeId
  138. });
  139. else if (result[i].ServiceTypeId == 140) // CO
  140. treeViewData[3].items.push({
  141. facilityTypeId: result[i].FacilityTypeId, facilityCode: result[i].FacilityCode, propertyId: result[i].PropertyId,
  142. text: result[i].Name, floorId: result[i].FloorId, zoneId: result[i].ZoneId,
  143. serviceTypeId: result[i].ServiceTypeId
  144. });
  145. else if (result[i].ServiceTypeId == 150) // O3
  146. treeViewData[4].items.push({
  147. facilityTypeId: result[i].FacilityTypeId, facilityCode: result[i].FacilityCode, propertyId: result[i].PropertyId,
  148. text: result[i].Name, floorId: result[i].FloorId, zoneId: result[i].ZoneId,
  149. serviceTypeId: result[i].ServiceTypeId
  150. });
  151. else if (result[i].ServiceTypeId == 160) // 미세먼지
  152. treeViewData[5].items.push({
  153. facilityTypeId: result[i].FacilityTypeId, facilityCode: result[i].FacilityCode, propertyId: result[i].PropertyId,
  154. text: result[i].Name, floorId: result[i].FloorId, zoneId: result[i].ZoneId,
  155. serviceTypeId: result[i].ServiceTypeId
  156. });
  157. }
  158. }
  159. })
  160. .fail(function (error) {
  161. utils.toast.show(error);
  162. });
  163. }
  164. function getImageSize(width, height) {
  165. var viewIndoor = $('#viewIndoor');
  166. var maxWidth = parseFloat(viewIndoor.css('width')), maxHeight = parseFloat(viewIndoor.css('height'));
  167. var widthRatio = width / maxWidth;
  168. var heightRatio = height / maxHeight;
  169. var maxRatio = max(widthRatio, heightRatio);
  170. if (maxRatio > 1) {
  171. return { width: width / maxRatio, height: height / maxRatio }
  172. }
  173. return { width: width, height: height }
  174. }
  175. function max(x, y) {
  176. if (x > y) return x;
  177. return y;
  178. }
  179. function loadImage(imageUrl) {
  180. $('#imageContext').find('text').remove();
  181. //var imageUrl = url;//'/Images/Blueprint/' + viewModel.dataModel.FloorId() + '.jpg';
  182. var image = document.getElementById("image");
  183. var newImage = new Image();
  184. newImage.onload = function () {
  185. var imageSize = getImageSize(newImage.width, newImage.height);
  186. $('#imageContext').css('width', imageSize.width).css('height', imageSize.height).css({
  187. 'border': '3px solid #1E90FF',
  188. 'border-radius': '5px',
  189. });
  190. $('#image').attr('width', imageSize.width).attr('height', imageSize.height); // 2016 05 30 추가, IE 문제해결, 종화
  191. }
  192. newImage.src = imageUrl;
  193. image.setAttributeNS('http://www.w3.org/1999/xlink', 'href', newImage.src);
  194. }
  195. function AddMarker(x, y) {
  196. var imageUrl = "https://js.devexpress.com/Demos/RealtorApp/images/map-marker.png";
  197. var image = document.createElementNS("http://www.w3.org/2000/svg", "image");
  198. image.setAttributeNS(null, 'x', x);
  199. image.setAttributeNS(null, 'y', y);
  200. image.setAttributeNS('http://www.w3.org/1999/xlink', 'href', imageUrl);
  201. $('#imageContext').append(image);
  202. markerArray_prev.push(image);
  203. markerArray_prev_forDelete.push(image);
  204. }
  205. function addText(x, y, text, style, type) {
  206. //************************
  207. if (type == 'coordinate') {
  208. var image = document.createElementNS("http://www.w3.org/2000/svg", "text");
  209. image.textContent = text;
  210. image.setAttributeNS(null, 'x', x);
  211. image.setAttributeNS(null, 'y', y);
  212. if (style) {
  213. image.setAttributeNS(null, 'style', style);
  214. }
  215. $('#imageContext').append(image);
  216. }
  217. else {
  218. if (type == 'temperature')
  219. var imageUrl = '/Images/Blueprint/object_1.png';
  220. else if (type == 'concentration')
  221. var imageUrl = '/Images/Blueprint/object_2.png';
  222. else if (type == 'carboneDioxide')
  223. var imageUrl = '/Images/Blueprint/object_3.png';
  224. else if (type == 'humidity')
  225. var imageUrl = '/Images/Blueprint/object_4.png';
  226. else if (type == 'dust')
  227. var imageUrl = '/Images/Blueprint/object_5.png';
  228. else if (type == 'ozone')
  229. var imageUrl = '/Images/Blueprint/object_6.png';
  230. var image = document.createElementNS("http://www.w3.org/2000/svg", "image");
  231. image.setAttributeNS(null, 'x', x);
  232. image.setAttributeNS(null, 'y', y);
  233. image.setAttributeNS('http://www.w3.org/1999/xlink', 'href', imageUrl);
  234. $('#imageContext').append(image);
  235. imageArray_prev.push(image);
  236. //************************
  237. var image = document.createElementNS("http://www.w3.org/2000/svg", "text");
  238. image.textContent = text;
  239. image.setAttributeNS(null, 'x', x + 45);
  240. image.setAttributeNS(null, 'y', y + 23);
  241. if (style) {
  242. image.setAttributeNS(null, 'style', style);
  243. }
  244. $('#imageContext').append(image);
  245. }
  246. }
  247. function setTextInSVG(values) {
  248. $('#imageContext').find('text').remove();
  249. // image 기존 이모티콘 지우기
  250. for (var i = 0; i < imageArray_prev.length; i++) {
  251. imageArray_prev[i].parentNode.removeChild(imageArray_prev[i]);
  252. }
  253. imageArray_prev = new Array();
  254. var floorTextLocationInfo = new Array();
  255. var cnt = 0;
  256. BemsFloorStatusDataSource.filter([
  257. ["SiteId", "=", BWA.UserInfo.SiteId()],
  258. "and",
  259. ["FloorId", "=", viewModel.dataModel.FloorId()]
  260. ]);
  261. BemsFloorStatusDataSource.load()
  262. .done(function (result) {
  263. for (var i = 0; i < result.length; i++) {
  264. floorTextLocationInfo[i] = {
  265. "floorId": 0,
  266. "x": 0,
  267. "y": 0,
  268. "type": "",
  269. "property": 0
  270. };
  271. floorTextLocationInfo[i].floorId = result[i].FloorId();
  272. floorTextLocationInfo[i].x = result[i].Xvalue();
  273. floorTextLocationInfo[i].y = result[i].Yvalue();
  274. floorTextLocationInfo[i].property = result[i].PropertyId();
  275. if (result[i].ServiceTypeId() == 100)
  276. floorTextLocationInfo[i].type = 'temperature';
  277. else if (result[i].ServiceTypeId() == 110)
  278. floorTextLocationInfo[i].type = 'humidity';
  279. else if (result[i].ServiceTypeId() == 130)
  280. floorTextLocationInfo[i].type = 'carboneDioxide';
  281. else if (result[i].ServiceTypeId() == 140)
  282. floorTextLocationInfo[i].type = 'concentration';
  283. else if (result[i].ServiceTypeId() == 150)
  284. floorTextLocationInfo[i].type = 'ozone';
  285. else if (result[i].ServiceTypeId() == 160)
  286. floorTextLocationInfo[i].type = 'dust';
  287. cnt++;
  288. }
  289. var newImage = new Image();
  290. newImage.onload = function () {
  291. var imageSize = getImageSize(newImage.width, newImage.height);
  292. var type = mapType['coordinate'];
  293. var coord_width = Math.round(imageSize.width);
  294. var coord_height = Math.round(imageSize.height);
  295. var coordination = '(' + coord_width + ',' + coord_height + ')';
  296. var coordination_x = '(' + coord_width + ',' + '0' + ')';
  297. var coordination_y = '(' + '0' + ',' + coord_height + ')';
  298. addText(10, 20, '(0,0)', type.font, 'coordinate'); //(0,0)을 나타내주기위함
  299. addText(coord_width - 80, coord_height - 10, coordination, type.font, 'coordinate'); //(max_x,max_y)을 나타내주기위함
  300. addText(coord_width - 60, 20, coordination_x, type.font, 'coordinate'); //(max_x,0)을 나타내주기위함
  301. addText(10, coord_height - 10, coordination_y, type.font, 'coordinate'); //(0,max_y)을 나타내주기위함
  302. for (var i = 0; i < cnt; i++) {
  303. var locationInfo = floorTextLocationInfo[i];
  304. var type = mapType[locationInfo.type];
  305. var value = values[i].toFixed(type.fixed);
  306. if (value != -9999) addText(locationInfo.x, locationInfo.y, value, type.font, locationInfo.type);
  307. }
  308. }
  309. newImage.src = imagefileUrl();
  310. });
  311. }
  312. function UpdateImage() {
  313. var promises = [];
  314. promises.push(BemsWebApplication.api.get('BemsMonitoringPointHistory/FloorEachPointValue', {
  315. SiteId: BWA.UserInfo.SiteId(),
  316. FloorId: viewModel.dataModel.FloorId(),
  317. }));
  318. $.when.apply(this, promises).done(function (values) {
  319. setTextInSVG(values);
  320. }).fail(function (error) {
  321. visiblePopup(false);
  322. });
  323. }
  324. function Insert(postData) {
  325. var store = new DevExpress.data.ODataStore({
  326. url: endpointSelector + "/BemsFloorStatus",
  327. key: ["SiteId", "FloorId", "FloorName", "ImageFileId", "Xvalue", "Yvalue", "PropertyId"],
  328. keyType: {
  329. SiteId: "Int32", FloorId: "Int32", FloorName: "String", ImageFileId: "Int32", Xvalue: "Int32", Yvalue: "Int32", PropertyId: "Int32"
  330. }
  331. });
  332. store.insert(postData).done(function (key, result) {
  333. utils.toast.show($G('successDatabaseInsertionMsg'));
  334. })
  335. .fail(function (error) {
  336. utils.toast.show(error);
  337. });
  338. }
  339. // 등록버튼 클릭
  340. function handlePopupButtonInsert() {
  341. var dataViewModel = viewModel.dataModel;
  342. var facility_code = $("#FacilityCode").dxSelectBox('instance').option('value');
  343. var control_Id = $("#ControlId").dxSelectBox('instance').option('value');
  344. var x_value = $("#XValue").dxTextBox('instance').option('value');
  345. var y_value = $("#YValue").dxTextBox('instance').option('value');
  346. var newImage = new Image();
  347. newImage.onload = function () {
  348. var imageSize = getImageSize(newImage.width, newImage.height);
  349. var type = mapType['coordinate'];
  350. if (facility_code == null || control_Id == null || x_value == "" || y_value == "") {
  351. utils.toast.show("필수 데이터가 부족합니다.", 'error');
  352. return;
  353. }
  354. else if (isNaN(x_value) || isNaN(y_value)) {
  355. utils.toast.show("좌표 값은 숫자형식으로 입력되어야합니다.", 'error');
  356. return;
  357. }
  358. else if (imageSize.width < 0 || imageSize.width <= x_value || imageSize.height < 0 || imageSize.height <= y_value) {
  359. utils.toast.show("좌표 값이 평면도 범위를 벗어납니다.", 'error');
  360. return;
  361. }
  362. //insert
  363. var postViewModel = new BemsWebApplication.BemsFloorStatusViewModel();
  364. postViewModel.SiteId(dataViewModel.SiteId());
  365. postViewModel.FloorId(dataViewModel.FloorId());
  366. postViewModel.FloorName(dataViewModel.Name());
  367. postViewModel.ImageFileId(dataViewModel.ImageFileId());
  368. postViewModel.Xvalue(parseInt(x_value));
  369. postViewModel.Yvalue(parseInt(y_value));
  370. postViewModel.FacilityTypeId(facilityTypeId_fin);
  371. postViewModel.FacilityCode(facilityCode_fin);
  372. postViewModel.PropertyId(propertyId_fin);
  373. postViewModel.ZoneId(zoneId_fin);
  374. postViewModel.ServiceTypeId(serviceTypeId_fin);
  375. postViewModel.FacilityName(facilityName_fin);
  376. var postData = postViewModel.toJS();
  377. Insert(postData);
  378. //DB 저장에 시간이 걸리기때문에 딜레이 후 데이터 로드
  379. setTimeout(function () {
  380. GetGridInPopup();
  381. InitializeData();
  382. UpdateImage();
  383. }, 100);
  384. }
  385. newImage.src = imagefileUrl();
  386. }
  387. // 삭제버튼 클릭
  388. function handlePopupButtonDelete() {
  389. DevExpress.ui.dialog.confirm($G('deleteConfirmMsg'), "삭제").then(function (result) {
  390. if (result) {
  391. var keys = $("#Observe_Point").dxDataGrid('instance').getSelectedRowKeys();
  392. for (var i = 0; i < keys.length; i++) {
  393. var num = 0;
  394. var removeData = {
  395. SiteId: keys[i].SiteId(),
  396. FloorId: keys[i].FloorId(),
  397. FloorName: keys[i].FloorName(),
  398. ImageFileId: keys[i].ImageFileId(),
  399. Xvalue: keys[i].Xvalue(),
  400. Yvalue: keys[i].Yvalue(),
  401. ZoneId: keys[i].ZoneId(),
  402. FacilityTypeId: keys[i].FacilityTypeId(),
  403. FacilityCode: keys[i].FacilityCode(),
  404. PropertyId: keys[i].PropertyId(),
  405. FacilityName: keys[i].FacilityName(),
  406. };
  407. BemsWebApplication.db['BemsFloorStatus'].remove(removeData).done(function () {
  408. viewModel.refreshList();
  409. utils.toast.show('데이터베이스 항목 삭제 작업이 성공하였습니다.');
  410. }).fail(function () {
  411. utils.toast.show('데이터베이스 항목 삭제 작업이 실패하였습니다.', 'error');
  412. });
  413. }
  414. }
  415. setTimeout(function () {
  416. GetGridInPopup();
  417. InitializeData();
  418. UpdateImage();
  419. }, 100);
  420. });
  421. }
  422. // 닫기버튼
  423. function PopupButtonClose() {
  424. viewModel.dataModel.ImageFileId(null);
  425. visiblePopup(false);
  426. GetGridData();
  427. }
  428. function GetGridData() {
  429. var gridData = new Array();
  430. var dataSource = new DevExpress.data.DataSource({
  431. store: {
  432. type: "odata",
  433. url: endpointSelector + "/BemsFloorPlan",
  434. },
  435. requireTotalCount: true,
  436. pageSize: 9999,
  437. });
  438. dataSource.filter([
  439. ["SiteId", "=", BWA.UserInfo.SiteId()]
  440. ]);
  441. dataSource.sort({ getter: "Name", asc: true });
  442. dataSource.load()
  443. .done(function (result) {
  444. for (var i = 0; i < result.length; i++) {
  445. gridData[i] = {
  446. "SiteId": 0,
  447. "FloorId": 0,
  448. "Name": "",
  449. "ImageFileId": 0
  450. };
  451. gridData[i].SiteId = result[i].SiteId;
  452. gridData[i].FloorId = result[i].FloorId;
  453. gridData[i].Name = result[i].Name;
  454. gridData[i].ImageFileId = result[i].ImageFileId;
  455. }
  456. $("#gridContainer").dxDataGrid("instance").option('dataSource', gridData);
  457. //$("#gridContainer").dxDataGrid("instance").refresh();
  458. })
  459. .fail(function (error) {
  460. utils.toast.show(error);
  461. });
  462. }
  463. function GetGridInPopup() {
  464. BemsFloorStatusDataSource.filter([
  465. ["FloorId", "=", viewModel.dataModel.FloorId()]
  466. ]);
  467. BemsFloorStatusDataSource.load()
  468. .done(function (FloorStatusResult) {
  469. floorstatus(FloorStatusResult);
  470. $("#Observe_Point").dxDataGrid("instance").option('dataSource', floorstatus());
  471. })
  472. }
  473. function InitializeData() {
  474. $("#FacilityCode").dxSelectBox({
  475. placeholder: "설비 이름",
  476. dataSource: treeViewData,
  477. displayExpr: "text",
  478. valueExpr: "id"
  479. });
  480. $("#ControlId").dxSelectBox({
  481. placeholder: "관제점 이름",
  482. });
  483. $("#XValue").dxTextBox({
  484. placeholder: "X축 값"
  485. });
  486. $("#YValue").dxTextBox({
  487. placeholder: "Y축 값"
  488. });
  489. $("#FacilityCode").dxSelectBox('instance').option('value', null);// 설비 이름 클리어
  490. $("#ControlId").dxSelectBox('instance').option('value', null);// 관제점 이름 클리어
  491. $("#XValue").dxTextBox('instance').option('value', "");
  492. $("#YValue").dxTextBox('instance').option('value', "");
  493. //select data update
  494. BemsFloorStatusDataSource.filter([
  495. ["FloorId", "=", viewModel.dataModel.FloorId()]
  496. ]);
  497. BemsFloorStatusDataSource.load()
  498. .done(function (FloorStatusResult) {
  499. $("#FacilityCode").dxSelectBox({
  500. onValueChanged: function () {
  501. controlIdforFloor = new Array();
  502. var value = $("#FacilityCode").dxSelectBox('instance').option('value');
  503. if (value != null) {
  504. controlIdDataSource = "";
  505. controlIdDataSource = treeViewData[value].items;
  506. for (var i = 0; i < controlIdDataSource.length; i++) {
  507. var isData = false;
  508. for (var j = 0; j < FloorStatusResult.length; j++) {
  509. if (FloorStatusResult[j].PropertyId() == controlIdDataSource[i].propertyId && FloorStatusResult[j].ServiceTypeId() == controlIdDataSource[i].serviceTypeId) {
  510. isData = true;
  511. break;
  512. }
  513. }
  514. if (controlIdDataSource[i].floorId == viewModel.dataModel.FloorId() && !isData) {
  515. controlIdforFloor.push(controlIdDataSource[i]);
  516. }
  517. }
  518. $("#ControlId").dxSelectBox('instance').option('value', null);// 텍스트 클리어
  519. $("#ControlId").dxSelectBox({
  520. placeholder: "관제점 이름",
  521. dataSource: controlIdforFloor,
  522. displayExpr: "text",
  523. valueExpr: "propertyId"
  524. });
  525. }
  526. }
  527. });
  528. $("#ControlId").dxSelectBox({
  529. onValueChanged: function () {
  530. var value = $("#ControlId").dxSelectBox('instance').option('text');
  531. if (value != null) {
  532. for (var i = 0; i < controlIdforFloor.length; i++) {
  533. if (controlIdforFloor[i].text == value) {
  534. facilityTypeId_fin = controlIdforFloor[i].facilityTypeId;
  535. facilityCode_fin = controlIdforFloor[i].facilityCode;
  536. propertyId_fin = controlIdforFloor[i].propertyId;
  537. facilityName_fin = controlIdforFloor[i].text;
  538. zoneId_fin = controlIdforFloor[i].zoneId;
  539. serviceTypeId_fin = controlIdforFloor[i].serviceTypeId;
  540. break;
  541. }
  542. }
  543. $("#ControlId").dxSelectBox('instance').option('text', controlIdforFloor);
  544. }
  545. }
  546. });
  547. });
  548. }
  549. var viewModel = BWA.DataGrid.createViewWithDataGrid(params, viewInfo, 'BemsFloorPlan', {
  550. dataSourceOptions: {
  551. select: [
  552. 'SiteId',
  553. 'FloorId',
  554. 'Name',
  555. 'ImageFileId'
  556. ],
  557. filter: [
  558. ['SiteId', '=', BWA.UserInfo.SiteId()]
  559. ],
  560. extendOptions: {
  561. forceOriginalField: true
  562. },
  563. },
  564. columns: [
  565. { dataField: 'SiteId', caption: '번호', width: '30%', alignment: 'center' },
  566. { dataField: 'Name', caption: '층 명칭', width: '70%', alignment: 'center', sortOrder: 'desc' },
  567. ],
  568. searchViewItems: [
  569. { id: 'FloorId', dataSource: FloorInPopUpForSearch },
  570. { id: 'Name' }
  571. ],
  572. //popupWidth: 450,
  573. NoSearchView: true, // 2019.07.25 kgpark 검색버튼 삭제
  574. paging: {
  575. pageSize: 20,
  576. enabled: true
  577. },
  578. pager: {
  579. },
  580. handleViewShowing: function () {
  581. $("#gridContainer").dxDataGrid({
  582. //paging: {
  583. // pageSize: 20
  584. //}
  585. });
  586. $("#Observe_Point").dxDataGrid({});
  587. setTimeout(function () {
  588. GetGridData();
  589. GetSelectData();
  590. }, 100);
  591. },
  592. handleDataGridRowClick: function (id, dataGrid, clickRow, popupVisible) {
  593. // image 기존 마커 지우기
  594. for (var i = 0; i < markerArray_prev.length; i++) {
  595. markerArray_prev[i].parentNode.removeChild(markerArray_prev[i]);
  596. }
  597. setTimeout(function () {
  598. markerArray_prev = new Array();
  599. }, 100);
  600. dataGrid.clearSelection();
  601. var data = clickRow.data;
  602. var viewDataModel = viewModel.dataModel;
  603. viewDataModel.Name(data.Name);
  604. viewDataModel.FloorId(data.FloorId);
  605. viewDataModel.ImageFileId(data.ImageFileId);
  606. viewDataModel.SiteId(data.SiteId);
  607. BemsFloorStatusDataSource.filter([
  608. ["SiteId", "=", BWA.UserInfo.SiteId()]
  609. ]);
  610. BemsFloorStatusDataSource.load()
  611. .done(function (FloorStatusResult) {
  612. floorstatus(FloorStatusResult);
  613. });
  614. if (data.ImageFileId != null) {
  615. // 여기서 ViewModel 설정하고 그리드 rowiTem
  616. // 갯수만 수정하면 되지 않을까? 만일 수정을 요청하면 말이다. hcLee 2016 01 14
  617. // 이미지 width, height를 제대로 설정하지 못하는 문제 해결
  618. if (RowClicked() == false) {
  619. visiblePopup(true);
  620. setTimeout(function () {
  621. imagefileUrl('{0}/CmFile(SiteId={1},FileId={2})/$value'.formati(BWA.db._url, viewModel.dataModel.SiteId(), viewDataModel.ImageFileId()));
  622. loadImage(imagefileUrl());
  623. }, 100)
  624. RowClicked(true);
  625. }
  626. else {
  627. imagefileUrl('{0}/CmFile(SiteId={1},FileId={2})/$value'.formati(BWA.db._url, viewModel.dataModel.SiteId(), viewDataModel.ImageFileId()));
  628. loadImage(imagefileUrl());
  629. setTimeout(function () {
  630. visiblePopup(true);
  631. }, 100)
  632. }
  633. // 이미지 width, height를 제대로 설정하지 못하는 문제 해결
  634. var SelectedDataArray = new Array();
  635. $("#Observe_Point").dxDataGrid({
  636. //dataSource: floorstatus(),
  637. selection: { mode: 'multiple', allowSelectAll: true },
  638. columns: [
  639. //{ dataField: 'FloorName', caption: '층 이름', width: '25%', alignment: 'center' },
  640. { dataField: 'FacilityName', caption: '관제점 이름 (' + viewModel.dataModel.Name() + ')', width: '60%', alignment: 'center' },
  641. { dataField: 'Xvalue', caption: 'x축', width: '20%', alignment: 'center' },
  642. { dataField: 'Yvalue', caption: 'y축', width: '20%', alignment: 'center' },
  643. ],
  644. //scrolling: {
  645. // mode: 'standard'
  646. //}
  647. onSelectionChanged: function (selectedItems) {
  648. var data = selectedItems.selectedRowsData;
  649. if (data.length < markerArray_prev.length) {
  650. UpdateImage();
  651. }
  652. // image 기존 마커 지우기
  653. for (var i = 0; i < markerArray_prev.length; i++) {
  654. markerArray_prev[i].parentNode.removeChild(markerArray_prev[i]);
  655. }
  656. setTimeout(function () {
  657. markerArray_prev = new Array();
  658. for (var i = 0; i < data.length; i++) {
  659. AddMarker(data[i].Xvalue(), data[i].Yvalue());
  660. }
  661. }, 100);
  662. }
  663. });
  664. }
  665. else {
  666. visiblePopup(false);
  667. utils.toast.show('해당 층의 평면도가 없습니다.','error');
  668. }
  669. },
  670. handleViewShown: function () {
  671. },
  672. });
  673. viewModel.imagefileUrl = imagefileUrl;
  674. viewModel.FloorInPopUp = FloorInPopUp;
  675. viewModel.dataModel.FloorId = ko.observable();
  676. viewModel.handlePopupButtonInsert = handlePopupButtonInsert;
  677. viewModel.handlePopupButtonDelete = handlePopupButtonDelete;
  678. viewModel.popupOptions = {
  679. width: 1500,//1250,
  680. height: 750,
  681. visible: visiblePopup,
  682. dragEnabled: true,
  683. shading: true,
  684. closeOnOutsideClick: false,
  685. shadingColor: 'transparent',
  686. showTitle: true,
  687. title: "관제점 등록",
  688. showCloseButton: true,
  689. onShowing: function () {
  690. setTimeout(function () {
  691. GetGridInPopup();
  692. InitializeData();
  693. UpdateImage();
  694. }, 100);
  695. },
  696. onShown: function () {
  697. },
  698. onHidden: function () {
  699. }
  700. }
  701. return viewModel;
  702. };