rehabilitation_management.js 28 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875
  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){
  311. var vm=this;
  312. if(!planids){
  313. layer.msg('无服务项',{icon:5})
  314. return ;
  315. }
  316. if(type==1){ // 单个服务项
  317. layer.open({
  318. type: 2,
  319. area: ['800px', '700px'],
  320. shade: 0.5,
  321. title: '服务项目内容',
  322. fixed: true, //不固定
  323. maxmin: true,
  324. closeBtn:1,
  325. shift: 5,
  326. shadeClose: false, //点击遮罩关闭层
  327. content: '../../rehabilitation/html/guide_the_message.html?planid='+planids+'&pId='+httpData['planId']+'&patient='+vm.patientCode+'&patientName='+vm.planInfo.patientName,
  328. end:function(){
  329. vm.goToLoadData(true);
  330. }
  331. });
  332. return ;
  333. }
  334. layer.open({ // 康复计划的所有服务项
  335. type: 2,
  336. area: ['800px', '700px'],
  337. shade: 0.5,
  338. title: '服务项目内容',
  339. fixed: true, //不固定
  340. maxmin: true,
  341. closeBtn:1,
  342. shift: 5,
  343. shadeClose: false, //点击遮罩关闭层
  344. content: '../../rehabilitation/html/service_item_content.html?planids='+planids+'&planId='+httpData['planId']+'&patient='+vm.patientCode+'&patientName='+vm.planInfo.patientName,
  345. end:function(){
  346. vm.goToLoadData(true);
  347. }
  348. });
  349. },
  350. changeStatus:function(val){
  351. this.status=val.code;
  352. console.log('this.status', this.status)
  353. },
  354. changeTask:function(val){
  355. this.searchTask=val.code;
  356. this.searchTaskName=val.name;
  357. },
  358. monDetail:function(){
  359. this.currentDay = this.ynow + '年'+ (this.mnow + 1) +'月';
  360. this.currentDayForEn=this.ynow+'/'+(this.mnow>=9?(this.mnow+1):"0"+(this.mnow+1))+'/'+(this.dnow>=9?this.dnow:"0"+this.dnow)
  361. },
  362. is_leap:function(year) { //判断是否为闰年
  363. return (year%100==0?res=(year%400==0?1:0):res=(year%4==0?1:0));
  364. },
  365. preMonth:function(){ //上一个月
  366. if(this.mnow<=0){
  367. this.mnow=11;
  368. this.ynow=this.ynow-1;
  369. }else{
  370. this.mnow--;
  371. }
  372. this.monDetail();
  373. this.goToLoadData(true);
  374. },
  375. getPreMouth:function(){
  376. var pMnow,pYnow;
  377. if(this.mnow<=0){
  378. pMnow=11;
  379. pYnow=this.ynow-1;
  380. }else{
  381. pMnow=this.mnow-1;
  382. pYnow=this.ynow;
  383. }
  384. var m_days=new Array(31,(28+this.is_leap(pYnow)),31,30,31,30,31,31,30,31,30,31); //每个月的天数
  385. return {
  386. days:m_days[pMnow],
  387. date:pYnow+'-'+(++pMnow>=10?pMnow:"0"+pMnow)
  388. }
  389. },
  390. nextMonth:function(){ //下一个月
  391. if(this.mnow>=11){
  392. this.mnow=0;
  393. this.ynow=this.ynow+1;
  394. }else{
  395. this.mnow++;
  396. }
  397. this.monDetail();
  398. this.goToLoadData(true);
  399. },
  400. getNextMouth:function(){
  401. var nMnow,nYnow;
  402. if(this.mnow>=11){
  403. nMnow=0;
  404. nYnow=this.ynow+1;
  405. }else{
  406. nMnow=this.mnow+1;
  407. nYnow=this.ynow;
  408. }
  409. var m_days=new Array(31,(28+this.is_leap(nYnow)),31,30,31,01,31,31,30,31,30,31); //每个月的天数
  410. return {
  411. days:m_days[nMnow],
  412. date:nYnow+'-'+(++nMnow>=10?nMnow:"0"+nMnow)
  413. }
  414. },
  415. goToLoadData:function(flag){//flag是否更新数据
  416. this.tabStatus==1 && (!this.calendarData.length || flag) && this.calendar();
  417. this.tabStatus==2 && (!this.timeAxisData.length || flag) && this.timeAxis();
  418. // this.changeSearch(-1)
  419. },
  420. calendar:function(){
  421. var nlstr = new Date(this.ynow,this.mnow,1); //当月第一天
  422. var firstday = nlstr.getDay()-1;//第一天星期几,默认是周日 我们改成周一
  423. firstday=firstday==-1?6:firstday;//如果是-1,说明当月的第一天是周日
  424. var m_days=new Array(31,(28+this.is_leap(this.ynow)),31,30,31,30,31,31,30,31,30,31); //每个月的天数
  425. var tr_str=Math.ceil((m_days[this.mnow] + firstday)/7); //当前月天数+第一天是星期几的数值 获得 表格行数
  426. var c_days=m_days[this.mnow];//当前月份的天数
  427. var p_arr=this.getPreMouth();
  428. var n_arr=this.getNextMouth();
  429. var i,k,idx,date_str;
  430. var dataArr=[];//天数/年月
  431. for(i=0;i<tr_str;i++) { //表格的行
  432. for(k=0;k<7;k++) { //表格每行的单元格
  433. idx=i*7+k; //单元格自然序列号
  434. date_str=idx-firstday+1; //计算日期
  435. var __ym;
  436. if(date_str<=0){//过滤无效日期(小于等于零的、大于月总天数的)
  437. date_str=date_str+p_arr['days'];//当前日期+上个月的天数就是上个月的日期
  438. __ym=p_arr['date'];
  439. }else if(date_str>c_days){
  440. date_str=date_str-c_days;//下个月的日期就是这个月的天数-当月的天数
  441. __ym=n_arr['date'];
  442. }else{
  443. __ym=this.ynow+'-'+(this.mnow>=9?"":"0")+(this.mnow+1);
  444. }
  445. dataArr.push({
  446. day:date_str,
  447. date:__ym
  448. });
  449. }
  450. }
  451. this.__Data=dataArr;
  452. this.monDetail();
  453. this.calenderPlanDetail();
  454. },
  455. daysSort: function(arr) {
  456. var getArr = JSON.parse(JSON.stringify(arr)),
  457. returnArr = []
  458. for(var i = 1; i < 31; i++) {
  459. for(var j = 0, len = getArr.length; j < len; j++) {
  460. var stri = i > 9 + '' ? i : '0'+i
  461. if(getArr[j].day == stri) {
  462. returnArr.push(getArr[j])
  463. getArr.splice(j,1)
  464. break;
  465. }
  466. }
  467. }
  468. return returnArr
  469. },
  470. // 日历有计划数据处理
  471. planHandleData: function(data, day, mounth) {
  472. var item = data;
  473. item.day = day;
  474. if(mounth) {item.mounth = mounth}
  475. var finishFlag=false
  476. var sFlag=false;
  477. var fFlag=false;
  478. if(item.specialist){
  479. if(item.specialist.all==item.specialist.finish){
  480. sFlag=true;
  481. }
  482. }else{
  483. sFlag = true;
  484. }
  485. if(item.family){
  486. if(item.family.all==item.family.finish){
  487. fFlag = true;
  488. }
  489. }else{
  490. fFlag = true;
  491. }
  492. finishFlag = sFlag && fFlag;
  493. item.finishFlag=finishFlag;
  494. return item
  495. },
  496. // 日历请求
  497. calenderPlanDetail:function(){
  498. var vm=this;
  499. var __days=vm.__Data;
  500. var lastDay=(__days.concat()).pop().day;
  501. lastDay=lastDay>9?lastDay:'0'+lastDay;
  502. if(vm.searchTask != '' || vm.status != '') {
  503. vm.isFastSearch = true
  504. } else {
  505. vm.isFastSearch = false
  506. }
  507. var params={
  508. executeStartTime: vm.isFastSearch ? '' : __days[0].date+'-'+__days[0].day+' 00:00:00',//日历开始时间(格式:yyyy-MM-dd HH:mm:ss)
  509. executeEndTime: vm.isFastSearch ? '' : (__days.concat()).pop().date+'-'+lastDay+' 23:59:59',//日历结束时间(格式:yyyy-MM-dd HH:mm:ss)
  510. planId:vm.planId,//计划id
  511. searchTask:vm.searchTask,//快速查找任务:(1、我的任务,2、健康教育,3、健康指导,4、随访)
  512. status:vm.status,//任务状态(0未完成,1已完成,2已预约)
  513. }
  514. rehaAPI.calendarPlanDetail(params).then(function(res){
  515. vm.curTask=vm.searchTask;
  516. vm.curTaskName=vm.searchTaskName;
  517. vm.calendarData=[];
  518. var list = [];
  519. if(res.status==200){
  520. var data=res.data
  521. // 快速查找
  522. if(vm.isFastSearch) {
  523. vm.searchData = []
  524. var searchData0 = [],
  525. searchData1 = [],
  526. searchData2 = [];
  527. for(var setM = 1; setM <= 12; setM++) {
  528. var _setM = setM > 9 ? setM : '0' + setM,
  529. _setY = new Date().getFullYear();
  530. var data0 = [],
  531. data1 = [],
  532. data2 = [];
  533. for(var i in data) {
  534. var getY = i.split("-")[0],
  535. getM = i.split("-")[1],
  536. getD = i.split("-")[2];
  537. // 去年
  538. if(_setY - 1 == getY && _setM == getM) {
  539. var item = vm.planHandleData(data[i], getD, getM)
  540. data0.push(item)
  541. data.length && data.splice(i,1);
  542. } else if(_setY == getY && _setM == getM) { // 今年
  543. var item = vm.planHandleData(data[i], getD, getM)
  544. data1.push(item)
  545. data.length && data.splice(i,1);
  546. } else if(_setY + 1 == getY && _setM == getM) { // 明年
  547. var item = vm.planHandleData(data[i], getD, getM)
  548. data2.push(item)
  549. data.length && data.splice(i,1);
  550. }
  551. }
  552. if(data0.length) {
  553. var dataSort = vm.daysSort(data0)
  554. var addlen = (dataSort.length + 1) % 7 ? (dataSort.length + 1) % 7 : 7
  555. for(var i = 0; i < 7 - addlen; i++) {
  556. dataSort.push({
  557. noService:true
  558. })
  559. }
  560. searchData0.push(dataSort)
  561. }
  562. if(data1.length) {
  563. var dataSort = vm.daysSort(data1)
  564. var addlen = (dataSort.length + 1) % 7 ? (dataSort.length + 1) % 7 : 7
  565. for(var i = 0; i < 7 - addlen; i++) {
  566. dataSort.push({
  567. noService:true
  568. })
  569. }
  570. searchData1.push(dataSort)
  571. }
  572. if(data2.length) {
  573. var dataSort = vm.daysSort(data2)
  574. var addlen = (dataSort.length + 1) % 7 ? (dataSort.length + 1) % 7 : 7
  575. for(var i = 0; i < 7 - addlen; i++) {
  576. dataSort.push({
  577. noService:true
  578. })
  579. }
  580. searchData2.push(dataSort)
  581. }
  582. }
  583. if(searchData0.length) {vm.searchData.push(searchData0)}
  584. if(searchData1.length) {vm.searchData.push(searchData1)}
  585. if(searchData2.length) {vm.searchData.push(searchData2)}
  586. return false;
  587. }
  588. // 正常日历
  589. var _currentTimeStamp=+new Date(new Date().setHours(0, 0, 0, 0));
  590. for(var i in __days){
  591. var _key=__days[i].date+'-'+(__days[i].day>9?__days[i].day:'0'+__days[i].day);
  592. var item={
  593. noService:true,
  594. day:__days[i].day
  595. };
  596. for(var j in data){
  597. if(_key==j){
  598. item = vm.planHandleData(data[j], __days[i].day)
  599. data.length && data.splice(j,1);
  600. break;
  601. }
  602. }
  603. var thatTime=+new Date(_key)-8*60*60*1000;
  604. var future=_currentTimeStamp>thatTime?0:(_currentTimeStamp==thatTime?1:2);
  605. item.future=future;
  606. list.push(item);
  607. // vm.calendarData.push(item);
  608. }
  609. vm.calendarData = _.chunk(list, 7)
  610. }
  611. })
  612. },
  613. // 时间轴请求
  614. timeAxis:function(){
  615. var m_days=new Array(31,(28+this.is_leap(this.ynow)),31,30,31,30,31,31,30,31,30,31); //每个月的天数
  616. var c_days=m_days[this.mnow];//当前月份的天数
  617. var __ym=this.ynow+'-'+(this.mnow>=9?"":"0")+(this.mnow+1);
  618. var dataArr=[];//天数/年月
  619. for(;c_days>0;c_days--){
  620. dataArr.push({
  621. day:c_days,
  622. date:__ym
  623. });
  624. }
  625. this.__xData=dataArr;
  626. this.monDetail();
  627. this.calendarPlanDetailList();
  628. this.calendarPlanDetailItems();
  629. },
  630. //时间轴请求
  631. calendarPlanDetailList:function(){
  632. var vm=this;
  633. var __days=vm.__xData;
  634. var lastDay=(__days.concat()).pop().day;
  635. lastDay=lastDay>9?lastDay:'0'+lastDay;
  636. var params={
  637. executeEndTime:__days[0].date+'-'+__days[0].day+' 23:59:59',//日历开始时间(格式:yyyy-MM-dd HH:mm:ss)
  638. executeStartTime:(__days.concat()).pop().date+'-'+lastDay+' 00:00:00',//日历结束时间(格式:yyyy-MM-dd HH:mm:ss)
  639. planId:vm.planId,//计划id
  640. searchTask:vm.searchTask,//快速查找任务:(1、我的任务,2、随访,3、复诊,4、健康教育)
  641. status:vm.status,//任务状态(0未完成,1已完成,2已预约)
  642. }
  643. rehaAPI.calendarPlanDetailList(params).then(function(res){
  644. if(res.status==200){
  645. // var _currentTimeStamp=+new Date(new Date().setHours(0, 0, 0, 0))
  646. var list=_.map(res.data||{},function(o){
  647. // var _time=o.executeTime.split(' ');
  648. // var thatTime=+new Date(_time[0]);
  649. // var future=_currentTimeStamp>thatTime?0:(_currentTimeStamp==thatTime?1:2);
  650. // (o.status==0 && _currentTimeStamp>thatTime) && (future=-1)
  651. // var _html=o.status==2?'预':(future==-1?'逾':'');
  652. // _html=future==1?'今':_html;
  653. // if(_html=='预') future=3;
  654. var _time=o.executeTime.split(' ');
  655. var _html = ''
  656. var d = new Date(o.execute_time);
  657. if(d.format("yyyy-MM-dd") == new Date().format("yyyy-MM-dd")) {
  658. o.firstSort = '1'
  659. future = 1
  660. _html = '今'
  661. if(o.status) {
  662. o.secondSort = '2'
  663. } else {
  664. o.secondSort = '1'
  665. }
  666. } else if(d > new Date()) {
  667. o.firstSort = '3'
  668. future = 2
  669. if(o.status) {
  670. o.secondSort = '2'
  671. } else {
  672. o.secondSort = '1'
  673. }
  674. } else {
  675. o.firstSort = '2'
  676. future = 0
  677. if(o.status == 0) {
  678. future = -1
  679. _html = '逾'
  680. o.secondSort = '1'
  681. } else {
  682. o.secondSort = '2'
  683. }
  684. }
  685. o.html=_html
  686. o.date=_time[0];
  687. o.time=_time[1];
  688. o.future=future;
  689. o.doctorName = o.doctor_name
  690. o.hospitalName = o.hospital_name
  691. return o;
  692. })||[];
  693. var nowTime = new Date().getTime()
  694. vm.timeAxisData = _.sortBy(list, function(o) {
  695. return o.firstSort + o.secondSort + (nowTime/o.execute_time)
  696. });
  697. }
  698. })
  699. },
  700. viewServerItemsDetail: function(o){
  701. console.log("o",o);
  702. if(o.code=='2'){
  703. showInfoMessage('请从“消息-患者消息列表”中查看患者的康复咨询记录')
  704. return
  705. }
  706. if(o.code=='3'){
  707. layer.open({
  708. type: 2,
  709. area: ['700px', '700px'],
  710. shade: 0.5,
  711. title: '健康记录',
  712. fixed: true, //不固定
  713. maxmin: true,
  714. closeBtn: 1,
  715. // shift: 5,
  716. shadeClose: false, //点击遮罩关闭层
  717. content: '../html/healthMonitor.html?patient=' + this.patientCode
  718. })
  719. return
  720. }
  721. this.serverItemInfo = o
  722. this.showServerItemDetail = true
  723. this.islimit = o.frequency_code?true:false
  724. },
  725. calendarPlanDetailItems: function(){
  726. var vm=this;
  727. var __days=vm.__xData;
  728. var lastDay=(__days.concat()).pop().day;
  729. lastDay=lastDay>9?lastDay:'0'+lastDay;
  730. var params={
  731. executeEndTime:__days[0].date+'-'+__days[0].day+' 23:59:59',//日历开始时间(格式:yyyy-MM-dd HH:mm:ss)
  732. executeStartTime:(__days.concat()).pop().date+'-'+lastDay+' 00:00:00',//日历结束时间(格式:yyyy-MM-dd HH:mm:ss)
  733. planId:vm.planId,//计划id
  734. searchTask:vm.searchTask,//快速查找任务:(1、我的任务,2、随访,3、复诊,4、健康教育)
  735. status:vm.status,//任务状态(0未完成,1已完成,2已预约)
  736. }
  737. rehaAPI.calendarPlanDetailItems(params).then(function(res){
  738. if(res.status==200){
  739. var arr = []
  740. $.each(res.data, function(i, o){
  741. if(o.code=='3'&&o.type){
  742. if(o.type==2){
  743. o.levelClazz = vm.getLevelClazz(o.value1, 139, 90) || vm.getLevelClazz(o.value2, 89, 60)
  744. o.levelClazz1 = vm.getLevelClazz(o.value1, 139, 90)
  745. o.levelClazz2 = vm.getLevelClazz(o.value2, 89, 60)
  746. o.levelClazz3 = vm.getLevelClazz(o.value3, 100, 60)
  747. } else {
  748. var num = parseInt(o.value2)
  749. var max = normalLevel[num][0],
  750. min = normalLevel[num][1];
  751. o.levelClazz1 = vm.getLevelClazz(o.value1, max, min)
  752. o.levelName = xuetangDuring[o.value2]
  753. }
  754. }
  755. arr.push(o)
  756. })
  757. vm.limitlessItems = arr
  758. }
  759. })
  760. },
  761. getLevelClazz: function(value,max,min) {
  762. if(!value||(!max && !min)) {
  763. return '';
  764. }
  765. var value = parseFloat(value);
  766. if(value < min) {
  767. return 'low';
  768. } else if(value > max) {
  769. return 'high';
  770. } else {
  771. return ''
  772. }
  773. },
  774. getNormalLevel: function(index) {
  775. return [
  776. [],
  777. [7, 4],
  778. [11.1, 4],
  779. [7, 4],
  780. [11.1, 4],
  781. [7, 4],
  782. [11.1, 4],
  783. [7, 4]
  784. ][index];
  785. },
  786. confirmSearch: function(){
  787. this.changeSearch(-1)
  788. this.goToLoadData(true)
  789. },
  790. changeSearch: function(status) {
  791. var i = status == 1 ? -400 : 0;
  792. var timer1 = setInterval(function() {
  793. i += (5 * status)
  794. $(".search-left").css("right", i + "px")
  795. if(status == 1 && i >= 0) {
  796. clearInterval(timer1)
  797. }
  798. if(status == -1 && i <= -400) {
  799. clearInterval(timer1)
  800. }
  801. }, 5)
  802. },
  803. //邀请视频聊天
  804. openVideoChat: function(otherDoc){
  805. var vm = this;
  806. var loading = layer.load(0);
  807. var participants = []
  808. var participantsMobile = {}
  809. //发起人
  810. participants.push({mobile: docInfo.mobile, name: docInfo.name, sex: docInfo.sex==1? 1 : 2, birthdate: "", level: 3, hospital_name: docInfo.hospitalName, idcard: ""});
  811. participantsMobile[docInfo.mobile] = 1;
  812. if(otherDoc){
  813. //被邀请人
  814. participants.push({
  815. mobile: otherDoc.doctorMobile,
  816. name: otherDoc.doctorName,
  817. sex: otherDoc.doctorSex==1? 1 : 2,
  818. birthdate: "",
  819. level: 3,
  820. hospital_name: otherDoc.doctorHospitalName,
  821. idcard: otherDoc.doctorIdcard})
  822. participantsMobile[otherDoc.doctorMobile] = 0;
  823. }
  824. videoChatAPI.addDoctor({participants : JSON.stringify(participants)}).then(function(res){
  825. if(res.status == 200){
  826. videoChatAPI.sessions({
  827. sessionId: httpRequest.uuid(24, 16),
  828. sessionType: 4,
  829. sessionName: vm.planInfo.patientName +"的远程门诊",
  830. participants: JSON.stringify(participantsMobile),
  831. videoconferencing: 1,
  832. idcard: vm.planInfo.idcard
  833. }).then(function(res1){
  834. layer.close(loading)
  835. if(res1.status == 200){
  836. layer.msg("发起会话成功",{icon:6});
  837. } else{
  838. layer.msg("发起会话失败",{icon:5});
  839. }
  840. }).catch(function(){
  841. layer.close(loading)
  842. layer.msg("系统繁忙",{icon:5});
  843. })
  844. }else{
  845. layer.close(loading)
  846. layer.msg(res.msg,{icon:5});
  847. }
  848. }).catch(function(){
  849. layer.close(loading)
  850. layer.msg("系统繁忙",{icon:5});
  851. })
  852. }
  853. },
  854. watch:{
  855. tabStatus:function(){
  856. this.goToLoadData();
  857. }
  858. }
  859. })
  860. }();