123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279 |
- <?xml version="1.0" encoding="utf-8"?>
- <FDL version="1.4">
- <TypeDefinition url="..\..\..\default_typedef.xml"/>
- <Form id="SMSMP90105_파일첨부샘플" classname="SMSMP90105_파일첨부샘플" inheritanceid="" position="absolute 0 0 1024 768" titletext="New Form" onload="form_onload">
- <Layouts>
- <Layout>
- <Static id="caption6" text="파일첨부샘플 " onclick=""caption6_onclick"" class="tit_1" position="absolute 16 16 278 41"/>
- <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">
- <Formats>
- <Format id="default">
- <Columns>
- <Column size="47"/>
- <Column size="80"/>
- <Column size="218"/>
- <Column size="90"/>
- <Column size="126"/>
- <Column size="101"/>
- </Columns>
- <Rows>
- <Row size="24" band="head"/>
- <Row size="30"/>
- </Rows>
- <Band id="head">
- <Cell text="상태"/>
- <Cell col="1" text="번호"/>
- <Cell col="2" text="파일명"/>
- <Cell col="3" text="사이즈"/>
- <Cell col="4" text="mime타입"/>
- <Cell col="5" text="다운로드"/>
- </Band>
- <Band id="body">
- <Cell displaytype="combo" text="status" expr="expr:getRowType(currow)" combodataset="ds_status" combocodecol="cd" combodatacol="value"/>
- <Cell col="1" text="bind:genrno"/>
- <Cell col="2" displaytype="button" edittype="textarea" text="bind:attfilenm"/>
- <Cell col="3" text="bind:attfilesize"/>
- <Cell col="4" text="bind:attfiletype"/>
- <Cell col="5" displaytype="button" text="bind:attfiledown"/>
- </Band>
- </Format>
- </Formats>
- </Grid>
- <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;}"/>
- <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;}"/>
- <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;}"/>
- <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;}"/>
- <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"/>
- </Layout>
- </Layouts>
- <Objects>
- <Dataset id="ds_notice" firefirstcount="0" firenextcount="0" useclientlayout="true" updatecontrol="true" enableevent="true" loadkeymode="keep" loadfiltermode="keep" reversesubsum="false">
- <ColumnInfo>
- <Column id="genrno" type="STRING" size="256"/>
- <Column id="attfilenm" type="STRING" size="256"/>
- <Column id="attfilepath" type="STRING" size="256"/>
- <Column id="attfiledata" type="BLOB" size="256"/>
- <Column id="attfilesize" type="STRING" size="256"/>
- <Column id="attfiletype" type="STRING" size="256"/>
- <Column id="attfiledown" type="STRING" size="256"/>
- </ColumnInfo>
- </Dataset>
- <Dataset id="ds_status" firefirstcount="0" firenextcount="0" useclientlayout="false" updatecontrol="true" enableevent="true" loadkeymode="keep" loadfiltermode="keep" reversesubsum="false">
- <ColumnInfo>
- <Column id="cd" type="STRING" size="256"/>
- <Column id="value" type="STRING" size="256"/>
- </ColumnInfo>
- <Rows>
- <Row>
- <Col id="cd">1</Col>
- <Col id="value">-</Col>
- </Row>
- <Row>
- <Col id="cd">2</Col>
- <Col id="value">입력</Col>
- </Row>
- <Row>
- <Col id="cd">4</Col>
- <Col id="value">수정</Col>
- </Row>
- <Row>
- <Col id="cd">8</Col>
- <Col id="value">삭제</Col>
- </Row>
- </Rows>
- </Dataset>
- <Dataset id="ds_download" firefirstcount="0" firenextcount="0" useclientlayout="false" updatecontrol="true" enableevent="true" loadkeymode="keep" loadfiltermode="keep" reversesubsum="false">
- <ColumnInfo>
- <Column id="attfilenm" type="STRING" size="256"/>
- <Column id="attfiledata" type="BLOB" size="256"/>
- </ColumnInfo>
- </Dataset>
- <Dataset id="ds_req" firefirstcount="0" firenextcount="0" useclientlayout="false" updatecontrol="true" enableevent="true" loadkeymode="keep" loadfiltermode="keep" reversesubsum="false">
- <ColumnInfo>
- <Column id="attfilenm" type="STRING" size="256"/>
- <Column id="attfilepath" type="STRING" size="256"/>
- <Column id="Column0" type="STRING" size="256"/>
- </ColumnInfo>
- </Dataset>
- </Objects>
- <Script type="xscript4.0"><![CDATA[/************************************************************************************************
- * 파 일 명 : SMSMP90105_파일첨부샘플.xfdl
- * 작 성 자 : 이상준
- * 작 성 일 : 2014.02.26
- * 설 명 : 샘플화면.
- * 수 정 자 :
- * 수정이력 :
- ************************************************************************************************/
- include "com_commonxp::comm_main.xjs"
- // 폼로드시 공지사항 조회
- function form_onload(obj:Form, e:LoadEventInfo)
- {
- lf_Search();
- }
- function bt_save_onclick(obj:Button, e:ClickEventInfo)
- {
- // 필수입력 체크
- var nUpdatedRow = 0;
- for (var i=0; i<ds_notice.rowcount ; i++)
- {
- var sRowType = ds_notice.getRowType(i);
-
- if (sRowType == Dataset.ROWTYPE_INSERT ||
- sRowType == Dataset.ROWTYPE_UPDATE ||
- sRowType == Dataset.ROWTYPE_DELETE)
- {
- nUpdatedRow++;
- }
- }
- if (nUpdatedRow == 0)
- {
- sysf_messageBox("변경된 데이터가 없습니다.","E999");
- }
- else {
- tranf_submit({
- id: "TXZZZ10100"
- , service: "sampleapp.UploadSample"
- , method: "reqExeSaveNoticeList"
- , inds : "req=ds_notice:U"
- , outds : "ds_notice=noticelist"
- , callback: "cbf_TXZZZ10100"
- , async: true
- });
- }
- }
- function cbf_TXZZZ10100()
- {
- trace("저장이 완료되었습니다.");
- }
- function lf_Search()
- {
- tranf_submit({
- id: "TRZZZ10100"
- , service: "sampleapp.UploadSample"
- , method: "reqGetNoticeList"
- , outds : "ds_notice=noticelist"
- , callback: "cbf_TRZZZ10100"
- , async: true
- });
-
- }
- function cbf_TRZZZ10100()
- {
- trace("조회가 완료되었습니다.");
- }
- function bt_init_onclick(obj:Button, e:ClickEventInfo)
- {
- lf_Search();
- }
- function bt_addrow_onclick(obj:Button, e:ClickEventInfo)
- {
- //Dataset 행추가
- var nRowNum = ds_notice.insertRow(0);
- //Dataset 초기값 셋팅
- ds_notice.setColumn(nRowNum, "attfilenm", "클릭하여 파일을 첨부하세요");
- }
- function bt_deleterow_onclick(obj:Button, e:ClickEventInfo)
- {
- ds_notice.updatecontrol = false;
-
- var bSucc = ds_notice.setRowType(ds_notice.rowposition, Dataset.ROWTYPE_DELETE);
- trace(bSucc);
- ds_notice.updatecontrol = true;
- }
- function gd_notice_oncellclick(obj:Grid, e:GridClickEventInfo)
- {
- trace(e.row+","+e.col);
- var sRowType = ds_notice.getRowType(e.row);
-
- if (e.col == 2) // 파일명 컬럼을 클릭했을 경우
- {
- trace ("파일첨부합니다");
-
- // 파일다이얼로그를 띄워 사용자에게 파일경로를 입력받는다.
- var fd = new FileDialog;
- var objVFile = fd.open("FileOpen", FileDialog.LOAD); // 단일 파일 선택
-
- // 해당 파일을 데이터 셋에 저장한다.
- lf_saveFile(objVFile, e.row)
- }
- else if (e.col == 5 && sRowType == Dataset.ROWTYPE_NORMAL) // 다운로드 컬럼을 클릭했을 경우
- {
- ds_req.clearData();
- ds_req.addRow();
- ds_req.setColumn(0,"attfilenm", ds_notice.getColumn(e.row, "attfilenm"));
- ds_req.setColumn(0,"attfilepath", ds_notice.getColumn(e.row, "attfilepath"));
- tranf_submit({
- id: "TXZZZ10101"
- , service: "sampleapp.UploadSample"
- , method: "reqGetAttachFile"
- , inds : "req=ds_req"
- , outds : "ds_download=file"
- , callback: "cbf_TXZZZ10101"
- , async: true
- });
- }
- }
- // 주어진 VirtualFile 을 데이터셋에 저장한다.
- function lf_saveFile(objVFile, nRow)
- {
- var sRowType = ds_notice.getRowType(nRow);
- // 그 파일의 데이터를 데이터셋의 특정 컬럼에 BLOB 형식으로 write 한다.
- var file = dsf_writeFileToDs(objVFile, ds_notice, nRow, "attfiledata");
- trace(file.filename);
- ds_notice.setColumn(nRow, "attfilenm", file.filename);
- ds_notice.setColumn(nRow, "attfilesize", file.filesize);
- ds_notice.setColumn(nRow, "attfiletype", file.filetype);
- if (sRowType == Dataset.ROWTYPE_INSERT) {
- ds_notice.setColumn(nRow, "attfiledown", "입력된 파일");
- }
- else {
- ds_notice.setColumn(nRow, "attfiledown", "수정된 파일");
- }
- }
- // ds_download 데이터셋으로부터 VirtualFile 객체를 추출하여 로컬파일시스템에 저장한다.
- // (내문서이외의 디렉토리에는 sandbox 정책으로 인하여 alert 창이 출력된다.
- function cbf_TXZZZ10101()
- {
- trace("다운로드를 시작합니다.");
- var fd = new FileDialog;
- var sFileName = ds_download.getColumn(0,"attfilenm");
- var objVFile = fd.open("FileSave", FileDialog.SAVE, "%MYDOCUMENT%", sFileName); // 단일 파일 선택
- if (objVFile != null) {
- dsf_readFileFromDs(objVFile.fullpath, ds_download, 0, "attfiledata"); // 파일저장
- }
- }
- function bt_batchuplaod_onclick(obj:Button, e:ClickEventInfo)
- {
- // 파일다이얼로그를 띄워 사용자에게 파일경로를 입력받는다.
- var fd = new FileDialog;
- var objVFileList = fd.open("FileOpen", FileDialog.MULTILOAD); // 여러파일 선택
-
- for (var i=0; i<objVFileList.length; i++)
- {
- //Dataset 행추가
- var nRowNum = ds_notice.insertRow(0);
-
- // 해당 파일의 데이터를 데이터셋의 특정 컬럼에 BLOB 형식으로 write 한다.
- lf_saveFile(objVFileList[i], nRowNum);
- }
- }
- ]]></Script>
- </Form>
- </FDL>
|