rehabilitation_management.js 23 KB

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