rehabilitation_management.js 24 KB

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