stockPrint.vue 8.8KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251
  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. <td width="80">实际入库</td>
  32. <td width="80">出库数量</td>
  33. <td width="80">出库退库</td>
  34. <td width="80">实际出库</td>
  35. <td width="80">剩余库存</td>
  36. </tr>
  37. </thead>
  38. <tbody>
  39. <tr v-for='(item,index) in WarehouseInfo.warehouseInfoDate' :key="index">
  40. <td>{{item.good_code}}</td>
  41. <td>{{item.good_name}}</td>
  42. <td>{{item.type.type_name}}</td>
  43. <td>{{item.specification_name}}</td>
  44. <td>{{stockInCount(item)}}</td>
  45. <td>{{item.price}}</td>
  46. <td>{{salesReturnCount(item)}}</td>
  47. <td> {{ stockInCount(item) - salesReturnCount(item) }}</td>
  48. <td>{{ stockOutCount(item) }}</td>
  49. <td>{{cancelStockCount(item) }}</td>
  50. <td>{{ stockOutCount(item) - cancelStockCount(item)}}</td>
  51. <td>{{stockInCount(item) -salesReturnCount(item) -stockOutCount(item) +cancelStockCount(item)}}</td>
  52. </tr>
  53. </tbody>
  54. </table>
  55. </div>
  56. </div>
  57. </div>
  58. </div>
  59. </div>
  60. </template>
  61. <script>
  62. import BreadCrumb from '@/xt_pages/components/bread-crumb'
  63. import { getAllStockQueryList } from "@/api/stock";
  64. import print from 'print-js'
  65. const moment = require('moment')
  66. export default {
  67. components:{
  68. BreadCrumb
  69. },
  70. data(){
  71. return{
  72. crumbs: [
  73. { path: false, name: '库存管理' },
  74. { path: false, name: '自备药查询' },
  75. { path: false, name: '自备药打印' },
  76. ],
  77. start_time:"",
  78. end_time:"",
  79. drug_name:"",
  80. drug_spec:"",
  81. keyword:"",
  82. tableData:[],
  83. time_now:moment(new Date()).add('year',0).format("YYYY-MM-DD"),
  84. type_name:"",
  85. limit:20,
  86. page:1,
  87. WarehouseInfo: {
  88. loading: false,
  89. warehouseInfoDate: []
  90. },
  91. }
  92. },
  93. methods:{
  94. printAction: function() {
  95. 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; } }'
  96. printJS({
  97. printable: 'print_content',
  98. type: 'html',
  99. documentTitle: ' ',
  100. style: style,
  101. scanStyles: false
  102. })
  103. },
  104. getlist(){
  105. const Params = {
  106. page: this.page,
  107. limit: this.limit,
  108. keyword: this.keywords,
  109. start_time:this.start_time,
  110. end_time:this.end_time,
  111. type_name:this.type_name,
  112. };
  113. this.WarehouseInfo.loading = true;
  114. this.WarehouseInfo.warehouseInfoDate = [];
  115. getAllStockQueryList(Params).then(response => {
  116. if (response.data.state == 0) {
  117. this.WarehouseInfo.loading = false;
  118. this.$message.error(response.data.msg);
  119. return false;
  120. } else {
  121. this.WarehouseInfo.loading = false;
  122. this.total = response.data.data.total;
  123. for (let i = 0; i < response.data.data.list.length; i++) {
  124. this.WarehouseInfo.warehouseInfoDate.push( response.data.data.list[i]);
  125. }
  126. for(let i=0;i<this.WarehouseInfo.warehouseInfoDate.length;i++){
  127. if(this.WarehouseInfo.warehouseInfoDate[i].query_warehousing_info.length>0){
  128. this.WarehouseInfo.warehouseInfoDate[i].price = this.WarehouseInfo.warehouseInfoDate[i].query_warehousing_info[0].price
  129. }else{
  130. this.WarehouseInfo.warehouseInfoDate[i].price = ""
  131. }
  132. }
  133. }
  134. console.log("打印数据源头",this.WarehouseInfo.warehouseInfoDate)
  135. });
  136. },
  137. stockInCount: function(row) {
  138. let total = 0;
  139. for (let i = 0; i < row.query_warehousing_info.length; i++) {
  140. total = total + row.query_warehousing_info[i].warehousing_count;
  141. }
  142. return total;
  143. },
  144. salesReturnCount: function(row) {
  145. let total = 0;
  146. for (let i = 0; i < row.query_sales_return_info.length; i++) {
  147. total = total + row.query_sales_return_info[i].count;
  148. }
  149. return total;
  150. },
  151. stockOutCount: function(row) {
  152. let total = 0;
  153. for (let i = 0; i < row.query_warehouseout_info.length; i++) {
  154. total = total + row.query_warehouseout_info[i].count;
  155. }
  156. return total;
  157. },
  158. cancelStockCount: function(row) {
  159. let total = 0;
  160. for (let i = 0; i < row.query_cancel_stock_info.length; i++) {
  161. total = total + row.query_cancel_stock_info[i].count;
  162. }
  163. return total;
  164. },
  165. },
  166. created(){
  167. var starttime = this.$route.query.start_time
  168. this.start_time = starttime
  169. var endtime = this.$route.query.end_time
  170. this.end_time = endtime
  171. var type_name = this.$route.query.type_name
  172. this.type_name = type_name
  173. var keyword = this.$route.query.keyword
  174. this.keyword = keyword
  175. this.getlist()
  176. }
  177. }
  178. </script>
  179. <style rel="stylesheet/scss" lang="scss" scoped>
  180. .print_main_content {
  181. background-color: white;
  182. max-width: 1500px;
  183. margin: 0 auto;
  184. padding: 0 0 20px 0;
  185. .order_title_panl {
  186. text-align: center;
  187. .main_title {
  188. font-size: 18px;
  189. line-height: 40px;
  190. font-weight: 500;
  191. }
  192. }
  193. .table_panel {
  194. .table {
  195. width: 100%;
  196. border: 1px solid;
  197. border-collapse: collapse;
  198. padding: 2px;
  199. thead {
  200. tr {
  201. td {
  202. border: 1px solid;
  203. text-align: center;
  204. font-size: 18px;
  205. padding: 15px 5px;
  206. }
  207. }
  208. }
  209. tbody {
  210. tr {
  211. td {
  212. border: 1px solid;
  213. text-align: center;
  214. font-size: 18px;
  215. padding: 10px 5px;
  216. white-space: pre-line;
  217. .proj {
  218. padding: 5px 0;
  219. text-align: left;
  220. .proj_title {
  221. font-size: 16px;
  222. font-weight: 500;
  223. line-height: 25px;
  224. }
  225. .proj_item {
  226. font-size: 15px;
  227. line-height: 20px;
  228. .zone_name {
  229. font-weight: 500;
  230. }
  231. }
  232. }
  233. }
  234. }
  235. }
  236. }
  237. }
  238. }
  239. </style>