|
|
@ -1,57 +1,68 @@ |
|
|
|
import { Component, OnInit, ViewContainerRef } from '@angular/core'; |
|
|
|
import { Component, OnInit, ViewContainerRef } from "@angular/core"; |
|
|
|
import { FormBuilder, FormGroup, Validators } from '@angular/forms'; |
|
|
|
import { FormBuilder, FormGroup, Validators } from "@angular/forms"; |
|
|
|
import { NzModalService } from 'ng-zorro-antd/modal'; |
|
|
|
import { NzModalService } from "ng-zorro-antd/modal"; |
|
|
|
import { NzMessageService } from 'ng-zorro-antd/message'; |
|
|
|
import { NzMessageService } from "ng-zorro-antd/message"; |
|
|
|
import { AddequipmentComponent } from './addequipment/addequipment.component'; |
|
|
|
import { AddequipmentComponent } from "./addequipment/addequipment.component"; |
|
|
|
import { HttpClient } from '@angular/common/http'; |
|
|
|
import { HttpClient } from "@angular/common/http"; |
|
|
|
import { EditequipmentComponent } from './editequipment/editequipment.component'; |
|
|
|
import { EditequipmentComponent } from "./editequipment/editequipment.component"; |
|
|
|
import { Router, ActivatedRoute } from '@angular/router' |
|
|
|
import { Router, ActivatedRoute } from "@angular/router"; |
|
|
|
import * as moment from 'moment'; |
|
|
|
import * as moment from "moment"; |
|
|
|
@Component({ |
|
|
|
@Component({ |
|
|
|
selector: 'app-equipment-info', |
|
|
|
selector: "app-equipment-info", |
|
|
|
templateUrl: './equipment-info.component.html', |
|
|
|
templateUrl: "./equipment-info.component.html", |
|
|
|
styleUrls: ['./equipment-info.component.scss'] |
|
|
|
styleUrls: ["./equipment-info.component.scss"], |
|
|
|
}) |
|
|
|
}) |
|
|
|
export class EquipmentInfoComponent implements OnInit { |
|
|
|
export class EquipmentInfoComponent implements OnInit { |
|
|
|
validateForm!: FormGroup; |
|
|
|
validateForm!: FormGroup; |
|
|
|
constructor(private router: Router, private fb: FormBuilder, private modal: NzModalService, private viewContainerRef: ViewContainerRef, private message: NzMessageService, private http: HttpClient) { } |
|
|
|
constructor( |
|
|
|
arr = [] |
|
|
|
private router: Router, |
|
|
|
|
|
|
|
private fb: FormBuilder, |
|
|
|
|
|
|
|
private modal: NzModalService, |
|
|
|
|
|
|
|
private viewContainerRef: ViewContainerRef, |
|
|
|
|
|
|
|
private message: NzMessageService, |
|
|
|
|
|
|
|
private http: HttpClient |
|
|
|
|
|
|
|
) {} |
|
|
|
|
|
|
|
arr = []; |
|
|
|
ngOnInit(): void { |
|
|
|
ngOnInit(): void { |
|
|
|
this.validateForm = this.fb.group({ |
|
|
|
this.validateForm = this.fb.group({ |
|
|
|
search: [null] |
|
|
|
search: [null], |
|
|
|
}); |
|
|
|
}); |
|
|
|
this.getEquipment() |
|
|
|
this.getEquipment(); |
|
|
|
// console.log(JSON.parse(sessionStorage.getItem('userdata')))
|
|
|
|
// console.log(JSON.parse(sessionStorage.getItem('userdata')))
|
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
//获取装备列表
|
|
|
|
//获取装备列表
|
|
|
|
equipmentList: any |
|
|
|
equipmentList: any; |
|
|
|
|
|
|
|
|
|
|
|
getEquipment() { |
|
|
|
getEquipment() { |
|
|
|
this.http.get('/api/services/app/FireEquipment/GetAll', { |
|
|
|
this.http |
|
|
|
|
|
|
|
.get("/api/services/app/FireEquipment/GetAll", { |
|
|
|
params: { |
|
|
|
params: { |
|
|
|
Name: this.validateForm.value.search ? this.validateForm.value.search : '', |
|
|
|
Name: this.validateForm.value.search |
|
|
|
organizationUnitId: JSON.parse(sessionStorage.getItem('userdata')).organization.id, |
|
|
|
? this.validateForm.value.search |
|
|
|
|
|
|
|
: "", |
|
|
|
|
|
|
|
organizationUnitId: JSON.parse(sessionStorage.getItem("userdata")) |
|
|
|
|
|
|
|
.organization.id, |
|
|
|
SkipCount: String(this.SkipCount), |
|
|
|
SkipCount: String(this.SkipCount), |
|
|
|
MaxResultCount: String(this.MaxResultCount) |
|
|
|
MaxResultCount: String(this.MaxResultCount), |
|
|
|
} |
|
|
|
}, |
|
|
|
}).subscribe((data: any) => { |
|
|
|
|
|
|
|
console.log('装备列表', data) |
|
|
|
|
|
|
|
this.equipmentList = data.result.items |
|
|
|
|
|
|
|
this.equipmentNum = data.result.totalCount |
|
|
|
|
|
|
|
}) |
|
|
|
}) |
|
|
|
|
|
|
|
.subscribe((data: any) => { |
|
|
|
|
|
|
|
console.log("装备列表", data); |
|
|
|
|
|
|
|
this.equipmentList = data.result.items; |
|
|
|
|
|
|
|
this.equipmentNum = data.result.totalCount; |
|
|
|
|
|
|
|
}); |
|
|
|
} |
|
|
|
} |
|
|
|
SkipCount: number = 0 //0 16 32 48
|
|
|
|
SkipCount: number = 0; //0 16 32 48
|
|
|
|
MaxResultCount: number = 16 |
|
|
|
MaxResultCount: number = 16; |
|
|
|
equipmentNum: string |
|
|
|
equipmentNum: string; |
|
|
|
pageChange($event) { |
|
|
|
pageChange($event) { |
|
|
|
this.SkipCount = ($event - 1) * this.MaxResultCount |
|
|
|
this.SkipCount = ($event - 1) * this.MaxResultCount; |
|
|
|
this.getEquipment() |
|
|
|
this.getEquipment(); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
submitForm() { |
|
|
|
submitForm() { |
|
|
|
this.getEquipment() |
|
|
|
this.getEquipment(); |
|
|
|
} |
|
|
|
} |
|
|
|
add() { |
|
|
|
add() { |
|
|
|
const modal = this.modal.create({ |
|
|
|
const modal = this.modal.create({ |
|
|
@ -59,109 +70,128 @@ export class EquipmentInfoComponent implements OnInit { |
|
|
|
nzViewContainerRef: this.viewContainerRef, |
|
|
|
nzViewContainerRef: this.viewContainerRef, |
|
|
|
nzWidth: 380, |
|
|
|
nzWidth: 380, |
|
|
|
nzBodyStyle: { |
|
|
|
nzBodyStyle: { |
|
|
|
'border': '1px solid #91CCFF', |
|
|
|
border: "1px solid #91CCFF", |
|
|
|
'border-radius': '0px', |
|
|
|
"border-radius": "0px", |
|
|
|
'padding': '7px', |
|
|
|
padding: "7px", |
|
|
|
'box-shadow': '0 0 8px 0 #fff', |
|
|
|
"box-shadow": "0 0 8px 0 #fff", |
|
|
|
'background-image': 'linear-gradient(#003665, #000f25)' |
|
|
|
"background-image": "linear-gradient(#003665, #000f25)", |
|
|
|
}, |
|
|
|
}, |
|
|
|
nzComponentParams: {}, |
|
|
|
nzComponentParams: {}, |
|
|
|
nzFooter: null, |
|
|
|
nzFooter: null, |
|
|
|
nzClosable: false, |
|
|
|
nzClosable: false, |
|
|
|
|
|
|
|
nzMaskClosable: false, |
|
|
|
nzOnOk: async () => { |
|
|
|
nzOnOk: async () => { |
|
|
|
if (instance.validateForm.valid) { |
|
|
|
if (instance.validateForm.valid) { |
|
|
|
await new Promise(resolve => { |
|
|
|
await new Promise((resolve) => { |
|
|
|
let body = { |
|
|
|
let body = { |
|
|
|
name: instance.validateForm.value.name, |
|
|
|
name: instance.validateForm.value.name, |
|
|
|
storageLocation: instance.validateForm.value.storageLocation, |
|
|
|
storageLocation: instance.validateForm.value.storageLocation, |
|
|
|
productionDate: moment(instance.validateForm.value.productionDate).format('yyyy-MM-DD'), |
|
|
|
productionDate: moment( |
|
|
|
maintenanceDate: moment(instance.validateForm.value.maintenanceDate).format('yyyy-MM-DD'), |
|
|
|
instance.validateForm.value.productionDate |
|
|
|
validityEndTime: moment(instance.validateForm.value.validityEndTime).format('yyyy-MM-DD'), |
|
|
|
).format("yyyy-MM-DD"), |
|
|
|
organizationUnitId: JSON.parse(sessionStorage.getItem('userdata')).organization.id |
|
|
|
maintenanceDate: moment( |
|
|
|
} |
|
|
|
instance.validateForm.value.maintenanceDate |
|
|
|
this.http.post('/api/services/app/FireEquipment/Create', body).subscribe(data => { |
|
|
|
).format("yyyy-MM-DD"), |
|
|
|
resolve(data) |
|
|
|
validityEndTime: moment( |
|
|
|
this.message.create('success', '创建成功!'); |
|
|
|
instance.validateForm.value.validityEndTime |
|
|
|
return true |
|
|
|
).format("yyyy-MM-DD"), |
|
|
|
}) |
|
|
|
organizationUnitId: JSON.parse(sessionStorage.getItem("userdata")) |
|
|
|
}) |
|
|
|
.organization.id, |
|
|
|
|
|
|
|
}; |
|
|
|
|
|
|
|
this.http |
|
|
|
|
|
|
|
.post("/api/services/app/FireEquipment/Create", body) |
|
|
|
|
|
|
|
.subscribe((data) => { |
|
|
|
|
|
|
|
resolve(data); |
|
|
|
|
|
|
|
this.message.create("success", "创建成功!"); |
|
|
|
|
|
|
|
return true; |
|
|
|
|
|
|
|
}); |
|
|
|
|
|
|
|
}); |
|
|
|
} else { |
|
|
|
} else { |
|
|
|
this.message.create('warning', '请填写完整!'); |
|
|
|
this.message.create("warning", "请填写完整!"); |
|
|
|
return false |
|
|
|
return false; |
|
|
|
} |
|
|
|
} |
|
|
|
}, |
|
|
|
}, |
|
|
|
}); |
|
|
|
}); |
|
|
|
modal.afterClose.subscribe(result => this.getEquipment()); |
|
|
|
modal.afterClose.subscribe((result) => this.getEquipment()); |
|
|
|
const instance = modal.getContentComponent(); |
|
|
|
const instance = modal.getContentComponent(); |
|
|
|
} |
|
|
|
} |
|
|
|
edit(item) { |
|
|
|
edit(item) { |
|
|
|
console.log('xxxxx', item) |
|
|
|
console.log("xxxxx", item); |
|
|
|
const modal = this.modal.create({ |
|
|
|
const modal = this.modal.create({ |
|
|
|
nzContent: EditequipmentComponent, |
|
|
|
nzContent: EditequipmentComponent, |
|
|
|
nzViewContainerRef: this.viewContainerRef, |
|
|
|
nzViewContainerRef: this.viewContainerRef, |
|
|
|
nzWidth: 380, |
|
|
|
nzWidth: 380, |
|
|
|
nzBodyStyle: { |
|
|
|
nzBodyStyle: { |
|
|
|
'border': '1px solid #91CCFF', |
|
|
|
border: "1px solid #91CCFF", |
|
|
|
'border-radius': '0px', |
|
|
|
"border-radius": "0px", |
|
|
|
'padding': '7px', |
|
|
|
padding: "7px", |
|
|
|
'box-shadow': '0 0 8px 0 #fff', |
|
|
|
"box-shadow": "0 0 8px 0 #fff", |
|
|
|
'background-image': 'linear-gradient(#003665, #000f25)' |
|
|
|
"background-image": "linear-gradient(#003665, #000f25)", |
|
|
|
}, |
|
|
|
}, |
|
|
|
nzComponentParams: { |
|
|
|
nzComponentParams: { |
|
|
|
data: item |
|
|
|
data: item, |
|
|
|
}, |
|
|
|
}, |
|
|
|
nzFooter: null, |
|
|
|
nzFooter: null, |
|
|
|
nzClosable: false, |
|
|
|
nzClosable: false, |
|
|
|
|
|
|
|
nzMaskClosable: false, |
|
|
|
nzOnOk: async () => { |
|
|
|
nzOnOk: async () => { |
|
|
|
if (instance.validateForm.valid) { |
|
|
|
if (instance.validateForm.valid) { |
|
|
|
await new Promise(resolve => { |
|
|
|
await new Promise((resolve) => { |
|
|
|
let body = { |
|
|
|
let body = { |
|
|
|
id: item.id, |
|
|
|
id: item.id, |
|
|
|
name: instance.validateForm.value.name, |
|
|
|
name: instance.validateForm.value.name, |
|
|
|
storageLocation: instance.validateForm.value.storageLocation, |
|
|
|
storageLocation: instance.validateForm.value.storageLocation, |
|
|
|
productionDate: moment(instance.validateForm.value.productionDate).format('yyyy-MM-DD'), |
|
|
|
productionDate: moment( |
|
|
|
maintenanceDate: moment(instance.validateForm.value.maintenanceDate).format('yyyy-MM-DD'), |
|
|
|
instance.validateForm.value.productionDate |
|
|
|
validityEndTime: moment(instance.validateForm.value.validityEndTime).format('yyyy-MM-DD'), |
|
|
|
).format("yyyy-MM-DD"), |
|
|
|
organizationUnitId: item.organizationUnitId |
|
|
|
maintenanceDate: moment( |
|
|
|
} |
|
|
|
instance.validateForm.value.maintenanceDate |
|
|
|
this.http.put('/api/services/app/FireEquipment/Update', body).subscribe(data => { |
|
|
|
).format("yyyy-MM-DD"), |
|
|
|
resolve(data) |
|
|
|
validityEndTime: moment( |
|
|
|
this.message.create('success', '修改成功!'); |
|
|
|
instance.validateForm.value.validityEndTime |
|
|
|
return true |
|
|
|
).format("yyyy-MM-DD"), |
|
|
|
}) |
|
|
|
organizationUnitId: item.organizationUnitId, |
|
|
|
}) |
|
|
|
}; |
|
|
|
|
|
|
|
this.http |
|
|
|
|
|
|
|
.put("/api/services/app/FireEquipment/Update", body) |
|
|
|
|
|
|
|
.subscribe((data) => { |
|
|
|
|
|
|
|
resolve(data); |
|
|
|
|
|
|
|
this.message.create("success", "修改成功!"); |
|
|
|
|
|
|
|
return true; |
|
|
|
|
|
|
|
}); |
|
|
|
|
|
|
|
}); |
|
|
|
} else { |
|
|
|
} else { |
|
|
|
this.message.create('warning', '请填写完整!'); |
|
|
|
this.message.create("warning", "请填写完整!"); |
|
|
|
return false |
|
|
|
return false; |
|
|
|
} |
|
|
|
|
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
}, |
|
|
|
}); |
|
|
|
}); |
|
|
|
const instance = modal.getContentComponent(); |
|
|
|
const instance = modal.getContentComponent(); |
|
|
|
modal.afterClose.subscribe(result => this.getEquipment()); |
|
|
|
modal.afterClose.subscribe((result) => this.getEquipment()); |
|
|
|
} |
|
|
|
} |
|
|
|
delete(item) { |
|
|
|
delete(item) { |
|
|
|
this.modal.confirm({ |
|
|
|
this.modal.confirm({ |
|
|
|
nzTitle: `确定要删除${item.name}这个器材吗?`, |
|
|
|
nzTitle: `确定要删除${item.name}这个器材吗?`, |
|
|
|
nzOkText: '确定', |
|
|
|
nzOkText: "确定", |
|
|
|
nzOkType: 'primary', |
|
|
|
nzOkType: "primary", |
|
|
|
nzOnOk: () => { |
|
|
|
nzOnOk: () => { |
|
|
|
this.http.delete('/api/services/app/FireEquipment/Delete', { |
|
|
|
this.http |
|
|
|
|
|
|
|
.delete("/api/services/app/FireEquipment/Delete", { |
|
|
|
params: { |
|
|
|
params: { |
|
|
|
Id: item.id |
|
|
|
Id: item.id, |
|
|
|
} |
|
|
|
}, |
|
|
|
}).subscribe(data => { |
|
|
|
|
|
|
|
this.message.create('success', '删除成功!'); |
|
|
|
|
|
|
|
this.getEquipment() |
|
|
|
|
|
|
|
}) |
|
|
|
}) |
|
|
|
|
|
|
|
.subscribe((data) => { |
|
|
|
|
|
|
|
this.message.create("success", "删除成功!"); |
|
|
|
|
|
|
|
this.getEquipment(); |
|
|
|
|
|
|
|
}); |
|
|
|
}, |
|
|
|
}, |
|
|
|
nzCancelText: '取消', |
|
|
|
nzCancelText: "取消", |
|
|
|
nzOnCancel: () => { |
|
|
|
nzOnCancel: () => {}, |
|
|
|
|
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
}); |
|
|
|
}); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
goback() { |
|
|
|
goback() { |
|
|
|
this.router.navigate(['/todaywarning/petrolStation']) |
|
|
|
this.router.navigate(["/todaywarning/petrolStation"]); |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|