rehabilitation_management.js 25 KB

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