signPrint.vue 26KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699
  1. <template>
  2. <div class="main-contain">
  3. <div class="position">
  4. <bread-crumb :crumbs="crumbs"></bread-crumb>
  5. <el-row style="float:right;">
  6. <el-col :span="24">
  7. <el-button size="small" icon="el-icon-printer" type="primary" @click="printAction">打印</el-button>
  8. </el-col>
  9. </el-row>
  10. </div>
  11. <div class="app-container" style="background-color: white;" v-show="show">
  12. <div id="dialysisTable">
  13. <div v-for="(item, index) in list" :key="index">
  14. <div class="signPrint" v-for="it in item.doctor_advice" style="page-break-after: always;">
  15. <div>分区/床位号:{{item.device_number.zone.name}}/{{item.device_number.number}}</div>
  16. <div>姓名:{{item.patient.name}}</div>
  17. <div>医嘱内容:{{ it.advice_name }}
  18. <span v-if="it.prescribing_number>0">
  19. {{it.prescribing_number}}{{ it.prescribing_number_unit }}
  20. </span>
  21. </div>
  22. <div>给药途径:{{it.execution_frequency}}</div>
  23. <div>执行频率:{{it.delivery_way}}</div>
  24. <div>打印时间:{{time}}</div>
  25. </div>
  26. </div>
  27. </div>
  28. </div>
  29. <div class="app-container" style="background-color: white;" v-show="showOne">
  30. <div id="dialysisTable">
  31. <div v-for="(item, index) in list" :key="index">
  32. <div class="signPrint" v-for="it in item.doctor_advice" style="page-break-after: always;">
  33. <div>分区/床位号:{{item.device_number.zone.name}}/{{item.device_number.number}}</div>
  34. <div>姓名:{{item.patient.name}}</div>
  35. <div>医嘱内容:{{getAdvice(item.doctor_advice)}}
  36. <span v-if="it.prescribing_number >0"> {{it.prescribing_number}}{{ it.prescribing_number_unit }}</span>
  37. </div>
  38. <div>给药途径:{{item.doctor_advice[0].execution_frequency}}</div>
  39. <div>执行频率:{{item.doctor_advice[0].delivery_way}}</div>
  40. <div>打印时间:{{time}}</div>
  41. </div>
  42. </div>
  43. </div>
  44. </div>
  45. </div>
  46. </template>
  47. <script>
  48. import BreadCrumb from '@/xt_pages/components/bread-crumb'
  49. import { getSchedualDoctors } from '@/api/advice'
  50. import { parseTime } from '@/utils'
  51. import print from 'print-js'
  52. const moment = require('moment')
  53. export default {
  54. components:{
  55. BreadCrumb
  56. },
  57. data(){
  58. return{
  59. crumbs: [
  60. { path: false, name: '耗材药品' },
  61. { path: false, name: '打印' }
  62. ],
  63. tableData:[],
  64. start_time:"",
  65. end_time:"",
  66. print_time:moment(new Date()).add('year', 0).format('YYYY-MM-DD'),
  67. zone_selected: 0,
  68. scheduleMap:[],
  69. time:'',
  70. show:true,
  71. showOne:false,
  72. delivery_way:"",
  73. list:[]
  74. }
  75. },
  76. methods:{
  77. printAction: function() {
  78. const style = '@media print { .dialysisTable{width:960px;margin: 0 auto;text-align: center;border-collapse: collapse;}.order_title_panl {text-align: center;.main_title {font-size: 18px;line-height: 40px;font-weight: 500;}}.dialysisTable tr{padding: 10px 0;}.dialysisTable th {color: #000;padding: 0;margin: 0;height: 30px;}.dialysisTable tr td {padding: 12px 0;}.subadvice_content {text-align: left;padding-left: 25px !important;padding-right: 5px !important;}.advice_content {text-align: left;padding-left: 5px !important;padding-right: 5px !important;padding: 15px 5px !important;} }'
  79. printJS({
  80. printable: 'dialysisTable',
  81. type: 'html',
  82. documentTitle: ' ',
  83. style: style,
  84. scanStyles: false
  85. })
  86. },
  87. requestSchedualDoctors (time) {
  88. let newTime = moment(time).format('YYYY-MM-DD')
  89. getSchedualDoctors({
  90. date: newTime,
  91. patient_type: 0,
  92. advice_type: 2,
  93. delivery_way:this.delivery_way,
  94. }).then(rs => {
  95. var resp = rs.data
  96. if (resp.state == 1) {
  97. this.admin_user = resp.data.adminUser
  98. var config = resp.data.config
  99. if(config.is_open == 0 || config.is_open == 2){
  100. var schedulesArr = resp.data.scheduals
  101. let schedules = []
  102. var ids = this.$store.getters.temp_params.advice_ids
  103. console.log('ids',ids)
  104. schedulesArr.map(item => {
  105. if(ids.indexOf(item.patient_id) > -1){
  106. schedules.push(item)
  107. }
  108. })
  109. for (let i = 0; i < schedules.length; i++) {
  110. schedules[i].dialysis_no = schedules[i].patient.dialysis_no
  111. }
  112. var arr = []
  113. for (let j = 0; j < schedules.length; j++) {
  114. arr.push(schedules[j].dialysis_no)
  115. }
  116. arr.sort(function (a, b) {
  117. return a - b
  118. })
  119. var arrTwo = []
  120. for (let i = 0; i < arr.length; i++) {
  121. for (let j = 0; j < schedules.length; j++) {
  122. if (arr[i] == schedules[j].dialysis_no) {
  123. arrTwo.push(schedules[j])
  124. }
  125. }
  126. }
  127. arrTwo.map((item, index) => {
  128. item.doctor_advice.sort(this.compare('start_time'))
  129. })
  130. const res = new Map()
  131. let a = arrTwo.filter(
  132. a => !res.has(a.dialysis_no) && res.set(a.dialysis_no, 1)
  133. )
  134. schedules = a
  135. var zoneMap = {}
  136. var scheduleMap = {}
  137. for (let index = 0; index < schedules.length; index++) {
  138. const schedule = schedules[index]
  139. if (schedule.doctor_advice.length == 0) {
  140. continue
  141. }
  142. if (scheduleMap[schedule.device_number.zone.name] == null) {
  143. scheduleMap[schedule.device_number.zone.name] = []
  144. }
  145. scheduleMap[schedule.device_number.zone.name].push(schedule)
  146. if (zoneMap[schedule.device_number.zone.name] == null) {
  147. zoneMap[schedule.device_number.zone.name] =schedule.device_number.zone}
  148. }
  149. var zones = []
  150. zones.push({ value: 0, text: '全部分区' })
  151. for (var zoneName in zoneMap) {
  152. zones.push({ value: zoneMap[zoneName].id, text: zoneName })
  153. }
  154. zones = zones.sort(function (a, b) {
  155. return a.value > b.value
  156. })
  157. this.zones = zones
  158. for (var key in scheduleMap) {
  159. let mapArr = scheduleMap[key]
  160. for (let i = 0; i < mapArr.length; i++) {
  161. mapArr[i]['new_advice'] = []
  162. }
  163. }
  164. for (var key in scheduleMap) {
  165. let mapArr = scheduleMap[key]
  166. for (let i = 0; i < mapArr.length; i++) {
  167. var maps = mapArr[i]
  168. var resp_advices = maps.doctor_advice
  169. if (resp_advices.length > 0) {
  170. var newGroupObject = function () {
  171. return Object.assign(
  172. {},
  173. {
  174. group_no: 0,
  175. advices: []
  176. }
  177. )
  178. }
  179. var initGroupBlock = function (group, advice) {
  180. group.group_no = advice.groupno
  181. }
  182. var advice_groups = []
  183. var group = newGroupObject()
  184. for (let index = 0; index < resp_advices.length; index++) {
  185. const advice = resp_advices[index]
  186. if (advice.groupno == 0) {
  187. // 老版本的医嘱
  188. if (advice.parent_id > 0) {
  189. if (advice_groups.length > 0) {
  190. var parent_group = advice_groups[advice_groups.length - 1]
  191. if (parent_group.advices.length > 0) {
  192. if (parent_group.advices[0].id == advice.parent_id) {
  193. parent_group.advices.push(advice)
  194. }
  195. }
  196. }
  197. continue
  198. } else {
  199. if (group.group_no > 0) {
  200. advice_groups.push(group)
  201. group = newGroupObject()
  202. }
  203. initGroupBlock(group, advice)
  204. group.advices.push(advice)
  205. advice_groups.push(group)
  206. group = newGroupObject()
  207. continue
  208. }
  209. } else {
  210. if (group.group_no > 0 && group.group_no != advice.groupno) {
  211. advice_groups.push(group)
  212. group = newGroupObject()
  213. }
  214. if (group.group_no == 0) {
  215. initGroupBlock(group, advice)
  216. }
  217. if (group.group_no == advice.groupno) {
  218. group.advices.push(advice)
  219. }
  220. }
  221. }
  222. if (group.group_no > 0) {
  223. // 上述的算法会导致最后一组没有加到advice_groups,这里要手动加
  224. advice_groups.push(group)
  225. }
  226. advice_groups = advice_groups
  227. } else {
  228. advice_groups = []
  229. }
  230. maps.new_advice = advice_groups
  231. }
  232. }
  233. console.log("scheduleMap999999999999",schedules)
  234. this.list = schedules
  235. }
  236. if(config.is_open == 1){
  237. var schedulesArr = resp.data.hisAdvices
  238. let schedules = []
  239. var ids = this.$store.getters.temp_params.advice_ids
  240. console.log('ids',ids)
  241. schedulesArr.map(item => {
  242. if(ids.indexOf(item.patient_id) > -1){
  243. schedules.push(item)
  244. }
  245. })
  246. for (let i = 0; i < schedules.length; i++) {
  247. schedules[i].dialysis_no = schedules[i].patient.dialysis_no
  248. }
  249. var arr = []
  250. for (let j = 0; j < schedules.length; j++) {
  251. arr.push(schedules[j].dialysis_no)
  252. }
  253. arr.sort(function (a, b) {
  254. return a - b
  255. })
  256. var arrTwo = []
  257. for (let i = 0; i < arr.length; i++) {
  258. for (let j = 0; j < schedules.length; j++) {
  259. if (arr[i] == schedules[j].dialysis_no) {
  260. arrTwo.push(schedules[j])
  261. }
  262. }
  263. }
  264. arrTwo.map((item, index) => {
  265. item.doctor_advice.sort(this.compare('start_time'))
  266. })
  267. const res = new Map()
  268. let a = arrTwo.filter(
  269. a => !res.has(a.dialysis_no) && res.set(a.dialysis_no, 1)
  270. )
  271. schedules = a
  272. var zoneMap = {}
  273. var scheduleMap = {}
  274. for (let index = 0; index < schedules.length; index++) {
  275. const schedule = schedules[index]
  276. if (schedule.doctor_advice.length == 0) {
  277. continue
  278. }
  279. if (scheduleMap[schedule.device_number.zone.name] == null) {
  280. scheduleMap[schedule.device_number.zone.name] = []
  281. }
  282. scheduleMap[schedule.device_number.zone.name].push(schedule)
  283. if (zoneMap[schedule.device_number.zone.name] == null) {
  284. zoneMap[schedule.device_number.zone.name] =
  285. schedule.device_number.zone
  286. }
  287. }
  288. var zones = []
  289. zones.push({ value: 0, text: '全部分区' })
  290. for (var zoneName in zoneMap) {
  291. zones.push({ value: zoneMap[zoneName].id, text: zoneName })
  292. }
  293. zones = zones.sort(function (a, b) {
  294. return a.value > b.value
  295. })
  296. this.zones = zones
  297. for (var key in scheduleMap) {
  298. let mapArr = scheduleMap[key]
  299. for (let i = 0; i < mapArr.length; i++) {
  300. mapArr[i]['new_advice'] = []
  301. }
  302. }
  303. for (var key in scheduleMap) {
  304. let mapArr = scheduleMap[key]
  305. for (let i = 0; i < mapArr.length; i++) {
  306. var maps = mapArr[i]
  307. var resp_advices = maps.doctor_advice
  308. if (resp_advices.length > 0) {
  309. var newGroupObject = function () {
  310. return Object.assign(
  311. {},
  312. {
  313. group_no: 0,
  314. advices: []
  315. }
  316. )
  317. }
  318. var initGroupBlock = function (group, advice) {
  319. group.group_no = advice.groupno
  320. }
  321. var advice_groups = []
  322. var group = newGroupObject()
  323. for (let index = 0; index < resp_advices.length; index++) {
  324. const advice = resp_advices[index]
  325. if (advice.groupno == 0) {
  326. // 老版本的医嘱
  327. if (advice.parent_id > 0) {
  328. if (advice_groups.length > 0) {
  329. var parent_group = advice_groups[advice_groups.length - 1]
  330. if (parent_group.advices.length > 0) {
  331. if (parent_group.advices[0].id == advice.parent_id) {
  332. parent_group.advices.push(advice)
  333. }
  334. }
  335. }
  336. continue
  337. } else {
  338. if (group.group_no > 0) {
  339. advice_groups.push(group)
  340. group = newGroupObject()
  341. }
  342. initGroupBlock(group, advice)
  343. group.advices.push(advice)
  344. advice_groups.push(group)
  345. group = newGroupObject()
  346. continue
  347. }
  348. } else {
  349. if (group.group_no > 0 && group.group_no != advice.groupno) {
  350. advice_groups.push(group)
  351. group = newGroupObject()
  352. }
  353. if (group.group_no == 0) {
  354. initGroupBlock(group, advice)
  355. }
  356. if (group.group_no == advice.groupno) {
  357. group.advices.push(advice)
  358. }
  359. }
  360. }
  361. if (group.group_no > 0) {
  362. // 上述的算法会导致最后一组没有加到advice_groups,这里要手动加
  363. advice_groups.push(group)
  364. }
  365. advice_groups = advice_groups
  366. } else {
  367. advice_groups = []
  368. }
  369. maps.new_advice = advice_groups
  370. }
  371. }
  372. this.list = schedules
  373. this.scheduleMap = scheduleMap
  374. }
  375. console.log("this.list",this.list)
  376. }
  377. })
  378. },
  379. compare (property) {
  380. return function (a, b) {
  381. var value1 = a[property]
  382. var value2 = b[property]
  383. return value1 - value2
  384. }
  385. },
  386. parseTime: function (time, layout) {
  387. if (time == 0) {
  388. return ''
  389. }
  390. return parseTime(time, layout)
  391. },
  392. getName (val) {
  393. for (let i = 0; i < this.admin_user.length; i++) {
  394. if (this.admin_user[i].id == val) {
  395. return this.admin_user[i].name
  396. }
  397. }
  398. },
  399. getAdvice: function(doctor_advice) {
  400. if (doctor_advice.length > 0) {
  401. let name = "";
  402. for (let i = 0; i < doctor_advice.length; i++) {
  403. let prescribing_number = "";
  404. let single_dose = "";
  405. let drug_spec = "";
  406. if (doctor_advice[i].prescribing_number > 0) {
  407. prescribing_number =
  408. doctor_advice[i].prescribing_number +
  409. doctor_advice[i].prescribing_number_unit;
  410. }
  411. if (doctor_advice[i].single_dose > 0) {
  412. single_dose =
  413. " 单次用量 " +
  414. doctor_advice[i].single_dose +
  415. doctor_advice[i].single_dose_unit;
  416. }
  417. if (doctor_advice[i].drug_spec > 0) {
  418. drug_spec =
  419. doctor_advice[i].drug_spec + doctor_advice[i].drug_spec_unit;
  420. }
  421. name =
  422. name +
  423. doctor_advice[i].advice_name +
  424. " " +
  425. drug_spec +
  426. " " +
  427. prescribing_number +
  428. " " +
  429. single_dose +
  430. " " +
  431. doctor_advice[i].delivery_way +
  432. " " +
  433. doctor_advice[i].execution_frequency +
  434. " " +
  435. doctor_advice[i].remark +
  436. "\n";
  437. // if (doctor_advice[i].child.length > 0) {
  438. // for (let a = 0; a < doctor_advice[i].child.length; a++) {
  439. // if (doctor_advice[i].child[a].prescribing_number > 0) {
  440. // doctor_advice[i].child[a]["presc"] =
  441. // doctor_advice[i].child[a].prescribing_number +
  442. // doctor_advice[i].child[a].prescribing_number_unit;
  443. // } else {
  444. // doctor_advice[i].child[a]["presc"] = "";
  445. // }
  446. // if (doctor_advice[i].child[a].single_dose > 0) {
  447. // doctor_advice[i].child[a]["single"] =
  448. // " " +
  449. // " 单次用量 " +
  450. // " " +
  451. // doctor_advice[i].child[a].single_dose +
  452. // doctor_advice[i].child[a].single_dose_unit;
  453. // } else {
  454. // doctor_advice[i].child[a]["single"] = "";
  455. // }
  456. // name =
  457. // name +
  458. // "▲" +
  459. // doctor_advice[i].child[a].advice_name +
  460. // "" +
  461. // doctor_advice[i].child[a].advice_desc +
  462. // doctor_advice[i].child[a].drug_spec_unit +
  463. // doctor_advice[i].child[a].presc +
  464. // doctor_advice[i].child[a].single +
  465. // "\n";
  466. // }
  467. // }
  468. }
  469. return name;
  470. }else{
  471. return ""
  472. }
  473. },
  474. },
  475. computed: {
  476. filtedScheduals: function () {
  477. var scheduleMap = new Object()
  478. if (this.zone_selected == 0) {
  479. for (const key in this.scheduleMap) {
  480. scheduleMap[key] = this.scheduleMap[key]
  481. }
  482. } else {
  483. var zone_name = this.zones[this.zone_selected].text
  484. scheduleMap[zone_name] = this.scheduleMap[zone_name]
  485. }
  486. if (this.schedule_type_selected != 0) {
  487. var _scheduleMap = {}
  488. for (const key in scheduleMap) {
  489. var origin_schedules = scheduleMap[key]
  490. var schedules = []
  491. for (let index = 0; index < origin_schedules.length; index++) {
  492. const schedule = origin_schedules[index]
  493. if (schedule.schedule_type == this.schedule_type_selected) {
  494. schedules.push(schedule)
  495. }
  496. }
  497. if (schedules.length > 0) {
  498. _scheduleMap[key] = schedules
  499. }
  500. }
  501. scheduleMap = _scheduleMap
  502. }
  503. for (var key in scheduleMap) {
  504. let mapArr = scheduleMap[key]
  505. for (let i = 0; i < mapArr.length; i++) {
  506. mapArr[i]['new_advice'] = []
  507. }
  508. }
  509. for (var key in scheduleMap) {
  510. let mapArr = scheduleMap[key]
  511. for (let i = 0; i < mapArr.length; i++) {
  512. var maps = mapArr[i]
  513. var resp_advices = maps.doctor_advice
  514. if (resp_advices.length > 0) {
  515. var newGroupObject = function () {
  516. return Object.assign(
  517. {},
  518. {
  519. group_no: 0,
  520. advices: []
  521. }
  522. )
  523. }
  524. var initGroupBlock = function (group, advice) {
  525. group.group_no = advice.groupno
  526. }
  527. var advice_groups = []
  528. var group = newGroupObject()
  529. for (let index = 0; index < resp_advices.length; index++) {
  530. const advice = resp_advices[index]
  531. if (advice.groupno == 0) {
  532. // 老版本的医嘱
  533. if (advice.parent_id > 0) {
  534. if (advice_groups.length > 0) {
  535. var parent_group = advice_groups[advice_groups.length - 1]
  536. if (parent_group.advices.length > 0) {
  537. if (parent_group.advices[0].id == advice.parent_id) {
  538. parent_group.advices.push(advice)
  539. }
  540. }
  541. }
  542. continue
  543. } else {
  544. if (group.group_no > 0) {
  545. advice_groups.push(group)
  546. group = newGroupObject()
  547. }
  548. initGroupBlock(group, advice)
  549. group.advices.push(advice)
  550. advice_groups.push(group)
  551. group = newGroupObject()
  552. continue
  553. }
  554. } else {
  555. if (group.group_no > 0 && group.group_no != advice.groupno) {
  556. advice_groups.push(group)
  557. group = newGroupObject()
  558. }
  559. if (group.group_no == 0) {
  560. initGroupBlock(group, advice)
  561. }
  562. if (group.group_no == advice.groupno) {
  563. group.advices.push(advice)
  564. }
  565. }
  566. }
  567. if (group.group_no > 0) {
  568. // 上述的算法会导致最后一组没有加到advice_groups,这里要手动加
  569. advice_groups.push(group)
  570. }
  571. advice_groups = advice_groups
  572. } else {
  573. advice_groups = []
  574. }
  575. maps.new_advice = advice_groups
  576. }
  577. }
  578. console.log("222222",scheduleMap)
  579. return scheduleMap
  580. },
  581. },
  582. created(){
  583. var time = this.$route.query.time
  584. var delivery_way = this.$route.query.delivery_way
  585. console.log("delivery_Way",delivery_way)
  586. this.delivery_way = delivery_way
  587. this.time = moment(time).format('YYYY-MM-DD')
  588. console.log(11,this.$route.query)
  589. this.requestSchedualDoctors(time)
  590. }
  591. }
  592. </script>
  593. <style rel="stylesheet/scss" lang="scss" scoped>
  594. .signPrint{
  595. -webkit-box-shadow: 0 1px 4px rgba(0, 0, 0, 0.27), 0 0 60px rgba(0, 0, 0, 0.06) inset;
  596. -moz-box-shadow: 0 1px 4px rgba(0, 0, 0, 0.27), 0 0 40px rgba(0, 0, 0, 0.06) inset;
  597. box-shadow: 0 1px 4px rgba(0, 0, 0, 0.27), 0 0 40px rgba(0, 0, 0, 0.06) inset;
  598. margin-bottom: 20px;
  599. padding: 20px 10px;
  600. }
  601. .dialysisTable{
  602. width:960px;
  603. margin: 0 auto;
  604. text-align: center;
  605. border-collapse: collapse;
  606. }
  607. .order_title_panl {
  608. text-align: center;
  609. .main_title {
  610. font-size: 18px;
  611. line-height: 40px;
  612. font-weight: 500;
  613. }
  614. }
  615. .dialysisTable tr{
  616. padding: 10px 0;
  617. }
  618. .dialysisTable th {
  619. color: #000;
  620. padding: 0;
  621. margin: 0;
  622. height: 30px;
  623. }
  624. .dialysisTable tr td {
  625. padding: 12px 0;
  626. }
  627. .subadvice_content {
  628. text-align: left;
  629. padding-left: 25px !important;
  630. padding-right: 5px !important;
  631. }
  632. .advice_content {
  633. text-align: left;
  634. padding-left: 5px !important;
  635. padding-right: 5px !important;
  636. padding: 15px 5px !important;
  637. }
  638. </style>