diff --git a/src/components/fMap/components/fMap.vue b/src/components/fMap/components/fMap.vue index 77b177c..163df71 100644 --- a/src/components/fMap/components/fMap.vue +++ b/src/components/fMap/components/fMap.vue @@ -55,6 +55,12 @@ } } }, + interactions:{ + type: Array, + default: ()=>{ + return ['keyboardpan','boxzoom'] + } + }, symbols: { type: Array, default: () => { @@ -129,34 +135,18 @@ bglayer: bgLayer, center: this.center, controls: ['zoompan'], + interactions: this.interactions, layers: this.layers }) this.$emit('ready', { fmap: this.fmap }) } else { this.fmap.setBgLayer(bgLayer) } - + debugger // 非查看事件位置点详情 - if (detail === null || detail === false) { - const that = this - this.fmap.on('fmap.map.singleclick', function(event) { - that.fmap.clearLayer('case') - - const marker = { - lon: event.coordinate[0], - lat: event.coordinate[1], - layer: 'case' - } - - that.longitude = marker.lon + '' - that.latitude = marker.lat + '' - - that.fmap.addFeatures([marker], { xField: 'lon', yField: 'lat', layer: 'case' }) - // that.fmap.navigate2Center([marker.lon, marker.lat]) - }) - } else { + if (detail) { // 查看位置点详情 - if (data.lng !== '' && data.lat != '') { + if (data && data.lng !== '' && data.lat !== '') { this.fmap.addFeatures([data], { xField: 'lng', yField: 'lat', layer: 'case' }) this.fmap.navigate2Center([data.lng, data.lat]) } diff --git a/src/components/fMap/components/fMap.vue b/src/components/fMap/components/fMap.vue index 77b177c..163df71 100644 --- a/src/components/fMap/components/fMap.vue +++ b/src/components/fMap/components/fMap.vue @@ -55,6 +55,12 @@ } } }, + interactions:{ + type: Array, + default: ()=>{ + return ['keyboardpan','boxzoom'] + } + }, symbols: { type: Array, default: () => { @@ -129,34 +135,18 @@ bglayer: bgLayer, center: this.center, controls: ['zoompan'], + interactions: this.interactions, layers: this.layers }) this.$emit('ready', { fmap: this.fmap }) } else { this.fmap.setBgLayer(bgLayer) } - + debugger // 非查看事件位置点详情 - if (detail === null || detail === false) { - const that = this - this.fmap.on('fmap.map.singleclick', function(event) { - that.fmap.clearLayer('case') - - const marker = { - lon: event.coordinate[0], - lat: event.coordinate[1], - layer: 'case' - } - - that.longitude = marker.lon + '' - that.latitude = marker.lat + '' - - that.fmap.addFeatures([marker], { xField: 'lon', yField: 'lat', layer: 'case' }) - // that.fmap.navigate2Center([marker.lon, marker.lat]) - }) - } else { + if (detail) { // 查看位置点详情 - if (data.lng !== '' && data.lat != '') { + if (data && data.lng !== '' && data.lat !== '') { this.fmap.addFeatures([data], { xField: 'lng', yField: 'lat', layer: 'case' }) this.fmap.navigate2Center([data.lng, data.lat]) } diff --git a/src/views/caseManage/createCase.vue b/src/views/caseManage/createCase.vue index 4fc7073..66c906c 100644 --- a/src/views/caseManage/createCase.vue +++ b/src/views/caseManage/createCase.vue @@ -1,6 +1,7 @@ @@ -257,6 +261,10 @@ lng: '0', // 事件经度 lat: '0' // 事件纬度 }, + currentPosition: { + lng: '0', + lat: '0' + }, allowAdd: true, // 允许新增联系人 addLoading: false, // 添加允许等待 reportersList: [], // 联系人选择列表 @@ -272,7 +280,8 @@ caseSourceList: [], userList: [], // 处理人列表 inputSize: 'small', // 按钮样式 - showMap: false, + fmap: null, // 地图 + showMap: false, // 是否显示地图 mapHeight: '0px', keyword: '', rules: { @@ -401,6 +410,8 @@ gridId: '', // 网格ID fieldintro: '' // 事件地址 }, + lng: '0', + lat: '0', caseLevel: '', // 案卷紧急程度 isTypical: '0', // 是否典型案例 isImportant: '0', // 是否要情 @@ -420,6 +431,7 @@ if (this.form.reporterPhone) { this.fetchReporter(this.form.reporterPhone) } + // this.$refs.mapComp.initMap() }, // 将客户添加到通讯录 addToCustomerList() { @@ -556,12 +568,33 @@ const seat = this.$store.getters.seat this.form.caseId = id + seat }, + // 地图准备好后的操作 + mapReady({ fmap }) { + this.fmap = fmap + // 禁用双击放大 + this.fmap.deactivateDbClickZoom() + const that = this + // 添加双击事件,在地图上添加点 + this.fmap.on('fmap.map.dbclick', function(event) { + that.fmap.clearLayer('case') + const marker = { + lon: event.coordinate[0], + lat: event.coordinate[1], + layer: 'case' + } + that.currentPosition.lng = marker.lon.toFixed(8) + '' + that.currentPosition.lat = marker.lat.toFixed(8) + '' + that.fmap.addFeatures([marker], { xField: 'lon', yField: 'lat', layer: 'case' }) + // that.fmap.navigate2Center([marker.lon, marker.lat]) + }) + }, + // 显示地图 showMapDiv() { this.showMap = true this.$refs.mapComp.initMap() - this.mapHeight = this.$refs.caseContainer.offsetHeight + 'px' }, + // 查询兴趣点 queryPoi() { if (this.keyword === '') { this.$message.warning('请输入关键字') @@ -569,17 +602,21 @@ this.$refs.mapComp.queryPoi(this.keyword) } }, + // 确定, 保存坐标并返回 confirmPos() { - this.form.lng = this.$refs.mapComp.longitude - this.form.lat = this.$refs.mapComp.latitude - + this.form.lng = this.currentPosition.lng + this.form.lat = this.currentPosition.lat this.showMap = false this.clearMap() console.log(this.form) }, + // 清除地图 clearMap() { + this.currentPosition.lng = '0' + this.currentPosition.lat = '0' this.$refs.mapComp.clearMap() }, + // 返回到事件详情 backToForm() { this.showMap = false this.clearMap() diff --git a/src/components/fMap/components/fMap.vue b/src/components/fMap/components/fMap.vue index 77b177c..163df71 100644 --- a/src/components/fMap/components/fMap.vue +++ b/src/components/fMap/components/fMap.vue @@ -55,6 +55,12 @@ } } }, + interactions:{ + type: Array, + default: ()=>{ + return ['keyboardpan','boxzoom'] + } + }, symbols: { type: Array, default: () => { @@ -129,34 +135,18 @@ bglayer: bgLayer, center: this.center, controls: ['zoompan'], + interactions: this.interactions, layers: this.layers }) this.$emit('ready', { fmap: this.fmap }) } else { this.fmap.setBgLayer(bgLayer) } - + debugger // 非查看事件位置点详情 - if (detail === null || detail === false) { - const that = this - this.fmap.on('fmap.map.singleclick', function(event) { - that.fmap.clearLayer('case') - - const marker = { - lon: event.coordinate[0], - lat: event.coordinate[1], - layer: 'case' - } - - that.longitude = marker.lon + '' - that.latitude = marker.lat + '' - - that.fmap.addFeatures([marker], { xField: 'lon', yField: 'lat', layer: 'case' }) - // that.fmap.navigate2Center([marker.lon, marker.lat]) - }) - } else { + if (detail) { // 查看位置点详情 - if (data.lng !== '' && data.lat != '') { + if (data && data.lng !== '' && data.lat !== '') { this.fmap.addFeatures([data], { xField: 'lng', yField: 'lat', layer: 'case' }) this.fmap.navigate2Center([data.lng, data.lat]) } diff --git a/src/views/caseManage/createCase.vue b/src/views/caseManage/createCase.vue index 4fc7073..66c906c 100644 --- a/src/views/caseManage/createCase.vue +++ b/src/views/caseManage/createCase.vue @@ -1,6 +1,7 @@ @@ -257,6 +261,10 @@ lng: '0', // 事件经度 lat: '0' // 事件纬度 }, + currentPosition: { + lng: '0', + lat: '0' + }, allowAdd: true, // 允许新增联系人 addLoading: false, // 添加允许等待 reportersList: [], // 联系人选择列表 @@ -272,7 +280,8 @@ caseSourceList: [], userList: [], // 处理人列表 inputSize: 'small', // 按钮样式 - showMap: false, + fmap: null, // 地图 + showMap: false, // 是否显示地图 mapHeight: '0px', keyword: '', rules: { @@ -401,6 +410,8 @@ gridId: '', // 网格ID fieldintro: '' // 事件地址 }, + lng: '0', + lat: '0', caseLevel: '', // 案卷紧急程度 isTypical: '0', // 是否典型案例 isImportant: '0', // 是否要情 @@ -420,6 +431,7 @@ if (this.form.reporterPhone) { this.fetchReporter(this.form.reporterPhone) } + // this.$refs.mapComp.initMap() }, // 将客户添加到通讯录 addToCustomerList() { @@ -556,12 +568,33 @@ const seat = this.$store.getters.seat this.form.caseId = id + seat }, + // 地图准备好后的操作 + mapReady({ fmap }) { + this.fmap = fmap + // 禁用双击放大 + this.fmap.deactivateDbClickZoom() + const that = this + // 添加双击事件,在地图上添加点 + this.fmap.on('fmap.map.dbclick', function(event) { + that.fmap.clearLayer('case') + const marker = { + lon: event.coordinate[0], + lat: event.coordinate[1], + layer: 'case' + } + that.currentPosition.lng = marker.lon.toFixed(8) + '' + that.currentPosition.lat = marker.lat.toFixed(8) + '' + that.fmap.addFeatures([marker], { xField: 'lon', yField: 'lat', layer: 'case' }) + // that.fmap.navigate2Center([marker.lon, marker.lat]) + }) + }, + // 显示地图 showMapDiv() { this.showMap = true this.$refs.mapComp.initMap() - this.mapHeight = this.$refs.caseContainer.offsetHeight + 'px' }, + // 查询兴趣点 queryPoi() { if (this.keyword === '') { this.$message.warning('请输入关键字') @@ -569,17 +602,21 @@ this.$refs.mapComp.queryPoi(this.keyword) } }, + // 确定, 保存坐标并返回 confirmPos() { - this.form.lng = this.$refs.mapComp.longitude - this.form.lat = this.$refs.mapComp.latitude - + this.form.lng = this.currentPosition.lng + this.form.lat = this.currentPosition.lat this.showMap = false this.clearMap() console.log(this.form) }, + // 清除地图 clearMap() { + this.currentPosition.lng = '0' + this.currentPosition.lat = '0' this.$refs.mapComp.clearMap() }, + // 返回到事件详情 backToForm() { this.showMap = false this.clearMap() diff --git a/src/views/caseManage/waitForCreate.vue b/src/views/caseManage/waitForCreate.vue index a7818bc..38f3ee2 100644 --- a/src/views/caseManage/waitForCreate.vue +++ b/src/views/caseManage/waitForCreate.vue @@ -43,7 +43,8 @@ width="1200px" custom-class="addcase-dialog" top="5vh" - append-to-body> + append-to-body + @close="closeCreateDialog"> @@ -235,6 +236,7 @@ // 关闭新建案件弹窗 closeCreateDialog() { this.showAddCase = false // 关闭弹窗 + this.$refs['addcase'].backToForm() this.search() }, fetchUserList() {