guide_the_message.js 11 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348
  1. ! function() {
  2. var httpData = GetRequest();
  3. new Vue({
  4. el: "#app",
  5. data: {
  6. imgData: {
  7. accept: 'image/gif, image/jpeg, image/png, image/jpg',
  8. },
  9. isCollapse: false,
  10. upImgs: [],
  11. upImgArr: [],
  12. planid: httpData['planid'],
  13. service: {
  14. relationRecordImg:{},
  15. messageList:{}
  16. }
  17. },
  18. mounted: function() {
  19. this.getServiceItem();
  20. },
  21. methods: {
  22. zwkf: function() {
  23. top.layer.msg('此功能暂未开放', {
  24. icon: 1
  25. });
  26. },
  27. jkjy: function(patient, planId) {
  28. var vm = this
  29. top.layer.open({
  30. type: 2,
  31. // offset: ['100px'], //右下角弹出
  32. area: ['80%', '648px'],
  33. shade: 0.5,
  34. title: '健康教育',
  35. fixed: true, //不固定
  36. maxmin: true,
  37. closeBtn: 1,
  38. shift: 5,
  39. shadeClose: false, //点击遮罩关闭层
  40. content: '../../article/html/article.html?code=' + patient + '&planId=' + planId + '&isReha=true'
  41. });
  42. },
  43. // 健康指导
  44. jkzd: function(planId,patient) {
  45. var vm = this
  46. top.layer.open({
  47. type: 2,
  48. // offset: ['100px'], //右下角弹出
  49. area: ['80%', '648px'],
  50. shade: 0.5,
  51. title: '健康教育',
  52. fixed: true, //不固定
  53. maxmin: true,
  54. closeBtn: 1,
  55. shift: 5,
  56. shadeClose: false, //点击遮罩关闭层
  57. content: '../../guidance/html/index.html#/person-edit-panel?patient=' + patient + '&planId=' + planId
  58. });
  59. },
  60. qwapp: function() {
  61. top.layer.msg('请前往app处理', {
  62. icon: 5
  63. });
  64. },
  65. getServiceItem: function() {
  66. var vm = this;
  67. var loginDoctor = JSON.parse(window.localStorage.getItem('wlyyAgent'));
  68. var loadding = top.layer.load(0, {
  69. shade: false
  70. }); //0代表加载的风格,支持0-2
  71. rehaAPI.serviceItem({
  72. planDetailId: vm.planid
  73. }).then(function(res) {
  74. top.layer.close(loadding);
  75. if(res.status == 200) {
  76. vm.service = res.data;
  77. var isZK=loginDoctor.doctorType==1?true:false;
  78. vm.service.isZK=isZK;
  79. if(vm.service.isMyTask==1){//执行者
  80. vm.service.isCK=true;//无法显示按钮
  81. if(loginDoctor.uid==vm.service.specialistDoctorCode){//说明我自己是创建者
  82. vm.service.isCK=false;
  83. vm.service.isCreate=true;
  84. }
  85. }else{
  86. if(loginDoctor.uid==vm.service.specialistDoctorCode){//说明我自己是创建者
  87. vm.service.isCreate=true;
  88. }
  89. }
  90. } else {
  91. top.layer.msg(res.msg, {
  92. icon: 5
  93. });
  94. }
  95. if(vm.service.status==1){
  96. var index = top.layer.getFrameIndex(window.name); //先得到当前iframe层的索引
  97. top.layer.title('服务记录详情', index) //再改变当前层的标题
  98. }
  99. })
  100. },
  101. zdly: function(data) {
  102. var vm = this
  103. var loginDoctor = JSON.parse(window.localStorage.getItem('wlyyAgent'));
  104. var otherCode, otherName;
  105. var planDetailId = data.planDetaiId;
  106. if(loginDoctor.doctorType == 1) {
  107. otherCode = data.familyDoctorCode;
  108. otherName = data.familyDoctorName;
  109. } else {
  110. otherCode = data.specialistDoctorCode;
  111. otherName = data.specialistDoctorName;
  112. }
  113. top.layer.open({
  114. type: 2,
  115. // offset: ['100px'], //右下角弹出
  116. area: ['80%', '600px'],
  117. shade: 0.5,
  118. title: '指导留言',
  119. fixed: true, //不固定
  120. maxmin: true,
  121. closeBtn: 1,
  122. shift: 5,
  123. shadeClose: false, //点击遮罩关闭层
  124. content: '../../consulting/html/consulting.html?otherCode=' + otherCode + '&otherName=' + encodeURI(otherName) + '&planDetailId=' + planDetailId,
  125. end: function() { // 未点击确定按钮,点击关闭按钮
  126.       
  127. vm.getServiceItem();    
  128. }
  129. });
  130. },
  131. deleteImg: function(idx) {
  132. console.log(idx)
  133. this.upImgs.splice(idx, 1)
  134. },
  135. chakan: function() {
  136. this.isCollapse = !this.isCollapse;
  137. },
  138. upLoadImgToBase64: function() {
  139. var vm = this;
  140. var img1 = event.target.files[0];
  141. console.log(img1)
  142. var reader = new FileReader();
  143. var type = img1.type; //文件的类型,判断是否是图片
  144. var size = img1.size; //文件的大小,判断图片的大小
  145. if(this.imgData.accept.indexOf(type) == -1) {
  146. alert('请选择我们支持的图片格式!');
  147. return false;
  148. }
  149. if(size > 3145728) {
  150. alert('请选择3M以内的图片!');
  151. return false;
  152. }
  153. reader.readAsDataURL(img1);
  154. reader.onload = function(e) {
  155. vm.upImgs.push({
  156. baseUrl: e.target.result
  157. });
  158. vm.upImgArr.push(img1);
  159. // vm.uploadImg(vm.upImgArr);
  160. }
  161. },
  162. qrwc: function(patient,type) {
  163. var vm = this;
  164. vm.saveRehabilitationOperateRecord(patient,type);
  165. },
  166. saveRehabilitationOperateRecord:function(patient,type){
  167. var vm=this;
  168. var userInfo = JSON.parse(window.localStorage.getItem(httpRequest.agentName));
  169. var _type;
  170. if(type==0){
  171. _type=5
  172. }
  173. if(type!=0){
  174. vm.uploadImg(vm.upImgArr, vm.updateNoteAndImageRehabilitationOperate);
  175. return ;//只有上传需要新增
  176. }
  177. var params={
  178. rehabilitationDetailId:vm.planid,
  179. node:null,
  180. patientCode:patient,
  181. doctorCode:userInfo.uid,
  182. relationRecordType:_type,
  183. relationRecordCode:'',
  184. relationRecordImg:null,
  185. status:0
  186. }
  187. rehaAPI.saveRehabilitationOperateRecord({dataJson:JSON.stringify(params)}).then(function(res){
  188. var icon=5;
  189. if(res.status==200){
  190. icon=1;
  191. vm.uploadImg(vm.upImgArr, vm.updateNoteAndImageRehabilitationOperate);
  192. }
  193. })
  194. },
  195. //上传图片
  196. uploadImg: function(data, cb) {
  197. var vm = this;
  198. var len = data.length;
  199. if(!len) {
  200. cb && cb();
  201. } else {
  202. var file = data[len - 1];
  203. var formData = new FormData();
  204. formData.append('file', file);
  205. rehaAPI.upload(formData).then(function(res) {
  206. console.log(res)
  207. if(res.status == 200) {
  208. console.log(vm.upImgs[len - 1])
  209. vm.upImgs[len - 1].img = res.data;
  210. data.pop();
  211. vm.uploadImg(data, cb);
  212. }
  213. })
  214. }
  215. },
  216. viewDetial:function(type,code){
  217. var vm=this;
  218. if(type == 3) {
  219. top.layer.msg('客户端暂不支持查询健康指导记录');
  220. } else if(type==4){
  221. top.layer.msg('客户端暂不支持查询随访记录');
  222. }else{
  223. top.layer.open({
  224. type: 2,
  225. // offset: ['100px'], //右下角弹出
  226. area: ['80%', '600px'],
  227. shade: 0.5,
  228. title: '指导教育',
  229. fixed: true, //不固定
  230. maxmin: true,
  231. closeBtn: 1,
  232. shift: 5,
  233. shadeClose: false, //点击遮罩关闭层
  234. content: '../../article/html/article-info.html?articleId=' + code,
  235. end: function() { // 未点击确定按钮,点击关闭按钮
  236. vm.getServiceItem();    
  237. }
  238. });
  239. }
  240. },
  241. updateNoteAndImageRehabilitationOperate: function() {
  242. var vm = this;
  243. var _image = [];
  244. for(var i in vm.upImgs) {
  245. _image.push(vm.upImgs[i].img);
  246. }
  247. var params = {
  248. planDetailId: vm.planid,
  249. node: vm.service.node,
  250. image: JSON.stringify(_image)
  251. }
  252. var loadding = top.layer.load(0, {
  253. shade: false
  254. }); //0代表加载的风格,支持0-2
  255. rehaAPI.updateNoteAndImageRehabilitationOperate(params).then(function(res) {
  256. top.layer.close(loadding);
  257. console.log(res)
  258. if(res.status == 200) {
  259. vm.getServiceItem();
  260. }
  261. })
  262. },
  263. getContent: function(value,type) {
  264. var res=value;
  265. if(type==2 || type==9){
  266. res = "<img src='"+httpRequest.getImgUrl(res)+"'>";
  267. }else if(type==3){
  268. res = '【语音】';
  269. }else if(type==19){
  270. res = '【聊天记录】';
  271. }else if(type==12){
  272. res = '【视频】';
  273. }
  274. return res;
  275. }
  276. },
  277. filters: {
  278. formatDate: function(value, format) {
  279. if(!value) return;
  280. var fmt = format || "yyyy-MM-dd hh:mm";
  281. var date = new Date(value);
  282. if(/(y+)/.test(fmt)) {
  283. fmt = fmt.replace(RegExp.$1, (date.getFullYear() + '').substr(4 - RegExp.$1.length));
  284. }
  285. let o = {
  286. 'M+': date.getMonth() + 1,
  287. 'd+': date.getDate(),
  288. 'h+': date.getHours(),
  289. 'm+': date.getMinutes(),
  290. 's+': date.getSeconds()
  291. };
  292. for(let k in o) {
  293. if(new RegExp(`(${k})`).test(fmt)) {
  294. let str = o[k] + '';
  295. fmt = fmt.replace(RegExp.$1, (RegExp.$1.length === 1) ? str : ('00' + str).substr(str.length));
  296. }
  297. }
  298. return fmt;
  299. },
  300. getImgUrl: function(value) {
  301. var url = httpRequest.getImgUrl(value);
  302. return url;
  303. }
  304. }
  305. })
  306. $("body").on('click','img',function(){
  307. var _this = $(this);//将当前的img元素作为_this传入函数
  308. imgShow("#outerdiv", "#innerdiv", "#bigimg", _this);
  309. });
  310. function imgShow(outerdiv, innerdiv, bigimg, _this){
  311. var src = _this.attr("src");//获取当前点击的pimg元素中的src属性
  312. $(bigimg).attr("src", src);//设置#bigimg元素的src属性
  313. /*获取当前点击图片的真实大小,并显示弹出层及大图*/
  314. $("<img/>").attr("src", src).load(function(){
  315. var windowW = $(window).width();//获取当前窗口宽度
  316. var windowH = $(window).height();//获取当前窗口高度
  317. var realWidth = this.width;//获取图片真实宽度
  318. var realHeight = this.height;//获取图片真实高度
  319. var imgWidth, imgHeight;
  320. var scale = 0.8;//缩放尺寸,当图片真实宽度和高度大于窗口宽度和高度时进行缩放
  321. if(realHeight>windowH*scale) {//判断图片高度
  322. imgHeight = windowH*scale;//如大于窗口高度,图片高度进行缩放
  323. imgWidth = imgHeight/realHeight*realWidth;//等比例缩放宽度
  324. if(imgWidth>windowW*scale) {//如宽度扔大于窗口宽度
  325. imgWidth = windowW*scale;//再对宽度进行缩放
  326. }
  327. } else if(realWidth>windowW*scale) {//如图片高度合适,判断图片宽度
  328. imgWidth = windowW*scale;//如大于窗口宽度,图片宽度进行缩放
  329. imgHeight = imgWidth/realWidth*realHeight;//等比例缩放高度
  330. } else {//如果图片真实高度和宽度都符合要求,高宽不变
  331. imgWidth = realWidth;
  332. imgHeight = realHeight;
  333. }
  334. $(bigimg).css("width",imgWidth);//以最终的宽度对图片缩放
  335. var w = (windowW-imgWidth)/2;//计算图片与窗口左边距
  336. var h = (windowH-imgHeight)/2;//计算图片与窗口上边距
  337. $(innerdiv).css({"top":h, "left":w});//设置#innerdiv的top和left属性
  338. $(outerdiv).fadeIn("fast");//淡入显示#outerdiv及.pimg
  339. });
  340. $(outerdiv).click(function(){//再次点击淡出消失弹出层
  341. $(this).fadeOut("fast");
  342. });
  343. }
  344. }();