Browse Source

条码预制生成预制码

seimin 1 year ago
parent
commit
a2bc689cb9

+ 48 - 28
src/app/views/barcode-prefabrication/barcode-prefabrication.component.html

@@ -24,7 +24,7 @@
24 24
             <td>{{ data.codeType ? data.codeType.name : '' }}</td>
25 25
             <td>
26 26
               <div class="coop">
27
-                <span *ngIf="coopBtns.generateQRcode" (click)="generateQRcode(data.id)">生成</span>
27
+                <span *ngIf="coopBtns.generateQRcode" (click)="generateQRcode(data)">生成</span>
28 28
                 <span *ngIf="coopBtns.edit" (click)="edit(data)">修改</span>
29 29
                 <span *ngIf="coopBtns.del" (click)="del(data)">删除</span>
30 30
               </div>
@@ -89,39 +89,26 @@
89 89
 <!-- 生成模态框 -->
90 90
 <div class="save add display_flex align-items_center justify-content_flex-center" *ngIf="generateModal">
91 91
   <div class="modalBody">
92
-    <div class="title">生成条码预制<i class="icon_transport transport-guanbi" (click)="hideGenerateModal()"></i>
92
+    <div class="title">条码生成<i class="icon_transport transport-guanbi" (click)="hideGenerateModal()"></i>
93 93
     </div>
94 94
     <overlay-scrollbars #osComponentRef1 class="content">
95 95
       <form nz-form [formGroup]="validateGenerateForm" class="addForm" (ngSubmit)="submitGenerateForm()">
96
-        <nz-form-item>
97
-          <nz-form-label [nzSm]="6" [nzXs]="24" nzRequired nzFor="title">预制名称</nz-form-label>
98
-          <nz-form-control nzErrorTip="请填写预制名称!">
99
-            <nz-input-group>
100
-              <input nz-input formControlName="title" placeholder="请填写预制名称" />
101
-            </nz-input-group>
96
+        <nz-form-item *ngIf="coopData.snConfigDTO.dateType">
97
+          <nz-form-label [nzSm]="8" [nzXs]="24" nzRequired nzFor="date">选择日期({{dateText}})</nz-form-label>
98
+          <nz-form-control nzErrorTip="请选择日期({{dateText}})!">
99
+            <div>
100
+              <nz-year-picker class="w100" *ngIf="isYear && !isMonth && !isDay" formControlName="date" nzPlaceHolder="请选择日期({{dateText}})"></nz-year-picker>
101
+              <nz-month-picker class="w100" *ngIf="isYear && isMonth && !isDay" formControlName="date" nzPlaceHolder="请选择日期({{dateText}})"></nz-month-picker>
102
+              <nz-date-picker class="w100" *ngIf="isYear && isMonth && isDay" formControlName="date" nzPlaceHolder="请选择日期({{dateText}})"></nz-date-picker>
103
+            </div>
102 104
           </nz-form-control>
103 105
         </nz-form-item>
104 106
         <nz-form-item>
105
-          <nz-form-label [nzSm]="6" [nzXs]="24" nzRequired nzFor="snConfig">序号名称</nz-form-label>
106
-          <nz-form-control nzErrorTip="请选择序号名称!">
107
-            <nz-select (nzOnSearch)="changeInp($event)" [nzDropdownMatchSelectWidth]="false" nzServerSearch nzShowSearch nzAllowClear formControlName="snConfig" nzPlaceHolder="请选择序号名称">
108
-              <ng-container *ngFor="let option of snConfigs">
109
-                <nz-option *ngIf="!isLoading" [nzLabel]="option.title" [nzValue]="option.id"></nz-option>
110
-              </ng-container>
111
-              <nz-option *ngIf="isLoading" nzDisabled nzCustomContent>
112
-                <i nz-icon nzType="loading" class="loading-icon"></i> 搜索中...
113
-              </nz-option>
114
-            </nz-select>
115
-          </nz-form-control>
116
-        </nz-form-item>
117
-        <nz-form-item>
118
-          <nz-form-label [nzSm]="6" [nzXs]="24" nzRequired nzFor="codeType">条码样式</nz-form-label>
119
-          <nz-form-control nzErrorTip="请选择条码样式!">
120
-            <nz-select [nzDropdownMatchSelectWidth]="false" nzShowSearch nzAllowClear
121
-              formControlName="codeType" nzPlaceHolder="请选择条码样式">
122
-              <nz-option [nzLabel]="data.name" [nzValue]="data.id" *ngFor="let data of codeTypes">
123
-              </nz-option>
124
-            </nz-select>
107
+          <nz-form-label [nzSm]="6" [nzXs]="24" nzRequired nzFor="count">生成数量</nz-form-label>
108
+          <nz-form-control nzErrorTip="请选择生成数量!">
109
+            <div style="margin-top: 15px;">
110
+              <nz-input-number nz-input formControlName="count" nzPlaceHolder="请填写生成数量" [nzMin]="1" [nzStep]="1" [nzPrecision]="0"></nz-input-number>
111
+            </div>
125 112
           </nz-form-control>
