rehabilitation_management.js 34 KB

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