Browse Source

Merge branch 'master' of http://121.36.37.70:3000/shaojiahao/Jinan_project

非煤矿山灾害智能感知和预警系统
邵佳豪 3 years ago
parent
commit
443ff3d03b
  1. 19
      src/app/home/basic-info/add-unit/add-unit.component.html
  2. 44
      src/app/home/basic-info/add-unit/add-unit.component.ts
  3. 10
      src/app/home/basic-info/unit/unit.component.html
  4. 81
      src/app/home/basic-info/unit/unit.component.ts
  5. 4
      src/app/home/system-management/or/editor/editor.component.html
  6. 15
      src/app/home/system-management/or/or.component.ts

19
src/app/home/basic-info/add-unit/add-unit.component.html

@ -37,8 +37,8 @@
<nz-form-item> <nz-form-item>
<nz-form-label nzRequired [nzSm]="7" [nzXs]="24" nzFor="所属救援站">所属救援站</nz-form-label> <nz-form-label nzRequired [nzSm]="7" [nzXs]="24" nzFor="所属救援站">所属救援站</nz-form-label>
<nz-form-control> <nz-form-control>
<nz-select formControlName="role" nzPlaceHolder="请选择所属救援站" nzMode="multiple"> <nz-select formControlName="role" nzPlaceHolder="请选择所属救援站">
<nz-option *ngFor="let item of listOfData2" [nzValue]="item.normalizedName" [nzLabel]="item.displayName"> <nz-option *ngFor="let item of jiuyuanzhan" [nzValue]="item.id" [nzLabel]="item.name">
</nz-option> </nz-option>
</nz-select> </nz-select>
</nz-form-control> </nz-form-control>
@ -46,8 +46,8 @@
<nz-form-item > <nz-form-item >
<nz-form-label [nzSm]="7" [nzXs]="24" nzFor="所属大队">所属大队</nz-form-label> <nz-form-label [nzSm]="7" [nzXs]="24" nzFor="所属大队">所属大队</nz-form-label>
<nz-form-control> <nz-form-control>
<nz-select formControlName="role2" nzPlaceHolder="请选择所属大队" nzMode="multiple"> <nz-select formControlName="role2" nzPlaceHolder="请选择所属大队" >
<nz-option *ngFor="let item of listOfData2" [nzValue]="item.normalizedName" [nzLabel]="item.displayName"> <nz-option *ngFor="let item of dadui" [nzValue]="item.id" [nzLabel]="item.name">
</nz-option> </nz-option>
</nz-select> </nz-select>
</nz-form-control> </nz-form-control>
@ -55,17 +55,16 @@
<nz-form-item> <nz-form-item>
<nz-form-label nzRequired [nzSm]="7" [nzXs]="24" nzFor="使用性质">使用性质</nz-form-label> <nz-form-label nzRequired [nzSm]="7" [nzXs]="24" nzFor="使用性质">使用性质</nz-form-label>
<nz-form-control> <nz-form-control>
<nz-select formControlName="role3" nzPlaceHolder="请选择使用性质" nzMode="multiple"> <nz-input-group>
<nz-option *ngFor="let item of listOfData2" [nzValue]="item.normalizedName" [nzLabel]="item.displayName"> <input nz-input type="text" formControlName="nature" placeholder="请输入使用性质" />
</nz-option> </nz-input-group>
</nz-select>
</nz-form-control> </nz-form-control>
</nz-form-item> </nz-form-item>
<nz-form-item> <nz-form-item>
<nz-form-label [nzSm]="7" [nzXs]="24" nzFor="建筑类型">建筑类型</nz-form-label> <nz-form-label [nzSm]="7" [nzXs]="24" nzFor="建筑类型">建筑类型</nz-form-label>
<nz-form-control> <nz-form-control>
<nz-select formControlName="role4" nzPlaceHolder="请选择建筑类型" nzMode="multiple"> <nz-select formControlName="role4" nzPlaceHolder="请选择建筑类型">
<nz-option *ngFor="let item of listOfData2" [nzValue]="item.normalizedName" [nzLabel]="item.displayName"> <nz-option *ngFor="let item of listOfData2" [nzValue]="item.id" [nzLabel]="item.name">
</nz-option> </nz-option>
</nz-select> </nz-select>
</nz-form-control> </nz-form-control>