126 113
         </nz-form-item>
127 114
       </form>
@@ -142,3 +129,36 @@
142 129
 
143 130
 <!-- 遮罩 -->
144 131
 <app-mask *ngIf="maskFlag"></app-mask>
132
+
133
+<!-- 打印二维码的内容 -->
134
+<div id="print-section" hidden>
135
+  <table>
136
+    <tr style="width: 80mm;height: 60mm;overflow: hidden;box-sizing: border-box;page-break-inside:avoid;" *ngFor="let item of codeList">
137
+      <td style="padding:0;">
138
+        <div style="display: flex;justify-content: center;align-items: center;height: 15mm;background-color: #F4EE17;-webkit-print-color-adjust: exact;font-size: 5mm;letter-spacing: 1mm;font-weight: bold;">
139
+          医疗废物标签
140
+        </div>
141
+        <div style="display:flex;overflow: hidden;height: 45mm;">
142
+          <img [src]="item.qrCode" style="height: 100%;box-shadow: 1mm #f2f2f2;">
143
+          <div style="flex: 1;">
144
+            <div style="font-size: 3mm;margin: 2mm 1mm 1mm;">医废序号:{{item.clinicalWasteSn}}</div>
145
+            <div style="font-size: 3mm;margin: 1mm;">科室名称:_______________</div>
146
+            <div style="font-size: 3mm;margin: 1mm; overflow: hidden;">
147
+              <p style="float: left;margin: 0;">医废类型:</p>
148
+              <ul style="margin:0;padding: 0;list-style-type: none;float: right;">
149
+                <li><span style="display: inline-block;width: 3mm;height: 3mm;border:1px solid #000;position: relative;top: 0.5mm;margin-right: 1mm;"></span>感染性废物</li>
150
+                <li style="margin-top: 1mm;"><span style="display: inline-block;width: 3mm;height: 3mm;border:1px solid #000;position: relative;top: 0.5mm;margin-right: 1mm;"></span>感染性废物</li>
151
+                <li style="margin-top: 1mm;"><span style="display: inline-block;width: 3mm;height: 3mm;border:1px solid #000;position: relative;top: 0.5mm;margin-right: 1mm;"></span>感染性废物</li>
152
+                <li style="margin-top: 1mm;"><span style="display: inline-block;width: 3mm;height: 3mm;border:1px solid #000;position: relative;top: 0.5mm;margin-right: 1mm;"></span>感染性废物</li>
153
+                <li style="margin-top: 1mm;"><span style="display: inline-block;width: 3mm;height: 3mm;border:1px solid #000;position: relative;top: 0.5mm;margin-right: 1mm;"></span>感染性废物</li>
154
+                <li style="margin-top: 1mm;"><span style="display: inline-block;width: 3mm;height: 3mm;border:1px solid #000;position: relative;top: 0.5mm;margin-right: 1mm;"></span>感染性废物</li>
155
+              </ul>
156
+            </div>
157
+          </div>
158
+        </div>
159
+      </td>
160
+    </tr>
161
+  </table>
162
+</div>
163
+<button ngxPrint printSectionId="print-section" #printBtn hidden [printStyle]="{ '@page': { margin: '0 !important' }, 'body': { margin: '0 !important' } }">打印</button>
164
+

+ 0 - 1
src/app/views/barcode-prefabrication/barcode-prefabrication.component.less

