server-items-detail.js 34 KB

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