rehabilitation_management.js 34 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934
  1. !(function () {
  2. var httpData = GetRequest()
  3. var currentGMT = new Date() //当前时间GMT
  4. var xuetangDuring = ['', '早餐前', '早餐后', '午餐前', '午餐后', '晚餐前', '晚餐后', '睡前']
  5. var normalLevel = [[], [7, 4], [11.1, 4], [7, 4], [11.1, 4], [7, 4], [11.1, 4], [7, 4]]
  6. var docInfo = JSON.parse(localStorage.wlyyAgent)
  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. top.rehabilitationVue = new Vue({
  28. el: '#app',
  29. data: {
  30. ynow: currentGMT.getFullYear(), //年份
  31. mnow: currentGMT.getMonth(), //月份(比实际少一个月---0开始至11)
  32. dnow: currentGMT.getDate(), //当前日
  33. currentDay: null, //带中文格式的当前年月
  34. currentDayForEn: null, //不带中文格式年月日2018/10/01如果写成/的话 转换成时间戳会变成北京时间8点
  35. calendarData: [], //日历数据
  36. loginDoctor: JSON.parse(localStorage.getItem('wlyyAgent')),
  37. timeAxisData: [], //时间轴数据
  38. __Data: [], //当前的年月(日历)
  39. __xData: [], //当前的年月(时间轴)
  40. isFastSearch: false, // 是否是快速查找任务
  41. status: '', //任务状态(0未完成,1已完成,2已预约)
  42. searchTask: '', //快速查找任务:(1、我的任务,2、健康教育,3、健康指导,4、随访,5、复诊)
  43. searchTaskName: '全部', //快速查找任务:(1、我的任务,2、健康教育,3、健康指导,4、随访,5、复诊)
  44. planId: httpData['planId'],
  45. patientCode: httpData['patientCode'],
  46. taskArr: [
  47. { code: '', name: '全部' },
  48. { code: 2, name: '康复咨询' },
  49. { code: 4, name: '上门服务' },
  50. { code: 1, name: '电话/短信关怀' },
  51. { code: 3, name: '健康监测' },
  52. { code: 5, name: '康复指导' },
  53. { code: 6, name: '康复随访' },
  54. { code: 7, name: '康复复诊' }
  55. ],
  56. statusArr: [
  57. { code: '', name: '全部' },
  58. { code: 0, name: '未完成' },
  59. { code: 1, name: '已完成' },
  60. { code: 2, name: '已预约' }
  61. ],
  62. curTask: '', //快速查找是否点击了搜索按钮
  63. curTaskName: '', //快速查找是否点击了搜索按钮
  64. tabStatus: null,
  65. planInfo: {},
  66. docList: [],
  67. diagnosisInformation: null,
  68. searchData: [], // 搜索计划安排(去年、今年、明年)
  69. medicalRecordsList: [], //病历列表
  70. limitlessItems: [],
  71. showServerItemDetail: false,
  72. serverItemInfo: undefined,
  73. islimit: false,
  74. scList: [],
  75. lastPlan: null
  76. },
  77. mounted: function () {
  78. if (!this.planId) {
  79. layer.msg('未传入计划id(planId)', { icon: 2 })
  80. } else {
  81. this.tabStatus = 1
  82. }
  83. this.planSchedule()
  84. // this.serviceDoctorList();//获取服务医生列表
  85. this.selectPlanServerDoctor() //获取服务医生列表
  86. this.bindEvents()
  87. // 获取最新的诊疗信息1条
  88. this.findDiagnosisInformationByPlanId()
  89. },
  90. methods: {
  91. gotoCheck: function () {
  92. var obj = {
  93. patientName: this.planInfo.patientName,
  94. patientCode: this.planInfo.patientCode
  95. }
  96. window.location.href = '../../jbsc/html/statistics.html?scListItem=' + encodeURIComponent(JSON.stringify(obj))
  97. },
  98. view: function (code) {
  99. var vm = this
  100. layer.open({
  101. type: 2,
  102. // offset: ['100px'], //右下角弹出
  103. area: ['568px', '100%'],
  104. shade: 0.5,
  105. title: '查看筛选结果',
  106. fixed: true, //不固定
  107. maxmin: true,
  108. closeBtn: 1,
  109. shift: 5,
  110. shadeClose: false, //点击遮罩关闭层
  111. content: '../../jbsc/html/view_screening_results.html?isView=true&resultCode=' + code
  112. })
  113. },
  114. gotoSc: function () {
  115. top.layer.open({
  116. type: 2,
  117. area: ['820px', '648px'],
  118. shade: 0.5,
  119. title: 'ASCVD风险评估',
  120. fixed: true, //不固定
  121. maxmin: true,
  122. closeBtn: 1,
  123. shift: 5,
  124. shadeClose: false, //点击遮罩关闭层
  125. content: `../../jbsc/html/questionnaire.html?fliter_code=6bcd306aaafb4e4381071346d86fadbb1&fliter_title=ASCVD风险评估&resident_code=${this.planInfo.patientCode}&resident_name=${this.planInfo.patientName}&sex=${this.planInfo.sex}&age=${this.planInfo.age}&idcard=${this.planInfo.idcard}&mobile=${this.planInfo.mobile}&surveyStatus=2&noswitch=1`
  126. })
  127. },
  128. getList: function () {
  129. var vm = this
  130. rehaAPI
  131. .getList({
  132. doctor: docInfo.code,
  133. diseaseType: vm.planInfo.disease,
  134. type: '',
  135. patientName: '',
  136. patientCode: this.patientCode,
  137. isDanger: '',
  138. pageNo: 1,
  139. pageSize: 1,
  140. filterType: 1,
  141. isAscvd: vm.planInfo.disease == '3' ? 1 : ''
  142. })
  143. .then(function (res) {
  144. vm.scList = res.data
  145. })
  146. },
  147. // 刷新
  148. refresh: function () {
  149. this.planSchedule()
  150. this.timeAxis()
  151. },
  152. // 获取服务医生列表
  153. selectPlanServerDoctor: function () {
  154. var vm = this,
  155. params = {
  156. planId: vm.planId
  157. }
  158. rehaAPI.selectPlanServerDoctor(params).then(function (res) {
  159. if (res.status == 200) {
  160. vm.docList = res.data
  161. } else {
  162. layer.msg(res.msg, { icon: 5 })
  163. }
  164. })
  165. },
  166. //获取计划表
  167. planSchedule: function () {
  168. var vm = this
  169. var params = {
  170. planId: this.planId,
  171. patientCode: this.patientCode
  172. }
  173. rehaAPI.planSchedule(params).then(function (res) {
  174. if (res.status == 200) {
  175. vm.planInfo = res.data
  176. vm.getList()
  177. vm.planInfo.tagClass = 'tag-' + res.data.healthyConditionType
  178. //patientImg:居民签名照/证件照,如果不为null的话说明居民已确认,显示康复完成明细
  179. if (vm.planInfo.status == 2 && !vm.planInfo.patientImg) {
  180. //任务全部完成时,显示完成提示框
  181. vm.showCompleteDailog()
  182. } else if (vm.planInfo.status == 2 && vm.planInfo.patientImg) {
  183. //居民已确认计划完成
  184. vm.tabStatus = 3
  185. $('#framePage').attr('src', 'stop_special_service.html?planids=' + vm.planId + '&planStatus=' + vm.planInfo.status)
  186. }
  187. vm.selectByMedicalCode(res.data.medicalRecordsCode)
  188. } else {
  189. layer.msg(res.msg, { icon: 5 })
  190. }
  191. })
  192. },
  193. // 获取住院病历
  194. selectByMedicalCode: function (medicalRecordsCode) {
  195. var vm = this
  196. var params = {
  197. medical: medicalRecordsCode
  198. }
  199. rehaAPI.selectByMedicalCode(params).then(function (res) {
  200. if (res.status == 200) {
  201. vm.medicalRecordsList = res.data
  202. } else {
  203. showErrorMessage(res.msg)
  204. }
  205. })
  206. },
  207. // 查看住院病历详情
  208. viewMedicalDetail: function (o) {
  209. var vm = this
  210. if (o.event) {
  211. var loading = layer.load(0, { shade: false })
  212. recoverAPI.getPatientAccetokenByIdcard({ idcard: vm.planInfo.idcard }).then(function (res) {
  213. layer.close(loading)
  214. if (res.status == 200) {
  215. layer.open({
  216. type: 2,
  217. area: ['75%', '650px'],
  218. shade: 0.5,
  219. title: '住院病历',
  220. closeBtn: 1,
  221. shift: 5,
  222. shadeClose: false, //点击遮罩关闭层
  223. content: httpRequest.server + 'profileweb/#/zhuyuan?patientCode=' + res.data.patientCode + '&hospital=' + docInfo.hospital + '&event=' + o.event
  224. })
  225. } else {
  226. showErrorMessage(res.msg)
  227. }
  228. })
  229. } else {
  230. layer.open({
  231. type: 2,
  232. area: ['600px', '600px'],
  233. shade: 0.5,
  234. title: '住院病历详情',
  235. fixed: true, //不固定
  236. maxmin: true,
  237. closeBtn: 1,
  238. shift: 5,
  239. shadeClose: false, //点击遮罩关闭层
  240. content: '../../rehabilitation/html/medical-records-detail.html?medicalRecordsCode=' + o.code
  241. })
  242. }
  243. },
  244. formatter: function (time) {
  245. return new Date(time).format('yyyy-MM-dd')
  246. },
  247. // 获取最新的诊疗消息
  248. findDiagnosisInformationByPlanId: function () {
  249. var vm = this,
  250. loading = layer.load(0, { shade: false }),
  251. params = {
  252. planId: vm.planId
  253. }
  254. recoverAPI.findDiagnosisInformationByPlanId(params).then(function (res) {
  255. layer.close(loading)
  256. if (res.status == 200) {
  257. vm.diagnosisInformation = res.data
  258. } else {
  259. showErrorMessage(res.msg)
  260. }
  261. })
  262. },
  263. serviceDoctorList: function () {
  264. var vm = this
  265. rehaAPI.serviceDoctorList({ patientCode: this.patientCode }).then(function (res) {
  266. if (res.status == 200) {
  267. vm.docList = res.data
  268. } else {
  269. layer.msg(res.msg, { icon: 5 })
  270. }
  271. })
  272. },
  273. weiXinConfirmClick: function () {
  274. var vm = this
  275. rehaAPI.sendWxMsg({ planId: this.planId }).then(function (res) {
  276. if (res.status == 200) {
  277. layer.msg('发送成功,等待居民确认')
  278. setTimeout(function () {
  279. vm.tabStatus = 3
  280. $('#framePage').attr('src', 'stop_special_service.html?planids=' + vm.planId + '&planStatus=' + vm.planInfo.status)
  281. }, 1000)
  282. } else {
  283. layer.msg(res.msg, { icon: 5 })
  284. }
  285. })
  286. },
  287. setImgSrc: function (src) {
  288. var str = httpRequest.getImgUrl(src)
  289. return str
  290. },
  291. showCompleteDailog: function () {
  292. layer.confirm(
  293. '<div class="mt10 tac"><image src="../images/yiwancheng_icon.png" width="100" height="100"/><div class="mt20 c-f20 c-333 mb40">本次康复计划已完成</div><div class="div-patient-comfirm c-f14 c-fff bgc-12b7f5" style="margin:40px auto 20px;">邀请居民确认</div></div>',
  294. {
  295. btn: [],
  296. area: ['400px', '340px'],
  297. title: '完成提示'
  298. },
  299. function (index) {
  300. // layer.close(index);
  301. }
  302. )
  303. },
  304. refreshPage: function () {
  305. if (!this.planId) {
  306. layer.msg('未传入计划id(planId)', { icon: 2 })
  307. return
  308. }
  309. this.goToLoadData(true)
  310. },
  311. bindEvents: function () {
  312. var vm = this
  313. $('body')
  314. .on('click', '.div-patient-comfirm', function () {
  315. layer.closeAll()
  316. vm.weiXinConfirmClick()
  317. })
  318. .on('click', '.div-patient-home', function () {
  319. location.href = '../../recover/html/personal-manage.html?patientCode=' + vm.patientCode + '&planId=' + vm.planId
  320. })
  321. },
  322. viewDetail: function (planids, type, item) {
  323. var vm = this
  324. if (!planids) {
  325. layer.msg('无服务项', { icon: 5 })
  326. return
  327. }
  328. console.log(planids, type, item,"item");
  329. if (vm.planInfo.disease == '3' && vm.scList.length == 0 && item && item.code == '6' && vm.loginDoctor.doctorType != '1') {
  330. this.$confirm('提示该居民近一年没有进行冠心病风险评估,请先进行评估,再进行随访登记', '提示', {
  331. confirmButtonText: '确定',
  332. cancelButtonText: '取消',
  333. type: 'warning'
  334. }).then(function () {
  335. vm.gotoSc()
  336. })
  337. return false
  338. }
  339. if (type == 1) {
  340. // 单个服务项
  341. layer.open({
  342. type: 2,
  343. area: ['800px', '700px'],
  344. shade: 0.5,
  345. title: '服务项目内容',
  346. fixed: true, //不固定
  347. maxmin: true,
  348. closeBtn: 1,
  349. shift: 5,
  350. shadeClose: false, //点击遮罩关闭层
  351. content:
  352. '../../rehabilitation/html/guide_the_message.html?planid=' +
  353. planids +
  354. '&pId=' +
  355. httpData['planId'] +
  356. '&patient=' +
  357. vm.patientCode +
  358. '&patientName=' +
  359. vm.planInfo.patientName,
  360. end: function () {
  361. vm.goToLoadData(true)
  362. }
  363. })
  364. return
  365. }
  366. layer.open({
  367. // 康复计划的所有服务项
  368. type: 2,
  369. area: ['800px', '700px'],
  370. shade: 0.5,
  371. title: '服务项目内容',
  372. fixed: true, //不固定
  373. maxmin: true,
  374. closeBtn: 1,
  375. shift: 5,
  376. shadeClose: false, //点击遮罩关闭层
  377. content:
  378. '../../rehabilitation/html/service_item_content.html?planids=' +
  379. planids +
  380. '&planId=' +
  381. httpData['planId'] +
  382. '&patient=' +
  383. vm.patientCode +
  384. '&patientName=' +
  385. vm.planInfo.patientName +
  386. '&disease=' +
  387. vm.planInfo.disease +
  388. '&scLenght=' +
  389. vm.scList.length,
  390. end: function () {
  391. vm.goToLoadData(true)
  392. }
  393. })
  394. },
  395. changeStatus: function (val) {
  396. this.status = val.code
  397. },
  398. changeTask: function (val) {
  399. this.searchTask = val.code
  400. this.searchTaskName = val.name
  401. },
  402. monDetail: function () {
  403. this.currentDay = this.ynow + '年' + (this.mnow + 1) + '月'
  404. this.currentDayForEn = this.ynow + '/' + (this.mnow >= 9 ? this.mnow + 1 : '0' + (this.mnow + 1)) + '/' + (this.dnow >= 9 ? this.dnow : '0' + this.dnow)
  405. },
  406. is_leap: function (year) {
  407. //判断是否为闰年
  408. return year % 100 == 0 ? (res = year % 400 == 0 ? 1 : 0) : (res = year % 4 == 0 ? 1 : 0)
  409. },
  410. preMonth: function () {
  411. //上一个月
  412. if (this.mnow <= 0) {
  413. this.mnow = 11
  414. this.ynow = this.ynow - 1
  415. } else {
  416. this.mnow--
  417. }
  418. this.monDetail()
  419. this.goToLoadData(true)
  420. },
  421. getPreMouth: function () {
  422. var pMnow, pYnow
  423. if (this.mnow <= 0) {
  424. pMnow = 11
  425. pYnow = this.ynow - 1
  426. } else {
  427. pMnow = this.mnow - 1
  428. pYnow = this.ynow
  429. }
  430. var m_days = new Array(31, 28 + this.is_leap(pYnow), 31, 30, 31, 30, 31, 31, 30, 31, 30, 31) //每个月的天数
  431. return {
  432. days: m_days[pMnow],
  433. date: pYnow + '-' + (++pMnow >= 10 ? pMnow : '0' + pMnow)
  434. }
  435. },
  436. nextMonth: function () {
  437. //下一个月
  438. if (this.mnow >= 11) {
  439. this.mnow = 0
  440. this.ynow = this.ynow + 1
  441. } else {
  442. this.mnow++
  443. }
  444. this.monDetail()
  445. this.goToLoadData(true)
  446. },
  447. getNextMouth: function () {
  448. var nMnow, nYnow
  449. if (this.mnow >= 11) {
  450. nMnow = 0
  451. nYnow = this.ynow + 1
  452. } else {
  453. nMnow = this.mnow + 1
  454. nYnow = this.ynow
  455. }
  456. var m_days = new Array(31, 28 + this.is_leap(nYnow), 31, 30, 31, 30, 31, 31, 30, 31, 30, 31) //每个月的天数
  457. return {
  458. days: m_days[nMnow],
  459. date: nYnow + '-' + (++nMnow >= 10 ? nMnow : '0' + nMnow)
  460. }
  461. },
  462. goToLoadData: function (flag) {
  463. //flag是否更新数据
  464. this.tabStatus == 1 && (!this.calendarData.length || flag) && this.calendar()
  465. this.tabStatus == 2 && (!this.timeAxisData.length || flag) && this.timeAxis()
  466. // this.changeSearch(-1)
  467. },
  468. calendar: function () {
  469. var nlstr = new Date(this.ynow, this.mnow, 1) //当月第一天
  470. var firstday = nlstr.getDay() - 1 //第一天星期几,默认是周日 我们改成周一
  471. firstday = firstday == -1 ? 6 : firstday //如果是-1,说明当月的第一天是周日
  472. var m_days = new Array(31, 28 + this.is_leap(this.ynow), 31, 30, 31, 30, 31, 31, 30, 31, 30, 31) //每个月的天数
  473. var tr_str = Math.ceil((m_days[this.mnow] + firstday) / 7) //当前月天数+第一天是星期几的数值 获得 表格行数
  474. var c_days = m_days[this.mnow] //当前月份的天数
  475. var p_arr = this.getPreMouth()
  476. var n_arr = this.getNextMouth()
  477. var i, k, idx, date_str
  478. var dataArr = [] //天数/年月
  479. for (i = 0; i < tr_str; i++) {
  480. //表格的行
  481. for (k = 0; k < 7; k++) {
  482. //表格每行的单元格
  483. idx = i * 7 + k //单元格自然序列号
  484. date_str = idx - firstday + 1 //计算日期
  485. var __ym
  486. if (date_str <= 0) {
  487. //过滤无效日期(小于等于零的、大于月总天数的)
  488. date_str = date_str + p_arr['days'] //当前日期+上个月的天数就是上个月的日期
  489. __ym = p_arr['date']
  490. } else if (date_str > c_days) {
  491. date_str = date_str - c_days //下个月的日期就是这个月的天数-当月的天数
  492. __ym = n_arr['date']
  493. } else {
  494. __ym = this.ynow + '-' + (this.mnow >= 9 ? '' : '0') + (this.mnow + 1)
  495. }
  496. dataArr.push({
  497. day: date_str,
  498. date: __ym
  499. })
  500. }
  501. }
  502. this.__Data = dataArr
  503. this.monDetail()
  504. this.calenderPlanDetail()
  505. },
  506. daysSort: function (arr) {
  507. var getArr = JSON.parse(JSON.stringify(arr)),
  508. returnArr = []
  509. for (var i = 1; i < 31; i++) {
  510. for (var j = 0, len = getArr.length; j < len; j++) {
  511. var stri = i > 9 + '' ? i : '0' + i
  512. if (getArr[j].day == stri) {
  513. returnArr.push(getArr[j])
  514. getArr.splice(j, 1)
  515. break
  516. }
  517. }
  518. }
  519. return returnArr
  520. },
  521. // 日历有计划数据处理
  522. planHandleData: function (data, day, mounth) {
  523. var item = data
  524. item.day = day
  525. if (mounth) {
  526. item.mounth = mounth
  527. }
  528. var finishFlag = false
  529. var sFlag = false
  530. var fFlag = false
  531. if (item.specialist) {
  532. if (item.specialist.all == item.specialist.finish) {
  533. sFlag = true
  534. }
  535. } else {
  536. sFlag = true
  537. }
  538. if (item.family) {
  539. if (item.family.all == item.family.finish) {
  540. fFlag = true
  541. }
  542. } else {
  543. fFlag = true
  544. }
  545. finishFlag = sFlag && fFlag
  546. item.finishFlag = finishFlag
  547. return item
  548. },
  549. // 日历请求
  550. calenderPlanDetail: function () {
  551. var vm = this
  552. var __days = vm.__Data
  553. var lastDay = __days.concat().pop().day
  554. lastDay = lastDay > 9 ? lastDay : '0' + lastDay
  555. if (vm.searchTask != '' || vm.status != '') {
  556. vm.isFastSearch = true
  557. } else {
  558. vm.isFastSearch = false
  559. }
  560. var params = {
  561. executeStartTime: vm.isFastSearch ? '' : __days[0].date + '-' + __days[0].day + ' 00:00:00', //日历开始时间(格式:yyyy-MM-dd HH:mm:ss)
  562. executeEndTime: vm.isFastSearch ? '' : __days.concat().pop().date + '-' + lastDay + ' 23:59:59', //日历结束时间(格式:yyyy-MM-dd HH:mm:ss)
  563. planId: vm.planId, //计划id
  564. searchTask: vm.searchTask, //快速查找任务:(1、我的任务,2、健康教育,3、健康指导,4、随访)
  565. status: vm.status //任务状态(0未完成,1已完成,2已预约)
  566. }
  567. rehaAPI.calendarPlanDetail(params).then(function (res) {
  568. vm.curTask = vm.searchTask
  569. vm.curTaskName = vm.searchTaskName
  570. vm.calendarData = []
  571. var list = []
  572. if (res.status == 200) {
  573. var data = res.data
  574. // 快速查找
  575. if (vm.isFastSearch) {
  576. vm.searchData = []
  577. var searchData0 = [],
  578. searchData1 = [],
  579. searchData2 = []
  580. for (var setM = 1; setM <= 12; setM++) {
  581. var _setM = setM > 9 ? setM : '0' + setM,
  582. _setY = new Date().getFullYear()
  583. var data0 = [],
  584. data1 = [],
  585. data2 = []
  586. for (var i in data) {
  587. var getY = i.split('-')[0],
  588. getM = i.split('-')[1],
  589. getD = i.split('-')[2]
  590. // 去年
  591. if (_setY - 1 == getY && _setM == getM) {
  592. var item = vm.planHandleData(data[i], getD, getM)
  593. data0.push(item)
  594. data.length && data.splice(i, 1)
  595. } else if (_setY == getY && _setM == getM) {
  596. // 今年
  597. var item = vm.planHandleData(data[i], getD, getM)
  598. data1.push(item)
  599. data.length && data.splice(i, 1)
  600. } else if (_setY + 1 == getY && _setM == getM) {
  601. // 明年
  602. var item = vm.planHandleData(data[i], getD, getM)
  603. data2.push(item)
  604. data.length && data.splice(i, 1)
  605. }
  606. }
  607. if (data0.length) {
  608. var dataSort = vm.daysSort(data0)
  609. var addlen = (dataSort.length + 1) % 7 ? (dataSort.length + 1) % 7 : 7
  610. for (var i = 0; i < 7 - addlen; i++) {
  611. dataSort.push({
  612. noService: true
  613. })
  614. }
  615. searchData0.push(dataSort)
  616. }
  617. if (data1.length) {
  618. var dataSort = vm.daysSort(data1)
  619. var addlen = (dataSort.length + 1) % 7 ? (dataSort.length + 1) % 7 : 7
  620. for (var i = 0; i < 7 - addlen; i++) {
  621. dataSort.push({
  622. noService: true
  623. })
  624. }
  625. searchData1.push(dataSort)
  626. }
  627. if (data2.length) {
  628. var dataSort = vm.daysSort(data2)
  629. var addlen = (dataSort.length + 1) % 7 ? (dataSort.length + 1) % 7 : 7
  630. for (var i = 0; i < 7 - addlen; i++) {
  631. dataSort.push({
  632. noService: true
  633. })
  634. }
  635. searchData2.push(dataSort)
  636. }
  637. }
  638. if (searchData0.length) {
  639. vm.searchData.push(searchData0)
  640. }
  641. if (searchData1.length) {
  642. vm.searchData.push(searchData1)
  643. }
  644. if (searchData2.length) {
  645. vm.searchData.push(searchData2)
  646. }
  647. return false
  648. }
  649. // 正常日历
  650. var _currentTimeStamp = +new Date(new Date().setHours(0, 0, 0, 0))
  651. for (var i in __days) {
  652. var _key = __days[i].date + '-' + (__days[i].day > 9 ? __days[i].day : '0' + __days[i].day)
  653. var item = {
  654. noService: true,
  655. day: __days[i].day
  656. }
  657. for (var j in data) {
  658. if (_key == j) {
  659. item = vm.planHandleData(data[j], __days[i].day)
  660. data.length && data.splice(j, 1)
  661. break
  662. }
  663. }
  664. var thatTime = +new Date(_key) - 8 * 60 * 60 * 1000
  665. var future = _currentTimeStamp > thatTime ? 0 : _currentTimeStamp == thatTime ? 1 : 2
  666. item.future = future
  667. list.push(item)
  668. // vm.calendarData.push(item);
  669. }
  670. vm.calendarData = _.chunk(list, 7)
  671. }
  672. })
  673. },
  674. // 时间轴请求
  675. timeAxis: function () {
  676. var m_days = new Array(31, 28 + this.is_leap(this.ynow), 31, 30, 31, 30, 31, 31, 30, 31, 30, 31) //每个月的天数
  677. var c_days = m_days[this.mnow] //当前月份的天数
  678. var __ym = this.ynow + '-' + (this.mnow >= 9 ? '' : '0') + (this.mnow + 1)
  679. var dataArr = [] //天数/年月
  680. for (; c_days > 0; c_days--) {
  681. dataArr.push({
  682. day: c_days,
  683. date: __ym
  684. })
  685. }
  686. this.__xData = dataArr
  687. this.monDetail()
  688. this.calendarPlanDetailList()
  689. this.calendarPlanDetailItems()
  690. },
  691. //时间轴请求
  692. calendarPlanDetailList: function () {
  693. var vm = this
  694. var __days = vm.__xData
  695. var lastDay = __days.concat().pop().day
  696. lastDay = lastDay > 9 ? lastDay : '0' + lastDay
  697. var params = {
  698. executeEndTime: __days[0].date + '-' + __days[0].day + ' 23:59:59', //日历开始时间(格式:yyyy-MM-dd HH:mm:ss)
  699. executeStartTime: __days.concat().pop().date + '-' + lastDay + ' 00:00:00', //日历结束时间(格式:yyyy-MM-dd HH:mm:ss)
  700. planId: vm.planId, //计划id
  701. searchTask: vm.searchTask, //快速查找任务:(1、我的任务,2、随访,3、复诊,4、健康教育)
  702. status: vm.status //任务状态(0未完成,1已完成,2已预约)
  703. }
  704. rehaAPI.calendarPlanDetailList(params).then(function (res) {
  705. if (res.status == 200) {
  706. // var _currentTimeStamp=+new Date(new Date().setHours(0, 0, 0, 0))
  707. var list =
  708. _.map(res.data || {}, function (o) {
  709. // var _time=o.executeTime.split(' ');
  710. // var thatTime=+new Date(_time[0]);
  711. // var future=_currentTimeStamp>thatTime?0:(_currentTimeStamp==thatTime?1:2);
  712. // (o.status==0 && _currentTimeStamp>thatTime) && (future=-1)
  713. // var _html=o.status==2?'预':(future==-1?'逾':'');
  714. // _html=future==1?'今':_html;
  715. // if(_html=='预') future=3;
  716. var _time = o.executeTime.split(' ')
  717. var _html = ''
  718. var d = new Date(o.execute_time)
  719. if (d.format('yyyy-MM-dd') == new Date().format('yyyy-MM-dd')) {
  720. o.firstSort = '1'
  721. future = 1
  722. _html = '今'
  723. if (o.status) {
  724. o.secondSort = '2'
  725. } else {
  726. o.secondSort = '1'
  727. }
  728. } else if (d > new Date()) {
  729. o.firstSort = '3'
  730. future = 2
  731. if (o.status) {
  732. o.secondSort = '2'
  733. } else {
  734. o.secondSort = '1'
  735. }
  736. } else {
  737. o.firstSort = '2'
  738. future = 0
  739. if (o.status == 0) {
  740. future = -1
  741. _html = '逾'
  742. o.secondSort = '1'
  743. } else {
  744. o.secondSort = '2'
  745. }
  746. }
  747. o.html = _html
  748. o.date = _time[0]
  749. o.time = _time[1]
  750. o.future = future
  751. o.doctorName = o.doctor_name
  752. o.hospitalName = o.hospital_name
  753. return o
  754. }) || []
  755. var nowTime = new Date().getTime()
  756. vm.timeAxisData = _.sortBy(list, function (o) {
  757. return o.firstSort + o.secondSort + nowTime / o.execute_time
  758. })
  759. }
  760. })
  761. },
  762. viewServerItemsDetail: function (o) {
  763. if (o.code == '2') {
  764. showInfoMessage('请从“消息-患者消息列表”中查看患者的康复咨询记录')
  765. return
  766. }
  767. if (o.code == '3') {
  768. layer.open({
  769. type: 2,
  770. area: ['700px', '700px'],
  771. shade: 0.5,
  772. title: '健康记录',
  773. fixed: true, //不固定
  774. maxmin: true,
  775. closeBtn: 1,
  776. // shift: 5,
  777. shadeClose: false, //点击遮罩关闭层
  778. content: '../html/healthMonitor.html?patient=' + this.patientCode
  779. })
  780. return
  781. }
  782. this.serverItemInfo = o
  783. this.showServerItemDetail = true
  784. this.islimit = o.frequency_code ? true : false
  785. },
  786. calendarPlanDetailItems: function () {
  787. var vm = this
  788. var __days = vm.__xData
  789. var lastDay = __days.concat().pop().day
  790. lastDay = lastDay > 9 ? lastDay : '0' + lastDay
  791. var params = {
  792. executeEndTime: __days[0].date + '-' + __days[0].day + ' 23:59:59', //日历开始时间(格式:yyyy-MM-dd HH:mm:ss)
  793. executeStartTime: __days.concat().pop().date + '-' + lastDay + ' 00:00:00', //日历结束时间(格式:yyyy-MM-dd HH:mm:ss)
  794. planId: vm.planId, //计划id
  795. searchTask: vm.searchTask, //快速查找任务:(1、我的任务,2、随访,3、复诊,4、健康教育)
  796. status: vm.status //任务状态(0未完成,1已完成,2已预约)
  797. }
  798. rehaAPI.calendarPlanDetailItems(params).then(function (res) {
  799. if (res.status == 200) {
  800. vm.lastPlan = res.json
  801. var arr = []
  802. $.each(res.data, function (i, o) {
  803. if (o.code == '3' && o.type) {
  804. if (o.type == 2) {
  805. o.levelClazz = vm.getLevelClazz(o.value1, 139, 90) || vm.getLevelClazz(o.value2, 89, 60)
  806. o.levelClazz1 = vm.getLevelClazz(o.value1, 139, 90)
  807. o.levelClazz2 = vm.getLevelClazz(o.value2, 89, 60)
  808. o.levelClazz3 = vm.getLevelClazz(o.value3, 100, 60)
  809. } else {
  810. var num = parseInt(o.value2)
  811. var max = normalLevel[num][0],
  812. min = normalLevel[num][1]
  813. o.levelClazz1 = vm.getLevelClazz(o.value1, max, min)
  814. o.levelName = xuetangDuring[o.value2]
  815. }
  816. }
  817. arr.push(o)
  818. })
  819. vm.limitlessItems = arr
  820. }
  821. })
  822. },
  823. getLevelClazz: function (value, max, min) {
  824. if (!value || (!max && !min)) {
  825. return ''
  826. }
  827. var value = parseFloat(value)
  828. if (value < min) {
  829. return 'low'
  830. } else if (value > max) {
  831. return 'high'
  832. } else {
  833. return ''
  834. }
  835. },
  836. getNormalLevel: function (index) {
  837. return [[], [7, 4], [11.1, 4], [7, 4], [11.1, 4], [7, 4], [11.1, 4], [7, 4]][index]
  838. },
  839. confirmSearch: function () {
  840. this.changeSearch(-1)
  841. this.goToLoadData(true)
  842. },
  843. changeSearch: function (status) {
  844. var i = status == 1 ? -400 : 0
  845. var timer1 = setInterval(function () {
  846. i += 5 * status
  847. $('.search-left').css('right', i + 'px')
  848. if (status == 1 && i >= 0) {
  849. clearInterval(timer1)
  850. }
  851. if (status == -1 && i <= -400) {
  852. clearInterval(timer1)
  853. }
  854. }, 5)
  855. },
  856. //邀请视频聊天
  857. openVideoChat: function (otherDoc) {
  858. var vm = this
  859. var loading = layer.load(0)
  860. var participants = []
  861. var participantsMobile = {}
  862. //发起人
  863. participants.push({ mobile: docInfo.mobile, name: docInfo.name, sex: docInfo.sex == 1 ? 1 : 2, birthdate: '', level: 3, hospital_name: docInfo.hospitalName, idcard: '' })
  864. participantsMobile[docInfo.mobile] = 1
  865. if (otherDoc) {
  866. //被邀请人
  867. participants.push({
  868. mobile: otherDoc.doctorMobile,
  869. name: otherDoc.doctorName,
  870. sex: otherDoc.doctorSex == 1 ? 1 : 2,
  871. birthdate: '',
  872. level: 3,
  873. hospital_name: otherDoc.doctorHospitalName,
  874. idcard: otherDoc.doctorIdcard
  875. })
  876. participantsMobile[otherDoc.doctorMobile] = 0
  877. }
  878. videoChatAPI
  879. .addDoctor({ participants: JSON.stringify(participants) })
  880. .then(function (res) {
  881. if (res.status == 200) {
  882. videoChatAPI
  883. .sessions({
  884. sessionId: httpRequest.uuid(24, 16),
  885. sessionType: 4,
  886. sessionName: vm.planInfo.patientName + '的远程门诊',
  887. participants: JSON.stringify(participantsMobile),
  888. videoconferencing: 1,
  889. idcard: vm.planInfo.idcard
  890. })
  891. .then(function (res1) {
  892. layer.close(loading)
  893. if (res1.status == 200) {
  894. layer.msg('发起会话成功', { icon: 6 })
  895. } else {
  896. layer.msg('发起会话失败', { icon: 5 })
  897. }
  898. })
  899. .catch(function () {
  900. layer.close(loading)
  901. layer.msg('系统繁忙', { icon: 5 })
  902. })
  903. } else {
  904. layer.close(loading)
  905. layer.msg(res.msg, { icon: 5 })
  906. }
  907. })
  908. .catch(function () {
  909. layer.close(loading)
  910. layer.msg('系统繁忙', { icon: 5 })
  911. })
  912. },
  913. toLastPlan(){
  914. window.location.href = `${window.location.pathname}?planId=${this.lastPlan.id}&patientCode=${this.patientCode}`
  915. }
  916. },
  917. watch: {
  918. tabStatus: function () {
  919. this.goToLoadData()
  920. }
  921. }
  922. })
  923. })()