Browse Source

[修改]修改完整度计分规则

非煤矿山灾害智能感知和预警系统
邵佳豪 2 years ago
parent
commit
48a0a4e02b
  1. 18
      src/app/home/basic-info/add-unit/add-unit.component.html
  2. 19
      src/app/home/basic-info/add-unit/add-unit.component.ts
  3. 63
      src/app/home/basic-info/unit-details/unit-details.component.html
  4. 175
      src/app/home/basic-info/unit-details/unit-details.component.ts
  5. 20
      src/app/home/basic-info/unit/unit.component.ts
  6. 97
      src/app/service/method.service.ts

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

@ -4,7 +4,7 @@
<nz-form-label [nzSm]="7" [nzXs]="24" nzRequired nzFor="单位名称">单位名称</nz-form-label> <nz-form-label [nzSm]="7" [nzXs]="24" nzRequired nzFor="单位名称">单位名称</nz-form-label>
<nz-form-control> <nz-form-control>
<nz-input-group> <nz-input-group>
<input nz-input type="text" formControlName="unitname" placeholder="请输入单位名称" (ngModelChange)="xxx()" /> <input nz-input type="text" formControlName="unitname" placeholder="请输入单位名称" />
</nz-input-group> </nz-input-group>
<div class="error-message" <div class="error-message"
*ngIf="validateForm.controls['unitname'].invalid && !validateForm.controls['unitname'].errors.required"> *ngIf="validateForm.controls['unitname'].invalid && !validateForm.controls['unitname'].errors.required">
@ -57,18 +57,10 @@
<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-tree-select [nzNodes]="nodes" nzShowSearch nzPlaceHolder="所属机构" formControlName="orDa" <nz-select formControlName="orDa" nzAllowClear nzPlaceHolder="所属大队">
[nzExpandedIcon]="multiExpandedIconTpl" [nzDropdownClassName]="'maxHeightTreeSelect'" [nzAllowClear]="false"> <nz-option *ngFor="let item of battalionList" [nzValue]="item.id" [nzLabel]="item.name">
</nz-tree-select> </nz-option>
<ng-template #multiExpandedIconTpl let-node let-origin="origin"> </nz-select>
<ng-container *ngIf="node.children.length == 0; else elseTemplate">
</ng-container>
<ng-template #elseTemplate>
<i nz-icon [nzType]="node.isExpanded ? 'caret-down' : 'caret-right'"
class="ant-tree-switcher-line-icon"></i>
</ng-template>
</ng-template>
</nz-form-control> </nz-form-control>
</nz-form-item> </nz-form-item>
<nz-form-item> <nz-form-item>

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

@ -27,12 +27,27 @@ export class AddUnitComponent implements OnInit {
nature: [null], nature: [null],
unittype: [null] unittype: [null]
}); });
this.getAllOrganization()
} }
destroyModal(): void { destroyModal(): void {
this.modal.destroy({ data: 'this the result data' }); this.modal.destroy({ data: 'this the result data' });
} }
xxx() { //获得所有大队
console.log(this.validateForm.controls['unitname']) battalionList = []
getAllOrganization() {
let params = {
ContainsChildren: "true",
PageNumber: 1,
PageSize: 9999,
code: '0000'
}
this.http.get('/api/Organizations', {
params: params
}).subscribe((data: any) => {
data.items.forEach(element => {
element.level == 'battalion' ? this.battalionList.push(element) : null
});
})
} }
} }

63
src/app/home/basic-info/unit-details/unit-details.component.html

