guide_the_message.js 15 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523
  1. var httpData = GetRequest();
  2. var docInfo = JSON.parse(window.localStorage.getItem('wlyyAgent'));
  3. var previewLayerIndex, followupLayerIndex, KFZDlayerIndex;
  4. function closeGuidancePreview(){
  5. layer.close(previewLayerIndex)
  6. }
  7. function closeFollowUpLayer(planDetaiId, relationCode){
  8. if($.isArray(relationCode)) {
  9. $.each(relationCode, function(index, item){
  10. top.rehabilitationGuideVue.saveRehabilitationOperateRecord(planDetaiId, 6, item)
  11. })
  12. } else {
  13. top.rehabilitationGuideVue.saveRehabilitationOperateRecord(planDetaiId, 6, relationCode)
  14. }
  15. layer.close(followupLayerIndex)
  16. }
  17. function closeKFZDlayer(planDetaiId){
  18. top.rehabilitationGuideVue.saveRehabilitationOperateRecord(planDetaiId, 5)
  19. layer.close(KFZDlayerIndex)
  20. }
  21. function showSuccessMessage(msg) {
  22. layer.msg(msg, {
  23. icon: 1
  24. })
  25. }
  26. function showErrorMessage(msg) {
  27. layer.msg(msg, {
  28. icon: 5
  29. })
  30. }
  31. top.rehabilitationGuideVue = new Vue({
  32. el: "#app",
  33. data: {
  34. imgData: {
  35. accept: 'image/gif, image/jpeg, image/png, image/jpg',
  36. },
  37. isCollapse: false,
  38. upImgs: [],
  39. upImgArr: [],
  40. planid: httpData['planid'], // 服务项id
  41. service: {
  42. relationRecordImg:{},
  43. messageList:{},
  44. },
  45. pId: httpData['pId'], // 康复计划id
  46. patient: httpData['patient'],
  47. patientName: decodeURI(httpData['patientName']),
  48. layerIndex: undefined,
  49. recordId: httpData['recordId']||undefined,
  50. islimit: false
  51. },
  52. mounted: function() {
  53. this.getServiceItem();
  54. },
  55. methods: {
  56. // 提醒患者 num 1康复指导2康复下转3复诊提醒4上门服务提醒5家签提醒
  57. sendSpecialistWeixinMessage: function(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: vm.planid,
  76. planId: vm.pId
  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(vm.planid, type)
  84. }
  85. } else {
  86. showErrorMessage(res.msg)
  87. }
  88. })
  89. layer.close(current); //再执行关闭
  90. })
  91. },
  92. //康复指导
  93. kfzd:function(){
  94. var vm=this, str = '../../rehabilitation/html/rehabilitation_guidance.html?patient='+vm.patient+'&planDetaiId='+vm.planid+'&planId='+vm.pId
  95. KFZDlayerIndex = layer.open({
  96. type: 2,
  97. // offset: ['100px'], //右下角弹出
  98. area: ['660px', '650px'],
  99. shade: 0.5,
  100. title: '康复指导',
  101. fixed: true, //不固定
  102. maxmin: true,
  103. closeBtn: 1,
  104. shift: 5,
  105. shadeClose: false, //点击遮罩关闭层
  106. content: str,
  107. end: function() { // 未点击确定按钮,点击关闭按钮
  108. this.getServiceItem();   
  109. }
  110. });
  111. },
  112. // 康复随访计划
  113. sfjh: function(){
  114. var vm=this
  115. followupLayerIndex = layer.open({
  116. type: 2,
  117. // offset: ['100px'], //右下角弹出
  118. area: ['80%', '650px'],
  119. shade: 0.5,
  120. title: '随访计划',
  121. fixed: true, //不固定
  122. maxmin: true,
  123. closeBtn: 1,
  124. shift: 5,
  125. shadeClose: false, //点击遮罩关闭层
  126. content:'../../followup/html/followup_newplan.html?patient='+vm.patient+'&planDetaiId='+vm.planid+'&planId='+vm.pId,
  127. end: function() { // 未点击确定按钮,点击关闭按钮
  128. this.getServiceItem();    
  129. }
  130. });
  131. },
  132. zwkf: function() {
  133. top.layer.msg('此功能暂未开放', {
  134. icon: 1
  135. });
  136. },
  137. //康复指导
  138. jkzd: function(planId,patient) {
  139. var vm = this
  140. top.layer.open({
  141. type: 2,
  142. // offset: ['100px'], //右下角弹出
  143. area: ['80%', '648px'],
  144. shade: 0.5,
  145. title: '健康教育',
  146. fixed: true, //不固定
  147. maxmin: true,
  148. closeBtn: 1,
  149. shift: 5,
  150. shadeClose: false, //点击遮罩关闭层
  151. content: '../../guidance/html/index.html#/person-edit-panel?patient=' + patient + '&planId=' + planId
  152. });
  153. },
  154. qwapp: function() {
  155. top.layer.msg('请前往app处理', {
  156. icon: 5
  157. });
  158. },
  159. viewGuidance: function(o){
  160. var vm = this
  161. previewLayerIndex = layer.open({
  162. type: 2,
  163. area: ['380px', '600px'],
  164. shade: 0.5,
  165. title: '预览',
  166. fixed: true, //不固定
  167. maxmin: true,
  168. closeBtn:1,
  169. shift: 5,
  170. shadeClose: false, //点击遮罩关闭层
  171. content: '../../rehabilitation/html/rehabilitation_guidance_preview.html?modelCode='+o.article
  172. });
  173. },
  174. getServiceItem: function() {
  175. var vm = this;
  176. var loginDoctor = JSON.parse(window.localStorage.getItem('wlyyAgent'));
  177. var loadding = top.layer.load(0, {
  178. shade: false
  179. }); //0代表加载的风格,支持0-2
  180. var params = {
  181. planDetailId: vm.planid,
  182. }
  183. if(vm.recordId){
  184. params['recordId'] = vm.recordId
  185. }
  186. rehaAPI.serviceItem(params).then(function(res) {
  187. top.layer.close(loadding);
  188. if(res.status == 200) {
  189. vm.service = res.data;
  190. var isZK=loginDoctor.doctorType==1?true:false;
  191. vm.service.isZK=isZK;
  192. if(vm.service.completeTime){
  193. var l = vm.service.completeTime.length
  194. vm.service.shortCompleteTime = vm.service.completeTime.substr(l-5, l-1)
  195. }
  196. if(vm.service.isMyTask==1){//执行者
  197. vm.service.isCK=true;//无法显示按钮
  198. if(loginDoctor.uid==vm.service.specialistDoctorCode){//说明我自己是创建者
  199. vm.service.isCK=false;
  200. vm.service.isCreate=true;
  201. }
  202. }else{
  203. if(loginDoctor.uid==vm.service.specialistDoctorCode){//说明我自己是创建者
  204. vm.service.isCreate=true;
  205. }
  206. }
  207. if(vm.service.type == 4 || vm.service.type == 5 || vm.service.type == 7){
  208. vm.getRelationRecord(vm.service.type, vm.planid).then(function(result){
  209. if(result.status == 200){
  210. vm.service.relationList = result.data&&result.data.length>0?result.data:undefined
  211. vm.$forceUpdate()
  212. }
  213. })
  214. }
  215. if(vm.service.frequencyCode){
  216. vm.islimit = true
  217. } else {
  218. vm.islimit = false
  219. }
  220. } else {
  221. top.layer.msg(res.msg, {
  222. icon: 5
  223. });
  224. }
  225. if(vm.service.status==1){
  226. var index = top.layer.getFrameIndex(window.name); //先得到当前iframe层的索引
  227. top.layer.title('服务记录详情', index) //再改变当前层的标题
  228. }
  229. })
  230. },
  231. getRelationRecord: function(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: vm.recordId?vm.recordId:planDetaiId
  245. }
  246. return httpRequest.get(url, {data: params})
  247. },
  248. zdly: function(data) {
  249. var vm = this
  250. var loginDoctor = JSON.parse(window.localStorage.getItem('wlyyAgent'));
  251. var otherCode, otherName;
  252. if(loginDoctor.doctorType == 1) {
  253. otherCode = data.familyDoctorCode;
  254. otherName = data.familyDoctorName;
  255. } else {
  256. otherCode = data.specialistDoctorCode;
  257. otherName = data.specialistDoctorName;
  258. }
  259. top.layer.open({
  260. type: 2,
  261. // offset: ['100px'], //右下角弹出
  262. area: ['660px', '600px'],
  263. shade: 0.5,
  264. title: '指导留言',
  265. fixed: true, //不固定
  266. maxmin: true,
  267. closeBtn: 1,
  268. shift: 5,
  269. shadeClose: false, //点击遮罩关闭层
  270. content: '../../consulting/html/consulting.html?otherCode=' + otherCode + '&otherName=' + encodeURI(otherName) + '&planDetailId=' + vm.planid,
  271. end: function() { // 未点击确定按钮,点击关闭按钮
  272.       
  273. vm.getServiceItem();    
  274. }
  275. });
  276. },
  277. deleteImg: function(idx) {
  278. console.log(idx)
  279. this.upImgs.splice(idx, 1)
  280. },
  281. chakan: function() {
  282. this.isCollapse = !this.isCollapse;
  283. },
  284. upLoadImgToBase64: function() {
  285. var vm = this;
  286. var img1 = event.target.files[0];
  287. var reader = new FileReader();
  288. var type = img1.type; //文件的类型,判断是否是图片
  289. var size = img1.size; //文件的大小,判断图片的大小
  290. if(this.imgData.accept.indexOf(type) == -1) {
  291. alert('请选择我们支持的图片格式!');
  292. return false;
  293. }
  294. if(size > 3145728) {
  295. alert('请选择3M以内的图片!');
  296. return false;
  297. }
  298. reader.readAsDataURL(img1);
  299. reader.onload = function(e) {
  300. vm.upImgs.push({
  301. baseUrl: e.target.result
  302. });
  303. vm.upImgArr.push(img1);
  304. console.log('e', e, 'vm.upImgs', vm.upImgs, 'vm.upImgArr', vm.upImgArr)
  305. //vm.uploadImg(vm.upImgArr);
  306. }
  307. },
  308. qrwc: function(patient,type) {
  309. var vm = this;
  310. if(!vm.service.node){
  311. showErrorMessage('请填写服务记录')
  312. return
  313. }
  314. if(!vm.upImgs.length){
  315. showErrorMessage('请上传相关记录')
  316. return
  317. }
  318. vm.saveRehabilitationOperateRecord(vm.planid,type);
  319. },
  320. saveRehabilitationOperateRecord:function(planDetailId, type, relationCode, flag){
  321. var vm=this;
  322. var params={
  323. rehabilitationDetailId: planDetailId,
  324. node: null,
  325. patientCode: vm.patient,
  326. doctorCode: docInfo.uid,
  327. relationRecordType: type,
  328. relationRecordCode: '',
  329. relationRecordImg: null,
  330. status: 0
  331. }
  332. rehaAPI.saveRehabilitationOperateRecord({dataJson:JSON.stringify(params)}).then(function(res){
  333. if(res.status==200){
  334. if(type==1){
  335. vm.uploadImg(vm.upImgArr);
  336. }else if(type==6){
  337. vm.updateRelationCodeByDetailId(planDetailId, relationCode)
  338. } else {
  339. vm.updateNoteAndImageRehabilitationOperate(planDetailId)
  340. }
  341. } else {
  342. layer.msg(res.msg, {
  343. icon: 5
  344. });
  345. }
  346. })
  347. },
  348. //上传图片
  349. uploadImg: function(data) {
  350. var vm = this;
  351. var len = data.length;
  352. if(len==0) {
  353. vm.updateNoteAndImageRehabilitationOperate(vm.planid)
  354. } else {
  355. var file = data[len - 1];
  356. var formData = new FormData();
  357. formData.append('file', file);
  358. rehaAPI.upload(formData).then(function(res) {
  359. if(res.status == 200) {
  360. vm.upImgs[len - 1].img = res.data;
  361. data.pop();
  362. vm.$forceUpdate()
  363. vm.uploadImg(data);
  364. } else {
  365. layer.msg(res.msg, {
  366. icon: 5
  367. });
  368. }
  369. })
  370. }
  371. },
  372. updateNoteAndImageRehabilitationOperate: function(planDetailId, relationCode) {
  373. var vm = this;
  374. var _image = [];
  375. $.each(vm.upImgs, function(index, obj){
  376. _image.push(obj.img);
  377. })
  378. var params = {
  379. planDetailId: planDetailId,
  380. node: vm.service&&vm.service.node?vm.service.node:null,
  381. image:JSON.stringify(_image)||''
  382. }
  383. if(relationCode){
  384. params['relationCode'] = relationCode
  385. }
  386. var loadding = top.layer.load(0, {
  387. shade: false
  388. }); //0代表加载的风格,支持0-2
  389. rehaAPI.updateNoteAndImageRehabilitationOperate(params).then(function(res) {
  390. top.layer.close(loadding);
  391. if(res.status == 200) {
  392. vm.getServiceItem();
  393. top.rehabilitationVue.refresh()
  394. }
  395. })
  396. },
  397. updateRelationCodeByDetailId: function(planDetailId, relationCode){
  398. var vm = this
  399. var params = {
  400. planDetailId: planDetailId,
  401. relationCode: relationCode,
  402. }
  403. rehaAPI.updateRelationCodeByDetailId(params).then(function(res) {
  404. if(res.status == 200) {
  405. vm.getServiceItem();
  406. top.rehabilitationVue.refresh()
  407. } else {
  408. showErrorMessage(res.msg)
  409. }
  410. })
  411. },
  412. viewDetial:function(type,code){
  413. var vm=this;
  414. if(type == 3) {
  415. top.layer.msg('客户端暂不支持查询健康指导记录');
  416. } else if(type==4){
  417. top.layer.msg('客户端暂不支持查询随访记录');
  418. }else{
  419. top.layer.open({
  420. type: 2,
  421. // offset: ['100px'], //右下角弹出
  422. area: ['80%', '600px'],
  423. shade: 0.5,
  424. title: '指导教育',
  425. fixed: true, //不固定
  426. maxmin: true,
  427. closeBtn: 1,
  428. shift: 5,
  429. shadeClose: false, //点击遮罩关闭层
  430. content: '../../article/html/article-info.html?articleId=' + code,
  431. end: function() { // 未点击确定按钮,点击关闭按钮
  432. vm.getServiceItem();    
  433. }
  434. });
  435. }
  436. },
  437. getContent: function(value,type) {
  438. var res=value;
  439. if(type==2 || type==9){
  440. res = "<img src='"+httpRequest.getImgUrl(res)+"'>";
  441. }else if(type==3){
  442. res = '【语音】';
  443. }else if(type==19){
  444. res = '【聊天记录】';
  445. }else if(type==12){
  446. res = '【视频】';
  447. }
  448. return res;
  449. }
  450. },
  451. filters: {
  452. formatDate: function(value, format) {
  453. if(!value) return;
  454. var fmt = format || "yyyy-MM-dd hh:mm";
  455. var date = new Date(value);
  456. if(/(y+)/.test(fmt)) {
  457. fmt = fmt.replace(RegExp.$1, (date.getFullYear() + '').substr(4 - RegExp.$1.length));
  458. }
  459. let o = {
  460. 'M+': date.getMonth() + 1,
  461. 'd+': date.getDate(),
  462. 'h+': date.getHours(),
  463. 'm+': date.getMinutes(),
  464. 's+': date.getSeconds()
  465. };
  466. for(let k in o) {
  467. if(new RegExp(`(${k})`).test(fmt)) {
  468. let str = o[k] + '';
  469. fmt = fmt.replace(RegExp.$1, (RegExp.$1.length === 1) ? str : ('00' + str).substr(str.length));
  470. }
  471. }
  472. return fmt;
  473. },
  474. getImgUrl: function(value) {
  475. var url = httpRequest.getImgUrl(value);
  476. return url;
  477. }
  478. }
  479. })
  480. $("body").on('click','img',function(){
  481. var _this = $(this);//将当前的img元素作为_this传入函数
  482. imgShow("#outerdiv", "#innerdiv", "#bigimg", _this);
  483. });
  484. function imgShow(outerdiv, innerdiv, bigimg, _this){
  485. var src = _this.attr("src");//获取当前点击的pimg元素中的src属性
  486. $(bigimg).attr("src", src);//设置#bigimg元素的src属性
  487. /*获取当前点击图片的真实大小,并显示弹出层及大图*/
  488. $("<img/>").attr("src", src).load(function(){
  489. var windowW = $(window).width();//获取当前窗口宽度
  490. var windowH = $(window).height();//获取当前窗口高度
  491. var realWidth = this.width;//获取图片真实宽度
  492. var realHeight = this.height;//获取图片真实高度
  493. var imgWidth, imgHeight;
  494. var scale = 0.8;//缩放尺寸,当图片真实宽度和高度大于窗口宽度和高度时进行缩放
  495. if(realHeight>windowH*scale) {//判断图片高度
  496. imgHeight = windowH*scale;//如大于窗口高度,图片高度进行缩放
  497. imgWidth = imgHeight/realHeight*realWidth;//等比例缩放宽度
  498. if(imgWidth>windowW*scale) {//如宽度扔大于窗口宽度
  499. imgWidth = windowW*scale;//再对宽度进行缩放
  500. }
  501. } else if(realWidth>windowW*scale) {//如图片高度合适,判断图片宽度
  502. imgWidth = windowW*scale;//如大于窗口宽度,图片宽度进行缩放
  503. imgHeight = imgWidth/realWidth*realHeight;//等比例缩放高度
  504. } else {//如果图片真实高度和宽度都符合要求,高宽不变
  505. imgWidth = realWidth;
  506. imgHeight = realHeight;
  507. }
  508. $(bigimg).css("width",imgWidth);//以最终的宽度对图片缩放
  509. var w = (windowW-imgWidth)/2;//计算图片与窗口左边距
  510. var h = (windowH-imgHeight)/2;//计算图片与窗口上边距
  511. $(innerdiv).css({"top":h, "left":w});//设置#innerdiv的top和left属性
  512. $(outerdiv).fadeIn("fast");//淡入显示#outerdiv及.pimg
  513. });
  514. $(outerdiv).click(function(){//再次点击淡出消失弹出层
  515. $(this).fadeOut("fast");
  516. });
  517. }