selfStockPrint.vue 6.7KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203
  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 width="80">实际入库</td>
  28. <td width="80">出库数量</td>
  29. <td width="80">实际出库</td>
  30. <td width="80">剩余库存</td>
  31. </tr>
  32. </thead>
  33. <tbody>
  34. <tr v-for='(item,index) in tableData' :key="index">
  35. <td>{{item.drug_name}}</td>
  36. <td>{{item.drug_spec}}</td>
  37. <td>{{item.Count}}</td>
  38. <td>{{item.Count}}</td>
  39. <td>{{item.outCount}}</td>
  40. <td>{{item.outCount}}</td>
  41. <td>{{item.total}}</td>
  42. </tr>
  43. </tbody>
  44. </table>
  45. </div>
  46. </div>
  47. </div>
  48. </div>
  49. </div>
  50. </template>
  51. <script>
  52. import BreadCrumb from '@/xt_pages/components/bread-crumb'
  53. import { getSelfStockQuery } from "@/api/drug/drug"
  54. import print from 'print-js'
  55. const moment = require('moment')
  56. export default {
  57. components:{
  58. BreadCrumb
  59. },
  60. data(){
  61. return{
  62. crumbs: [
  63. { path: false, name: '自备药管理' },
  64. { path: false, name: '库存查询' },
  65. { path: false, name: '库存打印' },
  66. ],
  67. start_time:"",
  68. end_time:"",
  69. drug_name:"",
  70. drug_spec:"",
  71. keyword:"",
  72. tableData:[],
  73. time_now:moment(new Date()).add('year',0).format("YYYY-MM-DD"),
  74. type_name:"",
  75. limit:20,
  76. page:1,
  77. }
  78. },
  79. methods:{
  80. printAction: function() {
  81. 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; } }'
  82. printJS({
  83. printable: 'print_content',
  84. type: 'html',
  85. documentTitle: ' ',
  86. style: style,
  87. scanStyles: false
  88. })
  89. },
  90. getlist(){
  91. var params ={
  92. type_name:this.type_name,
  93. start_time:this.start_time,
  94. end_time:this.end_time,
  95. keywords:this.keywords,
  96. page:this.page,
  97. limit:this.limit
  98. }
  99. console.log("params",params)
  100. getSelfStockQuery(params).then(response=>{
  101. if(response.data.state == 1){
  102. var stockQuery = response.data.data.stockQuery
  103. var stockOutQuery = response.data.data.stockOutQuery
  104. for(let i=0;i<stockQuery.length;i++){
  105. for(let j=0;j<stockOutQuery.length;j++){
  106. if(stockQuery[i].drug_name_id == stockOutQuery[j].drug_name_id ){
  107. stockQuery[i].outCount = stockOutQuery[j].Count
  108. stockQuery[i].total = stockQuery[i].Count - stockOutQuery[j].Count
  109. }
  110. }
  111. }
  112. console.log("表格数据",stockQuery)
  113. this.tableData = stockQuery
  114. }
  115. })
  116. },
  117. },
  118. created(){
  119. var starttime = this.$route.query.start_time
  120. this.start_time = starttime
  121. var endtime = this.$route.query.end_time
  122. this.end_time = endtime
  123. var type_name = this.$route.query.type_name
  124. this.type_name = type_name
  125. var keyword = this.$route.query.keyword
  126. this.keyword = keyword
  127. this.getlist()
  128. }
  129. }
  130. </script>
  131. <style rel="stylesheet/scss" lang="scss" scoped>
  132. .print_main_content {
  133. background-color: white;
  134. max-width: 1500px;
  135. margin: 0 auto;
  136. padding: 0 0 20px 0;
  137. .order_title_panl {
  138. text-align: center;
  139. .main_title {
  140. font-size: 18px;
  141. line-height: 40px;
  142. font-weight: 500;
  143. }
  144. }
  145. .table_panel {
  146. .table {
  147. width: 100%;
  148. border: 1px solid;
  149. border-collapse: collapse;
  150. padding: 2px;
  151. thead {
  152. tr {
  153. td {
  154. border: 1px solid;
  155. text-align: center;
  156. font-size: 18px;
  157. padding: 15px 5px;
  158. }
  159. }
  160. }
  161. tbody {
  162. tr {
  163. td {
  164. border: 1px solid;
  165. text-align: center;
  166. font-size: 18px;
  167. padding: 10px 5px;
  168. white-space: pre-line;
  169. .proj {
  170. padding: 5px 0;
  171. text-align: left;
  172. .proj_title {
  173. font-size: 16px;
  174. font-weight: 500;
  175. line-height: 25px;
  176. }
  177. .proj_item {
  178. font-size: 15px;
  179. line-height: 20px;
  180. .zone_name {
  181. font-weight: 500;
  182. }
  183. }
  184. }
  185. }
  186. }
  187. }
  188. }
  189. }
  190. }
  191. </style>