Commit 20fc3cf8 by 胡悦
2 parents 1cb01107 3ad9672b
<template> <template>
<div class="map-box" :style="{height: mapHeight+ 'px'}"> <div class="map-box" :style="{ height: mapHeight + 'px' }">
<div id="container" style="width: 100%; height: 100%"></div> <div id="container" style="width: 100%; height: 100%"></div>
<div class="map-address">{{ address }}</div> <div class="map-address">{{ address }}</div>
<div id="myPageTop" style="position: absolute; top: 10px; width: 50%; left: 25%"> <div id="myPageTop" style="position: absolute; top: 10px; width: 50%; left: 25%">
...@@ -11,10 +11,9 @@ ...@@ -11,10 +11,9 @@
</template> </template>
<script> <script>
import AMap from "AMap"; let map, marker, placeSearch
let map,marker, placeSearch;
export default { export default {
name: "map", name: 'map',
props: { props: {
mapHeight: { mapHeight: {
type: Number, type: Number,
...@@ -24,83 +23,95 @@ export default { ...@@ -24,83 +23,95 @@ export default {
data() { data() {
return { return {
input: "", input: '',
address: "", address: '',
lnglat: [], lnglat: []
}; }
}, },
methods: { methods: {
mapInit() { mapInit() {
map = new AMap.Map("container", { map = new AMap.Map('container', {
resizeEnable: true, resizeEnable: true,
zoom: 15, zoom: 20
}); })
AMap.plugin(["AMap.PlaceSearch"], function () { AMap.plugin(['AMap.PlaceSearch'], function () {
//构造地点查询类 //构造地点查询类
placeSearch = new AMap.PlaceSearch({ placeSearch = new AMap.PlaceSearch({
pageSize: 8, // 单页显示结果条数
pageIndex: 1, // 页码
citylimit: false, //是否强制限制在设置的城市内搜索 citylimit: false, //是否强制限制在设置的城市内搜索
map: map, // 展现结果的地图实例 // panel: "panel", // 结果列表将在此容器中进行展示。
autoFitView: true, // 是否自动调整地图视野使绘制的 Marker点都处于视口的可见范围 autoFitView: true, // 是否自动调整地图视野使绘制的 Marker点都处于视口的可见范围
renderStyle: "default", renderStyle: 'default'
}); })
}); })
// 添加列表点选监听事件 // 添加列表点选监听事件
map.on("click", this.getAddress); map.on('click', this.getAddress)
placeSearch.on("markerClick", this.getAddress); },
searchAddress() {
let _this = this
placeSearch.search(this.input, function (status, result) {
console.log(result)
if (status === 'complete' && result.poiList.pois.length) {
let lnglat = result.poiList.pois[0].location
_this.getAddress(lnglat)
}
})
}, },
addMarker(lnglat) { addMarker(lnglat) {
let position = [lnglat.lng,lnglat.lat] let position
if (lnglat.lng) {
position = [lnglat.lng, lnglat.lat]
} else {
position = lnglat
}
console.log(position)
marker = new AMap.Marker({ marker = new AMap.Marker({
icon: new AMap.Icon({ icon: new AMap.Icon({
image: "//a.amap.com/jsapi_demos/static/demo-center/icons/poi-marker-default.png", image: '//a.amap.com/jsapi_demos/static/demo-center/icons/poi-marker-default.png',
size: new AMap.Size(27, 34), //图标大小 size: new AMap.Size(27, 34), //图标大小
imageSize: new AMap.Size(27,34) imageSize: new AMap.Size(27, 34)
}), }),
position:position, position: position,
offset: new AMap.Pixel(-13, -30) offset: new AMap.Pixel(-10, -10)
}); })
marker.setMap(map); map.add(marker);
map.setFitView();
}, },
getAddress(e) { getAddress(e) {
let self = this; console.log(e)
let lnglat; let self = this
if (e.type == "click") { let lnglat
if (e.type == 'click') {
lnglat = e.lnglat lnglat = e.lnglat
} else { } else {
let { lng, lat } = e.data.entr_location?e.data.entr_location:e.data.location; let { lng, lat } = e
lnglat = [lng, lat]; lnglat = [lng, lat]
} }
if (marker) { if (marker) {
marker.setMap(null); marker.setMap(null)
marker = null; marker = null
} }
self.addMarker(lnglat) self.addMarker(lnglat)
AMap.plugin("AMap.Geocoder", () => { AMap.plugin('AMap.Geocoder', () => {
const geocoder = new AMap.Geocoder(); const geocoder = new AMap.Geocoder()
geocoder.getAddress(lnglat, (status, result) => { geocoder.getAddress(lnglat, (status, result) => {
self.lnglat = lnglat; self.lnglat = lnglat
self.address = result.regeocode.formattedAddress; self.address = result.regeocode.formattedAddress
}); })
}); })
},
searchAddress() {
placeSearch.search(this.input, function (status, result) {
if (status == "complete") {
// console.log(result.poiList.pois);
}
});
}, },
selectAddress(e) { selectAddress(e) {
//这里获得点选地点的经纬度 //这里获得点选地点的经纬度
this.getAddress(); this.getAddress()
} }
}, },
mounted() { mounted() {
this.mapInit(); this.mapInit()
} }
}; }
</script> </script>
<style scoped lang="scss"> <style scoped lang="scss">
......
...@@ -12,16 +12,15 @@ import apis from './api' ...@@ -12,16 +12,15 @@ import apis from './api'
import './public-path' import './public-path'
// import 'glsx-components/dist/glsx-components.css' // import 'glsx-components/dist/glsx-components.css'
import { start } from '@/setup' import { start } from '@/setup'
// import VueAMap from "vue-amap"; import VueAMap from "vue-amap";
import filters from './utils/filters' //新增过滤器 import filters from './utils/filters' //新增过滤器
// Vue.use(VueAMap); Vue.use(VueAMap);
// // 初始化vue-amap // 初始化vue-amap
// VueAMap.initAMapApiLoader({ VueAMap.initAMapApiLoader({
// key: "bd290dc27d0945959280753215ddda71", // 这里写你申请的高德地图的key key: "bd290dc27d0945959280753215ddda71", // 这里写你申请的高德地图的key
// plugin: ["AMap.Autocomplete", "AMap.Geocoder", "AMap.Geolocation"], plugin: ["AMap.PlaceSearch", "AMap.Geocoder", "AMap.Geolocation"],
// v: "1.4.15", v: "1.4.15"
// uiVersion: "1.1" });
// });
Vue.config.productionTip = false Vue.config.productionTip = false
Vue.prototype.$apis = apis Vue.prototype.$apis = apis
start() start()
......
...@@ -98,6 +98,9 @@ export default { ...@@ -98,6 +98,9 @@ export default {
// 设置全选 // 设置全选
var arr = tabMenu.find(i => i.accounttypeId == tabName).products.find(j => j.productId == productTab).merchantProTreeResponses var arr = tabMenu.find(i => i.accounttypeId == tabName).products.find(j => j.productId == productTab).merchantProTreeResponses
this.$refs[`tree_${tabName}_${productTab}`] ? this.$refs[`tree_${tabName}_${productTab}`][0].setCheckedKeys(this.getAllId(arr)) : '' this.$refs[`tree_${tabName}_${productTab}`] ? this.$refs[`tree_${tabName}_${productTab}`][0].setCheckedKeys(this.getAllId(arr)) : ''
this.$nextTick(() => {
this.addStyle()
})
}, },
productClick(productId) { productClick(productId) {
this.productTab = productId this.productTab = productId
...@@ -129,9 +132,6 @@ export default { ...@@ -129,9 +132,6 @@ export default {
} }
}) })
this.tabMenu_r = util.deepClone(tabMenu) this.tabMenu_r = util.deepClone(tabMenu)
this.$nextTick(() => {
this.addStyle()
})
this.accountTypes = tabMenu.map(item => { this.accountTypes = tabMenu.map(item => {
return { return {
products: null, products: null,
...@@ -184,6 +184,7 @@ export default { ...@@ -184,6 +184,7 @@ export default {
if (i.productId == j.productId) { if (i.productId == j.productId) {
itm.productsArr.push(j) itm.productsArr.push(j)
this.$nextTick(() => { this.$nextTick(() => {
this.addStyle()
this.$refs[`tree_${itm.accounttypeId}_${j.productId}`][0].setCheckedKeys(i.idList) this.$refs[`tree_${itm.accounttypeId}_${j.productId}`][0].setCheckedKeys(i.idList)
}) })
} }
...@@ -207,6 +208,7 @@ export default { ...@@ -207,6 +208,7 @@ export default {
if (i.productId == j.productId) { if (i.productId == j.productId) {
itm.productsArr.push(j) itm.productsArr.push(j)
this.$nextTick(() => { this.$nextTick(() => {
this.addStyle()
this.$refs[`tree_${itm.accounttypeId}_${j.productId}`] ? this.$refs[`tree_${itm.accounttypeId}_${j.productId}`][0].setCheckedKeys(i.menuIds) : '' this.$refs[`tree_${itm.accounttypeId}_${j.productId}`] ? this.$refs[`tree_${itm.accounttypeId}_${j.productId}`][0].setCheckedKeys(i.menuIds) : ''
}) })
} }
......
...@@ -18,10 +18,10 @@ ...@@ -18,10 +18,10 @@
<el-input size="small" disabled style="width: 40%" v-model="ruleForm.merchantName"></el-input> <el-input size="small" disabled style="width: 40%" v-model="ruleForm.merchantName"></el-input>
</el-form-item> </el-form-item>
<el-form-item label="角色名称" prop="roleName"> <el-form-item label="角色名称" prop="roleName">
<el-input size="small" maxlength="20" show-word-limit style="width: 40%;padding-right:50px" v-model="ruleForm.roleName" placeholder="请输入角色名称"></el-input> <el-input size="small" maxlength="20" style="width: 40%;padding-right:50px" v-model="ruleForm.roleName" placeholder="请输入角色名称"></el-input>
</el-form-item> </el-form-item>
<el-form-item label="角色说明" prop="roleDesc"> <el-form-item label="角色说明" prop="roleDesc">
<el-input size="small" maxlength="50" show-word-limit style="width: 40%;padding-right:50px" v-model="ruleForm.roleDesc" placeholder="请输入角色说明"></el-input> <el-input size="small" maxlength="50" style="width: 40%;padding-right:50px" v-model="ruleForm.roleDesc" placeholder="请输入角色说明"></el-input>
</el-form-item> </el-form-item>
<!-- <el-form-item label="角色权限" prop="roleRoot"> <!-- <el-form-item label="角色权限" prop="roleRoot">
<div class="custom_element"> <div class="custom_element">
......
...@@ -14,7 +14,7 @@ const cdn = { ...@@ -14,7 +14,7 @@ const cdn = {
`${CDN_DOMAIN}ajax/libs/element-ui/2.11.1/index.js`, `${CDN_DOMAIN}ajax/libs/element-ui/2.11.1/index.js`,
`${CDN_DOMAIN}ajax/libs/vuex/3.6.2/vuex.min.js`, `${CDN_DOMAIN}ajax/libs/vuex/3.6.2/vuex.min.js`,
`${CDN_DOMAIN}ajax/libs/echarts/5.1.2/echarts.min.js`, `${CDN_DOMAIN}ajax/libs/echarts/5.1.2/echarts.min.js`,
'http://webapi.amap.com/maps?v=2.0&key=bd290dc27d0945959280753215ddda71&plugin=AMap.Geocoder' // 'https://webapi.amap.com/maps?v=1.3&key=bd290dc27d0945959280753215ddda71&plugin=AMap.Geocoder'
] ]
} }
module.exports = { module.exports = {
......
Markdown is supported
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!