server-items-detail.js 41 KB

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