From 27bd4a08bf807f4f6132bb524da33490b6d22f87 Mon Sep 17 00:00:00 2001
From: fengxiang <110431245@qq.com>
Date: Tue, 19 Jun 2018 11:45:11 +0800
Subject: [PATCH] 省市区兼容旧版本
---
src/app/routes/reports/demo/demo.component.ts | 100 ++++++++++++++++++++++++++++----------------------
1 files changed, 56 insertions(+), 44 deletions(-)
diff --git a/src/app/routes/reports/demo/demo.component.ts b/src/app/routes/reports/demo/demo.component.ts
index ee873aa..9a81c7e 100644
--- a/src/app/routes/reports/demo/demo.component.ts
+++ b/src/app/routes/reports/demo/demo.component.ts
@@ -82,10 +82,10 @@
}
dimensionChange(value) {
- this.items.forEach((item,index) => {
+ this.items.forEach((item, index) => {
item.profession = null;
item.monitorPoint = null;
- item.device = null;
+ this.getDevices(index);
});
if (value === 'monitorPoint') {
this.professionShow = false;
@@ -159,37 +159,51 @@
this.areacodeService.getProvinces().subscribe(
(res: {label: string, value: string}[]) => {
event.resolve(res);
- }
- ); break;
+ });
+ break;
case 0:
this.areacodeService.getCities(option.value).subscribe(
(res: {label: string, value: string}[]) => {
event.resolve(res);
- }
- ); break;
+ });
+ break;
case 1:
this.areacodeService.getAreas(option.value).subscribe(
(res: {label: string, value: string}[]) => {
event.resolve(res);
- }
- ); break;
+ });
+ 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);
+ });
+ break;
}
}
public regionChange(event: {option: CascaderOption, index: number}, i) {
+
let name = '';
let areaName = '';
const option = event.option;
this.items[i].monitorPoint = null;
- this.items[i].profession = null;
+ //this.items[i].profession = null;
+ this.items[i].cityCode = null;
this.items[i].areaCode = null;
- this.items[i].device = null;
+ this.items[i].townCode = null;
+ this.items[i].villageCode = null;
switch (event.index) {
case 0:
name = 'provinceCode';
this.items[i].provinceCode = option.value;
- this.items[i].cityCode = null;
areaName = option.label;
break;
case 1:
@@ -202,6 +216,16 @@
this.items[i].areaCode = option.value;
areaName = option.parent.parent.label + '/' + option.parent.label + '/' + option.label;
break;
+ case 3:
+ name = 'townCode';
+ this.items[i].townCode = option.value;
+ areaName = option.parent.parent.parent.label + '/' + option.parent.parent.label + '/' + option.parent.label + '/' + option.label;
+ break;
+ case 4:
+ name = 'villageCode';
+ this.items[i].villageCode = option.value;
+ areaName = option.parent.parent.parent.parent.label + '/' + option.parent.parent.parent.label + '/' + option.parent.parent.label + '/' + option.parent.label + '/' + option.label;
+ break;
}
this.items[i].areaName = areaName;
this.http.get(environment.SERVER_BASH_URL + 'monitor-point/list/region', {params: {name: name, value: option.value}}).subscribe((res: any) => {
@@ -211,42 +235,30 @@
this.items[i].monitorPointOptions = res.data;
}
});
+ this.getDevices(i);
}
-
- monitorPointChange(value, i) {
- this.items[i].deviceOptions = [];
+
+ getDevices(i) {
this.items[i].device = null;
- if (value) {
- this.http.get(environment.SERVER_BASH_URL + 'device/monitorPointId', {params: {monitorPointId: value.id}}).subscribe((res: any) => {
- if (res.code === 0) {
- this.msgSrv.error(res.message);
- } else {
- this.items[i].deviceOptions = res.data;
- }
- });
+ if (!!this.items[i].profession) {
+ this.items[i].professionId = this.items[i].profession.id;
+ } else {
+ this.items[i].professionId = null;
}
- }
-
- professionChange(value, i) {
- this.items[i].deviceOptions = [];
- this.items[i].device = null;
- if (value) {
- if (!!this.items[i].areaName) {
- this.items[i].professionId = value.id;
- this.http.get(environment.SERVER_BASH_URL + 'device/professionId', {params: this.items[i]}).subscribe((res: any) => {
- if (res.code === 0) {
- this.msgSrv.error(res.message);
- } else {
- this.items[i].deviceOptions = res.data;
- }
- });
+ if (!!this.items[i].monitorPoint) {
+ this.items[i].monitorPointId = this.items[i].monitorPoint.id;
+ } else {
+ this.items[i].monitorPointId = null;
+ }
+ return this.http.get(environment.SERVER_BASH_URL + 'device/professionId', {params: this.items[i]}).subscribe((res: any) => {
+ if (res.code === 0) {
+ this.msgSrv.error(res.message);
} else {
- this.msgSrv.error('������������ ������������');
+ this.items[i].deviceOptions = res.data;
}
- }
-
+ });
}
-
+
_disabledDate(current: Date): boolean {
return current && current.getTime() > Date.now();
}
@@ -259,7 +271,7 @@
const areaName = '';
const item = this.items[i];
const queryItem: any = {};
- if (item.monitorPointOptions.length > 0) {
+ if (item.monitorPointOptions.length > 0 && item.deviceOptions.length > 0) {
for (const key in item) {
if (item[key]) {
queryItem[key] = item[key];
@@ -296,7 +308,7 @@
break;
}
}
- if (validate && this.timeType && query.reportType) {
+ if (validate) {
delete query.sensors;
if (this._sensors) {
const sensors = [];
@@ -311,7 +323,7 @@
query.type = this.timeType.value;
sessionStorage.setItem('queryParams', JSON.stringify(query));
} else {
- this.msgSrv.error('���������������������������������������');
+ this.msgSrv.error('���������������������������������������������������������������');
return false;
}
}
--
Gitblit v1.8.0