server-items-detail.js 35 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992002012022032042052062072082092102112122132142152162172182192202212222232242252262272282292302312322332342352362372382392402412422432442452462472482492502512522532542552562572582592602612622632642652662672682692702712722732742752762772782792802812822832842852862872882892902912922932942952962972982993003013023033043053063073083093103113123133143153163173183193203213223233243253263273283293303313323333343353363373383393403413423433443453463473483493503513523533543553563573583593603613623633643653663673683693703713723733743753763773783793803813823833843853863873883893903913923933943953963973983994004014024034044054064074084094104114124134144154164174184194204214224234244254264274284294304314324334344354364374384394404414424434444454464474484494504514524534544554564574584594604614624634644654664674684694704714724734744754764774784794804814824834844854864874884894904914924934944954964974984995005015025035045055065075085095105115125135145155165175185195205215225235245255265275285295305315325335345355365375385395405415425435445455465475485495505515525535545555565575585595605615625635645655665675685695705715725735745755765775785795805815825835845855865875885895905915925935945955965975985996006016026036046056066076086096106116126136146156166176186196206216226236246256266276286296306316326336346356366376386396406416426436446456466476486496506516526536546556566576586596606616626636646656666676686696706716726736746756766776786796806816826836846856866876886896906916926936946956966976986997007017027037047057067077087097107117127137147157167177187197207217227237247257267277287297307317327337347357367377387397407417427437447457467477487497507517527537547557567577587597607617627637647657667677687697707717727737747757767777787797807817827837847857867877887897907917927937947957967977987998008018028038048058068078088098108118128138148158168178188198208218228238248258268278288298308318328338348358368378388398408418428438448458468478488498508518528538548558568578588598608618628638648658668678688698708718728738748758768778788798808818828838848858868878888898908918928938948958968978988999009019029039049059069079089099109119129139149159169179189199209219229239249259269279289299309319329339349359369379389399409419429439449459469479489499509519529539549559569579589599609619629639649659669679689699709719729739749759769779789799809819829839849859869879889899909919929939949959969979989991000100110021003100410051006100710081009101010111012101310141015101610171018101910201021102210231024102510261027102810291030103110321033103410351036103710381039104010411042104310441045104610471048104910501051105210531054105510561057105810591060106110621063106410651066
  1. var currentGMT=new Date();//当前时间GMT
  2. function showSuccessMessage(msg) {
  3. layer.msg(msg, {
  4. icon: 1
  5. })
  6. }
  7. function showSuccessMessage(msg) {
  8. layer.msg(msg, {
  9. icon: 1
  10. })
  11. }
  12. function showErrorMessage(msg) {
  13. layer.msg(msg, {
  14. icon: 5
  15. })
  16. }
  17. function showWarningMessage(msg) {
  18. layer.msg(msg, {
  19. icon: 2
  20. })
  21. }
  22. function showInfoMessage(msg) {
  23. layer.msg(msg, {
  24. icon: 6
  25. })
  26. }
  27. var previewLayerIndex, followupLayerIndex, KFZDlayerIndex;
  28. function closeFollowUpLayer(planDetaiId, relationCode, flag){
  29. if($.isArray(relationCode)) {
  30. $.each(relationCode, function(index, item){
  31. _vm.saveRehabilitationOperateRecord(planDetaiId, 6, item, flag)
  32. })
  33. } else {
  34. _vm.saveRehabilitationOperateRecord(planDetaiId, 6, relationCode, flag)
  35. }
  36. layer.close(followupLayerIndex)
  37. }
  38. function closeKFZDlayer(planDetaiId, relationRecordId){
  39. layer.close(KFZDlayerIndex)
  40. _vm.saveRehabilitationOperateRecord(planDetaiId, 5)
  41. }
  42. function closeKFZD(){
  43. layer.close(KFZDlayerIndex)
  44. _vm.initData()
  45. }
  46. var _vm
  47. Vue.component('server-items-detail', {
  48. template: '<div class="p15 ui-grid ui-grid-vertical" style="height:calc(100%);position: relative;">\
  49. <div class="icon-group">\
  50. <i class="icon-edit el-icon-edit-outline mr15" @click="goToEditConfig"></i>\
  51. <i class="icon-close el-icon-close" @click="onClose"></i>\
  52. </div>\
  53. <div class="c-t-center c-f18 c-333 mt15">服务内容-{{service.title}}</div>\
  54. <div class="c-t-center c-f17 c-666 mt10">{{patientname}}患者{{service.title}}计划</div>\
  55. <div class="c-333 ptb10 c-f17 mt10">指导留言</div>\
  56. <div @click="zdly(service)">\
  57. <div class="c-f14 c-666" v-if="!message.isImg" >{{message.content}}</div>\
  58. <div class="mt10" v-else><img :src="message.content" @click.stop="previewImg(message.content)" style="width:60px;height:60px;" :data-preview-src="message.content" data-preview-group="1"/></div>\
  59. </div>\
  60. <div v-if="islimit" class="mtb10 ui-grid">\
  61. <div class="ui-col-1">\
  62. <i class="icon icon-prev icon-20" @click="preMonth"></i>\
  63. <span class="currentDay">{{currentDay}}</span>\
  64. <i class="icon icon-next icon-20" @click="nextMonth"></i></span>\
  65. </div>\
  66. <div class="pull-right switch-list" style="text-align:center">\
  67. <span class="rili" :class="{active:(tabStatus==1)}" @click="tabStatus=1"><i class="icon icon-rili icon-20"></i></span>\
  68. <span class="shijianzhou" :class="{active:(tabStatus==2)}" @click="tabStatus=2"><i class="icon icon-liebiao icon-20"></i></span>\
  69. </div>\
  70. </div>\
  71. <div v-if="islimit&&tabStatus==1" class="ui-col-1" style="overflow: hidden; overflow-y: scroll;">\
  72. <div class="calendar-week">\
  73. <div class="flex-box text-center">\
  74. <div class="flex-box-item">周一</div>\
  75. <div class="flex-box-item">周二</div>\
  76. <div class="flex-box-item">周三</div>\
  77. <div class="flex-box-item">周四</div>\
  78. <div class="flex-box-item">周五</div>\
  79. <div class="flex-box-item">周六</div>\
  80. <div class="flex-box-item">周日</div>\
  81. </div>\
  82. </div>\
  83. <div class="calendar-days">\
  84. <div v-for="items in calendarData" class="flex-box">\
  85. <div class="calendar-day" v-for="item in items" @click="viewDetail(item.planDetailIds)" :is-future="item.future">\
  86. <span class="day-number">{{item.day}}</span>\
  87. <div class="task-icon">\
  88. <i v-if="item.myTaskFlag" class="icon icon-flag icon-20"></i>\
  89. <i v-if="item.finishFlag" class="icon icon-check"></i>\
  90. </div>\
  91. <div class="coloured-box">\
  92. <span v-if="item.specialist" class="coloured-ribbon coloured-ribbon-blue">专<br />科</span>\
  93. <span v-if="item.family" class="coloured-ribbon coloured-ribbon-green">家<br />医</span>\
  94. </div>\
  95. <div class="progress-box">\
  96. <div class="progress" :style="{opacity:item.specialist?\'1\':\'0\'}">\
  97. <span>{{(item.specialist && item.specialist.finish)}}/{{(item.specialist && item.specialist.all)}}</span>\
  98. <div class="progress-bar" role="progressbar" aria-valuenow="0" aria-valuemin="0" aria-valuemax="100" :style="{width: (item.specialist?(item.specialist.finish/item.specialist.all):0)*100+\'%\'}"></div>\
  99. </div>\
  100. <div class="progress" :style="{opacity:item.family?\'1\':\'0\'}">\
  101. <span>{{(item.family && item.family.finish)}}/{{(item.family && item.family.all)}}</span>\
  102. <div class="progress-bar progress-bar-success" role="progressbar" aria-valuenow="2" aria-valuemin="0" aria-valuemax="100" :style="{width: (item.family?(item.family.finish/item.family.all):0)*100+\'%\'}"></div>\
  103. </div>\
  104. <p v-if="!item.noService" class="mb0 f12" :class="{\'visibility-hide\':!curTask}" style="line-height: 1;">{{curTaskName || \'&emsp;\'}}</p>\
  105. </div>\
  106. <p v-if="item.noService" class="no-server">无服务项</p>\
  107. </div>\
  108. </div>\
  109. </div>\
  110. </div>\
  111. <div v-show="tabStatus==2" class="ui-col-1 mt10" style="overflow-y: auto">\
  112. <div class="time-axis">\
  113. <div>\
  114. <table class="table">\
  115. <tr>\
  116. <th style="padding-right: 50px;text-align: right;">时间</th>\
  117. <th>项目</th>\
  118. <th>执行人员</th>\
  119. <th>执行地点</th>\
  120. <th class="text-center">相关记录</th>\
  121. <th class="text-center">状态</th>\
  122. </tr>\
  123. <tr v-for="item in timeAxisData" :is-future="item.future">\
  124. <td class="time text-right time-box">\
  125. <p class="mb5">{{item.date}}</p>\
  126. <p class="mb0">{{item.time}}</p>\
  127. <span class="cur-status">{{item.html}}</span>\
  128. </td>\
  129. <td class="project-name mw400">\
  130. <p class="mt10">{{item.name}}</p>\
  131. <p class="ellipsis mb0">{{item.content}}</p>\
  132. </td>\
  133. <td class="executor">{{item.doctorName}}</td>\
  134. <td class="place-of-execution">{{item.hospitalName}}</td>\
  135. <td class="view-task" @click="onViewDetail(item,1)">查看</td>\
  136. <td class="task-status" :class="item.future==-1?\'c-ff3b30\':(item.status==0?\'c-666\':\'\')">{{item.status==0?\'未完成\':(item.status==1?\'已完成\':\'已预约\')}}</td>\
  137. </tr>\
  138. <tr v-if="!timeAxisData.length">\
  139. <td colspan="6" class="f16 ptb10 text-center">\
  140. <img src="../../../images/wushuju_img.png" class="mt50"/>\
  141. <p class="c-666">暂无数据</p>\
  142. </td>\
  143. </tr>\
  144. </table>\
  145. </div>\
  146. </div>\
  147. </div>\
  148. <div v-if="docInfo.doctorType==1" class="c-t-center mt15">\
  149. <button v-if="!islimit&&service.executeDoctorCode!=docInfo.uid" class="btn btn-12b7f5" @click="zdly(service)">指导留言</button>\
  150. </div>\
  151. <div v-else-if="!islimit" class="c-t-center mt15">\
  152. <button v-if="service.isMyTask" class="btn btn-12b7f5" @click="zdly(service)">查看留言</button>\
  153. <button v-if="service.isMyTask&&service.type==\'1\'" class="btn btn-yuyue" @click="addCompleteRecord()">添加完成记录</button>\
  154. <button v-if="service.isMyTask&&service.type==\'4\'" class="btn btn-yuyue" @click="sendSpecialistWeixinMessage(planDetaiId,4)">发送提醒</button>\
  155. <button v-if="service.isMyTask&&service.type==\'4\'" class="btn btn-12b7f5" @click="toDoorDialog">代预约</button>\
  156. <button v-if="service.isMyTask&&service.type==\'5\'" class="btn btn-yuyue" @click="kfzd()">发送康复指导</button>\
  157. <button v-if="service.isMyTask&&service.type==\'6\'" class="btn btn-yuyue" @click="sfjh()">创建随访计划</button>\
  158. <button v-if="service.isMyTask&&service.type==\'7\'" class="btn btn-yuyue" @click="sendSpecialistWeixinMessage(planDetaiId,7)">发送提醒</button>\
  159. <button v-if="service.isMyTask&&service.type==\'7\'" class="btn btn-12b7f5" @click="qwapp">代预约</button>\
  160. </div>\
  161. <div id="completeRecord" style="display: none; padding: 15px 15px 0;">\
  162. <div class="note-info pt10">\
  163. <p class="f14 c-333">服务完成笔记</p>\
  164. <textarea class="form-control" style="resize: none;" rows="4" placeholder="可备注您的服务记录" v-model="node"></textarea>\
  165. </div>\
  166. <div class="note-info ptb10">\
  167. <p class="f14 c-333">相关记录</p>\
  168. <ul class="upload-box">\
  169. <li class="flex-box" v-for="(img,index) in upImgs">\
  170. <div class="upload-img-box">\
  171. <img :src="img.baseUrl" @click="previewImg(img.baseUrl)"/>\
  172. </div>\
  173. <a class="delete-img" @click="deleteImg(index)">&times;</a>\
  174. </li>\
  175. <li class="flex-box" v-if="upImgs.length<5">\
  176. <span class="add-img">+</span>\
  177. <input type="file" @change="upLoadImgToBase64" class="upload-img" />\
  178. </li>\
  179. </ul>\
  180. </div>\
  181. </div>\
  182. </div>',
  183. props: ['patientname','patientcode', 'planid', 'plandetailid'],
  184. data: function() {
  185. return {
  186. ynow: currentGMT.getFullYear(),//年份
  187. mnow: currentGMT.getMonth(),//月份(比实际少一个月---0开始至11)
  188. dnow: currentGMT.getDate(),//当前日
  189. currentDay:null,//带中文格式的当前年月
  190. calendarData:[],//日历数据
  191. timeAxisData: [], //时间轴数据
  192. tabStatus: 1,
  193. title: '',
  194. docInfo: JSON.parse(window.localStorage.getItem('wlyyAgent')),
  195. upImgs: [],
  196. upImgArr: [],
  197. imgData: {
  198. accept: 'image/gif, image/jpeg, image/png, image/jpg',
  199. },
  200. node: '',
  201. layerIndex: undefined,
  202. planDetaiId:'',
  203. service:{
  204. relationRecordImg:{},
  205. messageList:{},
  206. },
  207. message:{isImg:false,content:""},
  208. islimit: false,
  209. relationRecordId: null
  210. }
  211. },
  212. watch:{
  213. tabStatus:function(){
  214. if(this.islimit){
  215. this.goToLoadData(true);
  216. }
  217. }
  218. },
  219. mounted: function() {
  220. _vm = this
  221. this.initData()
  222. },
  223. methods: {
  224. initData: function(){
  225. var vm = this
  226. this.planDetaiId = this.plandetailid
  227. this.getServiceItem()
  228. },
  229. getServiceItem: function() {
  230. var vm = this;
  231. var loadding = top.layer.load(0, {
  232. shade: false
  233. }); //0代表加载的风格,支持0-2
  234. rehaAPI.serviceItem({
  235. planDetailId: vm.planDetaiId
  236. }).then(function(res) {
  237. top.layer.close(loadding);
  238. if(res.status == 200) {
  239. vm.service = res.data;
  240. var isZK=vm.docInfo.doctorType==1?true:false;
  241. vm.service.isZK=isZK;
  242. if(vm.service.isMyTask==1){//执行者
  243. vm.service.isCK=true;//无法显示按钮
  244. if(vm.docInfo.uid==vm.service.specialistDoctorCode){//说明我自己是创建者
  245. vm.service.isCK=false;
  246. vm.service.isCreate=true;
  247. }
  248. }else{
  249. if(vm.docInfo.uid==vm.service.specialistDoctorCode){//说明我自己是创建者
  250. vm.service.isCreate=true;
  251. }
  252. }
  253. if(vm.service.frequencyCode){
  254. vm.islimit = true
  255. vm.goToLoadData(true)
  256. vm.monDetail()
  257. } else {
  258. vm.islimit = false
  259. vm.tabStatus = 2
  260. vm.selectByPlanDetaiId()
  261. }
  262. vm.selectByGuidance()
  263. vm.$forceUpdate()
  264. } else {
  265. showErrorMessage(res.msg)
  266. }
  267. })
  268. },
  269. // 获取康复计划服务项的指导留言
  270. selectByGuidance: function(){
  271. var vm = this
  272. var params = {
  273. planId: vm.planid,
  274. itemCode: vm.service.type
  275. }
  276. rehaAPI.selectByGuidance(params).then(function(res){
  277. if(res.status==200){
  278. var messageIndex = _.findIndex(res.data, {doctor_type: 1});
  279. if(messageIndex>-1){
  280. var message = res.data[messageIndex]
  281. var contentType = message.content_type
  282. if(contentType==2||contentType==9){
  283. vm.message.isImg = true
  284. }
  285. vm.message.content = vm.getContent(message.content,message.content_type)
  286. }else{
  287. vm.message.content = "无"
  288. }
  289. } else {
  290. showErrorMessage(res.msg)
  291. }
  292. })
  293. },
  294. goToEditConfig: function(){
  295. var vm = this
  296. location.href = "../../recover/html/new_recover.html?patient=" + vm.patientcode + '&isEditConfig=true&planId='+vm.planid+'&planDetailId='+vm.planDetaiId
  297. },
  298. closeAllLayer: function(name, planDetaiId, type, relationCode, flag){
  299. if(name=='预览康复指导'){
  300. layer.close()
  301. }
  302. },
  303. // 提醒患者 num 1康复指导2康复下转3复诊提醒4上门服务提醒5家签提醒
  304. sendSpecialistWeixinMessage: function(planDetaiId, type){
  305. var vm = this
  306. var text = ''
  307. var patientName = vm.patientname
  308. var patientCode = vm.patientcode
  309. if(type==4){ // 上门服务
  310. text = '请问您是否确认提醒'+patientName+'居民预约上门护理服务?'
  311. } else if(type==7){ // 康复复诊
  312. text = '请问您是否确认提醒'+patientName+'居民进行复诊?'
  313. }
  314. var current=layer.confirm(text, {
  315. btn: ['确定', '取消'],
  316. title: "提示"
  317. }, function (index) {
  318. var _type = type == 4? 4:type==7?3:''
  319. var loading = layer.load(0, {shade: false})
  320. var params = {
  321. patient: patientCode,
  322. doctor: vm.docInfo.uid,
  323. type: _type,
  324. relationCode: planDetaiId,
  325. planId: vm.planid
  326. }
  327. rehaAPI.sendSpecialistWeixinMessage(params).then(function(res){
  328. layer.close(loading)
  329. if(res.status == 200){
  330. showSuccessMessage('提交成功!')
  331. if(_type==3 || _type==4){ // 提醒患者后,即认为是已完成
  332. vm.saveRehabilitationOperateRecord(planDetaiId, type)
  333. }
  334. } else {
  335. showErrorMessage(res.msg)
  336. }
  337. })
  338. layer.close(current); //再执行关闭
  339. })
  340. },
  341. // 添加完成记录
  342. addCompleteRecord: function(){
  343. var vm = this
  344. var detailId = this.planDetaiId
  345. var type = vm.service.type
  346. $("#completeRecord").css('display','block')
  347. this.layerIndex = layer.open({
  348. type: 1,
  349. area: ['500px', '450px'],
  350. shade: 0.5,
  351. title: '添加完成记录',
  352. btn: ['确定', '关闭'], //只是为了演示
  353. shadeClose: false, //点击遮罩关闭层
  354. content: $("#completeRecord"),
  355. yes: function(){
  356. vm.saveRehabilitationOperateRecord(detailId, 1)
  357. layer.close(vm.layerIndex)
  358. },
  359. });
  360. },
  361. monDetail:function(){
  362. this.currentDay = this.ynow + '年'+ (this.mnow + 1) +'月';
  363. },
  364. is_leap:function(year) { //判断是否为闰年
  365. return (year%100==0?res=(year%400==0?1:0):res=(year%4==0?1:0));
  366. },
  367. preMonth:function(){ //上一个月
  368. if(this.mnow<=0){
  369. this.mnow=11;
  370. this.ynow=this.ynow-1;
  371. }else{
  372. this.mnow--;
  373. }
  374. this.monDetail();
  375. this.goToLoadData(true);
  376. },
  377. getPreMouth:function(){
  378. var pMnow,pYnow;
  379. if(this.mnow<=0){
  380. pMnow=11;
  381. pYnow=this.ynow-1;
  382. }else{
  383. pMnow=this.mnow-1;
  384. pYnow=this.ynow;
  385. }
  386. var m_days=new Array(31,(28+this.is_leap(pYnow)),31,30,31,30,31,31,30,31,30,31); //每个月的天数
  387. return {
  388. days:m_days[pMnow],
  389. date:pYnow+'-'+(++pMnow>=10?pMnow:"0"+pMnow)
  390. }
  391. },
  392. nextMonth:function(){ //下一个月
  393. if(this.mnow>=11){
  394. this.mnow=0;
  395. this.ynow=this.ynow+1;
  396. }else{
  397. this.mnow++;
  398. }
  399. this.monDetail();
  400. this.goToLoadData(true);
  401. },
  402. getNextMouth:function(){
  403. var nMnow,nYnow;
  404. if(this.mnow>=11){
  405. nMnow=0;
  406. nYnow=this.ynow+1;
  407. }else{
  408. nMnow=this.mnow+1;
  409. nYnow=this.ynow;
  410. }
  411. var m_days=new Array(31,(28+this.is_leap(nYnow)),31,30,31,01,31,31,30,31,30,31); //每个月的天数
  412. return {
  413. days:m_days[nMnow],
  414. date:nYnow+'-'+(++nMnow>=10?nMnow:"0"+nMnow)
  415. }
  416. },
  417. goToLoadData:function(flag){//flag是否更新数据
  418. this.tabStatus==1 && (!this.calendarData.length || flag) && this.calendar();
  419. this.tabStatus==2 && (!this.timeAxisData.length || flag) && this.timeAxis();
  420. },
  421. calendar:function(){
  422. var nlstr = new Date(this.ynow,this.mnow,1); //当月第一天
  423. var firstday = nlstr.getDay()-1;//第一天星期几,默认是周日 我们改成周一
  424. firstday=firstday==-1?6:firstday;//如果是-1,说明当月的第一天是周日
  425. var m_days=new Array(31,(28+this.is_leap(this.ynow)),31,30,31,30,31,31,30,31,30,31); //每个月的天数
  426. var tr_str=Math.ceil((m_days[this.mnow] + firstday)/7); //当前月天数+第一天是星期几的数值 获得 表格行数
  427. var c_days=m_days[this.mnow];//当前月份的天数
  428. var p_arr=this.getPreMouth();
  429. var n_arr=this.getNextMouth();
  430. var i,k,idx,date_str;
  431. var dataArr=[];//天数/年月
  432. for(i=0;i<tr_str;i++) { //表格的行
  433. for(k=0;k<7;k++) { //表格每行的单元格
  434. idx=i*7+k; //单元格自然序列号
  435. date_str=idx-firstday+1; //计算日期
  436. var __ym;
  437. if(date_str<=0){//过滤无效日期(小于等于零的、大于月总天数的)
  438. date_str=date_str+p_arr['days'];//当前日期+上个月的天数就是上个月的日期
  439. __ym=p_arr['date'];
  440. }else if(date_str>c_days){
  441. date_str=date_str-c_days;//下个月的日期就是这个月的天数-当月的天数
  442. __ym=n_arr['date'];
  443. }else{
  444. __ym=this.ynow+'-'+(this.mnow>=9?"":"0")+(this.mnow+1);
  445. }
  446. dataArr.push({
  447. day:date_str,
  448. date:__ym
  449. });
  450. }
  451. }
  452. this.__Data=dataArr;
  453. this.calenderPlanDetail();
  454. },
  455. // 日历有计划数据处理
  456. planHandleData: function(data, day, mounth) {
  457. var item = data;
  458. item.day = day;
  459. if(mounth) {item.mounth = mounth}
  460. var finishFlag=false
  461. var sFlag=false;
  462. var fFlag=false;
  463. if(item.specialist){
  464. if(item.specialist.all==item.specialist.finish){
  465. sFlag=true;
  466. }
  467. }else{
  468. sFlag = true;
  469. }
  470. if(item.family){
  471. if(item.family.all==item.family.finish){
  472. fFlag = true;
  473. }
  474. }else{
  475. fFlag = true;
  476. }
  477. finishFlag = sFlag && fFlag;
  478. item.finishFlag=finishFlag;
  479. return item
  480. },
  481. calenderPlanDetail:function(){
  482. var vm=this;
  483. var __days=vm.__Data;
  484. var lastDay=(__days.concat()).pop().day;
  485. lastDay=lastDay>9?lastDay:'0'+lastDay;
  486. if(vm.searchTask || vm.status || vm.status == 0) {
  487. vm.isFastSearch = true
  488. } else {
  489. vm.isFastSearch = false
  490. }
  491. var params={
  492. executeStartTime: vm.isFastSearch ? '' : __days[0].date+'-'+__days[0].day+' 00:00:00',//日历开始时间(格式:yyyy-MM-dd HH:mm:ss)
  493. executeEndTime: vm.isFastSearch ? '' : (__days.concat()).pop().date+'-'+lastDay+' 23:59:59',//日历结束时间(格式:yyyy-MM-dd HH:mm:ss)
  494. planId:vm.planid,//计划id
  495. searchTask: vm.service.type,//快速查找任务:(1、我的任务,2、健康教育,3、健康指导,4、随访)
  496. status: null,//任务状态(0未完成,1已完成,2已预约)
  497. }
  498. rehaAPI.calendarPlanDetail(params).then(function(res){
  499. vm.curTask=vm.searchTask;
  500. vm.curTaskName=vm.searchTaskName;
  501. vm.calendarData=[];
  502. var list = [];
  503. if(res.status==200){
  504. var data=res.data
  505. // 快速查找
  506. if(vm.isFastSearch) {
  507. vm.searchData = []
  508. var searchData0 = [],
  509. searchData1 = [],
  510. searchData2 = [];
  511. for(var setM = 1; setM <= 12; setM++) {
  512. var _setM = setM > 9 ? setM : '0' + setM,
  513. _setY = new Date().getFullYear();
  514. var data0 = [],
  515. data1 = [],
  516. data2 = [];
  517. for(var i in data) {
  518. var getY = i.split("-")[0],
  519. getM = i.split("-")[1],
  520. getD = i.split("-")[2];
  521. // 去年
  522. if(_setY - 1 == getY && _setM == getM) {
  523. var item = vm.planHandleData(data[i], getD, getM)
  524. data0.push(item)
  525. data.length && data.splice(i,1);
  526. } else if(_setY == getY && _setM == getM) { // 今年
  527. var item = vm.planHandleData(data[i], getD, getM)
  528. data1.push(item)
  529. data.length && data.splice(i,1);
  530. } else if(_setY + 1 == getY && _setM == getM) { // 明年
  531. var item = vm.planHandleData(data[i], getD, getM)
  532. data2.push(item)
  533. data.length && data.splice(i,1);
  534. }
  535. }
  536. if(data0.length) {
  537. var dataSort = vm.daysSort(data0)
  538. var addlen = (dataSort.length + 1) % 7 ? (dataSort.length + 1) % 7 : 7
  539. for(var i = 0; i < 7 - addlen; i++) {
  540. dataSort.push({
  541. noService:true
  542. })
  543. }
  544. searchData0.push(dataSort)
  545. }
  546. if(data1.length) {
  547. var dataSort = vm.daysSort(data1)
  548. var addlen = (dataSort.length + 1) % 7 ? (dataSort.length + 1) % 7 : 7
  549. for(var i = 0; i < 7 - addlen; i++) {
  550. dataSort.push({
  551. noService:true
  552. })
  553. }
  554. searchData1.push(dataSort)
  555. }
  556. if(data2.length) {
  557. var dataSort = vm.daysSort(data2)
  558. var addlen = (dataSort.length + 1) % 7 ? (dataSort.length + 1) % 7 : 7
  559. for(var i = 0; i < 7 - addlen; i++) {
  560. dataSort.push({
  561. noService:true
  562. })
  563. }
  564. searchData2.push(dataSort)
  565. }
  566. }
  567. if(searchData0.length) {vm.searchData.push(searchData0)}
  568. if(searchData1.length) {vm.searchData.push(searchData1)}
  569. if(searchData2.length) {vm.searchData.push(searchData2)}
  570. return false;
  571. }
  572. // 正常日历
  573. var _currentTimeStamp=+new Date(new Date().setHours(0, 0, 0, 0));
  574. for(var i in __days){
  575. var _key=__days[i].date+'-'+(__days[i].day>9?__days[i].day:'0'+__days[i].day);
  576. var item={
  577. noService:true,
  578. day:__days[i].day
  579. };
  580. for(var j in data){
  581. if(_key==j){
  582. item = vm.planHandleData(data[j], __days[i].day)
  583. data.length && data.splice(j,1);
  584. break;
  585. }
  586. }
  587. var thatTime=+new Date(_key)-8*60*60*1000;
  588. var future=_currentTimeStamp>thatTime?0:(_currentTimeStamp==thatTime?1:2);
  589. item.future=future;
  590. list.push(item);
  591. // vm.calendarData.push(item);
  592. }
  593. vm.calendarData = vm.chunkFunction(list, 7)
  594. }
  595. })
  596. },
  597. chunkFunction:function(arr, size) {
  598. let changeIndex = 0;
  599. let secondArr = [];
  600. while (changeIndex < arr.length) {
  601. secondArr.push(arr.slice(changeIndex, changeIndex += size))
  602. }
  603. return secondArr;
  604. },
  605. //时间轴请求
  606. timeAxis:function(){
  607. var m_days=new Array(31,(28+this.is_leap(this.ynow)),31,30,31,30,31,31,30,31,30,31); //每个月的天数
  608. var c_days=m_days[this.mnow];//当前月份的天数
  609. var __ym=this.ynow+'-'+(this.mnow>=9?"":"0")+(this.mnow+1);
  610. var dataArr=[];//天数/年月
  611. for(;c_days>0;c_days--){
  612. dataArr.push({
  613. day:c_days,
  614. date:__ym
  615. });
  616. }
  617. this.__xData=dataArr;
  618. this.calendarPlanDetailList();
  619. },
  620. //限频次 时间轴请求
  621. calendarPlanDetailList:function(){
  622. var vm=this;
  623. var __days=vm.__xData;
  624. var lastDay=(__days.concat()).pop().day;
  625. lastDay=lastDay>9?lastDay:'0'+lastDay;
  626. var params={
  627. executeEndTime:__days[0].date+'-'+__days[0].day+' 23:59:59',//日历开始时间(格式:yyyy-MM-dd HH:mm:ss)
  628. executeStartTime:(__days.concat()).pop().date+'-'+lastDay+' 00:00:00',//日历结束时间(格式:yyyy-MM-dd HH:mm:ss)
  629. planId:vm.planid,//计划id
  630. searchTask:vm.service.type, // 服务项
  631. status: null, //任务状态(0未完成,1已完成,2已预约)
  632. }
  633. rehaAPI.calendarPlanDetailList(params).then(function(res){
  634. if(res.status==200){
  635. // var _currentTimeStamp=+new Date(new Date().setHours(0, 0, 0, 0))
  636. var list=_.map(res.data||{},function(o){
  637. // var _time=o.executeTime.split(' ');
  638. // var thatTime=+new Date(_time[0]);
  639. // var future=_currentTimeStamp>thatTime?0:(_currentTimeStamp==thatTime?1:2);
  640. // (o.status==0 && _currentTimeStamp>thatTime) && (future=-1)
  641. // var _html=o.status==2?'预':(future==-1?'逾':'');
  642. // _html=future==1?'今':_html;
  643. // if(_html=='预') future=3;
  644. var _time=o.executeTime.split(' ');
  645. var _html = ''
  646. var d = new Date(o.execute_time);
  647. if(d.format("yyyy-MM-dd") == new Date().format("yyyy-MM-dd")) {
  648. o.firstSort = '1'
  649. future = 1
  650. _html = '今'
  651. if(o.status) {
  652. o.secondSort = '2'
  653. } else {
  654. o.secondSort = '1'
  655. }
  656. } else if(d > new Date()) {
  657. o.firstSort = '3'
  658. future = 2
  659. if(o.status) {
  660. o.secondSort = '2'
  661. } else {
  662. o.secondSort = '1'
  663. }
  664. } else {
  665. o.firstSort = '2'
  666. future = 0
  667. if(o.status == 0) {
  668. future = -1
  669. _html = '逾'
  670. o.secondSort = '1'
  671. } else {
  672. o.secondSort = '2'
  673. }
  674. }
  675. o.html=_html
  676. o.date=_time[0];
  677. o.time=_time[1];
  678. o.future=future;
  679. o.doctorName = o.doctor_name
  680. o.hospitalName = o.hospital_name
  681. return o;
  682. })||[];
  683. var nowTime = new Date().getTime()
  684. vm.timeAxisData = _.sortBy(list, function(o) {
  685. return o.firstSort + o.secondSort + (nowTime/o.execute_time)
  686. });
  687. } else {
  688. showErrorMessage(res.msg)
  689. }
  690. })
  691. },
  692. //不限频次 时间轴请求
  693. selectByPlanDetaiId: function(){
  694. var vm = this
  695. var params = {
  696. planId: this.planid,
  697. code: vm.service.type,
  698. page: 1,
  699. pagesize: 10000
  700. }
  701. rehaAPI.selectByPlanDetaiId(params).then(function(res){
  702. if(res.status==200){
  703. var list=_.map(res.data.list||{},function(o){
  704. var _time=o.completeTime.split(' ');
  705. var _html = ''
  706. var d = new Date(o.completeTime);
  707. if(d.format("yyyy-MM-dd") == new Date().format("yyyy-MM-dd")) {
  708. o.firstSort = '1'
  709. future = 1
  710. _html = '今'
  711. if(o.status) {
  712. o.secondSort = '2'
  713. } else {
  714. o.secondSort = '1'
  715. }
  716. } else if(d > new Date()) {
  717. o.firstSort = '3'
  718. future = 2
  719. if(o.status) {
  720. o.secondSort = '2'
  721. } else {
  722. o.secondSort = '1'
  723. }
  724. } else {
  725. o.firstSort = '2'
  726. future = 0
  727. if(o.status == 0) {
  728. future = -1
  729. _html = '逾'
  730. o.secondSort = '1'
  731. } else {
  732. o.secondSort = '2'
  733. }
  734. }
  735. o.html=_html
  736. o.date=_time[0];
  737. o.time=_time[1];
  738. o.future=future;
  739. o.hospitalName = o.hosiptalName
  740. return o;
  741. })||[];
  742. var nowTime = new Date().getTime()
  743. vm.timeAxisData = _.sortBy(list, function(o) {
  744. return o.firstSort + o.secondSort + (nowTime/o.execute_time)
  745. });
  746. } else {
  747. showErrorMessage(res.msg)
  748. }
  749. })
  750. },
  751. zdly: function(data) {
  752. var vm = this
  753. var otherCode, otherName;
  754. var planDetailId = vm.plandetailid;
  755. if(vm.docInfo.doctorType == 1) {
  756. if(docInfo.uid == data.specialistDoctorCode) {
  757. //当前医生为创建计划的专科医生,与全科医生聊天
  758. otherCode = data.familyDoctorCode;
  759. otherName = data.familyDoctorName;
  760. }else {
  761. //当前医生为专科,当前医生不是创建计划的专科医生,没反应
  762. return false
  763. }
  764. } else {
  765. otherCode = data.specialistDoctorCode;
  766. otherName = data.specialistDoctorName;
  767. }
  768. top.layer.open({
  769. type: 2,
  770. area: ['660px', '600px'],
  771. shade: 0.5,
  772. title: '指导留言',
  773. fixed: true, //不固定
  774. maxmin: true,
  775. closeBtn: 1,
  776. shift: 5,
  777. shadeClose: false, //点击遮罩关闭层
  778. content: '../../consulting/html/consulting.html?otherCode=' + otherCode + '&otherName=' + encodeURI(otherName) + '&planDetailId=' + planDetailId,
  779. end: function() { // 未点击确定按钮,点击关闭按钮      
  780. vm.initData()   
  781. }
  782. });
  783. },
  784. //康复指导
  785. kfzd:function(){
  786. var vm=this
  787. KFZDlayerIndex = layer.open({
  788. type: 2,
  789. // offset: ['100px'], //右下角弹出
  790. area: ['660px', '650px'],
  791. shade: 0.5,
  792. title: '康复指导',
  793. fixed: true, //不固定
  794. maxmin: true,
  795. closeBtn: 1,
  796. shift: 5,
  797. shadeClose: false, //点击遮罩关闭层
  798. content:'../../rehabilitation/html/rehabilitation_guidance.html?patient='+vm.patientcode+'&planDetaiId='+vm.planDetaiId+'&planId='+vm.planid + '&isRecordId=true',
  799. end: function() { // 未点击确定按钮,点击关闭按钮
  800. vm.initData()   
  801. }
  802. });
  803. },
  804. // 康复随访计划
  805. sfjh: function(){
  806. var vm=this
  807. followupLayerIndex = layer.open({
  808. type: 2,
  809. // offset: ['100px'], //右下角弹出
  810. area: ['660px', '650px'],
  811. shade: 0.5,
  812. title: '随访计划',
  813. fixed: true, //不固定
  814. maxmin: true,
  815. closeBtn: 1,
  816. shift: 5,
  817. shadeClose: false, //点击遮罩关闭层
  818. content:'../../followup/html/followup_newplan.html?patient='+vm.patientcode+'&planDetaiId='+vm.planDetaiId+'&planId='+vm.planid,
  819. end: function() { // 未点击确定按钮,点击关闭按钮
  820. vm.initData()    
  821. }
  822. });
  823. },
  824. upLoadImgToBase64: function() {
  825. var vm = this;
  826. var img1 = event.target.files[0];
  827. var reader = new FileReader();
  828. var type = img1.type; //文件的类型,判断是否是图片
  829. var size = img1.size; //文件的大小,判断图片的大小
  830. if(this.imgData.accept.indexOf(type) == -1) {
  831. alert('请选择我们支持的图片格式!');
  832. return false;
  833. }
  834. if(size > 3145728) {
  835. alert('请选择3M以内的图片!');
  836. return false;
  837. }
  838. reader.readAsDataURL(img1);
  839. reader.onload = function(e) {
  840. vm.upImgs.push({
  841. baseUrl: e.target.result
  842. });
  843. vm.upImgArr.push(img1);
  844. vm.uploadImg(vm.upImgArr);
  845. }
  846. },
  847. //上传图片
  848. uploadImg: function(data) {
  849. var vm = this;
  850. var len = data.length;
  851. if(len==0) {
  852. return
  853. } else {
  854. var file = data[len - 1];
  855. var formData = new FormData();
  856. formData.append('file', file);
  857. rehaAPI.upload(formData).then(function(res) {
  858. if(res.status == 200) {
  859. vm.upImgs[len - 1].img = res.data;
  860. data.pop();
  861. vm.$forceUpdate()
  862. vm.uploadImg(data);
  863. } else {
  864. layer.msg(res.msg, {
  865. icon: 5
  866. });
  867. }
  868. })
  869. }
  870. },
  871. saveRehabilitationOperateRecord:function(planDetailId, type, relationCode, flag){
  872. var vm=this
  873. var patientName = vm.patientname
  874. var patientCode = vm.patientcode
  875. var _image = [];
  876. for(var i in vm.upImgs) {
  877. _image.push(vm.upImgs[i].img);
  878. }
  879. var params={
  880. rehabilitationDetailId: planDetailId,
  881. node: vm.node||'',
  882. patientCode: patientCode,
  883. doctorCode: vm.docInfo.uid,
  884. relationRecordType: type,
  885. relationRecordCode: '',
  886. relationRecordImg: '',
  887. status: flag&&flag==2?1:0, // 改记录的状态
  888. relationCode: relationCode, //业务id
  889. flag: flag,//标记(1随访2临时随访)
  890. }
  891. rehaAPI.saveRehabilitationOperateRecord({dataJson:JSON.stringify(params)}).then(function(res){
  892. if(res.status==200){
  893. if(type==1){
  894. vm.updateNoteAndImageRehabilitationOperate(planDetailId)
  895. }else if(type==6){
  896. vm.updateRelationCodeByDetailId(planDetailId, relationCode)
  897. } else {
  898. vm.updateNoteAndImageRehabilitationOperate(planDetailId)
  899. }
  900. }else {
  901. showErrorMessage(res.msg)
  902. }
  903. })
  904. },
  905. updateNoteAndImageRehabilitationOperate: function(planDetailId, relationCode) {
  906. var vm = this;
  907. var _image = [];
  908. for(var i in vm.upImgs) {
  909. _image.push(vm.upImgs[i].img);
  910. }
  911. var params = {
  912. planDetailId: planDetailId,
  913. node: vm.node||'',
  914. image: JSON.stringify(_image)||''
  915. }
  916. if(relationCode){
  917. params['relationCode'] = relationCode
  918. }
  919. var loadding = top.layer.load(0, {
  920. shade: false
  921. }); //0代表加载的风格,支持0-2
  922. rehaAPI.updateNoteAndImageRehabilitationOperate(params).then(function(res) {
  923. top.layer.close(loadding);
  924. if(res.status == 200) {
  925. vm.initData()
  926. }else {
  927. showErrorMessage(res.msg)
  928. }
  929. })
  930. },
  931. onViewDetail: function(item, type){
  932. var planids, recordId;
  933. if(this.islimit){
  934. planids = item.id
  935. } else {
  936. planids = item.id
  937. recordId = item.recordId
  938. }
  939. this.viewDetail(planids,type, recordId)
  940. },
  941. viewDetail:function(planids,type, recordId){
  942. var vm=this;
  943. if(!planids){
  944. layer.msg('无服务项',{icon:5})
  945. return ;
  946. }
  947. if(type==1){ // 单个服务项
  948. var s = '../../rehabilitation/html/guide_the_message.html?planid='+planids+'&pId='+vm.planid+'&patient='+vm.patientcode+'&patientName='+vm.patientname
  949. if(recordId){
  950. s += '&recordId='+ recordId
  951. }
  952. layer.open({
  953. type: 2,
  954. area: ['800px', '700px'],
  955. shade: 0.5,
  956. title: '服务项目内容',
  957. fixed: true, //不固定
  958. maxmin: true,
  959. closeBtn:1,
  960. shift: 5,
  961. shadeClose: false, //点击遮罩关闭层
  962. content: s,
  963. end:function(){ // 未点击确定按钮,点击关闭按钮
  964.     vm.initData(); // 刷新
  965.   }
  966. });
  967. return ;
  968. }
  969. layer.open({ // 康复计划的所有服务项
  970. type: 2,
  971. area: ['800px', '700px'],
  972. shade: 0.5,
  973. title: '服务项目内容',
  974. fixed: true, //不固定
  975. maxmin: true,
  976. closeBtn:1,
  977. shift: 5,
  978. shadeClose: false, //点击遮罩关闭层
  979. content: '../../rehabilitation/html/service_item_content.html?planids='+planids+'&planId='+vm.planid+'&patient='+vm.patientcode+'&patientName='+vm.patientname,
  980. end:function(){
  981. vm.initData();
  982. }
  983. });
  984. },
  985. onClose: function(){
  986. this.$emit('onclose')
  987. },
  988. qwapp:function(){
  989. layer.msg('请前往app处理',{icon:5});
  990. },
  991. getContent: function(value,type) {
  992. var res=value;
  993. if(type==2 || type==9){
  994. res = "<img src='"+httpRequest.getImgUrl(res)+"' width='100px'>";
  995. }else if(type==3){
  996. res = '【语音】';
  997. }else if(type==19){
  998. res = '【聊天记录】';
  999. }else if(type==12){
  1000. res = '【视频】';
  1001. }
  1002. return res;
  1003. },
  1004. previewImg: function(url){
  1005. imgShow("#outerdiv", "#innerdiv", "#bigimg", url);
  1006. },
  1007. toDoorDialog(){
  1008. // console.log("server");
  1009. top.layer.open({
  1010. type: 2,
  1011. area: ['850px', '700px'],
  1012. shade: 0.5,
  1013. title: '代预约',
  1014. fixed: true, //不固定
  1015. maxmin: true,
  1016. closeBtn: 1,
  1017. // shift: 5,
  1018. shadeClose: false, //点击遮罩关闭层
  1019. content: `/app/rehabilitation/html/toDoorService.html?patient=${this.patientcode}&detailId=${this.plandetailid}`
  1020. })
  1021. },
  1022. }
  1023. })
  1024. function imgShow(outerdiv, innerdiv, bigimg, _this){
  1025. var src = _this.attr("src");//获取当前点击的pimg元素中的src属性
  1026. $(bigimg).attr("src", src);//设置#bigimg元素的src属性
  1027. /*获取当前点击图片的真实大小,并显示弹出层及大图*/
  1028. $("<img/>").attr("src", src).load(function(){
  1029. var windowW = $(window).width();//获取当前窗口宽度
  1030. var windowH = $(window).height();//获取当前窗口高度
  1031. var realWidth = this.width;//获取图片真实宽度
  1032. var realHeight = this.height;//获取图片真实高度
  1033. var imgWidth, imgHeight;
  1034. var scale = 0.8;//缩放尺寸,当图片真实宽度和高度大于窗口宽度和高度时进行缩放
  1035. if(realHeight>windowH*scale) {//判断图片高度
  1036. imgHeight = windowH*scale;//如大于窗口高度,图片高度进行缩放
  1037. imgWidth = imgHeight/realHeight*realWidth;//等比例缩放宽度
  1038. if(imgWidth>windowW*scale) {//如宽度扔大于窗口宽度
  1039. imgWidth = windowW*scale;//再对宽度进行缩放
  1040. }
  1041. } else if(realWidth>windowW*scale) {//如图片高度合适,判断图片宽度
  1042. imgWidth = windowW*scale;//如大于窗口宽度,图片宽度进行缩放
  1043. imgHeight = imgWidth/realWidth*realHeight;//等比例缩放高度
  1044. } else {//如果图片真实高度和宽度都符合要求,高宽不变
  1045. imgWidth = realWidth;
  1046. imgHeight = realHeight;
  1047. }
  1048. $(bigimg).css("width",imgWidth);//以最终的宽度对图片缩放
  1049. var w = (windowW-imgWidth)/2;//计算图片与窗口左边距
  1050. var h = (windowH-imgHeight)/2;//计算图片与窗口上边距
  1051. $(innerdiv).css({"top":h, "left":w});//设置#innerdiv的top和left属性
  1052. $(outerdiv).fadeIn("fast");//淡入显示#outerdiv及.pimg
  1053. });
  1054. $(outerdiv).click(function(){//再次点击淡出消失弹出层
  1055. $(this).fadeOut("fast");
  1056. });
  1057. }