Переглянути джерело

处方审核打印添加小包标签选项

cc12458 1 рік тому
батько
коміт
49d1c24523

+ 1 - 0
src/api/prescription/prescriptionAudit.js

@@ -42,6 +42,7 @@ export function selectOrderDetail2(query) {
         total: data['packageNumber'],
         category: data['dosageForm'],
         method: data['prescriptionusage'],
+        usageMethod: data['usageMethod'],
         volume: data['concentration'] && `每次${data['concentration']}`,
         totalVolume: data['packageDose'],
         frequency: data['frequency'],

+ 35 - 4
src/components/print/express_75.vue

@@ -1,5 +1,5 @@
 <script>
-import {sf_express_print} from '@/tools/print.tool';
+import {getDevice, getDevices, sf_express_print} from '@/tools/print.tool';
 import {getExpressRecordParams} from '@/api/prescription/prescriptionAudit';
 import {editPrescriptionCore2, getPrescriptionCore2} from '@/api/prescription/prescriptionCore';
 import regionOptions from '@/utils/options';
@@ -8,6 +8,7 @@ export default {
   name: 'print_express_75',
   props: {
     id: {type: [String, Number], required: true},
+    selectable: Boolean,
   },
   data() {
     const locationValidator = (message) => (rule, value, callback) => {
@@ -26,6 +27,7 @@ export default {
 
       model: null,
       device: null,
+      devices: [],
       printing: false,
 
       submitting: false,
@@ -47,13 +49,19 @@ export default {
     loading() {
       return !this.loaded || !this.preview;
     },
+    deviceId() {
+      return this.device ? this.device.index : '';
+    }
   },
   mounted() {
-    // this.print(true);
+    if (this.selectable) getDevices().then(devices => this.devices = devices);
   },
   methods: {
     async print(preview = false) {
+      if (preview) this.loaded = false;
       try {
+        const device = await this.getDevice();
+
         if (preview) {
           this.getDicts('express_dech').then((response) => {this.expressDechOptions = response.data;});
           this.getDicts('express_pay_type').then((response) => {this.expressPayTypeOptions = response.data;});
@@ -68,10 +76,12 @@ export default {
             expressPayType: model.expressPayType,
             expressExecutor: model.expressExecutor,
           };
+
+          if (device == null) await getDevices();
         } else {
-          await this.getModel();
           this.printing = true;
-          await sf_express_print(this.model);
+          await this.getModel();
+          await sf_express_print(this.model, {}, device);
         }
       } catch (e) {}
       this.printing = false;
@@ -90,6 +100,20 @@ export default {
       });
     },
 
+    async getDevice() {
+      if (!this.device) this.device = await getDevice(
+        `name: Six:${this.paper}`,
+        `driver: RP4xx Series 200DPI TSC; paper: ${this.paper}`,
+        `paper:${this.paper}`,
+        `driver: RP4xx Series 200DPI TSC;`,
+      );
+      return this.device;
+    },
+
+    selected(value) {
+      this.device = this.devices.find(device => device.index === value);
+    },
+
     async save() {
       try {
         await this.$refs.form.validate()
@@ -157,6 +181,9 @@ export default {
         </template>
         <template v-else>
           <el-button style="flex: 1;" @click="editable = true;">编辑</el-button>
+          <el-select v-if="devices.length" placeholder="打印机" :value="deviceId" @change="selected">
+            <el-option v-for="item in devices" :key="item.index" :label="item.name" :value="item.index"></el-option>
+          </el-select>
           <el-button style="flex: 3;" type="primary" :loading="printing" @click="printing = true;print()">
             打印
           </el-button>
@@ -186,5 +213,9 @@ export default {
   > div {
     flex: none;
   }
+
+  .el-select {
+    margin: 0 12px;
+  }
 }
 </style>

+ 76 - 25
src/components/print/recipe_A5.vue

@@ -1,6 +1,6 @@
 <script>
 import CLodop from '@/libs/print/CLodop';
-import {getDevice} from '@/tools/print.tool';
+import {getDevice, getDevices} from '@/tools/print.tool';
 import {templateA5} from '@/components/print/template';
 import {selectOrderDetail, selectOrderDetail2} from '@/api/prescription/prescriptionAudit';
 import {bignumber, chain, multiply} from 'mathjs';
@@ -9,6 +9,7 @@ export default {
   name: 'print_recipe_a5',
   props: {
     id: {type: [String, Number], required: true},
+    selectable: Boolean,
   },
   data() {
     return {
@@ -18,9 +19,12 @@ export default {
 
       tag: `print-preview_${Date.now()}`,
       paper: '中药处方笺',
+      paperWidth: 1485,
+      paperHeight: 2100,
 
       model: null,
       device: null,
+      devices: [],
       printing: false,
     };
   },
@@ -28,39 +32,47 @@ export default {
     loading() {
       return !this.loaded || !this.preview;
     },
+    deviceId() {
+      return this.device ? this.device.index : '';
+    },
   },
   mounted() {
-    // this.print(true);
+    if (this.selectable) getDevices().then(devices => this.devices = devices);
+    this.loaded = true;
   },
   methods: {
     async print(preview = false) {
+      if (preview) this.loaded = false;
+
       const instance = await CLodop();
       const model = await this.getModel();
 
       templateA5.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: 559, height: 794}, `name:Canon LBP`);
-        if (this.device) instance['SET_PRINT_PAGESIZE'](1, '148mm', '210mm', '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})`);
+      const device = await this.getDevice();
+      if (device) {
+        if (device.papers.includes(this.paper)) instance['SET_PRINT_PAGESIZE'](1, 0, 0, this.paper);
+        else instance['SET_PRINT_PAGESIZE'](1, this.paperWidth, this.paperHeight, 'CreateCustomPage');
+
+        instance['SET_PRINTER_INDEX'](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 (instance['PRINT']()) this.complete();
+          else this.$message.warning(`请检查打印机 (${this.device.name})`);
+        }
+      } else if (preview) {
+        this.devices = await getDevices();
       } else {
         if (instance['PRINTA']()) this.complete();
         else this.$message.warning(`请检查打印机`);
       }
+
       this.printing = false;
       this.loaded = true;
     },
@@ -86,17 +98,44 @@ export default {
 
       return this.model;
     },
+
+    async getDevice() {
+      if (!this.device) this.device = await getDevice(
+        `name: Six:${this.paper}`,
+        `name: Six:${this.paperWidth}*${this.paperHeight}`,
+        `driver: Canon LBP6030/6040/6018L; paper: ${this.paper}`,
+        `driver: Canon LBP6030/6040/6018L; form: A5`,
+        `driver: Canon LBP6030/6040/6018L;`,
+        {width: this.paperWidth, height: this.paperHeight},
+        `paper:${this.paper}`,
+        `form: A5`,
+      );
+      console.log(this.device);
+      return this.device;
+    },
+
+    selected(value) {
+      this.device = this.devices.find(device => device.index === value);
+      this.print(true);
+    },
   },
 };
 </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 class="print-preview">
+    <div class="content" v-loading="loading">
+      <div class="top" :style="{backgroundColor: preview ? '#f0f0f0' : 'transparent'}">
+        {{ device && device.name }}
+      </div>
+      <iframe :id="tag" @load="delay"></iframe>
+    </div>
     <div style="display: flex; align-items: center; justify-content: space-evenly;">
-      <el-button style="width: 100%;" type="primary" :loading="printing" @click="printing = true;print()">
-        打印
+      <el-select v-if="devices.length" placeholder="打印机" :value="deviceId" @change="selected">
+        <el-option v-for="item in devices" :key="item.index" :label="item.name" :value="item.index"></el-option>
+      </el-select>
+      <el-button style="width: 100%;" type="primary" :disabled="loading" :loading="printing"
+                 @click="printing = true;print()">打印
       </el-button>
     </div>
   </div>
@@ -109,8 +148,16 @@ export default {
   display: flex;
   flex-direction: column;
 
+  .content {
+    flex: auto;
+    display: flex;
+    flex-direction: column;
+  }
+
   .top {
     height: 40px;
+    font-size: 12px;
+    color: rgba(0, 0, 0, 0.5);
   }
 
   iframe {
@@ -122,5 +169,9 @@ export default {
   > div {
     flex: none;
   }
+
+  .el-select {
+    margin-right: 12px;
+  }
 }
 </style>

+ 69 - 25
src/components/print/tag_60_40.vue

@@ -1,14 +1,14 @@
 <script>
 import CLodop from '@/libs/print/CLodop';
-import {getPrint} from '@/api/decoct/recipe';
-import {getDevice} from '@/tools/print.tool';
+import {getDevice, getDevices} from '@/tools/print.tool';
 import {template60_40} from '@/components/print/template';
+import {getPrint} from '@/api/decoct/recipe';
 
 export default {
   name: 'print_tag_60_40',
   props: {
     id: {type: [String, Number], required: true},
-    init: {type: Boolean, default: false},
+    selectable: Boolean,
   },
   data() {
     return {
@@ -18,9 +18,12 @@ export default {
 
       tag: `print-preview_${Date.now()}`,
       paper: '发药标签',
+      paperWidth: 60 * 10,
+      paperHeight: 40 * 10,
 
       model: null,
       device: null,
+      devices: [],
       printing: false,
     };
   },
@@ -28,39 +31,47 @@ export default {
     loading() {
       return !this.loaded || !this.preview;
     },
+    deviceId() {
+      return this.device ? this.device.index : '';
+    }
   },
   mounted() {
-    if (this.$props.init) this.print(true);
+    if (this.selectable) getDevices().then(devices => this.devices = devices);
+    this.loaded = true;
   },
   methods: {
     async print(preview = false) {
+      if (preview) this.loaded = false;
+
       const instance = await CLodop();
       const model = await this.getModel();
-
+      const postfix = model.recipe.usageMethod;
       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})`);
+      const device = await this.getDevice(postfix);
+      if (device) {
+        if (device.papers.includes(this.paper)) instance['SET_PRINT_PAGESIZE'](1, 0, 0, this.paper);
+        else instance['SET_PRINT_PAGESIZE'](1, this.paperWidth, this.paperHeight, 'CreateCustomPage');
+
+        instance['SET_PRINTER_INDEX'](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 (instance['PRINT']()) this.complete();
+          else this.$message.warning(`请检查打印机 (${this.device.name})`);
+        }
+      } else if (preview) {
+        this.devices = await getDevices();
       } else {
         if (instance['PRINTA']()) this.complete();
         else this.$message.warning(`请检查打印机`);
       }
+
       this.printing = false;
       this.loaded = true;
     },
@@ -87,6 +98,7 @@ export default {
             count: data['number'],
             total: data['packageNumber'],
             method: data['prescriptionusage'],
+            usageMethod: data['usageMethod'],
             volume: data['packageDose'] ? `${data['packageDose']}ml` : '',
             delivery: data['expressExecutor'],
             decoction: data['isBehalf'] === '1' ? '代煎' : '自煎',
@@ -107,18 +119,43 @@ export default {
         return this.model;
       });
     },
+
+    async getDevice(postfix= '') {
+      if (!this.device) this.device = await getDevice(
+        `name: Six:${this.paper}-${postfix}`,
+        `name: Six:${this.paperWidth}*${this.paperHeight}-${postfix}`,
+        `name: Six:${this.paper}`,
+        `name: Six:${this.paperWidth}*${this.paperHeight}`,
+        `driver: Gprinter GP-1324D; paper: ${this.paper}`,
+        `paper:${this.paper}`,
+        `driver: Gprinter GP-1324D;`,
+      );
+      return this.device;
+    },
+
+    selected(value) {
+      this.device = this.devices.find(device => device.index === value);
+      this.print(true);
+    }
   },
 };
 </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 v-loading="loading">
+      <div class="top" :style="{backgroundColor: preview ? '#f0f0f0' : 'transparent'}">
+        {{ device && device.name }}
+      </div>
+      <iframe :id="tag" @load="delay"></iframe>
+    </div>
     <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-select v-if="devices.length" placeholder="打印机" :value="deviceId" @change="selected">
+        <el-option v-for="item in devices" :key="item.index" :label="item.name" :value="item.index"></el-option>
+      </el-select>
       <el-button type="primary" :loading="printing" @click="printing = true;print()">打印</el-button>
     </div>
   </div>
@@ -131,6 +168,8 @@ export default {
 
   .top {
     height: 40px;
+    font-size: 12px;
+    color: rgba(0, 0, 0, 0.5);
   }
 
   iframe {
@@ -138,5 +177,10 @@ export default {
     width: 100%;
     height: 240px;
   }
+
+  .el-select {
+    margin: 0 12px;
+    flex: 1;
+  }
 }
 </style>

+ 69 - 27
src/components/print/tag_80_50.vue

@@ -1,6 +1,6 @@
 <script>
 import CLodop from '@/libs/print/CLodop';
-import {getDevice} from '@/tools/print.tool';
+import {getDevice, getDevices} from '@/tools/print.tool';
 import {template60_60} from '@/components/print/template';
 import {selectOrderDetail2} from '@/api/prescription/prescriptionAudit';
 
@@ -8,6 +8,7 @@ export default {
   name: 'print_tag_80_50',
   props: {
     id: {type: [String, Number], required: true},
+    selectable: Boolean,
   },
   data() {
     return {
@@ -17,9 +18,12 @@ export default {
 
       tag: `print-preview_${Date.now()}`,
       paper: '包装标签',
+      paperWidth: 60 * 10,
+      paperHeight: 60 * 10,
 
       model: null,
       device: null,
+      devices: [],
       printing: false,
     };
   },
@@ -27,39 +31,47 @@ export default {
     loading() {
       return !this.loaded || !this.preview;
     },
+    deviceId() {
+      return this.device ? this.device.index : '';
+    }
   },
   mounted() {
-    // this.print(true);
+    if (this.selectable) getDevices().then(devices => this.devices = devices);
+    this.loaded = true;
   },
   methods: {
     async print(preview = false) {
+      if (preview) this.loaded = false;
+
       const instance = await CLodop();
       const model = await this.getModel();
-
+      const postfix = model.recipe.usageMethod;
       template60_60.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})`);
+      const device = await this.getDevice(postfix);
+      if (device) {
+        if (device.papers.includes(this.paper)) instance['SET_PRINT_PAGESIZE'](1, 0, 0, this.paper);
+        else instance['SET_PRINT_PAGESIZE'](1, this.paperWidth, this.paperHeight, 'CreateCustomPage');
+
+        instance['SET_PRINTER_INDEX'](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 (instance['PRINT']()) this.complete();
+          else this.$message.warning(`请检查打印机 (${this.device.name})`);
+        }
+      } else if (preview) {
+        this.devices = await getDevices();
       } else {
         if (instance['PRINTA']()) this.complete();
         else this.$message.warning(`请检查打印机`);
       }
+
       this.printing = false;
       this.loaded = true;
     },
@@ -72,20 +84,44 @@ export default {
     },
 
     async getModel() {
-      if (this.model) return this.model;
-      this.model = await selectOrderDetail2({id: this.id});
+      if (!this.model) this.model = await selectOrderDetail2({id: this.id});
       return this.model;
     },
+
+    async getDevice(postfix= '') {
+      if (!this.device) this.device = await getDevice(
+        `name: Six:${this.paper}-${postfix}`,
+        `name: Six:${this.paperWidth}*${this.paperHeight}-${postfix}`,
+        `name: Six:${this.paper}`,
+        `name: Six:${this.paperWidth}*${this.paperHeight}`,
+        `driver: Gprinter GP-1324D; paper: ${this.paper}`,
+        `paper:${this.paper}`,
+        `driver: Gprinter GP-1324D;`,
+      );
+      return this.device;
+    },
+
+    selected(value) {
+      this.device = this.devices.find(device => device.index === value);
+      this.print(true);
+    }
   },
 };
 </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 class="print-preview">
+    <div v-loading="loading">
+      <div class="top" :style="{backgroundColor: preview ? '#f0f0f0' : 'transparent'}">
+        {{ device && device.name }}
+      </div>
+      <iframe :id="tag" @load="delay"></iframe>
+    </div>
     <div style="display: flex; align-items: center; justify-content: space-evenly;">
-      <el-button style="width: 100%;" type="primary" :loading="printing" @click="printing = true;print()">打印</el-button>
+      <el-select v-if="devices.length" placeholder="打印机" :value="deviceId" @change="selected">
+        <el-option v-for="item in devices" :key="item.index" :label="item.name" :value="item.index"></el-option>
+      </el-select>
+      <el-button style="width: 100%;" type="primary" :disabled="loading" :loading="printing" @click="printing = true;print()">打印</el-button>
     </div>
   </div>
 </template>
@@ -97,6 +133,8 @@ export default {
 
   .top {
     height: 40px;
+    font-size: 12px;
+    color: rgba(0, 0, 0, 0.5);
   }
 
   iframe {
@@ -104,5 +142,9 @@ export default {
     width: 100%;
     height: 280px;
   }
+
+  .el-select {
+    margin-right: 12px;
+  }
 }
 </style>

+ 73 - 25
src/components/print/ticket_72.vue

@@ -1,6 +1,6 @@
 <script>
 import CLodop from '@/libs/print/CLodop';
-import {getDevice} from '@/tools/print.tool';
+import {getDevice, getDevices} from '@/tools/print.tool';
 import {template72} from '@/components/print/template';
 import {selectOrderDetail, selectOrderDetail2} from '@/api/prescription/prescriptionAudit';
 import {bignumber, chain, multiply} from 'mathjs';
@@ -18,9 +18,12 @@ export default {
 
       tag: `print-preview_${Date.now()}`,
       paper: '药品明细',
+      paperWidth: 72 * 10,
+      paperHeight: 0,
 
       model: null,
       device: null,
+      devices: [],
       printing: false,
     };
   },
@@ -28,39 +31,47 @@ export default {
     loading() {
       return !this.loaded || !this.preview;
     },
+    deviceId() {
+      return this.device ? this.device.index : '';
+    }
   },
   mounted() {
-    // this.print(true);
+    if (this.selectable) getDevices().then(devices => this.devices = devices);
+    this.loaded = true;
   },
   methods: {
     async print(preview = false) {
+      if (preview) this.loaded = false;
+
       const instance = await CLodop();
       const model = await this.getModel();
 
       template72.call(instance, model, `${this.paper}`);
 
-      this.device = await getDevice(`paper:${this.paper}`);
-      if (this.device) instance['SET_PRINT_PAGESIZE'](3, 0, 0, this.paper);
-      else {
-        this.device = await getDevice(`name:GP-C80180 Series`);
-        instance['SET_PRINT_PAGESIZE'](3, '72mm', 0, '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})`);
+      const device = await this.getDevice();
+      if (device) {
+        if (device.papers.includes(this.paper)) instance['SET_PRINT_PAGESIZE'](3, 0, 0, this.paper);
+        else instance['SET_PRINT_PAGESIZE'](3, this.paperWidth, this.paperHeight, 'CreateCustomPage');
+
+        instance['SET_PRINTER_INDEX'](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 (instance['PRINT']()) this.complete();
+          else this.$message.warning(`请检查打印机 (${this.device.name})`);
+        }
+      } else if (preview) {
+        this.devices = await getDevices();
       } else {
         if (instance['PRINTA']()) this.complete();
         else this.$message.warning(`请检查打印机`);
       }
+
       this.printing = false;
       this.loaded = true;
     },
@@ -86,16 +97,41 @@ export default {
 
       return this.model;
     },
+
+    async getDevice() {
+      if (!this.device) this.device = await getDevice(
+        `name: Six:${this.paper}`,
+        `name: Six:${this.paperWidth}`,
+        `name: Six:ticket`,
+        `driver: GP-C80180 Series; paper: ${this.paper}`,
+        `driver: GP-C80180 Series;`,
+        `paper:${this.paper}`,
+      );
+      return this.device;
+    },
+
+    selected(value) {
+      this.device = this.devices.find(device => device.index === value);
+      this.print(true);
+    }
   },
 };
 </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 class="print-preview">
+    <div class="content" v-loading="loading">
+      <div class="top" :style="{backgroundColor: preview ? '#f0f0f0' : 'transparent'}">
+        {{ device && device.name }}
+      </div>
+      <iframe :id="tag" @load="delay"></iframe>
+    </div>
     <div style="display: flex; align-items: center; justify-content: space-evenly;">
-      <el-button style="width: 100%;" type="primary" :loading="printing" @click="printing = true;print()">打印
+      <el-select v-if="devices.length" placeholder="打印机" :value="deviceId" @change="selected">
+        <el-option v-for="item in devices" :key="item.index" :label="item.name" :value="item.index"></el-option>
+      </el-select>
+      <el-button style="width: 100%;" type="primary" :disabled="loading" :loading="printing"
+                 @click="printing = true;print()">打印
       </el-button>
     </div>
   </div>
@@ -104,12 +140,20 @@ export default {
 <style scoped lang="scss">
 .print-preview {
   margin: auto;
-  width: 360px;
+  width: 559px + 100px;
   display: flex;
   flex-direction: column;
 
+  .content {
+    flex: auto;
+    display: flex;
+    flex-direction: column;
+  }
+
   .top {
     height: 40px;
+    font-size: 12px;
+    color: rgba(0, 0, 0, 0.5);
   }
 
   iframe {
@@ -121,5 +165,9 @@ export default {
   > div {
     flex: none;
   }
+
+  .el-select {
+    margin-right: 12px;
+  }
 }
 </style>

+ 27 - 16
src/tools/print.tool.js

@@ -61,20 +61,23 @@ let sf_express = async function (options = {}) {
  *
  * @type {sf_express_instance_print_function}
  */
-export async function sf_express_print(data, options = {}) {
+export async function sf_express_print(data, options = {}, device) {
   const instance = await sf_express(options);
-  const {promise: loadDevices, resolve, reject} = withResolvers();
 
-  instance['getPrinters']((result) => {
-    if (result.code === 1) {
-      const devices = Array.isArray(result.printers) ? result.printers : [];
-      resolve(devices);
-    } else reject({message: result.msg, code: result.code});
-  });
+  if (device == null) {
+    const {promise: loadDevices, resolve, reject} = withResolvers();
+
+    instance['getPrinters']((result) => {
+      if (result.code === 1) {
+        const devices = Array.isArray(result.printers) ? result.printers : [];
+        resolve(devices);
+      } else reject({message: result.msg, code: result.code});
+    });
 
-  const devices = await loadDevices;
+    const devices = await loadDevices;
 
-  const device = devices.find(device => device.name.startsWith(process.env.VUE_APP_SF_EXPRESS_APPNAME));
+    device = devices.find(device => device.name.startsWith(process.env.VUE_APP_SF_EXPRESS_APPNAME));
+  }
 
   if (device) instance['setPrinter'](device.index);
   return new Promise((resolve, reject) => {
@@ -98,7 +101,8 @@ export async function getDevices() {
   const LODOP = await c_lodop();
   return Array.from({length: LODOP['GET_PRINTER_COUNT']()}, (_, i) => {
     return {
-      name: LODOP['GET_PRINTER_NAME'](`${i}:DriverName`),
+      name: LODOP['GET_PRINTER_NAME'](`${i}`),
+      driver: LODOP['GET_PRINTER_NAME'](`${i}:DriverName`),
       index: i,
       papers: LODOP['GET_PAGESIZES_LIST'](i, '\n').split('\n'),
       size: +LODOP['GET_PRINTER_NAME'](`${i}:PaperSize`),
@@ -114,14 +118,21 @@ export async function getDevice(...priority) {
   const devices = await getDevices();
   let device;
   for (let item of priority) {
+    let command = [];
     if (typeof item === 'string') {
-      const [key, value] = item.split(':');
-      item = {[key]: value};
+      const regex = /([^:;]+):+([^;]*)/g;
+      let match;
+      while ((match = regex.exec(item))) {
+        const key = match[1].trim();
+        const value = match[2].trim();
+        if (key && value) command.push([key, value]);
+      }
+    } else {
+      command = Object.entries(item);
     }
-    device = devices.find(device => Object.entries(item).every(([key, value]) => {
+    device = devices.find(device => command.every(([key, value]) => {
       if (key === 'paper') return device['papers'].includes(value);
-      if (key === 'name') return device.name.startsWith(value);
-      if (key === 'width' || key === 'height') value *= 10; /* 传入 mm,比较的是 0.1mm */
+      if (key === 'width_mm' || key === 'height_mm') value *= 10; /* 传入 mm,比较的是 0.1mm */
       return device[key] === value;
     }));
     if (device) break;

+ 1 - 1
src/views/pda/dispatch/printContainer.vue

@@ -60,7 +60,7 @@ export default {
         <print_express_75 ref="print0" :id="id" :style="style" @click="$event && update()"></print_express_75>
       </el-tab-pane>
       <el-tab-pane label="标签">
-        <Print_tag_60_40 ref="print1" :id="id" @click="$event && update(0)"></Print_tag_60_40>
+        <print_tag_60_40 ref="print1" :id="id" @click="$event && update(0)"></print_tag_60_40>
       </el-tab-pane>
     </el-tabs>
   </div>

+ 11 - 0
src/views/rescription/prescriptionCore/index.vue

@@ -1296,6 +1296,7 @@
     <el-dialog title="打印预览" :visible.sync="showPrint" @closed="showPrintId = ''">
       <print-container v-if="showPrintId" :id="showPrintId"
                        :load-express="showPrintExpressCom"
+                       :load-tag-s="showPrintTagSCom"
       />
     </el-dialog>
   </div>
@@ -1335,6 +1336,7 @@ import JsBarcode from "@/components/JsBarcode/index.vue";
 import Edit from "./edit.vue";
 import dayjs from "dayjs";
 import PrintContainer from '@/views/rescription/prescriptionCore/printContainer.vue';
+import {mapGetters} from 'vuex';
 
 // import JsBarcode from "jsbarcode"
 
@@ -1562,6 +1564,7 @@ export default {
     },
   },
   computed: {
+    ...mapGetters(["permissions"]),
     formattedDate() {
       const dateObj = new Date(this.curPatientBirthday);
       const year = dateObj.getFullYear();
@@ -1589,6 +1592,14 @@ export default {
         return "否";
       }
     },
+    // 打印加载小包标签组件
+    showPrintTagSCom() {
+      try {
+        return this.permissions.includes('rescription:prescriptionCore:print:tag_s')
+      } catch (e) {
+        return false;
+      }
+    }
   },
   methods: {
     countDose() {

+ 17 - 10
src/views/rescription/prescriptionCore/printContainer.vue

@@ -1,5 +1,6 @@
 <script>
 import Print_tag_80_50 from '@/components/print/tag_80_50.vue';
+import Print_tag_60_40 from '@/components/print/tag_60_40.vue';
 import Print_recipe_a5 from '@/components/print/recipe_A5.vue';
 import Print_ticket_72 from '@/components/print/ticket_72.vue';
 import Print_express_75 from '@/components/print/express_75.vue';
@@ -10,10 +11,13 @@ export default {
   props: {
     id: {type: [String, Number], required: true},
     loadExpress: {type: Boolean, default: false},
+    loadTagS: {type: Boolean, default: false},
   },
-  components: {Print_express_75, Print_ticket_72, Print_recipe_a5, Print_tag_80_50},
+  components: {Print_tag_60_40, Print_express_75, Print_ticket_72, Print_recipe_a5, Print_tag_80_50},
   data() {
-    return {};
+    return {
+      selected: 'print0',
+    };
   },
   computed: {
     height() { return `${window.innerHeight * 0.8}`; },
@@ -21,7 +25,7 @@ export default {
   },
   watch: {},
   mounted() {
-    this.select(0);
+    this.select(this.selected);
   },
   methods: {
     async print() {
@@ -44,9 +48,9 @@ export default {
         });
       }
     },
-    select(index) {
+    select(name) {
       try {
-        const el = this.$refs[`print${index}`];
+        const el = this.$refs[name];
         el['print'](true);
       } catch (e) {}
     }
@@ -57,17 +61,20 @@ export default {
 <template>
   <div>
     <el-button class="pin" type="primary" @click="print">组合打印</el-button>
-    <el-tabs tab-position="left" :style="style" @tab-click="select($event.index)">
-      <el-tab-pane label="标签">
+    <el-tabs tab-position="left" :style="style" v-model="selected" @tab-click="select($event.name)">
+      <el-tab-pane label="标签" name="print0">
         <print_tag_80_50 ref="print0" :id="id" @click="$event && update(0)"></print_tag_80_50>
       </el-tab-pane>
-      <el-tab-pane label="处方笺">
+      <el-tab-pane v-if="loadTagS" label="小包标签" name="print4">
+        <print_tag_60_40 ref="print4" :id="id" @click="$event && update(0)"></print_tag_60_40>
+      </el-tab-pane>
+      <el-tab-pane label="处方笺" name="print1">
         <print_recipe_a5 ref="print1" :id="id" :style="style" @click="$event && update(1)"></print_recipe_a5>
       </el-tab-pane>
-      <el-tab-pane label="药品清单">
+      <el-tab-pane label="药品清单" name="print2">
         <print_ticket_72 ref="print2" :id="id" :style="style" @click="$event && update(2)"></print_ticket_72>
       </el-tab-pane>
-      <el-tab-pane v-if="loadExpress" label="顺丰面单">
+      <el-tab-pane v-if="loadExpress" label="顺丰面单" name="print3">
         <print_express_75 ref="print3" :id="id" :style="style" @click="$event && update()"></print_express_75>
       </el-tab-pane>
     </el-tabs>