|
@@ -0,0 +1,219 @@
|
|
1
|
+import { Component, OnInit, ViewChild } from "@angular/core";
|
|
2
|
+import { ActivatedRoute, Router } from "@angular/router";
|
|
3
|
+import { FormBuilder, Validators, FormGroup } from "@angular/forms";
|
|
4
|
+
|
|
5
|
+import { MainService } from "../../services/main.service";
|
|
6
|
+import { OverlayScrollbarsComponent } from "overlayscrollbars-ngx";
|
|
7
|
+import { ToolService } from "../../services/tool.service";
|
|
8
|
+import { NzMessageService } from "ng-zorro-antd";
|
|
9
|
+
|
|
10
|
+@Component({
|
|
11
|
+ selector: "app-medical-waste-type",
|
|
12
|
+ templateUrl: "./medical-waste-type.component.html",
|
|
13
|
+ styleUrls: ["./medical-waste-type.component.less"],
|
|
14
|
+})
|
|
15
|
+export class MedicalWasteTypeComponent implements OnInit {
|
|
16
|
+ @ViewChild("osComponentRef1", {
|
|
17
|
+ read: OverlayScrollbarsComponent,
|
|
18
|
+ static: false,
|
|
19
|
+ })
|
|
20
|
+ osComponentRef1: OverlayScrollbarsComponent;
|
|
21
|
+ constructor(
|
|
22
|
+ private message: NzMessageService,
|
|
23
|
+ private fb: FormBuilder,
|
|
24
|
+ private route: ActivatedRoute,
|
|
25
|
+ private router: Router,
|
|
26
|
+ private mainService: MainService,
|
|
27
|
+ private tool: ToolService
|
|
28
|
+ ) {}
|
|
29
|
+
|
|
30
|
+ listOfData: any[] = []; //表格数据
|
|
31
|
+
|
|
32
|
+ modal: boolean = false; //新增/编辑模态框
|
|
33
|
+ add: boolean; //true:新增;false:编辑
|
|
34
|
+ validateForm: FormGroup; //新增/编辑表单
|
|
35
|
+ coopId: number; //表格中执行操作的id
|
|
36
|
+ hosId: any; //院区(搜索)
|
|
37
|
+ storageUnits: Array<any> = []; //所有储存单位
|
|
38
|
+ pageIndex: number = 1; //页码
|
|
39
|
+ listLength: number = 10; //总条数
|
|
40
|
+ pageSize: number = 10; //每页条数
|
|
41
|
+
|
|
42
|
+ promptContent: string; //操作提示框提示信息
|
|
43
|
+ ifSuccess: boolean; //操作成功/失败
|
|
44
|
+ promptInfo: string; //操作结果提示信息
|
|
45
|
+ promptModalShow: boolean; //操作提示框是否展示
|
|
46
|
+
|
|
47
|
+ btnLoading: boolean = false; //提交按钮loading状态
|
|
48
|
+
|
|
49
|
+ ngOnInit() {
|
|
50
|
+ this.coopBtns = this.tool.initCoopBtns(this.route);
|
|
51
|
+ this.initForm();
|
|
52
|
+ this.getStorageUnit();
|
|
53
|
+ this.getUnit();
|
|
54
|
+ }
|
|
55
|
+
|
|
56
|
+ // 初始化增删改按钮
|
|
57
|
+ coopBtns: any = {};
|
|
58
|
+ // 表格数据
|
|
59
|
+ loading1 = false;
|
|
60
|
+ getList() {
|
|
61
|
+ let data = {
|
|
62
|
+ idx: this.pageIndex - 1,
|
|
63
|
+ sum: this.pageSize,
|
|
64
|
+ clinicalWasteType: {
|
|
65
|
+ hosId: this.hosId,
|
|
66
|
+ },
|
|
67
|
+ };
|
|
68
|
+ this.loading1 = true;
|
|
69
|
+ this.mainService
|
|
70
|
+ .getFetchDataList("simple/data", "clinicalWasteType", data)
|
|
71
|
+ .subscribe((data) => {
|
|
72
|
+ this.loading1 = false;
|
|
73
|
+ this.listOfData = data.list;
|
|
74
|
+ this.listLength = data.totalNum;
|
|
75
|
+ });
|
|
76
|
+ }
|
|
77
|
+
|
|
78
|
+ // 获取所有储存单位
|
|
79
|
+ getStorageUnit() {
|
|
80
|
+ this.mainService.getDictionary("list", "storage_unit").subscribe((data) => {
|
|
81
|
+ this.storageUnits = data;
|
|
82
|
+ this.getAllHospital();
|
|
83
|
+ });
|
|
84
|
+ }
|
|
85
|
+
|
|
86
|
+ // 获取相应的院区
|
|
87
|
+ getAllHospital() {
|
|
88
|
+ this.hosId = this.tool.getCurrentHospital().id;
|
|
89
|
+ this.getList();
|
|
90
|
+ }
|
|
91
|
+
|
|
92
|
+ // 获取生成方案
|
|
93
|
+ units: Array<any> = [];
|
|
94
|
+ getUnit() {
|
|
95
|
+ var that = this;
|
|
96
|
+ that.mainService.getDictionary("list", "unit").subscribe((data) => {
|
|
97
|
+ that.units = data;
|
|
98
|
+ });
|
|
99
|
+ }
|
|
100
|
+
|
|
101
|
+ // 新增弹框
|
|
102
|
+ showModal() {
|
|
103
|
+ this.add = true;
|
|
104
|
+ this.initForm();
|
|
105
|
+ this.modal = true;
|
|
106
|
+ }
|
|
107
|
+ hideModal() {
|
|
108
|
+ this.modal = false;
|
|
109
|
+ this.initForm();
|
|
110
|
+ }
|
|
111
|
+
|
|
112
|
+ // 初始化新增form表单
|
|
113
|
+ initForm() {
|
|
114
|
+ this.validateForm = this.fb.group({
|
|
115
|
+ typeName: [null, [Validators.required]],
|
|
116
|
+ inventoryDays: [0, [Validators.required]],
|
|
117
|
+ unit: [null, [Validators.required]],
|
|
118
|
+ storageUnit: [null, [Validators.required]],
|
|
119
|
+ });
|
|
120
|
+ }
|
|
121
|
+ // 表单提交
|
|
122
|
+ submitForm(): void {
|
|
123
|
+ var that = this;
|
|
124
|
+ for (const i in that.validateForm.controls) {
|
|
125
|
+ that.validateForm.controls[i].markAsDirty({ onlySelf: true });
|
|
126
|
+ that.validateForm.controls[i].updateValueAndValidity();
|
|
127
|
+ }
|
|
128
|
+ if (that.validateForm.invalid) return;
|
|
129
|
+ that.btnLoading = true;
|
|
130
|
+ let data:any = {
|
|
131
|
+ typeName: that.validateForm.value.typeName,
|
|
132
|
+ inventoryDays: that.validateForm.value.inventoryDays,
|
|
133
|
+ unit: that.validateForm.value.unit ? { id: that.validateForm.value.unit } : undefined,
|
|
134
|
+ storageUnit: that.validateForm.value.storageUnit ? { id: that.validateForm.value.storageUnit } : undefined,
|
|
135
|
+ hosId: that.hosId,
|
|
136
|
+ };
|
|
137
|
+ if (!that.add) {
|
|
138
|
+ data = {...this.coopData, ...data};
|
|
139
|
+ }
|
|
140
|
+ that.mainService
|
|
141
|
+ .simplePost("addData", "clinicalWasteType", data)
|
|
142
|
+ .subscribe((data) => {
|
|
143
|
+ that.btnLoading = false;
|
|
144
|
+ that.hideModal();
|
|
145
|
+ that.initForm();
|
|
146
|
+ if (data.status == 200) {
|
|
147
|
+ that.showPromptModal(that.add ? "新增" : "编辑", true, "");
|
|
148
|
+ } else {
|
|
149
|
+ that.showPromptModal(that.add ? "新增" : "编辑", false, data.msg);
|
|
150
|
+ }
|
|
151
|
+ });
|
|
152
|
+ }
|
|
153
|
+
|
|
154
|
+ // 编辑
|
|
155
|
+ maskFlag: any = false;
|
|
156
|
+ coopData:any = {};
|
|
157
|
+ edit(data) {
|
|
158
|
+ this.modal = true;
|
|
159
|
+ this.add = false;
|
|
160
|
+ this.coopId = data.id;
|
|
161
|
+ this.coopData = data;
|
|
162
|
+ this.validateForm.controls.typeName.setValue(data.typeName);
|
|
163
|
+ this.validateForm.controls.inventoryDays.setValue(data.inventoryDays);
|
|
164
|
+ this.validateForm.controls.unit.setValue(data.unit.id);
|
|
165
|
+ this.validateForm.controls.storageUnit.setValue(data.storageUnit.id);
|
|
166
|
+ }
|
|
167
|
+
|
|
168
|
+ // 删除
|
|
169
|
+ delModal: boolean = false; //删除模态框
|
|
170
|
+ del(data) {
|
|
171
|
+ this.coopId = data.id;
|
|
172
|
+ this.delModal = true;
|
|
173
|
+ }
|
|
174
|
+ // 确认删除
|
|
175
|
+ confirmDel() {
|
|
176
|
+ let that = this;
|
|
177
|
+ that.btnLoading = true;
|
|
178
|
+ that.mainService
|
|
179
|
+ .simplePost("rmvData", "clinicalWasteType", [that.coopId])
|
|
180
|
+ .subscribe((data) => {
|
|
181
|
+ that.btnLoading = false;
|
|
182
|
+ that.hideDelModal();
|
|
183
|
+ if (data["status"] == 200) {
|
|
184
|
+ if (
|
|
185
|
+ that.listOfData.length == 1 &&
|
|
186
|
+ that.pageIndex == Math.ceil(that.listLength / that.pageSize)
|
|
187
|
+ ) {
|
|
188
|
+ that.listLength--;
|
|
189
|
+ that.pageIndex = Math.ceil(that.listLength / that.pageSize) || 1;
|
|
190
|
+ }
|
|
191
|
+ that.showPromptModal("删除", true, "");
|
|
192
|
+ } else {
|
|
193
|
+ that.showPromptModal("删除", false, data["msg"]);
|
|
194
|
+ }
|
|
195
|
+ });
|
|
196
|
+ }
|
|
197
|
+ // 关闭删除模态框
|
|
198
|
+ hideDelModal() {
|
|
199
|
+ this.delModal = false;
|
|
200
|
+ }
|
|
201
|
+
|
|
202
|
+ // 展示信息提示框(con:提示信息,success:操作是否成功,promptInfo:操作结果提示信息)
|
|
203
|
+ showPromptModal(con, success, promptInfo?) {
|
|
204
|
+ this.promptModalShow = false;
|
|
205
|
+ this.promptContent = con;
|
|
206
|
+ this.ifSuccess = success;
|
|
207
|
+ this.promptInfo = promptInfo;
|
|
208
|
+ setTimeout(() => {
|
|
209
|
+ this.promptModalShow = true;
|
|
210
|
+ }, 100);
|
|
211
|
+ this.getList();
|
|
212
|
+ }
|
|
213
|
+
|
|
214
|
+ // 查看
|
|
215
|
+ detail(id) {
|
|
216
|
+ this.router.navigateByUrl("/main/serialNumberSetting/serialNumberSettingDetail/" + id);
|
|
217
|
+ }
|
|
218
|
+ isLoading = false;
|
|
219
|
+}
|