info.js 31 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872
  1. import { TMapMngr, TFclt } from "/js/vworld/map-mngr.js";
  2. import { LayerIndex } from "/js/vworld/map-const.js";
  3. let _mapManager = null;
  4. let _selectFcltNmbr = null;
  5. let _vmsTableList = null;
  6. let _managerData = [];
  7. const _pageMsg = 'VMS';
  8. const _pageName = 'VMS 기본정보 관리';
  9. const _lyrIdx = LayerIndex.Vms;
  10. const _apiUri = '/api/vms/manager/info';
  11. const _vmsBtnBoxMap = new Map();
  12. const _vmsCdTypeMap = new Map();
  13. const _vmsInputBoxMap = new Map();
  14. /***
  15. * VMS_MAX_PHSE_NUM = 16; //VMS 최대 표출면 개수
  16. VMS_PHSE_CHNG_CYCL = 5; //VMS 표출면 변경 주기(계획된 메시지의 동작시간(초))
  17. VMS_CMNC_ERR_BASS_VAL = 127; //VMS 통신 오류 기본 값(모듈 전원이 꺼지는 온도값(℃))
  18. FAN_MTNS_TMPR = 35; //팬동작온도
  19. HETR_MTNS_TMPR = 0; //히터동작온도
  20. VMS_MODL_ERR_RATE = 20; //모듈장애율(Options)
  21. */
  22. const _updateColumns = {
  23. brgh_mode: null,
  24. cmncfail_slot_nmbr : 0,
  25. cmtrinfr_cnct_yn : "N",
  26. del_yn : "N",
  27. envrinfr_cnct_yn : "N",
  28. fan_mtns_tmpr : 35,
  29. frst_regr_nmbr : null,
  30. frst_rgst_dt : null,
  31. hetr_mtns_tmpr : 0,
  32. istl_lctn_nm : null,
  33. last_crct_dt : null,
  34. last_crpr_nmbr : window.opener.$userId,
  35. oper_mode : "A",
  36. panl_off_time : null,
  37. panl_on_time : null,
  38. panl_pwer_mode : null,
  39. pwer_fail_slot_nmbr : 0,
  40. strm_sesn_nm : null,
  41. trfc_strg_use_yn : "N",
  42. vms_cmnc_err_bass_val : 127,
  43. vms_cmnc_port : null,
  44. vms_ctlr_id : null,
  45. vms_ctlr_ip : null,
  46. vms_ctlr_nmbr : 0,
  47. vms_frm_type_cd : null,
  48. vms_id : null,
  49. vms_loc_ifsc_id : 0,
  50. vms_max_phse_num : 0,
  51. vms_modl_err_rate : 20,
  52. vms_modl_type_cd : null,
  53. vms_nght_brgh_step : 0,
  54. vms_nm : null,
  55. vms_phse_chng_cycl : 5,
  56. vms_type_cd : null,
  57. vms_usag_type_cd : null,
  58. vms_week_brgh_step : 0,
  59. web_cmra_id : null,
  60. web_cmra_ip : null,
  61. web_cmra_port : null,
  62. web_cmra_pwd : null,
  63. wthrinfr_cnct_yn : "N",
  64. x_crdn : 0,
  65. y_crdn : 0,
  66. strm_http_addr: null,
  67. strm_rtsp_addr: null,
  68. }
  69. const _btnClasses = [
  70. 'all-vms-apply-btn',
  71. 'close-btn',
  72. 'edit-btn',
  73. 'add-btn',
  74. 'del-btn',
  75. 'save-btn',
  76. 'cancle-btn'
  77. ];
  78. const _inputClasses = [
  79. 'vms_ctlr_nmbr',
  80. 'vms_ctlr_id',
  81. 'vms_nm',
  82. 'vms_usag_type_cd',
  83. 'vms_type_cd',
  84. 'x_crdn',
  85. 'y_crdn',
  86. 'vms_ctlr_ip',
  87. 'vms_cmnc_port',
  88. 'web_cmra_ip',
  89. 'web_cmra_port',
  90. 'web_cmra_id',
  91. 'web_cmra_pwd',
  92. 'strm_sesn_nm',
  93. 'vms_max_phse_num',
  94. 'panl_on_time',
  95. 'panl_off_time',
  96. 'strm_http_addr',
  97. 'strm_rtsp_addr',
  98. ];
  99. const panlTimeColumns = [
  100. 'panl_on_time',
  101. 'panl_off_time'
  102. ];
  103. $(()=>{
  104. _vmsTableList = $('.list-table').width('100%').height('100%').dxDataGrid({
  105. dataSource : null,
  106. allowColumnReordering : true,
  107. showColumnLines : true,
  108. showBorders : true,
  109. allowColumnResizing : true,
  110. rowAlternationEnabled : true,
  111. focusedRowEnabled : true,
  112. columnAutoWidth : true,
  113. noDataText : '표출할 정보가 없습니다.',
  114. keyExpr : 'vms_ctlr_nmbr',
  115. headerFilter : {
  116. visible: true,
  117. },
  118. scrolling : {
  119. mode : 'standard',
  120. },
  121. paging: {
  122. enabled: true,
  123. pageSize: 1000,
  124. },
  125. selection: {
  126. mode: 'single',
  127. },
  128. columns:[
  129. {
  130. dataField : "vms_ctlr_nmbr",
  131. caption : "번호",
  132. alignment : "center",
  133. sortOrder : 'asc',
  134. sortIndex : 0,
  135. cssClass : 'no-padding',
  136. },
  137. {
  138. dataField : "vms_ctlr_id",
  139. caption : "VMS ID",
  140. alignment : "center",
  141. cssClass : 'no-padding',
  142. },
  143. {
  144. dataField : "vms_usag_type_cd",
  145. caption : "유형",
  146. alignment : "center",
  147. cssClass : 'no-padding',
  148. lookup : {
  149. dataSource : null,
  150. valueExpr : "vms_usag_type_cd",
  151. displayExpr : "vms_usag_type_desc",
  152. }
  153. },
  154. {
  155. dataField : "vms_type_cd",
  156. caption : "크기",
  157. alignment : "center",
  158. cssClass : 'no-padding',
  159. lookup : {
  160. dataSource : null,
  161. valueExpr : "vms_type_cd",
  162. displayExpr : "vms_type_nm",
  163. }
  164. },
  165. {
  166. dataField : "vms_ctlr_ip",
  167. caption : "제어가 IP",
  168. alignment : "center",
  169. cssClass : 'no-padding',
  170. },
  171. {
  172. dataField : "vms_cmnc_port",
  173. caption : "통신포트",
  174. alignment : "center",
  175. cssClass : 'no-padding',
  176. },
  177. {
  178. dataField : "web_cmra_ip",
  179. caption : "웹카메라 IP",
  180. alignment : "center",
  181. cssClass : 'no-padding',
  182. },
  183. {
  184. dataField : "panl_on_time",
  185. caption : "전광판 ON",
  186. alignment : "center",
  187. cssClass : 'no-padding',
  188. },
  189. {
  190. dataField : "panl_off_time",
  191. caption : "전광판 OFF",
  192. alignment : "center",
  193. cssClass : 'no-padding',
  194. },
  195. {
  196. dataField : "vms_max_phse_num",
  197. caption : "폼 최대갯수",
  198. alignment : "center",
  199. cssClass : 'no-padding',
  200. },
  201. ],
  202. onRowDblClick(row){
  203. vmsTableDblClick(row);
  204. }
  205. }).dxDataGrid('instance');
  206. fetchVmsInputArray();
  207. fetchVmsButtonArray();
  208. fetchBaseData();
  209. });
  210. //필요 데이터 가져오기
  211. async function fetchBaseData(){
  212. getDataAsync('/api/vms/common/vms-type', fetchVmsType);
  213. getDataAsync('/api/vms/common/vms-usage', fetchVmsUsage);
  214. getDataAsync(_apiUri, fetchInfoTableList );
  215. }
  216. //VMS 목록 수신 및 세팅
  217. function fetchInfoTableList(jsonData){
  218. _vmsTableList.option('dataSource', jsonData);
  219. _managerData.push(jsonData);
  220. console.log(jsonData);
  221. doMap();
  222. updateIcon();
  223. }
  224. //VMS 유형 코드 데이터 수신 및 데이터 소스 세팅
  225. function fetchVmsUsage(jsonData){
  226. _vmsCdTypeMap.set('vms_usag_type_cd', jsonData);
  227. _vmsTableList.option('columns[2].lookup.dataSource', jsonData);
  228. const vmsUsagSelect = _vmsInputBoxMap.get('vms_usag_type_cd').get('input');
  229. vmsUsagSelect.option('dataSource', jsonData);
  230. setValue(vmsUsagSelect, jsonData[0].vms_usag_type_cd);
  231. _vmsInputBoxMap.get('vms_usag_type_cd').set('init', jsonData[0].vms_usag_type_cd);
  232. }
  233. //VMS 크기 코드 데이터 수신 및 데이터 소스 세팅
  234. function fetchVmsType(jsonData){
  235. _vmsCdTypeMap.set('vms_type_cd', jsonData);
  236. _vmsTableList.option('columns[3].lookup.dataSource', jsonData);
  237. const vmsTypeCdSelect = _vmsInputBoxMap.get('vms_type_cd').get('input');
  238. vmsTypeCdSelect.option('dataSource', jsonData);
  239. setValue(vmsTypeCdSelect, jsonData[0].vms_type_cd);
  240. _vmsInputBoxMap.get('vms_type_cd').set('init', jsonData[0].vms_type_cd);
  241. }
  242. //버튼들 화면 세팅
  243. function fetchVmsButtonArray(){
  244. _btnClasses.forEach( (btnClass)=>{
  245. _vmsBtnBoxMap.set(btnClass, new Map());
  246. const btnInfoBox = _vmsBtnBoxMap.get(btnClass);
  247. btnInfoBox.set('btn', $('.'+btnClass).dxButton({}).dxButton('instance'));
  248. switch(btnClass){
  249. case 'all-vms-apply-btn':
  250. setVmsBtnOption(btnClass, '전체 VMS 적용', 'save', allVmsApplyEvent, true, false);
  251. break;
  252. case 'close-btn':
  253. setVmsBtnOption(btnClass, '닫기', 'close', closeEvent);
  254. break;
  255. case 'edit-btn':
  256. setVmsBtnOption(btnClass, '편집', 'edit', editEvent, true, true);
  257. btnInfoBox.set('dblClick', [true, false]);
  258. btnInfoBox.set('event', [false, false]);
  259. btnInfoBox.set('cancle', [true, false, true]);
  260. break;
  261. case 'add-btn':
  262. setVmsBtnOption(btnClass, '추가', 'plus', addEvent, true, false);
  263. btnInfoBox.set('dblClick', [true, false]);
  264. btnInfoBox.set('event', [true, true]);
  265. btnInfoBox.set('cancle', [true, false, false]);
  266. break;
  267. case 'del-btn':
  268. setVmsBtnOption(btnClass, '삭제', 'minus', delEvent, true, true);
  269. btnInfoBox.set('dblClick', [true, false]);
  270. btnInfoBox.set('event', [true, true]);
  271. btnInfoBox.set('cancle', [true, false, true]);
  272. break;
  273. case 'save-btn':
  274. setVmsBtnOption(btnClass, '저장', 'save', null, true, true);
  275. btnInfoBox.set('dblClick', [true, true]);
  276. btnInfoBox.set('event', [true, false]);
  277. btnInfoBox.set('cancle', [true, true, true]);
  278. break;
  279. case 'cancle-btn':
  280. setVmsBtnOption(btnClass, '취소', 'close', cancleEvent, false, false);
  281. btnInfoBox.set('dblClick', [false, false]);
  282. btnInfoBox.set('event', [true, false]);
  283. btnInfoBox.set('cancle', [false, false, false]);
  284. break;
  285. default :
  286. break
  287. }
  288. });
  289. }
  290. //inputBox 화면 세팅
  291. function fetchVmsInputArray(){
  292. _inputClasses.forEach( (inputClass)=>{
  293. _vmsInputBoxMap.set(inputClass, new Map());
  294. const inputBox = _vmsInputBoxMap.get(inputClass);
  295. inputBox.set('input', null);
  296. switch(inputClass){
  297. case 'vms_ctlr_nmbr' :
  298. setVmsInputOption(inputClass, 'text', 60, null, 10);
  299. inputBox.set('must', '제어기 번호');
  300. break
  301. case 'vms_ctlr_id':
  302. setVmsInputOption(inputClass, 'text', 100, null, 30);
  303. inputBox.set('must', 'VMS ID');
  304. break
  305. case 'vms_nm' :
  306. setVmsInputOption(inputClass, 'text', 250, null, 40);
  307. inputBox.set('must', 'VMS 명칭');
  308. break
  309. case 'vms_usag_type_cd' :
  310. setVmsInputOption(inputClass, 'select', 250);
  311. inputBox.set('must', 'VMS 유형');
  312. break
  313. case 'vms_type_cd' :
  314. setVmsInputOption(inputClass, 'select', 250);
  315. inputBox.set('must', 'VMS 크기');
  316. break
  317. case 'x_crdn' :
  318. setVmsInputOption(inputClass, 'text', 120, '0.00000000', 11);
  319. inputBox.set('must', '위치좌표 X');
  320. inputBox.get('input').on('valueChanged', (text) => crdnChanges(text, 3));
  321. break
  322. case 'y_crdn' :
  323. setVmsInputOption(inputClass, 'text', 120, '0.00000000', 11);
  324. inputBox.set('must', '위치좌표 Y');
  325. inputBox.get('input').on('valueChanged', (text) => crdnChanges(text, 2));
  326. break
  327. case 'vms_ctlr_ip' :
  328. setVmsInputOption(inputClass, 'text', 170, null, 20);
  329. inputBox.set('must', '제어기 IP');
  330. break
  331. case 'vms_cmnc_port' :
  332. setVmsInputOption(inputClass, 'text', 70, null, 5);
  333. inputBox.set('must', '제어기 PORT');
  334. break
  335. case 'web_cmra_ip' :
  336. setVmsInputOption(inputClass, 'text', 170, null, 20);
  337. break
  338. case 'web_cmra_port' :
  339. setVmsInputOption(inputClass, 'text', 70, null, 5);
  340. break
  341. case 'web_cmra_id' :
  342. setVmsInputOption(inputClass, 'text', 120, null, 30);
  343. break
  344. case 'web_cmra_pwd' :
  345. setVmsInputOption(inputClass, 'text', 120, null, 64);
  346. break
  347. case 'strm_sesn_nm' :
  348. setVmsInputOption(inputClass, 'text', 250, null, 200);
  349. break
  350. case 'strm_http_addr' :
  351. setVmsInputOption(inputClass, 'text', 250, null, 200);
  352. break
  353. case 'strm_rtsp_addr' :
  354. setVmsInputOption(inputClass, 'text', 250, null, 200);
  355. break
  356. case 'vms_max_phse_num' :
  357. setVmsInputOption(inputClass, 'number', 70, 10, 16);
  358. break
  359. case 'panl_on_time' :
  360. setVmsInputOption(inputClass, 'time', 70, firstSettingTime);
  361. inputBox.set('must', '전광판 ON 시각');
  362. break
  363. case 'panl_off_time' :
  364. setVmsInputOption(inputClass, 'time', 70, firstSettingTime);
  365. inputBox.set('must', '전광판 OFF 시각');
  366. break
  367. default :
  368. break
  369. }
  370. });
  371. }
  372. //input 옵션 세팅
  373. function setVmsInputOption( inputClass, type, width, value, max, maskRules){
  374. const inputBox = _vmsInputBoxMap.get(inputClass);
  375. inputBox.set('init', '');
  376. if(value) inputBox.set('init', value);
  377. switch (type) {
  378. case 'text':
  379. inputBox.set('input', $('.' + inputClass).dxTextBox({
  380. value : value,
  381. readOnly : true,
  382. width : width,
  383. stylingMode : 'outlined',
  384. height : 25,
  385. maskRules : maskRules,
  386. maxLength : max,
  387. }).dxTextBox('instance'));
  388. break;
  389. case 'number':
  390. inputBox.set('input', $('.' + inputClass).dxNumberBox({
  391. value : value,
  392. readOnly : true,
  393. width : width,
  394. stylingMode : 'outlined',
  395. showSpinButtons : true,
  396. height : 25,
  397. min : 1,
  398. max : max,
  399. }).dxNumberBox('instance'));
  400. break;
  401. case 'select':
  402. const valueExpr = inputClass;
  403. const displayExpr = valueExpr.substring(0,valueExpr.length-2) + 'desc';
  404. inputBox.set('input', $('.' + inputClass).dxSelectBox({
  405. displayExpr : displayExpr,
  406. valueExpr : valueExpr,
  407. readOnly : true,
  408. width : width,
  409. stylingMode : 'outlined',
  410. height : 25,
  411. }).dxSelectBox('instance'));
  412. break;
  413. case 'time':
  414. inputBox.set('input', $('.' + inputClass).dxDateBox({
  415. type : type,
  416. value : value,
  417. readOnly : false,
  418. width : width,
  419. stylingMode : 'outlined',
  420. height : 25,
  421. displayFormat : 'HH:mm',
  422. interval : 10,
  423. }).dxDateBox('instance'));
  424. break
  425. default:
  426. break;
  427. }
  428. }
  429. //버튼 옵션 세팅
  430. function setVmsBtnOption( classNm, text, icon, event, visible, disabled){
  431. let btn = _vmsBtnBoxMap.get(classNm).get('btn');
  432. if(btn){
  433. btn.option('text', text);
  434. btn.option('icon', icon);
  435. btn.option('onClick', event);
  436. btn.option('visible', visible);
  437. btn.option('disabled', disabled);
  438. btn.option('stylingMode', 'outlined');
  439. };
  440. };
  441. //전체 VMS 적용 이벤트
  442. function allVmsApplyEvent(){
  443. const panlOnTime = getInput('panl_on_time');
  444. const panlOffTime = getInput('panl_off_time');
  445. let onTime = getValue(panlOnTime);
  446. let offTime = getValue(panlOffTime)
  447. let panlTimeParam = {};
  448. let data = [];
  449. let ctrlNmvr = null;
  450. for (let panlTimeColumn of panlTimeColumns){
  451. const inputBox = _vmsInputBoxMap.get(panlTimeColumn);
  452. const input = getInput(panlTimeColumn);
  453. if (nullChecker(getValue(input)) === ""){
  454. input.focus();
  455. return alertWarning(inputBox.get('must') + '을 입력해주세요', null, input);
  456. }
  457. else if (input.option('validationError')){
  458. input.focus();
  459. return alertWarning('전광판 On/Off 시각을 바르게 입력해주세요', null, input);
  460. }
  461. };
  462. if (_vmsTableList.getSelectedRowsData().length > 0) ctrlNmvr = _vmsTableList.getSelectedRowsData()[0].vms_ctlr_nmbr;
  463. confirmMessage("제어기 설정 정보를 전체 VMS에 동일하게 적용 하시겠습니까?").done((yes) => {
  464. if (yes === true) {
  465. onTime = getSendTime(onTime);
  466. offTime = getSendTime(offTime);
  467. panlTimeParam['panl_on_time'] = onTime;
  468. panlTimeParam['panl_off_time'] = offTime;
  469. const result = postInsertUpdate(_apiUri + '/panl-time', panlTimeParam);
  470. if (result > 0) {
  471. refresh(_vmsTableList, data, _apiUri);
  472. if (ctrlNmvr){
  473. _vmsTableList.clearSelection();
  474. _vmsTableList.selectRows(ctrlNmvr, true).done(function () {
  475. _vmsTableList.option("focusedRowKey", ctrlNmvr);
  476. _vmsTableList.refresh();
  477. });
  478. };
  479. eventOff();
  480. return alertConfirm('VMS 제어기 설정 정보저장<br>제이기 설정 정보를 전체 제어기에 적용 하였습니다.');
  481. };
  482. //return alertConfirm('VMS 제이기 설정 정보저장<br>제이기 설정 정보를 전체 제어기에 적용 되지 않았습니다.');
  483. }
  484. });
  485. };
  486. //닫기 이벤트
  487. function closeEvent(){
  488. window.close();
  489. };
  490. //편집 이벤트
  491. function editEvent(){
  492. eventOn();
  493. editFcltObject(_selectFcltNmbr, true);
  494. _vmsBtnBoxMap.get('save-btn').get('btn').off('click');
  495. _vmsBtnBoxMap.get('save-btn').get('btn').on('click', () => saveEvent('edit'));
  496. };
  497. //추가 이벤트
  498. function addEvent(){
  499. eventOn(true);
  500. let center = _mapManager.getCenter();
  501. const xCrdn = getInput('x_crdn');
  502. const yCrdn = getInput('y_crdn');
  503. setValue(xCrdn, center[0]);
  504. setValue(yCrdn, center[1]);
  505. const newNum = getNewNmbr();
  506. addFcltObject(newNum);
  507. setValue( getInput('vms_ctlr_nmbr'), newNum);
  508. _vmsBtnBoxMap.get('save-btn').get('btn').off('click');
  509. _vmsBtnBoxMap.get('save-btn').get('btn').on('click', () => saveEvent());
  510. };
  511. //삭제 이벤트
  512. function delEvent(){
  513. const vmsCtlrNmbr = _vmsTableList.getSelectedRowsData()[0].vms_ctlr_nmbr;
  514. if (confirm(_pageMsg + "번호 : " + vmsCtlrNmbr + "\n선택하신 " + _pageMsg + " 정보를 삭제하시겠습니까?")) {
  515. const result = deleteData(_apiUri, vmsCtlrNmbr);
  516. if (result > 0) {
  517. delResultMsg(_pageMsg);
  518. _managerData = refresh(_vmsTableList, _managerData, _apiUri);
  519. _vmsTableList.refresh().done(function () {
  520. _vmsTableList.option("focusedRowIndex", -1);
  521. _vmsTableList.clearSelection();
  522. });
  523. deleteFcltObject(vmsCtlrNmbr);
  524. }
  525. }
  526. };
  527. //저장 이벤트
  528. function saveEvent(type){
  529. let updateData = {..._updateColumns};
  530. if (type === 'edit') {
  531. let rowData = _vmsTableList.getSelectedRowsData()[0];
  532. for (let key in updateData) {
  533. updateData[key] = rowData[key];
  534. }
  535. }
  536. let selected = false;
  537. for( let inputClass of _inputClasses){
  538. const inputBox = _vmsInputBoxMap.get(inputClass);
  539. const input = getInput(inputClass);
  540. const value = input.option('value');
  541. if(inputBox.get('must') && nullChecker(value) === ""){
  542. input.focus();
  543. return alertWarning(inputBox.get('must') + " 정보를 입력해주세요.", null, input);
  544. };
  545. updateData[inputClass] = value;
  546. };
  547. if(!/^[0-9]{1,3}[.]{1}[0-9]{1,3}[.]{1}[0-9]{1,3}[.]{1}[0-9]{1,3}$/.test(updateData.vms_ctlr_ip)){
  548. const edIp = getInput('vms_ctlr_ip');
  549. edIp.focus();
  550. return alertWarning("스트리밍 주소 IP를 형식에 맞게 입력해주세요.", null, edIp);
  551. };
  552. if( updateData.web_cmra_ip && !/^[0-9]{1,3}[.]{1}[0-9]{1,3}[.]{1}[0-9]{1,3}[.]{1}[0-9]{1,3}$/.test(updateData.web_cmra_ip)){
  553. const edIp = getInput('web_cmra_ip');
  554. edIp.focus();
  555. return alertWarning("웹카메라 IP를 형식에 맞게 입력해주세요.", null, edIp);
  556. };
  557. if( updateData.strm_http_addr && !/^[0-9]{1,3}[.]{1}[0-9]{1,3}[.]{1}[0-9]{1,3}[.]{1}[0-9]{1,3}$/.test(updateData.strm_http_addr)){
  558. const edIp = getInput('strm_http_addr');
  559. edIp.focus();
  560. return alertWarning("스트리밍 HTTP 주소 IP를 형식에 맞게 입력해주세요.", null, edIp);
  561. };
  562. if( updateData.strm_rtsp_addr && !/^[0-9]{1,3}[.]{1}[0-9]{1,3}[.]{1}[0-9]{1,3}[.]{1}[0-9]{1,3}$/.test(updateData.strm_rtsp_addr)){
  563. const edIp = getInput('strm_rtsp_addr');
  564. edIp.focus();
  565. return alertWarning("스트리밍 RSTP 주소 IP를 형식에 맞게 입력해주세요.", null, edIp);
  566. };
  567. for( let panlTimeColumn of panlTimeColumns){
  568. const input = getInput(panlTimeColumn);
  569. if(input.option('validationError')){
  570. input.focus();
  571. return alertWarning('전광판 On/Off 시각을 바르게 입력해주세요', null, input);
  572. }
  573. }
  574. updateData.panl_on_time = getSendTime(updateData.panl_on_time);
  575. updateData.panl_off_time = getSendTime(updateData.panl_off_time);
  576. updateData.vms_id = updateData.vms_ctlr_nmbr % 10000;
  577. updateData.vms_modl_type_cd = updateData.vms_usag_type_cd === 'VUTN' ? "VMM0" : "VMM1";
  578. if (_vmsTableList.getRowIndexByKey(updateData.vms_ctlr_nmbr) > -1 && _vmsTableList.getSelectedRowsData().length > 0){
  579. let selectedData = _vmsTableList.getSelectedRowsData()[0];
  580. for(let key in updateData){
  581. if(!_inputClasses.includes(key) && key !== 'vms_id' && key !== 'vms_modl_type_cd'){
  582. updateData[key] = selectedData[key];
  583. }
  584. }
  585. selected = true;
  586. }
  587. console.log(updateData);
  588. let result = postInsertUpdate(_apiUri + "/" + updateData.vms_ctlr_nmbr, updateData);
  589. if (result <= 0) {
  590. return alertWarning("VMS 제어기 정보가 저장되지 않았습니다.");
  591. }
  592. insResultMsg("VMS 제어기");
  593. _managerData = refresh(_vmsTableList, _managerData, _apiUri);
  594. if(selected){
  595. _vmsTableList.clearSelection();
  596. _vmsTableList.selectRows(updateData.vms_ctlr_nmbr, true).done(function () {
  597. _vmsTableList.option("focusedRowKey", updateData.vms_ctlr_nmbr);
  598. _vmsTableList.refresh();
  599. });
  600. }
  601. eventOff();
  602. };
  603. //취소 이벤트
  604. function cancleEvent(){
  605. eventOff();
  606. };
  607. //vms 목록 더블클릭 이벤트
  608. function vmsTableDblClick(row){
  609. if(row.data){
  610. const vmsInfo = row.data;
  611. _selectFcltNmbr = vmsInfo.vms_ctlr_nmbr;
  612. selectFcltObject(_selectFcltNmbr);
  613. _inputClasses.forEach(inputClass => {
  614. const inputBox = _vmsInputBoxMap.get(inputClass).get('input');
  615. setValue(inputBox, vmsInfo[inputClass]);
  616. if(inputClass === 'panl_on_time' || inputClass === 'panl_off_time'){
  617. let timeVal = vmsInfo[inputClass];
  618. let now = nowTime();
  619. timeVal = now.substring(0,10) +' '+ timeVal.substring(0,2) + ':' + timeVal.substring(2,4)+ ':00';
  620. timeVal = new Date(timeVal).getTime();
  621. setValue(inputBox, timeVal);
  622. }
  623. });
  624. _btnClasses.forEach( (btnClass)=>{
  625. const btnInfoBox = _vmsBtnBoxMap.get(btnClass);
  626. const btn = btnInfoBox.get('btn');
  627. if(btnInfoBox.get('dblClick')){
  628. const options = btnInfoBox.get('dblClick');
  629. btn.option('visible', options[0]);
  630. btn.option('disabled', options[1]);
  631. }
  632. })
  633. }
  634. }
  635. //이벤트 실행시 발생 이벤트
  636. function eventOn(init){
  637. _btnClasses.forEach( (btnClass)=>{
  638. const btnInfoBox = _vmsBtnBoxMap.get(btnClass);
  639. const btn = btnInfoBox.get('btn');
  640. if(btnInfoBox.get('event')){
  641. const options = btnInfoBox.get('event');
  642. btn.option('visible', options[0]);
  643. btn.option('disabled', options[1]);
  644. };
  645. });
  646. _inputClasses.forEach(inputClass => {
  647. const inputInfoBox = _vmsInputBoxMap.get(inputClass);
  648. const inputBox = inputInfoBox.get('input');
  649. inputBox.option('readOnly', false);
  650. if(inputClass === 'vms_ctlr_nmbr'){
  651. inputBox.option('readOnly', true);
  652. }
  653. if(init){
  654. inputBox.option('value', inputInfoBox.get('init'));
  655. }
  656. });
  657. dsblOnBtn(_vmsTableList);
  658. }
  659. //이벤트 취소시 발생 이벤트
  660. function eventOff(){
  661. dsblOffBtn(_vmsTableList);
  662. updateIcon();
  663. const selectedData = _vmsTableList.getSelectedRowsData();
  664. const selected = selectedData.length > 0 ? true : false;
  665. _btnClasses.forEach( (btnClass)=>{
  666. const btnInfoBox = _vmsBtnBoxMap.get(btnClass);
  667. const btn = btnInfoBox.get('btn');
  668. if(btnInfoBox.get('cancle')){
  669. const options = btnInfoBox.get('cancle');
  670. btn.option('visible', options[0]);
  671. if (selected) {
  672. btn.option('disabled', options[1]);
  673. } else{
  674. btn.option('disabled', options[2]);
  675. }
  676. };
  677. });
  678. _inputClasses.forEach(inputClass => {
  679. const inputInfoBox = _vmsInputBoxMap.get(inputClass);
  680. const inputBox = inputInfoBox.get('input');
  681. inputBox.option('readOnly', true);
  682. if('panl_on_time' === inputClass || 'panl_off_time' === inputClass) inputBox.option('readOnly', false);
  683. if (selected) {
  684. inputBox.option('value', selectedData[0][inputClass]);
  685. } else{
  686. inputBox.option('value', inputInfoBox.get('init'));
  687. }
  688. });
  689. }
  690. /**
  691. * 제어기 신규 ID 조회
  692. */
  693. function getNewNmbr() {
  694. let newId = [];
  695. getData(_apiUri + "/new-id", newId);
  696. _selectFcltNmbr = newId[0].new_id;
  697. return _selectFcltNmbr;
  698. }
  699. /**
  700. * 지도 인터페이스 함수........
  701. */
  702. function doMap() {
  703. _mapManager = new TMapMngr("vms-map", "tooltip");
  704. _mapManager.setEditMode(_lyrIdx, true);
  705. _mapManager.showLayer(_lyrIdx, true);
  706. _mapManager.showFcltObjectText(_lyrIdx, true);
  707. _mapManager.onFcltDragEndFunc = onFcltDragEndFunc; // 객체(시설물) 편집시 객체 이동후 좌표 반환
  708. _mapManager.onMouseClickFunc = onMouseClickFunc; // 객체 마우스 클릭 이벤트 반환
  709. fetchMapIconBar($('.map-bar'), _mapManager, _lyrIdx, _pageName);
  710. }
  711. function onFcltDragEndFunc(ALyrIdx, ALyrName, ANmbr, ACoordX, ACoordY) {
  712. if (ALyrIdx != _lyrIdx) {
  713. return;
  714. }
  715. if (ANmbr === _selectFcltNmbr) {
  716. setValue(getInput('x_crdn'), ACoordX.toFixed(7));
  717. setValue(getInput('y_crdn'), ACoordY.toFixed(7));
  718. }
  719. console.log(`onFcltDragEndFunc, ${ALyrIdx}, ${ALyrName}, ${ANmbr}, ${ACoordX}, ${ACoordY}`);
  720. }
  721. function onMouseClickFunc(ALyrIdx, ALyrName, ANmbr, ACoordX, ACoordY, X, Y) {
  722. if (ALyrIdx != _lyrIdx) {
  723. return;
  724. }
  725. console.log(`onMouseClickFunc, ${ALyrIdx}, ${ALyrName}, ${ANmbr}, ${ACoordX}, ${ACoordY}, ${X}, ${Y}`);
  726. const obj = _mapManager.findLayerObject(ALyrIdx, ANmbr);
  727. if (!obj) {
  728. return;
  729. }
  730. }
  731. /**
  732. * 지도에 시설물 객체 정보를 그린다.
  733. */
  734. function updateIcon() {
  735. // 기존 객체를 모두 삭제한다.
  736. _mapManager.removeLayerObject(_lyrIdx);
  737. // 시설물 객체를 지도에 그린다.
  738. const objs = new Array();
  739. _managerData[0].forEach((obj) => {
  740. const item = new TFclt(obj.vms_ctlr_nmbr, obj.vms_nm, obj.x_crdn, obj.y_crdn);
  741. objs.push(item);
  742. });
  743. console.log(_lyrIdx, objs);
  744. _mapManager.initFcltObject(_lyrIdx, objs);
  745. }
  746. function selectFcltObject(ANmbr) {
  747. _mapManager.selectLayerObject(_lyrIdx, ANmbr);
  748. }
  749. function editFcltObject(ANmbr, AIsEdit) {
  750. _mapManager.editFcltObject(_lyrIdx, ANmbr, AIsEdit, AIsEdit ? "1" : "0");
  751. }
  752. function deleteFcltObject(ANmbr) {
  753. _mapManager.deleteFcltObject(_lyrIdx, ANmbr);
  754. _selectFcltNmbr = null;
  755. }
  756. function addFcltObject(ANmbr) {
  757. _mapManager.createFcltObject(_lyrIdx, ANmbr, "New", "New", "1" /*아이콘색결정,시설물유형_N.png*/ /*, x_crdn, y_crdn*/);
  758. }
  759. function getInput(column){
  760. return _vmsInputBoxMap.get(column).get('input')
  761. }
  762. //좌표값 변경 시 이벤트
  763. function crdnChanges(text, num){
  764. let value = text.value;
  765. const textBox = text.component
  766. if(!value || isNaN(value)) return setValue(textBox, '0.0000000');
  767. value = value.toString();
  768. if(value.length <= num) return setValue(textBox, value + ".0000000");
  769. if (!value.includes(".")){
  770. let front = value.substr(0, num);
  771. let end = value.substr(num, value.length);
  772. let zero = "";
  773. if (end.length < 7) {
  774. for (let ii = 0; ii < 7 - end.length; ii++) {
  775. zero += "0";
  776. }
  777. }
  778. if (end.length > 7) end = end.substring(0, 7);
  779. setValue(textBox, front + "." + end + zero);
  780. }
  781. else{
  782. switch (true) {
  783. case value.substring(0, value.indexOf(".")) === "":
  784. setValue(textBox, "0" + value);
  785. break;
  786. case value.substring(value.indexOf("."), value.length) === "":
  787. setValue(textBox, value + "0000000");
  788. break;
  789. case value.substring(value.indexOf("."), value.length).length < 7:
  790. let zero = "";
  791. for (let ii = 0; ii < 7 - value.substring(value.indexOf(".") + 1, value.length).length; ii++) {
  792. zero += "0";
  793. }
  794. setValue(textBox, value.substring(0, value.indexOf(".")) + value.substring(value.indexOf("."), value.length) + zero);
  795. break;
  796. default:
  797. break;
  798. }
  799. }
  800. }