rehabilitation_management.js 20 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576
  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. curDoc: JSON.parse(localStorage.docInfo),
  23. taskArr:[
  24. {code:1,name:'我的任务'},
  25. {code:2,name:'健康教育'},
  26. {code:3,name:'健康指导'},
  27. {code:4,name:'随访'},
  28. {code:5,name:'复诊'},
  29. ],
  30. statusArr:[
  31. {code:0,name:'未完成'},
  32. {code:1,name:'已完成'},
  33. {code:2,name:'已预约'},
  34. ],
  35. curTask:'',//快速查找是否点击了搜索按钮
  36. curTaskName:'',//快速查找是否点击了搜索按钮
  37. tabStatus:null,
  38. planInfo:{},
  39. docList:[],
  40. diagnosisInformation: null,
  41. searchData: [], // 搜索计划安排(去年、今年、明年)
  42. },
  43. mounted:function(){
  44. if(!this.planId){
  45. layer.msg('未传入计划id(planId)',{icon:2})
  46. }else{
  47. this.tabStatus=1;
  48. }
  49. this.planSchedule();
  50. this.serviceDoctorList();//获取服务医生列表
  51. this.bindEvents();
  52. // 获取最新的诊疗信息1条
  53. this.findDiagnosisInformationByPlanId()
  54. },
  55. methods:{
  56. //获取计划表
  57. planSchedule:function(){
  58. var vm = this;
  59. var params = {
  60. planId: this.planId,
  61. patientCode: this.patientCode
  62. };
  63. rehaAPI.planSchedule(params).then(function(res){
  64. if(res.status == 200){
  65. vm.planInfo = res.data;
  66. vm.planInfo.tagClass = "tag-"+res.data.healthyConditionType;
  67. //patientImg:居民签名照/证件照,如果不为null的话说明居民已确认,显示康复完成明细
  68. if(vm.planInfo.status==2 && !vm.planInfo.patientImg){//任务全部完成时,显示完成提示框
  69. vm.showCompleteDailog();
  70. }else if(vm.planInfo.status==2 && vm.planInfo.patientImg){//居民已确认计划完成
  71. vm.tabStatus=3;
  72. $("#framePage").attr("src","stop_special_service.html?planids="+vm.planId+"&planStatus="+vm.planInfo.status)
  73. }
  74. }else{
  75. layer.msg(res.msg,{icon:5});
  76. }
  77. })
  78. },
  79. // 获取最新的诊疗消息
  80. findDiagnosisInformationByPlanId: function() {
  81. var vm = this,
  82. loading = layer.load(0, {shade: false}),
  83. params = {
  84. planId: vm.planId
  85. }
  86. recoverAPI.findDiagnosisInformationByPlanId(params).then(function(res) {
  87. layer.close(loading)
  88. if(res.status == 200) {
  89. vm.diagnosisInformation = res.data
  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. 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. this.monDetail();
  288. this.calenderPlanDetail();
  289. },
  290. daysSort: function(arr) {
  291. var getArr = JSON.parse(JSON.stringify(arr)),
  292. returnArr = []
  293. for(var i = 1; i < 31; i++) {
  294. for(var j = 0, len = getArr.length; j < len; j++) {
  295. var stri = i > 9 + '' ? i : '0'+i
  296. if(getArr[j].day == stri) {
  297. returnArr.push(getArr[j])
  298. getArr.splice(j,1)
  299. break;
  300. }
  301. }
  302. }
  303. return returnArr
  304. },
  305. // 日历有计划数据处理
  306. planHandleData: function(data, day, mounth) {
  307. var item = data;
  308. item.day = day;
  309. if(mounth) {item.mounth = mounth}
  310. var finishFlag=false
  311. var sFlag=false;
  312. var fFlag=false;
  313. if(item.specialist){
  314. if(item.specialist.all==item.specialist.finish){
  315. sFlag=true;
  316. }
  317. }else{
  318. sFlag = true;
  319. }
  320. if(item.family){
  321. if(item.family.all==item.family.finish){
  322. fFlag = true;
  323. }
  324. }else{
  325. fFlag = true;
  326. }
  327. finishFlag = sFlag && fFlag;
  328. item.finishFlag=finishFlag;
  329. return item
  330. },
  331. // 日历请求
  332. calenderPlanDetail:function(){
  333. var vm=this;
  334. var __days=vm.__Data;
  335. var lastDay=(__days.concat()).pop().day;
  336. lastDay=lastDay>9?lastDay:'0'+lastDay;
  337. if(vm.searchTask || vm.status || vm.status == 0) {
  338. vm.isFastSearch = true
  339. } else {
  340. vm.isFastSearch = false
  341. }
  342. var params={
  343. executeStartTime: vm.isFastSearch ? '' : __days[0].date+'-'+__days[0].day+' 00:00:00',//日历开始时间(格式:yyyy-MM-dd HH:mm:ss)
  344. executeEndTime: vm.isFastSearch ? '' : (__days.concat()).pop().date+'-'+lastDay+' 23:59:59',//日历结束时间(格式:yyyy-MM-dd HH:mm:ss)
  345. planId:vm.planId,//计划id
  346. searchTask:vm.searchTask,//快速查找任务:(1、我的任务,2、健康教育,3、健康指导,4、随访)
  347. status:vm.status,//任务状态(0未完成,1已完成,2已预约)
  348. }
  349. rehaAPI.calendarPlanDetail(params).then(function(res){
  350. vm.curTask=vm.searchTask;
  351. vm.curTaskName=vm.searchTaskName;
  352. vm.calendarData=[];
  353. var list = [];
  354. if(res.status==200){
  355. var data=res.data
  356. // 快速查找
  357. if(vm.isFastSearch) {
  358. vm.searchData = []
  359. var searchData0 = [],
  360. searchData1 = [],
  361. searchData2 = [];
  362. for(var setM = 1; setM <= 12; setM++) {
  363. var _setM = setM > 9 ? setM : '0' + setM,
  364. _setY = new Date().getFullYear();
  365. var data0 = [],
  366. data1 = [],
  367. data2 = [];
  368. for(var i in data) {
  369. var getY = i.split("-")[0],
  370. getM = i.split("-")[1],
  371. getD = i.split("-")[2];
  372. // 去年
  373. if(_setY - 1 == getY && _setM == getM) {
  374. var item = vm.planHandleData(data[i], getD, getM)
  375. data0.push(item)
  376. data.length && data.splice(i,1);
  377. } else if(_setY == getY && _setM == getM) { // 今年
  378. var item = vm.planHandleData(data[i], getD, getM)
  379. data1.push(item)
  380. data.length && data.splice(i,1);
  381. } else if(_setY + 1 == getY && _setM == getM) { // 明年
  382. var item = vm.planHandleData(data[i], getD, getM)
  383. data2.push(item)
  384. data.length && data.splice(i,1);
  385. }
  386. }
  387. if(data0.length) {
  388. var dataSort = vm.daysSort(data0)
  389. var addlen = (dataSort.length + 1) % 7 ? (dataSort.length + 1) % 7 : 7
  390. for(var i = 0; i < 7 - addlen; i++) {
  391. dataSort.push({
  392. noService:true
  393. })
  394. }
  395. searchData0.push(dataSort)
  396. }
  397. if(data1.length) {
  398. var dataSort = vm.daysSort(data1)
  399. var addlen = (dataSort.length + 1) % 7 ? (dataSort.length + 1) % 7 : 7
  400. for(var i = 0; i < 7 - addlen; i++) {
  401. dataSort.push({
  402. noService:true
  403. })
  404. }
  405. searchData1.push(dataSort)
  406. }
  407. if(data2.length) {
  408. var dataSort = vm.daysSort(data2)
  409. var addlen = (dataSort.length + 1) % 7 ? (dataSort.length + 1) % 7 : 7
  410. for(var i = 0; i < 7 - addlen; i++) {
  411. dataSort.push({
  412. noService:true
  413. })
  414. }
  415. searchData2.push(dataSort)
  416. }
  417. }
  418. if(searchData0.length) {vm.searchData.push(searchData0)}
  419. if(searchData1.length) {vm.searchData.push(searchData1)}
  420. if(searchData2.length) {vm.searchData.push(searchData2)}
  421. return false;
  422. }
  423. // 正常日历
  424. var _currentTimeStamp=+new Date(new Date().setHours(0, 0, 0, 0));
  425. for(var i in __days){
  426. var _key=__days[i].date+'-'+(__days[i].day>9?__days[i].day:'0'+__days[i].day);
  427. var item={
  428. noService:true,
  429. day:__days[i].day
  430. };
  431. for(var j in data){
  432. if(_key==j){
  433. item = vm.planHandleData(data[j], __days[i].day)
  434. data.length && data.splice(j,1);
  435. break;
  436. }
  437. }
  438. var thatTime=+new Date(_key)-8*60*60*1000;
  439. var future=_currentTimeStamp>thatTime?0:(_currentTimeStamp==thatTime?1:2);
  440. item.future=future;
  441. list.push(item);
  442. // vm.calendarData.push(item);
  443. }
  444. vm.calendarData = _.chunk(list, 7)
  445. }
  446. })
  447. },
  448. // 时间轴请求
  449. timeAxis:function(){
  450. var m_days=new Array(31,(28+this.is_leap(this.ynow)),31,30,31,30,31,31,30,31,30,31); //每个月的天数
  451. var c_days=m_days[this.mnow];//当前月份的天数
  452. var __ym=this.ynow+'-'+(this.mnow>=9?"":"0")+(this.mnow+1);
  453. var dataArr=[];//天数/年月
  454. for(;c_days>0;c_days--){
  455. dataArr.push({
  456. day:c_days,
  457. date:__ym
  458. });
  459. }
  460. this.__xData=dataArr;
  461. this.monDetail();
  462. this.calendarPlanDetailList();
  463. },
  464. // 时间轴请求
  465. calendarPlanDetailList:function(){
  466. var vm=this;
  467. var __days=vm.__xData;
  468. var lastDay=(__days.concat()).pop().day;
  469. lastDay=lastDay>9?lastDay:'0'+lastDay;
  470. var params={
  471. executeEndTime:__days[0].date+'-'+__days[0].day+' 00:00:00',//日历开始时间(格式:yyyy-MM-dd HH:mm:ss)
  472. executeStartTime:(__days.concat()).pop().date+'-'+lastDay+' 23:59:59',//日历结束时间(格式:yyyy-MM-dd HH:mm:ss)
  473. planId:vm.planId,//计划id
  474. searchTask:vm.searchTask,//快速查找任务:(1、我的任务,2、随访,3、复诊,4、健康教育)
  475. status:vm.status,//任务状态(0未完成,1已完成,2已预约)
  476. }
  477. rehaAPI.calendarPlanDetailList(params).then(function(res){
  478. if(res.status==200){
  479. var _currentTimeStamp=+new Date(new Date().setHours(0, 0, 0, 0))
  480. vm.timeAxisData=_.map(res.data||{},function(o){
  481. var _time=o.executeTime.split(' ');
  482. var thatTime=+new Date(_time[0]);
  483. var future=_currentTimeStamp>thatTime?0:(_currentTimeStamp==thatTime?1:2);
  484. (o.status==0 && _currentTimeStamp>thatTime) && (future=-1)
  485. var _html=o.status==2?'预':(future==-1?'逾':'');
  486. _html=future==1?'今':_html;
  487. if(_html=='预') future=3;
  488. o.html=_html
  489. o.date=_time[0];
  490. o.time=_time[1];
  491. o.future=future;
  492. return o;
  493. })||[];
  494. }
  495. })
  496. },
  497. changeSearch: function(status) {
  498. var i = status == 1 ? -400 : 0;
  499. var timer1 = setInterval(function() {
  500. i += (5 * status)
  501. $(".search-left").css("right", i + "px")
  502. if(status == 1 && i >= 0) {
  503. clearInterval(timer1)
  504. }
  505. if(status == -1 && i <= -400) {
  506. clearInterval(timer1)
  507. }
  508. }, 5)
  509. },
  510. //邀请视频聊天
  511. openVideoChat: function(otherDoc){
  512. var vm = this;
  513. var loading = layer.load(0);
  514. var participants = []
  515. var participantsMobile = {}
  516. var docInfo = JSON.parse(localStorage.docInfo);
  517. //发起人
  518. participants.push({mobile: docInfo.mobile, name: docInfo.name, sex: docInfo.sex==1? 1 : 2, birthdate: "", level: 3, hospital_name: docInfo.hospitalName, idcard: ""});
  519. participantsMobile[docInfo.mobile] = 1;
  520. if(otherDoc){
  521. //被邀请人
  522. participants.push({
  523. mobile: otherDoc.doctorMobile,
  524. name: otherDoc.doctorName,
  525. sex: otherDoc.doctorSex==1? 1 : 2,
  526. birthdate: "",
  527. level: 3,
  528. hospital_name: otherDoc.doctorHospitalName,
  529. idcard: otherDoc.doctorIdcard})
  530. participantsMobile[otherDoc.doctorMobile] = 0;
  531. }
  532. videoChatAPI.addDoctor({participants : JSON.stringify(participants)}).then(function(res){
  533. if(res.status == 200){
  534. videoChatAPI.sessions({
  535. sessionId: httpRequest.uuid(24, 16),
  536. sessionType: 4,
  537. sessionName: vm.planInfo.patientName +"的远程门诊",
  538. participants: JSON.stringify(participantsMobile),
  539. videoconferencing: 1,
  540. idcard: vm.planInfo.idcard
  541. }).then(function(res1){
  542. layer.close(loading)
  543. if(res1.status == 200){
  544. layer.msg("发起会话成功",{icon:6});
  545. } else{
  546. layer.msg("发起会话失败",{icon:5});
  547. }
  548. }).catch(function(){
  549. layer.close(loading)
  550. layer.msg("系统繁忙",{icon:5});
  551. })
  552. }else{
  553. layer.close(loading)
  554. layer.msg(res.msg,{icon:5});
  555. }
  556. }).catch(function(){
  557. layer.close(loading)
  558. layer.msg("系统繁忙",{icon:5});
  559. })
  560. }
  561. },
  562. watch:{
  563. tabStatus:function(){
  564. this.goToLoadData();
  565. }
  566. }
  567. })
  568. }();