fengxiang
2018-07-06 8ac3a87733b421c1f1cb3b691f946c05bdae02df
src/app/routes/devices/monitor-point/monitor-point-edit/monitor-point-edit.component.ts
@@ -14,8 +14,8 @@
})
export class MonitorPointEditComponent implements OnInit {
   orgOptions = [];
  orgOptions = [];
  configMap: {organizationId: number};
  data: MonitorPoint;
  isSaving = false;
  validateForm: FormGroup;
@@ -32,11 +32,14 @@
    let _areas = null;
    if (areaNames != null) {
      _areas = {
       label: Object.values(areaNames).join('/'),
       label: Object.values(areaNames).filter(d => d).join('/'),
       value: data.areaCode
      };
    }
     this.OrgSelectChange(null);
     this.orgSelectChange(null);
     if (!!this.configMap.organizationId && !data.organizationId) {
          data.organizationId = this.configMap.organizationId;
     }
     const validates: MonitorPoint|object  = {
          name: [data.name, [Validators.required] ],
          organizationId: [data.organizationId, [Validators.required]],
@@ -48,6 +51,11 @@
     };
     this.validateForm = this.formBuilder.group(
         validates
     );
     this.validateForm.controls['organizationId'].valueChanges.subscribe(
       value => {
        this.configMap.organizationId = value;
       }
     );
  }
  close() {
@@ -77,6 +85,7 @@
     }
  }
  areaLazyLoad(event: { option: CascaderOption, index: number, resolve: (children: CascaderOption[]) => void, reject: () => void }) {
    // console.info(event);
    const index = event['index'];
    const option = event.option;  
    switch (index) {
@@ -93,7 +102,20 @@
         }
       ); break;
       case 1:
       this.areacodeService.getAreas(option.value).subscribe(
       // 区不是叶节点 兼容旧组件
       this.areacodeService.getAreas(option.value , false).subscribe(
         (res: {label: string, value: string}[]) => {
             event.resolve( res );
         }
       ); break;
       case 2:
       this.areacodeService.getTowns(option.value).subscribe(
         (res: {label: string, value: string}[]) => {
             event.resolve( res );
         }
       ); break;
       case 3:
       this.areacodeService.getVillages(option.value).subscribe(
         (res: {label: string, value: string}[]) => {
             event.resolve( res );
         }
@@ -104,8 +126,10 @@
      this.data.provinceCode = codes[0];
      this.data.cityCode = codes[1];
      this.data.areaCode = codes[2];
      this.data.townCode = codes[3];
      this.data.villageCode = codes[4];
  }
  OrgSelectChange(text) {
  orgSelectChange(text) {
      const pageBean: PageBean = {pageIndex: 0, pageSize: 20};
      this.organizationService.getPagingList(pageBean, text).subscribe(
        (res: PageBean) => {