doctorAdvicePrintTwo.vue 12KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351
  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 class="order_title_panl">
  14. <span class="main_title">临时医嘱</span>
  15. </div>
  16. <p style="width: 960px;text-align: right;margin: 0 auto 10px;">日期:{{ time }}</p>
  17. <table class="table dialysisTable" border="1" cellspacing="0" cellpadding="0">
  18. <tr>
  19. <th width="20px">序号</th>
  20. <th width="100px">姓名</th>
  21. <th width="50px">医嘱名称</th>
  22. <th width="50px">药品规格</th>
  23. <th width="50px">单位</th>
  24. <th width="50px">数量</th>
  25. </tr>
  26. <tr v-for="(item,index) in tableData" :key="index">
  27. <th width="20px">
  28. {{ index+1 }}
  29. </th>
  30. <th width="100px">
  31. {{ item.patient_name }}
  32. </th>
  33. <th width="50px">
  34. {{ item.advice_name }}
  35. </th>
  36. <th width="50px">
  37. {{ getSpecicalName(item.drug_id) }}
  38. </th>
  39. <th width="50px">
  40. {{ item.prescribing_number_unit }}
  41. </th>
  42. <th width="50px">
  43. {{ item.prescribing_number }}
  44. </th>
  45. </tr>
  46. </table>
  47. </div>
  48. </div>
  49. </div>
  50. </template>
  51. <script>
  52. import BreadCrumb from '@/xt_pages/components/bread-crumb'
  53. import { getSchedualDoctors } from '@/api/advice'
  54. import { parseTime } from '@/utils'
  55. import { jsGetAge } from "@/utils/tools";
  56. import print from 'print-js'
  57. const moment = require('moment')
  58. export default {
  59. components:{
  60. BreadCrumb
  61. },
  62. data(){
  63. return{
  64. crumbs: [
  65. { path: false, name: '药品' },
  66. { path: false, name: '打印' }
  67. ],
  68. tableData:[],
  69. start_time:"",
  70. end_time:"",
  71. print_time:moment(new Date()).add('year', 0).format('YYYY-MM-DD'),
  72. zone_selected: 0,
  73. scheduleMap:[],
  74. time:'',
  75. show:true,
  76. showOne:false,
  77. delivery_way:"",
  78. org_id:0,
  79. drugList:[]
  80. }
  81. },
  82. methods:{
  83. getAge: function (val) {
  84. var thisLen = val.patient.id_card_no.length;
  85. var birth = "";
  86. if (thisLen == 15) {
  87. birth = "19" + val.patient.id_card_no.substr(6, 6);
  88. } else {
  89. birth = val.patient.id_card_no.substr(6, 8);
  90. }
  91. var birthtwo =
  92. birth.substr(0, 4) +
  93. "-" +
  94. birth.substr(4, 2) +
  95. "-" +
  96. birth.substr(6, 2);
  97. var age = jsGetAge(birthtwo, "-");
  98. return age;
  99. },
  100. printAction: function() {
  101. 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;} }'
  102. printJS({
  103. printable: 'dialysisTable',
  104. type: 'html',
  105. documentTitle: ' ',
  106. style: style,
  107. scanStyles: false
  108. })
  109. },
  110. requestSchedualDoctors (time) {
  111. let newTime = moment(time).format('YYYY-MM-DD')
  112. getSchedualDoctors({
  113. date: newTime,
  114. patient_type: 0,
  115. advice_type: 2,
  116. delivery_way:this.delivery_way,
  117. }).then(rs => {
  118. var resp = rs.data
  119. if (resp.state == 1) {
  120. this.admin_user = resp.data.adminUser
  121. var config = resp.data.config
  122. let project_config = resp.data.project_config
  123. var hisAdvices = resp.data.hisAdvices
  124. var drugList = resp.data.drug
  125. this.drugList = []
  126. this.drugList = drugList
  127. var newArr = []
  128. if(hisAdvices!=null && hisAdvices.length>0){
  129. for(let i=0;i<hisAdvices.length>0;i++){
  130. for(let j=0;j<hisAdvices[i].doctor_advice.length;j++){
  131. hisAdvices[i].doctor_advice[j].patient_name = ""
  132. hisAdvices[i].doctor_advice[j].patient_name = hisAdvices[i].patient.name
  133. if(hisAdvices[i].doctor_advice[j].delivery_way !='口服' && hisAdvices[i].doctor_advice[j].delivery_way!='中药口服'){
  134. if(hisAdvices[i].doctor_advice[j].execution_frequency.indexOf('上机前')==-1){
  135. newArr.push(hisAdvices[i].doctor_advice[j])
  136. }
  137. }
  138. }
  139. }
  140. }
  141. this.tableData = []
  142. this.tableData = newArr
  143. console.log("newArr------",newArr)
  144. }
  145. })
  146. },
  147. compare (property) {
  148. return function (a, b) {
  149. var value1 = a[property]
  150. var value2 = b[property]
  151. return value1 - value2
  152. }
  153. },
  154. parseTime: function (time, layout) {
  155. if (time == 0) {
  156. return ''
  157. }
  158. return parseTime(time, layout)
  159. },
  160. getName (val) {
  161. for (let i = 0; i < this.admin_user.length; i++) {
  162. if (this.admin_user[i].id == val) {
  163. return this.admin_user[i].name
  164. }
  165. }
  166. },
  167. getSpecicalName(drug_id){
  168. var specification_name = ""
  169. for(let i=0;i<this.drugList.length;i++){
  170. if(drug_id == this.drugList[i].id){
  171. specification_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
  172. }
  173. }
  174. return specification_name
  175. }
  176. },
  177. computed: {
  178. filtedScheduals: function () {
  179. var scheduleMap = new Object()
  180. if (this.zone_selected == 0) {
  181. for (const key in this.scheduleMap) {
  182. scheduleMap[key] = this.scheduleMap[key]
  183. }
  184. } else {
  185. var zone_name = this.zones[this.zone_selected].text
  186. scheduleMap[zone_name] = this.scheduleMap[zone_name]
  187. }
  188. if (this.schedule_type_selected != 0) {
  189. var _scheduleMap = {}
  190. for (const key in scheduleMap) {
  191. var origin_schedules = scheduleMap[key]
  192. var schedules = []
  193. for (let index = 0; index < origin_schedules.length; index++) {
  194. const schedule = origin_schedules[index]
  195. if (schedule.schedule_type == this.schedule_type_selected) {
  196. schedules.push(schedule)
  197. }
  198. }
  199. if (schedules.length > 0) {
  200. _scheduleMap[key] = schedules
  201. }
  202. }
  203. scheduleMap = _scheduleMap
  204. }
  205. for (var key in scheduleMap) {
  206. let mapArr = scheduleMap[key]
  207. for (let i = 0; i < mapArr.length; i++) {
  208. mapArr[i]['new_advice'] = []
  209. }
  210. }
  211. for (var key in scheduleMap) {
  212. let mapArr = scheduleMap[key]
  213. for (let i = 0; i < mapArr.length; i++) {
  214. var maps = mapArr[i]
  215. var resp_advices = maps.doctor_advice
  216. if (resp_advices.length > 0) {
  217. var newGroupObject = function () {
  218. return Object.assign(
  219. {},
  220. {
  221. group_no: 0,
  222. advices: []
  223. }
  224. )
  225. }
  226. var initGroupBlock = function (group, advice) {
  227. group.group_no = advice.groupno
  228. }
  229. var advice_groups = []
  230. var group = newGroupObject()
  231. for (let index = 0; index < resp_advices.length; index++) {
  232. const advice = resp_advices[index]
  233. if (advice.groupno == 0) {
  234. // 老版本的医嘱
  235. if (advice.parent_id > 0) {
  236. if (advice_groups.length > 0) {
  237. var parent_group = advice_groups[advice_groups.length - 1]
  238. if (parent_group.advices.length > 0) {
  239. if (parent_group.advices[0].id == advice.parent_id) {
  240. parent_group.advices.push(advice)
  241. }
  242. }
  243. }
  244. continue
  245. } else {
  246. if (group.group_no > 0) {
  247. advice_groups.push(group)
  248. group = newGroupObject()
  249. }
  250. initGroupBlock(group, advice)
  251. group.advices.push(advice)
  252. advice_groups.push(group)
  253. group = newGroupObject()
  254. continue
  255. }
  256. } else {
  257. if (group.group_no > 0 && group.group_no != advice.groupno) {
  258. advice_groups.push(group)
  259. group = newGroupObject()
  260. }
  261. if (group.group_no == 0) {
  262. initGroupBlock(group, advice)
  263. }
  264. if (group.group_no == advice.groupno) {
  265. group.advices.push(advice)
  266. }
  267. }
  268. }
  269. if (group.group_no > 0) {
  270. // 上述的算法会导致最后一组没有加到advice_groups,这里要手动加
  271. advice_groups.push(group)
  272. }
  273. advice_groups = advice_groups
  274. } else {
  275. advice_groups = []
  276. }
  277. maps.new_advice = advice_groups
  278. }
  279. }
  280. console.log("222222",scheduleMap)
  281. return scheduleMap
  282. }
  283. },
  284. created(){
  285. var time = this.$route.query.time
  286. var delivery_way = this.$route.query.delivery_way
  287. this.delivery_way = delivery_way
  288. this.time = moment(time).format('YYYY-MM-DD')
  289. console.log(11,this.$route.query)
  290. this.requestSchedualDoctors(time)
  291. this.org_id = this.$store.getters.xt_user.template_info.org_id;
  292. }
  293. }
  294. </script>
  295. <style rel="stylesheet/scss" lang="scss" scoped>
  296. .dialysisTable{
  297. width:960px;
  298. margin: 0 auto;
  299. text-align: center;
  300. border-collapse: collapse;
  301. }
  302. .order_title_panl {
  303. text-align: center;
  304. .main_title {
  305. font-size: 18px;
  306. line-height: 40px;
  307. font-weight: 500;
  308. }
  309. }
  310. .dialysisTable tr{
  311. padding: 10px 0;
  312. }
  313. .dialysisTable th {
  314. color: #000;
  315. padding: 0;
  316. margin: 0;
  317. height: 30px;
  318. }
  319. .dialysisTable tr td {
  320. padding: 12px 0;
  321. }
  322. .subadvice_content {
  323. text-align: left;
  324. padding-left: 25px !important;
  325. padding-right: 5px !important;
  326. }
  327. .advice_content {
  328. text-align: left;
  329. padding-left: 5px !important;
  330. padding-right: 5px !important;
  331. padding: 15px 5px !important;
  332. }
  333. </style>