SMMNP00320.js 10 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295
  1. /* ---------------------------------------------------------------------
  2. Count List 관리 (SMMNP00320_CountList관리.xrw - JScript )
  3. - Version :
  4. 1) : Ver.1.00.01
  5. : Create By taebum
  6. : 2008-11-21 오전 10:05:51
  7. ---------------------------------------------------------------------- */
  8. /* --------------------------------------------------*/
  9. /* type : function */
  10. /* access : public */
  11. /* desc : xforms-ready시 수행한다 */
  12. /* return : */
  13. /* --------------------------------------------------*/
  14. function fInit() {
  15. model.removeNodeSet("/root/main/countlists/countlist");
  16. datagrid1.refresh();
  17. //대분류 코드 로딩
  18. fGetCdList("Lrg");
  19. addComboItem( "combo1", "전체", "%", "above" );
  20. model.setValue("/root/hidden/condition/lrgclscd","%");
  21. combo1.refresh();
  22. addComboItem( "combo2", "전체", "%", "above" );
  23. model.setValue("/root/hidden/condition/kindcd","%");
  24. combo2.refresh();
  25. }
  26. /**
  27. * 분류코드 조회
  28. */
  29. function fGetCdList(pFlag){
  30. var sSubmitNm = "";
  31. switch(pFlag){
  32. case "Lrg" :
  33. model.removeNodeSet("/root/init/combolists/lrgcombolists/lrgcombo");
  34. sSubmitNm = "TRMNP00320";
  35. break;
  36. case "Kind" :
  37. var sLrgclscd = model.getValue("/root/hidden/condition/lrgclscd");
  38. var sLrgArr = sLrgclscd.split(",");
  39. if(combo1.selectedIndex == 1 || sLrgclscd == "%" ) {
  40. //instrument 또는 전체
  41. model.removeNodeSet("/root/init/combolists/kindcombolists/kindcombo");
  42. addComboItem( "combo2", "전체", "%", "above" );
  43. model.setValue("/root/hidden/condition/kindcd","%");
  44. combo2.refresh();
  45. return;
  46. }
  47. model.removeNodeSet("/root/init/combolists/kindcombolists/kindcombo");
  48. model.setValue("/root/send/lrgclscd", sLrgArr[0]);
  49. model.setValue("/root/send/codenm1", model.getValue("/root/init/combolists/lrgcombolists/lrgcombo["+(combo1.selectedIndex+1)+"]/nm"));
  50. sSubmitNm = "TRMNP00321";
  51. break;
  52. default :
  53. break;
  54. }
  55. if(sSubmitNm != ""){
  56. model.setValue("/root/send/temp","temp");
  57. submit(sSubmitNm);
  58. }
  59. }
  60. /**
  61. * Combo값 변경시 이벤트
  62. */
  63. function fValueChangedCombo(pFlag){
  64. switch(pFlag){
  65. case "Lrg" :
  66. if(model.getValue("/root/hidden/condition/lrgclscd") != "%"){
  67. //종류코드 리스트 조회
  68. fGetCdList("Kind");
  69. addComboItem( "combo2", "전체", "%", "above" );
  70. model.setValue("/root/hidden/condition/kindcd","%");
  71. combo2.refresh();
  72. }else{
  73. model.removeNodeSet("/root/init/combolists/kindcombolists/kindcombo");
  74. addComboItem( "combo2", "전체", "%", "above" );
  75. model.setValue("/root/hidden/condition/kindcd","%");
  76. combo2.refresh();
  77. fSelectCodeList();
  78. }
  79. break;
  80. case "Kind" :
  81. fSelectCodeList();
  82. break;
  83. default :
  84. break;
  85. }
  86. }
  87. /**
  88. * Count List 등록 내역 조회
  89. *
  90. */
  91. function fSelectCodeList(){
  92. model.setValue("/root/send/lrgclscd", model.getValue("/root/hidden/condition/lrgclscd"));
  93. model.setValue("/root/send/kindcd" , model.getValue("/root/hidden/condition/kindcd"));
  94. model.setValue("/root/send/codenm1" , model.getValue("/root/init/combolists/lrgcombolists/lrgcombo["+(combo1.selectedIndex+1)+"]/nm"));
  95. model.setValue("/root/send/codenm2" , model.getValue("/root/init/combolists/kindcombolists/kindcombo["+(combo2.selectedIndex+1)+"]/nm"));
  96. model.setValue("/root/send/frcd" , model.getValue("/root/hidden/condition/kindcd"));
  97. model.setValue("/root/send/tocd" , model.getValue("/root/init/combolists/kindcombolists/kindcombo["+(combo2.selectedIndex+1)+"]/cd2"));
  98. submit("TRMNP00322");
  99. }
  100. /**
  101. * 그리드 행추가 버튼을 클릭하였을 경우 이벤트
  102. *
  103. */
  104. function fClickRowAddBtn(){
  105. var lrgclscd = model.getValue("/root/hidden/condition/lrgclscd");
  106. var kindcd = model.getValue("/root/hidden/condition/kindcd");
  107. if( lrgclscd == ""||lrgclscd == "%" ) {
  108. //-----------(20100811 경북대)
  109. //기존소스
  110. // messageBox("대분류를 선택하셔야 합니다.!", "E000");
  111. // model.setFocus("combo1");
  112. // return;
  113. messageBox("대분류를 선택되지 않았습니다. 대분류정보를 입력하십시오.!", "E000");
  114. //-----------(20100811 경북대)
  115. }
  116. if( kindcd == ""||kindcd == "%" ) {
  117. //-----------(20100811 경북대)
  118. //기존소스
  119. // messageBox("중분류를 선택하셔야 합니다.!", "E000");
  120. // model.setFocus("combo2");
  121. // return;
  122. messageBox("중분류를 선택되지 않았습니다. 중분류정보를 입력하십시오.!", "E000");
  123. //-----------(20100811 경북대)
  124. }
  125. var orglrgclscd = model.getValue("/root/main/countlists/countlist[" + (datagrid1.rows-1) + "]/org_lrgclscd");
  126. if( orglrgclscd != "" ) {
  127. model.setValue("/root/send/lrgclscd", model.getValue("/root/hidden/condition/lrgclscd").substring(0,2));
  128. submit("TRMNP00325", false);
  129. datagrid1.addRow(); // 입력할 행 추가.
  130. //---(20100811 경북대)
  131. if (lrgclscd == ""||lrgclscd == "%") lrgclscd = '01';
  132. //---(20100811 경북대)
  133. model.setValue("/root/main/countlists/countlist[" + (datagrid1.rows-1) + "]/lrgclscd", lrgclscd.substring(0,2));
  134. model.setValue("/root/main/countlists/countlist[" + (datagrid1.rows-1) + "]/codenm1", combo1.label);
  135. if( !(kindcd == ""||kindcd == "%") ){
  136. model.setValue("/root/main/countlists/countlist[" + (datagrid1.rows-1) + "]/codenm2", combo2.label);
  137. model.setValue("/root/main/countlists/countlist[" + (datagrid1.rows-1) + "]/kindcd", model.getValue("/root/temp/kindcdinfo/maxkindcd"));
  138. }
  139. }else {
  140. datagrid1.addRow(); // 입력할 행 추가.
  141. //---(20100811 경북대)
  142. // model.setValue("/root/main/countlists/countlist[" + (datagrid1.rows-1) + "]/lrgclscd", lrgclscd.substring(0,2));
  143. if (lrgclscd == ""||lrgclscd == "%") lrgclscd = '01';
  144. model.setValue("/root/main/countlists/countlist[" + (datagrid1.rows-1) + "]/lrgclscd", lrgclscd.substring(0,2));
  145. //---(20100811 경북대)
  146. model.setValue("/root/main/countlists/countlist[" + (datagrid1.rows-1) + "]/codenm1", combo1.label);
  147. if( !(kindcd == ""||kindcd == "%") ){
  148. var tmpkindcd = eval(model.getValue("/root/main/countlists/countlist[" + (datagrid1.rows-2) + "]/kindcd"))+1;
  149. if( tmpkindcd < 10 ) {//10보다 작으면 0을 붙여준다.
  150. tmpkindcd = "0" + tmpkindcd;
  151. }
  152. model.setValue("/root/main/countlists/countlist[" + (datagrid1.rows-1) + "]/codenm2", combo2.label);
  153. model.setValue("/root/main/countlists/countlist[" + (datagrid1.rows-1) + "]/kindcd", tmpkindcd);
  154. }
  155. }
  156. model.refresh();
  157. //datagrid1.row = cur_row;
  158. //datagrid1.select(cur_row, 4) = true;
  159. //datagrid1.editcell();
  160. }
  161. /**
  162. * 삭제 버튼을 클릭하였을 경우 이벤트
  163. *
  164. */
  165. function fClickDeleteBtn(){
  166. var cur_row = datagrid1.row; // 행 번호 가져오기
  167. var iStatus = datagrid1.rowstatus(cur_row);
  168. if(cur_row <= 0 || cur_row =="undefined") {
  169. alert("삭제할 행을 선택하시기 바랍니다...");
  170. return;
  171. }
  172. var org_sCodenm1 = model.getValue("/root/main/countlists/countlist["+cur_row+"]/org_codenm1");
  173. var org_sCodenm2 = model.getValue("/root/main/countlists/countlist["+cur_row+"]/org_codenm2");
  174. var org_sCodenm3 = model.getValue("/root/main/countlists/countlist["+cur_row+"]/org_codenm3");
  175. if(org_sCodenm1 == "INSTRUMENT" && org_sCodenm2 == "INSTRUMENT"
  176. && org_sCodenm3 == "INSTRUMENT"){
  177. messageBox("INSTRUMENT는 기본항목으로 삭제할 수 없습니다.", "I000");
  178. }
  179. if (iStatus == 1 || iStatus == 3){ // 새로 삽입된 행이면
  180. datagrid1.deleteitem(cur_row);
  181. }else if (iStatus == 4){ // 삭제로 표시된 행이면
  182. datagrid1.removestatus(cur_row, "delete");
  183. }else{
  184. datagrid1.addStatus(cur_row, "delete");
  185. }
  186. }
  187. /*
  188. * 저장 버튼을 클릭하였을 경우 이벤트
  189. *
  190. */
  191. function fOnClickSaveBtn(){
  192. if(!checkGridUpdate(datagrid1)){
  193. alert("저장할 자료가 존재하지 않습니다.");
  194. return;
  195. }
  196. var kindcd = model.getValue("/root/hidden/condition/kindcd");
  197. var indexnum = combo2.selectedIndex;
  198. if(checkGridField(datagrid1,"codenm1▦kindcd▦codenm2▦codenm3▦refseq")==false){
  199. alert("데이터중에 비어있는 필수필드가 있습니다.");
  200. return;
  201. }
  202. model.setValue("/root/send/listdata",datagrid1.getUpdateData());
  203. if ( submit("TXMNP00320") ) {
  204. //datagrid1.clearStatus(); // submit() 성공하면 그리드의 i,u,d 상태 제거
  205. fValueChangedCombo("Lrg");
  206. model.setValue("/root/hidden/condition/kindcd",kindcd);
  207. combo2.select(indexnum);
  208. fSelectCodeList();
  209. }
  210. }
  211. /**
  212. * @group :
  213. * @ver : 2006.12.20
  214. * @by :
  215. * @---------------------------------------------------
  216. * @type : function
  217. * @access : public
  218. * @desc :
  219. * @return : bool
  220. * @---------------------------------------------------
  221. */
  222. function checkGridUpdate(grid)
  223. {
  224. var iData = grid.getUpdateDataXml("insert");
  225. var uData = grid.getUpdateDataXml("update");
  226. var dData = grid.getUpdateDataXml("delete");
  227. if (iData=="" && uData=="" && dData=="") return false;
  228. else return true;
  229. }
  230. /**
  231. * @group :
  232. * @ver : 2006.12.20
  233. * @by :
  234. * @---------------------------------------------------
  235. * @type : function
  236. * @access : public
  237. * @desc :
  238. * @return : bool
  239. * @---------------------------------------------------
  240. */
  241. function checkGridField(grid, field){
  242. var nodeset = grid.nodeset;
  243. var iStatus;
  244. //var iData = grid.getUpdateDataXml("insert");
  245. for (i=grid.fixedRows; i<grid.rows; i++){
  246. iStatus = grid.rowstatus(i);
  247. if (iStatus == 1 || iStatus == 3){
  248. var fieldArr = field.split("▦");
  249. if(fieldArr.length < 1){
  250. return false;
  251. }
  252. for(var j = 0; j < fieldArr.length; j++){
  253. if(fieldArr[j] == null || fieldArr[j] == "" || fieldArr[j] == "undefined"){
  254. continue;
  255. }
  256. if(model.getValue(nodeset+"["+i+"]/"+fieldArr[j])=="") return false;
  257. }
  258. }
  259. }
  260. return true;
  261. }