44
src/app/home/basic-info/add-unit/add-unit.component.ts

@ -14,6 +14,9 @@ export class AddUnitComponent implements OnInit {
@Input() title?: string; @Input() title?: string;
@Input() subtitle?: string; @Input() subtitle?: string;
validateForm!: FormGroup; validateForm!: FormGroup;
zhidui=[]
dadui=[]
jiuyuanzhan=[]
constructor(private modal: NzModalRef, private fb: FormBuilder, private http: HttpClient, private toTree: TreeService) { } constructor(private modal: NzModalRef, private fb: FormBuilder, private http: HttpClient, private toTree: TreeService) { }
ngOnInit(): void { ngOnInit(): void {
@ -22,13 +25,13 @@ export class AddUnitComponent implements OnInit {
name: [null], name: [null],
iphone: [null], iphone: [null],
addr: [null], addr: [null],
role: [[]], role: [null],
role2: [[]], role2: [null],
role3: [[]], nature: [null],
role4: [[]], role4: [null],
phonenum: [null] phonenum: [null]
}); });
this.getAllOrganization()
} }
destroyModal(): void { destroyModal(): void {
this.modal.destroy({ data: 'this the result data' }); this.modal.destroy({ data: 'this the result data' });
@ -36,6 +39,7 @@ export class AddUnitComponent implements OnInit {
listOfData: any[] = []; listOfData: any[] = [];
listOfData2: any[] = []; listOfData2: any[] = [];
//获取角色列表 //获取角色列表
getAllRoles() { getAllRoles() {
let params = { let params = {
@ -65,23 +69,29 @@ export class AddUnitComponent implements OnInit {
} }
//获取所有组织机构 //获取所有组织机构
nodes: any = [] nodes: any = []
getAllOrganization() { getAllOrganization(){
let OrganizationUnitId = sessionStorage.getItem('isGasStation') == 'true' ? JSON.parse(sessionStorage.getItem('userdataOfgasstation')).organization.id : JSON.parse(sessionStorage.getItem('userdata')).organization.id
let params = { let params = {
OrganizationUnitId: OrganizationUnitId, // OrganizationUnitId: OrganizationUnitId,
IsContainsChildren: "true" // IsContainsChildren: "true"
ContainsChildren: true,
pageSize: 9999
} }
this.http.get('/api/services/app/Organization/GetAll', { this.http.get('/api/Organizations', {
params: params params: params
}).subscribe((data: any) => { }).subscribe((data: any) => {
data.result.items.forEach(element => { console.log(data);
if (element.id == OrganizationUnitId) { for (let index = 0; index < data.items.length; index++) {
element.parentId = null if(data.items[index].level==1){
this.zhidui.push(data.items[index])
}else if(data.items[index].level==2){
this.dadui.push(data.items[index])
}else{
this.jiuyuanzhan.push(data.items[index])
} }
element.key = element.id
element.title = element.displayName }
}); console.log(this.dadui);
this.nodes = [...this.toTree.toTree(data.result.items)]
}) })
} }
} }

10
src/app/home/basic-info/unit/unit.component.html

@ -68,18 +68,18 @@
<td [nzChecked]="checked"> <td [nzChecked]="checked">
</td> </td>
<td>{{ data.name }}</td> <td>{{ data.companyName }}</td>
<td> <td>
<div style="height: 20px; background: #eee; border-radius: 4px;"> <div style="height: 20px; background: #eee; border-radius: 4px;">
<div [ngStyle]="{'width':data.integrity+'%'}" <div [ngStyle]="{'width':integrity+'%'}"
style=" height: 100%; background: #46B783; border-radius: 4px; text-align: center; color: #fff;"> style=" height: 100%; background: #46B783; border-radius: 4px; text-align: center; color: #fff;">
{{data.integrity}}%</div> {{integrity}}%</div>
</div> </div>
</td> </td>
<td>{{ data.organization }}</td> <td>{{ data.organization }}</td>
<td>{{ data.level }}</td> <td>{{ data.level }}</td>
<td>{{ data.nature }}</td> <td>{{ data.useNature }}</td>
<td>{{ data.time }}</td> <td>{{ data.creationTime }}</td>
<td>{{ data.addr }}</td> <td>{{ data.addr }}</td>
<td>{{ data.state }}</td> <td>{{ data.state }}</td>
<td> <td>

81
src/app/home/basic-info/unit/unit.component.ts

@ -8,42 +8,22 @@ import { NzFormatEmitEvent, NzTreeComponent, NzTreeNodeOptions } from 'ng-zorro-
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';
interface Person {
id: string;
name: string;
integrity: number;
organization: string;
level: string;
nature:string;
time:string;
addr:string;
state:string
}
@Component({ @Component({
selector: 'app-unit', selector: 'app-unit',
templateUrl: './unit.component.html', templateUrl: './unit.component.html',
styleUrls: ['./unit.component.scss'] styleUrls: ['./unit.component.scss']
}) })
export class UnitComponent implements OnInit { export class UnitComponent implements OnInit {
checked=true checked = true
listOfData: Person[] = [
{ listOfData: any = [];
id: '1', integrity = 0
name: 'John Brown',
integrity: 20,
organization: 'New York No. 1 Lake Park',
level:'重点单位',
nature:'会议中心',
time:'time',
addr:'单位地址',
state:''
}
];
validateForm!: FormGroup; validateForm!: FormGroup;
constructor(private router: Router, private fb: FormBuilder, private http: HttpClient, private toTree: TreeService, private modal: NzModalService, private message: NzMessageService, private viewContainerRef: ViewContainerRef) { }
datas = ""
ngOnInit(): void { ngOnInit(): void {
this.validateForm = this.fb.group({ this.validateForm = this.fb.group({
level: [null], level: [null],
@ -51,25 +31,35 @@ export class UnitComponent implements OnInit {
event: [null], event: [null],
area: [null], area: [null],
disposalState: [null], disposalState: [null],
}); });
this.getCompanies()
this.http.get('/api/Companies').subscribe((data: any) => {
console.log(data);
})
} }
constructor(private router: Router,private fb: FormBuilder, private http: HttpClient, private toTree: TreeService, private modal: NzModalService, private message: NzMessageService, private viewContainerRef: ViewContainerRef) { }
searchValue = ''; searchValue = '';
next() { next() {
this.router.navigate(['/basicInfo/unit/details']); this.router.navigate(['/basicInfo/unit/details']);
} }
getCompanies() {
this.http.get('/api/Companies').subscribe((data: any) => {
console.log(data);
this.listOfData = data.items
this.listOfData = [...this.listOfData]
console.log(this.listOfData);
for (let index = 0; index < this.listOfData.length; index++) {
this.listOfData[index].creationTime=this.listOfData[index].creationTime.substring(0,10)
}
})
}
ngOnDestroy(): void { ngOnDestroy(): void {
console.log('删除了6666666666666') console.log('删除了6666666666666')
// CustomReuseStrategy.deleteRouteSnapshot('/basicInfo/unit'); // CustomReuseStrategy.deleteRouteSnapshot('/basicInfo/unit');
} }
addOr(node?: any) { addOr(node?: any) {
console.log(node)
const modal = this.modal.create({ const modal = this.modal.create({
nzTitle: "新增单位", nzTitle: "新增单位",
nzContent: AddUnitComponent, nzContent: AddUnitComponent,
@ -86,26 +76,27 @@ export class UnitComponent implements OnInit {
companyName: instance.validateForm.value.unit, companyName: instance.validateForm.value.unit,
directorName: instance.validateForm.value.name, directorName: instance.validateForm.value.name,
directorPhone: instance.validateForm.value.iphone, directorPhone: instance.validateForm.value.iphone,
address:instance.validateForm.value.addr, address: instance.validateForm.value.addr,
organizationId:instance.validateForm.value.role.id || 0, organizationId: instance.validateForm.value.role || null,
relatedOrganizationId:instance.validateForm.value.role2.id || 0, relatedOrganizationId: instance.validateForm.value.role2 || null,
buildingTypeId:instance.validateForm.value.role3.id || 0, buildingTypeId: instance.validateForm.value.role4 || null,
useNature:instance.validateForm.value.role4.id || 0, useNature: instance.validateForm.value.nature,
data: null
} }
this.http.post('/api/Companies', body).subscribe({ this.http.post('/api/Companies', body).subscribe({
next: (data: any) => { next: (data: any) => {
console.log(data,80808) console.log(data, 80808)
}, },
error: (err) => { error: (err) => {
console.log(err) console.log(err)
} }
} }
) )
}) })
} else { } else {
this.message.create('warning', '请填写完整!'); this.message.create('warning', '请填写完整!');
return false return false

4
src/app/home/system-management/or/editor/editor.component.html

@ -15,10 +15,10 @@
</nz-input-group> </nz-input-group>
</nz-form-control> </nz-form-control>
</nz-form-item> --> </nz-form-item> -->
<nz-form-item> <!-- <nz-form-item>
<nz-form-control> <nz-form-control>
<label [(ngModel)]="datacopy.isGasStation" nz-checkbox formControlName="isGasStation">是否为加油站</label> <label [(ngModel)]="datacopy.isGasStation" nz-checkbox formControlName="isGasStation">是否为加油站</label>
</nz-form-control> </nz-form-control>
</nz-form-item> </nz-form-item> -->
</form> </form>
</div> </div>

15
src/app/home/system-management/or/or.component.ts

@ -81,7 +81,8 @@ export class OrComponent implements OnInit {
addOr(node?: any) { addOr(node?: any) {
console.log(node) console.log(node);
const modal = this.modal.create({ const modal = this.modal.create({
nzTitle: node ? '新增组织机构' : '新增一级组织机构', nzTitle: node ? '新增组织机构' : '新增一级组织机构',
nzContent: AddorComponent, nzContent: AddorComponent,
@ -93,8 +94,7 @@ export class OrComponent implements OnInit {
await new Promise(resolve => { await new Promise(resolve => {
let body = { let body = {
name: instance.validateForm.value.name, name: instance.validateForm.value.name,
parentId: node ? Number(node.key) : null, parentId: node ? node.key : null
isGasStation: instance.validateForm.value.isGasStation
} }
this.http.post('/api/Organizations', body).subscribe(data => { this.http.post('/api/Organizations', body).subscribe(data => {
resolve(data) resolve(data)
@ -120,7 +120,7 @@ export class OrComponent implements OnInit {
} }
editOr(node) { editOr(node) {
// console.log(node) console.log(node)
const modal = this.modal.create({ const modal = this.modal.create({
nzTitle: '编辑组织机构', nzTitle: '编辑组织机构',
nzContent: EditorComponent, nzContent: EditorComponent,
@ -134,10 +134,9 @@ export class OrComponent implements OnInit {
await new Promise(resolve => { await new Promise(resolve => {
let body = { let body = {
name: instance.validateForm.value.name, name: instance.validateForm.value.name,
isGasStation: instance.validateForm.value.isGasStation,
parentId: node.origin.parentId parentId: node.origin.parentId
} }
this.http.put(`/api/Organizations/${node.origin.id}`, body).subscribe(data => { this.http.patch(`/api/Organizations/${node.origin.id}`, body).subscribe(data => {
resolve(data) resolve(data)
this.message.create('success', '编辑成功!'); this.message.create('success', '编辑成功!');
this.nzTreeComponent.getExpandedNodeList().forEach((item) => { this.nzTreeComponent.getExpandedNodeList().forEach((item) => {
@ -194,7 +193,7 @@ export class OrComponent implements OnInit {
if (this.pos == 0) {//目标节点内部 if (this.pos == 0) {//目标节点内部
parentId = event.node.key parentId = event.node.key
} else { } else {
if (event.node.level == 0) { if (event.node.level == 1) {
parentId = null parentId = null
} else { } else {
parentId = event.node.origin.parentId parentId = event.node.origin.parentId
@ -302,7 +301,7 @@ export class OrComponent implements OnInit {
pos//放置位置 pos//放置位置
beforeDrop = (arg: NzFormatBeforeDropEvent) => { beforeDrop = (arg: NzFormatBeforeDropEvent) => {
console.log('arg', arg) console.log('arg', arg)
if (arg.node.level === 0) {//如果为数据节点则不允许拖到一级节点 if (arg.node.level === 1) {//如果为数据节点则不允许拖到一级节点
this.message.create('warning', '不允许拖拽到一级节点'); this.message.create('warning', '不允许拖拽到一级节点');
this.isDrag = false this.isDrag = false
return of(false); return of(false);

Loading…
Cancel
Save