printContainer.vue 2.8 KB

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