print.vue 19KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583
  1. <template>
  2. <div class="main-contain">
  3. <div class="position">
  4. <bread-crumb :crumbs='crumbs'></bread-crumb>
  5. <el-button :loading="loading" size="small" icon="el-icon-printer" @click="printThisPage" type="primary">打印
  6. </el-button>
  7. </div>
  8. <div class="app-container ">
  9. <div id="dialysis-print-box">
  10. <div class="dialysis-print-order">
  11. <div class="order-yy-name">{{orgname}}</div>
  12. <div class="order-title" v-if="type == 1">入库单</div>
  13. <div class="order-title" v-if="type == 2">退货单</div>
  14. <div class="order-title" v-if="type == 3">出库单</div>
  15. <div class="order-title" v-if="type == 4">退库单</div>
  16. <div style="float: left;margin-bottom: 10px;">{{getDateOne()}}</div>
  17. <div style="float: right;margin-bottom: 10px;">{{getDateTwo()}}</div>
  18. <table class="print-table" border="1">
  19. <tbody>
  20. <tr>
  21. <td style="line-height: 50px" width="50">序号</td>
  22. <td style="line-height: 50px" width="250">耗材名称</td>
  23. <td style="line-height: 50px" width="250">规格型号</td>
  24. <td style="line-height: 50px" width="50">单位</td>
  25. <td style="line-height: 50px" width="80">数量</td>
  26. <td style="line-height:50px" width="80" v-if="type == 1">进货价</td>
  27. <td style="line-height:50px" width="80" v-if="type == 3">出货价</td>
  28. <td style="line-height: 50px" width="80" v-if="type == 1 || type == 3">总价</td>
  29. <td style="line-height: 50px" width="">备 注</td>
  30. </tr>
  31. <tr v-for="(stock,index) in stockDatas" :key="stock.id">
  32. <td style="line-height: 50px">&nbsp;
  33. {{index+1}}
  34. </td>
  35. <td style="line-height: 50px">
  36. <span>{{stock.good_name}}</span>
  37. </td>
  38. <td style="line-height: 50px">
  39. <span v-if="stock">{{stock.specification_name}}</span>
  40. </td>
  41. <td style="line-height: 50px">
  42. <span>{{stock.packing_unit}}</span>
  43. </td>
  44. <td style="line-height: 50px">
  45. <span v-if="type == 3">
  46. <span v-if="org_id == 10090">{{getWareOut(stock.id)}}</span>
  47. <span else>{{getStockCount(stock.id)}}</span>
  48. </span>
  49. <span v-else>{{calCount(stock)}}</span>
  50. </td>
  51. <td style="line-height:50px" v-if="type == 1 && stock.query_warehousing_info.length > 0">{{stock.query_warehousing_info[0].price}}</td>
  52. <td style="line-height:50px" v-if="type == 3 && stock.query_warehouseout_info.length > 0">
  53. <!-- {{stock.query_warehouseout_info[0].price}} -->
  54. {{getReailPrice(stock.id)}}
  55. </td>
  56. <td style="line-height: 50px" v-if="type == 1">{{calTotal(stock)}}</td>
  57. <td style="line-height: 50px" v-if="type == 3">
  58. <span v-if="org_id == 10090">{{getPrice(stock.id)}}</span>
  59. <span v-else>{{(getStockCount(stock.id) * getReailPrice(stock.id)).toFixed(2)}}</span>
  60. </td>
  61. <td style="line-height: 50px"></td>
  62. </tr>
  63. </tbody>
  64. </table>
  65. <table class="print-table" border="1" v-if="type == 1 || type == 3">
  66. <tbody>
  67. <tr>
  68. <td width="633" style="line-height: 50px">合计</td>
  69. <td width="80" style="line-height: 50px">
  70. <span v-if="type == 1">{{calTotalPrice()}}</span>
  71. <span v-if="type == 3 && org_id!=10090">{{getTotalPrice().toFixed(2)}}</span>
  72. <span v-if="type == 3 && org_id==10090">{{getTotalPriceOne().toFixed(2)}}</span>
  73. </td>
  74. <td></td>
  75. </tr>
  76. </tbody>
  77. </table>
  78. <div style="display:flex;margin-top:20px;float:right;">
  79. <div style="width:50px;">审批:</div><div style="width:100px;"></div>
  80. <div style="width:80px;">药材主任:</div><div style="width:100px;"></div>
  81. <div style="width:50px;">会计:</div><div style="width:100px;"></div>
  82. <div style="width:50px;">审核:</div><div style="width:100px;"></div>
  83. <div style="width:70px;">制单人:</div><div style="width:100px;"></div>
  84. </div>
  85. </div>
  86. </div>
  87. </div>
  88. </div>
  89. </template>
  90. <script>
  91. import { getPrintStockGood } from '@/api/stock'
  92. import { getDataConfig } from '@/utils/data'
  93. import { jsGetAge, uParseTime } from '@/utils/tools'
  94. import BreadCrumb from '@/xt_pages/components/bread-crumb'
  95. import print from 'print-js'
  96. export default {
  97. name: 'dialysisPrintOrder',
  98. components: {
  99. BreadCrumb
  100. },
  101. data() {
  102. return {
  103. crumbs: [
  104. { path: false, name: '出入库明细' },
  105. { path: false, name: '打印单' }
  106. ],
  107. loading: false,
  108. orgname: '',
  109. queryParams: {
  110. start_time: this.$route.query.start_time,
  111. end_time: this.$route.query.end_time,
  112. type: this.$route.query.type
  113. },
  114. totalPrice: 0,
  115. stockDatas: [],
  116. goodUnit: [],
  117. type: this.$route.query.type,
  118. start_time: this.$route.query.start_time,
  119. end_time: this.$route.query.end_time,
  120. stockTotal:[],
  121. wareOutInfo:[],
  122. org_id:0,
  123. informationList:[]
  124. }
  125. },
  126. methods: {
  127. getDateOne(){
  128. if (this.type == 1){
  129. return "入库日期: "+this.start_time +"~"+this.end_time
  130. }else if(this.type == 2){
  131. return "退货日期: "+this.start_time +"~"+this.end_time
  132. }else if(this.type == 3){
  133. return "出库日期: "+this.start_time +"~"+this.end_time
  134. }else if(this.type == 4){
  135. return "退库日期: "+this.start_time +"~"+this.end_time
  136. }
  137. },
  138. getDateTwo(){
  139. var ptime = Math.round(new Date().getTime() / 1000)
  140. return "印单日期:"+uParseTime(ptime, '{y}-{m}-{d}')
  141. },
  142. getTime(value, temp) {
  143. if (value == 0) {
  144. return ''
  145. }
  146. if (value != undefined) {
  147. return uParseTime(value, temp)
  148. }
  149. return ''
  150. },
  151. printThisPage() {
  152. var ptime = Math.round(new Date().getTime() / 1000)
  153. this.print_time = uParseTime(ptime, '{y}-{m}-{d} {h}:{i}')
  154. const style = '@media print {.dialysis-print-order{width:960px;margin:0 auto}.dialysis-print-order .order-yy-name{margin:auto;text-align:center;font-size:20px;letter-spacing:5px}.dialysis-print-order .order-title{margin:auto;font-weight:600;text-align:center;font-size:22px;padding:10px 20px 20px 20px}.dialysis-print-order .table-box{width:100%;line-height:23px;font-size:14px}.dialysis-print-order .print-table{width:100%;text-align:center;border-collapse:collapse;line-height:25px;font-size:14px}.dialysis-print-order .print-table-no{width:100%;text-align:center;border-collapse:collapse;font-size:14px}.dialysis-print-order .under-line{border-bottom:1px solid #999;width:95%;text-align:center;margin-left:2px}.dialysis-print-order .title-box{text-align:center;font-size:16px;border:1px solid #666}.dialysis-print-order .radio-lebel-box{font-weight:400;cursor:pointer}.dialysis-print-order .radio-no{opacity:0;outline:0;position:absolute;margin:0;width:0;height:0;z-index:-1}.dialysis-print-order .radio-inner{white-space:nowrap;cursor:pointer;outline:0;display:inline-block;line-height:1;position:relative;vertical-align:middle}.dialysis-print-order .radio-fang{display:inline-block;position:relative;border:1px solid #000;box-sizing:border-box;width:14px;height:14px;background-color:#fff;z-index:1;transition:border-color .25s cubic-bezier(.71,-.46,.29,1.46),background-color .25s cubic-bezier(.71,-.46,.29,1.46)}.dialysis-print-order .is-checked-radio::after{content:"√";font-size:15px}}.dialysis-print-order .print-table-no tr td { padding: 8px 5px; line-height: 25px; }.es-img{height: 20px; }.advice-name{text-align: left;}.advice-children{display:flex;} .dialysis-print-order .print-table tr td{padding: 0px 0px;} .print-template-two tr {line-height: 30px;} .title-box-pro{border: 0 #fff;line-height: 40px;height: 40px;text-align: left;padding-left: 10px !important;} .text-align-left{text-align: left !important;padding-left:10px !important;font-size: 14px !important;line-height: 25px;}'
  155. printJS({
  156. printable: 'dialysis-print-box',
  157. type: 'html',
  158. style: style,
  159. scanStyles: false
  160. })
  161. },
  162. getDialysisRecord() {
  163. this.loading = true
  164. getPrintStockGood(this.queryParams).then(response => {
  165. if (response.data.state == 1) {
  166. var stockTotal = response.data.data.stockTotal
  167. this.stockTotal = stockTotal
  168. var info = response.data.data.info
  169. this.wareOutInfo = info
  170. var org_id = response.data.data.orgid
  171. this.org_id = org_id
  172. var informationlist = response.data.data.infomationList
  173. this.informationList = informationlist
  174. this.stockDatas = []
  175. for (let i = 0; i < response.data.data.list.length; i++) {
  176. if (this.type == 1) {
  177. if (response.data.data.list[i].query_warehousing_info.length > 0) {
  178. this.stockDatas.push(response.data.data.list[i])
  179. }
  180. console.log("入库打印数据源",this.stockDatas)
  181. } else if (this.type == 2) {
  182. if (response.data.data.list[i].query_sales_return_info.length > 0) {
  183. this.stockDatas.push(response.data.data.list[i])
  184. }
  185. } else if (this.type == 3) {
  186. if (response.data.data.list[i].query_warehouseout_info.length > 0) {
  187. this.stockDatas.push(response.data.data.list[i])
  188. }
  189. console.log("出库打印数据源",this.stockDatas)
  190. } else if (this.type == 4) {
  191. if (response.data.data.list[i].query_cancel_stock_info.length > 0) {
  192. this.stockDatas.push(response.data.data.list[i])
  193. }
  194. }
  195. }
  196. var obj = null
  197. for(let i = 0; i <this.stockDatas.length;i++){
  198. obj = this.stockDatas[i]
  199. }
  200. console.log("9999999",this.stockDatas)
  201. var newArr = this.unique(this.stockDatas)
  202. console.log("耗材出库去重",newArr)
  203. this.stockDatas = newArr
  204. // if (this.stockDatas.length < 50) {
  205. // var nl = 50 - this.stockDatas.length
  206. // for (let index = 0; index < nl; index++) {
  207. // this.stockDatas.push([])
  208. // }
  209. // }
  210. this.loading = false
  211. } else {
  212. this.loading = false
  213. this.$message.error('请求数据失败')
  214. return false
  215. }
  216. })
  217. },
  218. calCount(stock) {
  219. let total = 0
  220. var array = []
  221. if (this.type == 1) {
  222. array = stock.query_warehousing_info
  223. } else if (this.type == 2) {
  224. array = stock.query_sales_return_info
  225. } else if (this.type == 3) {
  226. array = stock.query_warehouseout_info
  227. } else if (this.type == 4) {
  228. array = stock.query_cancel_stock_info
  229. }
  230. for (let i = 0; i < array.length; i++) {
  231. if (this.type == 1) {
  232. total = total + array[i].warehousing_count
  233. } else if (this.type == 2) {
  234. total = total + array[i].count
  235. } else if (this.type == 3) {
  236. total = total + array[i].count
  237. } else if (this.type == 4) {
  238. total = total + array[i].count
  239. }
  240. }
  241. return total
  242. }, calTotal(stock) {
  243. console.log(stock)
  244. var array = []
  245. if (this.type == 1) {
  246. array = stock.query_warehousing_info
  247. } else if (this.type == 3) {
  248. array = stock.query_warehouseout_info
  249. }
  250. let total_price = 0.0
  251. for (let i = 0; i < array.length; i++) {
  252. if(this.type == 1) {
  253. total_price = total_price + array[i].warehousing_count * array[i].price
  254. }else if(this.type == 3){
  255. total_price = total_price + array[i].count * array[i].price
  256. }
  257. }
  258. return Math.floor(total_price * 100) / 100
  259. },
  260. calTotalPrice() {
  261. var amountPrice = 0
  262. for (let i = 0; i < this.stockDatas.length; i++) {
  263. var obj = this.stockDatas[i]
  264. var len = 0
  265. if (this.type == 1) {
  266. len = obj.query_warehousing_info.length
  267. } else if (this.type == 3) {
  268. len = obj.query_warehouseout_info.length
  269. }
  270. let total_price = 0.0
  271. for (let a = 0; a < len; a++) {
  272. if (this.type == 1) {
  273. total_price = total_price + obj.query_warehousing_info[a].total_price
  274. } else if (this.type == 3) {
  275. total_price = total_price + obj.query_warehouseout_info[a].total_price
  276. }
  277. }
  278. amountPrice = amountPrice + Math.floor(total_price* 100) / 100
  279. }
  280. return Math.floor(amountPrice* 100) / 100
  281. }, getTotal: function(price, total) {
  282. var m = 0, r1, r2
  283. var s1 = price.toString()
  284. var s2 = total.toString()
  285. try {
  286. m += s1.split('.')[1].length
  287. } catch (e) {
  288. }
  289. try {
  290. } catch (e) {
  291. m += s2.split('.')[1].length
  292. }
  293. r1 = Number(price.toString().replace('.', ''))
  294. r2 = Number(total.toString().replace('.', ''))
  295. return r1 * r2 / Math.pow(10, m)
  296. },
  297. getUnit(id){
  298. var name = ""
  299. for(let i=0;i<this.goodUnit.length;i++){
  300. if(this.goodUnit[i].id == id){
  301. name = this.goodUnit[i].name
  302. }
  303. }
  304. return name
  305. },
  306. getStockCount(id){
  307. var count = ""
  308. for(let i=0;i<this.stockTotal.length;i++){
  309. if(id == this.stockTotal[i].good_id){
  310. count = this.stockTotal[i].count
  311. }
  312. }
  313. return count
  314. },
  315. getWareOut(id){
  316. var count = ""
  317. for(let i=0;i<this.wareOutInfo.length;i++){
  318. if(id == this.wareOutInfo[i].good_id){
  319. count = this.wareOutInfo[i].count
  320. }
  321. }
  322. return count
  323. },
  324. getPrice(id){
  325. var sum = ""
  326. for(let i=0;i<this.informationList.length;i++){
  327. for(let j=0;j<this.wareOutInfo.length;j++){
  328. if(this.informationList[i].id == this.wareOutInfo[j].good_id){
  329. this.wareOutInfo[j].buy_price = this.informationList[i].buy_price
  330. }
  331. }
  332. }
  333. for(let j=0;j<this.wareOutInfo.length;j++){
  334. if(id == this.wareOutInfo[j].good_id){
  335. sum += (this.wareOutInfo[j].buy_price * this.wareOutInfo[j].count).toFixed(2)
  336. }
  337. }
  338. return sum
  339. },
  340. getReailPrice(id){
  341. var price = 0
  342. for(let i=0;i<this.informationList.length;i++){
  343. if(id == this.informationList[i].id){
  344. price = this.informationList[i].buy_price
  345. }
  346. }
  347. return price
  348. },
  349. getTotalPrice(){
  350. var total_price = 0
  351. for(let i=0;i<this.stockDatas.length;i++){
  352. total_price += (this.getStockCount(this.stockDatas[i].id) * this.getReailPrice(this.stockDatas[i].id))
  353. }
  354. return total_price
  355. },
  356. getTotalPriceOne(){
  357. var total_price = 0
  358. for(let i=0;i<this.stockDatas.length;i++){
  359. total_price +=(this.getWareOut(this.stockDatas[i].id) * this.getReailPrice(this.stockDatas[i].id))
  360. }
  361. return total_price
  362. },
  363. unique(arr) {
  364. const res = new Map();
  365. return arr.filter((arr) => !res.has(arr.id) && res.set(arr.id, 1));
  366. },
  367. },
  368. created() {
  369. var xtuser = this.$store.getters.xt_user
  370. this.orgname = xtuser.org.org_name
  371. this.goodUnit = this.$store.getters.good_unit
  372. this.getDialysisRecord()
  373. }
  374. }
  375. </script>
  376. <style>
  377. .dialysis-print-order {
  378. width: 960px;
  379. margin: 0 auto
  380. }
  381. .dialysis-print-order .order-yy-name {
  382. margin: auto;
  383. text-align: center;
  384. font-size: 20px;
  385. letter-spacing: 5px;
  386. }
  387. .dialysis-print-order .order-title {
  388. margin: auto;
  389. font-weight: 600;
  390. text-align: center;
  391. font-size: 22px;
  392. padding: 10px 20px 20px 20px;
  393. }
  394. .dialysis-print-order .table-box {
  395. width: 100%;
  396. line-height: 23px;
  397. font-size: 14px;
  398. }
  399. .dialysis-print-order .print-table {
  400. width: 100%;
  401. text-align: center;
  402. border-collapse: collapse;
  403. line-height: 40px;
  404. font-size: 14px;
  405. }
  406. .dialysis-print-order .print-table-no {
  407. width: 100%;
  408. text-align: center;
  409. border-collapse: collapse;
  410. font-size: 14px;
  411. }
  412. .dialysis-print-order .under-line {
  413. border-bottom: 1px solid #999;
  414. width: 95%;
  415. text-align: center;
  416. margin-left: 2px;
  417. }
  418. .dialysis-print-order .title-box {
  419. text-align: center;
  420. font-size: 16px;
  421. }
  422. .dialysis-print-order .radio-lebel-box {
  423. font-weight: 400;
  424. cursor: pointer;
  425. }
  426. .dialysis-print-order .radio-no {
  427. opacity: 0;
  428. outline: none;
  429. position: absolute;
  430. margin: 0;
  431. width: 0;
  432. height: 0;
  433. z-index: -1;
  434. }
  435. .dialysis-print-order .radio-inner {
  436. white-space: nowrap;
  437. cursor: pointer;
  438. outline: none;
  439. display: inline-block;
  440. line-height: 1;
  441. position: relative;
  442. vertical-align: middle;
  443. }
  444. .dialysis-print-order .radio-fang {
  445. display: inline-block;
  446. position: relative;
  447. border: 1px solid #000;
  448. box-sizing: border-box;
  449. width: 14px;
  450. height: 14px;
  451. background-color: #fff;
  452. z-index: 1;
  453. transition: border-color .25s cubic-bezier(.71, -.46, .29, 1.46), background-color .25s cubic-bezier(.71, -.46, .29, 1.46);
  454. }
  455. .dialysis-print-order .is-checked-radio::after {
  456. content: "√";
  457. font-size: 15px;
  458. }
  459. .dialysis-print-order .print-table-no tr td {
  460. padding: 8px 5px;
  461. line-height: 25px;
  462. }
  463. .dialysis-print-order .print-table tr td {
  464. padding: 1px 1px;
  465. /*line-height: 25px;*/
  466. }
  467. .es-img {
  468. height: 25px;
  469. }
  470. .advice-name {
  471. text-align: left;
  472. }
  473. .advice-children {
  474. display: flex;
  475. }
  476. .title-box-pro {
  477. border: 0 #fff;
  478. line-height: 25px;
  479. height: 25px;
  480. text-align: left;
  481. padding-left: 10px !important;
  482. }
  483. .title-box-pro-tr {
  484. border: 0 #fff;
  485. }
  486. .text-align-left {
  487. text-align: left !important;
  488. padding-left: 10px !important;
  489. font-size: 14px !important;
  490. line-height: 25px;
  491. }
  492. .print-table-tr-new td {
  493. line-height: 20px !important;
  494. }
  495. .border-top-solid {
  496. border: solid 1px #000;
  497. }
  498. .print-template-two tr {
  499. line-height: 30px;
  500. }
  501. </style>