rehabilitation_management.js 14 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423
  1. !function(){
  2. var httpData=GetRequest();
  3. var currentGMT=new Date();//当前时间GMT
  4. new Vue({
  5. el:"#app",
  6. data:{
  7. ynow: currentGMT.getFullYear(),//年份
  8. mnow: currentGMT.getMonth(),//月份(比实际少一个月---0开始至11)
  9. dnow: currentGMT.getDate(),//当前日
  10. currentDay:null,//带中文格式的当前年月
  11. currentDayForEn:null,//不带中文格式年月日2018/10/01如果写成/的话 转换成时间戳会变成北京时间8点
  12. calendarData:[],//日历数据
  13. timeAxisData:[],//时间轴数据
  14. __Data:[],//当前的年月(日历)
  15. __xData:[],//当前的年月(时间轴)
  16. status:null,//任务状态(0未完成,1已完成,2已预约)
  17. searchTask:null,//快速查找任务:(1、我的任务,2、健康教育,3、健康指导,4、随访,5、复诊)
  18. searchTaskName:null,//快速查找任务:(1、我的任务,2、健康教育,3、健康指导,4、随访,5、复诊)
  19. planId: httpData['planId'],
  20. patientCode: httpData['patientCode'],
  21. taskArr:[
  22. {code:1,name:'我的任务'},
  23. {code:2,name:'健康教育'},
  24. {code:3,name:'健康指导'},
  25. {code:4,name:'随访'},
  26. {code:5,name:'复诊'},
  27. ],
  28. statusArr:[
  29. {code:0,name:'未完成'},
  30. {code:1,name:'已完成'},
  31. {code:2,name:'已预约'},
  32. ],
  33. curTask:'',//快速查找是否点击了搜索按钮
  34. curTaskName:'',//快速查找是否点击了搜索按钮
  35. tabStatus:null,
  36. planInfo:{},
  37. docList:[],
  38. diagnosisInformation: null
  39. },
  40. mounted:function(){
  41. if(!this.planId){
  42. layer.msg('未传入计划id(planId)',{icon:2})
  43. }else{
  44. this.tabStatus=1;
  45. }
  46. this.planSchedule();
  47. this.serviceDoctorList();//获取服务医生列表
  48. this.bindEvents();
  49. // 获取最新的诊疗信息1条
  50. this.findDiagnosisInformationByPatient()
  51. },
  52. methods:{
  53. //获取计划表
  54. planSchedule:function(){
  55. var vm = this;
  56. var params = {
  57. planId: this.planId,
  58. patientCode: this.patientCode
  59. };
  60. rehaAPI.planSchedule(params).then(function(res){
  61. if(res.status == 200){
  62. vm.planInfo = res.data;
  63. vm.planInfo.tagClass = "tag-"+res.data.healthyConditionType;
  64. //patientImg:居民签名照/证件照,如果不为null的话说明居民已确认,显示康复完成明细
  65. if(vm.planInfo.status==2 && !vm.planInfo.patientImg){//任务全部完成时,显示完成提示框
  66. vm.showCompleteDailog();
  67. }else if(vm.planInfo.status==2 && vm.planInfo.patientImg){//居民已确认计划完成
  68. vm.tabStatus=3;
  69. $("#framePage").attr("src","stop_special_service.html?planids="+vm.planId+"&planStatus="+vm.planInfo.status)
  70. }
  71. }else{
  72. layer.msg(res.msg,{icon:5});
  73. }
  74. })
  75. },
  76. // 获取最新的诊疗消息
  77. findDiagnosisInformationByPatient: function() {
  78. var vm = this,
  79. loading = layer.load(0, {shade: false}),params = {
  80. patient: vm.patientCode || "e040dd6814b648ceb3ba8d8a04f9f22c",
  81. page: 0,
  82. size: 1
  83. }
  84. recoverAPI.findDiagnosisInformationByPatient(params).then(function(res) {
  85. layer.close(loading)
  86. if(res.status == 200) {
  87. vm.diagnosisInformation = res.data.detailModelList[0]
  88. } else {
  89. showErrorMessage(res.msg);
  90. }
  91. })
  92. },
  93. serviceDoctorList:function(){
  94. var vm = this;
  95. rehaAPI.serviceDoctorList({patientCode: this.patientCode}).then(function(res){
  96. if(res.status == 200){
  97. vm.docList = res.data;
  98. }else{
  99. layer.msg(res.msg,{icon:5});
  100. }
  101. })
  102. },
  103. weiXinConfirmClick:function(){
  104. var vm = this;
  105. rehaAPI.sendWxMsg({planId: this.planId}).then(function(res){
  106. if(res.status == 200){
  107. layer.msg("发送成功,等待居民确认");
  108. setTimeout(function(){
  109. vm.tabStatus=3;
  110. $("#framePage").attr("src","stop_special_service.html?planids="+vm.planId+"&planStatus="+vm.planInfo.status)
  111. },1000)
  112. }else{
  113. layer.msg(res.msg,{icon:5});
  114. }
  115. })
  116. },
  117. setImgSrc: function (src) {
  118. var str = httpRequest.getImgUrl(src)
  119. return str
  120. },
  121. showCompleteDailog:function(){
  122. layer.confirm('<div class="mt10 tac"><image src="../images/yiwancheng_icon.png" width="100" height="100"/><div class="mt20 c-f20 c-333 mb40">本次康复计划已完成</div><div class="div-patient-comfirm c-f14 c-fff bgc-12b7f5" style="margin:40px auto 20px;">邀请居民确认</div></div>', {
  123. btn: [],
  124. area: ["400px", "340px"],
  125. title: "完成提示"
  126. }, function (index) {
  127. // layer.close(index);
  128. });
  129. },
  130. refreshPage:function(){
  131. if(!this.planId){
  132. layer.msg('未传入计划id(planId)',{icon:2})
  133. return ;
  134. }
  135. this.goToLoadData(true);
  136. },
  137. bindEvents:function(){
  138. var vm = this;
  139. $("body").on("click",".div-patient-comfirm",function(){
  140. layer.closeAll();
  141. vm.weiXinConfirmClick();
  142. }).on("click", ".div-patient-home", function() {
  143. location.href = "../../recover/html/personal-manage.html?patientCode=" + vm.patientCode
  144. })
  145. },
  146. viewDetail:function(planids,status,type){
  147. var vm=this;
  148. if(!planids){
  149. layer.msg('无服务项',{icon:5})
  150. return ;
  151. }
  152. if(status==1 && type==1){
  153. top.layer.open({
  154. type: 2,
  155. area: ['800px', '650px'],
  156. shade: 0.5,
  157. title: '完成项目确认',
  158. fixed: true, //不固定
  159. maxmin: true,
  160. closeBtn:1,
  161. shift: 5,
  162. shadeClose: false, //点击遮罩关闭层
  163. content: '../../rehabilitation/html/guide_the_message.html?planid='+planids
  164. });
  165. return ;
  166. }
  167. // planids='402803f6657f195301657f4c4ce70000';
  168. layer.open({
  169. type: 2,
  170. area: ['800px', '650px'],
  171. shade: 0.5,
  172. title: '服务项目内容',
  173. fixed: true, //不固定
  174. maxmin: true,
  175. closeBtn:1,
  176. shift: 5,
  177. shadeClose: false, //点击遮罩关闭层
  178. content: '../../rehabilitation/html/service_item_content.html?planids='+planids,
  179. end:function(){
  180. vm.goToLoadData(true);
  181. }
  182. });
  183. },
  184. changeStatus:function(val){
  185. this.status=this.status==val?null:val;
  186. },
  187. changeTask:function(val){
  188. this.searchTask=this.searchTask==val.code?null:val.code;
  189. this.searchTaskName=this.searchTaskName==val.name?null:val.name;
  190. },
  191. monDetail:function(){
  192. this.currentDay = this.ynow + '年'+ (this.mnow + 1) +'月';
  193. this.currentDayForEn=this.ynow+'/'+(this.mnow>=9?(this.mnow+1):"0"+(this.mnow+1))+'/'+(this.dnow>=9?this.dnow:"0"+this.dnow)
  194. },
  195. is_leap:function(year) { //判断是否为闰年
  196. return (year%100==0?res=(year%400==0?1:0):res=(year%4==0?1:0));
  197. },
  198. preMonth:function(){ //上一个月
  199. if(this.mnow<=0){
  200. this.mnow=11;
  201. this.ynow=this.ynow-1;
  202. }else{
  203. this.mnow--;
  204. }
  205. this.monDetail();
  206. this.goToLoadData(true);
  207. },
  208. getPreMouth:function(){
  209. var pMnow,pYnow;
  210. if(this.mnow<=0){
  211. pMnow=11;
  212. pYnow=this.ynow-1;
  213. }else{
  214. pMnow=this.mnow-1;
  215. pYnow=this.ynow;
  216. }
  217. var m_days=new Array(31,(28+this.is_leap(pYnow)),31,30,31,30,31,31,30,31,30,31); //每个月的天数
  218. return {
  219. days:m_days[pMnow],
  220. date:pYnow+'-'+(++pMnow>=10?pMnow:"0"+pMnow)
  221. }
  222. },
  223. nextMonth:function(){ //下一个月
  224. if(this.mnow>=11){
  225. this.mnow=0;
  226. this.ynow=this.ynow+1;
  227. }else{
  228. this.mnow++;
  229. }
  230. this.monDetail();
  231. this.goToLoadData(true);
  232. },
  233. getNextMouth:function(){
  234. var nMnow,nYnow;
  235. if(this.mnow>=11){
  236. nMnow=0;
  237. nYnow=this.ynow+1;
  238. }else{
  239. nMnow=this.mnow+1;
  240. nYnow=this.ynow;
  241. }
  242. var m_days=new Array(31,(28+this.is_leap(nYnow)),31,30,31,01,31,31,30,31,30,31); //每个月的天数
  243. return {
  244. days:m_days[nMnow],
  245. date:nYnow+'-'+(++nMnow>=10?nMnow:"0"+nMnow)
  246. }
  247. },
  248. goToLoadData:function(flag){//flag是否更新数据
  249. this.tabStatus==1 && (!this.calendarData.length || flag) && this.calendar();
  250. this.tabStatus==2 && (!this.timeAxisData.length || flag) && this.timeAxis();
  251. },
  252. calendar:function(){
  253. var nlstr = new Date(this.ynow,this.mnow,1); //当月第一天
  254. var firstday = nlstr.getDay()-1;//第一天星期几,默认是周日 我们改成周一
  255. firstday=firstday==-1?6:firstday;//如果是-1,说明当月的第一天是周日
  256. var m_days=new Array(31,(28+this.is_leap(this.ynow)),31,30,31,30,31,31,30,31,30,31); //每个月的天数
  257. var tr_str=Math.ceil((m_days[this.mnow] + firstday)/7); //当前月天数+第一天是星期几的数值 获得 表格行数
  258. var c_days=m_days[this.mnow];//当前月份的天数
  259. var p_arr=this.getPreMouth();
  260. var n_arr=this.getNextMouth();
  261. var i,k,idx,date_str;
  262. var dataArr=[];//天数/年月
  263. for(i=0;i<tr_str;i++) { //表格的行
  264. for(k=0;k<7;k++) { //表格每行的单元格
  265. idx=i*7+k; //单元格自然序列号
  266. date_str=idx-firstday+1; //计算日期
  267. var __ym;
  268. if(date_str<=0){//过滤无效日期(小于等于零的、大于月总天数的)
  269. date_str=date_str+p_arr['days'];//当前日期+上个月的天数就是上个月的日期
  270. __ym=p_arr['date'];
  271. }else if(date_str>c_days){
  272. date_str=date_str-c_days;//下个月的日期就是这个月的天数-当月的天数
  273. __ym=n_arr['date'];
  274. }else{
  275. __ym=this.ynow+'-'+(this.mnow>=9?"":"0")+(this.mnow+1);
  276. }
  277. dataArr.push({
  278. day:date_str,
  279. date:__ym
  280. });
  281. }
  282. }
  283. this.__Data=dataArr;
  284. this.monDetail();
  285. this.calenderPlanDetail();
  286. },
  287. // 日历请求
  288. calenderPlanDetail:function(){
  289. var vm=this;
  290. var __days=vm.__Data;
  291. var lastDay=(__days.concat()).pop().day;
  292. lastDay=lastDay>9?lastDay:'0'+lastDay;
  293. var params={
  294. executeStartTime:__days[0].date+'-'+__days[0].day+' 00:00:00',//日历开始时间(格式:yyyy-MM-dd HH:mm:ss)
  295. executeEndTime:(__days.concat()).pop().date+'-'+lastDay+' 23:59:59',//日历结束时间(格式:yyyy-MM-dd HH:mm:ss)
  296. planId:vm.planId,//计划id
  297. searchTask:vm.searchTask,//快速查找任务:(1、我的任务,2、健康教育,3、健康指导,4、随访)
  298. status:vm.status,//任务状态(0未完成,1已完成,2已预约)
  299. }
  300. rehaAPI.calendarPlanDetail(params).then(function(res){
  301. vm.curTask=vm.searchTask;
  302. vm.curTaskName=vm.searchTaskName;
  303. vm.calendarData=[];
  304. var list = [];
  305. if(res.status==200){
  306. var data=res.data
  307. var _currentTimeStamp=+new Date(new Date().setHours(0, 0, 0, 0));
  308. for(var i in __days){
  309. var _key=__days[i].date+'-'+(__days[i].day>9?__days[i].day:'0'+__days[i].day);
  310. var item={
  311. noService:true,
  312. day:__days[i].day
  313. };
  314. for(var j in data){
  315. if(_key==j){
  316. item=data[j];
  317. item.day=__days[i].day;
  318. var finishFlag=false
  319. var sFlag=false;
  320. var fFlag=false;
  321. if(item.specialist){
  322. if(item.specialist.all==item.specialist.finish){
  323. sFlag=true;
  324. }
  325. }else{
  326. sFlag = true;
  327. }
  328. if(item.family){
  329. if(item.family.all==item.family.finish){
  330. fFlag = true;
  331. }
  332. }else{
  333. fFlag = true;
  334. }
  335. finishFlag = sFlag && fFlag;
  336. item.finishFlag=finishFlag;
  337. data.length && data.splice(j,1);
  338. break;
  339. }
  340. }
  341. var thatTime=+new Date(_key)-8*60*60*1000;
  342. var future=_currentTimeStamp>thatTime?0:(_currentTimeStamp==thatTime?1:2);
  343. item.future=future;
  344. list.push(item);
  345. // vm.calendarData.push(item);
  346. }
  347. vm.calendarData = _.chunk(list, 7)
  348. }
  349. })
  350. },
  351. // 时间轴请求
  352. timeAxis:function(){
  353. var m_days=new Array(31,(28+this.is_leap(this.ynow)),31,30,31,30,31,31,30,31,30,31); //每个月的天数
  354. var c_days=m_days[this.mnow];//当前月份的天数
  355. var __ym=this.ynow+'-'+(this.mnow>=9?"":"0")+(this.mnow+1);
  356. var dataArr=[];//天数/年月
  357. for(;c_days>0;c_days--){
  358. dataArr.push({
  359. day:c_days,
  360. date:__ym
  361. });
  362. }
  363. this.__xData=dataArr;
  364. this.monDetail();
  365. this.calendarPlanDetailList();
  366. },
  367. // 时间轴请求
  368. calendarPlanDetailList:function(){
  369. var vm=this;
  370. var __days=vm.__xData;
  371. var lastDay=(__days.concat()).pop().day;
  372. lastDay=lastDay>9?lastDay:'0'+lastDay;
  373. var params={
  374. executeEndTime:__days[0].date+'-'+__days[0].day+' 00:00:00',//日历开始时间(格式:yyyy-MM-dd HH:mm:ss)
  375. executeStartTime:(__days.concat()).pop().date+'-'+lastDay+' 23:59:59',//日历结束时间(格式:yyyy-MM-dd HH:mm:ss)
  376. planId:vm.planId,//计划id
  377. searchTask:vm.searchTask,//快速查找任务:(1、我的任务,2、随访,3、复诊,4、健康教育)
  378. status:vm.status,//任务状态(0未完成,1已完成,2已预约)
  379. }
  380. rehaAPI.calendarPlanDetailList(params).then(function(res){
  381. if(res.status==200){
  382. var _currentTimeStamp=+new Date(new Date().setHours(0, 0, 0, 0))
  383. vm.timeAxisData=_.map(res.data||{},function(o){
  384. var _time=o.executeTime.split(' ');
  385. var thatTime=+new Date(_time[0]);
  386. var future=_currentTimeStamp>thatTime?0:(_currentTimeStamp==thatTime?1:2);
  387. (o.status==0 && _currentTimeStamp>thatTime) && (future=-1)
  388. var _html=o.status==2?'预':(future==-1?'逾':'');
  389. _html=future==1?'今':_html;
  390. if(_html=='预') future=3;
  391. o.html=_html
  392. o.date=_time[0];
  393. o.time=_time[1];
  394. o.future=future;
  395. return o;
  396. })||[];
  397. }
  398. console.log(vm.timeAxisData)
  399. })
  400. },
  401. changeSearch: function(status) {
  402. var i = status == 1 ? -400 : 0;
  403. var timer1 = setInterval(function() {
  404. i += (5 * status)
  405. $(".search-left").css("right", i + "px")
  406. if(status == 1 && i >= 0) {
  407. clearInterval(timer1)
  408. }
  409. if(status == -1 && i <= -400) {
  410. clearInterval(timer1)
  411. }
  412. }, 5)
  413. }
  414. },
  415. watch:{
  416. tabStatus:function(){
  417. this.goToLoadData();
  418. }
  419. }
  420. })
  421. }();