receiptsOut.vue 2.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125
  1. <template>
  2. <view>
  3. <u-navbar
  4. title="出场小票详情"
  5. title-color="#fff"
  6. :custom-back="customBack"
  7. :border-bottom="false"
  8. back-icon-color="#CCE8FF"
  9. :background="{background: 'linear-gradient(145deg, #41AFF9 0%, #2D8CFB 100%)' }"></u-navbar>
  10. <view class="receipts">
  11. <view class="receipts-list" v-for="(item,index) in itemList">
  12. <view v-if="item.itemType==1">{{item.itemContent}}</view>
  13. <view v-if="item.itemType==2">
  14. <tki-qrcode
  15. ref="qrcode"
  16. cid="tki-qrcode-canvas"
  17. :val="content"
  18. :size="200"
  19. unit="px"
  20. background="#000000"
  21. foreground="#ffffff"
  22. pdground="#ffffff"
  23. :iconSize="40"
  24. :onval="Onval"
  25. :loadMake="false"
  26. :usingComponents="true"
  27. :showLoading="false"
  28. loadingText="loadingText"
  29. />
  30. </view>
  31. </view>
  32. </view>
  33. <view class="footer">
  34. <u-button class="btn" @click="print" type="primary">打印小票</u-button>
  35. </view>
  36. <u-toast ref="uToast" />
  37. </view>
  38. </template>
  39. <script>
  40. import tkiQrcode from "tki-qrcode";
  41. //#ifdef APP-PLUS
  42. let device = uni.requireNativePlugin("DeviceInfo");
  43. //#endif
  44. export default{
  45. components: {
  46. tkiQrcode
  47. },
  48. data(){
  49. return {
  50. Onval:false,
  51. content:'',
  52. itemList:[],
  53. orederId:'',
  54. list:[]
  55. }
  56. },
  57. onLoad(page){
  58. console.log(page)
  59. this.orderId=page.orderId;
  60. this.getContentList();
  61. },
  62. methods:{
  63. getContentList(){
  64. this.$u.api.printLeave({orderId:this.orderId})
  65. .then(res=>{
  66. this.list = [];
  67. let content = ''
  68. res.data.itemList.forEach(item=>{
  69. const obj={
  70. itemType:item.itemType,
  71. }
  72. this.list.push(obj);
  73. console.log(obj)
  74. if (item.itemType == 2) {
  75. content = item.itemContent
  76. }
  77. })
  78. console.log('list',this.list)
  79. this.itemList = res.data.itemList;
  80. setTimeout(() => {
  81. this.Onval = true;
  82. this.content = content
  83. }, 300);
  84. console.log(res)
  85. }).catch(err=>{
  86. if(err.errMsg){
  87. this.$refs.uToast.show({
  88. title: '请检查网络',
  89. type: 'error',
  90. });
  91. return false;
  92. };
  93. this.$refs.uToast.show({
  94. title: err.msg,
  95. type: 'error',
  96. });
  97. });
  98. },
  99. customBack(){
  100. uni.navigateBack({
  101. delta: 1
  102. });
  103. },
  104. print(){
  105. this.$u.api.printLeave({orderId:this.orderId})
  106. .then(res => {
  107. if(res.code == 200){
  108. //#ifdef APP-PLUS
  109. device.print(res.data);
  110. //#endif
  111. plus.nativeUI.toast('打印成功');
  112. }
  113. })
  114. .catch(err=>{
  115. plus.nativeUI.toast('打印失败');
  116. });
  117. }
  118. }
  119. }
  120. </script>
  121. <style lang="scss">
  122. @import "./receiptsIn.scss";
  123. </style>