print.vue 20KB

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