12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697 |
- <template>
- <view class="replenishment-manualPrint-wrap">
- <view class="replenishment-manualPrint-footer">
- <view>
- <kk-printer @closeConnect="closeConnect" ref="kkprinter" defaultText="开始打印" @startPrint="startPrint"></kk-printer>
- </view>
- </view>
- </view>
- </template>
- <script>
- import kkPrinter from '@/components/kk-printer/index.vue';
- import {printText} from '@/libs/printTools.js'
- export default {
- components: { kkPrinter },
- data() {
- return {
- printIndex: 0,
- }
- },
- onReady() {
- uni.setNavigationBarColor({
- frontColor: '#ffffff',
- backgroundColor: this.$config('primaryColor')
- })
- },
- methods: {
- printOnce(opt,tsc,blesdk,data){
- const _this = this
- // 60*40 打印模板
- const command = printText(tsc,data)
- // 开始批量打印
- blesdk.senBlData(
- opt.deviceId,
- opt.serviceId,
- opt.writeId,
- command.getData(),
- function(){
- 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('、')
- _this.printIndex = _this.printIndex + 1
- if(_this.printIndex < result.length){
- _this.printOnce(opt,tsc,blesdk,result[_this.printIndex])
- }else{
- _this.printIndex = 0
- _this.$refs.kkprinter.onPrintSuccess()
- _this.isParinting = false
- }
- });
- },
- // 批量打印
- startPrint(opt,tsc,blesdk){
- 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('、')
- if(result.length){
- if(this.isParinting){
- return
- }
- this.isParinting = true
- this.printOnce(opt,tsc,blesdk,result[this.printIndex])
- }else{
- this.toashMsg("请选择产品!")
- this.$refs.kkprinter.onPrintFail()
- }
- },
- }
- }
- </script>
- <style lang="less">
- .replenishment-manualPrint-wrap{
- position: relative;
- width: 100%;
- height: 100%;
- overflow: hidden;
- padding-bottom: 102upx;
- .replenishment-manualPrint-body{
- > view{
- padding: 10rpx 25rpx;
- background-color: #fff;
- margin-bottom: 20rpx;
- border-radius: 25rpx;
- box-shadow: 2rpx 3rpx 5rpx #eee;
- }
- }
- .replenishment-manualPrint-footer{
- padding: 10upx 32upx 12upx;
- background-color: #fff;
- position: fixed;
- left: 0;
- bottom: 0;
- width: 100%;
- box-shadow: 3px 1px 7px #eee;
- display: flex;
- align-items: center;
- justify-content: space-between;
- }
- }
- </style>
|