medical_print.vue 8.4KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249
  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;">
  12. <div id="print_content">
  13. <div class="print_main_content">
  14. <div class="order_title_panl">
  15. <span class="main_title">{{ $store.getters.xt_user.org.org_name }}医护排班表</span>
  16. </div>
  17. <div style="text-align:right;margin-bottom:20px;font-size: 18px;">
  18. 打印时间:{{ getNowFormatDate() }}
  19. </div>
  20. <div class="table_panel">
  21. <table class="table">
  22. <thead>
  23. <tr>
  24. <td width="120">医护姓名</td>
  25. <td width="120">周一</td>
  26. <td width="120">周二</td>
  27. <td width="120">周三</td>
  28. <td width="120">周四</td>
  29. <td width="120">周五</td>
  30. <td width="120">周六</td>
  31. <td width="120">周日</td>
  32. </tr>
  33. </thead>
  34. <tbody>
  35. <tr v-for='(item,index) in tableData' :key="index">
  36. <td>{{ item.user_name }}</td>
  37. <td>{{ getClass(item.user_name,1) }}</td>
  38. <td>{{ getClass(item.user_name,2) }}</td>
  39. <td>{{ getClass(item.user_name,3) }}</td>
  40. <td>{{ getClass(item.user_name,4) }}</td>
  41. <td>{{ getClass(item.user_name,5) }}</td>
  42. <td>{{ getClass(item.user_name,6) }}</td>
  43. <td>{{ getClass(item.user_name,7) }}</td>
  44. </tr>
  45. </tbody>
  46. </table>
  47. </div>
  48. </div>
  49. </div>
  50. </div>
  51. </div>
  52. </template>
  53. <script>
  54. import BreadCrumb from '@/xt_pages/components/bread-crumb'
  55. import print from 'print-js'
  56. import { getDoctorList,getStaffScheduleList } from '@/api/doctorSchedule'
  57. export default {
  58. components:{
  59. BreadCrumb
  60. },
  61. data(){
  62. return{
  63. crumbs: [
  64. { path: false, name: '医护排班' },
  65. { path: false, name: '排班打印' }
  66. ],
  67. start_time:"",
  68. end_time:"",
  69. doctorlist:[],
  70. tableData:[]
  71. }
  72. },
  73. methods:{
  74. printAction: function() {
  75. const style = '@media print { .print_main_content { background-color: white; width:960px; margin:0 auto; padding: 0 0 20px 0; } .order_title_panl { text-align: center; } .main_title { font-size: 18px; line-height: 40px; font-weight: 500; } .table_panel { } .table { width: 100%; border: 1px solid; border-collapse: collapse; padding: 2px; } thead tr td { border: 1px solid; text-align: center; font-size: 20px; padding: 15px 5px; } tbody tr td { border: 1px solid; text-align: center; font-size: 18px; padding: 10px 5px; } .proj { padding: 5px 0; text-align: left; } .proj_title { font-size: 16px; font-weight: 500; line-height: 25px; } .proj_item { font-size: 15px; line-height: 20px; } .zone_name { font-weight: 500; } }'
  76. printJS({
  77. printable: 'print_content',
  78. type: 'html',
  79. documentTitle: ' ',
  80. style: style,
  81. scanStyles: false
  82. })
  83. },
  84. getDoctorList(){
  85. getDoctorList().then(response=>{
  86. var list = response.data.data.list
  87. console.log("医护列表",list)
  88. this.doctorlist = list
  89. this.getStaffScheduleList()
  90. })
  91. },
  92. //获取本周的所有排班列表
  93. getStaffScheduleList(){
  94. const params = {
  95. start_time:this.start_time,
  96. end_time:this.end_time,
  97. }
  98. getStaffScheduleList(params).then(response=>{
  99. if(response.data.state == 1){
  100. var staffList = response.data.data.staffList
  101. console.log("staffList",staffList)
  102. let tempArr = [], newArr = []
  103. for (let i = 0; i < staffList.length; i++) {
  104. if(tempArr.indexOf(staffList[i].user_name) === -1) {
  105. newArr.push({
  106. user_name: staffList[i].user_name,
  107. admin_user_id:staffList[i].admin_user_id,
  108. list: [{class_name:staffList[i].class_name,schedule_week:staffList[i].schedule_week}]
  109. })
  110. tempArr.push(staffList[i].user_name);
  111. } else {
  112. for (let j = 0; j < newArr.length; j++) {
  113. if (newArr[j].user_name == staffList[i].user_name) {
  114. newArr[j].list.push({class_name:staffList[i].class_name,admin_user_id:staffList[i].admin_user_id,schedule_week:staffList[i].schedule_week})
  115. }
  116. }
  117. }
  118. }
  119. let arr = [...newArr]
  120. this.doctorlist.map((item,index) => {
  121. if(!(arr[index] && item.admin_user_id == arr[index].admin_user_id)){
  122. arr.splice(index,0,{user_name:item.user_name,admin_user_id: item.admin_user_id,list: []})
  123. }
  124. })
  125. console.log(arr)
  126. this.tableData = arr
  127. }
  128. })
  129. },
  130. getClass(name,index){
  131. if(name != undefined){
  132. let newClass = '';
  133. this.tableData.map(item => {
  134. if(item.user_name == name){
  135. if(item.list){
  136. item.list.map(it => {
  137. if(it.schedule_week == index){
  138. newClass = it.class_name
  139. }
  140. })
  141. }
  142. }
  143. })
  144. return newClass
  145. }
  146. },
  147. getNowFormatDate() {
  148. var date = new Date();
  149. var seperator1 = "-";
  150. var year = date.getFullYear();
  151. var month = date.getMonth() + 1;
  152. var strDate = date.getDate();
  153. if (month >= 1 && month <= 9) {
  154. month = "0" + month;
  155. }
  156. if (strDate >= 0 && strDate <= 9) {
  157. strDate = "0" + strDate;
  158. }
  159. var currentdate = year + seperator1 + month + seperator1 + strDate;
  160. return currentdate;
  161. }
  162. },
  163. created(){
  164. var starttime = this.$route.query.starttime
  165. console.log("starttime",starttime)
  166. this.start_time = starttime
  167. var endtime = this.$route.query.endtime
  168. console.log("endtime",endtime)
  169. this.end_time = endtime
  170. //获取该机构所有医护人员
  171. this.getDoctorList()
  172. }
  173. }
  174. </script>
  175. <style rel="stylesheet/scss" lang="scss" scoped>
  176. .print_main_content {
  177. background-color: white;
  178. max-width: 1500px;
  179. margin: 0 auto;
  180. padding: 0 0 20px 0;
  181. .order_title_panl {
  182. text-align: center;
  183. .main_title {
  184. font-size: 18px;
  185. line-height: 40px;
  186. font-weight: 500;
  187. }
  188. }
  189. .table_panel {
  190. .table {
  191. width: 100%;
  192. border: 1px solid;
  193. border-collapse: collapse;
  194. padding: 2px;
  195. thead {
  196. tr {
  197. td {
  198. border: 1px solid;
  199. text-align: center;
  200. font-size: 20px;
  201. padding: 15px 5px;
  202. }
  203. }
  204. }
  205. tbody {
  206. tr {
  207. td {
  208. border: 1px solid;
  209. text-align: center;
  210. font-size: 18px;
  211. padding: 10px 5px;
  212. .proj {
  213. padding: 5px 0;
  214. text-align: left;
  215. .proj_title {
  216. font-size: 16px;
  217. font-weight: 500;
  218. line-height: 25px;
  219. }
  220. .proj_item {
  221. font-size: 15px;
  222. line-height: 20px;
  223. .zone_name {
  224. font-weight: 500;
  225. }
  226. }
  227. }
  228. }
  229. }
  230. }
  231. }
  232. }
  233. }
  234. </style>