service_item_content.js 15 KB

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