queryPrint.vue 7.5KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216
  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">自备药查询表</span>
  16. </div>
  17. <div style="text-align:right;margin-bottom:20px;font-size: 18px;">
  18. 打印时间:{{time_now}}
  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 tableData' :key="index">
  37. <td>{{index+1}}</td>
  38. <td>{{item.dialysis_no}}</td>
  39. <td>{{item.name}}</td>
  40. <td>{{item.drug_name}}</td>
  41. <td>{{item.drug_spec}}</td>
  42. <!-- <td>{{item.min_unit}}</td> -->
  43. <td>{{item.Total?item.Total:0}}</td>
  44. <td>{{item.Count}}</td>
  45. <td>{{(item.Total?item.Total:0) - item.Count}}</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 { getAllPatientStockList } from '@/api/drug/drug'
  58. import print from 'print-js'
  59. const moment = require('moment')
  60. export default {
  61. components:{
  62. BreadCrumb
  63. },
  64. data(){
  65. return{
  66. crumbs: [
  67. { path: false, name: '库存管理' },
  68. { path: false, name: '自备药查询' },
  69. { path: false, name: '自备药打印' },
  70. ],
  71. start_time:"",
  72. end_time:"",
  73. drug_name:"",
  74. drug_spec:"",
  75. keyword:"",
  76. tableData:[],
  77. time_now:moment(new Date()).add('year',0).format("YYYY-MM-DD")
  78. }
  79. },
  80. methods:{
  81. printAction: function() {
  82. 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; } }'
  83. printJS({
  84. printable: 'print_content',
  85. type: 'html',
  86. documentTitle: ' ',
  87. style: style,
  88. scanStyles: false
  89. })
  90. },
  91. getlist(){
  92. const params = {
  93. start_time:this.start_time,
  94. end_time:this.end_time,
  95. drug_name:this.drug_name,
  96. drug_spec:this.drug_spec,
  97. search_input:this.keyword
  98. }
  99. console.log("params------",params)
  100. getAllPatientStockList(params).then(response=>{
  101. if(response.data.state == 1){
  102. var stocklist = response.data.data.stocklist
  103. for(let i=0;i<stocklist.length;i++){
  104. stocklist[i].index = i+1
  105. stocklist[i].Count = 0
  106. }
  107. var outStockList = response.data.data.outStockList
  108. // for(let i=0;i<stocklist.length;i++){
  109. // for(let j=0;j<outStockList.length;j++){
  110. // if(stocklist[i].patient_id == outStockList[j].patient_id &&stocklist[i].drug_name == outStockList[j].drug_name && stocklist[i].drug_spec == outStockList[j].drug_spec){
  111. // stocklist[i].Count = outStockList[j].Count
  112. // }
  113. // }
  114. // }
  115. for(let i=0;i<outStockList.length;i++){
  116. for(let j=0;j<stocklist.length;j++){
  117. if(outStockList[i].patient_id == stocklist[j].patient_id &&outStockList[i].drug_name == stocklist[j].drug_name && outStockList[i].drug_spec == stocklist[j].drug_spec){
  118. outStockList[i].Total = stocklist[j].Total
  119. }
  120. }
  121. }
  122. console.log("stocklist99999",outStockList)
  123. this.tableData = outStockList
  124. }
  125. })
  126. }
  127. },
  128. created(){
  129. var starttime = this.$route.query.start_time
  130. this.start_time = starttime
  131. var endtime = this.$route.query.end_time
  132. this.end_time = endtime
  133. var drugname = this.$route.query.drug_name
  134. this.drug_name = drugname
  135. var drug_spec = this.$route.query.drug_spec
  136. this.drug_spec = drug_spec
  137. var keyword = this.$route.query.keyword
  138. this.keyword = keyword
  139. this.getlist()
  140. }
  141. }
  142. </script>
  143. <style rel="stylesheet/scss" lang="scss" scoped>
  144. .print_main_content {
  145. background-color: white;
  146. max-width: 1500px;
  147. margin: 0 auto;
  148. padding: 0 0 20px 0;
  149. .order_title_panl {
  150. text-align: center;
  151. .main_title {
  152. font-size: 18px;
  153. line-height: 40px;
  154. font-weight: 500;
  155. }
  156. }
  157. .table_panel {
  158. .table {
  159. width: 100%;
  160. border: 1px solid;
  161. border-collapse: collapse;
  162. padding: 2px;
  163. thead {
  164. tr {
  165. td {
  166. border: 1px solid;
  167. text-align: center;
  168. font-size: 18px;
  169. padding: 15px 5px;
  170. }
  171. }
  172. }
  173. tbody {
  174. tr {
  175. td {
  176. border: 1px solid;
  177. text-align: center;
  178. font-size: 18px;
  179. padding: 10px 5px;
  180. white-space: pre-line;
  181. .proj {
  182. padding: 5px 0;
  183. text-align: left;
  184. .proj_title {
  185. font-size: 16px;
  186. font-weight: 500;
  187. line-height: 25px;
  188. }
  189. .proj_item {
  190. font-size: 15px;
  191. line-height: 20px;
  192. .zone_name {
  193. font-weight: 500;
  194. }
  195. }
  196. }
  197. }
  198. }
  199. }
  200. }
  201. }
  202. }
  203. </style>