service_item_content.js 14 KB

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