a9595d065223be9bdc23a3c07b54b5595a8e405b.svn-base 30 KB

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