SMRSC09000.js 21 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505
  1. /* ---------------------------------------------------------------------
  2. SMRSC09000_상비약품관리.xrw (SMRSC09000.xfm - JScript )
  3. - Version :
  4. 1) : Ver.1.00.01
  5. : Create By Francis Choi
  6. : 2010.02.16
  7. ---------------------------------------------------------------------- */
  8. var gPurcDeptcd = ""; // 약국 사용부서
  9. // --------------------------------------------------
  10. // 사용자권한 Check
  11. // --------------------------------------------------
  12. function fInitForm() {
  13. fInitialize();
  14. model.refresh();
  15. }
  16. // --------------------------------------------------------------
  17. // 화면 open시와 초기화 버튼 클릭시 화면 초기화 기능을 수행한다.
  18. // --------------------------------------------------------------
  19. function fInitialize() {
  20. var vInstCd = getUserInfo("dutplceinstcd");
  21. model.removenode("/root/main/stockdata/item");
  22. //[2010.08.26]AS-IS 코드 TO_BE 코드 전환을 위한 물품구분 변경 (goodflag= P) => (goodflag= PH)
  23. model.setValue(ipt_goodflag.attribute("ref"), "PH");
  24. rszfUserReqInstList(cmb_instcd , getUserInfo("userid"),"1","B");
  25. rszfLMSComboList(model.getValue(ipt_goodflag.attribute("ref")), "", "", "cmb_lrg", "", "L", "Y", "Y");
  26. misfComboComCdListMulti("Z0007", "cmb_instcd"); //기관코드
  27. model.setValue(cmb_instcd.attribute("ref"), vInstCd); // Login 사용자 기관코드
  28. model.setValue(otp_usernm.attribute("ref"), getUserInfo("usernm")); // Login 사용자 기관코드
  29. cmb_lrg.value = "";
  30. misfGridInit(grd_dept);
  31. misfGridInit(grd_stock);
  32. misfGridInit(grd_history);
  33. misfGridInit(grd_drugprtlist);
  34. //grd_dept.explorerbar = "sortshow";
  35. //grd_stock.explorerbar = "sortshow";
  36. //grd_history.explorerbar = "sortshow";
  37. // -------------------------------------------------------------------------------------
  38. // 기관별 구매시스템 기본정보를 조회한다
  39. // vPathResult = "/root/init/RscsysinftLists";
  40. // drugdept 약제담당부서
  41. // -------------------------------------------------------------------------------------
  42. //rszfRscsysinftLists(vInstCd);
  43. //gPurcDeptcd = getRscsysinftInfo("drugdept"); //
  44. // -------------------------------------------
  45. // 기관별 구매발주자 기본정보를 조회한다
  46. // -------------------------------------------
  47. //rszfRscsysordtLists(vInstCd, gPurcDeptcd, getUserInfo("userid"))
  48. //var vPurcOrdId = getRscsysordtInfo("purcordid");
  49. model.setValue(rdo_drugflag.attribute("ref"),"1"); //관리구분 1.일반약품 2:마약류
  50. // alert(getUserInfo("userid")+"=="+vPurcOrdId);
  51. // var usrDeptCd = getUserInfo("dutplcecd");
  52. // if (usrDeptCd.substring(0,4) != "3242") {
  53. // vPurcOrdId = "1";
  54. /*if (vPurcOrdId == "") {
  55. btn_find.disabled = true;
  56. btn_save.disabled = true;
  57. btn_addRow.disabled = true;
  58. btn_delRow.disabled = true;
  59. grd_stock.colAttribute(grd_stock.colRef("drugqty" ), "editable") = false;
  60. grd_stock.colAttribute(grd_stock.colRef("keepmth" ), "editable") = false;
  61. grd_stock.colAttribute(grd_stock.colRef("clinicreason"), "editable") = false;
  62. grd_stock.colAttribute(grd_stock.colRef("modifyreason"), "editable") = false;
  63. grd_stock.colAttribute(grd_stock.colRef("cmt" ), "editable") = false;
  64. grd_stock.colDisabled(grd_stock.colRef("goodcd" )) = true;
  65. grd_stock.colDisabled(grd_stock.colRef("drugqty" )) = true;
  66. grd_stock.colDisabled(grd_stock.colRef("keepmth" )) = true;
  67. grd_stock.colDisabled(grd_stock.colRef("clinicreason")) = true;
  68. grd_stock.colDisabled(grd_stock.colRef("modifyreason")) = true;
  69. grd_stock.colDisabled(grd_stock.colRef("cmt" )) = true;
  70. if (getUserInfo("dutplcecd").substring(0,3) != "324") {
  71. model.setValue(ipt_deptcd.attribute("ref"), getUserInfo("dutplcecd"));
  72. model.setValue(opt_deptnm.attribute("ref"), getUserInfo("dutplcenm"));
  73. ipt_deptcd.disabled = true;
  74. }
  75. } else {
  76. cpt_excel.visible = true; // 저장
  77. }*/
  78. cpt_excel.visible = true; // 저장
  79. submit("TRRSC09001");
  80. model.setValue("/root/main/articleCnt", "");
  81. model.setValue("/root/main/totalPrice", "");
  82. //misfGridInit(grd_stock);
  83. //misfGridInit(grd_history);
  84. }
  85. // --------------------------------------------------------------
  86. // 상비약품량과 변경이력 조회
  87. // --------------------------------------------------------------
  88. function fSearch() {
  89. // misfGridInit(grd_dept);
  90. misfGridInit(grd_stock);
  91. misfGridInit(grd_history);
  92. submit("TRRSC09002");
  93. submit("TRRSC09003");
  94. fSumViewOption(grd_stock,ckb_reqdeptcd , "reqdeptcd" );
  95. fSumViewOption(grd_stock,ckb_reqdeptnm , "reqdeptnm" );
  96. fSumViewOption(grd_stock,ckb_lrgnm , "lrgnm" );
  97. fSumViewOption(grd_stock,ckb_mdlnm , "mdlnm" );
  98. fSumViewOption(grd_stock,ckb_smlnm , "smlnm" );
  99. fSumViewOption(grd_stock,ckb_lastupdt , "lastupdt" );
  100. fSumViewOption(grd_stock,ckb_lastupdt , "lastupdt" );
  101. fSumViewOption(grd_stock,chk_lastupdtnm, "lastupdtnm");
  102. // fTotalData();
  103. }
  104. // --------------------------------------------------------------
  105. // 상비약품 총량과 금액 Sum
  106. // --------------------------------------------------------------
  107. function fTotalData() {
  108. var articleCnt = model.getXPathValue("count(/root/main/stockdata/item)");
  109. var totalPrice = 0;
  110. for (var i = 1; i < grd_stock.rows; i++) {
  111. var aCnt = model.getValue(grd_stock.nodeset+"["+i+"]/drugqty" ); // 수량
  112. var cost = model.getValue(grd_stock.nodeset+"["+i+"]/goodunitcost"); // 단가
  113. var itemamt = model.getValue(grd_stock.nodeset+"["+i+"]/itemamt" ); // 조회시 금액
  114. totalPrice += parseFloat(itemamt);
  115. // totalPrice += parseFloat(aCnt)*parseFloat(cost);
  116. grd_stock.isReadOnly( i, grd_stock.colRef("goodcd"), i, grd_stock.colRef("goodcd")) = true; //전체 Grid ReadOnly false
  117. }
  118. // model.setValue("/root/main/articleCnt", articleCnt);
  119. // model.setValue("/root/main/totalPrice", totalPrice);
  120. // caption8.refresh();
  121. // caption10.refresh();
  122. }
  123. // --------------------------------------------------------------
  124. // 약품코드조회
  125. // --------------------------------------------------------------
  126. function fButtonClick() {
  127. if (grd_stock.col == grd_stock.colRef("goodcd")) {
  128. fSelectDrug();
  129. } else {
  130. }
  131. }
  132. // --------------------------------------------------------------
  133. // 약품코드조회
  134. // --------------------------------------------------------------
  135. function fSelectDrug() {
  136. modal("SPRSC09000", 0, 100, 150, "SPRSC09000", "/root/temp/receivedata", "/root/target");
  137. var usrSelVal = model.getValue("/root/temp/usrSelectDrugcd");
  138. if (usrSelVal != "") {
  139. var tmp = usrSelVal.split("▩");
  140. var tmp1 = tmp[0].split("▦");
  141. var tmp2 = tmp[1].split("▦");
  142. for (var i = 0; i < tmp1.length; i++) {
  143. if (tmp1[i] == "goodcd") {
  144. model.setValue("/root/send/search/drugcd", tmp2[i]);
  145. }
  146. if (tmp1[i] == "goodnm") {
  147. model.setValue("/root/send/search/drugnm", tmp2[i]);
  148. }
  149. }
  150. } else {
  151. model.setValue("/root/send/search/drugcd", "");
  152. model.setValue("/root/send/search/drugnm", "");
  153. }
  154. model.setValue("/root/temp/usrSelectDrugcd", "");
  155. ipt_goodcd.refresh();
  156. opt_goodnm.refresh();
  157. }
  158. // --------------------------------------------------------------
  159. // 부서 선택시 상비약품 조회 처리
  160. // --------------------------------------------------------------
  161. function fSearchStockList() {
  162. var selRow = grd_dept.row;
  163. if (grd_dept.isCell(event.target) && selRow > 0) {
  164. if(grd_dept.col != grd_dept.colRef("chk")){
  165. var deptcd = model.getValue("/root/main/deptdata/item["+selRow+"]/deptcd");
  166. var deptnm = model.getValue("/root/main/deptdata/item["+selRow+"]/deptnm");
  167. var allsizespecid = model.getValue("/root/main/deptdata/item["+selRow+"]/allsizespecid");
  168. model.setValue("/root/send/search/deptcd" , deptcd);
  169. model.setValue("/root/send/search/deptnm" , deptnm);
  170. model.setValue("/root/send/search/allsizespecid", allsizespecid);
  171. fSearch();
  172. model.refresh();
  173. }
  174. }
  175. }
  176. // --------------------------------------------------------------
  177. // 부서 상비약품 이력 조회
  178. // --------------------------------------------------------------
  179. function fSearchHistory() {
  180. if (grd_stock.isCell(event.target) && grd_stock.row > 0) {
  181. }
  182. }
  183. // --------------------------------------------------------------
  184. // 부서 상비약품 변경시 저장처리
  185. // --------------------------------------------------------------
  186. function fSave() {
  187. model.setValue("/root/send/saveData", grd_stock.getUpdateData());
  188. if (model.getValue("/root/send/saveData").split("▩").length < 3) {
  189. } else {
  190. var chkData = model.getValue("/root/send/saveData");
  191. var tmpData = chkData.split("▩");
  192. var tmpHeader = tmpData[0].split("▦");
  193. var submitType = true;
  194. // alert(tmpData);
  195. for (var i = 1; i < tmpData.length; i++) {
  196. tmpChkData = tmpData[i].split("▦");
  197. // 부서
  198. // alert(tmpChkData[grd_stock.colRef("reqdeptcd")+1]+"===>>"+grd_stock.colRef("reqdeptcd"));
  199. if (tmpChkData[grd_stock.colRef("reqdeptcd")+1] == "") {
  200. messageBox("부서는 ", "I003");
  201. submitType = false;
  202. break;
  203. }
  204. // 약품
  205. if (tmpChkData[grd_stock.colRef("goodcd")+1] == "") {
  206. messageBox("상품코드는 ", "I003");
  207. submitType = false;
  208. break;
  209. }
  210. // 수량
  211. if (tmpChkData[grd_stock.colRef("drugqty")+1] == "") {
  212. messageBox("수량은 ", "I003");
  213. submitType = false;
  214. break;
  215. }
  216. //변경 사유
  217. /*if (tmpChkData[grd_stock.colRef("modifyreason")+1] == "") {
  218. messageBox("변경사유는 ", "I003");
  219. submitType = false;
  220. break;
  221. }*/
  222. }
  223. if (submitType) {
  224. misfSave("TXRSC09001");
  225. var tmpDeptcd = model.getValue("/root/send/search/deptcd");
  226. var tmpAllsize= model.getValue("/root/send/search/allsizespecid");
  227. model.setValue("/root/send/search/deptcd", "");
  228. model.setValue("/root/send/search/allsizespecid", "");
  229. submit('TRRSC09001');
  230. model.setValue("/root/send/search/deptcd" , tmpDeptcd);
  231. model.setValue("/root/send/search/allsizespecid", tmpAllsize);
  232. fSearch();
  233. }
  234. }
  235. }
  236. // --------------------------------------------------------------
  237. // 부서 상비약품 Excel 저장처리
  238. // --------------------------------------------------------------
  239. function fSaveExcel() {
  240. var files = window.fileDialog("save","|", true, "부서별상비약품점검내역_"+getCurrentDate(),"xls","Excel Files(*.xls)|*.xls");
  241. // var filesarr= files.split("\\");
  242. // var filenm = filesarr[filesarr.length-1];
  243. // var filepath= files.split(filenm);
  244. if (files != "") {
  245. var sendPath = "/root/send/search";
  246. var ptxt = "";
  247. ptxt += "&instcd=" + model.getValue(sendPath+"/instcd" );
  248. ptxt += "&deptcd=" + model.getValue(sendPath+"/deptcd" );
  249. ptxt += "&lrgcd=" + model.getValue(sendPath+"/lrgcd" );
  250. ptxt += "&mdlcd=" + model.getValue(sendPath+"/mdlcd" );
  251. ptxt += "&smlcd=" + model.getValue(sendPath+"/smlcd" );
  252. ptxt += "&drugcd=" + model.getValue(sendPath+"/drugcd" );
  253. ptxt += "&drugtxt=" + model.getValue(sendPath+"/drugtxt" );
  254. ptxt += "&allsizespecid=" + model.getValue(sendPath+"/allsizespecid");
  255. //
  256. try {
  257. model.download(getActionURL("TRRSC09004")+ptxt, files, false);
  258. } catch(e) {
  259. }
  260. }
  261. }
  262. // --------------------------------------------------------------
  263. // 부서 상비약품 이력 Excel 저장처리
  264. // --------------------------------------------------------------
  265. function fSaveHistoryExcel() {
  266. var file = window.fileDialog("save","","false","","xls","Excel Files(*.xls)|*.xls");
  267. if (file != "") {
  268. grd_history.saveExcel(file);
  269. }
  270. }
  271. // --------------------------------------------------------------
  272. // 부서 상비약품 추가 처리
  273. // --------------------------------------------------------------
  274. function fAddRow() {
  275. misfGridIUD(grd_stock, "A");
  276. grd_stock.row = grd_stock.rows - grd_stock.fixedRows ;
  277. grd_stock.col = grd_stock.colRef("goodcd");
  278. model.setValue(grd_stock.nodeset +"[" + grd_stock.row + "]/reqdeptcd", model.getValue(ipt_deptcd.attribute("ref")));
  279. model.setValue(grd_stock.nodeset +"[" + grd_stock.row + "]/reqdeptnm", model.getValue(opt_deptnm.attribute("ref")));
  280. model.setValue(grd_stock.nodeset +"[" + grd_stock.row + "]/drugflag" , model.getValue(rdo_drugflag.attribute("ref")));
  281. if (model.getValue(ipt_allsizespecid.attribute("ref")) != "-") {
  282. model.setValue(grd_stock.nodeset +"[" + grd_stock.row + "]/cmt" , model.getValue(opt_deptnm.attribute("ref")));
  283. model.setValue(grd_stock.nodeset +"[" + grd_stock.row + "]/allsizespecid", model.getValue(ipt_allsizespecid.attribute("ref")));
  284. }
  285. // grd_stock.colDisabled(grd_stock.colRef("goodcd")) = true;
  286. grd_stock.isReadOnly( grd_stock.row , grd_stock.col, grd_stock.row, grd_stock.col) = false; //전체 Grid ReadOnly false
  287. grd_stock.editCell();
  288. }
  289. // --------------------------------------------------------------
  290. // 부서 상비약품 Row Copy 처리
  291. // --------------------------------------------------------------
  292. function fRowCopy() {
  293. var selRow = grd_stock.row;
  294. grd_stock.insertRow(selRow,"below");
  295. var copyPath = "/root/main/stockdata/item["+(selRow+1)+"]";
  296. model.copyNode(copyPath , grd_stock.nodeset +"["+selRow+"]");
  297. model.setValue(copyPath + "/drugqty" , "");
  298. model.setValue(copyPath + "/lastupdt", "");
  299. grd_stock.refresh();
  300. }
  301. // --------------------------------------------------------------
  302. // 부서 상비약품 Row 삭제 처리
  303. // --------------------------------------------------------------
  304. function fDelRow() {
  305. var deleteRowIdx = grd_stock.row;
  306. var rowStatus = grd_stock.rowStatus(deleteRowIdx);
  307. if (rowStatus == 1 || rowStatus == 3 || rowStatus == 5) {
  308. if (deleteRowIdx > -1) {
  309. grd_stock.deleteRow(deleteRowIdx, true);
  310. }
  311. } else {
  312. grd_stock.addStatus(deleteRowIdx,"delete");
  313. // model.setValue(grd_stock.nodeset +"["+deleteRowIdx+"]/modifyreason", "");
  314. }
  315. }
  316. // --------------------------------------------------------------
  317. // 부서 상비약품내역 OnClick 처리
  318. // --------------------------------------------------------------
  319. function fOperationStockGrid() {
  320. if (grd_stock.isCell(event.target) && grd_stock.row >= grd_stock.fixedRows ) {
  321. var tmpChk = model.getValue(grd_stock.nodeset +"["+grd_stock.row+"]/lastupdt");
  322. var selCol = grd_stock.col;
  323. if (tmpChk == "") {
  324. if (selCol == grd_stock.colRef("reqdeptcd")) {
  325. model.setValue("/root/target/recvref", "/root/target/recvitem[1]");
  326. modal( "SPRPZ00200", 0, 100, 150, "SPRPZ00200", "/root/target", "/root/target" );
  327. model.setValue(grd_stock.nodeset +"["+grd_stock.row+"]/reqdeptcd", model.getValue("/root/target/recvitem/reqdeptcd"));
  328. model.setValue(grd_stock.nodeset +"["+grd_stock.row+"]/reqdeptnm", model.getValue("/root/target/recvitem/reqdeptnm"));
  329. model.setValue("/root/target/recvitem/reqdeptcd", "");
  330. model.setValue("/root/target/recvitem/reqdeptnm", "");
  331. grd_stock.refresh();
  332. } else if ((selCol == grd_stock.colRef("goodcd")) ||
  333. (selCol == grd_stock.colRef("goodnm")) ){
  334. modal("SPRSC09000", 0, 100, 150, "SPRSC09000", "/root/temp/receivedata", "/root/target");
  335. var usrSelVal = model.getValue("/root/temp/usrSelectDrugcd");
  336. if (usrSelVal != "") {
  337. var tmp = usrSelVal.split("▩");
  338. var tmp1 = tmp[0].split("▦");
  339. var tmp2 = tmp[1].split("▦");
  340. for (var i = 0; i < tmp1.length; i++) {
  341. if (tmp1[i] != "") {
  342. try {
  343. model.setValue(grd_stock.nodeset +"["+grd_stock.row+"]/"+tmp1[i], tmp2[i]);
  344. } catch(e) {
  345. }
  346. }
  347. }
  348. model.setValue("/root/temp/usrSelectDrugcd", "");
  349. grd_stock.refresh();
  350. }
  351. }
  352. } else {
  353. if (selCol != 9 && selCol != 12 && selCol != 14 && selCol != 15 && selCol != 16) {
  354. var tmpDrugcd = model.getValue("/root/send/search/drugcd");
  355. var searchDrugcd = model.getValue("/root/main/stockdata/item["+grd_stock.row+"]/goodcd");
  356. model.setValue("/root/send/search/drugcd", searchDrugcd);
  357. submit("TRRSC09003");
  358. model.setValue("/root/send/search/drugcd", tmpDrugcd);
  359. ipt_goodcd.refresh();
  360. }
  361. }
  362. }
  363. }
  364. // --------------------------------------------------------------
  365. // 부서 상비약품내역 Value-Changed 처리
  366. // --------------------------------------------------------------
  367. function fStockChangeReasonReset() {
  368. var selRow = grd_stock.row;
  369. var selCol = grd_stock.col;
  370. if (selCol != 15) {
  371. model.setValue("/root/main/stockdata/item["+selRow+"]/modifyreason", "");
  372. }
  373. }
  374. // --------------------------------------------------
  375. // View Option 처리하는 함수
  376. // --------------------------------------------------
  377. function fSumViewOption(pGrid,pOption, pCol) {
  378. pGrid.colHidden(pGrid.colRef(pCol)) = (pOption.value =="Y") ? false : true;
  379. }
  380. /* ------------------------------------------------- */
  381. /* ------End Of List ------------------------------- */
  382. /* -------------------------------------------------- */