rehabilitation_management.js 17 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518
  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. this.changeSearch(-1)
  253. },
  254. calendar:function(){
  255. var nlstr = new Date(this.ynow,this.mnow,1); //当月第一天
  256. var firstday = nlstr.getDay()-1;//第一天星期几,默认是周日 我们改成周一
  257. firstday=firstday==-1?6:firstday;//如果是-1,说明当月的第一天是周日
  258. var m_days=new Array(31,(28+this.is_leap(this.ynow)),31,30,31,30,31,31,30,31,30,31); //每个月的天数
  259. var tr_str=Math.ceil((m_days[this.mnow] + firstday)/7); //当前月天数+第一天是星期几的数值 获得 表格行数
  260. var c_days=m_days[this.mnow];//当前月份的天数
  261. var p_arr=this.getPreMouth();
  262. var n_arr=this.getNextMouth();
  263. var i,k,idx,date_str;
  264. var dataArr=[];//天数/年月
  265. for(i=0;i<tr_str;i++) { //表格的行
  266. for(k=0;k<7;k++) { //表格每行的单元格
  267. idx=i*7+k; //单元格自然序列号
  268. date_str=idx-firstday+1; //计算日期
  269. var __ym;
  270. if(date_str<=0){//过滤无效日期(小于等于零的、大于月总天数的)
  271. date_str=date_str+p_arr['days'];//当前日期+上个月的天数就是上个月的日期
  272. __ym=p_arr['date'];
  273. }else if(date_str>c_days){
  274. date_str=date_str-c_days;//下个月的日期就是这个月的天数-当月的天数
  275. __ym=n_arr['date'];
  276. }else{
  277. __ym=this.ynow+'-'+(this.mnow>=9?"":"0")+(this.mnow+1);
  278. }
  279. dataArr.push({
  280. day:date_str,
  281. date:__ym
  282. });
  283. }
  284. }
  285. this.__Data=dataArr;
  286. this.monDetail();
  287. this.calenderPlanDetail();
  288. },
  289. daysSort: function(arr) {
  290. var getArr = JSON.parse(JSON.stringify(arr)),
  291. returnArr = []
  292. for(var i = 1; i < 31; i++) {
  293. for(var j = 0, len = getArr.length; j < len; j++) {
  294. var stri = i > 9 + '' ? i : '0'+i
  295. if(getArr[j].day == stri) {
  296. returnArr.push(getArr[j])
  297. getArr.splice(j,1)
  298. break;
  299. }
  300. }
  301. }
  302. return returnArr
  303. },
  304. // 日历有计划数据处理
  305. planHandleData: function(data, day, mounth) {
  306. var item = data;
  307. item.day = day;
  308. if(mounth) {item.mounth = mounth}
  309. var finishFlag=false
  310. var sFlag=false;
  311. var fFlag=false;
  312. if(item.specialist){
  313. if(item.specialist.all==item.specialist.finish){
  314. sFlag=true;
  315. }
  316. }else{
  317. sFlag = true;
  318. }
  319. if(item.family){
  320. if(item.family.all==item.family.finish){
  321. fFlag = true;
  322. }
  323. }else{
  324. fFlag = true;
  325. }
  326. finishFlag = sFlag && fFlag;
  327. item.finishFlag=finishFlag;
  328. return item
  329. },
  330. // 日历请求
  331. calenderPlanDetail:function(){
  332. var vm=this;
  333. var __days=vm.__Data;
  334. var lastDay=(__days.concat()).pop().day;
  335. lastDay=lastDay>9?lastDay:'0'+lastDay;
  336. if(vm.searchTask || vm.status || vm.status == 0) {
  337. vm.isFastSearch = true
  338. } else {
  339. vm.isFastSearch = false
  340. }
  341. var params={
  342. executeStartTime: vm.isFastSearch ? '' : __days[0].date+'-'+__days[0].day+' 00:00:00',//日历开始时间(格式:yyyy-MM-dd HH:mm:ss)
  343. executeEndTime: vm.isFastSearch ? '' : (__days.concat()).pop().date+'-'+lastDay+' 23:59:59',//日历结束时间(格式:yyyy-MM-dd HH:mm:ss)
  344. planId:vm.planId,//计划id
  345. searchTask:vm.searchTask,//快速查找任务:(1、我的任务,2、健康教育,3、健康指导,4、随访)
  346. status:vm.status,//任务状态(0未完成,1已完成,2已预约)
  347. }
  348. rehaAPI.calendarPlanDetail(params).then(function(res){
  349. vm.curTask=vm.searchTask;
  350. vm.curTaskName=vm.searchTaskName;
  351. vm.calendarData=[];
  352. var list = [];
  353. if(res.status==200){
  354. var data=res.data
  355. // 快速查找
  356. if(vm.isFastSearch) {
  357. vm.searchData = []
  358. var searchData0 = [],
  359. searchData1 = [],
  360. searchData2 = [];
  361. for(var setM = 1; setM <= 12; setM++) {
  362. var _setM = setM > 9 ? setM : '0' + setM,
  363. _setY = new Date().getFullYear();
  364. var data0 = [],
  365. data1 = [],
  366. data2 = [];
  367. for(var i in data) {
  368. var getY = i.split("-")[0],
  369. getM = i.split("-")[1],
  370. getD = i.split("-")[2];
  371. // 去年
  372. if(_setY - 1 == getY && _setM == getM) {
  373. var item = vm.planHandleData(data[i], getD, getM)
  374. data0.push(item)
  375. data.length && data.splice(i,1);
  376. } else if(_setY == getY && _setM == getM) { // 今年
  377. var item = vm.planHandleData(data[i], getD, getM)
  378. data1.push(item)
  379. data.length && data.splice(i,1);
  380. } else if(_setY + 1 == getY && _setM == getM) { // 明年
  381. var item = vm.planHandleData(data[i], getD, getM)
  382. data2.push(item)
  383. data.length && data.splice(i,1);
  384. }
  385. }
  386. if(data0.length) {
  387. var dataSort = vm.daysSort(data0)
  388. var addlen = (dataSort.length + 1) % 7 ? (dataSort.length + 1) % 7 : 7
  389. for(var i = 0; i < 7 - addlen; i++) {
  390. dataSort.push({
  391. noService:true
  392. })
  393. }
  394. searchData0.push(dataSort)
  395. }
  396. if(data1.length) {
  397. var dataSort = vm.daysSort(data1)
  398. var addlen = (dataSort.length + 1) % 7 ? (dataSort.length + 1) % 7 : 7
  399. for(var i = 0; i < 7 - addlen; i++) {
  400. dataSort.push({
  401. noService:true
  402. })
  403. }
  404. searchData1.push(dataSort)
  405. }
  406. if(data2.length) {
  407. var dataSort = vm.daysSort(data2)
  408. var addlen = (dataSort.length + 1) % 7 ? (dataSort.length + 1) % 7 : 7
  409. for(var i = 0; i < 7 - addlen; i++) {
  410. dataSort.push({
  411. noService:true
  412. })
  413. }
  414. searchData2.push(dataSort)
  415. }
  416. }
  417. if(searchData0.length) {vm.searchData.push(searchData0)}
  418. if(searchData1.length) {vm.searchData.push(searchData1)}
  419. if(searchData2.length) {vm.searchData.push(searchData2)}
  420. return false;
  421. }
  422. // 正常日历
  423. var _currentTimeStamp=+new Date(new Date().setHours(0, 0, 0, 0));
  424. for(var i in __days){
  425. var _key=__days[i].date+'-'+(__days[i].day>9?__days[i].day:'0'+__days[i].day);
  426. var item={
  427. noService:true,
  428. day:__days[i].day
  429. };
  430. for(var j in data){
  431. if(_key==j){
  432. item = vm.planHandleData(data[j], __days[i].day)
  433. data.length && data.splice(j,1);
  434. break;
  435. }
  436. }
  437. var thatTime=+new Date(_key)-8*60*60*1000;
  438. var future=_currentTimeStamp>thatTime?0:(_currentTimeStamp==thatTime?1:2);
  439. item.future=future;
  440. list.push(item);
  441. // vm.calendarData.push(item);
  442. }
  443. vm.calendarData = _.chunk(list, 7)
  444. }
  445. })
  446. },
  447. // 时间轴请求
  448. timeAxis:function(){
  449. var m_days=new Array(31,(28+this.is_leap(this.ynow)),31,30,31,30,31,31,30,31,30,31); //每个月的天数
  450. var c_days=m_days[this.mnow];//当前月份的天数
  451. var __ym=this.ynow+'-'+(this.mnow>=9?"":"0")+(this.mnow+1);
  452. var dataArr=[];//天数/年月
  453. for(;c_days>0;c_days--){
  454. dataArr.push({
  455. day:c_days,
  456. date:__ym
  457. });
  458. }
  459. this.__xData=dataArr;
  460. this.monDetail();
  461. this.calendarPlanDetailList();
  462. },
  463. // 时间轴请求
  464. calendarPlanDetailList:function(){
  465. var vm=this;
  466. var __days=vm.__xData;
  467. var lastDay=(__days.concat()).pop().day;
  468. lastDay=lastDay>9?lastDay:'0'+lastDay;
  469. var params={
  470. executeEndTime:__days[0].date+'-'+__days[0].day+' 00:00:00',//日历开始时间(格式:yyyy-MM-dd HH:mm:ss)
  471. executeStartTime:(__days.concat()).pop().date+'-'+lastDay+' 23:59:59',//日历结束时间(格式:yyyy-MM-dd HH:mm:ss)
  472. planId:vm.planId,//计划id
  473. searchTask:vm.searchTask,//快速查找任务:(1、我的任务,2、随访,3、复诊,4、健康教育)
  474. status:vm.status,//任务状态(0未完成,1已完成,2已预约)
  475. }
  476. rehaAPI.calendarPlanDetailList(params).then(function(res){
  477. if(res.status==200){
  478. var _currentTimeStamp=+new Date(new Date().setHours(0, 0, 0, 0))
  479. vm.timeAxisData=_.map(res.data||{},function(o){
  480. var _time=o.executeTime.split(' ');
  481. var thatTime=+new Date(_time[0]);
  482. var future=_currentTimeStamp>thatTime?0:(_currentTimeStamp==thatTime?1:2);
  483. (o.status==0 && _currentTimeStamp>thatTime) && (future=-1)
  484. var _html=o.status==2?'预':(future==-1?'逾':'');
  485. _html=future==1?'今':_html;
  486. if(_html=='预') future=3;
  487. o.html=_html
  488. o.date=_time[0];
  489. o.time=_time[1];
  490. o.future=future;
  491. return o;
  492. })||[];
  493. }
  494. })
  495. },
  496. changeSearch: function(status) {
  497. var i = status == 1 ? -400 : 0;
  498. var timer1 = setInterval(function() {
  499. i += (5 * status)
  500. $(".search-left").css("right", i + "px")
  501. if(status == 1 && i >= 0) {
  502. clearInterval(timer1)
  503. }
  504. if(status == -1 && i <= -400) {
  505. clearInterval(timer1)
  506. }
  507. }, 5)
  508. }
  509. },
  510. watch:{
  511. tabStatus:function(){
  512. this.goToLoadData();
  513. }
  514. }
  515. })
  516. }();