rehabilitation_management.js 17 KB

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