Commit cd6a914e authored by lizhichao's avatar lizhichao

新乐危化品平台

parents
.DS_Store
node_modules
/dist
# local env files
.env.local
.env.*.local
# Log files
npm-debug.log*
yarn-debug.log*
yarn-error.log*
# Editor directories and files
.idea
.vscode
*.suo
*.ntvs*
*.njsproj
*.sln
*.sw?
# hcsystem
## Project setup
```
npm install
```
### Compiles and hot-reloads for development
```
npm run serve
```
### Compiles and minifies for production
```
npm run build
```
### Run your tests
```
npm run test
```
### Lints and fixes files
```
npm run lint
```
### Customize configuration
See [Configuration Reference](https://cli.vuejs.org/config/).
module.exports = {
presets: [
'@vue/cli-plugin-babel/preset'
]
}
This diff is collapsed.
{
"name": "hcsystem",
"version": "0.1.0",
"private": true,
"scripts": {
"serve": "vue-cli-service serve",
"build": "vue-cli-service build"
},
"dependencies": {
"@jiaminghi/data-view": "^2.9.4",
"@types/axios": "^0.14.0",
"axios": "^0.19.2",
"core-js": "^3.6.4",
"element-ui": "^2.13.0",
"ol": "^6.4.3",
"vue": "^2.6.11",
"vue-amap": "^0.5.10",
"vue-class-component": "^7.2.2",
"vue-property-decorator": "^8.3.0",
"vue-router": "^3.1.5",
"vuex": "^3.1.2",
"vuex-class": "^0.3.2"
},
"devDependencies": {
"@vue/cli-plugin-babel": "^4.2.0",
"@vue/cli-plugin-typescript": "^4.2.0",
"@vue/cli-service": "^4.2.0",
"parcel-bundler": "^1.12.4",
"sass": "^1.25.0",
"sass-loader": "^8.0.2",
"typescript": "~3.7.5",
"vue-template-compiler": "^2.6.11"
},
"browserslist": [
"> 1%",
"last 2 versions"
]
}
body{padding: 0;margin: 0;background: #f9f9f9;overflow: hidden;width: 100%;height: 100%;font-size:14px;}
body.childPage{padding: 20px;}
[v-cloak]{display: none !important;}
.fl{float: left;}
.fr{float: right;}
.cent{text-align: center;}
.colorM{color: #1abc9c;}
.colorR{color: #F8333A;}
.colorB{color: #409EFF;}
.colorSL{color: #008000;}
.colorP{color: #6833F8;}
.pointer{cursor: pointer;}
.el-table th{background: #f9fafc;}
.el-table th,.el-table td{text-align: center;}
/* iframe{height: calc(100vh - 59px);} */
html{width: 100%;height: 100%;}
.hide{display: none;}
.marg10{margin-left: 10px;}
.margT10{margin-top: 10px;}
.iconfont{font-size: 20px;}
main > div{background: #ffffff;height:calc(100vh - 120px);padding: 0 10px;}
main > div .el-table{height:calc(100% - 120px);}
main > div .el-table .el-table__body-wrapper{height: calc(100% - 48px); overflow-y: auto;}
.userlist {
padding: 0 10px;
}
.topBar {
padding-top: 22px;
}
.el-pagination {
text-align: center;
padding-top: 20px;
}
.has-gutter tr th {
background: #f9fafc;
}
.el-dialog__body{max-height: 60vh;overflow: auto;}
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="utf-8">
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<meta name="viewport" content="width=device-width,initial-scale=1.0">
<link rel="icon" href="<%= BASE_URL %>logo.ico">
<link rel="stylesheet" href="//at.alicdn.com/t/font_1602732_a5503lsbuo.css"><!--单色 icon-->
<link rel="stylesheet" href="//at.alicdn.com/t/font_2005193_5ks6ghpnjgu.css"><!--图形-->
<script src="//at.alicdn.com/t/font_1767165_i3wsv6ptjfc.js"></script><!--彩色 svg icon-->
<link rel="stylesheet" href="./common.css"><!--自定义样式-->
<link rel="stylesheet" href="https://js.arcgis.com/3.33/dijit/themes/nihilo/nihilo.css">
<title>危化品企业监管平台</title>
</head>
<body>
<noscript>
<strong>We're sorry but <%= htmlWebpackPlugin.options.title %> doesn't work properly without JavaScript enabled. Please enable it to continue.</strong>
</noscript>
<div id="app"></div>
<!-- built files will be auto injected -->
</body>
<script src="https://js.arcgis.com/3.33/"></script>
</html>
<template>
<div id="app">
<router-view />
</div>
</template>
<script lang="ts">
import { Component, Vue } from 'vue-property-decorator';
@Component({
components: {
},
})
export default class App extends Vue {}
</script>
<style lang="scss">
#app {
font-family: Avenir, Helvetica, Arial, sans-serif;
width: 100%;
height: 100%;
}
</style>
<template>
<el-cascader
:disabled="disabled"
:options="options"
:props="props"
placeholder="请选择区域"
@change="handleChange"
v-model="citytxt"
></el-cascader>
</template>
<style lang="scss" scoped>
.el-cascader {
width: 100%;
}
</style>
<script lang="ts">
import { Component, Vue, Provide, Prop, Watch } from "vue-property-decorator";
import METHOD from "@/utils/methods";
// let city = require('@/assets/citycode.json');
@Component({
components: {}
})
export default class Home extends Vue {
@Prop({
//父组件传来的值
type: Array,
default() {
return [];
}
})
public valueqv: any;
@Prop(Boolean) param!: Boolean;
@Prop(Boolean) disabled!: Boolean;
@Provide() citytxt: any = [];
@Provide() options: any = [];
@Provide() props: any = {
value: "id",
label: "label",
children: "children"
};
@Watch("valueqv") formChange(v: any) {
this.citytxt = this.valueqv;
}
getTreeData() {
let that = this;
METHOD.axiosGet(that, `/district/getDistrictData`, function(res: any) {
if (res.code == 0) {
that.options = res.data;
sessionStorage.setItem("cityJson", JSON.stringify(res.data));
}
});
}
handleChange(v: any) {
this.$emit("changeFun", v);
}
created() {
this.citytxt = this.valueqv;
let cityData = sessionStorage.getItem("cityJson");
if (cityData) {
this.options = JSON.parse(cityData);
} else {
this.getTreeData();
}
}
}
</script>
This diff is collapsed.
<template>
<div class="mapwrap">
<el-dialog
title="绘制厂区边界"
:visible.sync="dialogTableVisible"
:show-close="false"
:close-on-click-modal="false"
id="mapcnt"
>
<el-row class="lt">
<el-button type="success" size="small" @click="starDrawBounds"
><i class="el-icon-edit"></i> 开始绘制</el-button
>
<el-button type="warning" size="small" @click="removeBounds"
><i class="el-icon-delete"></i> 清除绘制</el-button
>
<el-button type="primary" size="small" @click="confirmFun"
>提交边界</el-button
>
<el-button size="small" @click="$emit('dialogcancelFunB')"
>取消</el-button
>
</el-row>
<el-row>
<div id="mapContainerB" class="mapContainer">
<Search :MAP="MAP" :Mutil="Mutil" v-if="mapLoadDone"></Search>
</div>
</el-row>
</el-dialog>
</div>
</template>
<script lang="ts">
import { Component, Vue, Provide, Prop } from "vue-property-decorator";
import Search from "@/components/search.vue";
import Mutil from "@/utils/mapUtil.js";
@Component({
components: {
Search,
},
})
export default class DrawBounds extends Vue {
@Provide() MAP: any;
@Provide() Mutil: any;
@Provide() mapLoadDone = false;
@Prop(Boolean) dialogTableVisible!: Boolean;
@Prop(String) boundary!: String;
@Provide() Coordinates: any = [];
@Provide() mapView: any = {
center: "",
zoom: "",
polygoncoorArr: [],
};
@Provide() currSelectPolygon: any;
starDrawBounds() {
let that = this;
that.Mutil.drawPloygon(null, function (feature: any, target: any) {
//drawend 触发事件
let currView = that.MAP.getView();
that.mapView.center = currView.getCenter();
that.mapView.zoom = currView.getZoom();
let x = feature.getGeometry().getCoordinates({
right: true,
});
that.mapView.polygoncoorArr.push(x);
});
}
removeBounds() {
let that = this;
that.Mutil.removeSearchm("boundary");
that.mapView = {
center: "",
zoom: "",
polygoncoorArr: [],
};
}
confirmFun() {
let that = this;
that
.$confirm("确认提交厂区边界吗?", "提示", {
type: "info",
})
.then(() => {
that.$emit("drawconfirm", JSON.stringify(that.mapView));
that.$emit("dialogcancelFunB");
})
.catch(() => {
return;
});
}
mounted() {
let that = this;
console.log( that.dialogTableVisible )
that.$nextTick(() => {
that.Mutil = new Mutil("mapContainerB");
that.MAP = that.Mutil.MAP;
that.mapLoadDone = true;
if (that.boundary) {
that.mapView = JSON.parse((that as any).boundary);
that.Mutil.drawPloygon(JSON.parse((that as any).boundary));
}
that.Mutil.mapSelectBind((evt: any) => {
if (evt.selected[0].getGeometryName == "Polygon") {
that.currSelectPolygon = evt.selected[0];
}
});
});
}
}
</script>
<style lang="scss">
#mapcnt .el-dialog {
width: 90% !important;
}
.el-cascader {
width: 100%;
}
.lt .el-input {
width: 180px;
margin-right: 15px;
display: inline-block;
}
.mapContainer {
width: 100%;
height: 450px;
position: relative;
margin-top: 10px;
overflow: hidden;
}
.el-vue-amap-container {
width: 100%;
height: 100%;
}
.search-box {
position: absolute !important;
top: 10px;
left: 10px;
}
#searchbar input {
padding: 5px;
border: 1px solid royalblue;
border-radius: 5px;
min-width: 150px;
}
</style>
<template>
<div class="mapwrap">
<el-dialog
title="拾取坐标"
:visible.sync="dialogTableVisible"
:show-close="false"
:close-on-click-modal="false"
id="mapcnt"
>
<el-row class="lt">
经纬度:
<el-input
placeholder="经度"
v-model.number="lnglat.lng"
type="number"
></el-input>
<el-input
placeholder="纬度"
v-model.number="lnglat.lat"
type="number"
></el-input>
<el-button type="primary" size="small" @click="confirmFun"
>确定</el-button
>
<el-button size="small" @click="$emit('dialogcancelFun')"
>取消</el-button
>
</el-row>
<el-row>
<div id="mapContainer">
<Search :MAP="MAP" :Mutil="Mutil" v-if="mapLoadDone"></Search>
</div>
</el-row>
</el-dialog>
</div>
</template>
<script lang="ts">
import { Component, Vue, Provide, Prop } from "vue-property-decorator";
import Search from "@/components/search.vue";
import Mutil from "@/utils/mapUtil.js";
import { toLonLat } from "ol/proj";
@Component({
components: {
Search,
},
})
export default class Mapdialog extends Vue {
@Provide() MAP: any;
@Provide() Mutil: any;
@Provide() mapLoadDone = false;
@Prop(Number) slat!: Number;
@Prop(Number) slng!: Number;
@Prop(Boolean) dialogTableVisible!: Boolean;
@Provide() zoom: Number = 12;
@Provide() lnglat: any = {
lng: 0,
lat: 0,
};
mapClick() {
let that = this;
that.MAP.on("click", function (evt: any) {
let lnglat = toLonLat(evt.coordinate);
that.Mutil.removeSearchm("pickLngLat");
that.Mutil.addMarkerToMap(
"pickLngLat",
"",
require("@/assets/mark/pk.png"),
lnglat,
0.5
);
that.lnglat.lng = Number(lnglat[0].toPrecision(10));
that.lnglat.lat = Number(lnglat[1].toPrecision(10));
});
}
confirmFun() {
this.$emit("dialogcancelFun");
this.$emit("confirm", {
lng: this.lnglat.lng,
lat: this.lnglat.lat,
});
}
cancel() {}
mounted() {
let that = this;
that.$nextTick(() => {
that.Mutil = new Mutil("mapContainer");
that.MAP = that.Mutil.MAP;
that.mapLoadDone = true;
if (typeof that.slng == "number" && that.slng != 0) {
that.lnglat.lng = that.slng;
that.lnglat.lat = that.slat;
that.Mutil.addMarkerToMap(
"pickLngLat",
"",
require("@/assets/mark/pk.png"),
[that.slng, that.slat],
0.5
);
that.Mutil.setViewF({
center: [that.slng, that.slat],
zoom: 16,
});
}
that.mapClick();
});
}
}
</script>
<style lang="scss">
#mapcnt .el-dialog {
width: 90% !important;
}
.el-cascader {
width: 100%;
}
.lt .el-input {
width: 180px;
margin-right: 15px;
display: inline-block;
}
#mapContainer {
width: 100%;
height: 450px;
position: relative;
margin-top: 10px;
overflow: hidden;
}
.el-vue-amap-container {
width: 100%;
height: 100%;
}
.search-box {
position: absolute !important;
top: 10px;
left: 10px;
}
#searchbar input {
padding: 5px;
border: 1px solid royalblue;
border-radius: 5px;
min-width: 150px;
}
</style>
<template>
<div>
<div class="toolsboxbar pointer" @click="toolBoxShow = true">
<i class="el-icon-news"></i>态势标绘
</div>
<transition name="fade" mode="out-in">
<div class="toolsbox" v-if="toolBoxShow">
<h3>
标绘工具
<span class="fr pointer">
<i class="el-icon-close" @click="toolBoxShow = false"></i>
</span>
</h3>
<ul class="toolBar">
<li @click="toggleTool('drawMarker')" :class="{'cl': tabAct == 'drawMarker'}">
<i class="iconfont icon-hongqi-svg"></i>标记
</li>
<li @click="toggleTool('drawPolyline')" :class="{'cl': tabAct == 'drawPolyline'}">
<i class="iconfont icon-zhexian"></i>线段
</li>
<li @click="toggleTool('drawCircle')" :class="{'cl': tabAct == 'drawCircle'}">
<i class="iconfont icon-yuanxing"></i>圆形
</li>
<li @click="toggleTool('drawPolygon')" :class="{'cl': tabAct == 'drawPolygon'}">
<i class="iconfont icon-duobianxing"></i>多边形
</li>
<li @click="toggleTool('drawRule')" :class="{'cl': tabAct == 'drawRule'}">
<i class="iconfont icon-ceju"></i>测距
</li>
<li @click="toggleTool('drawMeasureArea')" :class="{'cl': tabAct == 'drawMeasureArea'}">
<i class="iconfont icon-cemianji"></i>面积
</li>
<li class="bjtx" @click="editOverlays()">编辑图形</li>
<li class="bjtx" @click="endEditOverlays()">关闭编辑</li>
<li class="bjtx" @click="delOverlays()">删除图形</li>
<li class="bjtx" @click="endOverlays()">结束绘制</li>
<li class="bjtx" @click="delAllOverlays()">清除所有</li>
</ul>
</div>
</transition>
</div>
</template>
<script lang="ts">
import { Component, Vue, Provide, Prop, Watch } from "vue-property-decorator";
@Component({
components: {},
})
export default class mouseTool extends Vue {
@Prop(Object) MAP!:Object;
@Prop() toolobj!:any;
@Prop(Object) mouseTool!:Object;
@Provide() editorArr: any = [];
@Provide() tabAct: any = "";
@Provide() toolBoxShow: boolean = false;
toggleTool(wd: any) {
let that = this;
that.tabAct = wd;
that.toolobj[wd]();
}
getAllDrawLays() {
let that = this,
laysArr = that.MAP.getAllOverlays(),
CircleArr: any = [],
MarkerArr: any = [],
PolylineArr: any = [],
PolygonArr: any = [];
laysArr.forEach((ele: any) => {
if (ele.CLASS_NAME == "AMap.Circle") CircleArr.push(ele);
if (ele.CLASS_NAME == "AMap.Polygon") PolygonArr.push(ele);
if (ele.CLASS_NAME == "AMap.Polyline") PolylineArr.push(ele);
if (ele.CLASS_NAME == "AMap.Marker" && ele.getzIndex() == 9999) {
MarkerArr.push(ele);
}
});
let allDrawLays = [
...CircleArr,
...MarkerArr,
...PolylineArr,
...PolygonArr,
];
return {
allDrawLays,
CircleArr,
MarkerArr,
PolylineArr,
PolygonArr,
};
}
editOverlays() {
let that = this,
layobj = that.getAllDrawLays(),
polyArr = [...layobj.PolylineArr, ...layobj.PolylineArr],
type = that.tabAct.substring(4);
switch (type) {
case "Circle":
if (layobj.CircleArr.length > 0)
layobj.CircleArr.forEach((ele: any) => {
let editor = new AMap.CircleEditor(that.MAP, ele);
editor.open();
that.editorArr.push(editor);
});
break;
case "Polyline":
if (layobj.PolylineArr.length > 0)
layobj.PolylineArr.forEach((ele: any) => {
let editor = new AMap.PolyEditor(that.MAP, ele);
editor.open();
that.editorArr.push(editor);
});
break;
case "Polygon":
if (layobj.PolygonArr.length > 0)
layobj.PolygonArr.forEach((ele: any) => {
let editor = new AMap.PolyEditor(that.MAP, ele);
editor.open();
that.editorArr.push(editor);
});
break;
}
}
alertFun(len: number, type: string, isedit: boolean) {
let stype = "",
html = "";
switch (type) {
case "Circle":
stype = "圆形";
break;
case "Polyline":
stype = "线段";
break;
case "Polygon":
stype = "多边形";
break;
}
for (let i = 0; i < len; i++) {
let lena = i + 1;
if (isedit)
html += `<input name="in" type="radio" onClick="window.clickRadioLays(${lena})"/>第${lena}${stype}`;
else
html += `<input name="in" type="radio" onClick="window.delRadioLays(${lena})"/>第${lena}${stype}`;
}
this.$alert(html, "选择", {
closeOnClickModal: true,
showConfirmButton: false,
dangerouslyUseHTMLString: true,
});
}
endEditOverlays() {
let that = this;
if (that.editorArr.length > 0) {
that.editorArr.forEach((ele: any) => {
ele.close();
});
}
}
delAllOverlays() {
let that = this;
that.mouseTool.close(true);
that.tabAct = "";
}
endOverlays() {
let that = this;
that.mouseTool.close(false);
that.tabAct = "";
}
delOverlays() {
let that = this,
layobj: any = that.getAllDrawLays(),
html = "",
type = that.tabAct.substring(4),
len = layobj[type + "Arr"] ? layobj[type + "Arr"].length : "";
(window as any).delRadioLays = function (num: any) {
that.MAP.remove(layobj[type + "Arr"][num - 1]);
};
if (len > 0) that.alertFun(len, type, false);
}
created() {
}
}
</script>
<style lang="scss">
@import "@/utils/public.scss";
.toolsboxbar {
position: absolute;
right: 85px;
top: 12px;
z-index: 2;
border: 1px solid blue;
background: white;
color: blue;
padding: 3px 5px;
font-size: medium;
border-radius: 3px;
box-shadow: 1px 1px 3px 1px #a09e9e;
}
.toolsbox {
width: 155px;
position: absolute;
right: 80px;
top: 12px;
z-index: 2;
background: #fff;
h3 {
text-align: left;
margin: 0;
line-height: 1.8;
background: #000;
color: white;
padding: 0 5px;
}
}
.toolBar {
overflow: hidden;
display: flex;
margin: 0;
padding: 0;
width: 100%;
flex-wrap: wrap;
justify-content: space-between;
padding: 5px;
box-sizing: border-box;
li {
display: inline-block;
border: 1px solid #333;
padding: 2px;
border-radius: 3px;
cursor: pointer;
min-width: 60px;
text-align: center;
margin: 2px 0;
&.cl {
background: #0000ff;
color: white;
}
&.bjtx {
&:hover {
background: #08785c;
color: white;
}
}
.clr {
background: #08785c;
color: white;
}
}
}
</style>
\ No newline at end of file
<template>
<div class="wrapper editwrap">
<el-dialog
:visible.sync="qxdialogVisible"
:title="'权限分配_' + roleName"
:show-close="false"
:close-on-click-modal="false"
>
<el-row :gutter="10">
<el-col :span="12">
<h4>菜单权限</h4>
<el-tree
:data="menuData"
show-checkbox
default-expand-all
ref="menuTree"
node-key="resourceId"
:props="Props"
:default-checked-keys="menuCheckedArr"
@check-change="menucheckchange"
></el-tree>
</el-col>
<el-col :span="12">
<h4>API权限</h4>
<el-tree
:data="apiData"
show-checkbox
default-expand-all
ref="apiTree"
:props="PropsB"
node-key="resourceId"
:default-checked-keys="apiCheckedArr"
@check-change="apicheckchange"
></el-tree>
</el-col>
</el-row>
<el-alert v-show="alertshow" title="请选择权限" show-icon type="warning" :closable="false"></el-alert>
<span slot="footer" class="dialog-footer">
<el-button type="primary" size="small" @click="confirmFun()">确定</el-button>
<el-button @click="$emit('QXdialogFun')" size="small">取消</el-button>
</span>
</el-dialog>
</div>
</template>
<script lang="ts">
import { Component, Vue, Provide, Prop, Watch } from "vue-property-decorator";
@Component({
components: {}
})
export default class quan extends Vue {
@Prop(Boolean) qxdialogVisible!: Boolean;
@Prop(String) roleID!: String;
@Prop(String) roleName!: String;
//tree
@Provide() menuData: any = [];
@Provide() Props: Object = {
label: "menuName",
children: "childList"
};
@Provide() PropsB: Object = {
label: "resourceName",
children: "childList"
};
@Provide() apiData: any = [];
@Provide() menuCheckedArr: any = []; //默认选中节点
@Provide() apiCheckedArr: any = []; //默认选中节点
@Provide() menuTreeArr: any = []; //tree1选中节点
@Provide() apiTreeArr: any = []; //tree2选中节点
@Provide() allArr: any = [];//所有选中节点
@Provide() alertshow: Boolean = false;
@Watch("allArr") change(newVal: any) {
if (newVal.length == 0) this.alertshow = true;
else this.alertshow = false;
}
/*getMData(type: String) {
let that = this;
(this as any).$axios
.get(`/resource/getResourcesList/${type}`)
.then((res: any) => {
if (type == "MENU") {
that.menuData = res;
} else if (type == "REST-API") {
that.apiData = res;
}
});
}*/
getTreeData(type: String) {
let that = this;
(this as any).$axios
.get(`/role/getRoleResourcesByRoleId/${that.roleID}?resourceType=${type}`)
.then((res: any) => {
if( res.code != 0 ) return;
if (type == "MENU") {
that.menuData = res.data;
that.menuCheckedArr = that.getCheckedArr(res.data);
that.$nextTick(() => {
that.menuTreeArr = (that as any).$refs.menuTree.getCheckedNodes();
});
} else if (type == "REST-API") {
that.apiData = res.data;
that.apiCheckedArr = that.getCheckedArr(res.data);
that.$nextTick(() => {
that.apiTreeArr = (that as any).$refs.apiTree.getCheckedNodes();
});
}
});
}
getCheckedArr(list: any) {
let arr: any = [];
list.forEach((ele: any) => {
if (ele.selected == "true") {
arr.push(ele.resourceId);
}
if (ele.childList.length > 0) {
ele.childList.forEach((sele: any) => {
if (sele.selected == "true") {
arr.push(sele.resourceId);
}
});
}
});
return arr;
}
confirmFun() {
let that = this,
param: any = [];
that.menucheckchange()
that.apicheckchange()
if (!that.alertshow) {
that.allArr.forEach((ele: any) => {
param.push({
resourceId: ele.resourceId,
roleId: that.roleID,
rid: ele.rid
});
});
that.$emit("confirm", param);
}
}
menucheckchange() {
let that = this;
that.menuTreeArr = (that as any).$refs.menuTree.getCheckedNodes();
that.allArr = [...that.menuTreeArr, ...that.apiTreeArr];
}
apicheckchange() {
let that = this;
that.apiTreeArr = (that as any).$refs.apiTree.getCheckedNodes();
that.allArr = [...that.menuTreeArr, ...that.apiTreeArr];
}
created() {
// this.getMData("REST-API");
// this.getMData("MENU");
let that = this;
that.getTreeData("REST-API");
that.getTreeData("MENU");
}
}
</script>
\ No newline at end of file
<template>
<div>
<div class="funBox">
<div class="funBox-item ser">
<input type="text" placeholder="输入地址" v-model="serVal" /><button @click="mapSearch()"></button>
<div class="serTip" v-if="tipsShow">
<div class="aimAdone">
<p>您可以尝试:</p>
<p>1、检查输入是否正确</p>
<p>2、输入其他关键字进行搜索</p>
</div>
</div>
<!-- 目标地点 -->
<div class="serTip" v-if="aimAdrsArr.length > 0">
<div v-for="(i, inde) in aimAdrsArr" :key="inde" class="aimAdone" @click="mapSetView(i.lonlat)">
<p>{{ inde + 1 + ". " + i.name }}</p>
<p class="grey">地址:{{ i.address }}</p>
</div>
</div>
<div class="serTip" v-if="serTipArr.length > 0">
<!-- 建议地点 -->
<ul>
<li v-for="(i, ind) in serTipArr" :key="ind" @click="toAimAdress(i.name)">
{{ i.name }}<span class="addressTxt">{{ i.address }}</span>
</li>
</ul>
</div>
</div>
<!-- <div
class="funBox-item btn"
v-for="(i, index) in mapStyleArr"
@click="changeMapStyle(index), (actInde = index)"
:key="index"
:class="{ atc: actInde == index }"
>
{{ i.word }}
</div> -->
</div>
</div>
</template>
<script>
import {
Component,
Vue,
Provide,
Watch
} from "vue-property-decorator";
import {
fromLonLat,
toLonLat
} from "ol/proj";
import {
Prop
} from "vue-property-decorator";
// import Mutil from "@/utils/mapUtil.js";
import axios from "axios";
@Component({
components: {},
})
export default class search extends Vue {
@Prop(Object) MAP;
@Prop(Object) Mutil;
@Provide() serVal = "";
@Provide() Mutil;
@Provide() mapStyleArr = [{
key: "gooleSatellite",
word: "谷歌卫星地图",
},
{
key: "amapSatellite",
word: "高德卫星地图",
},
{
key: "amapCity",
word: "高德城市地图",
},
// {
// key: "amapCity",
// word: "天地图",
// },
];
@Provide() serTipArr = [];
@Provide() aimAdrsArr = [];
@Provide() actInde = 0;
@Provide() tipsShow = false;
/*
调用高德api 搜索位置
*/
@Watch("serVal") change(newVal) {
if (newVal == "") {
this.Mutil.removeSearchm('searchM');
this.tipsShow = false;
this.serTipArr = [];
return;
}
this.searchFun("4", newVal);
}
searchFun(type, newVal) {
let that = this,
url = "http://api.tianditu.gov.cn/search";
that.serTipArr = [];
that.aimAdrsArr = [];
that.tipsShow = false;
axios
.get(url, {
params: {
type: "query",
postStr: {
// specifyAdminCode: "130100000000",
keyWord: newVal,
mapBound: "114.34193,37.92687,114.63753,38.16345",
level: "12",
queryType: type, //4:普通建议词搜索, 1:普通搜索,
start: "0",
count: 10,
},
tk: "c8df739f047ce17cfe41b63cbeae6997",
},
})
.then((res) => {
if (type == 4 && res.status == 200) {
if (res.data.suggests) {
that.tipsShow = false;
let {
suggests: tipsData
} = res.data;
that.serTipArr = tipsData;
} else {
that.serTipArr = [];
that.tipsShow = true;
}
}
if (type == 1 && res.status == 200) {
if (res.data.pois) {
that.tipsShow = false;
let {
pois: aimsData
} = res.data;
that.aimAdrsArr = aimsData;
that.Mutil.removeSearchm('searchM');
//标注到地图
that.aimAdrsArr.forEach((ele, inde) => {
let lnglat = ele.lonlat.split(" ");
that.Mutil.addMarkerToMap(
'searchM',
ele.name,
require("@/assets/mark/pick.png"),
[Number(lnglat[0]), Number(lnglat[1])],
0.5
);
if (inde == 0) {
that.MAP.getView().animate({
center: fromLonLat([Number(lnglat[0]), Number(lnglat[1])]),
zoom: 17,
duration: 1000,
});
}
});
} else {
that.aimAdrsArr = [];
that.tipsShow = true;
}
}
})
.catch((err) => {
that.$message.error(err);
});
}
mapSetView(lnglat) {
let that = this,
lonlat = lnglat.split(" ");
that.MAP.getView().animate({
center: fromLonLat([Number(lonlat[0]), Number(lonlat[1])]),
zoom: 17,
duration: 1000,
});
}
mapSearch() {
let that = this,
url = "https://restapi.amap.com/v3/place/text";
that.$axios
.get(
url +
`?key=a827e19b0efcc8bf58afb4f23de188d9&keywords=${that.serVal}?city='河北省'`
)
.then((res) => {
console.log(res);
})
.catch((err) => console.log(err));
}
toAimAdress(name) {
this.serTipArr = [];
this.searchFun("1", name);
}
changeMapStyle(inde) {
let that = this,
arr = [0, 1, 2, 3];
console.log(inde);
arr.forEach((ele) => {
if (ele != inde) that.MAP.getLayers().getArray()[ele].setVisible(false);
});
that.MAP.getLayers().getArray()[inde].setVisible(true);
}
created() {
}
}
</script>
<style>
.funBox {
position: absolute;
top: 10px;
left: 41px;
z-index: 2;
}
.funBox-item {
float: left;
background: #fff;
padding: 5px;
}
.funBox .ser {
width: 265px;
height: 45px;
box-sizing: border-box;
z-index: 2202;
border-radius: 2px;
position: relative;
}
.funBox .ser input {
position: absolute;
top: 12.5px;
box-sizing: border-box;
text-indent: 2px;
z-index: 2200;
border: none;
width: 219px;
height: 20px;
line-height: 20px;
padding: 0;
letter-spacing: 0.5px;
font-size: 14px;
}
.funBox .ser input:focus {
border: none;
outline: none;
}
.funBox button {
background: url("https://g.csdnimg.cn/common/csdn-toolbar/images/csdn-black-search.png") no-repeat center;
background-size: 80%;
position: absolute;
right: 0;
top: 0;
z-index: 9308;
box-sizing: border-box;
width: 45px;
height: 45px;
outline: none;
border: none;
border-left: #eee 1px solid;
}
.funBox .btn {
line-height: 25px;
padding: 10px 8px;
border-right: #afc5ee 1px dashed;
font-size: 14px;
cursor: pointer;
}
.funBox .btn:last-child {
border: none;
}
.serTip {
overflow: hidden;
position: absolute;
top: 47px;
left: 0;
width: 100%;
height: auto;
z-index: 9;
background: #fff;
}
.serTip ul {
margin: 0;
padding: 0;
}
.serTip li {
line-height: 2;
list-style: none;
font-size: 14px;
color: black;
padding: 0 10px;
width: 100%;
overflow: hidden;
height: 2em;
cursor: pointer;
}
.serTip li:hover {
background: #eee;
}
.aimAdone {
padding: 0 10px;
cursor: pointer;
}
.aimAdone:hover {
background: burlywood;
}
.addressTxt {
margin-left: 10px;
margin-right: 5px;
color: #999;
font-size: 12px;
}
.grey {
font-size: 12px;
color: #999;
}
.atc {
color: blue;
}
</style>
import Vue from 'vue'
import App from './App.vue'
import router from './router'
import store from './store'
import axios from './utils/http'
import ElementUI from 'element-ui'
import 'element-ui/lib/theme-chalk/index.css'
import dataV from '@jiaminghi/data-view'
// import VueAMap from 'vue-amap'
Vue.use(ElementUI)
Vue.use(dataV)
// Vue.use(VueAMap)
Vue.config.productionTip = false;
Vue.prototype.$axios = axios;
new Vue({
router,
store,
render: h => h(App)
}).$mount('#app')
This diff is collapsed.
import Vue, { VNode } from 'vue'
declare global {
namespace JSX {
// tslint:disable no-empty-interface
interface Element extends VNode {}
// tslint:disable no-empty-interface
interface ElementClass extends Vue {}
interface IntrinsicElements {
[elem: string]: any
}
}
}
declare module '*.vue' {
import Vue from 'vue'
export default Vue
}
declare module 'vue-amap';
import { ActionTree } from 'vuex'
const actions: ActionTree<any, any> = {
async setMoudleArr({state, commit} , moudleArr: any){
commit('SET_MOUDLEARR', moudleArr)
}
}
export default actions;
\ No newline at end of file
import { GetterTree } from 'vuex'
const getters: GetterTree<any, any> = {
moudleArr(state: any) : any {
return state.moudleArr
},
}
export default getters;
\ No newline at end of file
import Vue from 'vue'
import Vuex from 'vuex';
import state from './state'
import getters from './getters'
import mutations from './mutations'
import actions from './actions'
Vue.use(Vuex)
export default new Vuex.Store({
state,
getters,
mutations,
actions
})
\ No newline at end of file
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment