|
@@ -20,6 +20,7 @@ import { HttpEventType, HttpEvent, HttpRequest, HttpResponse, HttpClient } from
|
20
|
20
|
styleUrls: ["./repository-manage-add.component.less"],
|
21
|
21
|
})
|
22
|
22
|
export class RepositoryManageAddComponent implements OnInit {
|
|
23
|
+ currentHospital; //当前院区
|
23
|
24
|
@ViewChild("osComponentRef1", {
|
24
|
25
|
read: OverlayScrollbarsComponent,
|
25
|
26
|
static: false,
|
|
@@ -41,16 +42,23 @@ export class RepositoryManageAddComponent implements OnInit {
|
41
|
42
|
this.getProduct(e[0]);
|
42
|
43
|
});
|
43
|
44
|
this.detailId = this.route.snapshot.params.id;
|
|
45
|
+ this.optType = this.route.snapshot.queryParams.type //upgrade:升级
|
44
|
46
|
if(this.detailId==0){
|
45
|
|
- this.add = true
|
|
47
|
+ this.add = true //新增
|
46
|
48
|
}else{
|
47
|
|
- this.add = false
|
|
49
|
+ this.add = false //编辑
|
48
|
50
|
}
|
|
51
|
+ this.getDicData()
|
49
|
52
|
this.hosId = this.tool.getCurrentHospital().id;
|
50
|
53
|
this.coopBtns = this.tool.initCoopBtns(this.route);
|
|
54
|
+ this.currentHospital = this.tool.getCurrentHospital();
|
51
|
55
|
this.initForm();
|
52
|
56
|
this.getAllHospital();
|
53
|
57
|
}
|
|
58
|
+ detailData:any;
|
|
59
|
+ solutionNumber;
|
|
60
|
+ versionNumber;
|
|
61
|
+ optType:null;
|
54
|
62
|
classItem:null;
|
55
|
63
|
detailId:null; //列表数据
|
56
|
64
|
deptId:null; //选中的科室id
|
|
@@ -79,6 +87,7 @@ export class RepositoryManageAddComponent implements OnInit {
|
79
|
87
|
btnLoading1: boolean = false; //确认按钮loading状态
|
80
|
88
|
btnLoading2: boolean = false; //确认按钮loading状态
|
81
|
89
|
printLoading: boolean = false; //批量打印按钮loading状态
|
|
90
|
+ isSpinning: boolean = false; //页面loading状态
|
82
|
91
|
deptPhones: any = []; //新添加的科室电话列表
|
83
|
92
|
isAddDeptsPhone = true; //添加新的科室电话是否禁用
|
84
|
93
|
deptsPhoneId = 1; //科室电话自增id
|
|
@@ -96,148 +105,73 @@ export class RepositoryManageAddComponent implements OnInit {
|
96
|
105
|
// 初始化增删改按钮
|
97
|
106
|
coopBtns: any = {};
|
98
|
107
|
deptName:null;
|
|
108
|
+ detailContent:null;
|
99
|
109
|
//搜索父级科室
|
100
|
110
|
isDeptLoading = false;
|
101
|
|
- isSpinning = false;
|
102
|
111
|
delGrantModal = false;
|
103
|
112
|
showInsp = false;
|
104
|
113
|
changeInp(e, type) {
|
105
|
114
|
this.searchParentDeptSubject.next([e, type]);
|
106
|
115
|
}
|
107
|
116
|
|
108
|
|
- // 表格数据
|
109
|
|
- loading1 = false;
|
110
|
|
- getList() {
|
111
|
|
- var that = this;
|
112
|
|
- let data = {
|
113
|
|
- idx: 0,
|
114
|
|
- sum: 9999,
|
115
|
|
- drugsConfigure: {
|
116
|
|
- hosId: this.hosId,
|
117
|
|
- deptId :this.deptId?this.deptId:null,
|
118
|
|
- batchId: this.detailId
|
119
|
|
- }
|
120
|
|
- };
|
121
|
|
- this.loading1 = true;
|
122
|
|
- that.mainService
|
123
|
|
- .getFetchDataList("data", "drugsConfigure", data)
|
124
|
|
- .subscribe((data) => {
|
125
|
|
- this.loading1 = false;
|
126
|
|
- that.listOfData = data.list;
|
127
|
|
- });
|
128
|
|
- }
|
129
|
|
-
|
130
|
|
- // 发药科室列表
|
131
|
|
- getDispensingDept(e,type){
|
|
117
|
+ // 获取详情
|
|
118
|
+ getDetail(){
|
|
119
|
+ this.isSpinning = true
|
132
|
120
|
var that = this;
|
133
|
|
- let data = {
|
134
|
|
- idx: 0,
|
135
|
|
- sum: 9999,
|
136
|
|
- drugsConfigure: {
|
137
|
|
- hosId: this.hosId,
|
138
|
|
- deptId :e,
|
139
|
|
- batchId:''
|
|
121
|
+ let query = {
|
|
122
|
+ idx: that.pageIndex - 1,
|
|
123
|
+ sum: that.pageSize,
|
|
124
|
+ solution: {
|
|
125
|
+ hosId: this.hosId,
|
|
126
|
+ id:this.detailId,
|
|
127
|
+ operationType:'lookOver',
|
140
|
128
|
}
|
141
|
129
|
};
|
142
|
|
- if(type=='dept'){
|
143
|
|
- data.drugsConfigure.batchId = this.detailId
|
144
|
|
- }else{
|
145
|
|
- delete data.drugsConfigure.batchId
|
146
|
|
- }
|
147
|
|
- let deptData = this.hospitals1.find(i=>i.id==e)
|
|
130
|
+
|
148
|
131
|
that.mainService
|
149
|
|
- .getFetchDataList("data", "drugsConfigure", data)
|
150
|
|
- .subscribe((res) => {
|
151
|
|
- if(res.list.length==0){
|
152
|
|
- this.message.error(`您选择的科室“ ${deptData.dept}”时间段内没有消耗药品无法添加发药单。`)
|
153
|
|
- }else{
|
154
|
|
- this.getDeptData(e,'all','load')
|
|
132
|
+ .getFetchDataList("data", "solution", query)
|
|
133
|
+ .subscribe((res) => {
|
|
134
|
+ this.getFile()
|
|
135
|
+ let data = res.list[0]
|
|
136
|
+ this.detailData = data
|
|
137
|
+ this.solutionNumber = data.solutionNumber
|
|
138
|
+ this.versionNumber = data.versionNumber
|
|
139
|
+ this.detailContent = data.content || ''
|
|
140
|
+ let item = this.dicData.find(i=>i.id == this.detailData.type.id)
|
|
141
|
+ if(item){
|
|
142
|
+ this.classItem = item.value
|
155
|
143
|
}
|
156
|
|
- });
|
157
|
|
- }
|
158
|
|
-
|
159
|
|
- // 科室点击
|
160
|
|
- deptClick(e,item,index){
|
161
|
|
- e.stopPropagation();
|
162
|
|
- this.deptId = item.applyDeptDTO.id
|
163
|
|
- this.deptName = item.applyDeptDTO.dept
|
164
|
|
- this.deptIndex = index
|
165
|
|
- this.getList()
|
166
|
|
- }
|
167
|
|
-
|
168
|
|
- // 科室删除
|
169
|
|
- deptDel(e,item,index){
|
170
|
|
- e.stopPropagation();
|
171
|
|
- this.delModal = true;
|
172
|
|
- this.coopId = item.applyDept;
|
173
|
|
- }
|
174
|
|
-
|
175
|
|
- hideDelModal() {
|
176
|
|
- this.delModal = false;
|
177
|
|
- }
|
178
|
|
-
|
179
|
|
- // 选择楼栋
|
180
|
|
- buildingChange(e){
|
181
|
|
- this.deptId = null
|
182
|
|
- this.deptName = null
|
183
|
|
- this.deptIndex = null
|
184
|
|
- this.listOfData=[]
|
185
|
|
- this.showInsp = true
|
186
|
|
- this.getDeptData(e,'','')
|
187
|
|
- }
|
188
|
|
-
|
189
|
|
- // 根据楼栋查询科室
|
190
|
|
- getDeptData(e,type,initial){
|
191
|
|
- var that = this;
|
192
|
|
- let data = {
|
193
|
|
- idx: 0,
|
194
|
|
- sum: 99999,
|
195
|
|
- drugsList: {
|
196
|
|
- hosId: this.hosId,
|
197
|
|
- buildingId:e,
|
198
|
|
- batch:{
|
199
|
|
- id:this.detailId
|
|
144
|
+ this.validateForm.controls.title.setValue(data.title || '');
|
|
145
|
+ this.validateForm.controls.content.setValue(data.content || '');
|
|
146
|
+ this.validateForm.controls.repairVisible.setValue(data.repairVisible+'' || '');
|
|
147
|
+ this.validateForm.controls.knowledgeClass.setValue(data.type.id || '');
|
|
148
|
+ if(data.inspectionForm){
|
|
149
|
+ this.validateForm.controls.polling.setValue(data.inspectionForm.id || '');
|
200
|
150
|
}
|
201
|
|
- },
|
202
|
|
- };
|
203
|
|
- if(type=='all'){
|
204
|
|
- delete data.drugsList.buildingId
|
205
|
|
- }else{
|
206
|
|
- data.drugsList.buildingId = e
|
207
|
|
- }
|
208
|
|
- if(this.showInsp){
|
209
|
|
- this.isSpinning = true
|
210
|
|
- }
|
211
|
|
- that.mainService
|
212
|
|
- .getFetchDataList("data", "drugsList", data)
|
213
|
|
- .subscribe((res) => {
|
|
151
|
+ this.validateForm.controls.assetProductId.setValue(data.assetProductId || '');
|
214
|
152
|
this.isSpinning = false
|
215
|
|
- that.deptList = res.list;
|
216
|
|
- if(initial=='load'){
|
217
|
|
- if(res.list.length>0){
|
218
|
|
- this.deptId = res.list[0].applyDeptDTO.id
|
219
|
|
- this.deptName = res.list[0].applyDeptDTO.dept
|
220
|
|
- this.deptIndex = 0
|
221
|
|
- }
|
222
|
|
- this.getList()
|
|
153
|
+ });
|
|
154
|
+ }
|
|
155
|
+ fileAllData=null;
|
|
156
|
+ getFile(){
|
|
157
|
+ this.mainService
|
|
158
|
+ .getPreviewImage('solution', this.detailId)
|
|
159
|
+ .subscribe((res:any)=> {
|
|
160
|
+ if(res.data.length>0){
|
|
161
|
+ this.fileAllData = res.data
|
|
162
|
+ this.fileData = res.data.map(i=>{
|
|
163
|
+ return{
|
|
164
|
+ uid:i.id,
|
|
165
|
+ name:i.name,
|
|
166
|
+ token:i.token
|
|
167
|
+ }
|
|
168
|
+ })
|
223
|
169
|
}
|
224
|
|
- });
|
|
170
|
+ });
|
225
|
171
|
}
|
226
|
172
|
|
227
|
|
- // 选择科室
|
228
|
|
- addDeptId=''
|
229
|
|
- deptChange(e){
|
230
|
|
- this.addDeptId = e
|
231
|
|
-
|
232
|
|
- }
|
233
|
|
- // 添加科室
|
234
|
|
- addDept(){
|
235
|
|
- if(this.addDeptId){
|
236
|
|
- this.showInsp = true
|
237
|
|
- this.getDispensingDept(this.addDeptId,'dept')
|
238
|
|
- }else{
|
239
|
|
- this.message.error('请先选择发药科室')
|
240
|
|
- }
|
|
173
|
+ hideDelModal() {
|
|
174
|
+ this.delModal = false;
|
241
|
175
|
}
|
242
|
176
|
|
243
|
177
|
// 获取产品
|
|
@@ -258,40 +192,34 @@ export class RepositoryManageAddComponent implements OnInit {
|
258
|
192
|
});
|
259
|
193
|
}
|
260
|
194
|
|
261
|
|
- // 获取所有科室
|
262
|
|
- getDeparts() {
|
263
|
|
- let data = {
|
264
|
|
- batchId:this.detailId
|
265
|
|
- };
|
266
|
|
- this.mainService
|
267
|
|
- .getConsumeDept(data)
|
268
|
|
- .subscribe((res) => {
|
269
|
|
- this.hospitals1 = res.data
|
270
|
|
- });
|
271
|
|
- }
|
272
|
|
-
|
273
|
195
|
// 获取所有院区
|
274
|
196
|
getAllHospital() {
|
275
|
197
|
this.getPolling()
|
276
|
198
|
this.getProduct('')
|
277
|
199
|
this.getMalfunction()
|
278
|
|
- this.getDicData()
|
279
|
200
|
}
|
280
|
201
|
|
281
|
202
|
// 获取故障现象数据
|
282
|
203
|
getMalfunction(){
|
|
204
|
+ if(!this.currentHospital.type || (this.currentHospital.type && this.currentHospital.type.value !== '6')){
|
|
205
|
+ this.malfunctionData = [];
|
|
206
|
+ return;
|
|
207
|
+ };
|
283
|
208
|
let postData = {
|
284
|
|
- building: {
|
285
|
|
- cascadeHosId: this.hosId,
|
|
209
|
+ category: {
|
|
210
|
+ dutyIds: this.currentHospital.type.value === '6' ? this.currentHospital.id.toString() : undefined,
|
286
|
211
|
},
|
287
|
|
- idx: 0,
|
288
|
|
- sum: 20,
|
289
|
212
|
};
|
290
|
|
- this.mainService
|
291
|
|
- .getFetchDataList("data", "building", postData)
|
292
|
|
- .subscribe((result) => {
|
293
|
|
- this.malfunctionData = result.data
|
294
|
|
- });
|
|
213
|
+ this.mainService.incidentPost("listIncidentCategory", postData).subscribe(res => {
|
|
214
|
+ let incidentCategoryList = res.data || [];
|
|
215
|
+ incidentCategoryList = incidentCategoryList.map(v => ({...v, parentId: v.parent ? v.parent.id : undefined, label: v.category, value: v.id}));
|
|
216
|
+ this.malfunctionData = this.tool.tranListToTreeDataLeaf(incidentCategoryList, undefined, "parentId");
|
|
217
|
+
|
|
218
|
+ if(this.detailData && this.detailData.categoryId){
|
|
219
|
+ let malfunctionId = this.tool.tranListToTreeDataFindIdsLeaf(this.malfunctionData,this.detailData.categoryId);
|
|
220
|
+ this.validateForm.controls.malfunction.setValue(malfunctionId);
|
|
221
|
+ }
|
|
222
|
+ })
|
295
|
223
|
}
|
296
|
224
|
|
297
|
225
|
// 获取巡检列表
|
|
@@ -318,6 +246,12 @@ export class RepositoryManageAddComponent implements OnInit {
|
318
|
246
|
getDicData(){
|
319
|
247
|
this.mainService.getDictionary("list", "solution_type").subscribe((res) => {
|
320
|
248
|
this.dicData = res
|
|
249
|
+ if(!this.add){
|
|
250
|
+ this.getDetail()
|
|
251
|
+ }
|
|
252
|
+ if(this.optType=='upgrade'){
|
|
253
|
+ this.getDetail()
|
|
254
|
+ }
|
321
|
255
|
});
|
322
|
256
|
this.mainService.getDictionary("list", "solution_status").subscribe((res) => {
|
323
|
257
|
this.typeDic = res
|
|
@@ -327,29 +261,15 @@ export class RepositoryManageAddComponent implements OnInit {
|
327
|
261
|
// 选择知识库分类
|
328
|
262
|
radioChnage(e){
|
329
|
263
|
let item = this.dicData.find(i=>i.id == this.validateForm.value.knowledgeClass)
|
330
|
|
- this.classItem = item.value
|
|
264
|
+ if(item){
|
|
265
|
+ this.classItem = item.value
|
|
266
|
+ }
|
331
|
267
|
}
|
332
|
268
|
|
333
|
|
-
|
334
|
|
-
|
335
|
269
|
hideGrantModal(){
|
336
|
270
|
this.delGrantModal = false;
|
337
|
271
|
}
|
338
|
272
|
|
339
|
|
- // 增加/减少
|
340
|
|
- rowData = null;
|
341
|
|
- itemClick(e, data, type){
|
342
|
|
- e.stopPropagation();
|
343
|
|
- this.rowId = data.id
|
344
|
|
- this.rowData = data
|
345
|
|
- if(type=='add'){
|
346
|
|
- this.add = true
|
347
|
|
- }else{
|
348
|
|
- this.add = false
|
349
|
|
- }
|
350
|
|
- this.modal = true
|
351
|
|
- this.initForm();
|
352
|
|
- }
|
353
|
273
|
|
354
|
274
|
// 富文本内容
|
355
|
275
|
editOrData=null;
|
|
@@ -365,19 +285,51 @@ export class RepositoryManageAddComponent implements OnInit {
|
365
|
285
|
that.validateForm.controls[i].updateValueAndValidity();
|
366
|
286
|
}
|
367
|
287
|
if (that.validateForm.invalid) return;
|
|
288
|
+
|
|
289
|
+ if(this.classItem==1){
|
|
290
|
+ if(!this.validateForm.value.malfunction){
|
|
291
|
+ this.message.error(`请选择关联故障现象`)
|
|
292
|
+ return
|
|
293
|
+ }
|
|
294
|
+ }else if(this.classItem==2){
|
|
295
|
+ if(!this.validateForm.value.polling){
|
|
296
|
+ this.message.error(`请选择关联巡检表`)
|
|
297
|
+ return
|
|
298
|
+ }
|
|
299
|
+ }
|
|
300
|
+ let operationType = null
|
|
301
|
+ if(this.optType=='edit'){
|
|
302
|
+ operationType = 'edit'
|
|
303
|
+ }else if(this.optType=='upgrade'){
|
|
304
|
+ operationType = 'upgrade'
|
|
305
|
+ }
|
368
|
306
|
let data = {
|
369
|
|
- ...this.validateForm.value,
|
|
307
|
+ title:this.validateForm.value.title,
|
|
308
|
+ repairVisible:this.validateForm.value.repairVisible,
|
370
|
309
|
content:this.editOrData,
|
371
|
310
|
id:'',
|
372
|
311
|
hosId:this.hosId,
|
373
|
312
|
inspectionForm:{
|
374
|
|
- id:this.validateForm.value.polling
|
|
313
|
+ id:'' //巡检
|
375
|
314
|
},
|
376
|
315
|
type:{
|
377
|
316
|
id:this.validateForm.value.knowledgeClass
|
378
|
317
|
},
|
379
|
|
- buttonType:type==1?'confirm':'ts'
|
|
318
|
+ assetProductId:this.validateForm.value.assetProductId,
|
|
319
|
+ categoryId:'', //故障
|
|
320
|
+ buttonType:type==1?'confirm':'ts',
|
|
321
|
+ operationType: operationType
|
380
|
322
|
};
|
|
323
|
+ if(this.classItem==1){
|
|
324
|
+ data.categoryId = this.validateForm.value.malfunction[2]
|
|
325
|
+ delete data.inspectionForm
|
|
326
|
+ }else if(this.classItem==2){
|
|
327
|
+ data.inspectionForm.id = this.validateForm.value.polling
|
|
328
|
+ delete data.categoryId
|
|
329
|
+ }else{
|
|
330
|
+ delete data.inspectionForm
|
|
331
|
+ delete data.categoryId
|
|
332
|
+ }
|
381
|
333
|
if(this.add){
|
382
|
334
|
delete data.id
|
383
|
335
|
}else{
|
|
@@ -385,31 +337,35 @@ export class RepositoryManageAddComponent implements OnInit {
|
385
|
337
|
}
|
386
|
338
|
if(type==1){
|
387
|
339
|
that.btnLoading1 = true;
|
|
340
|
+ }else if(type==2){
|
|
341
|
+ that.btnLoading2 = true;
|
388
|
342
|
}else{
|
389
|
343
|
that.btnLoading2 = true;
|
390
|
344
|
}
|
391
|
345
|
|
392
|
346
|
that.mainService
|
393
|
|
- .simplePost("addData", "solution", data)
|
|
347
|
+ .simplePost(this.add?"addData":"updData", "solution", data)
|
394
|
348
|
.subscribe((res) => {
|
395
|
349
|
if(type==1){
|
396
|
350
|
that.btnLoading1 = false;
|
|
351
|
+ }else if(type==2){
|
|
352
|
+ that.btnLoading2 = false;
|
397
|
353
|
}else{
|
398
|
354
|
that.btnLoading2 = false;
|
399
|
355
|
}
|
400
|
356
|
if(this.fileData.length>0){
|
401
|
|
- this.uploadFile(res.data.id)
|
402
|
357
|
if (res.status == 200) {
|
403
|
|
- that.showPromptModal(that.add ? "增加" : "减少", true, "");
|
|
358
|
+ this.uploadFile(res.data.id)
|
|
359
|
+ that.showPromptModal("操作", true, "");
|
404
|
360
|
} else {
|
405
|
|
- that.showPromptModal(that.add ? "增加" : "减少", false, res.msg);
|
|
361
|
+ that.showPromptModal("操作", false, res.msg);
|
406
|
362
|
}
|
407
|
363
|
that.hideModal();
|
408
|
364
|
}else{
|
409
|
365
|
if (res.status == 200) {
|
410
|
|
- that.showPromptModal(that.add ? "增加" : "减少", true, "");
|
|
366
|
+ that.showPromptModal("操作", true, "");
|
411
|
367
|
} else {
|
412
|
|
- that.showPromptModal(that.add ? "增加" : "减少", false, res.msg);
|
|
368
|
+ that.showPromptModal("操作", false, res.msg);
|
413
|
369
|
}
|
414
|
370
|
that.hideModal();
|
415
|
371
|
}
|
|
@@ -418,21 +374,27 @@ export class RepositoryManageAddComponent implements OnInit {
|
418
|
374
|
|
419
|
375
|
// 上传图片
|
420
|
376
|
uploadFile(id){
|
421
|
|
- console.log(555,this.fileData)
|
422
|
377
|
let url = `/service/common/common/uploadAttachment/solution/${id}/${id}`
|
423
|
|
-
|
424
|
|
- for(let i of this.fileData){
|
425
|
|
- console.log(54545,i)
|
426
|
|
- const formData = new FormData();
|
427
|
|
- formData.append('file', i.originFileObj);
|
428
|
|
- formData.append('filename', i.originFileObj.name);
|
429
|
|
- const req = new HttpRequest('POST', url, formData, {
|
430
|
|
- reportProgress: true,
|
431
|
|
- withCredentials: true
|
432
|
|
- });
|
433
|
|
- this.http.request(req).subscribe((res) => {
|
434
|
|
-
|
435
|
|
- });
|
|
378
|
+ for(let i of this.fileData){//新上传的附件
|
|
379
|
+ let item = this.fileAllData.find(t=>t.id == i.uid) //之前的附件
|
|
380
|
+ if(!item){
|
|
381
|
+ const formData = new FormData();
|
|
382
|
+ if(i.originFileObj){
|
|
383
|
+ formData.append('file', i.originFileObj);
|
|
384
|
+ formData.append('filename', i.originFileObj.name);
|
|
385
|
+ }else{
|
|
386
|
+ formData.append('file', i);
|
|
387
|
+ formData.append('filename', i.name);
|
|
388
|
+ }
|
|
389
|
+
|
|
390
|
+ const req = new HttpRequest('POST', url, formData, {
|
|
391
|
+ reportProgress: true,
|
|
392
|
+ withCredentials: true
|
|
393
|
+ });
|
|
394
|
+ this.http.request(req).subscribe((res) => {
|
|
395
|
+
|
|
396
|
+ });
|
|
397
|
+ }
|
436
|
398
|
}
|
437
|
399
|
}
|
438
|
400
|
|
|
@@ -448,7 +410,6 @@ export class RepositoryManageAddComponent implements OnInit {
|
448
|
410
|
}
|
449
|
411
|
|
450
|
412
|
hideModal() {
|
451
|
|
- this.initForm();
|
452
|
413
|
this.modal = false;
|
453
|
414
|
}
|
454
|
415
|
// 初始化新增form表单
|
|
@@ -459,10 +420,10 @@ export class RepositoryManageAddComponent implements OnInit {
|
459
|
420
|
version: [null, []],
|
460
|
421
|
content: [null, []],
|
461
|
422
|
assetProductId: [null,[]],
|
462
|
|
- repairVisible: [null, [Validators.required]],
|
|
423
|
+ repairVisible: ['1', [Validators.required]],
|
463
|
424
|
knowledgeClass: [null, [Validators.required]],
|
464
|
|
- polling: [null, [Validators.required]],
|
465
|
|
-
|
|
425
|
+ polling: [null,],
|
|
426
|
+ malfunction:[null,],
|
466
|
427
|
});
|
467
|
428
|
}
|
468
|
429
|
|
|
@@ -470,9 +431,9 @@ export class RepositoryManageAddComponent implements OnInit {
|
470
|
431
|
avatarUrl: string;
|
471
|
432
|
avatarUrl1: string;
|
472
|
433
|
beforeUpload = (file: File) => {
|
|
434
|
+ console.log(888,file)
|
473
|
435
|
return new Observable((observer: Observer<boolean>) => {
|
474
|
436
|
let type = file.name.split('.')
|
475
|
|
- console.log(888,type[1])
|
476
|
437
|
const isPic = (type[1] === 'xlsx' || type[1] === 'pdf' ||
|
477
|
438
|
type[1] === 'xls' || type[1] === 'ppt' || type[1] === 'txt');
|
478
|
439
|
if (!isPic) {
|
|
@@ -493,7 +454,7 @@ export class RepositoryManageAddComponent implements OnInit {
|
493
|
454
|
|
494
|
455
|
// 附件上传
|
495
|
456
|
handleChange(info: { file: UploadFile }): void {
|
496
|
|
- // console.log(999,this.fileData)
|
|
457
|
+
|
497
|
458
|
}
|
498
|
459
|
|
499
|
460
|
private getBase64(img: File, callback: (img: string) => void): void {
|
|
@@ -503,17 +464,29 @@ export class RepositoryManageAddComponent implements OnInit {
|
503
|
464
|
}
|
504
|
465
|
|
505
|
466
|
// 删除附件
|
506
|
|
- removeFile = (file: File) => {
|
|
467
|
+ removeFile = (file) => {
|
|
468
|
+ console.log(111,file)
|
|
469
|
+ let item = this.fileAllData.find(i=>i.id == file.uid)
|
|
470
|
+ let index = this.fileData.findIndex(i=>i.uid == file.uid)
|
|
471
|
+ if(item){ //附件在数据库
|
|
472
|
+ this.mainService
|
|
473
|
+ .removeAttachment(file.token)
|
|
474
|
+ .subscribe((res:any=[]) => {
|
|
475
|
+ if (res.status == 200) {
|
|
476
|
+ this.getFile()
|
|
477
|
+ }
|
|
478
|
+ });
|
|
479
|
+ }else{//附件不在数据库
|
|
480
|
+ console.log(555, index)
|
|
481
|
+ if(index!=-1){
|
|
482
|
+ this.fileData.splice(index, 1)
|
|
483
|
+ }
|
|
484
|
+ }
|
507
|
485
|
|
508
|
|
- // let index = this.fileData.findIndex(i=>i.uid==e.uid)
|
509
|
|
- // this.fileData.splice(index, 1)
|
510
|
486
|
}
|
511
|
487
|
|
512
|
488
|
// 自定义上传
|
513
|
489
|
customReq = (item: UploadXHRArgs) => {
|
514
|
|
- // this.fileData.push(item.file)
|
515
|
|
- // console.log(2222,this.fileData);
|
516
|
|
- // Create a FormData here to store files and other parameters.
|
517
|
490
|
const formData = new FormData();
|
518
|
491
|
// tslint:disable-next-line:no-any
|
519
|
492
|
formData.append('file', item.file as any);
|
|
@@ -543,6 +516,7 @@ export class RepositoryManageAddComponent implements OnInit {
|
543
|
516
|
};
|
544
|
517
|
|
545
|
518
|
closeModel(){
|
|
519
|
+ this.initForm();
|
546
|
520
|
this.back()
|
547
|
521
|
}
|
548
|
522
|
|