rehabilitation_management.js 17 KB

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