doctorworkschdetail.js 5.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170
  1. "use strict";
  2. /**
  3. * mplus_modal_doctorworkschdetail
  4. */
  5. var mplus_modal_doctorworkschdetail = function(){
  6. // 상속
  7. mplus_common.call(this);
  8. //선택일자 일요일 전역변수
  9. var varSelDate;
  10. var gParam;
  11. // 상위 객체 생성
  12. //var mplusPatient = new mplus_mobile_patient();
  13. //var mplusNursing = new mplus_nursing();
  14. //super
  15. var self = this;
  16. //==== 변수 { ====
  17. //==== 변수 } ====
  18. /**
  19. * 초기화
  20. */
  21. this.init = function(initParam){ //여기서 모든화면 콤보박스데이터를 집어넣자!!! 그래야지 화면이동할때 속도가 오래걸리지않음!!!
  22. if(initParam === undefined || initParam == null || initParam == ""){
  23. self.alert("데이터 오류입니다. 관리자에게 문의하세요.");
  24. return;
  25. }
  26. gParam = initParam;
  27. // 초기 화면 조건 구성
  28. initCondition();
  29. // 이벤트 초기화
  30. addEvent();
  31. //검색
  32. searchWorkSch();
  33. };
  34. //==== 초기화 설정 { ====
  35. var initCondition = function(){
  36. // 초기 화면 조건 구성
  37. $("#spanDoctorWorkSchDocId").text(gParam.doctorId);
  38. $("#spanDoctorWorkSchDocNm").text(gParam.doctorNm);
  39. initStartEndDate();
  40. };
  41. var initStartEndDate = function(){
  42. varSelDate = new Date();
  43. varSelDate.setYear(moment(gParam.searchMonth , "YYYY-MM").format("YYYY"));
  44. varSelDate.setMonth(moment(gParam.searchMonth , "YYYY-MM").format("MM")-1);//Date 자료형은 Month -1
  45. varSelDate.setDate(1); // 1일고정
  46. //console.log("varSelDate : " + moment(varSelDate).format("YYYY-MM-DD") + " / varSelDate.getFullYear() : "+ varSelDate.getFullYear());
  47. $("#txtDoctorWorkSchYear").text(moment(varSelDate).format("YYYY"));
  48. $("#txtDoctorWorkSchMonth").text(moment(varSelDate).format("MM"));
  49. };
  50. //==== 초기화 설정 } ====
  51. //==== 이벤트 설정 { ====
  52. var addEvent = function(){
  53. //$("#btnLogout").on("click", function(){
  54. // logout();
  55. //});
  56. eventConditionClick();
  57. eventColumnClick();
  58. eventRowClick();
  59. };
  60. var eventConditionClick = function(){
  61. // 전 달 버튼클릭
  62. $("#btnDoctorWorkSchMonthSchBefore").off("click"); // 기존 이벤트 해제
  63. $("#btnDoctorWorkSchMonthSchBefore").on("click", function(e){
  64. varSelDate.setMonth(varSelDate.getMonth() -1);
  65. $("#txtDoctorWorkSchYear").text(moment(varSelDate).format("YYYY"));
  66. $("#txtDoctorWorkSchMonth").text(moment(varSelDate).format("MM"));
  67. searchWorkSch();
  68. });
  69. // 다음 달 버튼클릭
  70. $("#btnDoctorWorkSchMonthSchNext").off("click"); // 기존 이벤트 해제
  71. $("#btnDoctorWorkSchMonthSchNext").on("click", function(e){
  72. varSelDate.setMonth(varSelDate.getMonth() +1);
  73. $("#txtDoctorWorkSchYear").text(moment(varSelDate).format("YYYY"));
  74. $("#txtDoctorWorkSchMonth").text(moment(varSelDate).format("MM"));
  75. searchWorkSch();
  76. });
  77. };
  78. var eventColumnClick = function(){
  79. };
  80. var eventRowClick = function(){
  81. };
  82. //==== 이벤트 설정 } ====
  83. var searchWorkSch = function(){
  84. var param = {
  85. userId:gParam.doctorId,
  86. dutyMonth:moment(varSelDate).format("YYYYMM"),
  87. jobCls:"D"
  88. };
  89. self.schedule.getOnDutyMonthSch(param, processSearchWorkSch);
  90. };
  91. // 스케줄 정보 조회 결과 처리
  92. var processSearchWorkSch = function(lists){
  93. // 1. 스케줄 조회 결과 리스트를 varResultLists로 복사
  94. //console.log("test : " + JSON.stringify(lists));
  95. // 3. 스케줄 검색 결과를 화면에 disaplay
  96. if(lists != null && lists !== undefined){
  97. drawWorkSchList(lists);
  98. }else{
  99. self.alert("데이터 오류입니다. 관리자에게 문의하세요.");
  100. }
  101. };
  102. // 환자 정보 화면에 그리기
  103. var drawWorkSchList = function(lists){
  104. //1.검색월 전월 일수, 다음월 일수 구하기
  105. //2.각 위치에 해당하는 Data처리
  106. //3.Data 및 달력 조합 출력
  107. var strDisplayTemp = "";
  108. $("#divDoctorWorkSchResultRows").empty();
  109. var tempSelDate = new Date(varSelDate);
  110. tempSelDate.setDate(tempSelDate.getDate() - tempSelDate.getDay());
  111. var lastDays = 32 - new Date(varSelDate.getFullYear(), varSelDate.getMonth(), 32).getDate(); //해당 검색달의 일수
  112. //전월 일요일까지 수 + 검색월 일수 + 다음달 토요일까지 일수
  113. var vSchFullCnt = lastDays + varSelDate.getDay() - (new Date(varSelDate.getFullYear() , varSelDate.getMonth(), lastDays)).getDay() + 6;
  114. //console.log("(new Date(varSelDate.getFullYear() , varSelDate.getMonth(), lastDays)).getDay() : " + vSchFullCnt);
  115. //일자 채우기
  116. for(var vSchCnt = 0 ; vSchCnt < vSchFullCnt ;){
  117. strDisplayTemp += "<div class=\"row\">";
  118. for(var fCnt=0;fCnt<7;fCnt++){
  119. strDisplayTemp += " <div id=\"divDoctorWorkSchDate" + moment(tempSelDate).format("MMDD") + "\" class=\"col-sm-2 col-xs-2 " +((tempSelDate.getMonth() != varSelDate.getMonth())? "disable":"" )+ "\" style=\"padding:0px;\"><p>"+ tempSelDate.getDate() +"</p></div>";
  120. tempSelDate.setDate(tempSelDate.getDate() + 1);
  121. vSchCnt++;
  122. }
  123. strDisplayTemp +=" </div>";
  124. }
  125. $("#divDoctorWorkSchResultRows").append(strDisplayTemp);
  126. //달력이 그려진 후 append
  127. for(var objLength=0 ; objLength < lists.length ; objLength++){
  128. if(lists[objLength].dutyTxt != null && lists[objLength].dutyTxt != ""){
  129. var varDoctorWorkSchDateTail = moment(lists[objLength].dutyDt , "YYYY-MM-DD").format("MMDD");
  130. var TempKey = (lists[objLength].dutyTxt).replace(/\//g , "/<br/>");
  131. var strPtage = "<p style=\"font-size: 12px;\">"+ TempKey +"</p>";
  132. $("#divDoctorWorkSchDate"+varDoctorWorkSchDateTail).append(strPtage);
  133. }
  134. }
  135. };
  136. //==== 서비스 실행 { ====
  137. //==== 서비스 실행 { ====
  138. };