longSignPrint.vue 26KB

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