service_item_content.js 15 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532
  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. layer.open({
  132. type: 2,
  133. area: ['97%', '640px'],
  134. shade: 0.5,
  135. title: '服务项目内容',
  136. fixed: true, //不固定
  137. maxmin: true,
  138. closeBtn:1,
  139. shift: 5,
  140. shadeClose: false, //点击遮罩关闭层
  141. content: '../../rehabilitation/html/guide_the_message.html?planid='+service.planDetaiId+'&pId='+httpData['planId']+'&patient='+vm.patient+'&patientName='+vm.patientName,
  142. end:function(){
  143. vm.getServiceItemList();    
  144. }
  145. });
  146. },
  147. qwapp:function(){
  148. layer.msg('请前往app处理',{icon:5});
  149. },
  150. viewGuidance: function(o){
  151. var vm = this
  152. previewLayerIndex = layer.open({
  153. type: 2,
  154. area: ['380px', '600px'],
  155. shade: 0.5,
  156. title: '预览',
  157. fixed: true, //不固定
  158. maxmin: true,
  159. closeBtn:1,
  160. shift: 5,
  161. shadeClose: false, //点击遮罩关闭层
  162. content: '../../rehabilitation/html/rehabilitation_guidance_preview.html?modelCode='+o.article
  163. });
  164. },
  165. //获取服务列表
  166. getServiceItemList:function(){
  167. var vm=this;
  168. var loginDoctor = JSON.parse(window.localStorage.getItem('wlyyAgent') || '{}');
  169. var loadding = layer.load(0, {shade: false}); //0代表加载的风格,支持0-2
  170. rehaAPI.serviceItemList({planDetailIds:vm.planids}).then(function(res){
  171. layer.close(loadding);
  172. if(res.status==200){
  173. var isZK=loginDoctor.doctorType==1?true:false;
  174. vm.serviceData=_.map(res.data||{},function(o, index){
  175. o.isZK=isZK;
  176. if(o.isMyTask==1){//执行者
  177. o.isCK=true;//无法显示按钮
  178. if(loginDoctor.uid==o.specialistDoctorCode){//说明我自己是创建者
  179. o.isCK=false;
  180. o.isCreate=true;
  181. }
  182. }else{
  183. if(loginDoctor.uid==o.specialistDoctorCode){//说明我自己是创建者
  184. o.isCreate=true;
  185. }
  186. }
  187. if(o.itemType == 4 || o.itemType == 5 || o.itemType == 7){
  188. vm.getRelationRecord(index, o.itemType, o.planDetaiId).then(function(result){
  189. if(result.status == 200){
  190. o.relationList = result.data&&result.data.length>0?result.data:undefined
  191. vm.$forceUpdate()
  192. }
  193. })
  194. }
  195. return o
  196. })
  197. if(vm.serviceData.length>0){
  198. vm.curDetailId = vm.serviceData[0].planDetaiId
  199. }
  200. if(!vm.planId&&vm.serviceData.length>0){
  201. vm.planId = vm.curDetailId.planId
  202. }
  203. }else{
  204. layer.msg(res.msg,{icon:5});
  205. }
  206. })
  207. },
  208. getRelationRecord: function(index, type, planDetaiId){
  209. // 1.电话短信 2.康复咨询 3.远程监控检测 4.上门服务 5.康复指导 6 康复随访 7.复诊)
  210. var vm = this
  211. var url=''
  212. if(type==5){
  213. url='doctor/specialist/rehabilitation/selectByRelationCode'
  214. }else if(type==7){
  215. url='third/guahao/selectByRelationCode'
  216. }else if(type==4){
  217. url="/doctor/specialist/rehabilitation/selectRelationCode"
  218. }
  219. var vm = this
  220. var params = {
  221. relationCode: planDetaiId
  222. }
  223. return httpRequest.get(url, {data: params})
  224. },
  225. //康复指导
  226. kfzd:function(planDetaiId){
  227. var vm=this
  228. KFZDlayerIndex = layer.open({
  229. type: 2,
  230. // offset: ['100px'], //右下角弹出
  231. area: ['660px', '650px'],
  232. shade: 0.5,
  233. title: '康复指导',
  234. fixed: true, //不固定
  235. maxmin: true,
  236. closeBtn: 1,
  237. shift: 5,
  238. shadeClose: false, //点击遮罩关闭层
  239. content:'../../rehabilitation/html/rehabilitation_guidance.html?patient='+vm.patient+'&planDetaiId='+planDetaiId+'&planId='+vm.planId,
  240. end: function() { // 未点击确定按钮,点击关闭按钮
  241. vm.getServiceItemList();    
  242. }
  243. });
  244. },
  245. // 康复随访计划
  246. sfjh: function(planDetaiId){
  247. var vm=this
  248. followupLayerIndex = layer.open({
  249. type: 2,
  250. // offset: ['100px'], //右下角弹出
  251. area: ['80%', '650px'],
  252. shade: 0.5,
  253. title: '随访计划',
  254. fixed: true, //不固定
  255. maxmin: true,
  256. closeBtn: 1,
  257. shift: 5,
  258. shadeClose: false, //点击遮罩关闭层
  259. content:'../../followup/html/followup_newplan.html?patient='+vm.patient+'&planDetaiId='+planDetaiId+'&planId='+vm.planId,
  260. end: function() { // 未点击确定按钮,点击关闭按钮
  261. vm.getServiceItemList();    
  262. }
  263. });
  264. },
  265. saveRehabilitationOperateRecord:function(planDetailId, type, relationCode){
  266. var vm=this;
  267. var params={
  268. rehabilitationDetailId: planDetailId,
  269. node:null,
  270. patientCode: vm.patient,
  271. doctorCode: docInfo.uid,
  272. relationRecordType: type,
  273. relationRecordCode: '',
  274. relationRecordImg: null,
  275. status: 0
  276. }
  277. rehaAPI.saveRehabilitationOperateRecord({dataJson:JSON.stringify(params)}).then(function(res){
  278. if(res.status==200){
  279. if(type==6){
  280. vm.updateRelationCodeByDetailId(planDetailId, relationCode)
  281. } else{
  282. vm.updateNoteAndImageRehabilitationOperate(planDetailId)
  283. }
  284. }else {
  285. showErrorMessage(res.msg)
  286. }
  287. })
  288. },
  289. updateNoteAndImageRehabilitationOperate: function(planDetailId, relationCode) {
  290. var vm = this;
  291. var _image = [];
  292. for(var i in vm.upImgs) {
  293. _image.push(vm.upImgs[i].img);
  294. }
  295. var params = {
  296. planDetailId: planDetailId,
  297. node: '',
  298. image: ''
  299. }
  300. if(relationCode){
  301. params['relationCode'] = relationCode
  302. }
  303. var loadding = top.layer.load(0, {
  304. shade: false
  305. }); //0代表加载的风格,支持0-2
  306. rehaAPI.updateNoteAndImageRehabilitationOperate(params).then(function(res) {
  307. top.layer.close(loadding);
  308. if(res.status == 200) {
  309. vm.getServiceItemList();
  310. top.rehabilitationVue.refresh()
  311. }else {
  312. showErrorMessage(res.msg)
  313. }
  314. })
  315. },
  316. updateRelationCodeByDetailId: function(planDetailId, relationCode){
  317. var vm = this
  318. var params = {
  319. planDetailId: planDetailId,
  320. relationCode: relationCode,
  321. }
  322. rehaAPI.updateRelationCodeByDetailId(params).then(function(res) {
  323. if(res.status == 200) {
  324. vm.getServiceItemList();
  325. top.rehabilitationVue.refresh()
  326. } else {
  327. showErrorMessage(res.msg)
  328. }
  329. })
  330. },
  331. // 暂未开放
  332. zwkf:function(){
  333. layer.msg('此功能暂未开放',{icon:1});
  334. },
  335. goToFinish:function(planDetaiId){
  336. var vm=this;
  337. layer.open({
  338. type: 2,
  339. // offset: ['100px'], //右下角弹出
  340. area: ['80%', '650px'],
  341. shade: 0.5,
  342. title: '完成项目确认',
  343. fixed: true, //不固定
  344. maxmin: true,
  345. closeBtn:1,
  346. shift: 5,
  347. shadeClose: false, //点击遮罩关闭层
  348. content: '../../rehabilitation/html/guide_the_message.html?planid='+planDetaiId+'&pId='+vm.planId+'&patient='+vm.patient+'&patientName='+vm.patientName,
  349. end: function() { // 未点击确定按钮,点击关闭按钮
  350. vm.getServiceItemList();    
  351. }
  352. });
  353. },
  354. fwm:function(planid,patient){
  355. this.loadSocket(planid,patient);
  356. },
  357. zdly:function(data){
  358. var vm = this
  359. var loginDoctor = JSON.parse(window.localStorage.getItem('wlyyAgent'));
  360. var otherCode,otherName;
  361. var planDetailId='';
  362. // if(data.specialistDoctorCode==data.executeDoctorCode){
  363. // layer.msg('无法与自己聊天',{icon:5});
  364. // return ;
  365. // }
  366. if(docInfo.doctorType==1){
  367. if(docInfo.uid == data.specialistDoctorCode) {
  368. //当前医生为创建计划的专科医生,与全科医生聊天
  369. otherCode = data.familyDoctorCode;
  370. otherName = data.familyDoctorName;
  371. }else {
  372. //当前医生为专科,当前医生不是创建计划的专科医生,没反应
  373. return false
  374. }
  375. }else{
  376. //全科医生与专科医生聊天
  377. otherCode = data.specialistDoctorCode;
  378. name = data.specialistDoctorName;
  379. }
  380. // if(data.isMyTask==1){
  381. // otherCode=data.specialistDoctorCode;
  382. // otherName=data.specialistDoctorName;
  383. // }else{
  384. // otherCode=data.executeDoctorCode;
  385. // otherName=data.executeDoctorCode;
  386. // }
  387. planDetailId=data.planDetaiId;
  388. layer.open({
  389. type: 2,
  390. // offset: ['100px'], //右下角弹出
  391. area: ['660px', '600px'],
  392. shade: 0.5,
  393. title: '指导留言',
  394. fixed: true, //不固定
  395. maxmin: true,
  396. closeBtn:1,
  397. shift: 5,
  398. shadeClose: false, //点击遮罩关闭层
  399. content: '../../consulting/html/consulting.html?otherCode='+otherCode+'&otherName='+encodeURI(otherName)+'&planDetailId='+planDetailId,
  400. end:function(){ // 未点击确定按钮,点击关闭按钮
  401.       vm.getServiceItemList();
  402.     }
  403. });
  404. },
  405. loadSocket:function(planid,patient){
  406. var vm=this;
  407. var imurl=httpRequest.socketUrl;
  408. jQuery.getScript(imurl+"/socket.io/socket.io.js").done(function() {
  409. var socket = io.connect(imurl);
  410. var sessionId = 'system';
  411. socket.emit('login', {userId: userInfo.uid, password: userInfo.uid,sessionId:sessionId,clientType:"doctor"});
  412. socket.on('message', function (data) {
  413. console.log(data);
  414. if(data.type==1){
  415. vm.goToFinish(planid);
  416. setTimeout(function(){
  417. vm.qrModal=false;
  418. },1000/60)
  419. }
  420. });
  421. socket.on('error', function (data) {
  422. console.log(data);
  423. });
  424. socket.on('ack', function (data) {
  425. console.log(data);
  426. vm.getQRCode(planid);
  427. });
  428. function getLocalTime(nS) {
  429. return new Date(parseInt(nS) * 1000).toLocaleString().replace(/:\d{1,2}$/,' ');
  430. }
  431. })
  432. .fail(function() {
  433. layer.msg('服务码创建失败',{icon:5});
  434. });
  435. },
  436. getQRCode:function(planid){
  437. var vm=this;
  438. var loginDoctor = JSON.parse(window.localStorage.getItem('wlyyAgent'));
  439. var params={
  440. planDetailId:planid,
  441. doctorCode: loginDoctor.uid
  442. }
  443. rehaAPI.createServiceQrCode(params).then(function(res){
  444. console.log(res);
  445. if(res.status==200){
  446. vm.qrCode=res.data;
  447. setTimeout(function(){
  448. vm.qrModal=true;
  449. },1000/60)
  450. }else{
  451. layer.msg('服务码获取失败',{icon:5});
  452. }
  453. })
  454. },
  455. getContent: function(value,type) {
  456. var res=value;
  457. if(type==2 || type==9){
  458. res = "<img src='"+httpRequest.getImgUrl(res)+"' width='100px'>";
  459. }else if(type==3){
  460. res = '【语音】';
  461. }else if(type==19){
  462. res = '【聊天记录】';
  463. }else if(type==12){
  464. res = '【视频】';
  465. }
  466. return res;
  467. },
  468. previewImg: function(url){
  469. var src = httpRequest.getImgUrl(url);
  470. imgShow("#outerdiv", "#innerdiv", "#bigimg", src);
  471. }
  472. },
  473. filters:{
  474. formatDate:function(value, format) {
  475. if(!value) return ;
  476. var d = new Date(value);
  477. return d.format("yyyy-MM-dd hh:mm:ss");
  478. },
  479. getImgUrl: function(value) {
  480. var url = httpRequest.getImgUrl(value);
  481. return url;
  482. }
  483. }
  484. })
  485. // $("body").on('click','img',function(){
  486. // var _this = $(this);//将当前的img元素作为_this传入函数
  487. // imgShow("#outerdiv", "#innerdiv", "#bigimg", _this);
  488. // });
  489. function imgShow(outerdiv, innerdiv, bigimg, src){
  490. // var src = _this.attr("src");//获取当前点击的pimg元素中的src属性
  491. $(bigimg).attr("src", src);//设置#bigimg元素的src属性
  492. /*获取当前点击图片的真实大小,并显示弹出层及大图*/
  493. $("<img/>").attr("src", src).load(function(){
  494. var windowW = $(window).width();//获取当前窗口宽度
  495. var windowH = $(window).height();//获取当前窗口高度
  496. var realWidth = this.width;//获取图片真实宽度
  497. var realHeight = this.height;//获取图片真实高度
  498. var imgWidth, imgHeight;
  499. var scale = 0.8;//缩放尺寸,当图片真实宽度和高度大于窗口宽度和高度时进行缩放
  500. if(realHeight>windowH*scale) {//判断图片高度
  501. imgHeight = windowH*scale;//如大于窗口高度,图片高度进行缩放
  502. imgWidth = imgHeight/realHeight*realWidth;//等比例缩放宽度
  503. if(imgWidth>windowW*scale) {//如宽度扔大于窗口宽度
  504. imgWidth = windowW*scale;//再对宽度进行缩放
  505. }
  506. } else if(realWidth>windowW*scale) {//如图片高度合适,判断图片宽度
  507. imgWidth = windowW*scale;//如大于窗口宽度,图片宽度进行缩放
  508. imgHeight = imgWidth/realWidth*realHeight;//等比例缩放高度
  509. } else {//如果图片真实高度和宽度都符合要求,高宽不变
  510. imgWidth = realWidth;
  511. imgHeight = realHeight;
  512. }
  513. $(bigimg).css("width",imgWidth);//以最终的宽度对图片缩放
  514. var w = (windowW-imgWidth)/2;//计算图片与窗口左边距
  515. var h = (windowH-imgHeight)/2;//计算图片与窗口上边距
  516. $(innerdiv).css({"top":h, "left":w});//设置#innerdiv的top和left属性
  517. $(outerdiv).fadeIn("fast");//淡入显示#outerdiv及.pimg
  518. });
  519. $(outerdiv).click(function(){//再次点击淡出消失弹出层
  520. $(this).fadeOut("fast");
  521. });
  522. }