service_item_content.js 13 KB

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