rehabilitation_management.js 17 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500
  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.findDiagnosisInformationByPatient()
  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. findDiagnosisInformationByPatient: function() {
  80. var vm = this,
  81. loading = layer.load(0, {shade: false}),params = {
  82. patient: vm.patientCode || "e040dd6814b648ceb3ba8d8a04f9f22c",
  83. page: 0,
  84. size: 1
  85. }
  86. recoverAPI.findDiagnosisInformationByPatient(params).then(function(res) {
  87. layer.close(loading)
  88. if(res.status == 200) {
  89. vm.diagnosisInformation = res.data.detailModelList[0]
  90. } else {
  91. showErrorMessage(res.msg);
  92. }
  93. })
  94. },
  95. serviceDoctorList:function(){
  96. var vm = this;
  97. rehaAPI.serviceDoctorList({patientCode: this.patientCode}).then(function(res){
  98. if(res.status == 200){
  99. vm.docList = res.data;
  100. }else{
  101. layer.msg(res.msg,{icon:5});
  102. }
  103. })
  104. },
  105. weiXinConfirmClick:function(){
  106. var vm = this;
  107. rehaAPI.sendWxMsg({planId: this.planId}).then(function(res){
  108. if(res.status == 200){
  109. layer.msg("发送成功,等待居民确认");
  110. setTimeout(function(){
  111. vm.tabStatus=3;
  112. $("#framePage").attr("src","stop_special_service.html?planids="+vm.planId+"&planStatus="+vm.planInfo.status)
  113. },1000)
  114. }else{
  115. layer.msg(res.msg,{icon:5});
  116. }
  117. })
  118. },
  119. setImgSrc: function (src) {
  120. var str = httpRequest.getImgUrl(src)
  121. return str
  122. },
  123. showCompleteDailog:function(){
  124. 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>', {
  125. btn: [],
  126. area: ["400px", "340px"],
  127. title: "完成提示"
  128. }, function (index) {
  129. // layer.close(index);
  130. });
  131. },
  132. refreshPage:function(){
  133. if(!this.planId){
  134. layer.msg('未传入计划id(planId)',{icon:2})
  135. return ;
  136. }
  137. this.goToLoadData(true);
  138. },
  139. bindEvents:function(){
  140. var vm = this;
  141. $("body").on("click",".div-patient-comfirm",function(){
  142. layer.closeAll();
  143. vm.weiXinConfirmClick();
  144. }).on("click", ".div-patient-home", function() {
  145. location.href = "../../recover/html/personal-manage.html?patientCode=" + vm.patientCode
  146. })
  147. },
  148. viewDetail:function(planids,status,type){
  149. var vm=this;
  150. if(!planids){
  151. layer.msg('无服务项',{icon:5})
  152. return ;
  153. }
  154. if(status==1 && type==1){
  155. top.layer.open({
  156. type: 2,
  157. area: ['800px', '650px'],
  158. shade: 0.5,
  159. title: '完成项目确认',
  160. fixed: true, //不固定
  161. maxmin: true,
  162. closeBtn:1,
  163. shift: 5,
  164. shadeClose: false, //点击遮罩关闭层
  165. content: '../../rehabilitation/html/guide_the_message.html?planid='+planids
  166. });
  167. return ;
  168. }
  169. // planids='402803f6657f195301657f4c4ce70000';
  170. layer.open({
  171. type: 2,
  172. area: ['800px', '650px'],
  173. shade: 0.5,
  174. title: '服务项目内容',
  175. fixed: true, //不固定
  176. maxmin: true,
  177. closeBtn:1,
  178. shift: 5,
  179. shadeClose: false, //点击遮罩关闭层
  180. content: '../../rehabilitation/html/service_item_content.html?planids='+planids,
  181. end:function(){
  182. vm.goToLoadData(true);
  183. }
  184. });
  185. },
  186. changeStatus:function(val){
  187. this.status=this.status==val?null:val;
  188. },
  189. changeTask:function(val){
  190. this.searchTask=this.searchTask==val.code?null:val.code;
  191. this.searchTaskName=this.searchTaskName==val.name?null:val.name;
  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,01,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. },
  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. // 日历有计划数据处理
  290. planHandleData: function(data, day, mounth) {
  291. var item = data;
  292. item.day = day;
  293. if(mounth) {item.mounth = mounth}
  294. var finishFlag=false
  295. var sFlag=false;
  296. var fFlag=false;
  297. if(item.specialist){
  298. if(item.specialist.all==item.specialist.finish){
  299. sFlag=true;
  300. }
  301. }else{
  302. sFlag = true;
  303. }
  304. if(item.family){
  305. if(item.family.all==item.family.finish){
  306. fFlag = true;
  307. }
  308. }else{
  309. fFlag = true;
  310. }
  311. finishFlag = sFlag && fFlag;
  312. item.finishFlag=finishFlag;
  313. return item
  314. },
  315. // 日历请求
  316. calenderPlanDetail:function(){
  317. var vm=this;
  318. var __days=vm.__Data;
  319. var lastDay=(__days.concat()).pop().day;
  320. lastDay=lastDay>9?lastDay:'0'+lastDay;
  321. if(vm.searchTask || vm.status || vm.status == 0) {
  322. vm.isFastSearch = true
  323. } else {
  324. vm.isFastSearch = false
  325. }
  326. var params={
  327. executeStartTime: vm.isFastSearch ? '' : __days[0].date+'-'+__days[0].day+' 00:00:00',//日历开始时间(格式:yyyy-MM-dd HH:mm:ss)
  328. executeEndTime: vm.isFastSearch ? '' : (__days.concat()).pop().date+'-'+lastDay+' 23:59:59',//日历结束时间(格式:yyyy-MM-dd HH:mm:ss)
  329. planId:vm.planId,//计划id
  330. searchTask:vm.searchTask,//快速查找任务:(1、我的任务,2、健康教育,3、健康指导,4、随访)
  331. status:vm.status,//任务状态(0未完成,1已完成,2已预约)
  332. }
  333. rehaAPI.calendarPlanDetail(params).then(function(res){
  334. vm.curTask=vm.searchTask;
  335. vm.curTaskName=vm.searchTaskName;
  336. vm.calendarData=[];
  337. var list = [];
  338. if(res.status==200){
  339. var data=res.data
  340. // 快速查找
  341. if(vm.isFastSearch) {
  342. var searchData0 = [],
  343. searchData1 = [],
  344. searchData2 = [];
  345. for(var setM = 1; setM <= 12; setM++) {
  346. var _setM = setM > 9 ? setM : '0' + setM,
  347. _setY = new Date().getFullYear();
  348. var data0 = [],
  349. data1 = [],
  350. data2 = [];
  351. for(var i in data) {
  352. var getY = i.split("-")[0],
  353. getM = i.split("-")[1],
  354. getD = i.split("-")[2];
  355. // 去年
  356. if(_setY - 1 == getY && _setM == getM) {
  357. var item = vm.planHandleData(data[i], getD, getM)
  358. data0.push(item)
  359. data.length && data.splice(i,1);
  360. } else if(_setY == getY && _setM == getM) { // 今年
  361. var item = vm.planHandleData(data[i], getD, getM)
  362. data1.push(item)
  363. data.length && data.splice(i,1);
  364. } else if(_setY + 1 == getY && _setM == getM) { // 明年
  365. var item = vm.planHandleData(data[i], getD, getM)
  366. data2.push(item)
  367. data.length && data.splice(i,1);
  368. }
  369. }
  370. if(data0.length) {
  371. var addlen = (data0.length + 1) % 7 ? (data0.length + 1) % 7 : 7
  372. for(var i = 0; i < 7 - addlen; i++) {
  373. data0.push({
  374. noService:true
  375. })
  376. }
  377. searchData0.push(data0)
  378. }
  379. if(data1.length) {
  380. var addlen = (data1.length + 1) % 7 ? (data1.length + 1) % 7 : 7
  381. for(var i = 0; i < 7 - addlen; i++) {
  382. data1.push({
  383. noService:true
  384. })
  385. }
  386. searchData1.push(data1)
  387. }
  388. if(data2.length) {
  389. var addlen = (data2.length + 1) % 7 ? (data2.length + 1) % 7 : 7
  390. for(var i = 0; i < 7 - addlen; i++) {
  391. data2.push({
  392. noService:true
  393. })
  394. }
  395. searchData2.push(data2)
  396. }
  397. }
  398. if(searchData0.length) {vm.searchData.push(searchData0)}
  399. if(searchData1.length) {vm.searchData.push(searchData1)}
  400. if(searchData2.length) {vm.searchData.push(searchData2)}
  401. return false;
  402. }
  403. // 正常日历
  404. var _currentTimeStamp=+new Date(new Date().setHours(0, 0, 0, 0));
  405. for(var i in __days){
  406. var _key=__days[i].date+'-'+(__days[i].day>9?__days[i].day:'0'+__days[i].day);
  407. var item={
  408. noService:true,
  409. day:__days[i].day
  410. };
  411. for(var j in data){
  412. if(_key==j){
  413. item = vm.planHandleData(data[j], __days[i].day)
  414. data.length && data.splice(j,1);
  415. break;
  416. }
  417. }
  418. var thatTime=+new Date(_key)-8*60*60*1000;
  419. var future=_currentTimeStamp>thatTime?0:(_currentTimeStamp==thatTime?1:2);
  420. item.future=future;
  421. list.push(item);
  422. // vm.calendarData.push(item);
  423. }
  424. vm.calendarData = _.chunk(list, 7)
  425. }
  426. })
  427. },
  428. // 时间轴请求
  429. timeAxis:function(){
  430. var m_days=new Array(31,(28+this.is_leap(this.ynow)),31,30,31,30,31,31,30,31,30,31); //每个月的天数
  431. var c_days=m_days[this.mnow];//当前月份的天数
  432. var __ym=this.ynow+'-'+(this.mnow>=9?"":"0")+(this.mnow+1);
  433. var dataArr=[];//天数/年月
  434. for(;c_days>0;c_days--){
  435. dataArr.push({
  436. day:c_days,
  437. date:__ym
  438. });
  439. }
  440. this.__xData=dataArr;
  441. this.monDetail();
  442. this.calendarPlanDetailList();
  443. },
  444. // 时间轴请求
  445. calendarPlanDetailList:function(){
  446. var vm=this;
  447. var __days=vm.__xData;
  448. var lastDay=(__days.concat()).pop().day;
  449. lastDay=lastDay>9?lastDay:'0'+lastDay;
  450. var params={
  451. executeEndTime:__days[0].date+'-'+__days[0].day+' 00:00:00',//日历开始时间(格式:yyyy-MM-dd HH:mm:ss)
  452. executeStartTime:(__days.concat()).pop().date+'-'+lastDay+' 23:59:59',//日历结束时间(格式:yyyy-MM-dd HH:mm:ss)
  453. planId:vm.planId,//计划id
  454. searchTask:vm.searchTask,//快速查找任务:(1、我的任务,2、随访,3、复诊,4、健康教育)
  455. status:vm.status,//任务状态(0未完成,1已完成,2已预约)
  456. }
  457. rehaAPI.calendarPlanDetailList(params).then(function(res){
  458. if(res.status==200){
  459. var _currentTimeStamp=+new Date(new Date().setHours(0, 0, 0, 0))
  460. vm.timeAxisData=_.map(res.data||{},function(o){
  461. var _time=o.executeTime.split(' ');
  462. var thatTime=+new Date(_time[0]);
  463. var future=_currentTimeStamp>thatTime?0:(_currentTimeStamp==thatTime?1:2);
  464. (o.status==0 && _currentTimeStamp>thatTime) && (future=-1)
  465. var _html=o.status==2?'预':(future==-1?'逾':'');
  466. _html=future==1?'今':_html;
  467. if(_html=='预') future=3;
  468. o.html=_html
  469. o.date=_time[0];
  470. o.time=_time[1];
  471. o.future=future;
  472. return o;
  473. })||[];
  474. }
  475. console.log(vm.timeAxisData)
  476. })
  477. },
  478. changeSearch: function(status) {
  479. var i = status == 1 ? -400 : 0;
  480. var timer1 = setInterval(function() {
  481. i += (5 * status)
  482. $(".search-left").css("right", i + "px")
  483. if(status == 1 && i >= 0) {
  484. clearInterval(timer1)
  485. }
  486. if(status == -1 && i <= -400) {
  487. clearInterval(timer1)
  488. }
  489. }, 5)
  490. }
  491. },
  492. watch:{
  493. tabStatus:function(){
  494. this.goToLoadData();
  495. }
  496. }
  497. })
  498. }();