@ -46,6 +46,25 @@
</nz-select> </nz-select>
</nz-form-control> </nz-form-control>
</nz-form-item> </nz-form-item>
<nz-form-item>
<nz-form-label nzRequired [nzSpan]="7" nzFor="单位级别">单位级别</nz-form-label>
<nz-form-control [nzSpan]="12">
<nz-select formControlName="companyLevel" nzAllowClear nzPlaceHolder="请选择单位级别">
<nz-option nzValue="一般单位" nzLabel="一般单位"></nz-option>
<nz-option nzValue="重点单位" nzLabel="重点单位"></nz-option>
<nz-option nzValue="其他单位" nzLabel="其他单位"></nz-option>
<nz-option nzValue="九小场所" nzLabel="九小场所"></nz-option>
</nz-select>
</nz-form-control>
</nz-form-item>
<nz-form-item>
<nz-form-label [nzSpan]="7" nzFor="使用性质">使用性质</nz-form-label>
<nz-form-control [nzSpan]="12">
<nz-input-group>
<input nz-input type="text" formControlName="useNature" placeholder="使用性质" />
</nz-input-group>
</nz-form-control>
</nz-form-item>
<nz-form-item> <nz-form-item>
<nz-form-label [nzSpan]="7" nzFor="法定代表人">法定代表人</nz-form-label> <nz-form-label [nzSpan]="7" nzFor="法定代表人">法定代表人</nz-form-label>
<nz-form-control [nzSpan]="12"> <nz-form-control [nzSpan]="12">
@ -677,11 +696,13 @@
</td> </td>
<td colspan="2" <td colspan="2"
style="border-bottom-color:#000000; border-bottom-style:solid; border-bottom-width:0.75pt; border-right-color:#000000; border-right-style:solid; border-right-width:0.75pt; border-top-color:#000000; border-top-style:solid; border-top-width:0.75pt; vertical-align:middle; width:82.25pt"> style="border-bottom-color:#000000; border-bottom-style:solid; border-bottom-width:0.75pt; border-right-color:#000000; border-right-style:solid; border-right-width:0.75pt; border-top-color:#000000; border-top-style:solid; border-top-width:0.75pt; vertical-align:middle; width:82.25pt">
<p style="margin:0pt; text-align:center"><span <p style="margin:0pt; text-align:center">
style="font-family:'Times New Roman'; font-size:9pt"> <span style="font-family:'Times New Roman'; font-size:9pt">
<textarea <textarea [(ngModel)]="datas.other.listdata[3].data[0].value" nz-input style="width: 100%"
[(ngModel)]="datas.other.listdata[3].data[0].value" nz-input type="text"></textarea>
style="width: 100%" type="text"></textarea></span> <textarea [(ngModel)]="datas.other.listdata[3].data[1].value" nz-input style="width: 100%"
type="text"></textarea>
</span>
</p> </p>
</td>F </td>F
<td colspan="4" <td colspan="4"
@ -693,10 +714,14 @@
</td> </td>
<td colspan="6" <td colspan="6"
style="border-bottom-color:#000000; border-bottom-style:solid; border-bottom-width:0.75pt; border-right-color:#000000; border-right-style:solid; border-right-width:0.75pt; border-top-color:#000000; border-top-style:solid; border-top-width:0.75pt; vertical-align:middle; width:82.05pt"> style="border-bottom-color:#000000; border-bottom-style:solid; border-bottom-width:0.75pt; border-right-color:#000000; border-right-style:solid; border-right-width:0.75pt; border-top-color:#000000; border-top-style:solid; border-top-width:0.75pt; vertical-align:middle; width:82.05pt">
<p style="margin:0pt; text-align:center"><span <p style="margin:0pt; text-align:center">
style="font-family:'Times New Roman'; font-size:9pt"><textarea <span style="font-family:'Times New Roman'; font-size:9pt">
[(ngModel)]="datas.other.listdata[4].data[0].value" <textarea [(ngModel)]="datas.other.listdata[4].data[0].value" nz-input style="width: 100%"
nz-input style="width: 100%" type="text"></textarea></span></p> type="text"></textarea>
<textarea [(ngModel)]="datas.other.listdata[4].data[1].value" nz-input style="width: 100%"
type="text"></textarea>
</span>
</p>
</td> </td>
<td colspan="4" <td colspan="4"
style="border-bottom-color:#000000; border-bottom-style:solid; border-bottom-width:0.75pt; border-right-color:#000000; border-right-style:solid; border-right-width:0.75pt; border-top-color:#000000; border-top-style:solid; border-top-width:0.75pt; vertical-align:middle; width:57.55pt"> style="border-bottom-color:#000000; border-bottom-style:solid; border-bottom-width:0.75pt; border-right-color:#000000; border-right-style:solid; border-right-width:0.75pt; border-top-color:#000000; border-top-style:solid; border-top-width:0.75pt; vertical-align:middle; width:57.55pt">
@ -707,10 +732,12 @@
</td> </td>
<td colspan="2" <td colspan="2"
style="border-bottom-color:#000000; border-bottom-style:solid; border-bottom-width:0.75pt; border-right-color:#000000; border-right-style:solid; border-right-width:1pt; border-top-color:#000000; border-top-style:solid; border-top-width:0.75pt; vertical-align:middle; width:65.6pt"> style="border-bottom-color:#000000; border-bottom-style:solid; border-bottom-width:0.75pt; border-right-color:#000000; border-right-style:solid; border-right-width:1pt; border-top-color:#000000; border-top-style:solid; border-top-width:0.75pt; vertical-align:middle; width:65.6pt">
<p style="margin:0pt; text-align:center"><span <p style="margin:0pt; text-align:center"><span style="font-family:'Times New Roman'; font-size:9pt">
style="font-family:'Times New Roman'; font-size:9pt"><textarea <textarea [(ngModel)]="datas.other.listdata[5].data[0].value" nz-input style="width:100%"
[(ngModel)]="datas.other.listdata[5].data[0].value" type="text"></textarea>
nz-input style="width:100%" type="text"></textarea></span></p> <textarea [(ngModel)]="datas.other.listdata[5].data[1].value" nz-input style="width:100%"
type="text"></textarea>
</span></p>
</td> </td>
</tr> </tr>
<tr style="height:26.1pt"> <tr style="height:26.1pt">
@ -733,10 +760,12 @@
</td> </td>
<td colspan="10" <td colspan="10"
style="border-bottom-color:#000000; border-bottom-style:solid; border-bottom-width:0.75pt; border-right-color:#000000; border-right-style:solid; border-right-width:1pt; border-top-color:#000000; border-top-style:solid; border-top-width:0.75pt; vertical-align:middle; width:191.1pt"> style="border-bottom-color:#000000; border-bottom-style:solid; border-bottom-width:0.75pt; border-right-color:#000000; border-right-style:solid; border-right-width:1pt; border-top-color:#000000; border-top-style:solid; border-top-width:0.75pt; vertical-align:middle; width:191.1pt">
<p style="margin:0pt; text-align:center"><span <p style="margin:0pt; text-align:center"><span style="font-family:'Times New Roman'; font-size:9pt">
style="font-family:'Times New Roman'; font-size:9pt"><textarea <textarea [(ngModel)]="datas.other.listdata[6].data[0].value" nz-input style="width:100%"
[(ngModel)]="datas.other.listdata[6].data[0].value" type="text"></textarea>
nz-input style="width:100%" type="text"></textarea></span> <textarea [(ngModel)]="datas.other.listdata[6].data[1].value" nz-input style="width:100%"
type="text"></textarea>
</span>
</p> </p>
</td> </td>
</tr> </tr>

