FileListNew.jsp 14 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450
  1. <%@ page contentType="text/html; charset=utf-8" %>
  2. <%@ page import="kr.co.hsnc.common.sql.*" %>
  3. <%@ page import="kr.co.hsnc.common.util.*"%>
  4. <%@ page import="kr.co.hsnc.common.config.*"%>
  5. <%@ page import="com.udapsoft.waf.system.HandlerStorage" %>
  6. <%@ include file="/jsp/work/taglib.jsp" %>
  7. <jsp:useBean id="ctx" class="com.udapsoft.waf.system.context.SessionContext" scope="session" />
  8. <%
  9. ctx.init(request, response);
  10. ValueObject params = null;
  11. ValueObject user = null;
  12. String message = null;
  13. String event = null;
  14. HandlerStorage storage = ctx.getHandlerStorage();
  15. //user = storage.getUser();
  16. event = storage.getEvent();
  17. params = storage.getParams();
  18. String delHidden = "";
  19. String noHidden = ", Hidden:\"True\"";
  20. if( !params.get("IS_MODIFY").equals("Y") ) {
  21. delHidden = ", Hidden:\"True\"";
  22. noHidden = "";
  23. }
  24. RowSet fileListRowSet = storage.getRowSet("FileListRowSet");
  25. int size = (fileListRowSet != null ? fileListRowSet.size() : 0);
  26. String iframeID = params.get("iframeID");
  27. int defaultFileSize = params.getInt("file_size");
  28. if(defaultFileSize <= 0){
  29. defaultFileSize = WAFConfig.getInt("waf.repository.file.size");
  30. }
  31. String multi_yn = params.get("multi_yn");
  32. //params.get("obj_id")
  33. String user_fileName = "";
  34. // params.get("user_filename");
  35. /* String userAgent = request.getHeader("User-Agent");
  36. user _fileName = params.get("user_filename");*/
  37. /* if (userAgent != null && ((userAgent.indexOf("MSIE 7.0") > -1 && userAgent.indexOf("InfoPath") <= -1) || userAgent.indexOf("MSIE 8.0") > -1 || userAgent.indexOf("MSIE 9.0") > -1)) { // MS IE 5.5 이하
  38. user_fileName = Translator.translate("iso-8859-1", "ksc5601",ctx.get("user_filename"));
  39. } else if (userAgent != null && userAgent.indexOf("Trident") > -1) { // MS IE (보통은 6.x 이상 가정)
  40. user_fileName = Translator.translate("iso-8859-1", "UTF-8",ctx.get("user_filename"));
  41. } else { // 모질라나 오페라
  42. user_fileName = Translator.translate("iso-8859-1", "UTF-8",ctx.get("user_filename"));
  43. } */
  44. String zipDownYn = params.get("zip_down_yn");
  45. String zipDownName = params.get("zip_down_name");
  46. %>
  47. <style type="text/css">
  48. .view_title {
  49. BACKGROUND-COLOR : #5F86B6 ;
  50. FONT-FAMILY : "굴림", "Verdana" ;
  51. FONT-SIZE : 9pt ;
  52. COLOR : #ffffff ;
  53. TEXT-INDENT : 9px ;
  54. }
  55. </style>
  56. <SCRIPT language="JavaScript">
  57. var m_enc = "multipart/form-data";
  58. var a_enc = "application/x-www-form-urlencoded";
  59. /**
  60. * 시트 시작
  61. */
  62. var sheet1;
  63. var sheet1Row;
  64. var sheet1PageNo = 1;
  65. var pageLastRowIndex = 1;
  66. var validationResult = false;
  67. var filterShow = false;
  68. // 마지막으로 선택된 행의 번호를 기억하고 있음
  69. var CurMasterRow = 0;
  70. function _onReady(){
  71. gridInit(sheet1);
  72. reloadProc();
  73. autoResize();
  74. /* jQuery(window)
  75. $(window).on('beforeunload', function() {
  76. return doClose();
  77. }); */
  78. $('#myFile').bind('change', function() {
  79. alert(this.files[0].size);
  80. });
  81. }
  82. function gridInit(sheetName){
  83. var init_sheet = {};
  84. init_sheet.Cfg = {SearchMode:2, Page:30};
  85. init_sheet.Cols = [
  86. {Header:'상태', Type:"Status", SaveName:"STATUS", Width:0, Align:"Center", Hidden:"True"},
  87. {Header:'삭제', Type:"DelCheck", SaveName:"DEL_CHECK", Width:50, Align:"Center" <%=delHidden%>},
  88. {Header:'번호', Type:"Seq", SaveName:"NO", Width:40, Align:"Center" <%=noHidden%> },
  89. {Header:'파일ID', Type:"Text", SaveName:"FILE_ID", Width:80, Align:"Left", Edit: 0, Hidden:"True"},
  90. {Header:'파일맵ID', Type:"Text", SaveName:"FILE_MAP_ID", Width:80, Align:"Left", Edit: 0, Hidden:"True"},
  91. {Header:'☞ 파일명', Type:"Text", SaveName:"FILE_NAME", Width:250, Align:"Left", Edit: 0},
  92. {Header:'파일크기', Type:"Text", SaveName:"FILE_SIZE", Width:60, Align:"Center", Edit: 0},
  93. {Header:'생성일시', Type:"Text", SaveName:"CRE_DATE", Width:80, Align:"Center", Edit: 0, Format: "YmdHms"},
  94. ];
  95. init_sheet.HeaderMode = {Sort:1};
  96. IBS_InitSheet(sheetName, init_sheet);
  97. sheetName.SetDataAutoTrim(0);
  98. setGridSize();
  99. }
  100. function setGridSize() {
  101. sheet1.FitColWidth();
  102. }
  103. function sheet1_OnSearchEnd(code, message) {
  104. if(code == 0) {
  105. setGridSize();
  106. } else {
  107. //조회 에러 수행
  108. alert(message);
  109. }
  110. }
  111. function sheet1_OnDblClick(Row, Col, Value, CellX, CellY, CellW, CellH) {
  112. if (sheet1.ColSaveName(Col) == "FILE_NAME") {
  113. var url="/common/file/FileDownloadServlet";
  114. url += "?file_id=" + sheet1.GetCellValue(Row, "FILE_ID");
  115. window.open(url, "_fileDown", "toolbar=no, width=400, height=100, top=500, left=400, toolbar=no,directories=no,status=no,scrollbars=yes,resize=no,menubar=no,target=new")
  116. //2020.03.12 왜 아래 또 submit 하는지 모르겠음.
  117. //var fd = document.getElementById("form_filedown");
  118. //fd.target = "_fileDown";
  119. //fd.file_id.value = sheet1.GetCellValue(Row, "FILE_ID");
  120. //fd.submit();
  121. }
  122. }
  123. function sheet1_OnSaveEnd(code, msg) {
  124. if(code >= 0) {
  125. alert("파일이 삭제 되었습니다.!");
  126. } else {
  127. //alert(msg);
  128. alert("파일 삭제에 실패 하였습니다.");
  129. }
  130. }
  131. /**
  132. * 시트 끝
  133. */
  134. function saveProc() {
  135. var f = document.form1;
  136. if(document.getElementById("multi_yn").value == "N" && sheet1.RowCount() >= 1){
  137. alert("1개의 첨부파일만 가능합니다.\n추가 된 첨부파일을 삭제후 추가 바랍니다.");
  138. return;
  139. }
  140. if( f.attach_file.value == "" ) {
  141. alert("파일을 선택하세요.");
  142. return;
  143. }
  144. if(!checkFile(document.getElementById("attach_file"))) return;
  145. f.fevent.value = "FileListWorker.Save";
  146. f.target = "worker";
  147. f.action = "FileListNewSave.screen";
  148. f.encoding = m_enc;
  149. f.method = "post";
  150. formSubmit(f, false);
  151. }
  152. function getFileSize(filePath)
  153. {
  154. var browser=navigator.appName;
  155. var size = 0;
  156. if (browser=="Microsoft Internet Explorer")
  157. {
  158. try{
  159. var oas = new ActiveXObject("Scripting.FileSystemObject");
  160. var filepath = document.getElementById('attach_file').value;
  161. var e = oas.getFile(filepath);
  162. size = e.size;
  163. }catch(e){
  164. alert("ActiveX 컨트롤을 허용 하시기 바랍니다.\n리플레쉬후 다시 시도 바랍니다.\n"+e);
  165. size = 1;
  166. }
  167. }
  168. else
  169. {
  170. size = "";
  171. for(var i=0;i<document.getElementById("attach_file").files.length;i++){
  172. size += document.getElementById("attach_file").files[i].size + ";";
  173. }
  174. }
  175. return size;
  176. }
  177. function checkFile(obj)
  178. {
  179. var len = getFileSize(obj.value);
  180. var defSize = document.getElementById("defaultFileSize").value;
  181. var filelist = "";
  182. var cnt =0;
  183. if(isNaN(len)){
  184. filelist = len.split(";");
  185. for(var i=0;i<filelist.length-1;i++){
  186. if (filelist[i] > defSize * 1024 * 1024)
  187. {
  188. //alert("파일 크기는 "+defSize+"메가보다 작아야 합니다.");
  189. cnt += 1;
  190. }
  191. }
  192. if(cnt > 0){
  193. alert("파일 크기는 "+defSize+"메가보다 작아야 합니다.");
  194. return false;
  195. }else{
  196. return true;
  197. }
  198. }else{
  199. if (len > defSize * 1024 * 1024)
  200. {
  201. alert("파일 크기는 "+defSize+"메가보다 작아야 합니다.");
  202. return false;
  203. } else{
  204. return true;
  205. }
  206. }
  207. }
  208. // Form Lock 풀기
  209. function resetFormProc() {
  210. resetFormSubmit();
  211. }
  212. function delProc() {
  213. if(sheet1.RowCount("D") <= 0){
  214. alert("삭제할 파일이 없습니다.");
  215. return;
  216. }
  217. if (confirm("삭제하시겠습니까?")) {
  218. jQuery("#fevent").val("FileListWorker.Del");
  219. var url = Modular.model.PageContext.CONTEXT_ROOT + "/common/file/FileListNewDelete.screen";
  220. var result = Modular.view.IBSheet7.doSave(sheet1, url, jQuery("#form1"), false);
  221. }
  222. }
  223. function resetProc(){
  224. var f = document.form1;
  225. f.attach_file.value="";
  226. }
  227. function reloadProc() {
  228. jQuery("#form1").attr("encoding", a_enc);
  229. jQuery("#fevent").val("GET_FILE_LIST");
  230. var url = Modular.model.PageContext.CONTEXT_ROOT + "/common/file/FileListNewData.screen";
  231. Modular.view.IBSheet7.doSearch(sheet1, url, jQuery("#form1"), 10, "");
  232. }
  233. function viewFileListClose(layerID){
  234. var obj = parent.document.getElementById("<%=params.get("obj_id")%>");
  235. if(obj == null && '<%=iframeID%>' != ''){
  236. var childDiv = parent.document.getElementById("<%=params.get("iframeID")%>_divcontent");
  237. var objChild = childDiv.getElementsByTagName("iframe")[0];
  238. var objDoc = objChild.contentWindow || objChild.contentDocument;
  239. obj = eval(objDoc.document.getElementById("<%=params.get("obj_id")%>"));
  240. }
  241. if( obj != null ){
  242. if( obj.type == "textarea" ) {
  243. obj.value = "";
  244. for(var i = 1; i<=sheet1.RowCount(); i++){
  245. var str = i + " : " + sheet1.GetCellValue(i, "FILE_NAME") + " ( "+sheet1.GetCellValue(i, "FILE_SIZE")+" )";
  246. obj.value += str + "\n";
  247. }
  248. }else{
  249. var strHtml = "";
  250. for(var i = 1; i<=sheet1.RowCount(); i++){
  251. var temp = i + " : " + sheet1.GetCellValue(i, "FILE_NAME") + " ( "+sheet1.GetCellValue(i, "FILE_SIZE")+" )";
  252. strHtml += "<li><a href=\"javascript:fileDown('"+sheet1.GetCellValue(i, "FILE_ID")+"');\">" + temp +"</a></li>\n";
  253. }
  254. strHtml = "<ul>\n" + strHtml + "</ul>";
  255. obj.innerHTML = strHtml;
  256. }
  257. }
  258. parent.fLayerPopClose(layerID);
  259. }
  260. function viewFileListClose1(layerID){
  261. var obj = parent.document.getElementById("<%=params.get("obj_id")%>");
  262. if(obj == null && '<%=iframeID%>' != ''){
  263. var childDiv = parent.document.getElementById("<%=params.get("iframeID")%>_divcontent");
  264. var objChild = childDiv.getElementsByTagName("iframe")[0];
  265. var objDoc = objChild.contentWindow || objChild.contentDocument;
  266. obj = eval(objDoc.document.getElementById("<%=params.get("obj_id")%>"));
  267. }
  268. if( obj != null ){
  269. if( obj.type == "hidden" || obj.type == "text") {
  270. obj.value = "";
  271. for(var i = 1; i<=sheet1.RowCount(); i++){
  272. var str = i + " : " + sheet1.GetCellValue(i, "FILE_NAME") + " ( "+sheet1.GetCellValue(i, "FILE_SIZE")+" )";
  273. obj.value += str + "\n";
  274. }
  275. }else if( obj.type == "textarea" ) {
  276. obj.value = "";
  277. for(var i = 1; i<=sheet1.RowCount(); i++){
  278. var str = i + " : " + sheet1.GetCellValue(i, "FILE_NAME") + " ( "+sheet1.GetCellValue(i, "FILE_SIZE")+" )";
  279. obj.value += str + "\n";
  280. }
  281. }else{
  282. var strHtml = "";
  283. for(var i = 1; i<=sheet1.RowCount(); i++){
  284. var temp = i + " : " + sheet1.GetCellValue(i, "FILE_NAME") + " ( "+sheet1.GetCellValue(i, "FILE_SIZE")+" )";
  285. strHtml += "<li><a href=\"javascript:fileDown('"+sheet1.GetCellValue(i, "FILE_ID")+"');\">" + temp +"</a></li>\n";
  286. }
  287. strHtml = "<ul>\n" + strHtml + "</ul>";
  288. obj.innerHTML = strHtml;
  289. }
  290. }
  291. parent.fLayerPopClose(layerID);
  292. }
  293. function zipFileDown(){
  294. var url="/common/file/FileDownloadServlet";
  295. url += "?mode=zipDown";
  296. url += "&fileName=<%=zipDownName%>";
  297. url += "&fileGB=<%=params.get("file_gb")%>";
  298. url += "&ID=<%=params.get("id")%>";
  299. window.open(url, "_fileDown", "toolbar=no, width=400, height=100, top=500, left=400, toolbar=no,directories=no,status=no,scrollbars=yes,resize=no,menubar=no,target=new");
  300. }
  301. </SCRIPT>
  302. <STYLE>
  303. BODY {
  304. padding : 0 0 0 0;
  305. }
  306. </STYLE>
  307. <modular:search id="form1">
  308. <modular:key id="fevent" />
  309. </modular:search>
  310. <FORM id="form1" name="form1" method="post" modular:type="search">
  311. <INPUT type="hidden" name="fevent" id="fevent" value="">
  312. <INPUT type="hidden" name="file_gb" value="<%= params.get("file_gb") %>">
  313. <INPUT type="hidden" name="id" value="<%= params.get("id") %>">
  314. <INPUT type="hidden" name="is_modify" value="<%= params.get("is_modify") %>">
  315. <INPUT type="hidden" name="is_corp" value="<%= params.get("is_corp") %>">
  316. <INPUT type="hidden" name="is_con" value="<%= params.get("is_con") %>">
  317. <INPUT type="hidden" name="is_techreq" value="<%= params.get("is_techreq") %>">
  318. <INPUT type="hidden" name="mod_no" value="<%= params.get("mod_no") %>">
  319. <INPUT type="hidden" name="sysGb" value="<%=params.get("sys_gb")%>">
  320. <INPUT type="hidden" name="defaultFileSize" value="<%=defaultFileSize%>">
  321. <INPUT type="hidden" name="multi_yn" value="<%=multi_yn%>">
  322. <INPUT type="hidden" name="user_filename" value="<%=user_fileName%>">
  323. <INPUT type="hidden" name="zip_down_yn" value="<%=zipDownYn%>">
  324. <INPUT type="hidden" name="zip_down_name" value="<%=zipDownName%>">
  325. <% if( params.get("IS_MODIFY").equals("Y") ) { %>
  326. <table id="search-table" class="search-form-table">
  327. <colgroup>
  328. <col width="100" />
  329. <col width="400" />
  330. <col width="*" />
  331. </colgroup>
  332. <tr>
  333. <th>파일선택</th>
  334. <td>
  335. <input id="attach_file" type="file" name="attach_file" class="input" contenteditable="false" <% if(!"N".equals(params.get("multi_yn"))){ %>multiple<%} %>>
  336. </td>
  337. <td class="button">
  338. <span class="btnSearch center"><a href="javascript:saveProc();" id="btnSave">파일저장</a></span>
  339. <span class="btnSearch center"><a href="javascript:delProc();" id="btnDel">파일삭제</a></span>
  340. <% if (zipDownYn.equals("Y")) { %>
  341. <span class="btnSearch center"><a href="javascript:zipFileDown();" id="btnZipDown">모두저장(ZIP)</a></span>
  342. <%} %>
  343. </td>
  344. </tr>
  345. </table>
  346. <%} else if (zipDownYn.equals("Y")){%>
  347. <table id="search-table" class="search-form-table">
  348. <colgroup>
  349. <col width="*" />
  350. </colgroup>
  351. <tr>
  352. <td class="button" style="text-align: right;">
  353. <span class="btnSearch center"><a href="javascript:zipFileDown();" id="btnZipDown">모두저장(ZIP)</a></span>
  354. </td>
  355. </tr>
  356. </table>
  357. <%} %>
  358. <div id="sheet1_div" style="padding-top:5px; height: auto; min-height: 200px; overflow: auto;">
  359. <script>createIBSheet('sheet1','100%', '380px');</script>
  360. </div>
  361. <IFRAME width="0" height="0" name="worker" style="display:none;"></IFRAME>
  362. </FORM>
  363. <FORM id="form_filedown" name="form_filedown" method="get" action="/common/file/FileDownloadServlet" style="display:none">
  364. <input type="hidden" id="file_id" name="file_id"/>
  365. </FORM>