manualPrint.vue 4.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163
  1. <template>
  2. <view class="replenishment-manualPrint-wrap">
  3. <view class="replenishment-manualPrint-body">
  4. <view class="part-list">
  5. <!-- 补货产品 -->
  6. <partList :list="partList" title="补货产品" model="checkbox" fromPage="manualPrint" ref="partList" noDataText="暂无产品" @allChecked="allCheckedCallback"></partList>
  7. </view>
  8. </view>
  9. <view class="replenishment-manualPrint-footer">
  10. <view>
  11. <u-checkbox size="40" @change="allCheckeChange" v-model="allChecked" shape="circle">{{allChecked?'取消全选':'全选'}}</u-checkbox>
  12. </view>
  13. <view>
  14. <kk-printer ref="kkprinter" defaultText="开始打印" @startPrint="startPrint"></kk-printer>
  15. </view>
  16. </view>
  17. </view>
  18. </template>
  19. <script>
  20. import kkPrinter from '@/components/kk-printer/index.vue';
  21. import { shelfReplenishDetail, shelfReplenishDetailList, shelfReplenishPrintSign } from '@/api/shelfReplenish'
  22. import partList from '@/pages/common/partList.vue'
  23. import {printTempl} from '@/libs/printTools.js'
  24. export default {
  25. components: { partList, kkPrinter },
  26. data() {
  27. return {
  28. replenishBillSn: '',
  29. basicInfoData:null,
  30. partList: [],
  31. allChecked: false,
  32. printIndex: 0,
  33. }
  34. },
  35. onReady() {
  36. uni.setNavigationBarColor({
  37. frontColor: '#ffffff',
  38. backgroundColor: this.$config('primaryColor')
  39. })
  40. },
  41. onLoad(option) {
  42. this.replenishBillSn = option.sn
  43. this.getDetail()
  44. this.getPartList()
  45. },
  46. onUnload() {
  47. // this.$refs.kkprinter.closeConnect()
  48. },
  49. methods: {
  50. // 查询详情
  51. getDetail(){
  52. shelfReplenishDetail({ sn: this.replenishBillSn }).then(res => {
  53. if(res.status == 200){
  54. this.basicInfoData = res.data || null
  55. }else{
  56. this.basicInfoData = null
  57. }
  58. })
  59. },
  60. // 查询列表
  61. getPartList(){
  62. const _this = this
  63. shelfReplenishDetailList({ replenishBillSn: this.replenishBillSn }).then(res => {
  64. if(res.status == 200 && res.data){
  65. res.data.map(item =>{
  66. item.confirmQty = item.confirmQty ? Number(item.confirmQty) : 0
  67. item.printQty = item.confirmQty ? Number(item.confirmQty) : 0
  68. })
  69. this.partList = res.data || []
  70. }else{
  71. this.partList = []
  72. }
  73. })
  74. },
  75. // 全选
  76. allCheckeChange(e){
  77. this.$refs.partList.allSelect(e.value)
  78. },
  79. allCheckedCallback(val){
  80. this.allChecked = val
  81. },
  82. printOnce(opt,tsc,blesdk,data){
  83. const _this = this
  84. const dealer = this.$store.state.vuex_userData
  85. // 60*40 打印模板
  86. const command = printTempl(tsc,{
  87. dealerName: dealer.orgName,
  88. shelfName: this.basicInfoData.shelfInfo.shelfName || '',
  89. productCode: data.productCode || '',
  90. productName: data.product.name || '',
  91. shelfPlaceCode: data.shelfPlaceCode || '',
  92. currentInven: data.printQty,
  93. printDate: this.$u.timeFormat(this.timestamp, 'yyyy-mm-dd hh:MM'),
  94. printUser: dealer.userNameCN,
  95. barCode: `dealerSn=${dealer.orgSn}&shelfSn=${data.shelfSn}&productSn=${data.productSn}&productCode=${data.productCode}&shelfPlaceCode=${data.shelfPlaceCode}&shelfPlaceSn=${data.shelfPlaceSn}`
  96. })
  97. // 开始批量打印
  98. blesdk.senBlData(
  99. opt.deviceId,
  100. opt.serviceId,
  101. opt.writeId,
  102. command.getData(),
  103. function(){
  104. const result =_this.$refs.partList.getAllChecked()
  105. _this.printIndex = _this.printIndex + 1
  106. if(_this.printIndex < result.length){
  107. _this.printOnce(opt,tsc,blesdk,result[_this.printIndex])
  108. }else{
  109. _this.printIndex = 0
  110. _this.$refs.kkprinter.onPrintSuccess()
  111. _this.isParinting = false
  112. }
  113. });
  114. },
  115. // 批量打印
  116. startPrint(opt,tsc,blesdk){
  117. const result =this.$refs.partList.getAllChecked()
  118. if(result.length){
  119. if(this.isParinting){
  120. return
  121. }
  122. this.isParinting = true
  123. this.printOnce(opt,tsc,blesdk,result[this.printIndex])
  124. }else{
  125. this.toashMsg("请选择产品!")
  126. this.$refs.kkprinter.onPrintFail()
  127. }
  128. },
  129. }
  130. }
  131. </script>
  132. <style lang="less">
  133. .replenishment-manualPrint-wrap{
  134. position: relative;
  135. width: 100%;
  136. height: 100%;
  137. overflow: hidden;
  138. padding-bottom: 102upx;
  139. .replenishment-manualPrint-body{
  140. > view{
  141. padding: 10rpx 25rpx;
  142. background-color: #fff;
  143. margin-bottom: 20rpx;
  144. border-radius: 25rpx;
  145. box-shadow: 2rpx 3rpx 5rpx #eee;
  146. }
  147. }
  148. .replenishment-manualPrint-footer{
  149. padding: 10upx 32upx 12upx;
  150. background-color: #fff;
  151. position: fixed;
  152. left: 0;
  153. bottom: 0;
  154. width: 100%;
  155. box-shadow: 3px 1px 7px #eee;
  156. display: flex;
  157. align-items: center;
  158. justify-content: space-between;
  159. }
  160. }
  161. </style>