SMSMP90105_파일첨부샘플.xfdl 11 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279
  1. <?xml version="1.0" encoding="utf-8"?>
  2. <FDL version="1.4">
  3. <TypeDefinition url="..\..\..\default_typedef.xml"/>
  4. <Form id="SMSMP90105_파일첨부샘플" classname="SMSMP90105_파일첨부샘플" inheritanceid="" position="absolute 0 0 1024 768" titletext="New Form" onload="form_onload">
  5. <Layouts>
  6. <Layout>
  7. <Static id="caption6" text="파일첨부샘플 " onclick="&quot;caption6_onclick&quot;" class="tit_1" position="absolute 16 16 278 41"/>
  8. <Grid id="gd_notice" taborder="2" binddataset="ds_notice" useinputpanel="false" cellsizingtype="col" position2="absolute l:21 w:672 t:76 h:644" positiontype="position2" style="font:맑은고딕,10;" oncellclick="gd_notice_oncellclick">
  9. <Formats>
  10. <Format id="default">
  11. <Columns>
  12. <Column size="47"/>
  13. <Column size="80"/>
  14. <Column size="218"/>
  15. <Column size="90"/>
  16. <Column size="126"/>
  17. <Column size="101"/>
  18. </Columns>
  19. <Rows>
  20. <Row size="24" band="head"/>
  21. <Row size="30"/>
  22. </Rows>
  23. <Band id="head">
  24. <Cell text="상태"/>
  25. <Cell col="1" text="번호"/>
  26. <Cell col="2" text="파일명"/>
  27. <Cell col="3" text="사이즈"/>
  28. <Cell col="4" text="mime타입"/>
  29. <Cell col="5" text="다운로드"/>
  30. </Band>
  31. <Band id="body">
  32. <Cell displaytype="combo" text="status" expr="expr:getRowType(currow)" combodataset="ds_status" combocodecol="cd" combodatacol="value"/>
  33. <Cell col="1" text="bind:genrno"/>
  34. <Cell col="2" displaytype="button" edittype="textarea" text="bind:attfilenm"/>
  35. <Cell col="3" text="bind:attfilesize"/>
  36. <Cell col="4" text="bind:attfiletype"/>
  37. <Cell col="5" displaytype="button" text="bind:attfiledown"/>
  38. </Band>
  39. </Format>
  40. </Formats>
  41. </Grid>
  42. <Button id="bt_init" taborder="3" text="조회" onclick="bt_init_onclick" class="btn2" position2="absolute l:640 w:54 t:725 h:22" positiontype="position2" style="color:black;font:돋움,9; :disabled {font:Dotum,9;}"/>
  43. <Button id="bt_save" taborder="4" text="저장" onclick="bt_save_onclick" class="btn2" position2="absolute l:583 w:54 t:725 h:22" positiontype="position2" style="color:black;font:돋움,9; :disabled {font:Dotum,9;}"/>
  44. <Button id="bt_addrow" taborder="5" text="행추가" onclick="bt_addrow_onclick" class="btn2" position2="absolute l:582 w:54 t:44 h:20" positiontype="position2" style="color:black;font:돋움,9; :disabled {font:Dotum,9;}"/>
  45. <Button id="bt_deleterow" taborder="6" text="행삭제" onclick="bt_deleterow_onclick" class="btn2" position2="absolute l:639 w:54 t:44 h:20" positiontype="position2" style="color:black;font:돋움,9; :disabled {font:Dotum,9;}"/>
  46. <Button id="bt_batchuplaod" taborder="7" text="일괄첨부" class="btn2" position2="absolute l:21 w:75 t:49 h:20" positiontype="position2" style="color:black;font:돋움,9; :disabled {font:Dotum,9;}" onclick="bt_batchuplaod_onclick"/>
  47. </Layout>
  48. </Layouts>
  49. <Objects>
  50. <Dataset id="ds_notice" firefirstcount="0" firenextcount="0" useclientlayout="true" updatecontrol="true" enableevent="true" loadkeymode="keep" loadfiltermode="keep" reversesubsum="false">
  51. <ColumnInfo>
  52. <Column id="genrno" type="STRING" size="256"/>
  53. <Column id="attfilenm" type="STRING" size="256"/>
  54. <Column id="attfilepath" type="STRING" size="256"/>
  55. <Column id="attfiledata" type="BLOB" size="256"/>
  56. <Column id="attfilesize" type="STRING" size="256"/>
  57. <Column id="attfiletype" type="STRING" size="256"/>
  58. <Column id="attfiledown" type="STRING" size="256"/>
  59. </ColumnInfo>
  60. </Dataset>
  61. <Dataset id="ds_status" firefirstcount="0" firenextcount="0" useclientlayout="false" updatecontrol="true" enableevent="true" loadkeymode="keep" loadfiltermode="keep" reversesubsum="false">
  62. <ColumnInfo>
  63. <Column id="cd" type="STRING" size="256"/>
  64. <Column id="value" type="STRING" size="256"/>
  65. </ColumnInfo>
  66. <Rows>
  67. <Row>
  68. <Col id="cd">1</Col>
  69. <Col id="value">-</Col>
  70. </Row>
  71. <Row>
  72. <Col id="cd">2</Col>
  73. <Col id="value">입력</Col>
  74. </Row>
  75. <Row>
  76. <Col id="cd">4</Col>
  77. <Col id="value">수정</Col>
  78. </Row>
  79. <Row>
  80. <Col id="cd">8</Col>
  81. <Col id="value">삭제</Col>
  82. </Row>
  83. </Rows>
  84. </Dataset>
  85. <Dataset id="ds_download" firefirstcount="0" firenextcount="0" useclientlayout="false" updatecontrol="true" enableevent="true" loadkeymode="keep" loadfiltermode="keep" reversesubsum="false">
  86. <ColumnInfo>
  87. <Column id="attfilenm" type="STRING" size="256"/>
  88. <Column id="attfiledata" type="BLOB" size="256"/>
  89. </ColumnInfo>
  90. </Dataset>
  91. <Dataset id="ds_req" firefirstcount="0" firenextcount="0" useclientlayout="false" updatecontrol="true" enableevent="true" loadkeymode="keep" loadfiltermode="keep" reversesubsum="false">
  92. <ColumnInfo>
  93. <Column id="attfilenm" type="STRING" size="256"/>
  94. <Column id="attfilepath" type="STRING" size="256"/>
  95. <Column id="Column0" type="STRING" size="256"/>
  96. </ColumnInfo>
  97. </Dataset>
  98. </Objects>
  99. <Script type="xscript4.0"><![CDATA[/************************************************************************************************
  100. * 파 일 명 : SMSMP90105_파일첨부샘플.xfdl
  101. * 작 성 자 : 이상준
  102. * 작 성 일 : 2014.02.26
  103. * 설 명 : 샘플화면.
  104. * 수 정 자 :
  105. * 수정이력 :
  106. ************************************************************************************************/
  107. include "com_commonxp::comm_main.xjs"
  108. // 폼로드시 공지사항 조회
  109. function form_onload(obj:Form, e:LoadEventInfo)
  110. {
  111. lf_Search();
  112. }
  113. function bt_save_onclick(obj:Button, e:ClickEventInfo)
  114. {
  115. // 필수입력 체크
  116. var nUpdatedRow = 0;
  117. for (var i=0; i<ds_notice.rowcount ; i++)
  118. {
  119. var sRowType = ds_notice.getRowType(i);
  120. if (sRowType == Dataset.ROWTYPE_INSERT ||
  121. sRowType == Dataset.ROWTYPE_UPDATE ||
  122. sRowType == Dataset.ROWTYPE_DELETE)
  123. {
  124. nUpdatedRow++;
  125. }
  126. }
  127. if (nUpdatedRow == 0)
  128. {
  129. sysf_messageBox("변경된 데이터가 없습니다.","E999");
  130. }
  131. else {
  132. tranf_submit({
  133. id: "TXZZZ10100"
  134. , service: "sampleapp.UploadSample"
  135. , method: "reqExeSaveNoticeList"
  136. , inds : "req=ds_notice:U"
  137. , outds : "ds_notice=noticelist"
  138. , callback: "cbf_TXZZZ10100"
  139. , async: true
  140. });
  141. }
  142. }
  143. function cbf_TXZZZ10100()
  144. {
  145. trace("저장이 완료되었습니다.");
  146. }
  147. function lf_Search()
  148. {
  149. tranf_submit({
  150. id: "TRZZZ10100"
  151. , service: "sampleapp.UploadSample"
  152. , method: "reqGetNoticeList"
  153. , outds : "ds_notice=noticelist"
  154. , callback: "cbf_TRZZZ10100"
  155. , async: true
  156. });
  157. }
  158. function cbf_TRZZZ10100()
  159. {
  160. trace("조회가 완료되었습니다.");
  161. }
  162. function bt_init_onclick(obj:Button, e:ClickEventInfo)
  163. {
  164. lf_Search();
  165. }
  166. function bt_addrow_onclick(obj:Button, e:ClickEventInfo)
  167. {
  168. //Dataset 행추가
  169. var nRowNum = ds_notice.insertRow(0);
  170. //Dataset 초기값 셋팅
  171. ds_notice.setColumn(nRowNum, "attfilenm", "클릭하여 파일을 첨부하세요");
  172. }
  173. function bt_deleterow_onclick(obj:Button, e:ClickEventInfo)
  174. {
  175. ds_notice.updatecontrol = false;
  176. var bSucc = ds_notice.setRowType(ds_notice.rowposition, Dataset.ROWTYPE_DELETE);
  177. trace(bSucc);
  178. ds_notice.updatecontrol = true;
  179. }
  180. function gd_notice_oncellclick(obj:Grid, e:GridClickEventInfo)
  181. {
  182. trace(e.row+","+e.col);
  183. var sRowType = ds_notice.getRowType(e.row);
  184. if (e.col == 2) // 파일명 컬럼을 클릭했을 경우
  185. {
  186. trace ("파일첨부합니다");
  187. // 파일다이얼로그를 띄워 사용자에게 파일경로를 입력받는다.
  188. var fd = new FileDialog;
  189. var objVFile = fd.open("FileOpen", FileDialog.LOAD); // 단일 파일 선택
  190. // 해당 파일을 데이터 셋에 저장한다.
  191. lf_saveFile(objVFile, e.row)
  192. }
  193. else if (e.col == 5 && sRowType == Dataset.ROWTYPE_NORMAL) // 다운로드 컬럼을 클릭했을 경우
  194. {
  195. ds_req.clearData();
  196. ds_req.addRow();
  197. ds_req.setColumn(0,"attfilenm", ds_notice.getColumn(e.row, "attfilenm"));
  198. ds_req.setColumn(0,"attfilepath", ds_notice.getColumn(e.row, "attfilepath"));
  199. tranf_submit({
  200. id: "TXZZZ10101"
  201. , service: "sampleapp.UploadSample"
  202. , method: "reqGetAttachFile"
  203. , inds : "req=ds_req"
  204. , outds : "ds_download=file"
  205. , callback: "cbf_TXZZZ10101"
  206. , async: true
  207. });
  208. }
  209. }
  210. // 주어진 VirtualFile 을 데이터셋에 저장한다.
  211. function lf_saveFile(objVFile, nRow)
  212. {
  213. var sRowType = ds_notice.getRowType(nRow);
  214. // 그 파일의 데이터를 데이터셋의 특정 컬럼에 BLOB 형식으로 write 한다.
  215. var file = dsf_writeFileToDs(objVFile, ds_notice, nRow, "attfiledata");
  216. trace(file.filename);
  217. ds_notice.setColumn(nRow, "attfilenm", file.filename);
  218. ds_notice.setColumn(nRow, "attfilesize", file.filesize);
  219. ds_notice.setColumn(nRow, "attfiletype", file.filetype);
  220. if (sRowType == Dataset.ROWTYPE_INSERT) {
  221. ds_notice.setColumn(nRow, "attfiledown", "입력된 파일");
  222. }
  223. else {
  224. ds_notice.setColumn(nRow, "attfiledown", "수정된 파일");
  225. }
  226. }
  227. // ds_download 데이터셋으로부터 VirtualFile 객체를 추출하여 로컬파일시스템에 저장한다.
  228. // (내문서이외의 디렉토리에는 sandbox 정책으로 인하여 alert 창이 출력된다.
  229. function cbf_TXZZZ10101()
  230. {
  231. trace("다운로드를 시작합니다.");
  232. var fd = new FileDialog;
  233. var sFileName = ds_download.getColumn(0,"attfilenm");
  234. var objVFile = fd.open("FileSave", FileDialog.SAVE, "%MYDOCUMENT%", sFileName); // 단일 파일 선택
  235. if (objVFile != null) {
  236. dsf_readFileFromDs(objVFile.fullpath, ds_download, 0, "attfiledata"); // 파일저장
  237. }
  238. }
  239. function bt_batchuplaod_onclick(obj:Button, e:ClickEventInfo)
  240. {
  241. // 파일다이얼로그를 띄워 사용자에게 파일경로를 입력받는다.
  242. var fd = new FileDialog;
  243. var objVFileList = fd.open("FileOpen", FileDialog.MULTILOAD); // 여러파일 선택
  244. for (var i=0; i<objVFileList.length; i++)
  245. {
  246. //Dataset 행추가
  247. var nRowNum = ds_notice.insertRow(0);
  248. // 해당 파일의 데이터를 데이터셋의 특정 컬럼에 BLOB 형식으로 write 한다.
  249. lf_saveFile(objVFileList[i], nRowNum);
  250. }
  251. }
  252. ]]></Script>
  253. </Form>
  254. </FDL>