From 9a4eaa55985eb23f3935f762f7dc6f08408883e4 Mon Sep 17 00:00:00 2001 From: cpf <1105965053@qq.com> Date: Wed, 2 Mar 2022 15:36:50 +0800 Subject: [PATCH] =?UTF-8?q?GIS=E6=A8=A1=E7=B3=8A=E6=90=9C=E7=B4=A2=20?= =?UTF-8?q?=E6=96=B0=E5=A2=9E=E6=90=9C=E7=B4=A2=E7=BB=93=E6=9E=9C=E6=9C=AA?= =?UTF-8?q?=E6=9E=9C=E6=97=B6-=E8=AF=B7=E6=B1=82=E9=AB=98=E5=BE=B7api?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../gis-labeling/gis-labeling.component.ts | 65 +++++++++++++++---- 1 file changed, 52 insertions(+), 13 deletions(-) diff --git a/src/app/gis-management/gis-labeling/gis-labeling.component.ts b/src/app/gis-management/gis-labeling/gis-labeling.component.ts index 30bd58b..76462ed 100644 --- a/src/app/gis-management/gis-labeling/gis-labeling.component.ts +++ b/src/app/gis-management/gis-labeling/gis-labeling.component.ts @@ -1161,15 +1161,41 @@ export class GisLabelingComponent implements OnInit { //搜索 search() { - this.allCompany = [] - let paramsdata: any = { Name: this.searchText || '' } - this.http.get("/api/Companies", { params: paramsdata }).subscribe((data: any) => { - this.allCompany = data.items - const config = new MatSnackBarConfig(); - config.verticalPosition = 'top'; - config.duration = 3000 - this.snackBar.open(`搜索目标结果为${data.items.length}个`, '确定', config); - }) + let that = this + let placeSearch = MapFactory.PlaceSearchInstance(that); //构造地点查询类 + const config = new MatSnackBarConfig(); + config.verticalPosition = 'top'; + config.duration = 3000; + + this.allCompany = [] + let paramsdata: any = { Name: this.searchText || '' } + this.http.get("/api/Companies", { params: paramsdata }).subscribe((data: any) => { + if (data.items.length) { //数据库api 搜索 + this.allCompany = data.items + this.snackBar.open(`搜索目标结果为${data.items.length}个`, '确定', config); + } else { //高德api 搜索 + placeSearch.search(that.searchText, (status, result)=>{ + if (result.poiList.pois.length) { + let resultList = [] + result.poiList.pois.forEach((element: any) => { + let item = { + address: element.address, + buildingTypes: [], + id: null, + imageUrl: null, + location: {x: element.location.lng, y: element.location.lat}, + name: element.name + } + resultList.push(item) + }); + that.allCompany = resultList + that.snackBar.open(`搜索目标结果为${resultList.length}个`, '确定', config); + } else { + that.snackBar.open(`搜索目标结果为0个`, '确定', config); + } + }) + } + }) } //清除 @@ -1295,6 +1321,13 @@ export class GisLabelingComponent implements OnInit { //查看预案 seePlan(e) { + if (!e.id) { + const config = new MatSnackBarConfig(); + config.verticalPosition = 'top'; + config.duration = 3000 + this.snackBar.open('暂无单位数据', '确定', config); + return + } let data = e let dialogRef = this.dialog.open(LookPlanDialog, {//调用open方法打开对话框并且携带参数过去 width: '1400px', @@ -1309,9 +1342,16 @@ export class GisLabelingComponent implements OnInit { //分享 share(e) { + if (!e.id) { + const config = new MatSnackBarConfig(); + config.verticalPosition = 'top'; + config.duration = 3000 + this.snackBar.open('暂无单位数据', '确定', config); + return + } let data = { url: 'https://', - buildingType: e.buildingTypes[0].name, + buildingType: e.buildingTypes.length? e.buildingTypes[0].name : null, address: e.address } let dialogRef = this.dialog.open(ShareUrlDialog, {//调用open方法打开对话框并且携带参数过去 @@ -1503,7 +1543,7 @@ export class ShareUrlDialog { qrCode makeCode() { this.qrCode = new QRCode(document.getElementById("qrcode"), { - text: this.data.url, + text: this.data.url || "", width: 200, height: 200, colorDark: "#000000", @@ -1579,8 +1619,7 @@ export class LookPlanDialog { ngOnInit() { - sessionStorage.setItem("companyId", this.data.id) - console.log(this.data) + sessionStorage.setItem("companyId", this.data.id || "") this.getAllPlans() } //关闭弹窗