service_item_content.js 14 KB

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