service_item_content.js 14 KB

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