lib.js 16 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583
  1. /**
  2. * @(#)file lib.js
  3. * @(#)author developer
  4. * @(#)version 1.0
  5. * @(#)date 2003-05-14
  6. *
  7. * Copyright You can copy or redistribute this code freely,
  8. * but you should not remove the information about the copyright notice
  9. * and the author.
  10. * Description : 파일 기능에 대해 기술합니다..
  11. */
  12. /**
  13. * 금액을 3자리로 단위표시 해서 리턴한다.
  14. * 파라미터)> num: 숫자
  15. * 사용예)> plusComma("1234")
  16. */
  17. function plusComma(num) {
  18. var out = "";
  19. var minus = false;
  20. if (num < 0) { num *= -1; minus = true; }
  21. else minus = false;
  22. var dotPos = (num+"").split(".");
  23. var dotU = dotPos[0];
  24. var dotD = dotPos[1];
  25. var commaFlag = dotU.length%3;
  26. if(commaFlag) {
  27. out = dotU.substring(0, commaFlag);
  28. if (dotU.length > 3) out += ",";
  29. }
  30. else out = "";
  31. for (var i=commaFlag; i < dotU.length; i+=3) {
  32. out += dotU.substring(i, i+3);
  33. if( i < dotU.length-3) out += ",";
  34. }
  35. if(minus) out = "-" + out;
  36. if(dotD) return out + "." + dotD;
  37. else return out;
  38. }
  39. /**
  40. * 첨부파일
  41. * obj : 파일 목록이 들어갈 Object[textarea/select]
  42. * fileGB : 파일 종류 구분
  43. * isCorp : 업체 공개 항목 표시 여부
  44. * isContract : 계약용파일 항목 표시 여부
  45. * isModify : 입력/수정/삭제 기능 사용 여부
  46. * isTechReq : TBE 항목 표시 여부
  47. */
  48. //function viewFileList(fileGB, id, obj, isCorp, isContract, isModify, isTechReq) {
  49. //
  50. // var url = "/common/file/FileList.screen"
  51. // + "?file_gb=" + fileGB
  52. // + "&id=" + id;
  53. //
  54. // if( isCorp != null )
  55. // url += "&is_corp=" + isCorp;
  56. //
  57. // if( isContract != null )
  58. // url += "&is_con=" + isContract;
  59. //
  60. // if( isTechReq != null )
  61. // url += "&is_techreq=" + isTechReq;
  62. //
  63. // if( isModify != null )
  64. // url += "&is_modify=" + isModify;
  65. //
  66. // var result = null;
  67. //
  68. // result = window.showModalDialog(getDummyUrl(url),'Attach Files','dialogWidth:730px;dialogHeight:430px; center:yes; help:no; status:no; scroll:no; resizable:no');
  69. //
  70. // if( result == null )
  71. // return;
  72. //
  73. // if( obj == null )
  74. // return result;
  75. //
  76. // if( obj.type == "select-multiple" || obj.type == "select-one" ) {
  77. // removeAllOptions(obj);
  78. // if( result != null && result.length != null ) {
  79. // for( var i = 0 ; i < result.length ; i++ ) {
  80. // var str = getFileInfoStr(result[i], isCorp, isContract);
  81. // var option = new Option(str, str, false );
  82. // obj.options[i] = option;
  83. // }
  84. // }
  85. // }
  86. // else if( obj.type == "textarea" ) {
  87. // obj.value = "";
  88. // if( result != null && result.length != null ) {
  89. // obj.value = "";
  90. // for( var i = 0 ; i < result.length ; i++ ) {
  91. // var str = getFileInfoStr(result[i], isCorp, isContract);
  92. // obj.value += str + "\n";
  93. // }
  94. // }
  95. // }
  96. // else {
  97. // return result;
  98. // }
  99. //}
  100. function viewFileList(fileGB, id, obj, isModify, isDrectory, iframeID) {
  101. var win_id = "_viewFileList";
  102. var link = "/common/file/FileListNew.screen";
  103. link += "?pop_win_id="+win_id;
  104. link += "&sModule=LM";
  105. link += "&extFunction=viewFileListCloseWin";
  106. link += "&file_gb=" + fileGB;
  107. link += "&id=" + id;
  108. if( obj.id != null )
  109. link += "&obj_id=" + obj.id;
  110. if( iframeID != null )
  111. link += "&iframeID=" + iframeID;
  112. if( isModify != null )
  113. link += "&is_modify=" + isModify;
  114. if( isDrectory != null )
  115. link += "&sys_gb=" + isDrectory;
  116. //window.open(link, "_fileView", "toolbar=no, width=750, height=430, top=500, left=400, toolbar=no,directories=no,status=no,scrollbars=yes,resize=no,menubar=no,target=_blank")
  117. var result = null;
  118. result = window.showModalDialog(link,'Attach Files','dialogWidth:730px;dialogHeight:430px; center:yes; help:no; status:no; scroll:no; resizable:no');
  119. /*예약함수로 선언 되어 있어야 한다*/
  120. doAttachFileListSet();
  121. }
  122. function winclose(){
  123. alert("winclose : 111");
  124. }
  125. function viewFileListNew(fileGB, id, obj, isModify, isDrectory, iframeID, user_filename, file_size, multi_yn, zipDownYn, zipDownName) {
  126. var win_id = "_viewFileList";
  127. var link = "/common/file/FileListNew.screen";
  128. link += "?pop_win_id="+win_id;
  129. link += "&extFunction=viewFileListClose";
  130. link += "&file_gb=" + fileGB;
  131. link += "&id=" + id;
  132. if( obj.id != null )
  133. link += "&obj_id=" + obj.id;
  134. if( iframeID != null )
  135. link += "&iframeID=" + iframeID;
  136. if( isModify != null )
  137. link += "&is_modify=" + isModify;
  138. if( isDrectory != null )
  139. link += "&sys_gb=" + isDrectory;
  140. if( file_size != null )
  141. link += "&file_size=" + file_size;
  142. if( multi_yn != null )
  143. link += "&multi_yn=" + multi_yn;
  144. if( user_filename != null )
  145. link += "&user_filename=" + encodeURIComponent(user_filename);
  146. if( zipDownYn )
  147. link += "&zip_down_yn=" + zipDownYn;
  148. if( zipDownName )
  149. link += "&zip_down_name=" + encodeURIComponent(zipDownName);
  150. fLayerPop(win_id, link, 750,430, '', '', 'NO', '200');
  151. }
  152. /**
  153. * 파일 목록 정보를 얻는다.
  154. * 파라미터)> obj: 객체명, isCorp: 업체 공개 항목 표시 여부, isCon: 계약 할때 생성여부
  155. */
  156. function getFileInfoStr(obj, isCorp, isCon) {
  157. var str = "";
  158. str = obj.no + " : ";
  159. if( isCorp != null && isCorp == 'Y' )
  160. str += "업체공개[" + obj.open_corp_yn + "] ";
  161. if( isCon != null && isCon == 'Y' )
  162. str += "계약사용[" + obj.use_con_yn + "] ";
  163. str += obj.file_name + " (" + obj.file_size + ")";
  164. return str;
  165. }
  166. /**
  167. * 오류 알림창 컴포넌트
  168. */
  169. function dlgErrorDetailAlert(msg, detailMsg) {
  170. var dlgWidth = 500;
  171. var dlgHeight = 275;
  172. dlgErrorAlert(msg, dlgWidth, dlgHeight, detailMsg);
  173. }
  174. /**
  175. * 오류 알림창 컴포넌트 ( 공통 )
  176. */
  177. function dlgErrorMsg( resultObj ) {
  178. //var result = window.showModalDialog('/dialog/dlgError.screen',resultObj,'dialogWidth:505px;dialogHeight:325px; center:yes; help:no; status:yes; scroll:no; resizable:no');
  179. var win_id = "_dlgError";
  180. var link = "/dialog/dlgError.screen";
  181. link += "?pop_win_id="+win_id;
  182. link += "&errMsg="+encodeURIComponent(resultObj.getMessage());
  183. // link += "&errDetailMsg="+encodeURIComponent(resultObj.getDetailMessage());
  184. fLayerPop(win_id, link, 505,195, '', '', 'NO');
  185. }
  186. /**
  187. *
  188. */
  189. function dlgErrorAlert(msg, varWidth, varHeight, detailMsg)
  190. {
  191. var dlgWidth = 400;
  192. var dlgHeight = 170;//180
  193. if( varWidth != null )
  194. dlgWidth = varWidth;
  195. if( varHeight != null )
  196. dlgHeight = varHeight;
  197. if( detailMsg == null )
  198. detailMsg = "";
  199. if( detailMsg != "" ) {
  200. dlgHeight = dlgHeight + 107;
  201. }
  202. var msgArray = new Array( msg , detailMsg );
  203. window.showModalDialog(getDummyUrl('/dialog/dlgErrorAlert.screen') , msgArray,'dialogWidth:' + dlgWidth + 'px;dialogHeight:' + dlgHeight + 'px; center:yes; help:no; status:no; scroll:no; resizable:no');
  204. }
  205. /**
  206. * 현장 검색(html용) : 최종으로 현장 사용함 2005-01-14
  207. * 파라미터)> obj_dept_cd: 선택한 현장코드가 들어갈 객체, obj_dept_nm:선택한 현장명이 들어갈 객체
  208. * 사용예)> dlgSearchSpotDept(obj_dept_cd, obj_dept_nm)
  209. */
  210. function dlgSearchSpotDept(obj_dept_cd, obj_dept_nm)
  211. {
  212. var win_id = "_searchSite";
  213. var link = "/lib/dlgSearchSpotDept_Unitcd.screen";
  214. link += "?pop_win_id="+win_id+"&obj_dept_cd="+obj_dept_cd+"&obj_dept_nm="+obj_dept_nm;
  215. fLayerPop(win_id, link, 570,500, '', '', 'NO');
  216. }
  217. function dlgSearchSpotDeptEnd(result, obj_dept_cd, obj_dept_nm) {
  218. if( result == null ){
  219. parent.document.getElementById(obj_dept_cd).value = "";
  220. parent.document.getElementById(obj_dept_nm).value = "";
  221. }else{
  222. parent.document.getElementById(obj_dept_cd).value = result[0];
  223. parent.document.getElementById(obj_dept_nm).value = result[1];
  224. }
  225. parent.fLayerPopClose('_searchSite');
  226. }
  227. function dlgClear(obj_dept_cd, obj_dept_nm)
  228. {
  229. document.getElementById(obj_dept_cd).value = "";
  230. document.getElementById(obj_dept_nm).value = "";
  231. }
  232. function dlgSearchSpotDeptNew(obj_dept_cd, obj_dept_nm)
  233. {
  234. var win_id = "_searchSiteNew";
  235. var link = "/lib/dlgSearchSpotDept_Unitcd_New.screen";
  236. link += "?pop_win_id="+win_id+"&obj_dept_cd="+obj_dept_cd+"&obj_dept_nm="+obj_dept_nm;
  237. fLayerPop(win_id, link, 570,420, '', '', 'NO');
  238. }
  239. function dlgSearchSpotDeptNewEnd(result, obj_dept_cd, obj_dept_nm) {
  240. if( result == null ){
  241. parent.document.getElementById(obj_dept_cd).value = "";
  242. parent.document.getElementById(obj_dept_nm).value = "";
  243. }else{
  244. parent.document.getElementById(obj_dept_cd).value = result[0];
  245. parent.document.getElementById(obj_dept_nm).value = result[1];
  246. }
  247. parent.fLayerPopClose('_searchSiteNew');
  248. }
  249. function dlgClearNew(obj_dept_cd, obj_dept_nm)
  250. {
  251. document.getElementById(obj_dept_cd).value = "";
  252. document.getElementById(obj_dept_nm).value = "";
  253. submitXmlRequest("/lib/dlgSearchSpotDeptCrear.screen", "CLEAR_DEPT", document.form1, "SUCCESS");
  254. }
  255. function doResult(resultObj) {
  256. try {
  257. if( resultObj.getRequestEvent() == "CLEAR_DEPT") {
  258. if( resultObj.getSuccess() ) {
  259. }
  260. else {
  261. dlgErrorMsg(resultObj);
  262. }
  263. }
  264. document.form1.isSubmit = false;
  265. }
  266. catch(errorObject) {
  267. showErrorDlg("doResult()", errorObject);
  268. }
  269. }
  270. /**
  271. * 현장 검색 (sheet용): 최종으로 현장 사용함 2005-01-14
  272. * 파라미터)> obj_dept_cd: 선택한 현장코드가 들어갈 객체, obj_dept_nm:선택한 현장명이 들어갈 객체
  273. * 사용예)> dlgSearchSpotDept(obj_dept_cd, obj_dept_nm)
  274. */
  275. function dlgSearchSpotDept4Sheet(obj_dept_cd, obj_dept_nm, objSheet, iRow, iCol1, iCol2)
  276. {
  277. var result = "false";
  278. result = window.showModalDialog(getDummyUrl('/lib/dlgSearchSpotDept.screen'),'현장 찾기','dialogWidth:620px;dialogHeight:460px; center:yes; help:no; status:no; scroll:no; resizable:no');
  279. if( result == null )
  280. return;
  281. if( result.length != 2 )
  282. return;
  283. if( obj_dept_cd != null && obj_dept_nm != null )
  284. {
  285. objSheet.SetCellValue(iRow, iCol2, result[0]); //부서코드
  286. objSheet.SetCellValue(iRow, iCol1, result[1]); //부서명
  287. }
  288. }
  289. /**
  290. * 일반 팝업창
  291. * 파라미터)> url: 주소, title: title, scroll: 스크롤여부, nWidth: 팝업창의 넓이, nHeight: 팝업창의 높이
  292. * 사용예)> dlgConfirm("저장되었습니다.",200,150)
  293. */
  294. function openPopup(url, title, scroll, nWidth, nHeight){
  295. var opts, iMyWidth, iMyHeight;
  296. iMyWidth = (window.screen.width-nWidth)/2;
  297. iMyHeight = (window.screen.height-nHeight)/2;
  298. opts = "width="+nWidth+",height="+nHeight+",";
  299. opts += "toolbar=no,location=no,directories=no,status=no,";
  300. opts += "menubar=no,scrollbars="+scroll+",resizable=no,";
  301. opts += "left=" + iMyWidth + ",top=" + iMyHeight + ",screenX=" + iMyWidth + ",screenY=" + iMyHeight ;
  302. win = window.open(url, title, opts);
  303. //win.focus();
  304. }
  305. /**
  306. *전화번호 유효 Check
  307. *
  308. */
  309. function checkTelno(strTelno) {
  310. for (var i = 0 ; i < strTelno.length ; i++){
  311. if(isNaN(parseInt(strTelno.charAt(i))) && strTelno.charAt(i)!='-'){
  312. return false;
  313. }
  314. }
  315. return true;
  316. }
  317. /**
  318. * 소수점을 제거함
  319. * value : 입력값
  320. * num : 소수점자리수
  321. */
  322. function fixPoint( value , num) {
  323. //소수점제거
  324. if (value != null && num == 0 && value != "" && value.indexOf(".") > 0) {
  325. value = value.substring(0, value.indexOf("."));
  326. return value;
  327. }
  328. //소수점 추가
  329. else {
  330. value = addPoint( value , num);
  331. return value;
  332. }
  333. }
  334. /**
  335. * 소수점을 추가함
  336. * value : 입력값
  337. * num : 소수점자리수
  338. * 2007-10-19 김종만 수정
  339. */
  340. function addPoint( value , num) {
  341. //123 -> 123.00
  342. if (value != null && value != "" && value.indexOf(".") == -1) {
  343. //value 123 num 0
  344. if(num == 0 ) { return value; }
  345. value = value + ".";
  346. for(i = 0; i < num;i++) {
  347. value = value + "0";
  348. }
  349. return value;
  350. }
  351. //123.000 -> 123.00
  352. else if (value != null && value != "" && value.indexOf(".")>=0 && (value.length-value.indexOf(".")-1)<num ) {
  353. num = num - (value.length-value.indexOf(".")-1);
  354. for(i=0; i<num; i++)
  355. {
  356. value = value + "0";
  357. }
  358. return value;
  359. }
  360. else if (value != null && value != "") {
  361. return value;
  362. } else {
  363. value = value + "0.";
  364. for(i = 0; i < num;i++) {
  365. value = value + "0";
  366. }
  367. return value;
  368. }
  369. return value;
  370. }
  371. /**
  372. * 소수점을 제거함
  373. * value : 입력값
  374. * num : 소수점자리수
  375. */
  376. function fixPoint4sub( value , num) {
  377. var point_len = value.length - value.indexOf(".") -1 ;
  378. //소수점제거
  379. if (value != null && (num == 0 || point_len > num ) && value != "" && value.indexOf(".") > 0) {
  380. if( num == 0 ) {
  381. value = value.substring(0, value.indexOf("."));
  382. }
  383. else
  384. {
  385. value = value.substring(0, value.length-(point_len-num));
  386. }
  387. return value;
  388. }
  389. else if(value != null && point_len == num && value != "" && value.indexOf(".") > 0){
  390. return value;
  391. }
  392. //소수점 추가
  393. else {
  394. value = addPoint( value , num);
  395. return value;
  396. }
  397. }
  398. /**
  399. * 달력 컴포넌트
  400. * 사용예) dlgCalendar2('aaa');
  401. * @param obj_str
  402. */
  403. var obj_str_change;
  404. var obj_str_val;
  405. function dlgCalendar(obj_str)
  406. {
  407. var info = {Format:"yyyy-MM-dd",Result:document.getElementById(obj_str), CalButtons : "Close",CallBack:"Calendar_return"};
  408. IBShowCalendar("",info);
  409. obj_str_change = obj_str;
  410. obj_str_val = $("#"+obj_str).val();
  411. }
  412. /**
  413. * 달력 컴포넌트
  414. * 사용예) dlgMonthCalendar2('aaa');
  415. * @param obj_str
  416. */
  417. function dlgMCalendar(obj_str)
  418. {
  419. var info = {Format:"yyyy-MM",Result:document.getElementById(obj_str), CalButtons : "Close",CallBack:"Calendar_return"};
  420. IBShowCalendar("",info);
  421. obj_str_change = obj_str;
  422. obj_str_val = $("#"+obj_str).val();
  423. }
  424. /**
  425. * 콜백 이벤트 발생후 체인지 이벤트 발생..
  426. */
  427. function Calendar_return(){
  428. if(obj_str_val != $("#"+obj_str_change).val()){
  429. $("#"+obj_str_change).change();
  430. }
  431. }
  432. /**
  433. * 문자열을 UTF-8로 변환했을 경우 차지하게 되는 byte 수를 리턴한다.
  434. */
  435. function stringByteSize4UTF(str) {
  436. if (str == null || str.length == 0) {
  437. return 0;
  438. }
  439. var size = 0;
  440. for (var i = 0; i < str.length; i++) {
  441. size += charByteSize4UTF(str.charAt(i));
  442. }
  443. return size;
  444. }
  445. /**
  446. * 각 문자의 유니코드 코드를 분석하여, UTF-8로 변환시 차지하는 byte 수를 리턴한다.
  447. */
  448. function charByteSize4UTF(ch) {
  449. if (ch == null || ch.length == 0) {
  450. return 0;
  451. }
  452. var charCode = ch.charCodeAt(0);
  453. if (charCode <= 0x00007F) {
  454. return 1;
  455. } else if (charCode <= 0x0007FF) {
  456. return 2;
  457. } else if (charCode <= 0x00FFFF) {
  458. return 3;
  459. } else {
  460. return 4;
  461. }
  462. }
  463. /**
  464. * 사업장 검색 (구매)
  465. * 파라미터)> obj_corp_id:협력업체 id, obj_corp_name: 협력업체명, obj_reg: 사업자 번호
  466. * 사용예)> dlgSearchPURRegNo(12, '대동경유', '212-81-22345')
  467. */
  468. function dlgSearchPURRegNo(obj_corp_id, obj_corp_name, obj_reg )
  469. {
  470. var result = "false";
  471. var argObj = new Object();
  472. argObj.title = '사업자 찾기';
  473. argObj.ent_corp_id = "";
  474. argObj.work_id = "";
  475. argObj.site_gb = 'PUR';
  476. argObj.reg_gb = '1'; /* 사업자 찾기 */
  477. argObj.all_gb = '0';
  478. argObj.ent_corp_NM = "";
  479. var win_id = "_searchBizRegNo";
  480. var link = "/lib/dlgSearchBizRegNo.screen";
  481. link += "?pop_win_id="+win_id+"&obj_corp_id="+obj_corp_id+"&obj_corp_name="+obj_corp_name+"&reg_gb="+argObj.reg_gb+"&site_gb="+argObj.site_gb
  482. +"&all_gb="+argObj.all_gb;
  483. fLayerPop(win_id, link, 415,470, '', '', 'NO');
  484. //result = window.showModalDialog(getDummyUrl('/lib/dlgSearchBizRegNo.screen'),argObj,'dialogWidth:415px;dialogHeight:470px; center:yes; help:no; status:no; scroll:no; resizable:no');
  485. }
  486. function searchBizRegNoClose(result, obj_corp_id, obj_corp_name) {
  487. if( result == null ){
  488. obj_corp_id.value = "";
  489. obj_corp_name.value = "";
  490. }else{
  491. obj_corp_id.value = result[0];
  492. obj_corp_name.value = result[1];
  493. }
  494. fLayerPopClose('_searchBizRegNo');
  495. }