service_item_content.js 16 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554
  1. var httpData=GetRequest();
  2. var userInfo = JSON.parse(window.localStorage.getItem(httpRequest.agentName));
  3. var docInfo = JSON.parse(window.localStorage.getItem('wlyyAgent'));
  4. var previewLayerIndex, followupLayerIndex, KFZDlayerIndex;
  5. function closeGuidancePreview(){
  6. layer.close(previewLayerIndex)
  7. }
  8. function closeFollowUpLayer(planDetaiId, relationCode){
  9. if($.isArray(relationCode)) {
  10. $.each(relationCode, function(index, item){
  11. top.serviceItemVue.saveRehabilitationOperateRecord(planDetaiId, 6, item)
  12. })
  13. } else {
  14. top.serviceItemVue.saveRehabilitationOperateRecord(planDetaiId, 6, relationCode)
  15. }
  16. layer.close(followupLayerIndex)
  17. }
  18. function closeKFZDlayer(planDetaiId){
  19. top.serviceItemVue.saveRehabilitationOperateRecord(planDetaiId, 5)
  20. layer.close(KFZDlayerIndex)
  21. }
  22. function showSuccessMessage(msg) {
  23. layer.msg(msg, {
  24. icon: 1
  25. })
  26. }
  27. function showErrorMessage(msg) {
  28. layer.msg(msg, {
  29. icon: 5
  30. })
  31. }
  32. top.serviceItemVue = new Vue({
  33. el:"#app",
  34. data:{
  35. planId: httpData['planId'],
  36. planids: httpData['planids'],
  37. patient: httpData['patient'],
  38. patientName: decodeURI(httpData['patientName']),
  39. serviceData:[
  40. {
  41. relationRecordImg:{},
  42. messageList:{}
  43. }
  44. ],
  45. isCollapse :false,
  46. collapseIndex:0,
  47. qrCode:'',
  48. qrModal:false,
  49. curDetailId: '',
  50. layerIndex: undefined
  51. },
  52. mounted:function(){
  53. this.getServiceItemList();
  54. },
  55. methods:{
  56. // 提醒患者 num 1康复指导2康复下转3复诊提醒4上门服务提醒5家签提醒
  57. sendSpecialistWeixinMessage: function(planDetaiId, type){
  58. var vm = this
  59. var text = ''
  60. if(type==4){ // 上门服务
  61. text = '请问您是否确认提醒'+vm.patientName+'居民预约上门护理服务?'
  62. } else if(type==7){ // 康复复诊
  63. text = '请问您是否确认提醒'+vm.patientName+'居民进行复诊?'
  64. }
  65. var current=layer.confirm(text, {
  66. btn: ['确定', '取消'],
  67. title: "提示"
  68. }, function (index) {
  69. var _type = type == 4? 4:type==7?3:''
  70. var loading = layer.load(0, {shade: false})
  71. var params = {
  72. patient: vm.patient,
  73. doctor: docInfo.uid,
  74. type: _type,
  75. relationCode: planDetaiId,
  76. planId: vm.planId
  77. }
  78. rehaAPI.sendSpecialistWeixinMessage(params).then(function(res){
  79. layer.close(loading)
  80. if(res.status == 200){
  81. showSuccessMessage('提交成功!')
  82. if(_type==3 || _type==4){ // 提醒患者后,即认为是已完成
  83. vm.saveRehabilitationOperateRecord(planDetaiId, type)
  84. }
  85. } else {
  86. showErrorMessage(res.msg)
  87. }
  88. })
  89. layer.close(current); //再执行关闭
  90. })
  91. },
  92. viewDetial:function(type,code){
  93. var vm=this;
  94. if(type==3||type==4){
  95. var str="";
  96. if(type==3){
  97. str="健康指导记录";
  98. }
  99. if(type==4){
  100. str="随访记录"
  101. }
  102. top.layer.msg('客户端暂不支持查询'+str);
  103. }else{
  104. top.layer.open({
  105. type: 2,
  106. // offset: ['100px'], //右下角弹出
  107. area: ['80%', '600px'],
  108. shade: 0.5,
  109. title: '指导教育',
  110. fixed: true, //不固定
  111. maxmin: true,
  112. closeBtn: 1,
  113. shift: 5,
  114. shadeClose: false, //点击遮罩关闭层
  115. content: '../../article/html/article-info.html?articleId=' + code,
  116. end: function() { // 未点击确定按钮,点击关闭按钮
  117. vm.getServiceItemList();    
  118. }
  119. });
  120. }
  121. },
  122. chakan:function(){
  123. this.isCollapse=!this.isCollapse;
  124. },
  125. changeCollapseIndex:function(idx, o){
  126. this.collapseIndex=idx;
  127. this.curDetailId = o.planDetaiId
  128. },
  129. clickItem:function(service){
  130. var vm=this
  131. var age=service.age=='0'?'':service.age
  132. if(httpData.disease=='3'&&httpData.scLenght==0&&service.itemType=='6'&&docInfo.doctorType!='1'){
  133. vm.$confirm('提示该居民近一年没有进行冠心病风险评估,请先进行评估,再进行随访登记', '提示', {
  134. confirmButtonText: '确定',
  135. cancelButtonText: '取消',
  136. type: 'warning'
  137. }).then(function(){
  138. top.layer.open({
  139. type: 2,
  140. area: ['820px', '648px'],
  141. shade: 0.5,
  142. title: 'ASCVD风险评估',
  143. fixed: true, //不固定
  144. maxmin: true,
  145. closeBtn:1,
  146. shift: 5,
  147. shadeClose: false, //点击遮罩关闭层
  148. content: '../../jbsc/html/questionnaire.html?fliter_code=6bcd306aaafb4e4381071346d86fadbb1'+'&fliter_title=ASCVD风险评估'+'&resident_code='+service.patient+'&resident_name='+vm.patientName+"&surveyStatus=2"+'&age='+age
  149. });
  150. })
  151. return false
  152. }
  153. layer.open({
  154. type: 2,
  155. area: ['97%', '640px'],
  156. shade: 0.5,
  157. title: '服务项目内容',
  158. fixed: true, //不固定
  159. maxmin: true,
  160. closeBtn:1,
  161. shift: 5,
  162. shadeClose: false, //点击遮罩关闭层
  163. content: '../../rehabilitation/html/guide_the_message.html?planid='+service.planDetaiId+'&pId='+httpData['planId']+'&patient='+vm.patient+'&patientName='+vm.patientName,
  164. end:function(){
  165. vm.getServiceItemList();    
  166. }
  167. });
  168. },
  169. qwapp:function(){
  170. layer.msg('请前往app处理',{icon:5});
  171. },
  172. viewGuidance: function(o){
  173. var vm = this
  174. previewLayerIndex = layer.open({
  175. type: 2,
  176. area: ['380px', '600px'],
  177. shade: 0.5,
  178. title: '预览',
  179. fixed: true, //不固定
  180. maxmin: true,
  181. closeBtn:1,
  182. shift: 5,
  183. shadeClose: false, //点击遮罩关闭层
  184. content: '../../rehabilitation/html/rehabilitation_guidance_preview.html?modelCode='+o.article
  185. });
  186. },
  187. //获取服务列表
  188. getServiceItemList:function(){
  189. var vm=this;
  190. var loginDoctor = JSON.parse(window.localStorage.getItem('wlyyAgent') || '{}');
  191. var loadding = layer.load(0, {shade: false}); //0代表加载的风格,支持0-2
  192. rehaAPI.serviceItemList({planDetailIds:vm.planids}).then(function(res){
  193. layer.close(loadding);
  194. if(res.status==200){
  195. var isZK=loginDoctor.doctorType==1?true:false;
  196. vm.serviceData=_.map(res.data||{},function(o, index){
  197. o.isZK=isZK;
  198. if(o.isMyTask==1){//执行者
  199. o.isCK=true;//无法显示按钮
  200. if(loginDoctor.uid==o.specialistDoctorCode){//说明我自己是创建者
  201. o.isCK=false;
  202. o.isCreate=true;
  203. }
  204. }else{
  205. if(loginDoctor.uid==o.specialistDoctorCode){//说明我自己是创建者
  206. o.isCreate=true;
  207. }
  208. }
  209. if(o.itemType == 4 || o.itemType == 5 || o.itemType == 7){
  210. vm.getRelationRecord(index, o.itemType, o.planDetaiId).then(function(result){
  211. if(result.status == 200){
  212. o.relationList = result.data&&result.data.length>0?result.data:undefined
  213. vm.$forceUpdate()
  214. }
  215. })
  216. }
  217. return o
  218. })
  219. if(vm.serviceData.length>0){
  220. vm.curDetailId = vm.serviceData[0].planDetaiId
  221. }
  222. if(!vm.planId&&vm.serviceData.length>0){
  223. vm.planId = vm.curDetailId.planId
  224. }
  225. }else{
  226. layer.msg(res.msg,{icon:5});
  227. }
  228. })
  229. },
  230. getRelationRecord: function(index, type, planDetaiId){
  231. // 1.电话短信 2.康复咨询 3.远程监控检测 4.上门服务 5.康复指导 6 康复随访 7.复诊)
  232. var vm = this
  233. var url=''
  234. if(type==5){
  235. url='doctor/specialist/rehabilitation/selectByRelationCode'
  236. }else if(type==7){
  237. url='third/guahao/selectByRelationCode'
  238. }else if(type==4){
  239. url="/doctor/specialist/rehabilitation/selectRelationCode"
  240. }
  241. var vm = this
  242. var params = {
  243. relationCode: planDetaiId
  244. }
  245. return httpRequest.get(url, {data: params})
  246. },
  247. //康复指导
  248. kfzd:function(planDetaiId){
  249. var vm=this
  250. KFZDlayerIndex = layer.open({
  251. type: 2,
  252. // offset: ['100px'], //右下角弹出
  253. area: ['660px', '650px'],
  254. shade: 0.5,
  255. title: '康复指导',
  256. fixed: true, //不固定
  257. maxmin: true,
  258. closeBtn: 1,
  259. shift: 5,
  260. shadeClose: false, //点击遮罩关闭层
  261. content:'../../rehabilitation/html/rehabilitation_guidance.html?patient='+vm.patient+'&planDetaiId='+planDetaiId+'&planId='+vm.planId,
  262. end: function() { // 未点击确定按钮,点击关闭按钮
  263. vm.getServiceItemList();    
  264. }
  265. });
  266. },
  267. // 康复随访计划
  268. sfjh: function(planDetaiId){
  269. var vm=this
  270. followupLayerIndex = layer.open({
  271. type: 2,
  272. // offset: ['100px'], //右下角弹出
  273. area: ['80%', '650px'],
  274. shade: 0.5,
  275. title: '随访计划',
  276. fixed: true, //不固定
  277. maxmin: true,
  278. closeBtn: 1,
  279. shift: 5,
  280. shadeClose: false, //点击遮罩关闭层
  281. content:'../../followup/html/followup_newplan.html?patient='+vm.patient+'&planDetaiId='+planDetaiId+'&planId='+vm.planId,
  282. end: function() { // 未点击确定按钮,点击关闭按钮
  283. vm.getServiceItemList();    
  284. }
  285. });
  286. },
  287. saveRehabilitationOperateRecord:function(planDetailId, type, relationCode){
  288. var vm=this;
  289. var params={
  290. rehabilitationDetailId: planDetailId,
  291. node:null,
  292. patientCode: vm.patient,
  293. doctorCode: docInfo.uid,
  294. relationRecordType: type,
  295. relationRecordCode: '',
  296. relationRecordImg: null,
  297. status: 0
  298. }
  299. rehaAPI.saveRehabilitationOperateRecord({dataJson:JSON.stringify(params)}).then(function(res){
  300. if(res.status==200){
  301. if(type==6){
  302. vm.updateRelationCodeByDetailId(planDetailId, relationCode)
  303. } else{
  304. vm.updateNoteAndImageRehabilitationOperate(planDetailId)
  305. }
  306. }else {
  307. showErrorMessage(res.msg)
  308. }
  309. })
  310. },
  311. updateNoteAndImageRehabilitationOperate: function(planDetailId, relationCode) {
  312. var vm = this;
  313. var _image = [];
  314. for(var i in vm.upImgs) {
  315. _image.push(vm.upImgs[i].img);
  316. }
  317. var params = {
  318. planDetailId: planDetailId,
  319. node: '',
  320. image: ''
  321. }
  322. if(relationCode){
  323. params['relationCode'] = relationCode
  324. }
  325. var loadding = top.layer.load(0, {
  326. shade: false
  327. }); //0代表加载的风格,支持0-2
  328. rehaAPI.updateNoteAndImageRehabilitationOperate(params).then(function(res) {
  329. top.layer.close(loadding);
  330. if(res.status == 200) {
  331. vm.getServiceItemList();
  332. top.rehabilitationVue.refresh()
  333. }else {
  334. showErrorMessage(res.msg)
  335. }
  336. })
  337. },
  338. updateRelationCodeByDetailId: function(planDetailId, relationCode){
  339. var vm = this
  340. var params = {
  341. planDetailId: planDetailId,
  342. relationCode: relationCode,
  343. }
  344. rehaAPI.updateRelationCodeByDetailId(params).then(function(res) {
  345. if(res.status == 200) {
  346. vm.getServiceItemList();
  347. top.rehabilitationVue.refresh()
  348. } else {
  349. showErrorMessage(res.msg)
  350. }
  351. })
  352. },
  353. // 暂未开放
  354. zwkf:function(){
  355. layer.msg('此功能暂未开放',{icon:1});
  356. },
  357. goToFinish:function(planDetaiId){
  358. var vm=this;
  359. layer.open({
  360. type: 2,
  361. // offset: ['100px'], //右下角弹出
  362. area: ['80%', '650px'],
  363. shade: 0.5,
  364. title: '完成项目确认',
  365. fixed: true, //不固定
  366. maxmin: true,
  367. closeBtn:1,
  368. shift: 5,
  369. shadeClose: false, //点击遮罩关闭层
  370. content: '../../rehabilitation/html/guide_the_message.html?planid='+planDetaiId+'&pId='+vm.planId+'&patient='+vm.patient+'&patientName='+vm.patientName,
  371. end: function() { // 未点击确定按钮,点击关闭按钮
  372. vm.getServiceItemList();    
  373. }
  374. });
  375. },
  376. fwm:function(planid,patient){
  377. this.loadSocket(planid,patient);
  378. },
  379. zdly:function(data){
  380. var vm = this
  381. var loginDoctor = JSON.parse(window.localStorage.getItem('wlyyAgent'));
  382. var otherCode,otherName;
  383. var planDetailId='';
  384. // if(data.specialistDoctorCode==data.executeDoctorCode){
  385. // layer.msg('无法与自己聊天',{icon:5});
  386. // return ;
  387. // }
  388. if(docInfo.doctorType==1){
  389. if(docInfo.uid == data.specialistDoctorCode) {
  390. //当前医生为创建计划的专科医生,与全科医生聊天
  391. otherCode = data.familyDoctorCode;
  392. otherName = data.familyDoctorName;
  393. }else {
  394. //当前医生为专科,当前医生不是创建计划的专科医生,没反应
  395. return false
  396. }
  397. }else{
  398. //全科医生与专科医生聊天
  399. otherCode = data.specialistDoctorCode;
  400. name = data.specialistDoctorName;
  401. }
  402. // if(data.isMyTask==1){
  403. // otherCode=data.specialistDoctorCode;
  404. // otherName=data.specialistDoctorName;
  405. // }else{
  406. // otherCode=data.executeDoctorCode;
  407. // otherName=data.executeDoctorCode;
  408. // }
  409. planDetailId=data.planDetaiId;
  410. layer.open({
  411. type: 2,
  412. // offset: ['100px'], //右下角弹出
  413. area: ['660px', '600px'],
  414. shade: 0.5,
  415. title: '指导留言',
  416. fixed: true, //不固定
  417. maxmin: true,
  418. closeBtn:1,
  419. shift: 5,
  420. shadeClose: false, //点击遮罩关闭层
  421. content: '../../consulting/html/consulting.html?otherCode='+otherCode+'&otherName='+encodeURI(otherName)+'&planDetailId='+planDetailId,
  422. end:function(){ // 未点击确定按钮,点击关闭按钮
  423.       vm.getServiceItemList();
  424.     }
  425. });
  426. },
  427. loadSocket:function(planid,patient){
  428. var vm=this;
  429. var imurl=httpRequest.socketUrl;
  430. jQuery.getScript(imurl+"/socket.io/socket.io.js").done(function() {
  431. var socket = io.connect(imurl);
  432. var sessionId = 'system';
  433. socket.emit('login', {userId: userInfo.uid, password: userInfo.uid,sessionId:sessionId,clientType:"doctor"});
  434. socket.on('message', function (data) {
  435. console.log(data);
  436. if(data.type==1){
  437. vm.goToFinish(planid);
  438. setTimeout(function(){
  439. vm.qrModal=false;
  440. },1000/60)
  441. }
  442. });
  443. socket.on('error', function (data) {
  444. console.log(data);
  445. });
  446. socket.on('ack', function (data) {
  447. console.log(data);
  448. vm.getQRCode(planid);
  449. });
  450. function getLocalTime(nS) {
  451. return new Date(parseInt(nS) * 1000).toLocaleString().replace(/:\d{1,2}$/,' ');
  452. }
  453. })
  454. .fail(function() {
  455. layer.msg('服务码创建失败',{icon:5});
  456. });
  457. },
  458. getQRCode:function(planid){
  459. var vm=this;
  460. var loginDoctor = JSON.parse(window.localStorage.getItem('wlyyAgent'));
  461. var params={
  462. planDetailId:planid,
  463. doctorCode: loginDoctor.uid
  464. }
  465. rehaAPI.createServiceQrCode(params).then(function(res){
  466. console.log(res);
  467. if(res.status==200){
  468. vm.qrCode=res.data;
  469. setTimeout(function(){
  470. vm.qrModal=true;
  471. },1000/60)
  472. }else{
  473. layer.msg('服务码获取失败',{icon:5});
  474. }
  475. })
  476. },
  477. getContent: function(value,type) {
  478. var res=value;
  479. if(type==2 || type==9){
  480. res = "<img src='"+httpRequest.getImgUrl(res)+"' width='100px'>";
  481. }else if(type==3){
  482. res = '【语音】';
  483. }else if(type==19){
  484. res = '【聊天记录】';
  485. }else if(type==12){
  486. res = '【视频】';
  487. }
  488. return res;
  489. },
  490. previewImg: function(url){
  491. var src = httpRequest.getImgUrl(url);
  492. imgShow("#outerdiv", "#innerdiv", "#bigimg", src);
  493. }
  494. },
  495. filters:{
  496. formatDate:function(value, format) {
  497. if(!value) return ;
  498. var d = new Date(value);
  499. return d.format("yyyy-MM-dd hh:mm:ss");
  500. },
  501. getImgUrl: function(value) {
  502. var url = httpRequest.getImgUrl(value);
  503. return url;
  504. }
  505. }
  506. })
  507. // $("body").on('click','img',function(){
  508. // var _this = $(this);//将当前的img元素作为_this传入函数
  509. // imgShow("#outerdiv", "#innerdiv", "#bigimg", _this);
  510. // });
  511. function imgShow(outerdiv, innerdiv, bigimg, src){
  512. // var src = _this.attr("src");//获取当前点击的pimg元素中的src属性
  513. $(bigimg).attr("src", src);//设置#bigimg元素的src属性
  514. /*获取当前点击图片的真实大小,并显示弹出层及大图*/
  515. $("<img/>").attr("src", src).load(function(){
  516. var windowW = $(window).width();//获取当前窗口宽度
  517. var windowH = $(window).height();//获取当前窗口高度
  518. var realWidth = this.width;//获取图片真实宽度
  519. var realHeight = this.height;//获取图片真实高度
  520. var imgWidth, imgHeight;
  521. var scale = 0.8;//缩放尺寸,当图片真实宽度和高度大于窗口宽度和高度时进行缩放
  522. if(realHeight>windowH*scale) {//判断图片高度
  523. imgHeight = windowH*scale;//如大于窗口高度,图片高度进行缩放
  524. imgWidth = imgHeight/realHeight*realWidth;//等比例缩放宽度
  525. if(imgWidth>windowW*scale) {//如宽度扔大于窗口宽度
  526. imgWidth = windowW*scale;//再对宽度进行缩放
  527. }
  528. } else if(realWidth>windowW*scale) {//如图片高度合适,判断图片宽度
  529. imgWidth = windowW*scale;//如大于窗口宽度,图片宽度进行缩放
  530. imgHeight = imgWidth/realWidth*realHeight;//等比例缩放高度
  531. } else {//如果图片真实高度和宽度都符合要求,高宽不变
  532. imgWidth = realWidth;
  533. imgHeight = realHeight;
  534. }
  535. $(bigimg).css("width",imgWidth);//以最终的宽度对图片缩放
  536. var w = (windowW-imgWidth)/2;//计算图片与窗口左边距
  537. var h = (windowH-imgHeight)/2;//计算图片与窗口上边距
  538. $(innerdiv).css({"top":h, "left":w});//设置#innerdiv的top和left属性
  539. $(outerdiv).fadeIn("fast");//淡入显示#outerdiv及.pimg
  540. });
  541. $(outerdiv).click(function(){//再次点击淡出消失弹出层
  542. $(this).fadeOut("fast");
  543. });
  544. }