server-items-detail.js 32 KB

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