SMMNP00720.js 10 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349
  1. /* ---------------------------------------------------------------------
  2. 회복실 V/S 항목관리(SMMNP00720.xfm - JScript )
  3. - Version :
  4. 1) : Ver.1.00.01
  5. : Create By taebum
  6. : 2008-06-19 오후 6:08:34
  7. ---------------------------------------------------------------------- */
  8. var sGGridXPath = "/root/main/list/codelists/codelist";
  9. var sLGridXPath = "/root/main/list/codelists/lrglist";
  10. /**
  11. * 초기화
  12. *
  13. */
  14. function fInitialize(){
  15. model.removeNodeset("/root/main/list/codelists");
  16. model.resetInstanceNode("/root/send");
  17. model.refresh();
  18. cmb_useyn.select(2);
  19. cmb_defaultyn.select(2);
  20. //대분류 콤보 리스트 조회
  21. fGetLrgList();
  22. fbtnSearch();
  23. }
  24. function fGetLrgList(pFlag){
  25. model.setValue("/root/send/temp","temp");
  26. model.removeNodeset("/root/init/lrgcombolists/lrglist");
  27. submit("TRMNP00721");
  28. addComboItem( "combo1", "전체", "%", "above" );
  29. if(pFlag != "" && pFlag != null && pFlag != "undefined"){
  30. model.setValue("/root/send/s_lrgcd",pFlag);
  31. combo1.refresh();
  32. }else{
  33. model.setValue("/root/send/s_lrgcd","%");
  34. combo1.refresh();
  35. }
  36. }
  37. /**
  38. * 그리드 행추가 버튼을 클릭하였을 경우 이벤트
  39. *
  40. */
  41. function fClickRowAddBtn(){
  42. var cur_LrgRow = datagrid1.row; // 행 번호 가져오기
  43. if(cur_LrgRow <= 0 || cur_LrgRow =="undefined") {
  44. alert("분류를 선택하시기 바랍니다...");
  45. return;
  46. }
  47. grd_codelist.addRow(); // 입력할 행 추가.
  48. var cur_row = grd_codelist.row; // 추가된 행 번호 가져오기
  49. var cnt_row = grd_codelist.rows; // 현재 행의 갯수 가져오기
  50. //줄 추가시 기본세팅
  51. //대분류코드, 명칭
  52. model.setValue(sGGridXPath+"["+cur_row+"]/lrgcd",model.getValue("/root/main/list/codelists/lrglist["+cur_LrgRow+"]/lrgcd"));
  53. model.setValue(sGGridXPath+"["+cur_row+"]/lrgnm",model.getValue("/root/main/list/codelists/lrglist["+cur_LrgRow+"]/lrgnm"));
  54. model.setValue(sGGridXPath+"["+cur_row+"]/lrgsortno",model.getValue("/root/main/list/codelists/lrglist["+cur_LrgRow+"]/lrgsortno"));
  55. model.setValue(sGGridXPath+"["+cur_row+"]/useyn","Y");
  56. model.setValue(sGGridXPath+"["+cur_row+"]/defaultyn","Y");
  57. model.setValue(sGGridXPath+"["+cur_row+"]/useyn","Y");
  58. //현재 사용하지 않는 이력관리용 frdd, todd
  59. model.setValue(sGGridXPath+"["+cur_row+"]/frdd","20081003");
  60. model.setValue(sGGridXPath+"["+cur_row+"]/todd","29991231");
  61. grd_codelist.refresh();
  62. grd_codelist.row = cur_row;
  63. grd_codelist.select(cur_row, 2) = true;
  64. grd_codelist.editcell();
  65. }
  66. /**
  67. * 그리드 행추가 버튼을 클릭하였을 경우 이벤트
  68. *
  69. */
  70. function fClickLrgRowAddBtn(){
  71. datagrid1.addRow(); // 입력할 행 추가.
  72. var cur_row = datagrid1.row; // 추가된 행 번호 가져오기
  73. var cnt_row = datagrid1.rows; // 현재 행의 갯수 가져오기
  74. //줄 추가시 기본세팅
  75. model.setValue(sLGridXPath+"["+cur_row+"]/vsitemcd","00000");
  76. model.setValue(sLGridXPath+"["+cur_row+"]/vsitemnm","-");
  77. model.setValue(sLGridXPath+"["+cur_row+"]/defaultyn","-");
  78. model.setValue(sLGridXPath+"["+cur_row+"]/useyn","Y");
  79. model.setValue(sLGridXPath+"["+cur_row+"]/sortno","0");
  80. model.setValue(sLGridXPath+"["+cur_row+"]/ioflag","-");
  81. //현재 사용하지 않는 이력관리용 frdd, todd
  82. model.setValue(sLGridXPath+"["+cur_row+"]/frdd","20081003");
  83. model.setValue(sLGridXPath+"["+cur_row+"]/todd","29991231");
  84. datagrid1.refresh();
  85. datagrid1.row = cur_row;
  86. datagrid1.select(cur_row, 2) = true;
  87. datagrid1.editcell();
  88. }
  89. /**
  90. * 그리드 Row가 추가될 경우 이벤트
  91. *
  92. */
  93. function fRowChanged(){
  94. var cur_row = grd_codelist.row;
  95. if ( cur_row > 0 ) {
  96. model.copyNode("/root/main/item","/root/main/list/codelists["+cur_row+"]");
  97. model.refresh();
  98. }
  99. }
  100. /**
  101. * 그리드 ValueChanged가 발생되었을 경우 이벤트
  102. *
  103. */
  104. function fGridValueChanged(){
  105. var cur_row = grd_codelist.row; // 추가된 행 번호 가져오기
  106. var cur_cel = grd_codelist.col;
  107. var cnt_row = grd_codelist.rows; // 현재 행의 갯수 가져오기
  108. var stat = grd_codelist.colstatus(0);
  109. if(cur_cel == 4){
  110. if(model.getValue("/root/main/list/codelists/codelist["+cur_row+"]/vsitemcd") == "00000"){
  111. messageBox("00000 항목코드는 사용하실 수 없습니다. ","I000");
  112. model.setValue("/root/main/list/codelists/codelist["+cur_row+"]/vsitemcd" , model.getValue("/root/main/list/codelists/codelist["+cur_row+"]/org_vsitemcd"));
  113. grd_codelist.refresh();
  114. grd_codelist.select(cur_row, 4) = true;
  115. grd_codelist.editcell();
  116. grd_codelist.rowstatus(cur_row) = 0;
  117. }
  118. }
  119. }
  120. /**
  121. * 삭제 버튼을 클릭하였을 경우 이벤트
  122. *
  123. */
  124. function fClickDeleteBtn(){
  125. var cur_row = grd_codelist.row; // 행 번호 가져오기
  126. var iStatus = grd_codelist.rowstatus(cur_row);
  127. if(cur_row <= 0 || cur_row =="undefined") {
  128. alert("삭제할 행을 선택하시기 바랍니다...");
  129. return;
  130. }
  131. if (iStatus == 1 || iStatus == 3){ // 새로 삽입된 행이면
  132. grd_codelist.deleteitem(cur_row);
  133. }else if (iStatus == 4){ // 삭제로 표시된 행이면
  134. grd_codelist.removestatus(cur_row, "delete");
  135. }else{
  136. grd_codelist.addStatus(cur_row, "delete");
  137. }
  138. }
  139. /**
  140. * 삭제 버튼을 클릭하였을 경우 이벤트
  141. *
  142. */
  143. function fClickLrgDeleteBtn(){
  144. var cur_row = datagrid1.row; // 행 번호 가져오기
  145. var iStatus = datagrid1.rowstatus(cur_row);
  146. if(cur_row <= 0 || cur_row =="undefined") {
  147. alert("삭제할 행을 선택하시기 바랍니다...");
  148. return;
  149. }
  150. if( messageBox(model.getValue("/root/main/list/codelists/lrglist["+cur_row+"]/lrgnm")+" 분류에 포함된 모든 항목이 삭제됩니다. 삭제하시겠습니까? ","Q000") != "6") {
  151. return;
  152. }
  153. if (iStatus == 1 || iStatus == 3){ // 새로 삽입된 행이면
  154. datagrid1.deleteitem(cur_row);
  155. }else if (iStatus == 4){ // 삭제로 표시된 행이면
  156. datagrid1.removestatus(cur_row, "delete");
  157. }else{
  158. datagrid1.addStatus(cur_row, "delete");
  159. }
  160. }
  161. /*
  162. * 저장 버튼을 클릭하였을 경우 이벤트
  163. *
  164. */
  165. function fOnClickSaveBtn(){
  166. if(!checkGridUpdate(grd_codelist) && !checkGridUpdate(datagrid1)){
  167. alert("저장할 자료가 존재하지 않습니다.");
  168. return;
  169. }
  170. if(!checkGridField(grd_codelist,"lrgcd▦lrgnm▦lrgsortno▦vsitemcd▦vsitemnm▦ioflag▦defaultyn▦useyn▦sortno▦")){
  171. alert("데이터중에 비어있는 필수필드가 있습니다.");
  172. return;
  173. }
  174. if(!checkGridField(datagrid1,"lrgcd▦lrgnm▦vsitemcd▦vsitemnm▦ioflag▦lrgsortno▦")){
  175. alert("데이터중에 비어있는 필수필드가 있습니다.");
  176. return;
  177. }
  178. model.setValue("/root/send/listdata" , grd_codelist.getUpdateData());
  179. model.setValue("/root/send/lrglistdata", datagrid1.getUpdateData());
  180. if ( submit("TXMNP00720") ) {
  181. grd_codelist.clearStatus(); // submit() 성공하면 그리드의 i,u,d 상태 제거
  182. model.setValue("/root/send/listdata","");
  183. //changeNodeSet();
  184. //대분류 콤보 리스트 조회
  185. fGetLrgList();
  186. cmb_useyn.select(2);
  187. cmb_defaultyn.select(2);
  188. }
  189. }
  190. /**
  191. * @group :
  192. * @ver : 2006.12.20
  193. * @by :
  194. * @---------------------------------------------------
  195. * @type : function
  196. * @access : public
  197. * @desc :
  198. * @return : bool
  199. * @---------------------------------------------------
  200. */
  201. function checkGridUpdate(grid)
  202. {
  203. var iData = grid.getUpdateDataXml("insert");
  204. var uData = grid.getUpdateDataXml("update");
  205. var dData = grid.getUpdateDataXml("delete");
  206. if (iData=="" && uData=="" && dData=="") return false;
  207. else return true;
  208. }
  209. /**
  210. * @group :
  211. * @ver : 2006.12.20
  212. * @by :
  213. * @---------------------------------------------------
  214. * @type : function
  215. * @access : public
  216. * @desc :
  217. * @return : bool
  218. * @---------------------------------------------------
  219. */
  220. function checkGridField(grid, field){
  221. var nodeset = grid.nodeset;
  222. var iStatus;
  223. //var iData = grid.getUpdateDataXml("insert");
  224. for (i=grid.fixedRows; i<grid.rows; i++){
  225. iStatus = grid.rowstatus(i);
  226. if (iStatus == 1 || iStatus == 2 || iStatus == 3){
  227. var fieldArr = field.split("▦");
  228. if(fieldArr.length < 1){
  229. return false;
  230. }
  231. for(var j = 0; j < fieldArr.length; j++){
  232. if(fieldArr[j] == null || fieldArr[j] == "" || fieldArr[j] == "undefined"){
  233. continue;
  234. }
  235. if(model.getValue(nodeset+"["+i+"]/"+fieldArr[j])=="") return false;
  236. }
  237. }
  238. }
  239. return true;
  240. }
  241. /* @group :
  242. * @ver : 2008-06-02 오후 5:01:10
  243. * @by : taebum
  244. * @-----------------------------------
  245. * @type : function
  246. * @access : public
  247. * @desc : 조회 및 검색
  248. */
  249. function fbtnSearch() {
  250. model.removeNodeSet("/root/main/list/codelists/codelist");
  251. model.removeNodeSet("/root/main/list/codelists/lrglist");
  252. grd_codelist.refresh();
  253. datagrid1.refresh();
  254. //model.refresh();
  255. submit("TRMNP00720");
  256. //changeNodeSet();
  257. }
  258. /* @group :
  259. * @ver : 2008-06-02 오후 5:19:26
  260. * @by : taebum
  261. * @-----------------------------------
  262. * @type : function
  263. * @access : public
  264. * @desc : Excel 버튼 클릭시 이벤트
  265. */
  266. function fOnClickExcelBtn(){
  267. var fileName = window.fileDialog("save", ",", false, "excel", "xls", "All Files (*.*)|*.*|Excel Files(*.xls)|*.xls");
  268. if (fileName != ""){
  269. grd_codelist.saveExcel(fileName);
  270. }
  271. }
  272. /* @group :
  273. * @ver : 2008-12-11 오후 4:04:55
  274. * @by : taebum
  275. * @-----------------------------------
  276. * @type : function
  277. * @access : public
  278. * @desc : 분류 클릭시 아이템 리스트조회
  279. */
  280. function fClickLrgGrid(){
  281. var cur_LrgRow = datagrid1.row;
  282. if(cur_LrgRow > 0){
  283. model.removeNodeSet("/root/main/list/codelists/codelist");
  284. grd_codelist.refresh();
  285. model.removeNodeSet("/root/hidden/itemlists/codelist");
  286. model.setValue("/root/send/s_lrgcd", model.getValue("/root/main/list/codelists/lrglist["+cur_LrgRow+"]/lrgcd"));
  287. combo1.refresh();
  288. submit("TRMNP00722");
  289. var iItemcnt = getNodesetCnt(model, "/root/hidden/itemlists/codelist");
  290. if(iItemcnt > 0){
  291. for(var i = 1; i <= iItemcnt; i++){
  292. model.duplicate("/root/main/list/codelists", "/root/hidden/itemlists/codelist["+i+"]");
  293. }
  294. grd_codelist.refresh();
  295. model.removeNodeSet("/root/hidden/itemlists/codelist");
  296. }
  297. }
  298. }
  299. /* ------------------------------------------------- */
  300. /* ------End Of List ------------------------------- */
  301. /* -------------------------------------------------- */