doctorworksch.js 14 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408
  1. "use strict";
  2. /**
  3. * mplus_medical_OnDutyWeekSch
  4. */
  5. var mplus_schedule_doctorworksch = function(){
  6. // 상속
  7. mplus_common.call(this);
  8. // 상위 객체 생성
  9. //var mplusPatient = new mplus_mobile_patient();
  10. //var mplusNursing = new mplus_nursing();
  11. //super
  12. var self = this;
  13. //선택일자 일요일 전역변수
  14. var varSelDate;
  15. var varResultLists = [];
  16. //==== 변수 } ====
  17. /**
  18. * 초기화
  19. */
  20. this.init = function(){ //여기서 모든화면 콤보박스데이터를 집어넣자!!! 그래야지 화면이동할때 속도가 오래걸리지않음!!!
  21. // 접근 권한 체크
  22. checkAccessPermission();
  23. // 초기 화면 조건 구성
  24. initCondition();
  25. // 이벤트 초기화
  26. addEvent();
  27. };
  28. //==== 접근 권한 체크 { ====
  29. var checkAccessPermission = function(){
  30. //if( !self.common.checkAccessJobKind( "1000")){
  31. // self.alertTrue("접근 권한이 없습니다.", self.common.gotoDefaultHomePage);
  32. //}
  33. //if( !self.common.checkAccessUserAuth( "01")){
  34. // self.alertTrue("접근 권한이 없습니다.", self.common.gotoDefaultHomePage);
  35. //}
  36. //self.common.disableElements( $("#myModalBtn"));
  37. };
  38. //==== 접근 권한 체크 } ====
  39. //==== 초기화 설정 { ====
  40. var initCondition = function(){
  41. // 초기 화면 조건 구성
  42. // 순서 조심! startdt enddt 설정 후 서버에서 부서리스트를 설정 후 스케줄데이터를 호출해야함
  43. //0.데이터 초기화
  44. $("#txtDoctorInfoDoctorNm").text("");
  45. $("#txtDoctorInfoSpeciality").text("");
  46. $("#txtDoctorInfoDoctorTel").text("");
  47. $("#sltOnDutyWeekSchDept").empty();
  48. $("#divOnDutyWeekSchResultRows").empty();
  49. //1.기간설정_test
  50. initStartEndDate();
  51. //2.주 일자 처리
  52. initWeekDate();
  53. //3.선택 부서 처리
  54. initSelDept();
  55. };
  56. var initStartEndDate = function(){
  57. varSelDate = new Date();
  58. //일요일이면 차주 가져오기
  59. //다른 요일이면 해당 요일 처리
  60. varSelDate.setDate(varSelDate.getDate() - varSelDate.getDay());
  61. $("#txtOnDutyWeekSchStartYear").text( moment(varSelDate).format("YYYY") );
  62. $("#txtOnDutyWeekSchStartMonth").text( moment(varSelDate).format("MM") );
  63. $("#txtOnDutyWeekSchStartDay").text( moment(varSelDate).format("DD") );
  64. varSelDate.setDate(varSelDate.getDate() + 6);
  65. $("#txtOnDutyWeekSchEndYear").text( moment(varSelDate).format("YYYY") );
  66. $("#txtOnDutyWeekSchEndMonth").text( moment(varSelDate).format("MM") );
  67. $("#txtOnDutyWeekSchEndDay").text( moment(varSelDate).format("DD") );
  68. varSelDate.setDate(varSelDate.getDate() - 6);
  69. //console.log("처리일자 : " + moment(varSelDate).format("YYYY-MM-DD"));
  70. };
  71. var initSelDept = function(){
  72. //search deptlist
  73. var param = {
  74. userId: gLoginUserId,
  75. jobCls: localStorage.selectedJobKindCd
  76. };
  77. self.schedule.getShcDeptList(param, processSearchShcDeptList);
  78. };
  79. var processSearchShcDeptList = function(lists){
  80. $("#sltOnDutyWeekSchDept").empty();
  81. var strDisplayTemp = "";
  82. strDisplayTemp = "<option value=\"\">부서</option>";
  83. if(lists !== undefined){
  84. for(var i=0; i<lists.length; i++){
  85. strDisplayTemp += "<option value=\""+ lists[i].deptCd +"\">"+ lists[i].deptNm +"</option>";
  86. }
  87. }
  88. $("#sltOnDutyWeekSchDept").append(strDisplayTemp);
  89. $("#sltOnDutyWeekSchDept").val(localStorage.selectedDeptCd);
  90. if($("#sltOnDutyWeekSchDept").val()==null){
  91. $("#sltOnDutyWeekSchDept").val($("#sltOnDutyWeekSchDept option:first").val());
  92. };
  93. //기본 정보 셋팅 후 호출
  94. searchWorkSch();
  95. };
  96. //==== 초기화 설정 } ====
  97. //==== 이벤트 설정 { ====
  98. var addEvent = function(){
  99. eventRowClick();
  100. eventConditionClick();
  101. };
  102. var eventConditionClick = function(){
  103. //부서변경 이벤트
  104. $("#sltOnDutyWeekSchDept").unbind();
  105. $("#sltOnDutyWeekSchDept").change(function(){
  106. searchWorkSch();
  107. });
  108. // 이전 주 버튼클릭
  109. $("#btnOnDutyWeekSchBeforeWeek").off("click"); // 기존 이벤트 해제
  110. $("#btnOnDutyWeekSchBeforeWeek").on("click", function(e){
  111. varSelDate.setDate(varSelDate.getDate() - 7);
  112. $("#txtOnDutyWeekSchStartYear").text( moment(varSelDate).format("YYYY") );
  113. $("#txtOnDutyWeekSchStartMonth").text( moment(varSelDate).format("MM") );
  114. $("#txtOnDutyWeekSchStartDay").text( moment(varSelDate).format("DD") );
  115. varSelDate.setDate(varSelDate.getDate() + 6);
  116. $("#txtOnDutyWeekSchEndYear").text( moment(varSelDate).format("YYYY") );
  117. $("#txtOnDutyWeekSchEndMonth").text( moment(varSelDate).format("MM") );
  118. $("#txtOnDutyWeekSchEndDay").text( moment(varSelDate).format("DD") );
  119. varSelDate.setDate(varSelDate.getDate() - 6);
  120. initWeekDate();
  121. searchWorkSch();
  122. });
  123. // 다음 주 버튼클릭
  124. $("#btnOnDutyWeekSchNextWeek").off("click"); // 기존 이벤트 해제
  125. $("#btnOnDutyWeekSchNextWeek").on("click", function(e){
  126. varSelDate.setDate(varSelDate.getDate() + 7);
  127. $("#txtOnDutyWeekSchStartYear").text( moment(varSelDate).format("YYYY") );
  128. $("#txtOnDutyWeekSchStartMonth").text( moment(varSelDate).format("MM") );
  129. $("#txtOnDutyWeekSchStartDay").text( moment(varSelDate).format("DD") );
  130. varSelDate.setDate(varSelDate.getDate() + 6);
  131. $("#txtOnDutyWeekSchEndYear").text( moment(varSelDate).format("YYYY") );
  132. $("#txtOnDutyWeekSchEndMonth").text( moment(varSelDate).format("MM") );
  133. $("#txtOnDutyWeekSchEndDay").text( moment(varSelDate).format("DD") );
  134. varSelDate.setDate(varSelDate.getDate() - 6);
  135. initWeekDate();
  136. searchWorkSch();
  137. });
  138. //전화걸기
  139. $("#btnDoctorInfoDoctorTelCall").unbind();
  140. $("#btnDoctorInfoDoctorTelCall").on("click", function(e){
  141. if($("#txtDoctorInfoDoctorTel").text()==""){
  142. self.alert("해당 의사의 전화번호가 존재하지 않습니다.");
  143. return;
  144. };
  145. location.href = "tel:"+$("#txtDoctorInfoDoctorTel").text();
  146. });
  147. //조회 클릭
  148. $("#btnOnDutyWeekSchSearch").unbind();
  149. $("#btnOnDutyWeekSchSearch").on("click", function(e){
  150. searchWorkSch();
  151. });
  152. $(window).unbind();
  153. $(window).resize(function() {
  154. console.log("resize call!");
  155. //p 사이즈 처리
  156. //화면의 고정되는 input으로 처리 .col-xs-2로 처리하면 변함
  157. var pHeightSize = ($("#inputOnDutyWeekSchSearchTxt").height() * 0.6);
  158. var pWidthSize = ($("#inputOnDutyWeekSchSearchTxt").width() * 0.25);
  159. console.log("pWidthSize : " + pWidthSize);
  160. $(".schptag").width(pWidthSize);
  161. $(".schptag").height(pHeightSize);
  162. $(".schkeytag").width(pWidthSize);
  163. });
  164. };
  165. var initWeekDate = function(){
  166. var tempSelDate = new Date(varSelDate);
  167. $("#txtSchSunDate").text(moment(tempSelDate).format("DD"));
  168. tempSelDate.setDate(tempSelDate.getDate() + 1);
  169. $("#txtSchMonDate").text(moment(tempSelDate).format("DD"));
  170. tempSelDate.setDate(tempSelDate.getDate() + 1);
  171. $("#txtSchTueDate").text(moment(tempSelDate).format("DD"));
  172. tempSelDate.setDate(tempSelDate.getDate() + 1);
  173. $("#txtSchWedDate").text(moment(tempSelDate).format("DD"));
  174. tempSelDate.setDate(tempSelDate.getDate() + 1);
  175. $("#txtSchThuDate").text(moment(tempSelDate).format("DD"));
  176. tempSelDate.setDate(tempSelDate.getDate() + 1);
  177. $("#txtSchFriDate").text(moment(tempSelDate).format("DD"));
  178. tempSelDate.setDate(tempSelDate.getDate() + 1);
  179. $("#txtSchSatDate").text(moment(tempSelDate).format("DD"));
  180. };
  181. var eventRowClick = function(){
  182. // 스케줄 선택 이벤트 처리
  183. $(".schptag").off("click"); // 기존 이벤트 해제
  184. $(".schptag").on("click", function(e){
  185. var doctorId = e.currentTarget.attributes.doctorId.value;
  186. var doctorNm = e.currentTarget.attributes.doctorNm.value;
  187. //console.log("click : " + doctorId);
  188. var param = {
  189. doctorId : doctorId,
  190. doctorNm : doctorNm,
  191. searchMonth : moment(varSelDate).format("YYYYMM")
  192. };
  193. mplusModalDoctorworkschdetail.init(param);
  194. $("#modalDoctorWorkSchDetail").modal("show");
  195. return;
  196. var param = {
  197. userId:gLoginUserId,
  198. doctorId: doctorId
  199. };
  200. self.schedule.getDoctorInfo(param, processSearchDoctorInfo);
  201. // 환자 정보 화면 띄우기
  202. //$("#modalDoctorInfo").modal("show");
  203. //mplusModalDoctorinfo.init(param);
  204. });
  205. };
  206. var processSearchDoctorInfo = function(lists){
  207. //console.log("lists : " + lists.length);
  208. if(lists !== undefined && lists != null && lists.length != 0){
  209. /*
  210. var varDoctorInfo = "주치의 : " + lists[0].doctorNm +"<br/>"
  211. + "전문분야 : "+ lists[0].speciality+"<br/>"
  212. + "전화번호 : "+ lists[0].doctorTel;
  213. $("#mplusAlertDoctorInfoBody").append(varDoctorInfo);
  214. */
  215. $("#txtDoctorInfoDoctorNm").text(lists[0].doctorNm);
  216. $("#txtDoctorInfoSpeciality").text(lists[0].speciality);
  217. if(lists[0].doctorTel != ""){
  218. $("#txtDoctorInfoDoctorTel").text(lists[0].doctorTel);
  219. $("#btnDoctorInfoDoctorTelCall").css('display', 'inline-block');
  220. }else{
  221. $("#btnDoctorInfoDoctorTelCall").css('display', 'none');
  222. }
  223. //$("#mplusAlertDoctorInfo").modal("show");
  224. }else{
  225. self.alert("해당 의사의 정보가 없습니다.");
  226. }
  227. };
  228. //==== 이벤트 설정 } ====
  229. //==== 스케줄 정보 조회 처리 { ====
  230. // 스케줄 정보 조회
  231. var searchWorkSch = function(){
  232. var tempSelDate = new Date(varSelDate);
  233. tempSelDate.setDate(tempSelDate.getDate() + 6);
  234. //console.log("searchWorkSch varSelDate : " + moment(varSelDate).format("YYYY-MM-DD") + " / tempSelDate : " + moment(tempSelDate).format("YYYY-MM-DD"));
  235. var param = {
  236. userId: gLoginUserId,
  237. startDt: moment(varSelDate).format("YYYYMMDD"),
  238. endDt: moment(tempSelDate).format("YYYYMMDD"),
  239. jobCls:"D",//의사
  240. workingTy:"%",//진료구분
  241. selectedDeptCd: $("#sltOnDutyWeekSchDept").val(),
  242. searchTxt:$("#inputOnDutyWeekSchSearchTxt").val()
  243. };
  244. self.schedule.getOnDutyWeekSch(param, processSearchWorkSch);
  245. };
  246. // 스케줄 정보 조회 결과 처리
  247. var processSearchWorkSch = function(lists){
  248. // 1. 스케줄 조회 결과 리스트를 varResultLists로 복사
  249. varResultLists = lists;
  250. // 2. 스케줄 검색 결과 리스트를 재정리 : 아이디순서별
  251. //self.common.JSONGroupBy(varResultLists, "dutyTxt");
  252. // 3. 스케줄 검색 결과를 화면에 disaplay
  253. drawWorkSchList();
  254. };
  255. // 환자 정보 화면에 그리기
  256. var drawWorkSchList = function(){
  257. //1.dutyTxt로 정렬 된 list 출력
  258. //2.CSS로 인한 p size 처리
  259. //3.key로 리스트 출력
  260. //4.row 정리
  261. var lists = self.common.JSONGroupBy(varResultLists, "dutyTxt");
  262. //console.log(JSON.stringify(lists));
  263. var strDisplayTemp = "";
  264. $("#divOnDutyWeekSchResultRows").empty();
  265. //일 월 화 수 목 금 토 일 변수
  266. var scheduleList = ["","","","","","",""];
  267. //CSS Style List
  268. var scheduleClassList = ["D-type","N-type","ICU"];
  269. //CSS 변수
  270. var varCSSTemp = 0;
  271. //p 사이즈 처리
  272. var pHeightSize = ($("#inputOnDutyWeekSchSearchTxt").height() * 0.6);
  273. var pWidthSize = ($("#inputOnDutyWeekSchSearchTxt").width() * 0.25);
  274. console.log("pWidthSize : " + pWidthSize);
  275. for(var key in lists){
  276. //초기화
  277. scheduleList = ["","","","","","",""];
  278. var tempLists = lists[key];
  279. //console.log(JSON.stringify(tempLists[0].dayCd)); }
  280. for(var inputCnt = 0 ; inputCnt < tempLists.length ; inputCnt++){
  281. //console.log("cnt inputCnt : " + inputCnt + " lists[inputCnt].dayCd : " + lists[inputCnt].dayCd + " lists[inputCnt].workingInfo : " + lists[inputCnt].workingInfo + " userid : " + lists[inputCnt].doctorId);
  282. var TempPTage = "";
  283. if(tempLists[inputCnt].userId == gLoginUserId){
  284. TempPTage = "<p class=\"schptag \" style=\"background:#99abb5; display:inline-block; padding-top:8px;\" doctorNm=\"" + tempLists[inputCnt].userNm + "\" doctorId=\"" + tempLists[inputCnt].userId + "\">"+tempLists[inputCnt].userNm+"</p>";
  285. }else{
  286. TempPTage = "<p class=\"schptag \" style=\"display:inline-block; padding-top:8px;\" doctorNm=\"" + tempLists[inputCnt].userNm + "\" doctorId=\"" + tempLists[inputCnt].userId + "\">"+tempLists[inputCnt].userNm+"</p>";
  287. }
  288. if(tempLists[inputCnt].dayCd == "SUN"){
  289. scheduleList[0] += TempPTage;
  290. } else if (tempLists[inputCnt].dayCd == "MON"){
  291. scheduleList[1] += TempPTage;
  292. } else if (tempLists[inputCnt].dayCd == "TUE"){
  293. scheduleList[2] += TempPTage;
  294. } else if (tempLists[inputCnt].dayCd == "WED"){
  295. scheduleList[3] += TempPTage;
  296. } else if (tempLists[inputCnt].dayCd == "THU"){
  297. scheduleList[4] += TempPTage;
  298. } else if (tempLists[inputCnt].dayCd == "FRI"){
  299. scheduleList[5] += TempPTage;
  300. } else if (tempLists[inputCnt].dayCd == "SAT"){
  301. scheduleList[6] += TempPTage;
  302. }
  303. }
  304. var TempKey = key.replace(/\//g , "/<br/>");
  305. //console.log("TempKey : " + TempKey);
  306. strDisplayTemp += "<div class=\"duty-person\">"
  307. + "<div class=\"row\">"
  308. + " <div class=\"col-sm-2 col-xs-2 \" style=\"margin-top: 8px;\"><sapn class=\" span" + scheduleClassList[(varCSSTemp % 3)] + " \" style=\"display: inline-block; width:35px; word-wrap: break-word; line-height: normal;\">" + TempKey + "</span></div>"
  309. + " <div class=\"col-sm-2 col-xs-2 "+scheduleClassList[(varCSSTemp % 3)]+"\">"
  310. + scheduleList[0]
  311. + " </div>"
  312. + " <div class=\"col-sm-2 col-xs-2 "+scheduleClassList[(varCSSTemp % 3)]+"\">"
  313. + scheduleList[1]
  314. + " </div>"
  315. + " <div class=\"col-sm-2 col-xs-2 "+scheduleClassList[(varCSSTemp % 3)]+"\">"
  316. + scheduleList[2]
  317. + " </div>"
  318. + " <div class=\"col-sm-2 col-xs-2 "+scheduleClassList[(varCSSTemp % 3)]+"\">"
  319. + scheduleList[3]
  320. + " </div>"
  321. + " <div class=\"col-sm-2 col-xs-2 "+scheduleClassList[(varCSSTemp % 3)]+"\">"
  322. + scheduleList[4]
  323. + " </div>"
  324. + " <div class=\"col-sm-2 col-xs-2 "+scheduleClassList[(varCSSTemp % 3)]+"\">"
  325. + scheduleList[5]
  326. + " </div>"
  327. + " <div class=\"col-sm-2 col-xs-2 "+scheduleClassList[(varCSSTemp % 3)]+"\">"
  328. + scheduleList[6]
  329. + " </div>"
  330. + " </div>"
  331. + "</div>"
  332. ;
  333. varCSSTemp++;
  334. }
  335. $("#divOnDutyWeekSchResultRows").append(strDisplayTemp); // element 추가
  336. $(".schptag").width(pWidthSize);
  337. $(".schptag").height(pHeightSize);
  338. $(".schkeytag").width(pWidthSize);
  339. eventRowClick();
  340. };
  341. //==== 환자 정보 조회 처리 } ====
  342. };