rehabilitation_management.js 13 KB

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