manager.js 27 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697989910010110210310410510610710810911011111211311411511611711811912012112212312412512612712812913013113213313413513613713813914014114214314414514614714814915015115215315415515615715815916016116216316416516616716816917017117217317417517617717817918018118218318418518618718818919019119219319419519619719819920020120220320420520620720820921021121221321421521621721821922022122222322422522622722822923023123223323423523623723823924024124224324424524624724824925025125225325425525625725825926026126226326426526626726826927027127227327427527627727827928028128228328428528628728828929029129229329429529629729829930030130230330430530630730830931031131231331431531631731831932032132232332432532632732832933033133233333433533633733833934034134234334434534634734834935035135235335435535635735835936036136236336436536636736836937037137237337437537637737837938038138238338438538638738838939039139239339439539639739839940040140240340440540640740840941041141241341441541641741841942042142242342442542642742842943043143243343443543643743843944044144244344444544644744844945045145245345445545645745845946046146246346446546646746846947047147247347447547647747847948048148248348448548648748848949049149249349449549649749849950050150250350450550650750850951051151251351451551651751851952052152252352452552652752852953053153253353453553653753853954054154254354454554654754854955055155255355455555655755855956056156256356456556656756856957057157257357457557657757857958058158258358458558658758858959059159259359459559659759859960060160260360460560660760860961061161261361461561661761861962062162262362462562662762862963063163263363463563663763863964064164264364464564664764864965065165265365465565665765865966066166266366466566666766866967067167267367467567667767867968068168268368468568668768868969069169269369469569669769869970070170270370470570670770870971071171271371471571671771871972072172272372472572672772872973073173273373473573673773873974074174274374474574674774874975075175275375475575675775875976076176276376476576676776876977077177277377477577677777877978078178278378478578678778878979079179279379479579679779879980080180280380480580680780880981081181281381481581681781881982082182282382482582682782882983083183283383483583683783883984084184284384484584684784884985085185285385485585685785885986086186286386486586686786886987087187287387487587687787887988088188288388488588688788888989089189289389489589689789889990090190290390490590690790890991091191291391491591691791891992092192292392492592692792892993093193293393493593693793893994094194294394494594694794894995095195295395495595695795895996096196296396496596696796896997097197297397497597697797897998098198298398498598698798898999099199299399499599699799899910001001
  1. import { TMapMngr, TFclt } from "/js/vworld/map-mngr.js";
  2. import { LayerType, LayerIndex } from "/js/vworld/map-const.js";
  3. let _mapManager = null;
  4. let _selectFcltNmbr = null;
  5. const _lyrIdx = LayerIndex.Cctv;
  6. //우측 섹션 관련
  7. let _managerData = [];
  8. let _managerTable = null;
  9. let _idArr = [];
  10. let cctvNo = null;
  11. let cctvNm = null;
  12. let cctvId = null;
  13. let cctvX = null;
  14. let cctvY = null;
  15. let ctrlIp = null;
  16. let ctlrPort = null;
  17. let strmSvrIp = null;
  18. let strmSvrPort = null;
  19. let lctnNm = null;
  20. let strmSesnNm = null;
  21. let camNo = null;
  22. let outRstp = null;
  23. let intrHttp = null;
  24. let outHttp = null;
  25. let webRtcId = null;
  26. let webRtcIp = null;
  27. let webRtcPort = null;
  28. let rtcId = null;
  29. let rtcIp = null;
  30. let rtcPort = null;
  31. let saveBtn = null;
  32. let cancleBtn = null;
  33. let addBtn = null;
  34. let delBtn = null;
  35. let editBtn = null;
  36. let addNum = 0;
  37. let nmbrCheck = null;
  38. let homepageYn = null;
  39. let cctvCaptIp = null;
  40. const ipExpr = /^[0-9]{1,3}[.]{1}[0-9]{1,3}[.]{1}[0-9]{1,3}[.]{1}[0-9]{1,3}$/;
  41. const _updateColumns = {
  42. altt_imag_dspl_yn: "N",
  43. altt_imag_nmbr: 0,
  44. cctv_area_dvsn: "1",
  45. cctv_capt_ip : null,
  46. cctv_capt_port: null,
  47. cctv_ctlr_id: null,
  48. cctv_ctlr_ip: null,
  49. cctv_ctlr_local_no: 0,
  50. cctv_ctlr_nmbr: null,
  51. cctv_ctlr_port: null,
  52. cctv_id: null,
  53. cctv_nm: null,
  54. cctv_type_cd : null,
  55. fan_off_tmpr : 25,
  56. fan_on_tmpr : 30,
  57. hetr_off_tmpr : 10,
  58. hetr_on_tmpr : 5,
  59. del_yn : "N",
  60. intr_http_addr: null,
  61. istl_lctn_addr: null,
  62. istl_lctn_nm: null,
  63. link_id: null,
  64. node_id: null,
  65. strm_rtsp_addr: null,
  66. strm_http_addr: null,
  67. strm_sesn_nm: null,
  68. strm_svr_ip : null,
  69. strm_svr_port : null,
  70. syop_cntl_yn: "N",
  71. use_yn : "Y",
  72. rtc_id : null,
  73. rtc_svr_ip : null,
  74. rtc_svr_port: 0,
  75. x_crdn: 0,
  76. y_crdn: 0,
  77. homepage_yn: null,
  78. };
  79. //공통
  80. let commonUri = "/api/cctv/manager/info";
  81. const _pageName = 'CCTV 기본정보 관리';
  82. const pageMsg = "CCTV";
  83. const inputArr = [
  84. (cctvNo = {
  85. box : null,
  86. option : 80,
  87. disabled : true,
  88. label : "CCTV 관리번호",
  89. column : "cctv_ctlr_nmbr",
  90. max : 10,
  91. must : true,
  92. }),
  93. (cctvId = {
  94. box : null,
  95. option : 120,
  96. disabled : false,
  97. label : "제어기 ID",
  98. column : "cctv_ctlr_id",
  99. id : true,
  100. max : 10,
  101. must : true,
  102. }),
  103. (camNo = {
  104. box : null,
  105. option : 60,
  106. disabled : false,
  107. label : "카메라 번호",
  108. column : "cctv_ctlr_local_no",
  109. number : true,
  110. max : 5,
  111. must : true,
  112. }),
  113. (cctvNm = {
  114. box : null,
  115. option : 255,
  116. disabled : false,
  117. label : "CCTV 명칭",
  118. column : "cctv_nm",
  119. max : 40,
  120. must : true,
  121. }),
  122. (lctnNm = {
  123. box : null,
  124. option : 255,
  125. label : "위치명",
  126. must : true,
  127. disabled : false,
  128. column : "istl_lctn_nm",
  129. max : 40,
  130. }),
  131. (ctrlIp = {
  132. box : null,
  133. option : 140,
  134. label : "제어기 IP",
  135. disabled : false,
  136. must : true,
  137. expr : ipExpr,
  138. column : "cctv_ctlr_ip",
  139. max : 20,
  140. }),
  141. (ctlrPort = {
  142. box : null,
  143. option : 80,
  144. label : "제어기 PORT",
  145. disabled : false,
  146. must : true,
  147. number : true,
  148. column : "cctv_ctlr_port",
  149. max : 5,
  150. }),
  151. (cctvCaptIp = {
  152. box : null,
  153. option : 255,
  154. label : "카메라 IP",
  155. disabled : false,
  156. must : false,
  157. number : false,
  158. column : "cctv_capt_ip",
  159. max : 20,
  160. }),
  161. (cctvX = {
  162. box : null,
  163. option : 110,
  164. label : "X좌표",
  165. disabled : false,
  166. must : true,
  167. value : "0.00000000",
  168. method: function (e) {
  169. crdnChanges(e, 3);
  170. },
  171. column: "x_crdn",
  172. max: 12,
  173. }),
  174. (cctvY = {
  175. box : null,
  176. option : 110,
  177. disabled : false,
  178. label : "Y좌표",
  179. must : true,
  180. value : "0.00000000",
  181. method: function (e) {
  182. crdnChanges(e, 2);
  183. },
  184. column: "y_crdn",
  185. max: 11,
  186. }),
  187. (strmSvrIp = {
  188. box : null,
  189. option : 140,
  190. label : "분배서버 IP",
  191. disabled : false,
  192. must : true,
  193. expr : ipExpr,
  194. column : "strm_svr_ip",
  195. max : 20,
  196. }),
  197. (strmSvrPort = {
  198. box : null,
  199. option : 80,
  200. label : "분배서버 PORT",
  201. disabled : false,
  202. must : true,
  203. number : true,
  204. column : "strm_svr_port",
  205. max : 5,
  206. }),
  207. (strmSesnNm = {
  208. box : null,
  209. option : 255,
  210. label : "스트리밍 세션명",
  211. disabled : false,
  212. column : "strm_sesn_nm",
  213. max : 200,
  214. }),
  215. (outRstp = {
  216. class : "out-rstp",
  217. box : null,
  218. option : 255,
  219. label : "스트리밍 RSTP 주소",
  220. disabled : false,
  221. column : "strm_rtsp_addr",
  222. max : 200,
  223. }),
  224. // (intrHttp = {
  225. // box : null,
  226. // option : 255,
  227. // label : "인터넷 HLS 주소",
  228. // disabled : false,
  229. // column : "intr_http_addr",
  230. // max : 200,
  231. // }),
  232. // (outHttp = {
  233. // box : null,
  234. // option : 255,
  235. // label : "스트리밍 HTTP 주소",
  236. // disabled : false,
  237. // column : "strm_http_addr",
  238. // max : 200,
  239. // }),
  240. (webRtcId = {
  241. box : null,
  242. option : 255,
  243. label : "WEB RTC ID",
  244. disabled : false,
  245. column : "rtc_id",
  246. max : 56,
  247. }),
  248. (webRtcIp = {
  249. box : null,
  250. option : 140,
  251. label : "WEB RTC IP",
  252. disabled : false,
  253. column : "web_rtc_svr_ip",
  254. // expr : ipExpr,
  255. max : 30,
  256. }),
  257. (webRtcPort = {
  258. box : null,
  259. option : 80,
  260. label : "WEB RTC PORT",
  261. number : true,
  262. disabled : false,
  263. column : "web_rtc_svr_port",
  264. max : 5,
  265. }),
  266. (rtcId = {
  267. box : null,
  268. option : 255,
  269. label : "RTC ID",
  270. disabled : false,
  271. column : "web_rtc_id",
  272. max : 56,
  273. }),
  274. (rtcIp = {
  275. box : null,
  276. option : 140,
  277. label : "RTC IP",
  278. disabled : false,
  279. column : "rtc_svr_ip",
  280. expr : ipExpr,
  281. max : 20,
  282. }),
  283. (rtcPort = {
  284. box : null,
  285. option : 80,
  286. label : "RTC PORT",
  287. number : true,
  288. disabled : false,
  289. column : "rtc_svr_port",
  290. max : 5,
  291. }),
  292. (homepageYn = {
  293. box : null,
  294. option : 80,
  295. label : "홈페이지 영상표출",
  296. select : true,
  297. dataSource: ['Y', 'N'],
  298. disabled : false,
  299. column : 'homepage_yn'
  300. })
  301. ];
  302. const btnArr = [
  303. (editBtn = {
  304. class: "edit-btn",
  305. box: null,
  306. option: 80,
  307. visible: true,
  308. disabled: true,
  309. dbdsb: false,
  310. edit: {
  311. click: {
  312. visible: false,
  313. disabled: false,
  314. },
  315. cancle: {
  316. visible: true,
  317. disabled: false,
  318. },
  319. },
  320. add: {
  321. click: {
  322. visible: false,
  323. disabled: false,
  324. },
  325. selected: {
  326. visible: true,
  327. disabled: false,
  328. },
  329. unSelected: {
  330. visible: true,
  331. disabled: true,
  332. },
  333. },
  334. addvsb: false,
  335. icon: "edit",
  336. text: "편집",
  337. method: function () {
  338. editEvent();
  339. },
  340. }),
  341. (cancleBtn = {
  342. class: "cancle-btn",
  343. box: null,
  344. option: 80,
  345. visible: false,
  346. disabled: false,
  347. dbdsb: false,
  348. edit: {
  349. click: {
  350. visible: true,
  351. disabled: false,
  352. },
  353. cancle: {
  354. visible: false,
  355. disabled: false,
  356. },
  357. },
  358. add: {
  359. click: {
  360. visible: true,
  361. disabled: false,
  362. },
  363. selected: {
  364. visible: false,
  365. disabled: false,
  366. },
  367. unSelected: {
  368. visible: false,
  369. disabled: false,
  370. },
  371. },
  372. addvsb: true,
  373. icon: "close",
  374. text: "취소",
  375. }),
  376. (addBtn = {
  377. class: "add-btn",
  378. box: null,
  379. option: 80,
  380. disabled: false,
  381. visible: true,
  382. edit: {
  383. click: {
  384. visible: true,
  385. disabled: true,
  386. },
  387. cancle: {
  388. visible: true,
  389. disabled: false,
  390. },
  391. },
  392. add: {
  393. click: {
  394. visible: true,
  395. disabled: true,
  396. },
  397. selected: {
  398. visible: true,
  399. disabled: false,
  400. },
  401. unSelected: {
  402. visible: true,
  403. disabled: false,
  404. },
  405. },
  406. dbdsb: false,
  407. adddsb: true,
  408. icon: "plus",
  409. text: "추가",
  410. method: function () {
  411. addEvent();
  412. },
  413. }),
  414. (delBtn = {
  415. class: "del-btn",
  416. box: null,
  417. option: 80,
  418. disabled: true,
  419. visible: true,
  420. edit: {
  421. click: {
  422. visible: true,
  423. disabled: true,
  424. },
  425. cancle: {
  426. visible: true,
  427. disabled: false,
  428. },
  429. },
  430. add: {
  431. click: {
  432. visible: true,
  433. disabled: true,
  434. },
  435. selected: {
  436. visible: true,
  437. disabled: false,
  438. },
  439. unSelected: {
  440. visible: true,
  441. disabled: true,
  442. },
  443. },
  444. dbdsb: false,
  445. adddsb: true,
  446. icon: "minus",
  447. text: "삭제",
  448. method: function () {
  449. const cctvCtlrNmbr = _managerTable.getSelectedRowsData()[0].cctv_ctlr_nmbr;
  450. confirmMessage(pageMsg
  451. + "번호 : "
  452. + cctvCtlrNmbr
  453. + "<br>선택하신 " + pageMsg + " 정보를 삭제하시겠습니까?").done((yes)=>{
  454. if (yes === true) {
  455. const result = deleteData(commonUri, cctvCtlrNmbr);
  456. if (result > 0) {
  457. delResultMsg(pageMsg);
  458. boxInit();
  459. buttonReset("add", "unSelected");
  460. _managerTable.option("focusedRowKey", null);
  461. _managerData = [];
  462. getData(commonUri, _managerData);
  463. dataSorting(_managerData[0], 'cctv_ctlr_id');
  464. _managerTable.option('dataSource', _managerData[0]);
  465. deleteFcltObject(cctvCtlrNmbr);
  466. }
  467. }
  468. });
  469. },
  470. }),
  471. (saveBtn = {
  472. class: "save-btn",
  473. box: null,
  474. option: 80,
  475. disabled: true,
  476. dbdsb: true,
  477. edit: {
  478. click: {
  479. visible: true,
  480. disabled: false,
  481. },
  482. cancle: {
  483. visible: true,
  484. disabled: true,
  485. },
  486. },
  487. add: {
  488. click: {
  489. visible: true,
  490. disabled: false,
  491. },
  492. selected: {
  493. visible: true,
  494. disabled: true,
  495. },
  496. unSelected: {
  497. visible: true,
  498. disabled: true,
  499. },
  500. },
  501. adddsb: false,
  502. visible: true,
  503. icon: "save",
  504. text: "저장",
  505. }),
  506. ];
  507. let typeCd = null;
  508. //let useYn = null;
  509. $(() => {
  510. typeCd = new dxSelect($('.cctv_type_cd'), 'outlined', 140, 27, 'cctv_type_cd_desc', 'cctv_type_cd', true, 'cctv_type_cd', 'CCTV 유형코드');
  511. //상단 닫기 버튼
  512. $(".cancle-button")
  513. .dxButton({
  514. text: "닫기",
  515. icon: "close",
  516. height: "30px",
  517. width: "80px",
  518. stylingMode: "outlined",
  519. onClick() {
  520. window.close();
  521. },
  522. })
  523. .dxButton("instance");
  524. inputArr.map((item) => {
  525. if (item.select) {
  526. item.box = $("." + item.column)
  527. .dxSelectBox({
  528. width: item.option,
  529. stylingMode: "outlined",
  530. readOnly: true,
  531. height: 27,
  532. dataSource: item.dataSource,
  533. })
  534. .dxSelectBox("instance");
  535. }
  536. else {
  537. item.box = $("." + item.column)
  538. .dxTextBox({
  539. width: item.option,
  540. stylingMode: "outlined",
  541. readOnly: true,
  542. maxLength: item.max,
  543. height: 27,
  544. })
  545. .dxTextBox("instance");
  546. }
  547. if (item.value) {
  548. item.box.option("value", item.value);
  549. }
  550. if (item.method) {
  551. item.box.on("valueChanged", item.method);
  552. }
  553. });
  554. btnArr.map((item) => {
  555. item.box = $("." + item.class)
  556. .dxButton({
  557. icon: item.icon,
  558. width: item.option,
  559. text: item.text,
  560. visible: item.visible,
  561. disabled: item.disabled,
  562. focusStateEnabled: false,
  563. stylingMode: "outlined",
  564. onClick() {
  565. if (item.method) {
  566. item.method();
  567. }
  568. },
  569. })
  570. .dxButton("instance");
  571. });
  572. // 지도객체 생성
  573. doMap();
  574. // 시설물 정보를 읽어 온다.
  575. getData(commonUri, _managerData);
  576. if (_managerData[0].length > 0) {
  577. dataSorting(_managerData[0], 'cctv_ctlr_id');
  578. }
  579. updateIcon();
  580. //CCTV 제어기 목록
  581. let columns = [
  582. {
  583. dataField: "cctv_ctlr_id",
  584. caption: "CCTV ID",
  585. width: 120,
  586. alignment: "center",
  587. },
  588. {
  589. dataField: "istl_lctn_nm",
  590. caption: "설치 위치",
  591. alignment: "center",
  592. cellTemplate(c, e) {
  593. c.css("text-align", "left");
  594. return c.text(e.displayValue);
  595. },
  596. },
  597. ];
  598. _managerTable = initializedGrid($(".manager-table"), '100%', '100%', columns,
  599. _managerData[0], 'single', 'standard', 'cctv_ctlr_nmbr', false, true,
  600. false, 1000, false, false, false, '', true, '', null)
  601. .dxDataGrid("instance");
  602. _managerTable.on('rowDblClick', (e) => listDblClick(e));
  603. fetchTypeData();
  604. });
  605. /**
  606. * CCTV 유형 데이터 수신
  607. */
  608. function fetchTypeData(){
  609. getDataAsync(_codeUrl + '/CCTVT',(jsonData)=>{
  610. let typeCdData = [];
  611. jsonData.map((item)=>{
  612. typeCdData.push({
  613. cctv_type_cd : item.cmmn_cd,
  614. cctv_type_cd_desc : '[ ' + item.cmmn_cd +' ] ' + item.cmmn_cd_kor_nm,
  615. });
  616. })
  617. typeCd.setDataSource(typeCdData);
  618. typeCd.setValue(jsonData[0].cmmn_cd);
  619. });
  620. }
  621. /**
  622. * CCTV 목록 더블클릭
  623. * @param e 더블클릭 로우 정보
  624. */
  625. function listDblClick(e){
  626. _selectFcltNmbr = e.data.cctv_ctlr_nmbr;
  627. selectFcltObject(_selectFcltNmbr);
  628. inputArr.map((item) => {
  629. if (item.box) {
  630. item.box.option("value", e.data[item.column]);
  631. }
  632. });
  633. typeCd.setValue(e.data[typeCd.column]);
  634. btnArr.map((item) => {
  635. if (item.box) {
  636. item.box.option("disabled", item.dbdsb);
  637. }
  638. });
  639. }
  640. /**
  641. * 이벤트 활성화
  642. */
  643. function editEvent() {
  644. editFcltObject(_selectFcltNmbr, true);
  645. cancleBtn.box.off("click");
  646. cancleBtn.box.on("click", () => editCancel());
  647. eventOn();
  648. cctvId.box.option('readOnly', true);
  649. btnArr.map((item) => {
  650. if (item.box) {
  651. item.box.option("visible", item.edit.click.visible);
  652. item.box.option("disabled", item.edit.click.disabled);
  653. }
  654. });
  655. saveBtn.box.off('click');
  656. saveBtn.box.on('click', () => saveEvent('edit'));
  657. }
  658. /**
  659. * 이벤트 비활성화
  660. */
  661. function editCancel() {
  662. updateIcon();
  663. eventCancel();
  664. boxPull();
  665. buttonReset("edit", "cancle");
  666. }
  667. /**
  668. * CCTV ID 전체 값
  669. * @returns {*[]} CCTV ID 배열
  670. */
  671. function getIdArr(){
  672. let idArr = [];
  673. if (_managerData[0].length > 0) {
  674. _managerData[0].map((obj)=>{
  675. if(obj.cctv_ctlr_id)idArr.push(obj.cctv_ctlr_id);
  676. })
  677. }
  678. return idArr;
  679. }
  680. /**
  681. * 저장 버튼 클릭
  682. * @param type 편집 유형
  683. * @returns {boolean|*}
  684. */
  685. function saveEvent(type) {
  686. _idArr = getIdArr();
  687. for (let input of inputArr) {
  688. const box = input.box;
  689. if (box) {
  690. const value = getValue(box) === "" ? null : getValue(box);
  691. const max = input.max;
  692. const label = input.label;
  693. if (!nullChecker(value)) {
  694. if (input.must) {
  695. return alertWarning( "필수 항목을 입력해주세요. [ " + label +" ]", null, box);
  696. }
  697. }
  698. else {
  699. if (max && getByteLength(value) > max) {
  700. return alertWarning( max + " 바이트 이내로 입력해주세요. [ " + label +" ]", null, box);
  701. }
  702. if (input.expr && !input.expr.test(value)) {
  703. return alertWarning("IP 형식에 맞게 입력해주세요. [ " + label +" ]", null, box);
  704. }
  705. if (input.number && isNaN(value)) {
  706. return alertWarning("해당 항목은 숫자만 입력이 가능합니다. [ " + label + " ]", null, box);
  707. }
  708. if (input.id && _idArr.includes(value) && type === "add") {
  709. return alertWarning( "제어기 ID : " + value + "<br>이미 사용중인 제어기 ID 입니다.", null, box);
  710. }
  711. }
  712. }
  713. }
  714. let updateData = {..._updateColumns};
  715. if (type === 'edit') {
  716. // 수정모드일 경우에는....
  717. const rowData = _managerTable.getSelectedRowsData()[0];
  718. for (let key in updateData) {
  719. updateData[key] = rowData[key];
  720. }
  721. console.log('edit mode...')
  722. }
  723. // 수정모드인 경우와 추가 모드 비교해야함...
  724. inputArr.map((item) => {
  725. if (item.column && item.box) {
  726. const value = item.box.option("value");
  727. updateData[item.column] = value === "" ? null : value;
  728. }
  729. });
  730. updateData.cctv_type_cd = typeCd.getValue();
  731. //updateData.use_yn = useYn.getValue() ? "Y" : "N";
  732. //ctrlIpNum
  733. let result = postInsertUpdate(commonUri + "/" + updateData.cctv_ctlr_nmbr, updateData);
  734. if (result > 0) {
  735. insResultMsg(pageMsg);
  736. _managerData = [];
  737. getData(commonUri, _managerData);
  738. dataSorting(_managerData[0], 'cctv_ctlr_id');
  739. _managerTable.option('dataSource', _managerData[0]);
  740. _managerTable.clearSelection();
  741. _managerTable.refresh().done(function () {
  742. _managerTable.selectRows(updateData.cctv_ctlr_nmbr, true).done(()=>{
  743. _managerTable.option("focusedRowKey", updateData.cctv_ctlr_nmbr);
  744. boxPull();
  745. buttonReset("add", "selected");
  746. updateIcon();
  747. eventCancel();
  748. });
  749. });
  750. }
  751. }
  752. /**
  753. * 추가버튼 클릭 후 취소
  754. */
  755. function addCancel() {
  756. updateIcon();
  757. eventCancel();
  758. if (_managerTable.getSelectedRowsData().length > 0) {
  759. boxPull();
  760. buttonReset("add", "selected");
  761. return;
  762. }
  763. boxInit();
  764. buttonReset("add", "unSelected");
  765. }
  766. /**
  767. * 추가 버튼 클릭
  768. */
  769. function addEvent() {
  770. eventOn();
  771. boxInit();
  772. let center = _mapManager.getCenter();
  773. cancleBtn.box.off("click");
  774. cancleBtn.box.on("click", () => addCancel());
  775. cctvX.box.option("value", center[0].toFixed(8));
  776. cctvY.box.option("value", center[1].toFixed(8));
  777. addNum = getNewNmbr();
  778. const lastData = _managerData[0][_managerData[0].length - 1]
  779. setValue(camNo.box, lastData.cctv_ctlr_local_no + 1);
  780. setValue(homepageYn.box, "Y");
  781. let idVal = lastData.cctv_ctlr_id;
  782. if (idVal.length){
  783. let idNo = idVal.substring(idVal.indexOf('V') + 1, idVal.length);
  784. if (!isNaN(idNo)) {
  785. let cctvIdVal = 'CCTV' + (Number(idNo) + 10);
  786. setValue(cctvId.box, cctvIdVal);
  787. }
  788. }
  789. addFcltObject(addNum);
  790. cctvNo.box.option("value", addNum);
  791. btnArr.map((item) => {
  792. item.box.option("visible", item.add.click.visible);
  793. item.box.option("disabled", item.add.click.disabled);
  794. });
  795. saveBtn.box.off('click');
  796. saveBtn.box.on('click', () => saveEvent('add'));
  797. }
  798. /**
  799. * input 데이터 값 넣기
  800. */
  801. function boxPull() {
  802. let selectedRow = _managerTable.getSelectedRowsData()[0];
  803. inputArr.map((item) => {
  804. if (item.box) {
  805. item.box.option("value", selectedRow[item.column]);
  806. }
  807. });
  808. typeCd.setValue(selectedRow[typeCd.valueExpr]);
  809. }
  810. /**
  811. * input 데이터 값 초기화
  812. */
  813. function boxInit() {
  814. inputArr.map((item) => {
  815. if (item.value) return item.box.option("value", item.value);
  816. if (item.box) {
  817. item.box.option("value", null);
  818. }
  819. });
  820. //useYn.setValue(false);
  821. typeCd.setValue(typeCd.getDataSource()[0][typeCd.valueExpr])
  822. }
  823. /**
  824. * 버튼 상태 초기화
  825. * @param eventName 이벤트 명
  826. * @param option 옵션
  827. */
  828. function buttonReset(eventName, option) {
  829. btnArr.map((item) => {
  830. item.box.option("visible", item[eventName][option].visible);
  831. item.box.option("disabled", item[eventName][option].disabled);
  832. });
  833. }
  834. /**
  835. * 이벤트 취소
  836. */
  837. function eventCancel() {
  838. dsblOffBtn(_managerTable);
  839. inputArr.map((item) => {
  840. if (item.box) {
  841. item.box.option("readOnly", true);
  842. }
  843. });
  844. typeCd.setReadOnly(true);
  845. //useYn.setReadOnly(true);
  846. if(_managerTable.getSelectedRowsData().length > 0){
  847. _selectFcltNmbr = _managerTable.getSelectedRowsData()[0].cctv_ctlr_nmbr;
  848. selectFcltObject(_selectFcltNmbr);
  849. }
  850. }
  851. /**
  852. * 이벤트 활성화
  853. */
  854. function eventOn() {
  855. dsblOnBtn(_managerTable);
  856. typeCd.setReadOnly(false);
  857. //useYn.setReadOnly(false);
  858. inputArr.map((item) => {
  859. if (item.box) {
  860. item.box.option("readOnly", item.disabled);
  861. }
  862. });
  863. }
  864. /**
  865. * 제어기 신규 ID 조회
  866. */
  867. function getNewNmbr() {
  868. let newId = [];
  869. getData(commonUri + "/new-id", newId);
  870. _selectFcltNmbr = newId[0].new_id;
  871. return _selectFcltNmbr;
  872. }
  873. /**
  874. * 지도 인터페이스 함수........
  875. */
  876. function doMap() {
  877. _mapManager = new TMapMngr("traf-hs-map", "tooltip");
  878. _mapManager.setEditMode(_lyrIdx, true);
  879. _mapManager.showLayer(_lyrIdx, true);
  880. _mapManager.onFcltDragEndFunc = onFcltDragEndFunc; // 객체(시설물) 편집시 객체 이동후 좌표 반환
  881. _mapManager.onMouseClickFunc = onMouseClickFunc; // 객체 마우스 클릭 이벤트 반환
  882. _mapManager.checkFcltEditMode(_lyrIdx);
  883. _mapManager.showFcltObjectText(_lyrIdx, true);
  884. fetchMapIconBar($('.map-bar'), _mapManager, _pageName, fcltObjectTextOnOff, null);
  885. }
  886. function fcltObjectTextOnOff(e){
  887. _mapManager.showFcltObjectText(_lyrIdx, e.value);
  888. _mapManager.refreshLayer(_lyrIdx);
  889. }
  890. function onFcltDragEndFunc(ALyrIdx, ALyrName, ANmbr, ACoordX, ACoordY) {
  891. if (ALyrIdx != _lyrIdx) {
  892. return;
  893. }
  894. if (ANmbr === _selectFcltNmbr) {
  895. cctvX.box.option("value", ACoordX.toFixed(8));
  896. cctvY.box.option("value", ACoordY.toFixed(8));
  897. }
  898. console.log(`onFcltDragEndFunc, ${ALyrIdx}, ${ALyrName}, ${ANmbr}, ${ACoordX}, ${ACoordY}`);
  899. }
  900. function onMouseClickFunc(ALyrIdx, ALyrName, ANmbr, ACoordX, ACoordY, X, Y) {
  901. if (ALyrIdx != _lyrIdx) {
  902. return;
  903. }
  904. // console.log(`onMouseClickFunc, ${ALyrIdx}, ${ALyrName}, ${ANmbr}, ${ACoordX}, ${ACoordY}, ${X}, ${Y}`);
  905. const obj = _mapManager.findLayerObject(ALyrIdx, ANmbr);
  906. if (!obj) {
  907. return;
  908. }
  909. else {
  910. if (_selectFcltNmbr === ANmbr) {
  911. return;
  912. }
  913. if (!editBtn.box.option('visible')) {
  914. return;
  915. }
  916. _selectFcltNmbr = ANmbr;
  917. selectFcltObject(_selectFcltNmbr);
  918. _managerTable.selectRows(ANmbr).done(()=>{
  919. _managerTable.option('focusedRowKey',ANmbr);
  920. const selectedData = _managerTable.getSelectedRowsData()[0];
  921. inputArr.map((item) => {
  922. if (item.box) {
  923. item.box.option("value", selectedData[item.column]);
  924. }
  925. });
  926. typeCd.setValue(selectedData[typeCd.column]);
  927. btnArr.map((item) => {
  928. item.box.option("disabled", item.dbdsb);
  929. });
  930. });
  931. }
  932. }
  933. /**
  934. * 지도에 시설물 객체 정보를 그린다.
  935. */
  936. function updateIcon() {
  937. // 기존 객체를 모두 삭제한다.
  938. _mapManager.removeLayerObject(_lyrIdx);
  939. if (_managerData[0] && _managerData[0].length > 0) {
  940. // 시설물 객체를 지도에 그린다.
  941. const objs = new Array();
  942. _managerData[0].forEach((obj) => {
  943. const item = new TFclt(obj.cctv_ctlr_nmbr, obj.istl_lctn_nm, obj.x_crdn, obj.y_crdn);
  944. objs.push(item);
  945. });
  946. _mapManager.initFcltObject(_lyrIdx, objs);
  947. }
  948. }
  949. function selectFcltObject(ANmbr) {
  950. _mapManager.selectLayerObject(_lyrIdx, ANmbr);
  951. }
  952. function editFcltObject(ANmbr, AIsEdit) {
  953. _mapManager.editFcltObject(_lyrIdx, ANmbr, AIsEdit, AIsEdit ? "1" : "0");
  954. }
  955. function deleteFcltObject(ANmbr) {
  956. _mapManager.deleteFcltObject(_lyrIdx, ANmbr);
  957. _selectFcltNmbr = null;
  958. }
  959. function addFcltObject(ANmbr) {
  960. _mapManager.createFcltObject(_lyrIdx, ANmbr, "New", "New", "1" /*아이콘색결정,시설물유형_N.png*/ /*, x_crdn, y_crdn*/);
  961. }