printAbc.vue 2.4 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697
  1. <template>
  2. <view class="replenishment-manualPrint-wrap">
  3. <view class="replenishment-manualPrint-footer">
  4. <view>
  5. <kk-printer @closeConnect="closeConnect" ref="kkprinter" defaultText="开始打印" @startPrint="startPrint"></kk-printer>
  6. </view>
  7. </view>
  8. </view>
  9. </template>
  10. <script>
  11. import kkPrinter from '@/components/kk-printer/index.vue';
  12. import {printText} from '@/libs/printTools.js'
  13. export default {
  14. components: { kkPrinter },
  15. data() {
  16. return {
  17. printIndex: 0,
  18. }
  19. },
  20. onReady() {
  21. uni.setNavigationBarColor({
  22. frontColor: '#ffffff',
  23. backgroundColor: this.$config('primaryColor')
  24. })
  25. },
  26. methods: {
  27. printOnce(opt,tsc,blesdk,data){
  28. const _this = this
  29. // 60*40 打印模板
  30. const command = printText(tsc,data)
  31. // 开始批量打印
  32. blesdk.senBlData(
  33. opt.deviceId,
  34. opt.serviceId,
  35. opt.writeId,
  36. command.getData(),
  37. function(){
  38. const result ='A、B、C、D、E、F、G、H、I、J、K、L、M、N、O、P、Q、R、S、T、U、V、W、X、Y、Z'.split('、')
  39. _this.printIndex = _this.printIndex + 1
  40. if(_this.printIndex < result.length){
  41. _this.printOnce(opt,tsc,blesdk,result[_this.printIndex])
  42. }else{
  43. _this.printIndex = 0
  44. _this.$refs.kkprinter.onPrintSuccess()
  45. _this.isParinting = false
  46. }
  47. });
  48. },
  49. // 批量打印
  50. startPrint(opt,tsc,blesdk){
  51. const result = 'A、B、C、D、E、F、G、H、I、J、K、L、M、N、O、P、Q、R、S、T、U、V、W、X、Y、Z'.split('、')
  52. if(result.length){
  53. if(this.isParinting){
  54. return
  55. }
  56. this.isParinting = true
  57. this.printOnce(opt,tsc,blesdk,result[this.printIndex])
  58. }else{
  59. this.toashMsg("请选择产品!")
  60. this.$refs.kkprinter.onPrintFail()
  61. }
  62. },
  63. }
  64. }
  65. </script>
  66. <style lang="less">
  67. .replenishment-manualPrint-wrap{
  68. position: relative;
  69. width: 100%;
  70. height: 100%;
  71. overflow: hidden;
  72. padding-bottom: 102upx;
  73. .replenishment-manualPrint-body{
  74. > view{
  75. padding: 10rpx 25rpx;
  76. background-color: #fff;
  77. margin-bottom: 20rpx;
  78. border-radius: 25rpx;
  79. box-shadow: 2rpx 3rpx 5rpx #eee;
  80. }
  81. }
  82. .replenishment-manualPrint-footer{
  83. padding: 10upx 32upx 12upx;
  84. background-color: #fff;
  85. position: fixed;
  86. left: 0;
  87. bottom: 0;
  88. width: 100%;
  89. box-shadow: 3px 1px 7px #eee;
  90. display: flex;
  91. align-items: center;
  92. justify-content: space-between;
  93. }
  94. }
  95. </style>