|
@@ -0,0 +1,137 @@
|
|
|
|
|
+<script>
|
|
|
|
|
+import CLodop from '@/libs/print/CLodop';
|
|
|
|
|
+import {getPrint} from '@/api/decoct/recipe';
|
|
|
|
|
+import {getDevice} from '@/tools/print.tool';
|
|
|
|
|
+import {template60_40} from '@/components/print/template';
|
|
|
|
|
+
|
|
|
|
|
+export default {
|
|
|
|
|
+ name: 'print_tag_60_40',
|
|
|
|
|
+ props: {
|
|
|
|
|
+ id: {type: [String, Number], required: true},
|
|
|
|
|
+ },
|
|
|
|
|
+ data() {
|
|
|
|
|
+ return {
|
|
|
|
|
+ loaded: false,
|
|
|
|
|
+ preview: false,
|
|
|
|
|
+ total: 1,
|
|
|
|
|
+
|
|
|
|
|
+ tag: `print-preview_${Date.now()}`,
|
|
|
|
|
+ paper: '发药标签',
|
|
|
|
|
+
|
|
|
|
|
+ model: null,
|
|
|
|
|
+ device: null,
|
|
|
|
|
+ printing: false,
|
|
|
|
|
+ };
|
|
|
|
|
+ },
|
|
|
|
|
+ computed: {
|
|
|
|
|
+ loading() {
|
|
|
|
|
+ return !this.loaded || !this.preview;
|
|
|
|
|
+ },
|
|
|
|
|
+ },
|
|
|
|
|
+ mounted() {
|
|
|
|
|
+ this.print(true);
|
|
|
|
|
+ },
|
|
|
|
|
+ methods: {
|
|
|
|
|
+ async print(preview = false) {
|
|
|
|
|
+ const instance = await CLodop();
|
|
|
|
|
+ const model = await this.getModel();
|
|
|
|
|
+
|
|
|
|
|
+ template60_40.call(instance, model, `${this.paper}`);
|
|
|
|
|
+
|
|
|
|
|
+ this.device = await getDevice(`paper:${this.paper}`);
|
|
|
|
|
+ if (this.device) instance['SET_PRINT_PAGESIZE'](1, 0, 0, this.paper);
|
|
|
|
|
+ else {
|
|
|
|
|
+ this.device = await getDevice({width: 60, height: 40}, `name:Gprinter GP-1324D`);
|
|
|
|
|
+ if (this.device) instance['SET_PRINT_PAGESIZE'](1, '60mm', '40mm', 'CreateCustomPage');
|
|
|
|
|
+ }
|
|
|
|
|
+ if (this.device) instance['SET_PRINTER_INDEX'](this.device.index);
|
|
|
|
|
+
|
|
|
|
|
+ instance['SET_PRINT_COPIES'](this.total);
|
|
|
|
|
+
|
|
|
|
|
+ if (preview) {
|
|
|
|
|
+ instance['SET_PREVIEW_WINDOW'](1, 1, 1, 0, 0, `${this.paper}.开始打印`);
|
|
|
|
|
+ instance['SET_SHOW_MODE']('PREVIEW_IN_BROWSE', true);
|
|
|
|
|
+ instance['SET_PRINT_MODE']('AUTO_CLOSE_PREWINDOW', true);
|
|
|
|
|
+ instance['PREVIEW'](this.tag);
|
|
|
|
|
+ } else if (this.device) {
|
|
|
|
|
+ if (instance['PRINT']()) this.complete();
|
|
|
|
|
+ else this.$message.warning(`请检查打印机 (${this.device.name})`);
|
|
|
|
|
+ } else {
|
|
|
|
|
+ if (instance['PRINTA']()) this.complete();
|
|
|
|
|
+ else this.$message.warning(`请检查打印机`);
|
|
|
|
|
+ }
|
|
|
|
|
+ this.printing = false;
|
|
|
|
|
+ this.loaded = true;
|
|
|
|
|
+ },
|
|
|
|
|
+ delay() {
|
|
|
|
|
+ setTimeout(() => {this.preview = true;}, 500);
|
|
|
|
|
+ },
|
|
|
|
|
+ complete() {
|
|
|
|
|
+ this.$message.success(`开始打印`);
|
|
|
|
|
+ this.$emit('close', true);
|
|
|
|
|
+ },
|
|
|
|
|
+
|
|
|
|
|
+ async getModel() {
|
|
|
|
|
+ if (this.model) return this.model;
|
|
|
|
|
+
|
|
|
|
|
+ return getPrint({id: this.id}).then((res) => {
|
|
|
|
|
+ const data = res.data;
|
|
|
|
|
+ this.model = {
|
|
|
|
|
+ patient: {
|
|
|
|
|
+ name: `${data['name']}`,
|
|
|
|
|
+ gender: `${data['sex']}`,
|
|
|
|
|
+ birthday: `${data['patientBirthday']}`,
|
|
|
|
|
+ },
|
|
|
|
|
+ recipe: {
|
|
|
|
|
+ count: `${data['number']}`,
|
|
|
|
|
+ total: `${data['packageNumber']}`,
|
|
|
|
|
+ method: `${data['prescriptionusage']}`,
|
|
|
|
|
+ volume: `${data['packageDose']}ml`,
|
|
|
|
|
+ },
|
|
|
|
|
+ department: [data['department'], data['bedNo']].filter(Boolean).join(' '),
|
|
|
|
|
+ record: {
|
|
|
|
|
+ title: `${data['medicalName']}(代煎中心)`,
|
|
|
|
|
+ date: `${data['createTime']}`,
|
|
|
|
|
+ no: `${data['preNo']}`,
|
|
|
|
|
+ category: data['preMzZy'] === '1' ? '门诊' : '住院',
|
|
|
|
|
+ remark: [data['frequency'], data['medicationTime']].filter(Boolean).join(','),
|
|
|
|
|
+ },
|
|
|
|
|
+ };
|
|
|
|
|
+ this.total = this.model.recipe.total;
|
|
|
|
|
+
|
|
|
|
|
+ return this.model;
|
|
|
|
|
+ });
|
|
|
|
|
+ },
|
|
|
|
|
+ },
|
|
|
|
|
+};
|
|
|
|
|
+</script>
|
|
|
|
|
+
|
|
|
|
|
+<template>
|
|
|
|
|
+ <div class="print-preview" v-loading="loading">
|
|
|
|
|
+ <div class="top" :style="{backgroundColor: preview ? '#f0f0f0' : 'transparent'}"></div>
|
|
|
|
|
+ <iframe :id="tag" @load="delay"></iframe>
|
|
|
|
|
+ <div style="display: flex; align-items: center; justify-content: space-evenly;">
|
|
|
|
|
+ <el-tooltip class="item" effect="dark" content="打印数量" placement="top">
|
|
|
|
|
+ <el-input-number style="width: 120px;" v-model="total" :min="1" :disabled="printing"></el-input-number>
|
|
|
|
|
+ </el-tooltip>
|
|
|
|
|
+ <el-button type="primary" :loading="printing" @click="printing = true;print()">打印</el-button>
|
|
|
|
|
+ </div>
|
|
|
|
|
+ </div>
|
|
|
|
|
+</template>
|
|
|
|
|
+
|
|
|
|
|
+<style scoped lang="scss">
|
|
|
|
|
+.print-preview {
|
|
|
|
|
+ margin: auto;
|
|
|
|
|
+ width: 300px;
|
|
|
|
|
+
|
|
|
|
|
+ .top {
|
|
|
|
|
+ height: 40px;
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+ iframe {
|
|
|
|
|
+ border: none;
|
|
|
|
|
+ width: 100%;
|
|
|
|
|
+ height: 240px;
|
|
|
|
|
+ }
|
|
|
|
|
+}
|
|
|
|
|
+</style>
|