175
src/app/home/basic-info/unit-details/unit-details.component.ts

@ -157,32 +157,32 @@ export class UnitDetailsComponent implements OnInit {
listdata: [{ listdata: [{
name: '消防水源', name: '消防水源',
data: [ data: [
{ name: '消防水池数量', velue: '' }, { name: '消防水池数量', value: '' },
{ name: '消防水池位置', velue: '' }, { name: '消防水池位置', value: '' },
{ name: '总容量(平方米)', velue: '' }, { name: '总容量(平方米)', value: '' },
{ name: '补给方式', velue: '' }, { name: '补给方式', value: '' },
{ name: '室外其他水源', velue: '' }, { name: '室外其他水源', value: '' },
{ name: '室外其他水源位置', velue: '' } { name: '室外其他水源位置', value: '' }
] ]
}, },
{ {
name: '消防栓泵', name: '消防栓泵',
data: [ data: [
{ name: '数量', velue: '' }, { name: '数量', value: '' },
{ name: '扬程(m)', velue: '' }, { name: '扬程(m)', value: '' },
{ name: '流量(L/S)', velue: '' }, { name: '流量(L/S)', value: '' },
{ name: '水泵接合器数量', velue: '' }, { name: '水泵接合器数量', value: '' },
{ name: '水泵接合器位置', velue: '' } { name: '水泵接合器位置', value: '' }
] ]
}, },
{ {
name: '喷淋泵', name: '喷淋泵',
data: [ data: [
{ name: '数量', velue: '' }, { name: '数量', value: '' },
{ name: '扬程(m)', velue: '' }, { name: '扬程(m)', value: '' },
{ name: '流量(L/S)', velue: '' }, { name: '流量(L/S)', value: '' },
{ name: '水泵接合器数量', velue: '' }, { name: '水泵接合器数量', value: '' },
{ name: '水泵接合器位置', velue: '' }, { name: '水泵接合器位置', value: '' },
] ]
@ -190,29 +190,29 @@ export class UnitDetailsComponent implements OnInit {
{ {
name: '消防电梯', name: '消防电梯',
data: [ data: [
{ name: '数量', velue: '' }, { name: '数量', value: '' },
{ name: '位置', velue: '' }, { name: '位置', value: '' },
] ]
}, },
{ {
name: '疏散电梯', name: '疏散电梯',
data: [ data: [
{ name: '数量', velue: '' }, { name: '数量', value: '' },
{ name: '位置', velue: '' }, { name: '位置', value: '' },
] ]
}, },
{ {
name: '安全出口', name: '安全出口',
data: [ data: [
{ name: '数量', velue: '' }, { name: '数量', value: '' },
{ name: '位置', velue: '' }, { name: '位置', value: '' },
] ]
}, },
{ {
name: '标准层室内消火栓', name: '标准层室内消火栓',
data: [ data: [
{ name: '数量', velue: '' }, { name: '数量', value: '' },
{ name: '位置', velue: '' }, { name: '位置', value: '' },
] ]
} }
@ -284,32 +284,32 @@ export class UnitDetailsComponent implements OnInit {
listdata: [{ listdata: [{
name: '消防水源', name: '消防水源',
data: [ data: [
{ name: '消防水池数量', velue: '' }, { name: '消防水池数量', value: '' },
{ name: '消防水池位置', velue: '' }, { name: '消防水池位置', value: '' },
{ name: '总容量(平方米)', velue: '' }, { name: '总容量(平方米)', value: '' },
{ name: '补给方式', velue: '' }, { name: '补给方式', value: '' },
{ name: '室外其他水源', velue: '' }, { name: '室外其他水源', value: '' },
{ name: '室外其他水源位置', velue: '' } { name: '室外其他水源位置', value: '' }
] ]
}, },
{ {
name: '消防栓泵', name: '消防栓泵',
data: [ data: [
{ name: '数量', velue: '' }, { name: '数量', value: '' },
{ name: '扬程(m)', velue: '' }, { name: '扬程(m)', value: '' },
{ name: '流量(L/S)', velue: '' }, { name: '流量(L/S)', value: '' },
{ name: '水泵接合器数量', velue: '' }, { name: '水泵接合器数量', value: '' },
{ name: '水泵接合器位置', velue: '' } { name: '水泵接合器位置', value: '' }
] ]
}, },
{ {
name: '喷淋泵', name: '喷淋泵',
data: [ data: [
{ name: '数量', velue: '' }, { name: '数量', value: '' },
{ name: '扬程(m)', velue: '' }, { name: '扬程(m)', value: '' },
{ name: '流量(L/S)', velue: '' }, { name: '流量(L/S)', value: '' },
{ name: '水泵接合器数量', velue: '' }, { name: '水泵接合器数量', value: '' },
{ name: '水泵接合器位置', velue: '' }, { name: '水泵接合器位置', value: '' },
] ]
@ -317,29 +317,29 @@ export class UnitDetailsComponent implements OnInit {
{ {
name: '消防电梯', name: '消防电梯',
data: [ data: [
{ name: '数量', velue: '' }, { name: '数量', value: '' },
{ name: '位置', velue: '' }, { name: '位置', value: '' },
] ]
}, },
{ {
name: '疏散电梯', name: '疏散电梯',
data: [ data: [
{ name: '数量', velue: '' }, { name: '数量', value: '' },
{ name: '位置', velue: '' }, { name: '位置', value: '' },
] ]
}, },
{ {
name: '安全出口', name: '安全出口',
data: [ data: [
{ name: '数量', velue: '' }, { name: '数量', value: '' },
{ name: '位置', velue: '' }, { name: '位置', value: '' },
] ]
}, },
{ {
name: '标准层室内消火栓', name: '标准层室内消火栓',
data: [ data: [
{ name: '数量', velue: '' }, { name: '数量', value: '' },
{ name: '位置', velue: '' }, { name: '位置', value: '' },
] ]
} }
@ -455,11 +455,14 @@ export class UnitDetailsComponent implements OnInit {
}).catch((err) => { }).catch((err) => {
this.isHaveLastTask = false this.isHaveLastTask = false
}) })
this.validateForm = this.fb.group({ this.validateForm = this.fb.group({
code: [null], code: [null],
organizationId: [null, [Validators.required]], organizationId: [null, [Validators.required]],
relatedOrganizationId: [null], relatedOrganizationId: [null],
buildingTypeId: [null], buildingTypeId: [null],
companyLevel: [null, [Validators.required]],
useNature: [null],
legalPersonName: [null], legalPersonName: [null],
legalPersonPhone: [null], legalPersonPhone: [null],
principalName: [null], principalName: [null],
@ -1358,59 +1361,14 @@ export class UnitDetailsComponent implements OnInit {
} }
edit() { edit() {
let num = 0
let num2 = 0
let num3 = 0
console.log(this.validateForm.value);
for (const key in this.validateForm.value) {
if (Object.prototype.hasOwnProperty.call(this.validateForm.value, key)) {
const element = this.validateForm.value[key];
if (element) {
num3 += 1
}
}
}
this.imageUrl ? num3 += 1 : null
// for (const key in this.datas) {
// if (Object.prototype.hasOwnProperty.call(this.datas, key)) {
// const element = this.datas[key];
// for (const key in element) {
// if (Object.prototype.hasOwnProperty.call(element, key)) {
// const element2 = element[key];
// if (element2) {
// // console.log(element2);
// num += 1
// }
// }
// }
// }
// }
// for (const key in this.datas.KeyParts) {
// if (Object.prototype.hasOwnProperty.call(this.datas.KeyParts, key)) {
// const element = this.datas.KeyParts[key]
// for (const key in element) {
// if (Object.prototype.hasOwnProperty.call(element, key)) {
// const element2 = element[key]
// // console.log(element2);
// if (element2) {
// num2 += 1
// }
// }
// }
// }
// }
// let num4 = (num + num2 + num3 - 1) / 64
let xxx = num3 / 11
this.integrity = Math.floor(xxx * 100) / 100
console.log('完整度', this.integrity)
let body = { let body = {
id: this.id, id: this.id,
usci: this.validateForm.value.code, usci: this.validateForm.value.code,
organizationId: this.validateForm.value.organizationId, organizationId: this.validateForm.value.organizationId,
relatedOrganizationId: this.validateForm.value.relatedOrganizationId, relatedOrganizationId: this.validateForm.value.relatedOrganizationId,
buildingTypeId: this.validateForm.value.buildingTypeId, buildingTypeId: this.validateForm.value.buildingTypeId,
companyLevel: this.validateForm.value.companyLevel,
useNature: this.validateForm.value.useNature,
legalPersonName: this.validateForm.value.legalPersonName, legalPersonName: this.validateForm.value.legalPersonName,
legalPersonPhone: this.validateForm.value.legalPersonPhone, legalPersonPhone: this.validateForm.value.legalPersonPhone,
directorName: this.validateForm.value.principalName, directorName: this.validateForm.value.principalName,
@ -1420,19 +1378,25 @@ export class UnitDetailsComponent implements OnInit {
imageFile: this.imageUrl, imageFile: this.imageUrl,
companyName: this.datas.basicInfo.name, companyName: this.datas.basicInfo.name,
address: this.datas.basicInfo.address, address: this.datas.basicInfo.address,
useNature: this.datas.basicInfo.xingzhi,
data: JSON.stringify(this.datas), data: JSON.stringify(this.datas),
integrity: this.integrity, integrity: 0,
location: { location: {
x: this.markerPosition.x, x: this.markerPosition.x,
y: this.markerPosition.y y: this.markerPosition.y
} }
} }
//计算完整度
body.integrity = this.methodService.getIntegrity(body)
this.http.patch('/api/Companies/' + this.id, body).subscribe(data => { this.http.patch('/api/Companies/' + this.id, body).subscribe(data => {
this.message.create('success', '保存成功!'); this.message.create('success', '保存成功!');
this.getCompanies() this.getCompanies()
}) })
} }
BuildingTypes BuildingTypes
getBuildingTypes() { getBuildingTypes() {
this.http.get('/api/BuildingTypes').subscribe((data: any) => { this.http.get('/api/BuildingTypes').subscribe((data: any) => {
@ -1455,11 +1419,12 @@ export class UnitDetailsComponent implements OnInit {
shiwaiweizhi: "" shiwaiweizhi: ""
} }
} }
}else{
this.datas.basicInfo.name = data.companyName || ''
this.datas.basicInfo.address = data.address || ''
this.datas.basicInfo.xingzhi = data.useNature || ''
} }
// this.datas.basicInfo.name = data.companyName
// this.datas.basicInfo.address = data.address
// this.datas.basicInfo.xingzhi = data.useNature
this.integrity = data.integrity
this.imageUrl = data.imageFile this.imageUrl = data.imageFile
console.log('当前单位信息2', this.datas); console.log('当前单位信息2', this.datas);
this.validateForm.patchValue({ this.validateForm.patchValue({
@ -1467,6 +1432,10 @@ export class UnitDetailsComponent implements OnInit {
organizationId: data.organizationId, organizationId: data.organizationId,
relatedOrganizationId: data.relatedOrganizationId, relatedOrganizationId: data.relatedOrganizationId,
buildingTypeId: data.buildingTypeId, buildingTypeId: data.buildingTypeId,
companyLevel: data.companyLevel,
useNature: data.useNature,
legalPersonName: data.legalPersonName, legalPersonName: data.legalPersonName,
legalPersonPhone: data.legalPersonPhone, legalPersonPhone: data.legalPersonPhone,
principalName: data.directorName, principalName: data.directorName,
@ -1483,6 +1452,9 @@ export class UnitDetailsComponent implements OnInit {
this.labelGis() this.labelGis()
}) })
} }
nodes: any = [] nodes: any = []
getAllOrganization() { getAllOrganization() {
let organizationId = JSON.parse(sessionStorage.getItem('userData')).organizationId let organizationId = JSON.parse(sessionStorage.getItem('userData')).organizationId
@ -1520,7 +1492,6 @@ export class UnitDetailsComponent implements OnInit {
this.http.get('/api/Organizations', { this.http.get('/api/Organizations', {
params: params params: params
}).subscribe((data: any) => { }).subscribe((data: any) => {
console.log('组织机构2222', data.items)
data.items.forEach(element => { data.items.forEach(element => {
element.level == 'battalion' ? this.battalionList.push(element) : null element.level == 'battalion' ? this.battalionList.push(element) : null
}); });

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

@ -12,6 +12,7 @@ import { UnitEditComponent } from '../unit-edit/unit-edit.component'
import { asBlob } from 'html-docx-js-typescript' import { asBlob } from 'html-docx-js-typescript'
// 要保存这个docx文件推荐引入file-saver哦,你可以用npm i -D file-saver来安装 // 要保存这个docx文件推荐引入file-saver哦,你可以用npm i -D file-saver来安装
import { saveAs } from 'file-saver' import { saveAs } from 'file-saver'
import { MethodService } from 'src/app/service/method.service';
@Component({ @Component({
selector: 'app-unit', selector: 'app-unit',
templateUrl: './unit.component.html', templateUrl: './unit.component.html',
@ -22,7 +23,7 @@ export class UnitComponent implements OnInit {
listOfData: any = []; listOfData: any = [];
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) { } constructor(public methodService: MethodService, private router: Router, private fb: FormBuilder, private http: HttpClient, private toTree: TreeService, private modal: NzModalService, private message: NzMessageService, private viewContainerRef: ViewContainerRef) { }
PageNumber = 1 PageNumber = 1
PageSize = 10 PageSize = 10
ngOnInit(): void { ngOnInit(): void {
@ -134,22 +135,15 @@ export class UnitComponent implements OnInit {
nzWidth: 450, nzWidth: 450,
nzComponentParams: { nzComponentParams: {
nodes: this.nodes, nodes: this.nodes,
BuildingTypes: this.BuildingTypes BuildingTypes: this.BuildingTypes,
}, },
nzOnOk: async () => { nzOnOk: async () => {
if (instance.validateForm.valid) { if (instance.validateForm.valid) {
await new Promise((resolve, reject) => { await new Promise((resolve, reject) => {
let num = 0
for (const key in instance.validateForm.value) {
if (Object.prototype.hasOwnProperty.call(instance.validateForm.value, key)) {
const element = instance.validateForm.value[key];
if (element) {
num += 1
}
}
}
let integrity: number = num / 64
let integrity = this.methodService.getAddIntegrity(instance.validateForm.value)
let body = { let body = {
companyName: instance.validateForm.value.unitname, companyName: instance.validateForm.value.unitname,
directorName: instance.validateForm.value.person, directorName: instance.validateForm.value.person,
@ -161,7 +155,7 @@ export class UnitComponent implements OnInit {
companyLevel: instance.validateForm.value.companyLevel, companyLevel: instance.validateForm.value.companyLevel,
useNature: instance.validateForm.value.nature, useNature: instance.validateForm.value.nature,
data: null, data: null,
integrity: integrity.toFixed(2) integrity: integrity
} }
this.http.post('/api/Companies', body).subscribe({ this.http.post('/api/Companies', body).subscribe({
next: async (data) => { next: async (data) => {

97
src/app/service/method.service.ts

@ -108,4 +108,101 @@ export class MethodService {
}) })
return item return item
} }
/**
*
*/
getIntegrity(data) {
// console.log('完整度原始数据', data)
let tabledata = JSON.parse(data.data)
// console.log('表格数据', tabledata)
let molecule = 0
let denominator = 56 + 4 + tabledata.key.length * 5//完整度分母
//统计最上方12个输入框
data.usci ? molecule += 1 : null
data.organizationId ? molecule += 1 : null
data.relatedOrganizationId ? molecule += 1 : null
data.buildingTypeId ? molecule += 1 : null
data.companyLevel ? molecule += 1 : null
data.useNature ? molecule += 1 : null
data.legalPersonName ? molecule += 1 : null
data.legalPersonPhone ? molecule += 1 : null
data.directorName ? molecule += 1 : null
data.directorPhone ? molecule += 1 : null
data.securityAdministratorName ? molecule += 1 : null
data.securityAdministratorPhone ? molecule += 1 : null
//统计表格中单位基本情况15个输入框
delete tabledata.basicInfo.people
delete tabledata.basicInfo.time
for (const key in tabledata.basicInfo) {
const element = tabledata.basicInfo[key];
if (key == 'pilin') {
for (const k in tabledata.basicInfo.pilin) {
const item = tabledata.basicInfo.pilin[k];
item ? molecule += 1 : null
}
} else {
element ? molecule += 1 : null
}
}
//统计表格中单位重点部位
tabledata.key.forEach(element => {
element.data.forEach(item => {
item.value ? molecule += 1 : null
});
});
//统计表格中重点提示
tabledata.zhongdiantishi ? molecule += 1 : null
////统计表格中主要消防设施28个输入框 + 4个选择框
//4个选择框默认都算分
molecule += 4
//ewai对象4个值
for (const key in tabledata.ewai) {
const element = tabledata.ewai[key];
element ? molecule += 1 : null
}
//other对象24个值
tabledata.other.listdata.forEach(element => {
element.data.forEach(item => {
item.value ? molecule += 1 : null
});
});
// console.log('分子', molecule)
// console.log('分母', denominator)
let integrity = molecule / denominator
integrity = Math.floor(integrity * 100) / 100
// console.log('完整度', integrity)
return integrity
}
/**
*
*/
getAddIntegrity(data) {
// console.log('完整度原始数据', data)
let molecule = 4
let denominator = 70 //完整度分母
for (const key in data) {
if (Object.prototype.hasOwnProperty.call(data, key)) {
const element = data[key];
if (key == 'nature') {
element ? molecule += 2 : null
} else {
element ? molecule += 1 : null
}
}
}
// console.log('分子', molecule)
// console.log('分母', denominator)
let integrity = molecule / denominator
integrity = Math.floor(integrity * 100) / 100
// console.log('完整度', integrity)
return integrity
}
} }

Loading…
Cancel
Save