123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505 |
- /* ---------------------------------------------------------------------
-
- SMRSC09000_상비약품관리.xrw (SMRSC09000.xfm - JScript )
- - Version :
- 1) : Ver.1.00.01
- : Create By Francis Choi
- : 2010.02.16
- ---------------------------------------------------------------------- */
- var gPurcDeptcd = ""; // 약국 사용부서
-
- // --------------------------------------------------
- // 사용자권한 Check
- // --------------------------------------------------
- function fInitForm() {
- fInitialize();
- model.refresh();
- }
-
- // --------------------------------------------------------------
- // 화면 open시와 초기화 버튼 클릭시 화면 초기화 기능을 수행한다.
- // --------------------------------------------------------------
- function fInitialize() {
- var vInstCd = getUserInfo("dutplceinstcd");
- model.removenode("/root/main/stockdata/item");
- //[2010.08.26]AS-IS 코드 TO_BE 코드 전환을 위한 물품구분 변경 (goodflag= P) => (goodflag= PH)
- model.setValue(ipt_goodflag.attribute("ref"), "PH");
-
- rszfUserReqInstList(cmb_instcd , getUserInfo("userid"),"1","B");
- rszfLMSComboList(model.getValue(ipt_goodflag.attribute("ref")), "", "", "cmb_lrg", "", "L", "Y", "Y");
- misfComboComCdListMulti("Z0007", "cmb_instcd"); //기관코드
-
- model.setValue(cmb_instcd.attribute("ref"), vInstCd); // Login 사용자 기관코드
- model.setValue(otp_usernm.attribute("ref"), getUserInfo("usernm")); // Login 사용자 기관코드
-
- cmb_lrg.value = "";
- misfGridInit(grd_dept);
- misfGridInit(grd_stock);
- misfGridInit(grd_history);
- misfGridInit(grd_drugprtlist);
- //grd_dept.explorerbar = "sortshow";
- //grd_stock.explorerbar = "sortshow";
- //grd_history.explorerbar = "sortshow";
- // -------------------------------------------------------------------------------------
- // 기관별 구매시스템 기본정보를 조회한다
- // vPathResult = "/root/init/RscsysinftLists";
- // drugdept 약제담당부서
- // -------------------------------------------------------------------------------------
- //rszfRscsysinftLists(vInstCd);
-
- //gPurcDeptcd = getRscsysinftInfo("drugdept"); //
-
- // -------------------------------------------
- // 기관별 구매발주자 기본정보를 조회한다
- // -------------------------------------------
- //rszfRscsysordtLists(vInstCd, gPurcDeptcd, getUserInfo("userid"))
-
- //var vPurcOrdId = getRscsysordtInfo("purcordid");
-
- model.setValue(rdo_drugflag.attribute("ref"),"1"); //관리구분 1.일반약품 2:마약류
-
- // alert(getUserInfo("userid")+"=="+vPurcOrdId);
-
- // var usrDeptCd = getUserInfo("dutplcecd");
- // if (usrDeptCd.substring(0,4) != "3242") {
- // vPurcOrdId = "1";
-
- /*if (vPurcOrdId == "") {
- btn_find.disabled = true;
- btn_save.disabled = true;
- btn_addRow.disabled = true;
- btn_delRow.disabled = true;
-
- grd_stock.colAttribute(grd_stock.colRef("drugqty" ), "editable") = false;
- grd_stock.colAttribute(grd_stock.colRef("keepmth" ), "editable") = false;
- grd_stock.colAttribute(grd_stock.colRef("clinicreason"), "editable") = false;
- grd_stock.colAttribute(grd_stock.colRef("modifyreason"), "editable") = false;
- grd_stock.colAttribute(grd_stock.colRef("cmt" ), "editable") = false;
-
- grd_stock.colDisabled(grd_stock.colRef("goodcd" )) = true;
- grd_stock.colDisabled(grd_stock.colRef("drugqty" )) = true;
- grd_stock.colDisabled(grd_stock.colRef("keepmth" )) = true;
- grd_stock.colDisabled(grd_stock.colRef("clinicreason")) = true;
- grd_stock.colDisabled(grd_stock.colRef("modifyreason")) = true;
- grd_stock.colDisabled(grd_stock.colRef("cmt" )) = true;
-
- if (getUserInfo("dutplcecd").substring(0,3) != "324") {
- model.setValue(ipt_deptcd.attribute("ref"), getUserInfo("dutplcecd"));
- model.setValue(opt_deptnm.attribute("ref"), getUserInfo("dutplcenm"));
- ipt_deptcd.disabled = true;
- }
-
- } else {
- cpt_excel.visible = true; // 저장
- }*/
- cpt_excel.visible = true; // 저장
- submit("TRRSC09001");
- model.setValue("/root/main/articleCnt", "");
- model.setValue("/root/main/totalPrice", "");
-
- //misfGridInit(grd_stock);
- //misfGridInit(grd_history);
- }
-
- // --------------------------------------------------------------
- // 상비약품량과 변경이력 조회
- // --------------------------------------------------------------
- function fSearch() {
-
- // misfGridInit(grd_dept);
- misfGridInit(grd_stock);
- misfGridInit(grd_history);
-
- submit("TRRSC09002");
- submit("TRRSC09003");
-
- fSumViewOption(grd_stock,ckb_reqdeptcd , "reqdeptcd" );
- fSumViewOption(grd_stock,ckb_reqdeptnm , "reqdeptnm" );
- fSumViewOption(grd_stock,ckb_lrgnm , "lrgnm" );
- fSumViewOption(grd_stock,ckb_mdlnm , "mdlnm" );
- fSumViewOption(grd_stock,ckb_smlnm , "smlnm" );
- fSumViewOption(grd_stock,ckb_lastupdt , "lastupdt" );
- fSumViewOption(grd_stock,ckb_lastupdt , "lastupdt" );
- fSumViewOption(grd_stock,chk_lastupdtnm, "lastupdtnm");
- // fTotalData();
- }
-
- // --------------------------------------------------------------
- // 상비약품 총량과 금액 Sum
- // --------------------------------------------------------------
- function fTotalData() {
- var articleCnt = model.getXPathValue("count(/root/main/stockdata/item)");
- var totalPrice = 0;
-
- for (var i = 1; i < grd_stock.rows; i++) {
- var aCnt = model.getValue(grd_stock.nodeset+"["+i+"]/drugqty" ); // 수량
- var cost = model.getValue(grd_stock.nodeset+"["+i+"]/goodunitcost"); // 단가
- var itemamt = model.getValue(grd_stock.nodeset+"["+i+"]/itemamt" ); // 조회시 금액
-
- totalPrice += parseFloat(itemamt);
-
- // totalPrice += parseFloat(aCnt)*parseFloat(cost);
- grd_stock.isReadOnly( i, grd_stock.colRef("goodcd"), i, grd_stock.colRef("goodcd")) = true; //전체 Grid ReadOnly false
- }
-
- // model.setValue("/root/main/articleCnt", articleCnt);
- // model.setValue("/root/main/totalPrice", totalPrice);
-
- // caption8.refresh();
- // caption10.refresh();
- }
- // --------------------------------------------------------------
- // 약품코드조회
- // --------------------------------------------------------------
- function fButtonClick() {
- if (grd_stock.col == grd_stock.colRef("goodcd")) {
- fSelectDrug();
- } else {
-
-
- }
- }
-
- // --------------------------------------------------------------
- // 약품코드조회
- // --------------------------------------------------------------
- function fSelectDrug() {
- modal("SPRSC09000", 0, 100, 150, "SPRSC09000", "/root/temp/receivedata", "/root/target");
-
- var usrSelVal = model.getValue("/root/temp/usrSelectDrugcd");
-
- if (usrSelVal != "") {
- var tmp = usrSelVal.split("▩");
- var tmp1 = tmp[0].split("▦");
- var tmp2 = tmp[1].split("▦");
-
- for (var i = 0; i < tmp1.length; i++) {
- if (tmp1[i] == "goodcd") {
- model.setValue("/root/send/search/drugcd", tmp2[i]);
- }
- if (tmp1[i] == "goodnm") {
- model.setValue("/root/send/search/drugnm", tmp2[i]);
- }
- }
-
- } else {
- model.setValue("/root/send/search/drugcd", "");
- model.setValue("/root/send/search/drugnm", "");
- }
-
- model.setValue("/root/temp/usrSelectDrugcd", "");
- ipt_goodcd.refresh();
- opt_goodnm.refresh();
- }
-
- // --------------------------------------------------------------
- // 부서 선택시 상비약품 조회 처리
- // --------------------------------------------------------------
- function fSearchStockList() {
- var selRow = grd_dept.row;
- if (grd_dept.isCell(event.target) && selRow > 0) {
- if(grd_dept.col != grd_dept.colRef("chk")){
- var deptcd = model.getValue("/root/main/deptdata/item["+selRow+"]/deptcd");
- var deptnm = model.getValue("/root/main/deptdata/item["+selRow+"]/deptnm");
- var allsizespecid = model.getValue("/root/main/deptdata/item["+selRow+"]/allsizespecid");
-
- model.setValue("/root/send/search/deptcd" , deptcd);
- model.setValue("/root/send/search/deptnm" , deptnm);
- model.setValue("/root/send/search/allsizespecid", allsizespecid);
-
- fSearch();
- model.refresh();
- }
- }
- }
-
- // --------------------------------------------------------------
- // 부서 상비약품 이력 조회
- // --------------------------------------------------------------
- function fSearchHistory() {
- if (grd_stock.isCell(event.target) && grd_stock.row > 0) {
-
- }
- }
-
- // --------------------------------------------------------------
- // 부서 상비약품 변경시 저장처리
- // --------------------------------------------------------------
- function fSave() {
-
- model.setValue("/root/send/saveData", grd_stock.getUpdateData());
-
- if (model.getValue("/root/send/saveData").split("▩").length < 3) {
- } else {
- var chkData = model.getValue("/root/send/saveData");
- var tmpData = chkData.split("▩");
- var tmpHeader = tmpData[0].split("▦");
-
- var submitType = true;
-
- // alert(tmpData);
-
-
- for (var i = 1; i < tmpData.length; i++) {
- tmpChkData = tmpData[i].split("▦");
- // 부서
- // alert(tmpChkData[grd_stock.colRef("reqdeptcd")+1]+"===>>"+grd_stock.colRef("reqdeptcd"));
-
- if (tmpChkData[grd_stock.colRef("reqdeptcd")+1] == "") {
- messageBox("부서는 ", "I003");
- submitType = false;
- break;
- }
-
- // 약품
- if (tmpChkData[grd_stock.colRef("goodcd")+1] == "") {
- messageBox("상품코드는 ", "I003");
- submitType = false;
- break;
- }
-
- // 수량
- if (tmpChkData[grd_stock.colRef("drugqty")+1] == "") {
- messageBox("수량은 ", "I003");
- submitType = false;
- break;
- }
-
- //변경 사유
- /*if (tmpChkData[grd_stock.colRef("modifyreason")+1] == "") {
- messageBox("변경사유는 ", "I003");
- submitType = false;
- break;
- }*/
- }
-
- if (submitType) {
- misfSave("TXRSC09001");
- var tmpDeptcd = model.getValue("/root/send/search/deptcd");
- var tmpAllsize= model.getValue("/root/send/search/allsizespecid");
-
- model.setValue("/root/send/search/deptcd", "");
- model.setValue("/root/send/search/allsizespecid", "");
- submit('TRRSC09001');
-
- model.setValue("/root/send/search/deptcd" , tmpDeptcd);
- model.setValue("/root/send/search/allsizespecid", tmpAllsize);
-
- fSearch();
- }
- }
- }
-
- // --------------------------------------------------------------
- // 부서 상비약품 Excel 저장처리
- // --------------------------------------------------------------
- function fSaveExcel() {
- var files = window.fileDialog("save","|", true, "부서별상비약품점검내역_"+getCurrentDate(),"xls","Excel Files(*.xls)|*.xls");
- // var filesarr= files.split("\\");
- // var filenm = filesarr[filesarr.length-1];
- // var filepath= files.split(filenm);
- if (files != "") {
- var sendPath = "/root/send/search";
-
- var ptxt = "";
- ptxt += "&instcd=" + model.getValue(sendPath+"/instcd" );
- ptxt += "&deptcd=" + model.getValue(sendPath+"/deptcd" );
- ptxt += "&lrgcd=" + model.getValue(sendPath+"/lrgcd" );
- ptxt += "&mdlcd=" + model.getValue(sendPath+"/mdlcd" );
- ptxt += "&smlcd=" + model.getValue(sendPath+"/smlcd" );
- ptxt += "&drugcd=" + model.getValue(sendPath+"/drugcd" );
- ptxt += "&drugtxt=" + model.getValue(sendPath+"/drugtxt" );
- ptxt += "&allsizespecid=" + model.getValue(sendPath+"/allsizespecid");
- //
- try {
- model.download(getActionURL("TRRSC09004")+ptxt, files, false);
- } catch(e) {
- }
- }
- }
-
- // --------------------------------------------------------------
- // 부서 상비약품 이력 Excel 저장처리
- // --------------------------------------------------------------
- function fSaveHistoryExcel() {
- var file = window.fileDialog("save","","false","","xls","Excel Files(*.xls)|*.xls");
-
- if (file != "") {
- grd_history.saveExcel(file);
- }
- }
-
- // --------------------------------------------------------------
- // 부서 상비약품 추가 처리
- // --------------------------------------------------------------
- function fAddRow() {
-
- misfGridIUD(grd_stock, "A");
- grd_stock.row = grd_stock.rows - grd_stock.fixedRows ;
- grd_stock.col = grd_stock.colRef("goodcd");
-
- model.setValue(grd_stock.nodeset +"[" + grd_stock.row + "]/reqdeptcd", model.getValue(ipt_deptcd.attribute("ref")));
- model.setValue(grd_stock.nodeset +"[" + grd_stock.row + "]/reqdeptnm", model.getValue(opt_deptnm.attribute("ref")));
- model.setValue(grd_stock.nodeset +"[" + grd_stock.row + "]/drugflag" , model.getValue(rdo_drugflag.attribute("ref")));
-
- if (model.getValue(ipt_allsizespecid.attribute("ref")) != "-") {
- model.setValue(grd_stock.nodeset +"[" + grd_stock.row + "]/cmt" , model.getValue(opt_deptnm.attribute("ref")));
- model.setValue(grd_stock.nodeset +"[" + grd_stock.row + "]/allsizespecid", model.getValue(ipt_allsizespecid.attribute("ref")));
- }
-
- // grd_stock.colDisabled(grd_stock.colRef("goodcd")) = true;
-
- grd_stock.isReadOnly( grd_stock.row , grd_stock.col, grd_stock.row, grd_stock.col) = false; //전체 Grid ReadOnly false
-
- grd_stock.editCell();
- }
-
- // --------------------------------------------------------------
- // 부서 상비약품 Row Copy 처리
- // --------------------------------------------------------------
- function fRowCopy() {
- var selRow = grd_stock.row;
-
- grd_stock.insertRow(selRow,"below");
- var copyPath = "/root/main/stockdata/item["+(selRow+1)+"]";
-
- model.copyNode(copyPath , grd_stock.nodeset +"["+selRow+"]");
- model.setValue(copyPath + "/drugqty" , "");
- model.setValue(copyPath + "/lastupdt", "");
- grd_stock.refresh();
- }
-
- // --------------------------------------------------------------
- // 부서 상비약품 Row 삭제 처리
- // --------------------------------------------------------------
- function fDelRow() {
-
- var deleteRowIdx = grd_stock.row;
- var rowStatus = grd_stock.rowStatus(deleteRowIdx);
-
- if (rowStatus == 1 || rowStatus == 3 || rowStatus == 5) {
-
- if (deleteRowIdx > -1) {
- grd_stock.deleteRow(deleteRowIdx, true);
- }
- } else {
- grd_stock.addStatus(deleteRowIdx,"delete");
- // model.setValue(grd_stock.nodeset +"["+deleteRowIdx+"]/modifyreason", "");
- }
- }
-
- // --------------------------------------------------------------
- // 부서 상비약품내역 OnClick 처리
- // --------------------------------------------------------------
- function fOperationStockGrid() {
- if (grd_stock.isCell(event.target) && grd_stock.row >= grd_stock.fixedRows ) {
- var tmpChk = model.getValue(grd_stock.nodeset +"["+grd_stock.row+"]/lastupdt");
- var selCol = grd_stock.col;
- if (tmpChk == "") {
- if (selCol == grd_stock.colRef("reqdeptcd")) {
- model.setValue("/root/target/recvref", "/root/target/recvitem[1]");
- modal( "SPRPZ00200", 0, 100, 150, "SPRPZ00200", "/root/target", "/root/target" );
- model.setValue(grd_stock.nodeset +"["+grd_stock.row+"]/reqdeptcd", model.getValue("/root/target/recvitem/reqdeptcd"));
- model.setValue(grd_stock.nodeset +"["+grd_stock.row+"]/reqdeptnm", model.getValue("/root/target/recvitem/reqdeptnm"));
-
- model.setValue("/root/target/recvitem/reqdeptcd", "");
- model.setValue("/root/target/recvitem/reqdeptnm", "");
- grd_stock.refresh();
-
- } else if ((selCol == grd_stock.colRef("goodcd")) ||
- (selCol == grd_stock.colRef("goodnm")) ){
- modal("SPRSC09000", 0, 100, 150, "SPRSC09000", "/root/temp/receivedata", "/root/target");
- var usrSelVal = model.getValue("/root/temp/usrSelectDrugcd");
- if (usrSelVal != "") {
-
- var tmp = usrSelVal.split("▩");
- var tmp1 = tmp[0].split("▦");
- var tmp2 = tmp[1].split("▦");
-
- for (var i = 0; i < tmp1.length; i++) {
- if (tmp1[i] != "") {
- try {
- model.setValue(grd_stock.nodeset +"["+grd_stock.row+"]/"+tmp1[i], tmp2[i]);
- } catch(e) {
- }
- }
- }
-
- model.setValue("/root/temp/usrSelectDrugcd", "");
- grd_stock.refresh();
- }
- }
- } else {
- if (selCol != 9 && selCol != 12 && selCol != 14 && selCol != 15 && selCol != 16) {
- var tmpDrugcd = model.getValue("/root/send/search/drugcd");
- var searchDrugcd = model.getValue("/root/main/stockdata/item["+grd_stock.row+"]/goodcd");
- model.setValue("/root/send/search/drugcd", searchDrugcd);
- submit("TRRSC09003");
- model.setValue("/root/send/search/drugcd", tmpDrugcd);
- ipt_goodcd.refresh();
- }
- }
- }
- }
-
- // --------------------------------------------------------------
- // 부서 상비약품내역 Value-Changed 처리
- // --------------------------------------------------------------
- function fStockChangeReasonReset() {
- var selRow = grd_stock.row;
- var selCol = grd_stock.col;
-
- if (selCol != 15) {
- model.setValue("/root/main/stockdata/item["+selRow+"]/modifyreason", "");
- }
- }
-
- // --------------------------------------------------
- // View Option 처리하는 함수
- // --------------------------------------------------
- function fSumViewOption(pGrid,pOption, pCol) {
- pGrid.colHidden(pGrid.colRef(pCol)) = (pOption.value =="Y") ? false : true;
- }
-
-
- /* ------------------------------------------------- */
- /* ------End Of List ------------------------------- */
- /* -------------------------------------------------- */
|