@@ -42,7 +42,6 @@
42 42
       margin-top: 12px;
43 43
 
44 44
       div {
45
-        text-align: center;
46 45
         margin: 0;
47 46
 
48 47
         &.icon {

+ 58 - 27
src/app/views/barcode-prefabrication/barcode-prefabrication.component.ts

@@ -1,6 +1,6 @@
1
-import { Component, OnInit, ViewChild } from "@angular/core";
1
+import { Component, OnInit, ViewChild, ElementRef } from "@angular/core";
2 2
 import { ActivatedRoute, Router } from "@angular/router";
3
-import { FormBuilder, Validators, FormGroup } from "@angular/forms";
3
+import { FormBuilder, Validators, FormGroup, FormControl } from "@angular/forms";
4 4
 
5 5
 import { MainService } from "../../services/main.service";
6 6
 import { OverlayScrollbarsComponent } from "overlayscrollbars-ngx";
@@ -8,6 +8,7 @@ import { ToolService } from "../../services/tool.service";
8 8
 import { NzMessageService } from "ng-zorro-antd";
9 9
 import { Subject } from 'rxjs';
10 10
 import { debounceTime } from 'rxjs/operators';
11
+import { format } from 'date-fns';
11 12
 
12 13
 @Component({
13 14
   selector: "app-barcode-prefabrication",
@@ -15,6 +16,7 @@ import { debounceTime } from 'rxjs/operators';
15 16
   styleUrls: ["./barcode-prefabrication.component.less"],
16 17
 })
17 18
 export class BarcodePrefabricationComponent implements OnInit {
19
+  @ViewChild('printBtn', { static: false }) printBtn: ElementRef<HTMLElement>;
18 20
   @ViewChild("osComponentRef1", {
19 21
     read: OverlayScrollbarsComponent,
20 22
     static: false,
@@ -224,8 +226,30 @@ export class BarcodePrefabricationComponent implements OnInit {
224 226
   }
225 227
 
226 228
   // 生成
227
-  generateQRcode(id) {
228
-    this.coopId = id;
229
+  dateText: string = '';
230
+  isYear: boolean = false;
231
+  isMonth: boolean = false;
232
+  isDay: boolean = false;
233
+  generateQRcode(data) {
234
+    this.coopData = data;
235
+    if(this.coopData.snConfigDTO.dateType){
236
+      this.dateText = '';
237
+      this.isYear = false;
238
+      this.isMonth = false;
239
+      this.isDay = false;
240
+      if(this.coopData.snConfigDTO.dateType.name.includes('y')){
241
+        this.dateText += '年';
242
+        this.isYear = true;
243
+      }
244
+      if(this.coopData.snConfigDTO.dateType.name.includes('m')){
245
+        this.dateText += '月';
246
+        this.isMonth = true;
247
+      }
248
+      if(this.coopData.snConfigDTO.dateType.name.includes('d')){
249
+        this.dateText += '日';
250
+        this.isDay = true;
251
+      }
252
+    }
229 253
     this.showGenerateModal();
230 254
   }
231 255
 
@@ -243,40 +267,47 @@ export class BarcodePrefabricationComponent implements OnInit {
243 267
   // 初始化新增form表单
244 268
   initGenerateForm() {
245 269
     this.validateGenerateForm = this.fb.group({
246
-      title: [null, [Validators.required]],
247
-      snConfig: [null, [Validators.required]],
248
-      codeType: [null, [Validators.required]],
270
+      date: [null, [Validators.required]],
271
+      count: [1, [Validators.required]],
249 272
     });
273
+    if(this.coopData.snConfigDTO.dateType){
274
+      this.validateGenerateForm.addControl(
275
+        'date',
276
+        new FormControl(null, Validators.required)
277
+      );
278
+    }else{
279
+      this.validateGenerateForm.removeControl('date');
280
+    }
250 281
   }
251 282
   // 生成表单提交
283
+  codeList: any[] = [];
252 284
   submitGenerateForm(): void {
253
-    // todo
254
-    return;
255
-    for (const i in this.validateForm.controls) {
256
-      this.validateForm.controls[i].markAsDirty({ onlySelf: true });
257
-      this.validateForm.controls[i].updateValueAndValidity();
285
+    console.log(this.validateGenerateForm.value)
286
+    for (const i in this.validateGenerateForm.controls) {
287
+      this.validateGenerateForm.controls[i].markAsDirty({ onlySelf: true });
288
+      this.validateGenerateForm.controls[i].updateValueAndValidity();
258 289
     }
259
-    if (this.validateForm.invalid) return;
290
+    if (this.validateGenerateForm.invalid) return;
260 291
     this.btnLoading = true;
261
-    let data:any = {
262
-      title: this.validateForm.value.title,
263
-      snConfig: this.validateForm.value.snConfig,
264
-      codeType: this.validateForm.value.codeType ? { id: this.validateForm.value.codeType } : undefined,
265
-      hosId: this.hosId,
292
+    let postData:any = {
293
+      count: this.validateGenerateForm.value.count,
294
+      date: this.validateGenerateForm.value.date ? format(this.validateGenerateForm.value.date, 'yyyy-MM-dd HH:mm:ss') : undefined,
295
+      id: this.coopData.id,
266 296
     };
267
-    if (!this.add) {
268
-      data = {...data, ...this.coopData};
269
-    }
270 297
     this.mainService
271
-      .simplePost("addData", "precastCode", data)
298
+      .coopWorkerOrder("generatePrecastCode", postData)
272 299
       .subscribe((data) => {
273 300
         this.btnLoading = false;
274
-        this.hideModal();
275
-        this.initForm();
276
-        if (data.status == 200) {
277
-          this.showPromptModal(this.add ? "新增" : "编辑", true, "");
301
+        this.hideGenerateModal();
302
+        this.initGenerateForm();
303
+        if (data.state == 200) {
304
+          this.codeList = data.data || [];
305
+          // 打印
306
+          setTimeout(()=>{
307
+            this.printBtn.nativeElement.click();
308
+          }, )
278 309
         } else {
279
-          this.showPromptModal(this.add ? "新增" : "编辑", false, data.msg);
310
+          this.showPromptModal("生成", false, data.msg);
280 311
         }
281 312
       });
282 313
   }

+ 3 - 1
src/app/views/barcode-prefabrication/barcode-prefabrication.module.ts

@@ -4,6 +4,7 @@ import { CommonModule } from '@angular/common';
4 4
 import { BarcodePrefabricationRoutingModule } from './barcode-prefabrication-routing.module';
5 5
 import { BarcodePrefabricationComponent } from './barcode-prefabrication.component';
6 6
 import { ShareModule } from 'src/app/share/share.module';
7
+import { NgxPrintModule } from 'ngx-print';
7 8
 
8 9
 
9 10
 @NgModule({
@@ -13,7 +14,8 @@ import { ShareModule } from 'src/app/share/share.module';
13 14
   imports: [
14 15
     CommonModule,
15 16
     BarcodePrefabricationRoutingModule,
16
-    ShareModule
17
+    ShareModule,
18
+    NgxPrintModule,
17 19
   ]
18 20
 })
19 21
 export class BarcodePrefabricationModule { }

+ 2 - 2
src/app/views/serial-number-setting/serial-number-setting.component.html

@@ -70,9 +70,9 @@
70 70
         <nz-form-item>
71 71
           <nz-form-label [nzSm]="6" [nzXs]="24" nzRequired nzFor="length">自增长位数</nz-form-label>
72 72
           <nz-form-control nzErrorTip="请填写自增长位数!">
73
-            <nz-input-group>
73
+            <div style="margin-top: 15px;">
74 74
               <nz-input-number nz-input formControlName="length" nzPlaceHolder="请填写自增长位数" [nzMin]="1" [nzStep]="1" [nzPrecision]="0"></nz-input-number>
75
-            </nz-input-group>
75
+            </div>
76 76
           </nz-form-control>
77 77
         </nz-form-item>
78 78
         <nz-form-item>

+ 0 - 1
src/app/views/serial-number-setting/serial-number-setting.component.less

@@ -42,7 +42,6 @@
42 42
       margin-top: 12px;
43 43
 
44 44
       div {
45
-        text-align: center;
46 45
         margin: 0;
47 46
 
48 47
         &.icon {