rehabilitation_management.js 28 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887
  1. !function(){
  2. var httpData=GetRequest();
  3. var currentGMT=new Date();//当前时间GMT
  4. var xuetangDuring = ['', '早餐前', '早餐后', '午餐前', '午餐后', '晚餐前', '晚餐后', '睡前'];
  5. var normalLevel = [
  6. [],
  7. [7, 4],
  8. [11.1, 4],
  9. [7, 4],
  10. [11.1, 4],
  11. [7, 4],
  12. [11.1, 4],
  13. [7, 4]
  14. ];
  15. var docInfo = JSON.parse(localStorage.docInfo);
  16. function showSuccessMessage(msg) {
  17. layer.msg(msg, {
  18. icon: 1
  19. })
  20. }
  21. function showErrorMessage(msg) {
  22. layer.msg(msg, {
  23. icon: 5
  24. })
  25. }
  26. function showWarningMessage(msg) {
  27. layer.msg(msg, {
  28. icon: 2
  29. })
  30. }
  31. function showInfoMessage(msg) {
  32. layer.msg(msg, {
  33. icon: 6
  34. })
  35. }
  36. top.rehabilitationVue = new Vue({
  37. el:"#app",
  38. data:{
  39. ynow: currentGMT.getFullYear(),//年份
  40. mnow: currentGMT.getMonth(),//月份(比实际少一个月---0开始至11)
  41. dnow: currentGMT.getDate(),//当前日
  42. currentDay:null,//带中文格式的当前年月
  43. currentDayForEn:null,//不带中文格式年月日2018/10/01如果写成/的话 转换成时间戳会变成北京时间8点
  44. calendarData:[],//日历数据
  45. loginDoctor:JSON.parse(localStorage.getItem('wlyyAgent')),
  46. timeAxisData:[],//时间轴数据
  47. __Data:[],//当前的年月(日历)
  48. __xData:[],//当前的年月(时间轴)
  49. isFastSearch: false, // 是否是快速查找任务
  50. status: '',//任务状态(0未完成,1已完成,2已预约)
  51. searchTask: '',//快速查找任务:(1、我的任务,2、健康教育,3、健康指导,4、随访,5、复诊)
  52. searchTaskName: '全部',//快速查找任务:(1、我的任务,2、健康教育,3、健康指导,4、随访,5、复诊)
  53. planId: httpData['planId'],
  54. patientCode: httpData['patientCode'],
  55. taskArr:[{code:"",name:"全部"},{code:2,name:"康复咨询"},{code:4,name:"上门服务"},{code:1,name:"电话/短信关怀"},{code:3,name:"健康监测"},{code:5,name:"康复指导"},
  56. {code:6,name:"康复随访"},{code:7,name:"康复复诊"}],
  57. statusArr:[{code:"",name:"全部"},{code:0,name:"未完成"},{code:1,name:"已完成"},{code:2,name:"已预约"}],
  58. curTask:'',//快速查找是否点击了搜索按钮
  59. curTaskName:'',//快速查找是否点击了搜索按钮
  60. tabStatus:null,
  61. planInfo:{},
  62. docList:[],
  63. diagnosisInformation: null,
  64. searchData: [], // 搜索计划安排(去年、今年、明年)
  65. medicalRecordsList: [], //病历列表
  66. limitlessItems: [],
  67. showServerItemDetail: false,
  68. serverItemInfo: undefined,
  69. islimit: false,
  70. scList:[]
  71. },
  72. mounted:function(){
  73. if(!this.planId){
  74. layer.msg('未传入计划id(planId)',{icon:2})
  75. }else{
  76. this.tabStatus=1;
  77. }
  78. this.planSchedule();
  79. // this.serviceDoctorList();//获取服务医生列表
  80. this.selectPlanServerDoctor();//获取服务医生列表
  81. this.bindEvents();
  82. // 获取最新的诊疗信息1条
  83. this.findDiagnosisInformationByPlanId()
  84. },
  85. methods:{
  86. gotoCheck:function(){
  87. var obj= {
  88. patientName:this.planInfo.patientName,
  89. patientCode:this.planInfo.patientCode
  90. }
  91. window.location.href='../../jbsc/html/statistics.html?scListItem='+encodeURIComponent(JSON.stringify(obj))
  92. },
  93. view: function (code) {
  94. var vm = this
  95. layer.open({
  96. type: 2,
  97. // offset: ['100px'], //右下角弹出
  98. area: ['568px', '100%'],
  99. shade: 0.5,
  100. title: '查看筛选结果',
  101. fixed: true, //不固定
  102. maxmin: true,
  103. closeBtn: 1,
  104. shift: 5,
  105. shadeClose: false, //点击遮罩关闭层
  106. content: '../../jbsc/html/view_screening_results.html?isView=true&resultCode=' +code
  107. })
  108. },
  109. gotoSc:function(){
  110. console.log(this.planInfo,'sadddddddddddddddddd')
  111. top.layer.open({
  112. type: 2,
  113. area: ['820px', '648px'],
  114. shade: 0.5,
  115. title: 'ASCVD风险评估',
  116. fixed: true, //不固定
  117. maxmin: true,
  118. closeBtn:1,
  119. shift: 5,
  120. shadeClose: false, //点击遮罩关闭层
  121. content: '../../jbsc/html/questionnaire.html?fliter_code=6bcd306aaafb4e4381071346d86fadbb1'+'&fliter_title=ASCVD风险评估'+'&resident_code='+this.planInfo.patientCode+'&resident_name='+this.planInfo.patientName+'&sex='+this.planInfo.sex+'&age='+this.planInfo.age+'&idcard='+this.planInfo.idcard+'&mobile='+this.planInfo.mobile+"&surveyStatus=2"
  122. });
  123. },
  124. getList:function(){
  125. var vm=this
  126. console.log('211111111111111111111111',vm.planInfo)
  127. rehaAPI.getList({
  128. doctor: docInfo.code,
  129. diseaseType: vm.planInfo.disease,
  130. type: '',
  131. patientName: '',
  132. patientCode: this.patientCode,
  133. isDanger: '',
  134. pageNo: 1,
  135. pageSize: 1,
  136. filterType: 1,
  137. isAscvd: vm.planInfo.disease=='3'? 1:''
  138. }).then(function(res){
  139. vm.scList= res.data
  140. console.log(res,'dasssssssssssssssssss')
  141. })
  142. },
  143. // 刷新
  144. refresh: function(){
  145. this.planSchedule();
  146. this.timeAxis();
  147. },
  148. // 获取服务医生列表
  149. selectPlanServerDoctor: function(){
  150. var vm = this,
  151. params = {
  152. planId: vm.planId
  153. }
  154. rehaAPI.selectPlanServerDoctor(params).then(function(res){
  155. if(res.status==200){
  156. vm.docList = res.data
  157. }else{
  158. layer.msg(res.msg,{icon:5});
  159. }
  160. })
  161. },
  162. //获取计划表
  163. planSchedule:function(){
  164. var vm = this;
  165. var params = {
  166. planId: this.planId,
  167. patientCode: this.patientCode
  168. };
  169. rehaAPI.planSchedule(params).then(function(res){
  170. if(res.status == 200){
  171. vm.planInfo = res.data;
  172. vm.getList()
  173. vm.planInfo.tagClass = "tag-"+res.data.healthyConditionType;
  174. //patientImg:居民签名照/证件照,如果不为null的话说明居民已确认,显示康复完成明细
  175. if(vm.planInfo.status==2 && !vm.planInfo.patientImg){//任务全部完成时,显示完成提示框
  176. vm.showCompleteDailog();
  177. }else if(vm.planInfo.status==2 && vm.planInfo.patientImg){//居民已确认计划完成
  178. vm.tabStatus=3;
  179. $("#framePage").attr("src","stop_special_service.html?planids="+vm.planId+"&planStatus="+vm.planInfo.status)
  180. }
  181. vm.selectByMedicalCode(res.data.medicalRecordsCode)
  182. }else{
  183. layer.msg(res.msg,{icon:5});
  184. }
  185. })
  186. },
  187. // 获取住院病历
  188. selectByMedicalCode: function(medicalRecordsCode){
  189. var vm = this;
  190. var params = {
  191. medical: medicalRecordsCode
  192. };
  193. rehaAPI.selectByMedicalCode(params).then(function(res){
  194. if(res.status==200){
  195. vm.medicalRecordsList = res.data
  196. }else {
  197. showErrorMessage(res.msg);
  198. }
  199. })
  200. },
  201. // 查看住院病历详情
  202. viewMedicalDetail: function(o){
  203. var vm=this
  204. if(o.event){
  205. var loading = layer.load(0, {shade: false})
  206. recoverAPI.getPatientAccetokenByIdcard({idcard:vm.planInfo.idcard}).then(function(res){
  207. layer.close(loading)
  208. if(res.status==200){
  209. layer.open({
  210. type: 2,
  211. area: ['75%', '650px'],
  212. shade: 0.5,
  213. title: '住院病历',
  214. closeBtn: 1,
  215. shift: 5,
  216. shadeClose: false, //点击遮罩关闭层
  217. content: httpRequest.server+"profileweb/#/zhuyuan?patientCode="+res.data.patientCode+"&hospital="+docInfo.hospital+"&event="+o.event,
  218. });
  219. }else{
  220. showErrorMessage(res.msg);
  221. }
  222. })
  223. }else{
  224. layer.open({
  225. type: 2,
  226. area: ['600px', '600px'],
  227. shade: 0.5,
  228. title: '住院病历详情',
  229. fixed: true, //不固定
  230. maxmin: true,
  231. closeBtn:1,
  232. shift: 5,
  233. shadeClose: false, //点击遮罩关闭层
  234. content: '../../rehabilitation/html/medical-records-detail.html?medicalRecordsCode='+ o.code,
  235. });
  236. }
  237. },
  238. formatter: function(time){
  239. return new Date(time).format('yyyy-MM-dd')
  240. },
  241. // 获取最新的诊疗消息
  242. findDiagnosisInformationByPlanId: function() {
  243. var vm = this,
  244. loading = layer.load(0, {shade: false}),
  245. params = {
  246. planId: vm.planId
  247. }
  248. recoverAPI.findDiagnosisInformationByPlanId(params).then(function(res) {
  249. layer.close(loading)
  250. if(res.status == 200) {
  251. vm.diagnosisInformation = res.data
  252. } else {
  253. showErrorMessage(res.msg);
  254. }
  255. })
  256. },
  257. serviceDoctorList:function(){
  258. var vm = this;
  259. rehaAPI.serviceDoctorList({patientCode: this.patientCode}).then(function(res){
  260. if(res.status == 200){
  261. vm.docList = res.data;
  262. }else{
  263. layer.msg(res.msg,{icon:5});
  264. }
  265. })
  266. },
  267. weiXinConfirmClick:function(){
  268. var vm = this;
  269. rehaAPI.sendWxMsg({planId: this.planId}).then(function(res){
  270. if(res.status == 200){
  271. layer.msg("发送成功,等待居民确认");
  272. setTimeout(function(){
  273. vm.tabStatus=3;
  274. $("#framePage").attr("src","stop_special_service.html?planids="+vm.planId+"&planStatus="+vm.planInfo.status)
  275. },1000)
  276. }else{
  277. layer.msg(res.msg,{icon:5});
  278. }
  279. })
  280. },
  281. setImgSrc: function (src) {
  282. var str = httpRequest.getImgUrl(src)
  283. return str
  284. },
  285. showCompleteDailog:function(){
  286. 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>', {
  287. btn: [],
  288. area: ["400px", "340px"],
  289. title: "完成提示"
  290. }, function (index) {
  291. // layer.close(index);
  292. });
  293. },
  294. refreshPage:function(){
  295. if(!this.planId){
  296. layer.msg('未传入计划id(planId)',{icon:2})
  297. return ;
  298. }
  299. this.goToLoadData(true);
  300. },
  301. bindEvents:function(){
  302. var vm = this;
  303. $("body").on("click",".div-patient-comfirm",function(){
  304. layer.closeAll();
  305. vm.weiXinConfirmClick();
  306. }).on("click", ".div-patient-home", function() {
  307. location.href = "../../recover/html/personal-manage.html?patientCode=" + vm.patientCode+'&planId='+vm.planId
  308. })
  309. },
  310. viewDetail:function(planids,type,item){
  311. var vm=this;
  312. console.log(planids,type,item,'dsaaaaaaa')
  313. if(!planids){
  314. layer.msg('无服务项',{icon:5})
  315. return ;
  316. }
  317. if(vm.planInfo.disease=='3'&&vm.scList.length==0&&item&&item.code=='6'&&vm.loginDoctor.doctorType!='1'){
  318. this.$confirm('提示该居民近一年没有进行冠心病风险评估,请先进行评估,再进行随访登记', '提示', {
  319. confirmButtonText: '确定',
  320. cancelButtonText: '取消',
  321. type: 'warning'
  322. }).then(function(){
  323. vm.gotoSc()
  324. })
  325. return false
  326. }
  327. if(type==1){ // 单个服务项
  328. layer.open({
  329. type: 2,
  330. area: ['800px', '700px'],
  331. shade: 0.5,
  332. title: '服务项目内容',
  333. fixed: true, //不固定
  334. maxmin: true,
  335. closeBtn:1,
  336. shift: 5,
  337. shadeClose: false, //点击遮罩关闭层
  338. content: '../../rehabilitation/html/guide_the_message.html?planid='+planids+'&pId='+httpData['planId']+'&patient='+vm.patientCode+'&patientName='+vm.planInfo.patientName,
  339. end:function(){
  340. vm.goToLoadData(true);
  341. }
  342. });
  343. return ;
  344. }
  345. layer.open({ // 康复计划的所有服务项
  346. type: 2,
  347. area: ['800px', '700px'],
  348. shade: 0.5,
  349. title: '服务项目内容',
  350. fixed: true, //不固定
  351. maxmin: true,
  352. closeBtn:1,
  353. shift: 5,
  354. shadeClose: false, //点击遮罩关闭层
  355. content: '../../rehabilitation/html/service_item_content.html?planids='+planids+'&planId='+httpData['planId']+'&patient='+vm.patientCode+'&patientName='+vm.planInfo.patientName+'&disease='+vm.planInfo.disease+'&scLenght='+vm.scList.length,
  356. end:function(){
  357. vm.goToLoadData(true);
  358. }
  359. });
  360. },
  361. changeStatus:function(val){
  362. this.status=val.code;
  363. console.log('this.status', this.status)
  364. },
  365. changeTask:function(val){
  366. this.searchTask=val.code;
  367. this.searchTaskName=val.name;
  368. },
  369. monDetail:function(){
  370. this.currentDay = this.ynow + '年'+ (this.mnow + 1) +'月';
  371. this.currentDayForEn=this.ynow+'/'+(this.mnow>=9?(this.mnow+1):"0"+(this.mnow+1))+'/'+(this.dnow>=9?this.dnow:"0"+this.dnow)
  372. },
  373. is_leap:function(year) { //判断是否为闰年
  374. return (year%100==0?res=(year%400==0?1:0):res=(year%4==0?1:0));
  375. },
  376. preMonth:function(){ //上一个月
  377. if(this.mnow<=0){
  378. this.mnow=11;
  379. this.ynow=this.ynow-1;
  380. }else{
  381. this.mnow--;
  382. }
  383. this.monDetail();
  384. this.goToLoadData(true);
  385. },
  386. getPreMouth:function(){
  387. var pMnow,pYnow;
  388. if(this.mnow<=0){
  389. pMnow=11;
  390. pYnow=this.ynow-1;
  391. }else{
  392. pMnow=this.mnow-1;
  393. pYnow=this.ynow;
  394. }
  395. var m_days=new Array(31,(28+this.is_leap(pYnow)),31,30,31,30,31,31,30,31,30,31); //每个月的天数
  396. return {
  397. days:m_days[pMnow],
  398. date:pYnow+'-'+(++pMnow>=10?pMnow:"0"+pMnow)
  399. }
  400. },
  401. nextMonth:function(){ //下一个月
  402. if(this.mnow>=11){
  403. this.mnow=0;
  404. this.ynow=this.ynow+1;
  405. }else{
  406. this.mnow++;
  407. }
  408. this.monDetail();
  409. this.goToLoadData(true);
  410. },
  411. getNextMouth:function(){
  412. var nMnow,nYnow;
  413. if(this.mnow>=11){
  414. nMnow=0;
  415. nYnow=this.ynow+1;
  416. }else{
  417. nMnow=this.mnow+1;
  418. nYnow=this.ynow;
  419. }
  420. var m_days=new Array(31,(28+this.is_leap(nYnow)),31,30,31,01,31,31,30,31,30,31); //每个月的天数
  421. return {
  422. days:m_days[nMnow],
  423. date:nYnow+'-'+(++nMnow>=10?nMnow:"0"+nMnow)
  424. }
  425. },
  426. goToLoadData:function(flag){//flag是否更新数据
  427. this.tabStatus==1 && (!this.calendarData.length || flag) && this.calendar();
  428. this.tabStatus==2 && (!this.timeAxisData.length || flag) && this.timeAxis();
  429. // this.changeSearch(-1)
  430. },
  431. calendar:function(){
  432. var nlstr = new Date(this.ynow,this.mnow,1); //当月第一天
  433. var firstday = nlstr.getDay()-1;//第一天星期几,默认是周日 我们改成周一
  434. firstday=firstday==-1?6:firstday;//如果是-1,说明当月的第一天是周日
  435. var m_days=new Array(31,(28+this.is_leap(this.ynow)),31,30,31,30,31,31,30,31,30,31); //每个月的天数
  436. var tr_str=Math.ceil((m_days[this.mnow] + firstday)/7); //当前月天数+第一天是星期几的数值 获得 表格行数
  437. var c_days=m_days[this.mnow];//当前月份的天数
  438. var p_arr=this.getPreMouth();
  439. var n_arr=this.getNextMouth();
  440. var i,k,idx,date_str;
  441. var dataArr=[];//天数/年月
  442. for(i=0;i<tr_str;i++) { //表格的行
  443. for(k=0;k<7;k++) { //表格每行的单元格
  444. idx=i*7+k; //单元格自然序列号
  445. date_str=idx-firstday+1; //计算日期
  446. var __ym;
  447. if(date_str<=0){//过滤无效日期(小于等于零的、大于月总天数的)
  448. date_str=date_str+p_arr['days'];//当前日期+上个月的天数就是上个月的日期
  449. __ym=p_arr['date'];
  450. }else if(date_str>c_days){
  451. date_str=date_str-c_days;//下个月的日期就是这个月的天数-当月的天数
  452. __ym=n_arr['date'];
  453. }else{
  454. __ym=this.ynow+'-'+(this.mnow>=9?"":"0")+(this.mnow+1);
  455. }
  456. dataArr.push({
  457. day:date_str,
  458. date:__ym
  459. });
  460. }
  461. }
  462. this.__Data=dataArr;
  463. this.monDetail();
  464. this.calenderPlanDetail();
  465. },
  466. daysSort: function(arr) {
  467. var getArr = JSON.parse(JSON.stringify(arr)),
  468. returnArr = []
  469. for(var i = 1; i < 31; i++) {
  470. for(var j = 0, len = getArr.length; j < len; j++) {
  471. var stri = i > 9 + '' ? i : '0'+i
  472. if(getArr[j].day == stri) {
  473. returnArr.push(getArr[j])
  474. getArr.splice(j,1)
  475. break;
  476. }
  477. }
  478. }
  479. return returnArr
  480. },
  481. // 日历有计划数据处理
  482. planHandleData: function(data, day, mounth) {
  483. var item = data;
  484. item.day = day;
  485. if(mounth) {item.mounth = mounth}
  486. var finishFlag=false
  487. var sFlag=false;
  488. var fFlag=false;
  489. if(item.specialist){
  490. if(item.specialist.all==item.specialist.finish){
  491. sFlag=true;
  492. }
  493. }else{
  494. sFlag = true;
  495. }
  496. if(item.family){
  497. if(item.family.all==item.family.finish){
  498. fFlag = true;
  499. }
  500. }else{
  501. fFlag = true;
  502. }
  503. finishFlag = sFlag && fFlag;
  504. item.finishFlag=finishFlag;
  505. return item
  506. },
  507. // 日历请求
  508. calenderPlanDetail:function(){
  509. var vm=this;
  510. var __days=vm.__Data;
  511. var lastDay=(__days.concat()).pop().day;
  512. lastDay=lastDay>9?lastDay:'0'+lastDay;
  513. if(vm.searchTask != '' || vm.status != '') {
  514. vm.isFastSearch = true
  515. } else {
  516. vm.isFastSearch = false
  517. }
  518. var params={
  519. executeStartTime: vm.isFastSearch ? '' : __days[0].date+'-'+__days[0].day+' 00:00:00',//日历开始时间(格式:yyyy-MM-dd HH:mm:ss)
  520. executeEndTime: vm.isFastSearch ? '' : (__days.concat()).pop().date+'-'+lastDay+' 23:59:59',//日历结束时间(格式:yyyy-MM-dd HH:mm:ss)
  521. planId:vm.planId,//计划id
  522. searchTask:vm.searchTask,//快速查找任务:(1、我的任务,2、健康教育,3、健康指导,4、随访)
  523. status:vm.status,//任务状态(0未完成,1已完成,2已预约)
  524. }
  525. rehaAPI.calendarPlanDetail(params).then(function(res){
  526. vm.curTask=vm.searchTask;
  527. vm.curTaskName=vm.searchTaskName;
  528. vm.calendarData=[];
  529. var list = [];
  530. if(res.status==200){
  531. var data=res.data
  532. // 快速查找
  533. if(vm.isFastSearch) {
  534. vm.searchData = []
  535. var searchData0 = [],
  536. searchData1 = [],
  537. searchData2 = [];
  538. for(var setM = 1; setM <= 12; setM++) {
  539. var _setM = setM > 9 ? setM : '0' + setM,
  540. _setY = new Date().getFullYear();
  541. var data0 = [],
  542. data1 = [],
  543. data2 = [];
  544. for(var i in data) {
  545. var getY = i.split("-")[0],
  546. getM = i.split("-")[1],
  547. getD = i.split("-")[2];
  548. // 去年
  549. if(_setY - 1 == getY && _setM == getM) {
  550. var item = vm.planHandleData(data[i], getD, getM)
  551. data0.push(item)
  552. data.length && data.splice(i,1);
  553. } else if(_setY == getY && _setM == getM) { // 今年
  554. var item = vm.planHandleData(data[i], getD, getM)
  555. data1.push(item)
  556. data.length && data.splice(i,1);
  557. } else if(_setY + 1 == getY && _setM == getM) { // 明年
  558. var item = vm.planHandleData(data[i], getD, getM)
  559. data2.push(item)
  560. data.length && data.splice(i,1);
  561. }
  562. }
  563. if(data0.length) {
  564. var dataSort = vm.daysSort(data0)
  565. var addlen = (dataSort.length + 1) % 7 ? (dataSort.length + 1) % 7 : 7
  566. for(var i = 0; i < 7 - addlen; i++) {
  567. dataSort.push({
  568. noService:true
  569. })
  570. }
  571. searchData0.push(dataSort)
  572. }
  573. if(data1.length) {
  574. var dataSort = vm.daysSort(data1)
  575. var addlen = (dataSort.length + 1) % 7 ? (dataSort.length + 1) % 7 : 7
  576. for(var i = 0; i < 7 - addlen; i++) {
  577. dataSort.push({
  578. noService:true
  579. })
  580. }
  581. searchData1.push(dataSort)
  582. }
  583. if(data2.length) {
  584. var dataSort = vm.daysSort(data2)
  585. var addlen = (dataSort.length + 1) % 7 ? (dataSort.length + 1) % 7 : 7
  586. for(var i = 0; i < 7 - addlen; i++) {
  587. dataSort.push({
  588. noService:true
  589. })
  590. }
  591. searchData2.push(dataSort)
  592. }
  593. }
  594. if(searchData0.length) {vm.searchData.push(searchData0)}
  595. if(searchData1.length) {vm.searchData.push(searchData1)}
  596. if(searchData2.length) {vm.searchData.push(searchData2)}
  597. return false;
  598. }
  599. // 正常日历
  600. var _currentTimeStamp=+new Date(new Date().setHours(0, 0, 0, 0));
  601. for(var i in __days){
  602. var _key=__days[i].date+'-'+(__days[i].day>9?__days[i].day:'0'+__days[i].day);
  603. var item={
  604. noService:true,
  605. day:__days[i].day
  606. };
  607. for(var j in data){
  608. if(_key==j){
  609. item = vm.planHandleData(data[j], __days[i].day)
  610. data.length && data.splice(j,1);
  611. break;
  612. }
  613. }
  614. var thatTime=+new Date(_key)-8*60*60*1000;
  615. var future=_currentTimeStamp>thatTime?0:(_currentTimeStamp==thatTime?1:2);
  616. item.future=future;
  617. list.push(item);
  618. // vm.calendarData.push(item);
  619. }
  620. vm.calendarData = _.chunk(list, 7)
  621. }
  622. })
  623. },
  624. // 时间轴请求
  625. timeAxis:function(){
  626. var m_days=new Array(31,(28+this.is_leap(this.ynow)),31,30,31,30,31,31,30,31,30,31); //每个月的天数
  627. var c_days=m_days[this.mnow];//当前月份的天数
  628. var __ym=this.ynow+'-'+(this.mnow>=9?"":"0")+(this.mnow+1);
  629. var dataArr=[];//天数/年月
  630. for(;c_days>0;c_days--){
  631. dataArr.push({
  632. day:c_days,
  633. date:__ym
  634. });
  635. }
  636. this.__xData=dataArr;
  637. this.monDetail();
  638. this.calendarPlanDetailList();
  639. this.calendarPlanDetailItems();
  640. },
  641. //时间轴请求
  642. calendarPlanDetailList:function(){
  643. var vm=this;
  644. var __days=vm.__xData;
  645. var lastDay=(__days.concat()).pop().day;
  646. lastDay=lastDay>9?lastDay:'0'+lastDay;
  647. var params={
  648. executeEndTime:__days[0].date+'-'+__days[0].day+' 23:59:59',//日历开始时间(格式:yyyy-MM-dd HH:mm:ss)
  649. executeStartTime:(__days.concat()).pop().date+'-'+lastDay+' 00:00:00',//日历结束时间(格式:yyyy-MM-dd HH:mm:ss)
  650. planId:vm.planId,//计划id
  651. searchTask:vm.searchTask,//快速查找任务:(1、我的任务,2、随访,3、复诊,4、健康教育)
  652. status:vm.status,//任务状态(0未完成,1已完成,2已预约)
  653. }
  654. rehaAPI.calendarPlanDetailList(params).then(function(res){
  655. if(res.status==200){
  656. // var _currentTimeStamp=+new Date(new Date().setHours(0, 0, 0, 0))
  657. var list=_.map(res.data||{},function(o){
  658. // var _time=o.executeTime.split(' ');
  659. // var thatTime=+new Date(_time[0]);
  660. // var future=_currentTimeStamp>thatTime?0:(_currentTimeStamp==thatTime?1:2);
  661. // (o.status==0 && _currentTimeStamp>thatTime) && (future=-1)
  662. // var _html=o.status==2?'预':(future==-1?'逾':'');
  663. // _html=future==1?'今':_html;
  664. // if(_html=='预') future=3;
  665. var _time=o.executeTime.split(' ');
  666. var _html = ''
  667. var d = new Date(o.execute_time);
  668. if(d.format("yyyy-MM-dd") == new Date().format("yyyy-MM-dd")) {
  669. o.firstSort = '1'
  670. future = 1
  671. _html = '今'
  672. if(o.status) {
  673. o.secondSort = '2'
  674. } else {
  675. o.secondSort = '1'
  676. }
  677. } else if(d > new Date()) {
  678. o.firstSort = '3'
  679. future = 2
  680. if(o.status) {
  681. o.secondSort = '2'
  682. } else {
  683. o.secondSort = '1'
  684. }
  685. } else {
  686. o.firstSort = '2'
  687. future = 0
  688. if(o.status == 0) {
  689. future = -1
  690. _html = '逾'
  691. o.secondSort = '1'
  692. } else {
  693. o.secondSort = '2'
  694. }
  695. }
  696. o.html=_html
  697. o.date=_time[0];
  698. o.time=_time[1];
  699. o.future=future;
  700. o.doctorName = o.doctor_name
  701. o.hospitalName = o.hospital_name
  702. return o;
  703. })||[];
  704. var nowTime = new Date().getTime()
  705. vm.timeAxisData = _.sortBy(list, function(o) {
  706. return o.firstSort + o.secondSort + (nowTime/o.execute_time)
  707. });
  708. }
  709. })
  710. },
  711. viewServerItemsDetail: function(o){
  712. console.log("o",o);
  713. if(o.code=='2'){
  714. showInfoMessage('请从“消息-患者消息列表”中查看患者的康复咨询记录')
  715. return
  716. }
  717. if(o.code=='3'){
  718. layer.open({
  719. type: 2,
  720. area: ['700px', '700px'],
  721. shade: 0.5,
  722. title: '健康记录',
  723. fixed: true, //不固定
  724. maxmin: true,
  725. closeBtn: 1,
  726. // shift: 5,
  727. shadeClose: false, //点击遮罩关闭层
  728. content: '../html/healthMonitor.html?patient=' + this.patientCode
  729. })
  730. return
  731. }
  732. this.serverItemInfo = o
  733. this.showServerItemDetail = true
  734. this.islimit = o.frequency_code?true:false
  735. },
  736. calendarPlanDetailItems: function(){
  737. var vm=this;
  738. var __days=vm.__xData;
  739. var lastDay=(__days.concat()).pop().day;
  740. lastDay=lastDay>9?lastDay:'0'+lastDay;
  741. var params={
  742. executeEndTime:__days[0].date+'-'+__days[0].day+' 23:59:59',//日历开始时间(格式:yyyy-MM-dd HH:mm:ss)
  743. executeStartTime:(__days.concat()).pop().date+'-'+lastDay+' 00:00:00',//日历结束时间(格式:yyyy-MM-dd HH:mm:ss)
  744. planId:vm.planId,//计划id
  745. searchTask:vm.searchTask,//快速查找任务:(1、我的任务,2、随访,3、复诊,4、健康教育)
  746. status:vm.status,//任务状态(0未完成,1已完成,2已预约)
  747. }
  748. rehaAPI.calendarPlanDetailItems(params).then(function(res){
  749. if(res.status==200){
  750. var arr = []
  751. $.each(res.data, function(i, o){
  752. if(o.code=='3'&&o.type){
  753. if(o.type==2){
  754. o.levelClazz = vm.getLevelClazz(o.value1, 139, 90) || vm.getLevelClazz(o.value2, 89, 60)
  755. o.levelClazz1 = vm.getLevelClazz(o.value1, 139, 90)
  756. o.levelClazz2 = vm.getLevelClazz(o.value2, 89, 60)
  757. o.levelClazz3 = vm.getLevelClazz(o.value3, 100, 60)
  758. } else {
  759. var num = parseInt(o.value2)
  760. var max = normalLevel[num][0],
  761. min = normalLevel[num][1];
  762. o.levelClazz1 = vm.getLevelClazz(o.value1, max, min)
  763. o.levelName = xuetangDuring[o.value2]
  764. }
  765. }
  766. arr.push(o)
  767. })
  768. vm.limitlessItems = arr
  769. }
  770. })
  771. },
  772. getLevelClazz: function(value,max,min) {
  773. if(!value||(!max && !min)) {
  774. return '';
  775. }
  776. var value = parseFloat(value);
  777. if(value < min) {
  778. return 'low';
  779. } else if(value > max) {
  780. return 'high';
  781. } else {
  782. return ''
  783. }
  784. },
  785. getNormalLevel: function(index) {
  786. return [
  787. [],
  788. [7, 4],
  789. [11.1, 4],
  790. [7, 4],
  791. [11.1, 4],
  792. [7, 4],
  793. [11.1, 4],
  794. [7, 4]
  795. ][index];
  796. },
  797. confirmSearch: function(){
  798. this.changeSearch(-1)
  799. this.goToLoadData(true)
  800. },
  801. changeSearch: function(status) {
  802. var i = status == 1 ? -400 : 0;
  803. var timer1 = setInterval(function() {
  804. i += (5 * status)
  805. $(".search-left").css("right", i + "px")
  806. if(status == 1 && i >= 0) {
  807. clearInterval(timer1)
  808. }
  809. if(status == -1 && i <= -400) {
  810. clearInterval(timer1)
  811. }
  812. }, 5)
  813. },
  814. //邀请视频聊天
  815. openVideoChat: function(otherDoc){
  816. var vm = this;
  817. var loading = layer.load(0);
  818. var participants = []
  819. var participantsMobile = {}
  820. //发起人
  821. participants.push({mobile: docInfo.mobile, name: docInfo.name, sex: docInfo.sex==1? 1 : 2, birthdate: "", level: 3, hospital_name: docInfo.hospitalName, idcard: ""});
  822. participantsMobile[docInfo.mobile] = 1;
  823. if(otherDoc){
  824. //被邀请人
  825. participants.push({
  826. mobile: otherDoc.doctorMobile,
  827. name: otherDoc.doctorName,
  828. sex: otherDoc.doctorSex==1? 1 : 2,
  829. birthdate: "",
  830. level: 3,
  831. hospital_name: otherDoc.doctorHospitalName,
  832. idcard: otherDoc.doctorIdcard})
  833. participantsMobile[otherDoc.doctorMobile] = 0;
  834. }
  835. videoChatAPI.addDoctor({participants : JSON.stringify(participants)}).then(function(res){
  836. if(res.status == 200){
  837. videoChatAPI.sessions({
  838. sessionId: httpRequest.uuid(24, 16),
  839. sessionType: 4,
  840. sessionName: vm.planInfo.patientName +"的远程门诊",
  841. participants: JSON.stringify(participantsMobile),
  842. videoconferencing: 1,
  843. idcard: vm.planInfo.idcard
  844. }).then(function(res1){
  845. layer.close(loading)
  846. if(res1.status == 200){
  847. layer.msg("发起会话成功",{icon:6});
  848. } else{
  849. layer.msg("发起会话失败",{icon:5});
  850. }
  851. }).catch(function(){
  852. layer.close(loading)
  853. layer.msg("系统繁忙",{icon:5});
  854. })
  855. }else{
  856. layer.close(loading)
  857. layer.msg(res.msg,{icon:5});
  858. }
  859. }).catch(function(){
  860. layer.close(loading)
  861. layer.msg("系统繁忙",{icon:5});
  862. })
  863. }
  864. },
  865. watch:{
  866. tabStatus:function(){
  867. this.goToLoadData();
  868. }
  869. }
  870. })
  871. }();