server-items-detail.js 35 KB

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