rehabilitation_management.js 27 KB

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