rehabilitation_management.js 13 KB

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