stockPrint.vue 10KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318
  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="80">耗材类型</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. </tr>
  33. </thead>
  34. <tbody>
  35. <tr v-for='(item,index) in tableList' :key="index">
  36. <td>{{getGoodType(item.good_type_id)}}</td>
  37. <td>{{item.good_name }}</td>
  38. <td><span>{{item.specification_name }} / {{item.packing_unit}}</span></td>
  39. <td>{{item.price}}</td>
  40. <td>{{getManufacture(item.manufacturer)}}</td>
  41. <td>{{getInCount(item.good_id)}}</td>
  42. <td><span>{{getOutCount(item.good_id) + getAutoCount(item.good_id)}}</span></td>
  43. <td>{{getInCount(item.good_id)- getOutCount(item.good_id) - getAutoCount(item.good_id)}}</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 { getAllStockList,GetAllGoodType,getStockDrugCount } from "@/api/stock";
  56. import print from 'print-js'
  57. const moment = require('moment')
  58. export default {
  59. components:{
  60. BreadCrumb
  61. },
  62. data(){
  63. return{
  64. crumbs: [
  65. { path: false, name: '库存管理' },
  66. { path: false, name: '库存查询' },
  67. { path: false, name: '库存查询打印' },
  68. ],
  69. start_time:"",
  70. end_time:"",
  71. drug_name:"",
  72. drug_spec:"",
  73. keyword:"",
  74. tableData:[],
  75. time_now:moment(new Date()).add('year',0).format("YYYY-MM-DD"),
  76. type_name:"",
  77. limit:"",
  78. page:"",
  79. WarehouseInfo: {
  80. loading: false,
  81. warehouseInfoDate: [],
  82. },
  83. tableList:[],
  84. goodType:[],
  85. manufacturerList:[],
  86. countList:[],
  87. outCountList:[],
  88. autoCountList:[],
  89. }
  90. },
  91. methods:{
  92. printAction: function() {
  93. 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; } }'
  94. printJS({
  95. printable: 'print_content',
  96. type: 'html',
  97. documentTitle: ' ',
  98. style: style,
  99. scanStyles: false
  100. })
  101. },
  102. getlist(){
  103. const params = {
  104. page: this.page,
  105. limit: this.limit,
  106. keywords: this.keywords,
  107. start_time:this.start_time,
  108. end_time:this.end_time,
  109. type:this.type_name,
  110. }
  111. getAllStockList(params).then(response=>{
  112. if(response.data.state == 1){
  113. var list = response.data.data.list
  114. console.log("list22222",list)
  115. this.tableList = list
  116. var total = response.data.data.total
  117. console.log("total",total)
  118. this.total = total
  119. var manufacturerList = response.data.data.manufacturerList
  120. this.manufacturerList = manufacturerList
  121. }
  122. })
  123. },
  124. GetAllGoodType() {
  125. GetAllGoodType().then(response => {
  126. if (response.data.state == 0) {
  127. this.$message.error(response.data.msg);
  128. return false;
  129. } else {
  130. for (let i = 0; i < response.data.data.goodType.length; i++) {
  131. this.goodType.push(response.data.data.goodType[i]);
  132. }
  133. }
  134. });
  135. },
  136. stockInCount: function(row) {
  137. let total = 0;
  138. for (let i = 0; i < row.query_warehousing_info.length; i++) {
  139. total = total + row.query_warehousing_info[i].warehousing_count;
  140. }
  141. return total;
  142. },
  143. salesReturnCount: function(row) {
  144. let total = 0;
  145. for (let i = 0; i < row.query_sales_return_info.length; i++) {
  146. total = total + row.query_sales_return_info[i].count;
  147. }
  148. return total;
  149. },
  150. stockOutCount: function(row) {
  151. let total = 0;
  152. for (let i = 0; i < row.query_warehouseout_info.length; i++) {
  153. total = total + row.query_warehouseout_info[i].count;
  154. }
  155. return total;
  156. },
  157. cancelStockCount: function(row) {
  158. let total = 0;
  159. for (let i = 0; i < row.query_cancel_stock_info.length; i++) {
  160. total = total + row.query_cancel_stock_info[i].count;
  161. }
  162. return total;
  163. },
  164. getGoodType(id){
  165. var name = ""
  166. for(let i=0;i<this.goodType.length;i++){
  167. if(id == this.goodType[i].id){
  168. name = this.goodType[i].type_name
  169. }
  170. }
  171. return name
  172. },
  173. getManufacture(id){
  174. var name = ""
  175. for(let i=0;i<this.manufacturerList.length;i++){
  176. if(id == this.manufacturerList[i].id){
  177. name = this.manufacturerList[i].manufacturer_name
  178. }
  179. }
  180. return name
  181. },
  182. getStockDrugCount(){
  183. var params ={
  184. keywords: this.keywords,
  185. start_time:this.start_time,
  186. end_time:this.end_time,
  187. }
  188. getStockDrugCount(params).then(response=>{
  189. if(response.data.state == 1){
  190. var count = response.data.data.count
  191. console.log("入库统计",count)
  192. this.countList = count
  193. var outlist = response.data.data.outList
  194. console.log("出库数量",outlist)
  195. this.outCountList = outlist
  196. var autoCount = response.data.data.autoCount
  197. console.log("autoCount",autoCount)
  198. this.autoCountList = autoCount
  199. }
  200. })
  201. },
  202. getInCount(id){
  203. var count= ""
  204. for(let i=0;i<this.countList.length;i++){
  205. if(id == this.countList[i].good_id){
  206. count = this.countList[i].count
  207. }
  208. }
  209. return count
  210. },
  211. getOutCount(id){
  212. var count = ""
  213. for(let i=0;i<this.outCountList.length;i++){
  214. if(id == this.outCountList[i].good_id){
  215. count = this.outCountList[i].count
  216. }
  217. }
  218. return count
  219. },
  220. getAutoCount(id){
  221. var count= ""
  222. for(let i=0;i<this.autoCountList.length;i++){
  223. if(id == this.autoCountList[i].good_id){
  224. count = this.autoCountList[i].count
  225. }
  226. }
  227. return count
  228. }
  229. },
  230. created(){
  231. var starttime = this.$route.query.start_time
  232. this.start_time = starttime
  233. var endtime = this.$route.query.end_time
  234. this.end_time = endtime
  235. var type_name = this.$route.query.type_name
  236. this.type_name = type_name
  237. var keyword = this.$route.query.keyword
  238. this.keyword = keyword
  239. this.page = this.$route.query.page
  240. this.limit = this.$route.query.limit
  241. this.getlist()
  242. this.GetAllGoodType()
  243. this.getStockDrugCount()
  244. }
  245. }
  246. </script>
  247. <style rel="stylesheet/scss" lang="scss" scoped>
  248. .print_main_content {
  249. background-color: white;
  250. max-width: 1500px;
  251. margin: 0 auto;
  252. padding: 0 0 20px 0;
  253. .order_title_panl {
  254. text-align: center;
  255. .main_title {
  256. font-size: 18px;
  257. line-height: 40px;
  258. font-weight: 500;
  259. }
  260. }
  261. .table_panel {
  262. .table {
  263. width: 100%;
  264. border: 1px solid;
  265. border-collapse: collapse;
  266. padding: 2px;
  267. thead {
  268. tr {
  269. td {
  270. border: 1px solid;
  271. text-align: center;
  272. font-size: 18px;
  273. padding: 15px 5px;
  274. }
  275. }
  276. }
  277. tbody {
  278. tr {
  279. td {
  280. border: 1px solid;
  281. text-align: center;
  282. font-size: 18px;
  283. padding: 10px 5px;
  284. white-space: pre-line;
  285. .proj {
  286. padding: 5px 0;
  287. text-align: left;
  288. .proj_title {
  289. font-size: 16px;
  290. font-weight: 500;
  291. line-height: 25px;
  292. }
  293. .proj_item {
  294. font-size: 15px;
  295. line-height: 20px;
  296. .zone_name {
  297. font-weight: 500;
  298. }
  299. }
  300. }
  301. }
  302. }
  303. }
  304. }
  305. }
  306. }
  307. </style>