service_item_content.js 16 KB

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