queryPrint.vue 24KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636
  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. 打印时间:
  19. </div>
  20. <div class="table_panel">
  21. <table class="table">
  22. <thead>
  23. <tr>
  24. <td width="60">序号</td>
  25. <td width="80">透析号</td>
  26. <td width="80">姓名</td>
  27. <td>药品名称</td>
  28. <td>规格名称</td>
  29. <td width="70">单位</td>
  30. <td width="70">自备量</td>
  31. <td width="70">已使用</td>
  32. <td width="70">剩余</td>
  33. </tr>
  34. </thead>
  35. <tbody>
  36. <tr v-for='(item,index) in 8' :key="index">
  37. <td>张三</td>
  38. <td>张三</td>
  39. <td>张三</td>
  40. <td>张三</td>
  41. <td>张三</td>
  42. <td>张三</td>
  43. <td>张三</td>
  44. <td>张三</td>
  45. <td>张三</td>
  46. </tr>
  47. </tbody>
  48. </table>
  49. </div>
  50. </div>
  51. </div>
  52. </div>
  53. </div>
  54. </template>
  55. <script>
  56. import BreadCrumb from '@/xt_pages/components/bread-crumb'
  57. import print from 'print-js'
  58. import { getDoctorList,getScheduleByDoctorId } from '@/api/doctorSchedule'
  59. export default {
  60. components:{
  61. BreadCrumb
  62. },
  63. data(){
  64. return{
  65. crumbs: [
  66. { path: false, name: '库存管理' },
  67. { path: false, name: '自备药查询' },
  68. { path: false, name: '自备药打印' },
  69. ],
  70. start_time:"",
  71. end_time:"",
  72. doctorlist:[],
  73. tableData:[],
  74. arrZero:[],
  75. arrOne:[],
  76. arrTwo:[],
  77. arrThree:[],
  78. arrFour:[],
  79. arrFive:[],
  80. arrSix:[],
  81. arrSeven:[],
  82. typevalue:0,
  83. doctorTableData:[],
  84. nurseTableData:[]
  85. }
  86. },
  87. methods:{
  88. printAction: function() {
  89. 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: 16px; padding: 15px 5px; } tbody tr td { border: 1px solid; text-align: center; font-size: 16px; padding: 10px 5px; white-space: pre-line;} .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; } }'
  90. printJS({
  91. printable: 'print_content',
  92. type: 'html',
  93. documentTitle: ' ',
  94. style: style,
  95. scanStyles: false
  96. })
  97. },
  98. getDoctorList(){
  99. getDoctorList().then(response=>{
  100. var list = response.data.data.list
  101. this.doctorlist = list
  102. this.getScheduleByDoctorId()
  103. //
  104. var doctorlist = response.data.data.doctorlist
  105. let arr = []
  106. for(let i=0;i<doctorlist.length;i++){
  107. if(doctorlist[i].sort == 0){
  108. doctorlist[i].sort = ""
  109. }
  110. }
  111. console.log('doctorlist',doctorlist)
  112. this.doctorTableData = doctorlist
  113. var nurselist = response.data.data.nurselist
  114. for(let i=0;i<nurselist.length;i++){
  115. if(nurselist[i].sort == 0){
  116. nurselist[i].sort = ""
  117. }
  118. }
  119. this.nurseTableData = nurselist
  120. })
  121. },
  122. //获取本周的所有排班列表
  123. getScheduleByDoctorId(){
  124. const params = {
  125. start_time:this.start_time,
  126. end_time:this.end_time,
  127. doctor_id:this.typevalue,
  128. }
  129. console.log("parasm",params)
  130. getScheduleByDoctorId(params).then(response=>{
  131. if(response.data.state == 1){
  132. var staffList = response.data.data.staffList
  133. console.log("stafflist",staffList)
  134. var sevenStr = ""
  135. var oneStr = ""
  136. var twoStr = ""
  137. var threeStr = ""
  138. var fourStr = ""
  139. var fiveStr = ""
  140. var sixStr = ""
  141. for(let i=0;i<staffList.length;i++){
  142. if(staffList[i].schedule_week == 0){
  143. staffList[i].class_index = 0
  144. var arr = []
  145. this.arrZero.push(staffList[i].class_name)
  146. for(let i=0;i<this.arrZero.length;i++){
  147. if(this.arrZero[i]!=''){
  148. arr.push(this.arrZero[i])
  149. }
  150. }
  151. var countedNames = arr.reduce(function (allNames, name) {
  152. if (name in allNames) {
  153. allNames[name]++;
  154. }
  155. else {
  156. allNames[name] = 1;
  157. }
  158. return allNames;
  159. }, {});
  160. let objKey = Object.keys(countedNames)
  161. let objVal = Object.values(countedNames)
  162. var zeroStr = ''
  163. objKey.map((item,index) => {
  164. let objVal = Object.values(countedNames)
  165. zeroStr += item + objVal[index] + '\n'
  166. })
  167. sevenStr = zeroStr
  168. }
  169. if(staffList[i].schedule_week == 1){
  170. staffList[i].class_index = 1
  171. var arr = []
  172. this.arrOne.push(staffList[i].class_name)
  173. for(let i=0;i<this.arrOne.length;i++){
  174. if(this.arrOne[i]!=''){
  175. arr.push(this.arrOne[i])
  176. }
  177. }
  178. var countedNames = arr.reduce(function (allNames, name) {
  179. if (name in allNames) {
  180. allNames[name]++;
  181. }
  182. else {
  183. allNames[name] = 1;
  184. }
  185. return allNames;
  186. }, {});
  187. let objKey = Object.keys(countedNames)
  188. let objVal = Object.values(countedNames)
  189. let strOne = ''
  190. objKey.map((item,index) => {
  191. let objVal = Object.values(countedNames)
  192. strOne += item + objVal[index] + '\n'
  193. })
  194. oneStr = strOne
  195. }
  196. if(staffList[i].schedule_week == 2){
  197. staffList[i].class_index = 2
  198. var arr = []
  199. this.arrTwo.push(staffList[i].class_name)
  200. for(let i=0;i<this.arrTwo.length;i++){
  201. if(this.arrTwo[i]!=''){
  202. arr.push(this.arrTwo[i])
  203. }
  204. }
  205. var countedNames = arr.reduce(function (allNames, name) {
  206. if (name in allNames) {
  207. allNames[name]++;
  208. }
  209. else {
  210. allNames[name] = 1;
  211. }
  212. return allNames;
  213. }, {});
  214. let objKey = Object.keys(countedNames)
  215. let objVal = Object.values(countedNames)
  216. let strTwo = ''
  217. objKey.map((item,index) => {
  218. let objVal = Object.values(countedNames)
  219. strTwo += item + objVal[index] + '\n'
  220. })
  221. twoStr = strTwo
  222. }
  223. if(staffList[i].schedule_week == 3){
  224. staffList[i].class_index = 3
  225. var arr = []
  226. this.arrThree.push(staffList[i].class_name)
  227. for(let i=0;i<this.arrThree.length;i++){
  228. if(this.arrThree[i]!=''){
  229. arr.push(this.arrThree[i])
  230. }
  231. }
  232. var countedNames = arr.reduce(function (allNames, name) {
  233. if (name in allNames) {
  234. allNames[name]++;
  235. }
  236. else {
  237. allNames[name] = 1;
  238. }
  239. return allNames;
  240. }, {});
  241. let objKey = Object.keys(countedNames)
  242. let objVal = Object.values(countedNames)
  243. let strThree = ''
  244. objKey.map((item,index) => {
  245. let objVal = Object.values(countedNames)
  246. strThree += item + objVal[index] + '\n'
  247. })
  248. threeStr = strThree
  249. }
  250. if(staffList[i].schedule_week == 4){
  251. staffList[i].class_index = 4
  252. var arr = []
  253. this.arrFour.push(staffList[i].class_name)
  254. for(let i=0;i<this.arrFour.length;i++){
  255. if(this.arrFour[i]!=''){
  256. arr.push(this.arrFour[i])
  257. }
  258. }
  259. var countedNames = arr.reduce(function (allNames, name) {
  260. if (name in allNames) {
  261. allNames[name]++;
  262. }
  263. else {
  264. allNames[name] = 1;
  265. }
  266. return allNames;
  267. }, {});
  268. let objKey = Object.keys(countedNames)
  269. let objVal = Object.values(countedNames)
  270. let strFour = ''
  271. objKey.map((item,index) => {
  272. let objVal = Object.values(countedNames)
  273. strFour += item + objVal[index] + '\n'
  274. })
  275. fourStr = strFour
  276. }
  277. if(staffList[i].schedule_week == 5){
  278. staffList[i].class_index = 5
  279. var arr = []
  280. this.arrFive.push(staffList[i].class_name)
  281. for(let i=0;i<this.arrFive.length;i++){
  282. if(this.arrFive[i]!=''){
  283. arr.push(this.arrFive[i])
  284. }
  285. }
  286. var countedNames = arr.reduce(function (allNames, name) {
  287. if (name in allNames) {
  288. allNames[name]++;
  289. }
  290. else {
  291. allNames[name] = 1;
  292. }
  293. return allNames;
  294. }, {});
  295. let objKey = Object.keys(countedNames)
  296. let objVal = Object.values(countedNames)
  297. let strFive = ''
  298. objKey.map((item,index) => {
  299. let objVal = Object.values(countedNames)
  300. strFive += item + objVal[index] + '\n'
  301. })
  302. fiveStr = strFive
  303. }
  304. if(staffList[i].schedule_week == 6){
  305. staffList[i].class_index = 6
  306. var arr = []
  307. this.arrSix.push(staffList[i].class_name)
  308. for(let i=0;i<this.arrSix.length;i++){
  309. if(this.arrSix[i]!=''){
  310. arr.push(this.arrSix[i])
  311. }
  312. }
  313. var countedNames = arr.reduce(function (allNames, name) {
  314. if (name in allNames) {
  315. allNames[name]++;
  316. }
  317. else {
  318. allNames[name] = 1;
  319. }
  320. return allNames;
  321. }, {});
  322. let objKey = Object.keys(countedNames)
  323. let objVal = Object.values(countedNames)
  324. let strSix = ''
  325. objKey.map((item,index) => {
  326. let objVal = Object.values(countedNames)
  327. strSix += item + objVal[index] + '\n'
  328. })
  329. sixStr = strSix
  330. }
  331. }
  332. let tempArr = [], newArr = []
  333. for (let i = 0; i < staffList.length; i++) {
  334. if (tempArr.indexOf(staffList[i].user_name) === -1) {
  335. newArr.push({
  336. user_name: staffList[i].user_name,
  337. admin_user_id:staffList[i].admin_user_id,
  338. user_type:staffList[i].doctor_type,
  339. is_sort:staffList[i].is_sort,
  340. sort:staffList[i].sort,
  341. list: [{class_name:staffList[i].class_name,admin_user_id:staffList[i].admin_user_id,schedule_week:staffList[i].schedule_week,user_type:staffList[i].doctor_type,class_attributes:staffList[i].class_attributes}]
  342. })
  343. tempArr.push(staffList[i].user_name);
  344. } else {
  345. for (let j = 0; j < newArr.length; j++) {
  346. if (newArr[j].user_name == staffList[i].user_name) {
  347. newArr[j].list.push({class_name:staffList[i].class_name,admin_user_id:staffList[i].admin_user_id,schedule_week:staffList[i].schedule_week,user_type:staffList[i].doctor_type,class_attributes:staffList[i].class_attributes})
  348. }
  349. }
  350. }
  351. }
  352. let arr = [...newArr]
  353. let newNurse = []
  354. let newDoctor = []
  355. arr.map(item => {
  356. if(item.user_type == 2){
  357. newDoctor.push(item)
  358. }
  359. if(item.user_type == 3){
  360. newNurse.push(item)
  361. }
  362. })
  363. if(this.typevalue == 0){
  364. //护士
  365. newNurse.sort(this.compare('admin_user_id'))
  366. let newNurseTableData = []
  367. this.nurseTableData.map(item => {
  368. if(item.is_sort == 1){
  369. newNurseTableData.push(item)
  370. }
  371. })
  372. newNurseTableData.sort(this.compare('admin_user_id'))
  373. newNurseTableData.map((item,index) => {
  374. if (newNurse[index] && item.admin_user_id == newNurse[index].admin_user_id) {
  375. }else{
  376. newNurse.splice(index, 0, {user_name: item.user_name, admin_user_id: item.admin_user_id, list: [],user_type:item.user_type,is_sort:item.is_sort,sort:item.sort})
  377. }
  378. })
  379. newNurse.sort(this.compare('sort'))
  380. //医生
  381. newDoctor.sort(this.compare('admin_user_id'))
  382. let newDoctorTableData = []
  383. this.doctorTableData.map(item => {
  384. if(item.is_sort == 1){
  385. newDoctorTableData.push(item)
  386. }
  387. })
  388. newDoctorTableData.sort(this.compare('admin_user_id'))
  389. newDoctorTableData.map((item,index) => {
  390. if (newDoctor[index] && item.admin_user_id == newDoctor[index].admin_user_id) {
  391. }else{
  392. newDoctor.splice(index, 0, {user_name: item.user_name, admin_user_id: item.admin_user_id, list: [],user_type:item.user_type,is_sort:item.is_sort,sort:item.sort})
  393. }
  394. })
  395. newDoctor.sort(this.compare('sort'))
  396. let arr2 = []
  397. arr2.push({class_name:oneStr,schedule_week:1})
  398. arr2.push({class_name:twoStr,schedule_week:2})
  399. arr2.push({class_name:threeStr,schedule_week:3})
  400. arr2.push({class_name:fourStr,schedule_week:4})
  401. arr2.push({class_name:fiveStr,schedule_week:5})
  402. arr2.push({class_name:sixStr,schedule_week:6})
  403. arr2.push({class_name:zeroStr,schedule_week:0})
  404. var obj = {}
  405. obj.admin_user_id = "1000000"
  406. obj.user_name = "合计"
  407. obj.user_type = 10
  408. obj.list = arr2
  409. arr.push(obj)
  410. let data = []
  411. data.push(...newNurse)
  412. data.push(...newDoctor)
  413. data.push(obj)
  414. this.tableData = data
  415. }
  416. if(this.typevalue == 2){
  417. newDoctor.sort(this.compare('admin_user_id'))
  418. let newDoctorTableData = []
  419. this.doctorTableData.map(item => {
  420. if(item.is_sort == 1){
  421. newDoctorTableData.push(item)
  422. }
  423. })
  424. newDoctorTableData.sort(this.compare('admin_user_id'))
  425. newDoctorTableData.map((item,index) => {
  426. if (newDoctor[index] && item.admin_user_id == newDoctor[index].admin_user_id) {
  427. }else{
  428. newDoctor.splice(index, 0, {user_name: item.user_name, admin_user_id: item.admin_user_id, list: [],user_type:item.user_type,is_sort:item.is_sort,sort:item.sort})
  429. }
  430. })
  431. newDoctor.sort(this.compare('sort'))
  432. let arr2 = []
  433. arr2.push({class_name:oneStr,schedule_week:1})
  434. arr2.push({class_name:twoStr,schedule_week:2})
  435. arr2.push({class_name:threeStr,schedule_week:3})
  436. arr2.push({class_name:fourStr,schedule_week:4})
  437. arr2.push({class_name:fiveStr,schedule_week:5})
  438. arr2.push({class_name:sixStr,schedule_week:6})
  439. arr2.push({class_name:zeroStr,schedule_week:0})
  440. var obj = {}
  441. obj.admin_user_id = "1000000"
  442. obj.user_name = "合计"
  443. obj.user_type = 10
  444. obj.list = arr2
  445. newDoctor.push(obj)
  446. this.tableData = newDoctor
  447. }
  448. if(this.typevalue == 3){
  449. newNurse.sort(this.compare('admin_user_id'))
  450. let newNurseTableData = []
  451. this.nurseTableData.map(item => {
  452. if(item.is_sort == 1){
  453. newNurseTableData.push(item)
  454. }
  455. })
  456. newNurseTableData.sort(this.compare('admin_user_id'))
  457. newNurseTableData.map((item,index) => {
  458. if (newNurse[index] && item.admin_user_id == newNurse[index].admin_user_id) {
  459. }else{
  460. newNurse.splice(index, 0, {user_name: item.user_name, admin_user_id: item.admin_user_id, list: [],user_type:item.user_type,is_sort:item.is_sort,sort:item.sort})
  461. }
  462. })
  463. newNurse.sort(this.compare('sort'))
  464. let arr2 = []
  465. arr2.push({class_name:oneStr,schedule_week:1})
  466. arr2.push({class_name:twoStr,schedule_week:2})
  467. arr2.push({class_name:threeStr,schedule_week:3})
  468. arr2.push({class_name:fourStr,schedule_week:4})
  469. arr2.push({class_name:fiveStr,schedule_week:5})
  470. arr2.push({class_name:sixStr,schedule_week:6})
  471. arr2.push({class_name:zeroStr,schedule_week:0})
  472. var obj = {}
  473. obj.admin_user_id = "1000000"
  474. obj.user_name = "合计"
  475. obj.user_type = 10
  476. obj.list = arr2
  477. newNurse.push(obj)
  478. this.tableData = newNurse
  479. }
  480. }
  481. })
  482. },
  483. getClass(name,index){
  484. if(name != undefined){
  485. let newClass = '';
  486. this.tableData.map(item => {
  487. if(item.user_name == name){
  488. if(item.list){
  489. item.list.map(it => {
  490. if(it.schedule_week == index){
  491. newClass = it.class_name
  492. }
  493. })
  494. }
  495. }
  496. })
  497. if(newClass && newClass.indexOf("(") > -1){
  498. let num = newClass.indexOf("(")
  499. let a = newClass.slice(0, num) + '\n' + newClass.slice(num)
  500. return a
  501. }else if(newClass && newClass.indexOf("(") > -1) {
  502. let num = newClass.indexOf("(")
  503. let a = newClass.slice(0, num) + '\n' + newClass.slice(num)
  504. return a
  505. }else{
  506. return newClass
  507. }
  508. }
  509. },
  510. getNowFormatDate() {
  511. var date = new Date();
  512. var seperator1 = "-";
  513. var year = date.getFullYear();
  514. var month = date.getMonth() + 1;
  515. var strDate = date.getDate();
  516. if (month >= 1 && month <= 9) {
  517. month = "0" + month;
  518. }
  519. if (strDate >= 0 && strDate <= 9) {
  520. strDate = "0" + strDate;
  521. }
  522. var currentdate = year + seperator1 + month + seperator1 + strDate;
  523. return currentdate;
  524. },
  525. compare(property){
  526. return function(a,b){
  527. var value1 = a[property];
  528. var value2 = b[property];
  529. return value2 - value1;
  530. }
  531. },
  532. },
  533. created(){
  534. var starttime = this.$route.query.starttime
  535. this.start_time = starttime
  536. var endtime = this.$route.query.endtime
  537. this.end_time = endtime
  538. this.weekArr = this.$route.query.weekArr.split(',')
  539. this.typevalue = parseInt(this.$route.query.typeValue)
  540. //获取该机构所有医护人员
  541. this.getDoctorList()
  542. }
  543. }
  544. </script>
  545. <style rel="stylesheet/scss" lang="scss" scoped>
  546. .print_main_content {
  547. background-color: white;
  548. max-width: 1500px;
  549. margin: 0 auto;
  550. padding: 0 0 20px 0;
  551. .order_title_panl {
  552. text-align: center;
  553. .main_title {
  554. font-size: 18px;
  555. line-height: 40px;
  556. font-weight: 500;
  557. }
  558. }
  559. .table_panel {
  560. .table {
  561. width: 100%;
  562. border: 1px solid;
  563. border-collapse: collapse;
  564. padding: 2px;
  565. thead {
  566. tr {
  567. td {
  568. border: 1px solid;
  569. text-align: center;
  570. font-size: 18px;
  571. padding: 15px 5px;
  572. }
  573. }
  574. }
  575. tbody {
  576. tr {
  577. td {
  578. border: 1px solid;
  579. text-align: center;
  580. font-size: 18px;
  581. padding: 10px 5px;
  582. white-space: pre-line;
  583. .proj {
  584. padding: 5px 0;
  585. text-align: left;
  586. .proj_title {
  587. font-size: 16px;
  588. font-weight: 500;
  589. line-height: 25px;
  590. }
  591. .proj_item {
  592. font-size: 15px;
  593. line-height: 20px;
  594. .zone_name {
  595. font-weight: 500;
  596. }
  597. }
  598. }
  599. }
  600. }
  601. }
  602. }
  603. }
  604. }
  605. </style>