printContainer.vue 2.4 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980
  1. <script>
  2. import Print_tag_80_50 from '@/components/print/tag_80_50.vue';
  3. import Print_recipe_a5 from '@/components/print/recipe_A5.vue';
  4. import Print_ticket_72 from '@/components/print/ticket_72.vue';
  5. import Print_express_75 from '@/components/print/express_75.vue';
  6. import {updatePrintStatus} from '@/api/prescription/prescriptionCore';
  7. export default {
  8. name: 'printContainer',
  9. props: {
  10. id: {type: [String, Number], required: true},
  11. loadExpress: {type: Boolean, default: false},
  12. },
  13. components: {Print_express_75, Print_ticket_72, Print_recipe_a5, Print_tag_80_50},
  14. data() {
  15. return {};
  16. },
  17. computed: {
  18. height() { return `${window.innerHeight * 0.8}`; },
  19. style() { return {height: `${this.height}px`}; },
  20. },
  21. watch: {},
  22. methods: {
  23. async print() {
  24. const keys = Object.keys(this.$refs).filter(key => key.startsWith('print'));
  25. try {
  26. for (const key of keys) {
  27. const el = this.$refs[key];
  28. await el['print']();
  29. }
  30. this.$message.success(`组合打印成功`);
  31. } catch (e) {
  32. this.$message.error(`出错了,请重试`);
  33. }
  34. },
  35. update(type) {
  36. if (type === 0 || type === 1) {
  37. updatePrintStatus({
  38. isPrint: '1',
  39. id: this.id,
  40. });
  41. }
  42. },
  43. select(index) {
  44. try {
  45. const el = this.$refs[`print${index}`];
  46. el['print'](true);
  47. } catch (e) {}
  48. }
  49. },
  50. };
  51. </script>
  52. <template>
  53. <div>
  54. <el-button class="pin" type="primary" @click="print">组合打印</el-button>
  55. <el-tabs tab-position="left" :style="style" @tab-click="select($event.index)">
  56. <el-tab-pane label="标签">
  57. <print_tag_80_50 ref="print0" :id="id" @click="$event && update(0)"></print_tag_80_50>
  58. </el-tab-pane>
  59. <el-tab-pane label="处方笺">
  60. <print_recipe_a5 ref="print1" :id="id" :style="style" @click="$event && update(1)"></print_recipe_a5>
  61. </el-tab-pane>
  62. <el-tab-pane label="药品清单">
  63. <print_ticket_72 ref="print2" :id="id" :style="style" @click="$event && update(2)"></print_ticket_72>
  64. </el-tab-pane>
  65. <el-tab-pane v-if="loadExpress" label="顺丰面单">
  66. <print_express_75 ref="print3" :id="id" :style="style" @click="$event && update()"></print_express_75>
  67. </el-tab-pane>
  68. </el-tabs>
  69. </div>
  70. </template>
  71. <style scoped lang="scss">
  72. .pin {
  73. position: absolute;
  74. top: 12px;
  75. right: 60px;
  76. }
  77. </style>