diff --git a/src/app/home/basic-info/add-unit/add-unit.component.html b/src/app/home/basic-info/add-unit/add-unit.component.html index 46f8703..24e1500 100644 --- a/src/app/home/basic-info/add-unit/add-unit.component.html +++ b/src/app/home/basic-info/add-unit/add-unit.component.html @@ -4,7 +4,7 @@ 单位名称 - +
@@ -57,18 +57,10 @@ 所属大队 - - - - - - - - - - + + + + diff --git a/src/app/home/basic-info/add-unit/add-unit.component.ts b/src/app/home/basic-info/add-unit/add-unit.component.ts index 90c272b..c5dcd92 100644 --- a/src/app/home/basic-info/add-unit/add-unit.component.ts +++ b/src/app/home/basic-info/add-unit/add-unit.component.ts @@ -27,12 +27,27 @@ export class AddUnitComponent implements OnInit { nature: [null], unittype: [null] }); + this.getAllOrganization() } destroyModal(): void { 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 + }); + }) } } diff --git a/src/app/home/basic-info/unit-details/unit-details.component.html b/src/app/home/basic-info/unit-details/unit-details.component.html index 261273f..43738b7 100644 --- a/src/app/home/basic-info/unit-details/unit-details.component.html +++ b/src/app/home/basic-info/unit-details/unit-details.component.html @@ -46,6 +46,25 @@ + + 单位级别 + + + + + + + + + + + 使用性质 + + + + + + 法定代表人 @@ -677,11 +696,13 @@ -

- +

+ + + +

F -

+

+ + + + +

@@ -707,10 +732,12 @@ -

+

+ + +

@@ -733,10 +760,12 @@ -

+

+ + +

