From b34a07505c315da6305aaa0aee6f7a2a0234a921 Mon Sep 17 00:00:00 2001
From: 沈斌 <bluelazysb@hotmail.com>
Date: Wed, 28 Feb 2018 11:22:53 +0800
Subject: [PATCH] 隐藏标题栏无用的图标
---
src/app/routes/devices/monitor-point/monitor-point-edit/monitor-point-edit.component.ts | 118 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++-
1 files changed, 116 insertions(+), 2 deletions(-)
diff --git a/src/app/routes/devices/monitor-point/monitor-point-edit/monitor-point-edit.component.ts b/src/app/routes/devices/monitor-point/monitor-point-edit/monitor-point-edit.component.ts
index a99f4d1..9ca1b95 100644
--- a/src/app/routes/devices/monitor-point/monitor-point-edit/monitor-point-edit.component.ts
+++ b/src/app/routes/devices/monitor-point/monitor-point-edit/monitor-point-edit.component.ts
@@ -1,4 +1,11 @@
+import { MonitorPoint } from '@business/entity/data';
+import { PageBean } from '@business/entity/grid';
+import { OrganizationService } from '@business/services/http//organization.service';
+import { AreacodeService } from '@business/services/http/areacode.service';
import { Component, OnInit } from '@angular/core';
+import { NzMessageService, NzModalSubject } from 'ng-zorro-antd';
+import { FormGroup, FormBuilder, FormControl, Validators } from '@angular/forms';
+import { CascaderOption } from 'ng-zorro-antd/src/cascader/nz-cascader.component';
@Component({
selector: 'app-monitor-point-edit',
@@ -7,9 +14,116 @@
})
export class MonitorPointEditComponent implements OnInit {
- constructor() { }
+ orgOptions = [];
+
+ data: MonitorPoint;
+ isSaving = false;
+ validateForm: FormGroup;
+ constructor(
+ private subject: NzModalSubject,
+ private formBuilder: FormBuilder,
+ private areacodeService: AreacodeService,
+ private organizationService: OrganizationService
+ ) { }
ngOnInit() {
+ const data = this.data;
+ const areaNames = data.areaNames;
+ let _areas = null;
+ if (areaNames != null) {
+ _areas = {
+ label: Object.values(areaNames).join('/'),
+ value: data.areaCode
+ };
+ }
+ this.OrgSelectChange(null);
+ const validates: MonitorPoint|object = {
+ name: [data.name, [Validators.required] ],
+ organizationId: [data.organizationId, [Validators.required]],
+ longitude: [data.longitude],
+ latitude: [data.latitude],
+ address: [data.address ],
+ _areas: [_areas, [Validators.required]],
+ description: [data.description ]
+ };
+ this.validateForm = this.formBuilder.group(
+ validates
+ );
}
-
+ close() {
+ this.subject.destroy();
+ }
+ save($event, value, valid) {
+ $event.preventDefault();
+ if (valid) {
+ for (const i in this.validateForm.controls) {
+ this.validateForm.controls[ i ].disable();
+ }
+ this.isSaving = true;
+ Object.keys(value).forEach( (key: string) => {
+ // '_'������������������������������
+ if (!key.startsWith('_') && value[key] != null) {
+ this.data[key] = value[key];
+ }
+ } );
+ this.subject.next( this );
+ }else {
+ this.validate();
+ }
+ }
+ validate() {
+ for (const i in this.validateForm.controls) {
+ this.validateForm.controls[ i ].markAsDirty();
+ }
+ }
+ areaLazyLoad(event: { option: CascaderOption, index: number, resolve: (children: CascaderOption[]) => void, reject: () => void }) {
+ const index = event['index'];
+ const option = event.option;
+ switch (index) {
+ case -1:
+ this.areacodeService.getProvinces().subscribe(
+ (res: {label: string, value: string}[]) => {
+ event.resolve( res );
+ }
+ ); break;
+ case 0:
+ this.areacodeService.getCities(option.value).subscribe(
+ (res: {label: string, value: string}[]) => {
+ event.resolve( res );
+ }
+ ); break;
+ case 1:
+ this.areacodeService.getAreas(option.value).subscribe(
+ (res: {label: string, value: string}[]) => {
+ event.resolve( res );
+ }
+ ); break;
+ }
+ }
+ setAreaCodes(codes: string[]) {
+ this.data.provinceCode = codes[0];
+ this.data.cityCode = codes[1];
+ this.data.areaCode = codes[2];
+ }
+ OrgSelectChange(text) {
+ const pageBean: PageBean = {pageIndex: 0, pageSize: 20};
+ this.organizationService.getPagingList(pageBean, text).subscribe(
+ (res: PageBean) => {
+ if (res != null && res.data != null) {
+ this.orgOptions = res.data;
+ }
+ const organization = this.data.organization;
+ if (organization != null && text == null) {
+ const num: number = this.orgOptions.filter(
+ (item: any) => {
+ return item.id === organization.id;
+ }
+ ).length;
+ if ( num === 0 ) {
+ this.orgOptions.push(organization);
+ }
+ }
+ }
+ );
+ }
}
--
Gitblit v1.8.0