diff --git a/src/app/home/basic-info/unit-details/unit-details.component.ts b/src/app/home/basic-info/unit-details/unit-details.component.ts index 5304585..7146d29 100644 --- a/src/app/home/basic-info/unit-details/unit-details.component.ts +++ b/src/app/home/basic-info/unit-details/unit-details.component.ts @@ -157,32 +157,32 @@ export class UnitDetailsComponent implements OnInit { listdata: [{ name: '消防水源', data: [ - { name: '消防水池数量', velue: '' }, - { name: '消防水池位置', velue: '' }, - { name: '总容量(平方米)', velue: '' }, - { name: '补给方式', velue: '' }, - { name: '室外其他水源', velue: '' }, - { name: '室外其他水源位置', velue: '' } + { name: '消防水池数量', value: '' }, + { name: '消防水池位置', value: '' }, + { name: '总容量(平方米)', value: '' }, + { name: '补给方式', value: '' }, + { name: '室外其他水源', value: '' }, + { name: '室外其他水源位置', value: '' } ] }, { name: '消防栓泵', data: [ - { name: '数量', velue: '' }, - { name: '扬程(m)', velue: '' }, - { name: '流量(L/S)', velue: '' }, - { name: '水泵接合器数量', velue: '' }, - { name: '水泵接合器位置', velue: '' } + { name: '数量', value: '' }, + { name: '扬程(m)', value: '' }, + { name: '流量(L/S)', value: '' }, + { name: '水泵接合器数量', value: '' }, + { name: '水泵接合器位置', value: '' } ] }, { name: '喷淋泵', data: [ - { name: '数量', velue: '' }, - { name: '扬程(m)', velue: '' }, - { name: '流量(L/S)', velue: '' }, - { name: '水泵接合器数量', velue: '' }, - { name: '水泵接合器位置', velue: '' }, + { name: '数量', value: '' }, + { name: '扬程(m)', value: '' }, + { name: '流量(L/S)', value: '' }, + { name: '水泵接合器数量', value: '' }, + { name: '水泵接合器位置', value: '' }, ] @@ -190,29 +190,29 @@ export class UnitDetailsComponent implements OnInit { { name: '消防电梯', data: [ - { name: '数量', velue: '' }, - { name: '位置', velue: '' }, + { name: '数量', value: '' }, + { name: '位置', value: '' }, ] }, { name: '疏散电梯', data: [ - { name: '数量', velue: '' }, - { name: '位置', velue: '' }, + { name: '数量', value: '' }, + { name: '位置', value: '' }, ] }, { name: '安全出口', data: [ - { name: '数量', velue: '' }, - { name: '位置', velue: '' }, + { name: '数量', value: '' }, + { name: '位置', value: '' }, ] }, { name: '标准层室内消火栓', data: [ - { name: '数量', velue: '' }, - { name: '位置', velue: '' }, + { name: '数量', value: '' }, + { name: '位置', value: '' }, ] } @@ -284,32 +284,32 @@ export class UnitDetailsComponent implements OnInit { listdata: [{ name: '消防水源', data: [ - { name: '消防水池数量', velue: '' }, - { name: '消防水池位置', velue: '' }, - { name: '总容量(平方米)', velue: '' }, - { name: '补给方式', velue: '' }, - { name: '室外其他水源', velue: '' }, - { name: '室外其他水源位置', velue: '' } + { name: '消防水池数量', value: '' }, + { name: '消防水池位置', value: '' }, + { name: '总容量(平方米)', value: '' }, + { name: '补给方式', value: '' }, + { name: '室外其他水源', value: '' }, + { name: '室外其他水源位置', value: '' } ] }, { name: '消防栓泵', data: [ - { name: '数量', velue: '' }, - { name: '扬程(m)', velue: '' }, - { name: '流量(L/S)', velue: '' }, - { name: '水泵接合器数量', velue: '' }, - { name: '水泵接合器位置', velue: '' } + { name: '数量', value: '' }, + { name: '扬程(m)', value: '' }, + { name: '流量(L/S)', value: '' }, + { name: '水泵接合器数量', value: '' }, + { name: '水泵接合器位置', value: '' } ] }, { name: '喷淋泵', data: [ - { name: '数量', velue: '' }, - { name: '扬程(m)', velue: '' }, - { name: '流量(L/S)', velue: '' }, - { name: '水泵接合器数量', velue: '' }, - { name: '水泵接合器位置', velue: '' }, + { name: '数量', value: '' }, + { name: '扬程(m)', value: '' }, + { name: '流量(L/S)', value: '' }, + { name: '水泵接合器数量', value: '' }, + { name: '水泵接合器位置', value: '' }, ] @@ -317,29 +317,29 @@ export class UnitDetailsComponent implements OnInit { { name: '消防电梯', data: [ - { name: '数量', velue: '' }, - { name: '位置', velue: '' }, + { name: '数量', value: '' }, + { name: '位置', value: '' }, ] }, { name: '疏散电梯', data: [ - { name: '数量', velue: '' }, - { name: '位置', velue: '' }, + { name: '数量', value: '' }, + { name: '位置', value: '' }, ] }, { name: '安全出口', data: [ - { name: '数量', velue: '' }, - { name: '位置', velue: '' }, + { name: '数量', value: '' }, + { name: '位置', value: '' }, ] }, { name: '标准层室内消火栓', data: [ - { name: '数量', velue: '' }, - { name: '位置', velue: '' }, + { name: '数量', value: '' }, + { name: '位置', value: '' }, ] } @@ -455,11 +455,14 @@ export class UnitDetailsComponent implements OnInit { }).catch((err) => { this.isHaveLastTask = false }) + this.validateForm = this.fb.group({ code: [null], organizationId: [null, [Validators.required]], relatedOrganizationId: [null], buildingTypeId: [null], + companyLevel: [null, [Validators.required]], + useNature: [null], legalPersonName: [null], legalPersonPhone: [null], principalName: [null], @@ -1358,59 +1361,14 @@ export class UnitDetailsComponent implements OnInit { } 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 = { id: this.id, usci: this.validateForm.value.code, organizationId: this.validateForm.value.organizationId, relatedOrganizationId: this.validateForm.value.relatedOrganizationId, buildingTypeId: this.validateForm.value.buildingTypeId, + companyLevel: this.validateForm.value.companyLevel, + useNature: this.validateForm.value.useNature, legalPersonName: this.validateForm.value.legalPersonName, legalPersonPhone: this.validateForm.value.legalPersonPhone, directorName: this.validateForm.value.principalName, @@ -1420,19 +1378,25 @@ export class UnitDetailsComponent implements OnInit { imageFile: this.imageUrl, companyName: this.datas.basicInfo.name, address: this.datas.basicInfo.address, - useNature: this.datas.basicInfo.xingzhi, data: JSON.stringify(this.datas), - integrity: this.integrity, + integrity: 0, location: { x: this.markerPosition.x, y: this.markerPosition.y } } + + //计算完整度 + body.integrity = this.methodService.getIntegrity(body) + this.http.patch('/api/Companies/' + this.id, body).subscribe(data => { this.message.create('success', '保存成功!'); this.getCompanies() }) } + + + BuildingTypes getBuildingTypes() { this.http.get('/api/BuildingTypes').subscribe((data: any) => { @@ -1455,11 +1419,12 @@ export class UnitDetailsComponent implements OnInit { 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 console.log('当前单位信息2', this.datas); this.validateForm.patchValue({ @@ -1467,6 +1432,10 @@ export class UnitDetailsComponent implements OnInit { organizationId: data.organizationId, relatedOrganizationId: data.relatedOrganizationId, buildingTypeId: data.buildingTypeId, + + companyLevel: data.companyLevel, + useNature: data.useNature, + legalPersonName: data.legalPersonName, legalPersonPhone: data.legalPersonPhone, principalName: data.directorName, @@ -1483,6 +1452,9 @@ export class UnitDetailsComponent implements OnInit { this.labelGis() }) } + + + nodes: any = [] getAllOrganization() { let organizationId = JSON.parse(sessionStorage.getItem('userData')).organizationId @@ -1520,7 +1492,6 @@ export class UnitDetailsComponent implements OnInit { this.http.get('/api/Organizations', { params: params }).subscribe((data: any) => { - console.log('组织机构2222', data.items) data.items.forEach(element => { element.level == 'battalion' ? this.battalionList.push(element) : null }); diff --git a/src/app/home/basic-info/unit/unit.component.ts b/src/app/home/basic-info/unit/unit.component.ts index 7f64e7b..753cef2 100644 --- a/src/app/home/basic-info/unit/unit.component.ts +++ b/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' // 要保存这个docx文件推荐引入file-saver哦,你可以用npm i -D file-saver来安装 import { saveAs } from 'file-saver' +import { MethodService } from 'src/app/service/method.service'; @Component({ selector: 'app-unit', templateUrl: './unit.component.html', @@ -22,7 +23,7 @@ export class UnitComponent implements OnInit { listOfData: any = []; 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 PageSize = 10 ngOnInit(): void { @@ -134,22 +135,15 @@ export class UnitComponent implements OnInit { nzWidth: 450, nzComponentParams: { nodes: this.nodes, - BuildingTypes: this.BuildingTypes + BuildingTypes: this.BuildingTypes, + }, nzOnOk: async () => { if (instance.validateForm.valid) { 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 = { companyName: instance.validateForm.value.unitname, directorName: instance.validateForm.value.person, @@ -161,7 +155,7 @@ export class UnitComponent implements OnInit { companyLevel: instance.validateForm.value.companyLevel, useNature: instance.validateForm.value.nature, data: null, - integrity: integrity.toFixed(2) + integrity: integrity } this.http.post('/api/Companies', body).subscribe({ next: async (data) => { diff --git a/src/app/service/method.service.ts b/src/app/service/method.service.ts index 047a9d2..4342181 100644 --- a/src/app/service/method.service.ts +++ b/src/app/service/method.service.ts @@ -108,4 +108,101 @@ export class MethodService { }) 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 + } }