Commit fd33c9ed by zhangxw
2 parents 2df94fd2 589c39eb
......@@ -15,6 +15,13 @@
"libraryName": "element-ui",
"styleLibraryName": "theme-chalk"
}
],
[
"import",
{
"libraryName": "vxe-table",
"style": true // 样式是否也按需加载
}
]
]
}
......@@ -34,7 +34,7 @@ module.exports = {
},
externals: {
vue: 'Vue',
'element-ui': 'ElementUI'
//'element-ui': 'ElementUI'
},
module: {
rules: [
......@@ -90,6 +90,7 @@ module.exports = {
test: /\.(png|jpg|gif|svg)$/,
loader: 'file-loader',
options: {
limit: 10000,
name: 'images/[name].[ext]?[hash]',
publicPath: resourcesPath
}
......
This diff could not be displayed because it is too large.
......@@ -11,6 +11,7 @@
"build": "cross-env NODE_ENV=production webpack --progress --hide-modules --config config/webpack.config.js"
},
"dependencies": {
"@amap/amap-jsapi-loader": "^1.0.1",
"animate.css": "^3.7.0",
"axios": "^0.18.0",
"calendar-months": "^1.0.1",
......@@ -22,14 +23,16 @@
"es6-promise": "^4.2.4",
"font-awesome": "^4.7.0",
"moment": "^2.22.0",
"node-sass": "^7.0.1",
"qs": "^6.5.1",
"sass": "^1.45.1",
"vue": "^2.5.11",
"vue-infinite-loading": "^2.3.1",
"vue-router": "^3.0.1",
"vue-template-compiler": "^2.6.14",
"vuex": "^3.0.1",
"xlsx": "^0.14.0",
"node-sass":"7.0.1"
"vxe-table": "^3.5.5",
"xe-utils": "^3.5.4",
"xlsx": "^0.14.0"
},
"browserslist": [
"> 1%",
......@@ -60,7 +63,6 @@
"url-loader": "^1.0.1",
"vue-loader": "^14.2.2",
"vue-style-loader": "^4.1.0",
"vue-template-compiler": "^2.5.16",
"webpack": "^4.6.0",
"webpack-bundle-analyzer": "^2.11.1",
"webpack-cli": "^2.0.14",
......
......@@ -25,26 +25,26 @@
</template>
<script>
import store from './vuex/store.js'
import { mapGetters, mapActions } from 'vuex'
import vSideBar from 'components/SideBar.vue'
import store from "./vuex/store.js";
import { mapGetters, mapActions } from "vuex";
import vSideBar from "components/SideBar.vue";
export default {
name: 'app',
name: "app",
data() {
return {
isQiankun: window.__POWERED_BY_QIANKUN__,
logo: require('images/logo.png')
}
return {
isQiankun: window.__POWERED_BY_QIANKUN__,
logo: require("images/logo.png"),
};
},
watch: {
$route(to, from) {
if(this.isQiankun) {
if (this.isQiankun) {
this.getBreadcrumb();
}
}
},
},
mounted(){
mounted() {
// store.dispatch('getDeviceResources')
// store.dispatch('getLoginUser').then((res)=>{
// if(store.state.common.username === 'gqgdcx'){
......@@ -62,90 +62,107 @@ export default {
// g = d.getElementsByTagName('body')[0],
// x = w.innerWidth || e.clientWidth || g.clientWidth,
// y = w.innerHeight|| e.clientHeight|| g.clientHeight;
// d.getElementsByTagName('main')[0].style['minHeight'] = y+'px'
// }
// window.onresize()
this.$onGlobalStateChange((state, prev) => {
if(state.isCollapsed != this.isCollapse) {
this.toggleCollapse()
if (state.isCollapsed != this.isCollapse) {
this.toggleCollapse();
}
})
});
},
computed: {
...mapGetters([
'isCollapse',
'isFullsize'
])
...mapGetters(["isCollapse", "isFullsize"]),
},
methods: {
getBreadcrumb() {
const { getters: {curBreadCrumb}} = this.$root.parentVuex;
let matched = this.$route.matched.filter(item => item.name); // this.$route.matched 可以获取到一个数组,包含当前路由的所有嵌套路径片段的路由记录
const {
getters: { curBreadCrumb },
} = this.$root.parentVuex;
let matched = this.$route.matched.filter((item) => item.name); // this.$route.matched 可以获取到一个数组,包含当前路由的所有嵌套路径片段的路由记录
const first = matched[0];
const { meta, path } = first;
const basePath = '/oEshield#';
const basePath = "/oEshield#";
let breadcrumb = [];
if(meta) {
if (meta) {
const { title, pushState } = meta;
if(pushState && title) {
if (pushState && title) {
breadcrumb.push({
name: title,
path: basePath + path
})
path: basePath + path,
});
history.state.pushState = pushState;
history.state.breadcrumb = [...curBreadCrumb, breadcrumb[0]];
// this.$root.parentVuex.dispatch('menu/setBreadCrumb', [...curBreadCrumb, breadcrumb]);
}
}
},
toggle(){
this.toggleCollapse()
toggle() {
this.toggleCollapse();
},
...mapActions([
'toggleCollapse'
]),
navigate(){
let routeData = this.$router.resolve({
path: '/notice',
query: {
}
...mapActions(["toggleCollapse"]),
navigate() {
let routeData = this.$router.resolve({
path: "/notice",
query: {},
});
window.open(routeData.href, '_blank');
}
window.open(routeData.href, "_blank");
},
},
components: {
vSideBar
vSideBar,
},
store
}
store,
};
</script>
<style scoped>
.topbar {
min-height: 50px;
padding: 15px 10px;
}
.toggle-btn, .logo{
vertical-align: middle;
}
.logo{
margin-left: 10px;
}
a.right-link{
color: #999;
font-size: 14px;
margin-right: 20px;
line-height: 30px;
text-decoration: none;
}
.full-size main{
margin: 0;
.topbar {
min-height: 50px;
padding: 15px 10px;
}
.toggle-btn,
.logo {
vertical-align: middle;
}
.logo {
margin-left: 10px;
}
a.right-link {
color: #999;
font-size: 14px;
margin-right: 20px;
line-height: 30px;
text-decoration: none;
}
.full-size main {
margin: 0;
}
.full-size .sidebar,
.full-size .topbar {
display: none;
}
</style>
<style lang="scss">
.el_table {
thead {
th {
background: rgba($color: #f2f2f2, $alpha: 0.5) !important;
}
}
.full-size .sidebar, .full-size .topbar{
display: none;
}
.links_group {
position: relative;
display: flex;
align-items: flex-end;
justify-content: space-between;
padding: 10px 0;
.name {
font-size: 18px;
font-weight: bold;
color: #666;
}
}
</style>
import api from '../config.js'
import request from './request'
export default {
getLoginUser (request = {}) {
getLoginUser(request = {}) {
return api.get('common/getLoginUser', request)
},
/*获取用户角色信息*/
getUserRoleInfo() {
return api.get('user/getRoleInfo')
},
/*车辆品牌*/
getAllVehicleBrand (request = {}) {
getAllVehicleBrand(request = {}) {
return api.get('vehicle/getAllVehicleBrand', request)
},
getBrandTypeByBrandId(request = {}) {
return api.get('vehicle/getBrandTypeByBrandId', request)
},
/*车辆分组分类*/
getAllVehicleGroup (request = {}) {
getAllVehicleGroup(request = {}) {
return api.get('vehiclegroup/getAllVehicleGroup', request)
},
getClassListByGroupId (request = {}) {
getClassListByGroupId(request = {}) {
return api.get('vehicleclass/getClassListByGroupId', request)
},
/*获取菜单权限*/
getDeviceResources (request = {}) {
getDeviceResources(request = {}) {
return api.get('user/userDeviceResources', request)
}
}
// 获取车辆树
export const GET_ORGANIZATION_TREE = params => {
return request(params, '/usercenter/organization/orgtree')
}
\ No newline at end of file
import request from './request'
import store from "@/vuex/store";
// 新增围栏
export const SAVE_ELECFENCE_INFO = params => {
return request(params, '/trialdrive/elecfence/add', 'POST')
}
// 更新围栏
export const UPDATE_ELECFENCE_INFO = params => {
return request(params, '/trialdrive/elecfence/edit', 'POST')
}
// 获取围栏详情
export const GET_ELECFENCE_INFO = params => {
return request(params, '/trialdrive/elecfence/info')
}
//新增、编辑围栏-获取关联设备列表
export const GET_ELECFENCE_LINKEDDEVICES = params => {
return request(params, '/trialdrive/elecfence/linkedDevices')
}
//新增、编辑围栏-关联设备-获取用户权限设备列表接口
export const GET_ELECFENCE_LINKSNS = params => {
return request(params, '/trialdrive/elecfence/linksns/search')
}
//新增、编辑围栏-批量删除关联设备
export const REMOVE_ELECFENCE_LINKEDDEVICES = params => {
return request(params, '/trialdrive/elecfence/batchUnlink')
}
//新增、编辑围栏-批量导入关联设备
export const IMPORT_ELECFENCE_LINKEDDEVICES = `${store.getters.baseURL}/trialdrive/elecfence/batchImport`
//新增、编辑围栏-批量导入模板下载
export const DOWN_ELECFENCE_EXCELTEMPLATE = params => {
return request(params, '/publiccenter/dict/data/type/excelTemplate/batchLinkFenceSns')
}
\ No newline at end of file
......@@ -142,3 +142,13 @@ export default {
export const GET_DEVICEINFO_BYSNS = params => {
return request(params, '/trialdrive/monitor/vehiclelocation')
}
// 批量查询设备位置点
export const GET_DEVICE_LOCATION = params => {
return request(params, '/trialdrive/monitor/vehiclelocation', 'get')
}
// 批量查询设备在线状态
export const GET_MONITOR_ONLINELIST = params => {
return request(params, '/devicemonitor/monitor/onlinelist', 'get')
}
\ No newline at end of file
import request from './request'
// 轨迹回放-获取轨迹回放位置点
export const GET_DEVICE_LISTTRACKPOINT = params => {
return request(params, '/devicemonitor/monitor/listtrackpoint')
}
\ No newline at end of file
This diff could not be displayed because it is too large.
.wrap {
/* min-height: 949px; */
main {
display: block;
margin: 0;
//background-color: #f3f3f4;
/*min-height: 949px;
*/position: relative;
*/
position: relative;
-webkit-transition: margin .1s linear;
transition: margin .1s linear;
-moz-transition: margin .1s linear;
-ms-transition: margin .1s linear;
-o-transition: margin .1s linear;
}
}
.sidebar {
position: absolute;
......@@ -20,14 +21,16 @@
left: 0px;
width: 220px;
height: 100%;
-webkit-transition: width .1s linear;
transition: width .1s linear;
-webkit-transition: width .1s linear;
transition: width .1s linear;
font-size: 13px !important;
* {
font-size: 13px !important;
}
color:#a7b1c2;
}
&.full-width {
......@@ -36,13 +39,15 @@
/* -webkit-transition: margin .3s linear;
transition: margin .3s linear; */
}
.sidebar {
width: 64px;
width: 64px;
/* -webkit-transition: width .3s linear;
transition: width .3s linear; */
}
.nav-footer{
.nav-footer {
display: none;
}
}
......@@ -69,33 +74,38 @@
.el-popper[x-placement^="bottom"] {
margin-top: 2px;
}
.el-input.is-disabled .el-input__inner{
.el-input.is-disabled .el-input__inner {
color: #666;
}
/* .el-table--scrollable-x .el-table__body-wrapper{解决被遮挡
z-index: 100;
} */
.el-date-editor{
.el-date-editor {
vertical-align: middle;
}
.table-header-ctrl {
margin: 0px;
min-height: 70px;
.el-input,
.el-date-editor,
.el-select {
width: 100%;
}
.el-input__suffix {
right: 15px;
}
input{
input {
border-radius: 0px;
}
.el-date-editor{
.el-date-editor {
border-radius: 0px;
margin-top: 7px;
}
......@@ -103,6 +113,7 @@
td.ctrl-column {
padding-left: 50px;
.el-dropdown {
margin-top: 5px;
}
......@@ -120,37 +131,62 @@ td.ctrl-column {
.el-table th>.cell {
color: #666;
}
.pull-right{
float: right;
.pull-right {
float: right;
}
.pull-left{
float: left;
.pull-left {
float: left;
}
.text-center{
.text-center {
text-align: center;
}
.table-page-wrap{
float: right;
margin: 20px 0px;
.table-page-wrap {
float: right;
margin: 20px 0px;
}
.el-message{//避免被el-dialog遮罩层遮住
.el-message {
//避免被el-dialog遮罩层遮住
z-index: 3000 !important;
}
.el-tree .device-invalid{
.el-tree .device-invalid {
color: #999;
}
.el-tree-node:focus > .el-tree-node__content{
.el-tree-node:focus>.el-tree-node__content {
background-color: inherit;
}
#editOrderModal #color .el-form-item__label{
color: red !important;
#editOrderModal #color .el-form-item__label {
color: red !important;
}
.el-alert--success {
background-color: #f0f9eb;
color: #67c23a;
}
.el-alert--error {
background-color: #fef0f0;
color: #f56c6c;
}
// 监控页面图标
.icon_info_shop {
width: 24px;
height: 24px;
background: url('../images/info_shop.png') no-repeat;
background-size: 24px auto;
}
.icon_info_plate {
background: url('../images/info_plate.png') no-repeat;
background-size: 24px auto;
width: 24px;
height: 24px;
}
\ No newline at end of file
......@@ -34,7 +34,10 @@ h3.uimap-info-title{
word-break: break-all;
}
.amap-controls{
display: none;
//display: none;
}
.amap-logo,.amap-copyright{
display: none !important;
}
.navg-info-window{
background-color: #fff;
......
.map-wrap{
// position: absolute;
// top: 100px;
// left: 0;
width: 100%;
height: calc(100% - 100px);
overflow: hidden;
.map-controll{
position: absolute;
top: 40px;
right: 250px;
z-index: 102;
.fullsize-btn{
margin-left: 20px;
}
}
.map-bottom-controll{
position: absolute;
bottom: 30px;
right: 20px;
z-index: 102;
ul{
border: 1px solid #eee;
color: #094;
}
.ctrl-item{
background-color: #fff;
padding: 6px 10px;
font-size: 16px;
}
}
.controll-wrap{
position: absolute;
top: 40px;
left: 40px;
z-index: 101;
width: 320px;
max-height: 716px;
}
.menu-search{
.el-select{
width: 100px;
}
.input-with-select{
width: 100%;
}
.el-input-group__append{
background: #094;
border-color: #094;
color: #fff;
font-size: 16px;
}
.el-input-group__append:hover, .el-input-group__append:focus {
background: #33ad69;
border-color: #33ad69;
}
}
.filter-entrance{
margin-top: 10px;
background-color: rgba(255,255,255,0.9);
//border: 1px solid #dcdfe6;
box-shadow: 1px 1px 5px #dcdfe6;
.el-button{
padding: 6px;
}
}
.filter-dialog-set{
margin-top: 10px;
height: 100%;
position: relative;
}
.filter-dialog{
position: absolute;
top: 0;
left: 0;
width: 100%;
background-color: #fff;
border: 1px solid #dcdfe6;
box-sizing: border-box;
.filter-dialog-header{
text-align: center;
padding: 8px;
border-bottom: 1px solid #eee;
.el-icon-close{
font-size: 16px;
cursor: pointer;
}
}
.filter-dialog-body{
padding: 15px;
.upload-wrap{
.el-select{
width: 100px;
}
.input-with-select{
width: 100%;
}
}
}
.upload-sure-btn{
width: 100%;
}
animation-duration: .5s;
animation-delay: 0s;
display: none;
&.active{
display: block
}
.sub-filter{
padding-bottom: 15px;
border-bottom: 1px solid #eee;
}
.monitor-list{
max-height: calc(100vh - 280px);
/* max-height: 568px; */
overflow: auto;
margin-right: -10px;
padding-right: 10px;
}
.monitor-list-item{
display: flex;
border-bottom: 1px solid #eee;
.user-info{
flex: 1;
color: #666;
&>p{
margin: 8px 0;
}
.name{
color: #333;
margin-right: 15px;
}
}
&:last-child{
border-bottom: none;
}
.device-icon{
margin-right: 5px;
margin-top: 12px;
}
}
.device-icon-label{
display: inline-block;
margin-left: 5px;
}
.device-icon{
display: inline-block;
vertical-align: middle;
width: 8px;
height: 8px;
border-radius: 5px;
background-color: rgba(0,153,68,0.8);
&.offline{
background-color: rgba(255,0,0,0.8);
}
}
.filter-dialog-footer{
border-top: 1px solid #eee;
padding: 10px;
span{
vertical-align: middle;
}
}
}
.search-box{
.date-filter{
position: absolute;
top: 0px;
right: 0px;
}
.el-form--inline .el-form-item{
margin-right: 0px;
}
.stay-ctrl{
margin-top: 5px;
input{
width: 100%;
}
.el-form-item{
margin-bottom: 0px;
}
.unit{
line-height: 30px;
margin-left: 10px;
}
}
.el-range-editor--mini .el-range-input{
width: 115px;
}
.el-form-item{
margin-bottom: 15px;
}
.submit-el-form-item{
margin-top: 20px;
}
}
.search-box, .result-box{
padding: 20px;
background: #fff;
box-shadow: 1px 1px 4px #ccc;
display: none;
}
.search-box.active, .result-box.active{
display: block;
}
.result-box{
/* height: 100%;
.map-wrap {
// position: absolute;
// top: 100px;
// left: 0;
width: 100%;
height: calc(100% - 100px);
overflow: hidden;
.map-controll {
position: absolute;
top: 40px;
right: 250px;
z-index: 102;
.fullsize-btn {
margin-left: 20px;
}
}
.map-bottom-controll {
position: absolute;
bottom: 30px;
right: 20px;
z-index: 102;
ul {
border: 1px solid #eee;
color: #094;
}
.ctrl-item {
background-color: #fff;
padding: 6px 10px;
font-size: 16px;
}
}
.controll-wrap {
position: absolute;
top: 40px;
left: 40px;
z-index: 101;
width: 320px;
max-height: 716px;
}
.menu-search {
.el-select {
width: 100px;
}
.input-with-select {
width: 100%;
}
.el-input-group__append {
background: #094;
border-color: #094;
color: #fff;
font-size: 16px;
}
.el-input-group__append:hover,
.el-input-group__append:focus {
background: #33ad69;
border-color: #33ad69;
}
}
.filter-entrance {
margin-top: 10px;
background-color: rgba(255, 255, 255, 0.9);
//border: 1px solid #dcdfe6;
box-shadow: 1px 1px 5px #dcdfe6;
.el-button {
padding: 6px;
}
}
.filter-dialog-set {
margin-top: 10px;
height: 100%;
position: relative;
}
.filter-dialog {
position: absolute;
top: 0;
left: 0;
width: 100%;
background-color: #fff;
border: 1px solid #dcdfe6;
box-sizing: border-box;
.filter-dialog-header {
text-align: center;
padding: 8px;
border-bottom: 1px solid #eee;
.el-icon-close {
font-size: 16px;
cursor: pointer;
}
}
.filter-dialog-body {
padding: 15px;
.upload-wrap {
.el-select {
width: 100px;
}
.input-with-select {
width: 100%;
}
}
}
.upload-sure-btn {
width: 100%;
}
animation-duration: .5s;
animation-delay: 0s;
display: none;
&.active {
display: block
}
.sub-filter {
padding-bottom: 15px;
border-bottom: 1px solid #eee;
}
.monitor-list {
max-height: calc(100vh - 280px);
/* max-height: 568px; */
overflow: auto;
margin-right: -10px;
padding-right: 10px;
}
.monitor-list-item {
display: flex;
border-bottom: 1px solid #eee;
.user-info {
flex: 1;
color: #666;
&>p {
margin: 8px 0;
}
.name {
color: #333;
margin-right: 15px;
}
}
&:last-child {
border-bottom: none;
}
.device-icon {
margin-right: 5px;
margin-top: 12px;
}
}
.device-icon-label {
display: inline-block;
margin-left: 5px;
}
.device-icon {
display: inline-block;
vertical-align: middle;
width: 8px;
height: 8px;
border-radius: 5px;
background-color: rgba(0, 153, 68, 0.8);
&.offline {
background-color: rgba(255, 0, 0, 0.8);
}
}
.filter-dialog-footer {
border-top: 1px solid #eee;
padding: 10px;
span {
vertical-align: middle;
}
}
}
.search-box {
.date-filter {
position: absolute;
top: 0px;
right: 0px;
}
.el-form--inline .el-form-item {
margin-right: 0px;
}
.stay-ctrl {
margin-top: 5px;
input {
width: 100%;
}
.el-form-item {
margin-bottom: 0px;
}
.unit {
line-height: 30px;
margin-left: 10px;
}
}
.el-range-editor--mini .el-range-input {
width: 115px;
}
.el-form-item {
margin-bottom: 15px;
}
.submit-el-form-item {
margin-top: 20px;
}
}
.search-box,
.result-box {
padding: 20px;
background: #fff;
box-shadow: 1px 1px 4px #ccc;
display: none;
}
.search-box.active,
.result-box.active {
display: block;
}
.result-box {
/* height: 100%;
max-height: 660px; */
padding: 0px;
.result-box-head{
text-align: center;
border-bottom: 1px solid #ddd;
padding: 10px 15px;
&>*{
vertical-align: middle;
}
}
.result-box-filter{
font-size: 0px;
padding: 5px 0px;
border-bottom: 1px solid #eee;
.el-button{
font-size: 13px;
padding: 2px 10px;
margin: 0;
&:first-child{
border-right: 1px solid #eee;
}
i{
margin: 0 3px;
}
}
}
.stay-list{
/* height: calc(100% - 70px); */
max-height: calc(100vh - 200px);
overflow-y: auto;
}
.stay-list-item{
line-height: 1.5;
padding: 10px 15px;
border-bottom: 1px solid #eee;
p{
margin: 0px;
}
.datetime{
font-size: 13px;
color: #666;
}
}
}
.replay-player{
max-width: 400px;
position: absolute;
top: 20px;
right: 20px;
z-index: 500;
background: #fff;
padding: 5px 10px;
margin-top: 10px;
.el-progress{
display: inline-block;
width: 200px;
margin: 0;
height: 10px;
border-radius: 0;
}
&>a{
margin: 0 5px;
cursor: pointer;
&:hover{
color: #094;
}
}
}
.row-form-item .el-form-item__label{
float: none;
}
padding: 0px;
.result-box-head {
text-align: center;
border-bottom: 1px solid #ddd;
padding: 10px 15px;
&>* {
vertical-align: middle;
}
}
.result-box-filter {
font-size: 0px;
padding: 5px 0px;
border-bottom: 1px solid #eee;
.el-button {
font-size: 13px;
padding: 2px 10px;
margin: 0;
&:first-child {
border-right: 1px solid #eee;
}
i {
margin: 0 3px;
}
}
}
.stay-list {
/* height: calc(100% - 70px); */
max-height: calc(100vh - 200px);
overflow-y: auto;
}
.stay-list-item {
line-height: 1.5;
padding: 10px 15px;
border-bottom: 1px solid #eee;
p {
margin: 0px;
}
.datetime {
font-size: 13px;
color: #666;
}
}
}
.replay-player {
max-width: 400px;
position: absolute;
top: 20px;
right: 20px;
z-index: 500;
background: #fff;
padding: 5px 10px;
margin-top: 10px;
.el-progress {
display: inline-block;
width: 200px;
margin: 0;
height: 10px;
border-radius: 0;
}
&>a {
margin: 0 5px;
cursor: pointer;
&:hover {
color: #094;
}
}
}
.row-form-item .el-form-item__label {
float: none;
}
}
.full-width .map-wrap{
// top: 0px;
height: 100%;
.full-width .map-wrap {
// top: 0px;
height: 100%;
}
.map-container{
width: 100%;
height: 100%;
z-index: 100;
.map-container {
width: 100%;
height: 100%;
z-index: 100;
}
.el-loading-mask{
z-index: 500;
.el-loading-mask {
z-index: 500;
}
.map-infowindow-ct{
&>p{
display: flex;
}
.lb{
}
.des{
flex: 1;
word-break: break-all;
}
.icon{
margin-right: 5px;
}
.battery{
position: relative;
width: 42px;
height: 20px;
i{
position: absolute;
top: 0;
left: 0;
width: 100%;
height: 100%;
}
.fill{
width: 39px;
}
.fill-percentage{
padding: 3px;
box-sizing: border-box;
background-color: #d4f1dc;
}
.text{
color: #37c060;
font-size: 12px;
text-align: center;
}
&.empty .fill-percentage{
background-color: #f0d0d0;
}
&.empty .fill-percentage{
color: #df2222;
}
&.hide{
display: none;
}
}
.redirect-row{
display: flex;
}
a.redirect-btn{
flex: 1;
border: 1px solid rgba(0,153,68,0.8);
border-radius: 2px;
text-align: center;
padding: 4px 0px;
color: rgba(0,153,68,0.8);
margin: 2px;
cursor: pointer;
&:hover{
color: rgba(0,153,68, 1);
border-color: rgba(0,153,68, 1);
}
}
a.locate-btn{
padding: 2px 8px;
border: 1px solid #094;
border-radius: 4px 0 0 4px;
& + .locate-btn{
border-radius: 0 4px 4px 0;
border-left: none;
}
&.active{
background-color: #094;
color: #fff;
}
}
.map-infowindow-ct {
&>p {
display: flex;
}
.lb {}
.des {
flex: 1;
word-break: break-all;
}
.icon {
margin-right: 5px;
}
.battery {
position: relative;
width: 42px;
height: 20px;
i {
position: absolute;
top: 0;
left: 0;
width: 100%;
height: 100%;
}
.fill {
width: 39px;
}
.fill-percentage {
padding: 3px;
box-sizing: border-box;
background-color: #d4f1dc;
}
.text {
color: #37c060;
font-size: 12px;
text-align: center;
}
&.empty .fill-percentage {
background-color: #f0d0d0;
}
&.empty .fill-percentage {
color: #df2222;
}
&.hide {
display: none;
}
}
.redirect-row {
display: flex;
}
a.redirect-btn {
flex: 1;
border: 1px solid rgba(0, 153, 68, 0.8);
border-radius: 2px;
text-align: center;
padding: 4px 0px;
color: rgba(0, 153, 68, 0.8);
margin: 2px;
cursor: pointer;
&:hover {
color: rgba(0, 153, 68, 1);
border-color: rgba(0, 153, 68, 1);
}
}
a.locate-btn {
padding: 2px 8px;
border: 1px solid #094;
border-radius: 4px 0 0 4px;
&+.locate-btn {
border-radius: 0 4px 4px 0;
border-left: none;
}
&.active {
background-color: #094;
color: #fff;
}
}
a.fence_btn_grey {
border: 1px solid #d8d8d8;
color: #999;
background: #f2f2f2;
&:hover {
border: 1px solid #d8d8d8;
color: #999;
background: #f2f2f2;
}
}
}
.poi_marker{
display: inline-block;
width: 40px;
height: 48px;
background-image: url('../images/poi-marker-default.png');
background-size: 40px 50px;
text-align: center;
color: #fff;
padding-top: 2px;
.poi_marker {
display: inline-block;
width: 40px;
height: 48px;
background-image: url('../images/poi-marker-default.png');
background-size: 40px 50px;
text-align: center;
color: #fff;
padding-top: 2px;
}
.poi_infowin{
.poi_item{
display: flex;
justify-content: space-between;
label{
color: #666;
}
span, input{
flex: 1;
}
input{
border: 1px solid #ccc;
height: 22px;
padding: 2px 8px;
}
}
.poi_ctrl{
justify-content: flex-end;
&>a{
display: inline-block;
border: 1px solid rgba(0, 153, 68, 0.8);
border-radius: 12px;
text-align: center;
padding: 2px 10px;
color: rgba(0, 153, 68, 0.8);
margin-left: 10px;
cursor: pointer;
}
&>a[data-delete]{
border: 1px solid #dcdfe6;
color: #606266;
}
}
.poi_infowin {
.poi_item {
display: flex;
justify-content: space-between;
label {
color: #666;
}
span,
input {
flex: 1;
}
input {
border: 1px solid #ccc;
height: 22px;
padding: 2px 8px;
}
}
.poi_ctrl {
justify-content: flex-end;
&>a {
display: inline-block;
border: 1px solid rgba(0, 153, 68, 0.8);
border-radius: 12px;
text-align: center;
padding: 2px 10px;
color: rgba(0, 153, 68, 0.8);
margin-left: 10px;
cursor: pointer;
}
&>a[data-delete] {
border: 1px solid #dcdfe6;
color: #606266;
}
}
}
\ No newline at end of file
<template>
<el-cascader v-model="city" :options="cityList" :props="cascaderProps" :disabled="disabled" @change="onChange"></el-cascader>
</template>
<script>
import cityJson from "@/assets/json/city.json";
export default {
name: "CitySelect",
props: {
value: {
type: [String, Number],
default: "",
},
checkStrictly: {
type: Boolean,
default: false,
},
disabled: {
type: Boolean,
default: false,
},
},
data() {
return {
cityList: cityJson,
city: "",
cascaderProps: {
value: "code",
label: "name",
children: "children",
checkStrictly: this.checkStrictly,
},
};
},
watch: {
// value: {
// handler: function (n, o) {
// if (n) {
// this.init();
// }
// },
// immediate: true,
// },
},
mounted() {
//this.city = this.value;
this.init();
},
methods: {
onChange(e) {
console.log(e);
let list = this.cityList;
let nameList = []
let m = list.find((k) => k.code == e[0]);
console.log(m)
nameList.push(m.name)
let n = m.children.find((k) => k.code == e[1]);
let b = (n && n.children || []).find((k) => k.code == e[2]);
if (n) {
this.$emit("input", n.name);
nameList.push(n.name)
}
if(b){
nameList.push(b.name)
}
this.$emit("change", { code: e, name: nameList });
},
// 初始化
init() {
let o = this.value.toString();
let list = this.cityList;
let arr = [];
if (!o) {
return false;
}
// for(let i =0,len=list.length;i<len;i++){
// let k = list[i]
// if(k.code == o){
// arr.push(k.code)
// return false;
// }
// }
list.forEach((k) => {
// 只有省份
if (k.code == o) {
arr.push(k.code);
return;
}
if (k.children) {
k.children.forEach((j) => {
// 只有省市
if (j.code == o) {
arr.push(k.code);
arr.push(j.code);
return;
}
j.children &&
j.children.forEach((h) => {
// 只有省市区
if (h.code == o) {
arr.push(k.code);
arr.push(j.code);
arr.push(h.code);
return;
}
});
});
}
});
// let m = list.find((k) => {
// let n = k.children.find((j) => j.name == o || j.code == o);
// if (n) {
// arr.push(k.code);
// arr.push(n.code);
// return false;
// }
// });
this.city = arr;
console.log(arr);
},
// 展开数组
unfoldTree(arr, afterArray = []) {
let _this = this;
arr.map((k) => {
afterArray.push(k);
if (k.children) {
_this.unfoldTree(k.children, afterArray);
}
});
return afterArray;
},
},
};
</script>
<style lang="scss" scoped>
</style>
\ No newline at end of file
<template>
<div class="">
<el-input placeholder="输入关键字进行过滤" v-model="filterText" size="small">
</el-input>
<div v-loading="loading">
<el-tree style="max-height:50vh;overflow:auto" class="filter-tree" :data="filterTextData" :filter-node-method="filterNode" highlight-current ref="tree" node-key="id" check-on-click-node>
</el-tree>
</div>
<p style="text-align: right; margin-top: 10px">
<el-button @click="filterConfirm" type="primary">确定</el-button>
<el-button @click="closeFilter">取消</el-button>
</p>
</div>
</template>
<script>
import { GET_ORGANIZATION_TREE } from "@/api/services/common";
import { showToast } from "@/utils/utils";
export default {
name: "GlsxOrganization",
data() {
return {
filterText: "",
filterTextData: [],
_timeout: "",
loading: false,
};
},
mounted() {
this.getTree();
},
watch: {
filterText(n) {
let _this = this;
_this.loading = true;
setTimeout(function () {
_this.$refs.tree.filter(n);
}, 100);
},
},
methods: {
// 确认选择树
filterConfirm() {
let o = this.$refs.tree.getCurrentNode();
if (!o) {
showToast({
message: "请选择所属组织",
type: "error",
});
return false;
}
const { label, id, origin } = o;
// if (origin && origin.type != "u") {
// showToast({
// message: "请选择下级所属组织",
// type: "error",
// });
// return false;
// }
console.log(o);
this.$emit("change", o);
// this.searchForm.specialShopName = label.split("/")[1];
// this.searchForm.specialShopCode = label.split("/")[0];
//this.$set(this, "form.specialShopName", label);
//this.searchForm.specialShopId = id;
//this.closeFilter();
},
// 获取组织机构树数据
getTree() {
GET_ORGANIZATION_TREE({ hasUserLeaf: true }).then((res) => {
const { data } = res;
this.filterTextData = data || [];
});
},
// 搜索树
filterNode(value, data) {
let _this = this;
if (!value) {
_this.loading = false;
return true;
}
setTimeout(function () {
_this.loading = false;
}, 1500);
return data.label.indexOf(value) !== -1;
},
// 关闭树
closeFilter() {
this.$emit("change");
},
// 搜索树
onChange(val) {
this.loading = true;
this.$refs.tree.filter(val);
},
},
};
</script>
<style lang="scss" scoped>
</style>
\ No newline at end of file
const MAP_KEY = '75116f653f3b2e4568116dad8cd9b899'
export const MAP_KEY = '75116f653f3b2e4568116dad8cd9b899'
// 地图插件
export const MAP_PLUGINS = [
'AMap.PolyEditor',
'AMap.CircleEditor',
'AMap.DistrictSearch',
'AMap.Autocomplete',
'AMap.MarkerClusterer',
'AMap.MouseTool',
'AMap.Text',
"AMap.RangingTool",
"AMap.Geolocation",
"AMap.PolygonEditor",
"AMap.PolylineEditor",
'AMap.Scale'
]
export const CONSTANT = {
//ROOT: process.env.NODE_ENV === 'development'?'ots/':'',
API_URL: '/ots/',
MAP_KEY,
AMAP_URL: `https://webapi.amap.com/maps?v=1.4.2&key=${MAP_KEY}&plugin=AMap.PolyEditor,AMap.CircleEditor,AMap.DistrictSearch,AMap.Autocomplete,AMap.MarkerClusterer,AMap.MouseTool,AMap.Text`
MAP_PLUGINS,
AMAP_URL: `https://webapi.amap.com/maps?v=1.4.2&key=${MAP_KEY}&plugin=${MAP_PLUGINS.toString()}`
}
\ No newline at end of file
import 'font-awesome/css/font-awesome.min.css'
import './assets/scss/element-variables.scss'
import '@/assets/scss/element-variables.scss'
//import Vue from 'vue'
//import ElementUI from 'element-ui';
import ElementUI from 'element-ui';
import 'animate.css/animate.min.css'
import './assets/scss/style.scss'
//import 'element-ui/lib/theme-chalk/index.css';
import './assets/spritesmith-generated/sprite.css'
import '@/assets/scss/style.scss'
import 'element-ui/lib/theme-chalk/index.css';
import '@/assets/spritesmith-generated/sprite.css'
import Router from 'vue-router'
import routes from './router'
import './core/public-path';
import actions from './core/actions';
import routes from '@/router'
import '@/core/public-path';
import actions from '@/core/actions';
import vLayout from 'pages/Layout.vue'
import vFullLayout from 'pages/FullWidthLayout.vue'
import vLayout from '@/pages/Layout.vue'
import vFullLayout from '@/pages/FullWidthLayout.vue'
import store from './vuex/store.js'
import store from '@/vuex/store.js'
import App from './App.vue'
import App from '@/App.vue'
import Vue from 'vue'
Vue.component('vLayout',vLayout)
Vue.component('vFullLayout',vFullLayout)
Vue.component('vLayout', vLayout)
Vue.component('vFullLayout', vFullLayout)
//Vue.use(ElementUI)
Vue.use(ElementUI)
import 'xe-utils'
import VXETable from 'vxe-table'
import 'vxe-table/lib/style.css'
Vue.use(VXETable)
// new Vue({
// el: '#app',
......@@ -34,16 +41,19 @@ Vue.component('vFullLayout',vFullLayout)
let router = null;
let instance = null;
function render({ data = {} , container } = {}) {
function render({ data = {}, container } = {}) {
router = new Router({
base: window.__POWERED_BY_QIANKUN__ ? '/oEshield' : '/',
routes
});
store.commit('SET_BASE_URL', data.baseURL);
Vue.prototype.$parentCommon = data.common;
Vue.prototype.$parentRouter = data.router;
Vue.prototype.$parentVuex = data.store;
instance = new Vue({
router,
store,
data(){
data() {
return {
parentRouter: data.router,
parentVuex: data.store,
......@@ -55,7 +65,7 @@ function render({ data = {} , container } = {}) {
}
if (!window.__POWERED_BY_QIANKUN__) {
render();
render();
}
export async function bootstrap() {
......@@ -66,13 +76,13 @@ export async function mount(props) {
console.log('props from main framework', props.data);
actions.setActions(props);
Vue.prototype.$onGlobalStateChange = props.onGlobalStateChange
Vue.prototype.$setGlobalState = props.setGlobalState
Vue.prototype.$setGlobalState = props.setGlobalState
render(props);
props.setGlobalState({
})
console.log(props)
}
export async function unmount() {
......
<template>
<div>
<!-- 围栏调用地图弹框 -->
<div class="ibox-content" style="height: 500px; padding:0 10px;z-index: 100">
<fence-map :mapData="mapData" @onUpdateMapData="updateMapData" :readonlyStatus="readonlyStatus" ref="fenceMap">
</fence-map>
</div>
<!-- 围栏调用地图弹框 /-->
<!-- 围栏内容 开始 -->
<div class="fold_box">
<div class="fold_btn" @click="foldEvent">
<i class="el-icon-arrow-down" v-if="showContent"></i>
<i class="el-icon-arrow-up" v-else></i>
<span>{{showContent?'收起':'展开'}}</span>
</div>
</div>
<el-collapse-transition>
<div v-show="showContent">
<div class="tab_wrap">
<el-tabs type="card" v-show="hideTab">
<el-tab-pane label="围栏基础信息">
<div class="ibox-content scrollbar" style="padding: 30px 20px;">
<el-form ref="fenceForm" :model="form" :rules="rules" :inline="false" size="mini" label-width="100px" class="fence_form">
<el-form-item label="围栏名称" prop="fenceName">
<el-input v-model.trim="form.fenceName" placeholder="请输入围栏名称" maxlength="200" :disabled="readonlyStatus"></el-input>
</el-form-item>
<el-form-item label="监控类型" prop="triggerType">
<el-select v-model="form.triggerType" placeholder="请选择" size="small">
<el-option label="驶入" :value="1"></el-option>
<el-option label="驶出" :value="2"></el-option>
<el-option label="驶入驶出" :value="3"></el-option>
</el-select>
</el-form-item>
<el-form-item label="监控周期" prop="timeType">
<el-radio-group v-model="form.timeType" @change="changeTimeType">
<el-radio :label="1">永久有效</el-radio>
<el-radio :label="2">指定区间</el-radio>
</el-radio-group>
</el-form-item>
<el-form-item label="指定区间" prop="dateRange" v-if="form.timeType == 2">
<el-date-picker v-model="form.dateRange" type="daterange" size="small" range-separator="至" start-placeholder="开始日期" end-placeholder="结束日期" value-format="yyyy-MM-dd">
</el-date-picker>
</el-form-item>
<el-form-item label="区域类型" class="is-required">
<el-radio-group v-model="form.shapeType" @change="shapeTypeChange">
<el-radio-button label="1">圆形</el-radio-button>
<el-radio-button label="3">多边形</el-radio-button>
<el-radio-button label="4">行政区域</el-radio-button>
</el-radio-group>
<div class="shape_tip" v-show="form.shapeType==3">*注:地图任意位置,单击新增双击结束绘制。</div>
</el-form-item>
<el-form-item label="围栏半径" prop="radius" v-if="form.shapeType == 1">
<div class="radius_box">
<el-input placeholder="请输入围栏半径" v-model.trim="form.radius">
<template slot="append">米</template>
</el-input>
<el-button type="primary" class="btn" :disabled="!form.radius" @click="changeRadius">更新围栏</el-button>
</div>
</el-form-item>
<el-form-item label="省市区" class="is-required" v-if="form.shapeType==4" prop="areaCode">
<city-select v-model="form.areaCode" :checkStrictly="true" @change="changeArea"></city-select>
</el-form-item>
<el-form-item label="围栏类型" prop="bizFenceType">
<el-radio :label="14" v-model="form.bizFenceType">报警型</el-radio>
</el-form-item>
<el-form-item label="状态" prop="enableStatus">
<el-radio-group v-model="form.enableStatus">
<el-radio :label="1">启用</el-radio>
<el-radio :label="0">停用</el-radio>
</el-radio-group>
</el-form-item>
<el-form-item label="短信通知" prop="telNumbers">
<el-input v-model.trim="form.telNumbers" maxlength="100" placeholder="输入格式:手机号码,手机号码(支持双号)"></el-input>
</el-form-item>
<el-form-item label="描述" class="el_long_form_item">
<el-input type="textarea" v-model.trim="form.remark" resize="none" maxlength="100" placeholder="请输入围栏描述"></el-input>
</el-form-item>
<el-form-item label="操作记录" class="el_long_form_item" v-show="isEditMode">
<div class="record-list" v-html="form.record"></div>
</el-form-item>
</el-form>
</div>
</el-tab-pane>
<el-tab-pane label="监控对象">
<div class="links_group">
<div>已关联{{tableData.length}}个设备</div>
<div>
<el-button v-if="!readonlyStatus" type="primary" @click="userDate" size="small" :loading="submitting">关联用户</el-button>
<el-button size="small" :disabled="!selectedIds || selectedIds.length<=0" @click="batchRemove">批量删除</el-button>
</div>
</div>
<!-- <el-table class="el_table" :data="tableData" border height="300" size="small" v-loading="loading" @selection-change="selectChange" style="width: 100%;margin-bottom:40px">
<el-table-column :disabled="readonlyStatus" type="selection" width="40"></el-table-column>
<el-table-column fixed type="index" label="序号" :index="getIndex" width="70"></el-table-column>
<el-table-column fixed prop="name" label="姓名" show-overflow-tooltip></el-table-column>
<el-table-column fixed prop="vin" label="车架号" show-overflow-tooltip></el-table-column>
<el-table-column prop="sn" label="设备号" show-overflow-tooltip></el-table-column>
<el-table-column prop="time" label="GPS时间" show-overflow-tooltip></el-table-column>
<el-table-column prop="address" label="位置" show-overflow-tooltip></el-table-column>
<el-table-column prop="userTel" label="联系方式" show-overflow-tooltip></el-table-column>
</el-table> -->
<vxe-table :data="tableData" border show-overflow ref="xTableComponent" max-height="300" :row-config="{isHover: true}" :sort-config="{trigger: 'cell'}" @checkbox-change="selectChange" @checkbox-all="selectChange">
<vxe-column type="checkbox" width="60"></vxe-column>
<vxe-column type="seq" title="序号" width="60"></vxe-column>
<vxe-column field="name" title="姓名"></vxe-column>
<vxe-column field="vin" title="车架号"></vxe-column>
<vxe-column field="sn" title="设备号" show-overflow></vxe-column>
<vxe-column field="time" title="GPS时间" show-overflow></vxe-column>
<vxe-column field="address" title="位置" show-overflow></vxe-column>
<vxe-column field="userTel" title="联系方式" show-overflow></vxe-column>
</vxe-table>
</el-tab-pane>
</el-tabs>
</div>
<div class="fenceModalfooter">
<el-button v-if="!readonlyStatus" type="primary" @click="saveFence" size="small" :loading="submitting">保存</el-button>
<el-button @click="cancel" size="small">取消</el-button>
</div>
</div>
</el-collapse-transition>
<!-- 围栏内容 end -->
<user-list :init="userListInit" v-if="userListModalVisible" @onUserListInit="(res)=>userListInit=res" :userData="tableData" @onUpdateUserData="updateUserData" :userListModalVisible="userListModalVisible" :shopId="form.specialShopId" @onUserListModalChange="userListModalChange" ref="userList">
</user-list>
</div>
</template>
<script>
import mapService from "@/utils/mapService.js";
import fenceMap from "./fenceMap.vue";
import userList from "./fence_userlist.vue";
import InfiniteLoading from "vue-infinite-loading";
import CitySelect from "@/components/area";
import { deepClone, showToast, showModal } from "@/utils/utils";
import {
GET_ELECFENCE_LINKEDDEVICES,
GET_ELECFENCE_INFO,
SAVE_ELECFENCE_INFO,
UPDATE_ELECFENCE_INFO,
REMOVE_ELECFENCE_LINKEDDEVICES,
} from "@/api/services/fence";
export default {
props: ["fenceModalVisible", "fenceId"],
components: {
CitySelect,
fenceMap,
userList,
InfiniteLoading,
},
data() {
let checkFenceName = (rule, vaule, cb) => {
if (
typeof this.restainFenceName != "undefined" &&
this.form.fenceName === this.restainFenceName
) {
cb();
}
};
let checkArea = (rule, vaule, cb) => {
if (this.form.shapeType == 4 && !this.form.areaCode) {
cb(new Error("请选择行政区域"));
} else {
cb();
}
};
let checkDaterange = (rule, vaule, cb) => {
const dateRange = this.form.dateRange;
if (!dateRange || !dateRange.length) {
cb(new Error("请选择日期"));
} else {
let min = dateRange[0];
let max = dateRange[1];
if (!moment.isMoment(min)) {
min = moment(min);
}
if (!moment.isMoment(max)) {
max = moment(max);
}
if (min.isBefore(moment(max).subtract(30 * 6, "days"), "minute")) {
cb(new Error("日期范围不能超过180天"));
}
}
cb();
};
let checkMsgtel = (rule, vaule, cb) => {
let reg = /^1\d{10}((\,1\d{10})|(\,1\d{10}))?$/;
if (this.form.telNumbers && !reg.test(this.form.telNumbers)) {
cb(new Error("请输入正确的格式"));
} else {
cb();
}
};
// 校验半径
let checkRadius = (rule, vaule, cb) => {
if (this.form.shapeType == 1 && !/^\d+$/.test(this.form.radius)) {
console.log(this.form.radius);
cb(new Error("请输入正确的格式,不能输入小数点"));
} else {
cb();
}
};
return {
scrollToRef: "",
tableData: [],
//dateRange: [],
currentPage: 1,
pageSize: 10,
maxPage: 1,
submitting: false,
userArr: [],
userData: [],
hideTab: true,
btnText: "保存",
readonlyStatus: false,
form: {
bizFenceType: 14,
shapeType: 1,
triggerType: 1,
timeType: 2,
enableStatus: 1,
radius: 1000,
},
restainFenceName: "",
rules: {
fenceName: [
{ required: true, message: "请输入围栏名称", trigger: "blur" },
{ pattern: /^\S{2,200}$/, message: "至少2字", trigger: "blur" },
// {validator: checkFenceName, trigger: 'blur'}
],
triggerType: [
{ required: true, message: "请选择监控类型", trigger: "change" },
],
timeType: [
{ required: true, message: "请选择监控周期", trigger: "change" },
],
areaCode: [{ validator: checkArea, trigger: "blur" }],
bizFenceType: [
{ required: true, message: "请选择围栏类型", trigger: "change" },
],
shapeType: [
{ required: true, message: "请选择区域类型", trigger: "change" },
],
radius: [{ validator: checkRadius, trigger: "blur" }],
enableStatus: [
{ required: true, message: "请选择状态", trigger: "change" },
],
telNumbers: [{ validator: checkMsgtel, trigger: "blur" }],
dateRange: [
{ required: true, message: "请选择指定区间", trigger: "change" },
],
},
transferTimeoutId: undefined,
geocoder: null,
transferFlag: null,
transferError: false,
userListModalVisible: false,
selectedIds: [],
mapData: null,
polygonPath: [],
loading: false,
showContent: true,
};
},
computed: {
isEditMode: {
get() {
return typeof this.fenceId != "undefined";
},
},
},
created() {
window.Vue.directive("loadmore", {
bind(el, binding) {
const selectWrap = el.querySelector(".el-table__body-wrapper");
selectWrap.addEventListener("scroll", function () {
let sign = 0;
const scrollDistance =
this.scrollHeight - this.scrollTop - this.clientHeight;
if (scrollDistance == sign) {
//binding.value()
//console.log(sign)
// _this.currentPage++;
// _this.getFenceSnsList(_this.fenceId);
}
});
},
});
},
mounted() {
//this.listener();
let _this = this;
let query = this.$route.query;
if (query.id) {
_this.fenceId = query.id;
_this.getFenceInfo(query.id);
_this.getList();
} else {
//this.$refs.fenceForm.clearValidate();
_this.$refs.fenceMap.updateFence({
fenceType: "circle",
});
}
},
methods: {
// 监听围栏类型变化
shapeTypeChange() {
if (this.form.shapeType == 4) {
this.$refs.fenceForm.clearValidate();
this.$refs.fenceMap.updateFence({
fenceType: "area",
});
} else if (this.form.shapeType == 1) {
this.$refs.fenceMap.updateFence({
fenceType: "circle",
});
} else if (this.form.shapeType == 3) {
this.$refs.fenceMap.updateFence({
fenceType: "polygon",
});
}
},
// 监听表格选择
selectChange() {
const records = this.$refs.xTableComponent.getCheckboxRecords();
console.log(records);
this.selectedIds = records;
},
userListModalChange(isOpen) {
this.userListModalVisible = isOpen;
},
userDate() {
this.userListModalVisible = true;
},
updateUserData(data) {
this.userArr = data;
this.tableData = data;
console.log(data);
},
updateMapData(data) {
console.log(data);
if (data.radius) {
this.form.radius = data.radius;
}
if (data.lng && data.lat) {
this.form.lng = data.lng;
this.form.lat = data.lat;
//this.transfer();
}
if (data.polygonPath && data.polygonPath.length) {
this.polygonPath = data.polygonPath;
}
},
changeStatus() {
if (this.hideTab == true) {
this.hideTab = false;
} else if (this.hideTab == false) {
this.hideTab = true;
}
},
// 保存围栏信息
saveFence() {
let _this = this;
if (this.form.shapeType == 3) {
if (this.polygonPath.length === 0) {
this.$message({
message: "请绘制线路",
type: "error",
});
return;
}
}
_this.$refs.fenceForm.validate((valid) => {
if (!valid) {
return false;
}
_this.submitting = true;
let oParams = _this.getParams();
console.log(oParams);
// 编辑围栏
if (_this.fenceId) {
UPDATE_ELECFENCE_INFO(oParams)
.then((res) => {
_this.submitting = false;
if (res.code != 200) {
showToast({
message: res.message,
});
return false;
}
showToast({
message: "编辑成功",
type: "success",
});
_this.cancel();
})
.catch(() => {
_this.submitting = false;
});
return false;
}
// 新增围栏
SAVE_ELECFENCE_INFO(oParams)
.then((res) => {
_this.submitting = false;
if (res.code != 200) {
showToast({
message: res.message,
});
return false;
}
showToast({
message: "新增成功",
type: "success",
});
_this.cancel();
})
.catch(() => {
_this.submitting = false;
});
});
},
// 返回上一页
cancel() {
//window.history.go(-1);
// this.$router.push({path:"fenceManagement"})
let path = `/trialRun#/fence/index`;
history.pushState({}, path, path);
},
// 获取参数
getParams() {
let _this = this;
let form = deepClone(_this.form);
let oParams = {};
// 围栏基础信息
oParams.fenceName = form.fenceName;
oParams.shapeType = form.shapeType;
oParams.timeType = form.timeType;
oParams.triggerType = form.triggerType;
oParams.enableStatus = form.enableStatus;
oParams.bizFenceType = 14;
oParams.telNumbers = form.telNumbers;
oParams.remark = form.remark;
// 编辑围栏特有参数
if (_this.fenceId) {
oParams.id = _this.fenceId;
}
// 圆形围栏
if (form.shapeType == 1) {
oParams.radius = form.radius;
oParams.lnglat = `${form.lng},${form.lat}`;
}
// 多边形围栏
if (form.shapeType == 3) {
//oParams.lnglat = this.polygonPath;
oParams.lnglat = this.polygonPath.join("|");
}
// 行政区域围栏
if (form.shapeType == 4) {
oParams.areaCode = form.areaCode[form.areaCode.length - 1];
oParams.areaText = form.areaText.toString();
}
// 监控周期 1:永久有效,2:指定区间
if (form.timeType == 1) {
oParams.startTime = moment().format("YYYY-MM-DD");
oParams.endTime = moment().add(50, "year").format("YYYY-MM-DD");
} else {
oParams.startTime = form.dateRange[0];
oParams.endTime = form.dateRange[1];
}
// 用户设备列表
let list = deepClone(this.tableData);
if (list) {
list.map((k) => {
delete k._X_ROW_KEY;
});
oParams.snList = list;
} else {
this.userArr.map((k) => {
delete k._X_ROW_KEY;
});
oParams.snList = this.userArr;
}
return oParams;
},
transfer() {
if (this.form.lng && this.form.lat && this.validateLngLat()) {
this.transferTimeoutId && window.clearTimeout(this.transferTimeoutId);
this.transferTimeoutId = window.setTimeout(() => {
const flag = new Date();
this.transferFlag = flag;
if (!this.geocoder) {
mapService.getGeocoder().then((gc) => {
this.geocoder = gc;
this.getAddress(flag);
});
} else {
this.getAddress(flag);
}
}, 500);
}
},
getAddress(flag) {
const lnglatXY = [this.form.lng, this.form.lat];
this.form.analysisAddress = "";
this.geocoder.getAddress(lnglatXY, (status, result) => {
if (flag == this.transferFlag) {
if (status === "complete" && result.info === "OK") {
//获取地址成功
//console.log(result.regeocode.formattedAddress)
this.form.analysisAddress = result.regeocode.formattedAddress;
this.transferError = false;
this.$refs.fenceForm.validateField("analysisAddress");
//this.$refs.fenceMap.updateMap(this.form)
} else {
this.transferError = true;
this.$refs.fenceForm.validateField("analysisAddress");
}
}
});
},
// 监听省市区改变
changeArea(e) {
console.log(e);
this.form.areaCode = e.code;
this.form.areaText = e.name;
this.$refs.fenceMap.updateFence({
fenceType: "area",
areaCode: e.code[e.code.length - 1],
});
},
// 监听监控周期
changeTimeType(e) {
if (e == 1) {
delete this.rules.dateRange;
return false;
}
let oParams = [
{ required: true, message: "请选择指定区间", trigger: "change" },
];
this.$set(this.rules, "dateRange", oParams);
},
// 获取关联设备列表
getList() {
let _this = this;
let oParams = {};
oParams.fenceId = this.fenceId;
GET_ELECFENCE_LINKEDDEVICES(oParams).then((res) => {
_this.tableData = res.data || [];
});
},
// 获取围栏信息
getFenceInfo(id) {
let _this = this;
let oParams = {};
oParams.fenceId = id;
GET_ELECFENCE_INFO(oParams).then((res) => {
if (res.code != 200) {
return false;
}
let _typeList = {
1: "circle",
3: "polygon",
4: "area",
};
let obj = res.data || {};
let mapData = {};
if (obj.startTime) {
obj.dateRange = [obj.startTime, obj.endTime];
}
if (obj.lnglat) {
let lnglat = obj.lnglat.split(",");
console.log(lnglat);
obj.lng = lnglat[0];
obj.lat = lnglat[1];
}
_this.form = obj;
mapData.fenceType = _typeList[obj.shapeType];
// 地图画围栏
switch (obj.shapeType) {
case 3:
let path = obj.lnglat.split("|").map((item) => {
return [item.split(",")[0], item.split(",")[1]];
});
mapData.polygonPath = path;
_this.polygonPath = path;
break;
case 4:
mapData.areaCode = obj.areaCode;
break;
default:
let lnglat = obj.lnglat ? obj.lnglat.split(",") : [];
mapData.lng = lnglat[0];
mapData.lat = lnglat[1];
mapData.radius = obj.radius;
break;
}
_this.mapData = mapData;
_this.$refs.fenceMap.initFence(mapData);
});
},
// 批量删除
batchRemove() {
let _this = this;
showModal({
message: "确认删除选择的关联用户吗?",
showCancelButton: true,
type: "warning",
success: function () {
_this.removeUserList();
},
});
},
// 删除关联用户数据
removeUserList() {
let _this = this;
let list = _this.selectedIds || [];
let oList = this.tableData || [];
let arr = [];
// 新增围栏删除关联用户
if (!this.fenceId) {
this.tableData = oList.filter((k) => {
return list.findIndex((j) => j.sn == k.sn) < 0;
});
return false;
}
list.map((k) => {
arr.push(k.sn);
});
let oParams = {};
oParams.linkSns = arr.toString();
oParams.fenceId = _this.fenceId;
REMOVE_ELECFENCE_LINKEDDEVICES(oParams).then((res) => {
if (res.code == 200) {
showToast({
message: "删除成功",
type: "success",
});
_this.tableData = oList.filter((k) => {
return list.findIndex((j) => j.sn == k.sn) < 0;
});
}
});
},
// 显示隐藏内容
foldEvent() {
this.showContent = !this.showContent;
},
//监听围栏半径改变
changeRadius() {
let e = this.form.radius;
let reg = /^\d+$/;
if (!reg.test(e) || e < 1000) {
showToast({
message: "请输入整数且不小于1000",
});
return false;
}
this.$refs.fenceMap.updateFence({
fenceType: "circle",
lng: this.form.lng,
lat: this.form.lat,
radius: this.form.radius,
});
},
},
};
</script>
<style scoped lang="scss">
h3 {
margin: 10px 0px;
}
form {
height: 100%;
overflow-y: auto;
margin: -30px -20px;
padding: 10px 100px 20px 30px;
}
.tab-content {
margin-top: 20px;
}
.record-list {
padding-left: 20px;
}
.fenceModalfooter {
margin: 0;
padding: 20px;
padding-top: 10px;
text-align: right;
box-sizing: border-box;
z-index: 500;
position: fixed;
left: 0;
bottom: 0;
width: 100%;
border-top: 1px solid #e7eaec;
background-color: #fdfdfd;
margin-left: 220px;
padding-right: 260px;
}
.tab_wrap {
position: relative;
padding: 10px;
.tab_ctrl {
position: absolute;
top: 20px;
right: 20px;
}
}
.shape_tip {
color: #999;
line-height: 2;
font-size: 12px;
}
.fence_form {
display: flex;
flex-wrap: wrap;
.el-form-item {
flex: 0 0 50%;
}
.el_long_form_item {
flex: 0 0 100%;
}
}
.fold_box {
display: flex;
justify-content: flex-end;
border-bottom: 1px solid #f2f2f2;
.fold_btn {
cursor: pointer;
padding: 6px 16px;
border: 1px solid #2196f3;
border-bottom: 0;
border-top-left-radius: 10px;
border-top-right-radius: 10px;
background: #2196f3;
color: #fff;
}
}
.radius_box{
display:flex;
.btn{
margin-left:4px;
}
}
</style>
<style >
.scrollbar::-webkit-scrollbar {
width: 4px;
}
.scrollbar::-webkit-scrollbar-thumb {
border-radius: 15px;
box-shadow: inset 0 0 5px rgba(0, 0, 0, 0.2);
background: rgba(255, 255, 255, 0.1);
}
.scrollbar::-webkit-scrollbar-track {
border-radius: 0;
box-shadow: inset 0 0 5px rgba(0, 0, 0, 0.2);
background: rgba(255, 255, 255, 255);
}
.special-shop-input .el-input__inner {
cursor: pointer;
}
</style>
\ No newline at end of file
<template>
<v-full-layout>
<template slot="breadcrumb">
<el-breadcrumb-item>电子围栏</el-breadcrumb-item>
</template>
<template slot="main">
<div class="map-wrap" >
<div id="map" class="map-container" v-loading="mapLoading"></div>
<map-controll></map-controll>
<div class="controll-wrap">
<div class="search-box active side_auto_h">
<h3>电子围栏</h3>
<p class="info">{{name}}/{{standno}}/{{sn}}</p>
<el-form ref="form" :model="form" :rules="rules" :inline="false" size="mini" class="form">
<el-form-item label="定位方式">
<el-select v-model="form.locationType" placeholder="请选择" size="small" style="width: 280px">
<el-option label="GPS" :value="1"></el-option>
<el-option label="基站" :value="2"></el-option>
</el-select>
</el-form-item>
<el-form-item label="围栏名称" prop="electricFenceName">
<el-input v-model.trim="form.electricFenceName" maxlength="200"></el-input>
</el-form-item>
<el-form-item label="触发类型">
<el-select v-model="form.triggerType" placeholder="请选择" size="small" style="width: 280px">
<el-option label="驶出" :value="2"></el-option>
<el-option label="驶入" :value="1"></el-option>
<el-option label="驶入驶出" :value="3"></el-option>
</el-select>
</el-form-item>
<el-form-item label="指定区间" prop="daterange">
<el-date-picker
style="width: 100%;"
v-model="form.dateRange"
type="daterange"
size="small"
:clearable="false"
:editable="false"
:unlink-panels="true"
range-separator="至"
start-placeholder="开始日期"
end-placeholder="结束日期">
</el-date-picker>
</el-form-item>
<el-form-item label="监控区域" class="row-form-item">
<el-row>
<el-col :span="8">
<el-radio v-model="form.shapeType" :label="2">圆形</el-radio>
</el-col>
<el-col :span="16">
<el-form-item label="" prop="fenceRadius">
<el-input v-model.trim="form.fenceRadius" style="width: 80px;" maxlength="200"></el-input>米
</el-form-item>
</el-col>
</el-row>
<el-row>
<el-col :span="8">
<el-radio v-model="form.shapeType" :label="5">多边形</el-radio>
</el-col>
<el-col :span="16" class="shape_tip">*注:地图任意位置,单击新增双击结束绘制。</el-col>
</el-row>
<el-row>
<el-col :span="8">
<el-radio v-model="form.shapeType" :label="3">行政区域</el-radio>
</el-col>
<el-col :span="16">
<el-form-item label="">
<!-- 监控省市区组件 -->
<!-- <area-select ref="clearArea" @onChangArea="areaChoose" :prependFirst="true" :id="form.areaCode"></area-select> -->
<!-- 监控省市区组件 /-->
</el-form-item>
</el-col>
</el-row>
</el-form-item>
<el-form-item label="短信通知" prop="msgtel">
<el-input v-model.trim="form.msgtel" maxlength="100" placeholder="输入格式:手机号码,手机号码(支持双号)"></el-input>
</el-form-item>
<el-form-item label="围栏状态">
<el-radio v-model="form.status" :label="1">启用</el-radio>
<el-radio v-model="form.status" :label="0">停用</el-radio>
</el-form-item>
<el-form-item>
<el-button type="primary" @click="submit" size="small" :loading="isSubmitting">保存</el-button>
</el-form-item>
</el-form>
</div>
</div>
</div>
</template>
</v-full-layout>
</template>
<script>
import '@/assets/spritesmith-generated/sprite.css'
import store from '@/vuex/store.js'
import remoteLoad from '@/utils/remoteLoad.js'
import mapService from '@/utils/mapService.js'
import '@/utils/mapEvent.js'
import EventBus from '@/event-bus'
import {services} from '@/api'
const MONITOR_SERVICE = services.monitor;
import {CONSTANT} from '@/constant'
import AreaSelect from './AreaSelect.vue'
import MAPGEO from '@/utils/mapgeo'
import MapControll from './MapControll.vue'
export default{
data(){
let checkFenceName = (rule, vaule, cb)=>{
if(typeof this.restainFenceName != 'undefined' && this.form.electricFenceName === this.restainFenceName){
cb();
}
MONITOR_SERVICE.checkFenceName({name: this.form.electricFenceName}).then((res)=>{
if(res.returnCode == 0){
if(res.data.isExist == 1){
cb(new Error('该围栏名已存在,请重新输入!'))
}else{
cb();
}
}
})
}
let checkDaterange = (rule, vaule, cb)=>{
const dateRange = this.form.dateRange;
if(!dateRange || !dateRange.length){
cb(new Error('请选择日期'))
}else{
let min = dateRange[0];
let max = dateRange[1];
if(!moment.isMoment(min)){
min = moment(min)
}
if(!moment.isMoment(max)){
max = moment(max)
}
if(min.isBefore( moment(max).subtract(30*6, 'days'), 'minute')){
cb(new Error('日期范围不能超过180天'))
}
}
cb()
}
let checkRadius = (rule, vaule, cb)=>{
const fenceRadius = this.form.fenceRadius;
if(this.form.shapeType == 2 && (!/^\d+$/.test(fenceRadius) || fenceRadius<1000)){
cb(new Error('请输入整数且不小于1000'))
}else{
cb();
}
}
let checkMsgtel = (rule, vaule, cb)=>{
if(this.form.msgtel && !/^1\d{10}(\,1\d{10})?$/.test(this.form.msgtel)){
cb(new Error('请输入正确的格式'))
}else{
cb();
}
}
return {
sn: this.$route.query.sn,
name: this.$route.query.name,
standno: this.$route.query.standno,
AMap: null,
mapObj: null,
mapLoading: false,
isInitMap: false,
searchText: '',
searchType: 'sn',
isSearching: false,
areaId: '',
areaStr: '',
isSubmitting: false,
form: {
fenceNo: '',
electricFenceName: '',
locationType: 1,
triggerType: 3,
dateRange: [],
shapeType: 2,
fenceRadius: '1000',
status: 1,
areaCode: '',
lng: '',
lat: '',
analysisAddress: '',
msgtel: ''
},
rules: {
electricFenceName: [
{required: true, message: '请输入围栏名称', trigger: 'blur'},
{pattern: /^\S{2,200}$/, message: '至少2字', trigger: 'blur' },
{validator: checkFenceName, trigger: 'blur'}
],
daterange: [{validator: checkDaterange}],
fenceRadius: [
{validator: checkRadius, trigger: 'blur'}
],
msgtel: [{validator: checkMsgtel, trigger: 'blur'}],
},
fenceId: undefined,
restainFenceName: '',
polygonPath: []
}
},
mounted(){
store.dispatch('setFullsize', true)
},
watch: {
'form.fenceRadius'(newVal){
if(this.form.shapeType === 2){
if(this._updateFenceRadiusTimeoutId){
clearTimeout(this._updateFenceRadiusTimeoutId)
}
this._updateFenceRadiusTimeoutId = setTimeout(()=>{
this.$refs.form.validateField('fenceRadius', (error)=>{
if(error){
return false;
}else{
this.updateFenceRadius(newVal)
}
});
/*this.$refs.form.validate((valid, field)=>{
if(valid){
this.updateFenceRadius(newVal)
}else{
return false;
}
});*/
}, 500);
}
},
'form.shapeType'(newVal){
this._shapeTypeTimeoutId && clearTimeout(this._shapeTypeTimeoutId);
this._shapeTypeTimeoutId = setTimeout(()=>{
console.log(newVal)
if(newVal === 2){
this.$refs.form.validateField('fenceRadius', (error)=>{
if(error){
EventBus.$emit('uiMap.fence.destroy');
return false;
}else{
this.drawFenceCircle()
}
});
}else if(newVal === 3){
if(this.areaId){
this.drawDistrict(this.areaId)
}else{
EventBus.$emit('uiMap.fence.destroy');
}
}else if(newVal === 5){
this.drawPolygon()
}
}, 500)
}
},
methods: {
initMap(){
let check = ()=>{
this.checkMapLoaded && window.clearTimeout(this.checkMapLoaded);
return setTimeout(()=>{
if('AMap' in window && typeof AMap.Map == 'function' && !this.mapObj){
window.AMap = AMap;
this.mapObj = mapService.init('map');
//this.bindEvent();
this.isInitMap = true;
this.initFence();
}else{
this.checkMapLoaded = check()
}
}, 100)
}
this.checkMapLoaded = check();
},
initFence(){
MONITOR_SERVICE.getSingleFence({
sn: this.sn
}).then((res)=>{
if(res.returnCode == 0){
const data = res.data;
if(data){
this.fenceId = data.fenceId;
const form = this.form;
form.locationType = data.locationType;
form.electricFenceName = data.electricFenceName;
this.restainFenceName = form.electricFenceName;
form.triggerType = data.electricFenceType;
form.dateRange = [moment(data.startTime),moment(data.endTime)];
form.shapeType = data.shapeType;
form.status = data.status;
form.areaCode = data.areaCode;
form.msgtel = data.telNumbers;
if(form.shapeType === 2){
form.fenceRadius = data.radius;
form.lng = data.lng;
form.lat = data.lat;
EventBus.$emit('uiMap.fence.createFenceCircle', {
lng: data.lng,
lat: data.lat,
radius: data.radius
});
}else if(form.shapeType === 3){
this.drawDistrict(data.areaCode)
}else if(form.shapeType === 5){
if(data.lnglat){
this.polygonPath = data.lnglat.split('|').map((item)=>{
return [item.split(',')[0], item.split(',')[1]]
})
}
this.drawPolygon()
}
}else{
this.restainFenceName = undefined;
}
this.initDetail();
}
});
},
initDetail(){
MONITOR_SERVICE.getTrackBySn({
sn: this.sn
}).then((res)=>{
if(res.returnCode == 0){
const data = res.data;
const form = this.form;
if(!this.restainFenceName){
form.electricFenceName = '单设备围栏-'+this.name;
}
if(!form.lng && !form.lat){
form.lng = data.lngGPS;
form.lat = data.latGPS;
this.drawFenceCircle();
}
EventBus.$emit('uiMap.fence.createFenceMarker', data);
}
});
},
pickDate(beforeDays){
this.form.dateRange = [moment().subtract(beforeDays, 'days'),moment().subtract(1, 'days')]
},
submit(){
if(this.form.shapeType == 5){
if(this.polygonPath.length === 0){
this.$message({
message: '请绘制围栏',
type: 'error'
});
return;
}
}
this.$refs.form.validate((valid, field)=>{
if(valid){
this.isSubmitting = true;
this.getParams().then((data)=>{
let params = data;
if(typeof this.fenceId != 'undefined'){
params.id = this.fenceId;
MONITOR_SERVICE.updateFence(JSON.stringify(params)).then((res)=>{
if(res.returnCode == 0){
//this.closeDialog();
this.$message({
message: res.message,
type: 'success'
});
}
this.isSubmitting = false;
});
}else{
MONITOR_SERVICE.getNewFenceId().then((res)=>{
if(res.returnCode == 0){
params.fenceNo = res.data.fenceNo;
MONITOR_SERVICE.saveFence(JSON.stringify(params)).then((res)=>{
if(res.returnCode == 0){
//this.closeDialog();
this.$message({
message: res.message,
type: 'success'
});
this.fenceId = res.data;
this.restainFenceName = this.form.electricFenceName;
}
this.isSubmitting = false;
});
}
});
}
});
}else{
return false;
}
});
},
getParams(){
return new Promise((resolve, reject)=>{
const form = this.form;
const params = {};
const transferItem = {
data: [{
elng: form.lng,
elat: form.lat
}]
}
MAPGEO.transferAddressByGroup(transferItem, ()=>{
params.electricFenceName = form.electricFenceName;
params.electricFenceType = form.triggerType;
params.shapeType = form.shapeType;
params.locationType = form.locationType;
if(params.shapeType == 3){
params.areaCode = this.areaId;
params.areaString = this.areaStr;
}else if(params.shapeType == 2){
params.lng = form.lng;
params.lat = form.lat;
params.radius = form.fenceRadius;
params.analysisAddress = transferItem.data[0].transferAddress;
}else if(params.shapeType == 5){
params.lnglat = this.polygonPath.join('|')
}
params.status = form.status;
params.snList = [{sn: this.sn}]
params.startTime = moment(this.form.dateRange[0]).format('YYYY-MM-DD');
params.endTime = moment(this.form.dateRange[1]).format('YYYY-MM-DD');
if(form.msgtel){
params.telNumbers = form.msgtel
}
params.timeType = 2
resolve(params)
});
});
},
areaChoose(areaId, areaStr){
this.areaId = areaId;
this.areaStr = areaStr;
if(this.form.shapeType === 3){
this.drawDistrict(areaId)
}
},
updateFenceRadius(radius){
EventBus.$emit('uiMap.fence.updateFenceRadius', radius)
},
drawFenceCircle(){
EventBus.$emit('uiMap.fence.createFenceCircle', {
lng: this.form.lng,
lat: this.form.lat,
radius: this.form.fenceRadius
});
},
drawDistrict(areaCode){
this._drawDistrictTimeoutId && clearTimeout(this._drawDistrictTimeoutId);
this._drawDistrictTimeoutId = setTimeout(()=>{
EventBus.$emit('uiMap.fence.drawDistrict', areaCode);
}, 500);
},
drawPolygon(){
EventBus.$emit('uiMap.fence.drawPolygon', this.polygonPath)
}
},
created () {
if(window.AMap){
this.initMap();
}else{
remoteLoad(`${CONSTANT.AMAP_URL}`).then(()=>{
remoteLoad(`https://webapi.amap.com/ui/1.0/main.js?v=1.0.11`).then(()=>{
this.initMap();
})
})
}
EventBus.$on('uiMap.fence.loading', (isLoading)=>{
this.mapLoading = isLoading;
});
EventBus.$on('uiMap.fence.onFenceRadiusChange', (radius)=>{
this.form.fenceRadius = radius;
//this.$refs.form.validateField('fenceRadius');
});
EventBus.$on('uiMap.fence.onFenceLngLatChange', (data)=>{
this.form.lng = data.lng;
this.form.lat = data.lat;
});
EventBus.$on('uiMap.fence.polygonChange', (data)=>{
this.polygonPath = data.polygonPath
});
},
beforeDestroy(){
},
components: {
AreaSelect,
MapControll
}
}
</script>
<style scoped>
/*样式写在 scss/monitor.scss*/
.side_auto_h{
max-height: calc(100vh - 100px);
overflow: auto;
}
.shape_tip{
color:#999;
line-height:1.5;
margin-bottom: 10px;
}
</style>
\ No newline at end of file
<template>
<v-full-layout>
<template slot="breadcrumb">
<el-breadcrumb-item>电子围栏</el-breadcrumb-item>
</template>
<template slot="main">
<div class="map-wrap" >
<div id="map" class="map-container" v-loading="mapLoading"></div>
<map-controll></map-controll>
<div class="controll-wrap">
<div class="search-box active side_auto_h">
<h3>电子围栏</h3>
<p class="info">{{name}}/{{standno}}/{{sn}}</p>
<el-form ref="form" :model="form" :rules="rules" :inline="false" size="mini" class="form">
<el-form-item label="定位方式">
<el-select v-model="form.locationType" placeholder="请选择" size="small" style="width: 280px">
<el-option label="GPS" :value="1"></el-option>
<el-option label="基站" :value="2"></el-option>
</el-select>
</el-form-item>
<el-form-item label="围栏名称" prop="electricFenceName">
<el-input v-model.trim="form.electricFenceName" maxlength="200"></el-input>
</el-form-item>
<el-form-item label="触发类型">
<el-select v-model="form.triggerType" placeholder="请选择" size="small" style="width: 280px">
<el-option label="驶出" :value="2"></el-option>
<el-option label="驶入" :value="1"></el-option>
<el-option label="驶入驶出" :value="3"></el-option>
</el-select>
</el-form-item>
<el-form-item label="指定区间" prop="daterange">
<el-date-picker
style="width: 100%;"
v-model="form.dateRange"
type="daterange"
size="small"
:clearable="false"
:editable="false"
:unlink-panels="true"
range-separator="至"
start-placeholder="开始日期"
end-placeholder="结束日期">
</el-date-picker>
</el-form-item>
<el-form-item label="监控区域" class="row-form-item">
<el-row>
<el-col :span="8">
<el-radio v-model="form.shapeType" :label="2">圆形</el-radio>
</el-col>
<el-col :span="16">
<el-form-item label="" prop="fenceRadius">
<el-input v-model.trim="form.fenceRadius" style="width: 80px;" maxlength="200"></el-input>米
</el-form-item>
</el-col>
</el-row>
<el-row>
<el-col :span="8">
<el-radio v-model="form.shapeType" :label="5">多边形</el-radio>
</el-col>
<el-col :span="16" class="shape_tip">*注:地图任意位置,单击新增双击结束绘制。</el-col>
</el-row>
<el-row>
<el-col :span="8">
<el-radio v-model="form.shapeType" :label="3">行政区域</el-radio>
</el-col>
<el-col :span="16">
<el-form-item label="">
<!-- 监控省市区组件 -->
<area-select ref="clearArea" @onChangArea="areaChoose" :prependFirst="true" :id="form.areaCode"></area-select>
<!-- 监控省市区组件 /-->
</el-form-item>
</el-col>
</el-row>
</el-form-item>
<el-form-item label="短信通知" prop="msgtel">
<el-input v-model.trim="form.msgtel" maxlength="100" placeholder="输入格式:手机号码,手机号码(支持双号)"></el-input>
</el-form-item>
<el-form-item label="围栏状态">
<el-radio v-model="form.status" :label="1">启用</el-radio>
<el-radio v-model="form.status" :label="0">停用</el-radio>
</el-form-item>
<el-form-item>
<el-button type="primary" @click="submit" size="small" :loading="isSubmitting">保存</el-button>
</el-form-item>
</el-form>
</div>
</div>
</div>
</template>
</v-full-layout>
<v-full-layout>
<template slot="breadcrumb">
<el-breadcrumb-item>电子围栏</el-breadcrumb-item>
</template>
<template slot="main">
<div class="map-wrap">
<div id="map" class="map-container" v-loading="mapLoading"></div>
<map-controll></map-controll>
<div class="controll-wrap">
<el-scrollbar class="el_scrollbar">
<div class="search-box">
<h3>电子围栏</h3>
<p class="info">{{name}}/{{standno}}/{{sn}}</p>
<el-form ref="form" :model="form" :rules="rules" size="mini" class="form" label-position="top">
<el-form-item label="定位方式">
<el-select v-model="form.locationType" class="a_select" placeholder="请选择" size="small" :disabled="true">
<el-option label="GPS" :value="1"></el-option>
<el-option label="基站" :value="2"></el-option>
</el-select>
</el-form-item>
<el-form-item label="围栏名称" prop="fenceName">
<el-input v-model.trim="form.fenceName" maxlength="200"></el-input>
</el-form-item>
<el-form-item label="触发类型" prop="triggerType">
<el-select v-model="form.triggerType" class="a_select" placeholder="请选择" size="small">
<el-option label="驶出" :value="2"></el-option>
<el-option label="驶入" :value="1"></el-option>
<el-option label="驶入驶出" :value="3"></el-option>
</el-select>
</el-form-item>
<el-form-item label="指定区间" prop="dateRange">
<el-date-picker style="width: 100%;" v-model="form.dateRange" type="daterange" size="small" :clearable="false" :editable="false" :unlink-panels="true" range-separator="至" start-placeholder="开始日期" end-placeholder="结束日期" value-format="yyyy-MM-dd">
</el-date-picker>
</el-form-item>
<el-form-item label="监控区域" class="row-form-item">
<div class="el_radio_group">
<div class="radio_cell">
<el-radio :label="1" v-model="form.shapeType">圆形</el-radio>
<el-form-item label="" prop="radius">
<el-input v-model.trim="form.radius" style="width: 80px;" maxlength="200" @change="changeRadius"></el-input>米
</el-form-item>
</div>
<div class="radio_cell">
<el-radio :label="3" v-model="form.shapeType">多边形</el-radio>
<div class="shape_tip">*注:地图任意位置,单击新增双击结束绘制。</div>
</div>
<div class="radio_cell">
<el-radio :label="4" v-model="form.shapeType">行政区域</el-radio>
<el-form-item label="" prop="areaName">
<city-select v-model="form.areaName" :checkStrictly="true" :disabled="form.shapeType != 4" @change="changeArea"></city-select>
</el-form-item>
</div>
</div>
</el-form-item>
<el-form-item label="短信通知" prop="telNumbers">
<el-input v-model.trim="form.telNumbers" maxlength="100" placeholder="输入格式:手机号码,手机号码(支持双号)"></el-input>
</el-form-item>
<el-form-item label="围栏状态">
<el-radio v-model="form.enableStatus" :label="1">启用</el-radio>
<el-radio v-model="form.enableStatus" :label="0">停用</el-radio>
</el-form-item>
<el-form-item>
<el-button type="primary" @click="submit" size="small" :loading="isSubmitting">保存</el-button>
</el-form-item>
</el-form>
</div>
</el-scrollbar>
</div>
</div>
</template>
</v-full-layout>
</template>
<script>
import '../../assets/spritesmith-generated/sprite.css'
import store from '../../vuex/store.js'
import remoteLoad from 'utils/remoteLoad.js'
import mapService from 'utils/mapService.js'
import 'utils/mapEvent.js'
import EventBus from '../../event-bus'
import {services} from '../../api'
import mock from '../../mock'
const MONITOR_SERVICE = services.monitor;
import "@/assets/spritesmith-generated/sprite.css";
import mapService from "@/utils/mapService.js";
import "@/utils/mapEvent.js";
import EventBus from "@/event-bus";
import { services } from "@/api";
const MONITOR_SERVICE = services.monitor;
import { CONSTANT } from "@/constant";
import { deepClone, showToast } from "@/utils/utils";
import AreaSelect from "./AreaSelect.vue";
import MapControll from "./MapControll.vue";
import AMapLoader from "@amap/amap-jsapi-loader";
import { GET_DEVICE_LOCATION } from "@/api/services/monitor";
import CitySelect from "@/components/area";
import { SAVE_ELECFENCE_INFO } from "@/api/services/fence";
export default {
components: {
AreaSelect,
MapControll,
CitySelect,
},
data() {
let checkFenceName = (rule, vaule, cb) => {
if (
typeof this.restainFenceName != "undefined" &&
this.form.electricFenceName === this.restainFenceName
) {
cb();
}
MONITOR_SERVICE.checkFenceName({
name: this.form.electricFenceName,
}).then((res) => {
if (res.returnCode == 0) {
if (res.data.isExist == 1) {
cb(new Error("该围栏名已存在,请重新输入!"));
} else {
cb();
}
}
});
};
let checkDaterange = (rule, vaule, cb) => {
const dateRange = this.form.dateRange;
if (!dateRange || !dateRange.length) {
cb(new Error("请选择日期"));
} else {
let min = dateRange[0];
let max = dateRange[1];
if (!moment.isMoment(min)) {
min = moment(min);
}
if (!moment.isMoment(max)) {
max = moment(max);
}
if (min.isBefore(moment(max).subtract(30 * 6, "days"), "minute")) {
cb(new Error("日期范围不能超过180天"));
}
}
cb();
};
let checkRadius = (rule, vaule, cb) => {
const fenceRadius = this.form.radius;
if (
this.form.shapeType == 1 &&
(!/^\d+$/.test(fenceRadius) || fenceRadius < 1000)
) {
cb(new Error("请输入整数且不小于1000"));
} else {
cb();
}
};
let checkMsgtel = (rule, vaule, cb) => {
let reg = /^1\d{10}((\,1\d{10})|(\,1\d{10}))?$/;
if (this.form.telNumbers && !reg.test(this.form.telNumbers)) {
cb(new Error("请输入正确的格式"));
} else {
cb();
}
};
let checkArea = (rule, vaule, cb) => {
if (this.form.shapeType == 4 && !this.form.areaCode) {
cb(new Error("请选择行政区域"));
} else {
cb();
}
};
return {
sn: this.$route.query.sn,
name: this.$route.query.name,
standno: this.$route.query.standno,
AMap: null,
mapObj: null,
mapLoading: false,
isInitMap: false,
searchText: "",
searchType: "sn",
isSearching: false,
areaId: "",
areaStr: "",
isSubmitting: false,
form: {
locationType: 1,
triggerType: 3,
shapeType: 1,
radius: 1000,
enableStatus: 1,
},
rules: {
fenceName: [
{ required: true, message: "请输入围栏名称", trigger: "blur" },
{ pattern: /^\S{2,200}$/, message: "至少2字", trigger: "blur" },
// { validator: checkFenceName, trigger: "blur" },
],
triggerType: [
{ required: true, message: "请选择触发类型", trigger: "change" },
],
dateRange: [
{ required: true, message: "请选择指定区间", trigger: "change" },
{ validator: checkDaterange, trigger: "change" },
],
raidus: [{ validator: checkRadius, trigger: "blur" }],
telNumbers: [{ validator: checkMsgtel, trigger: "blur" }],
areaName: [{ validator: checkArea, trigger: "blur" }],
},
fenceId: "",
restainFenceName: "",
polygonPath: [],
deviceInfo: {}, // 设备信息
deviceList: [], // 设备列表
};
},
created() {
EventBus.$on("uiMap.fence.onFenceRadiusChange", this.onFenceRadiusChange);
EventBus.$on("uiMap.fence.polygonChange", this.onFencePolyChange);
this.initMap();
},
mounted() {
//store.dispatch("setFullsize", true);
},
// watch: {
// "form.shapeType": {
// handler: function (n, o) {
// this.changeShapeType(n);
// },
// immediate: true,
// },
// },
methods: {
// 初始化地图
initMap() {
let _this = this;
AMapLoader.load({
key: CONSTANT.MAP_KEY, // 申请好的Web端开发者Key,首次调用 load 时必填
version: "2.0", // 指定要加载的 JSAPI 的版本,缺省时默认为 1.4.15
plugins: CONSTANT.MAP_PLUGINS, // 需要使用的的插件列表,如比例尺'AMap.Scale'等
}).then((AMap) => {
window.AMap = AMap;
_this.map = mapService.init("map");
_this.getDevinceInfo();
});
},
// 获取设备信息
getDevinceInfo() {
let oParams = {};
oParams.sns = this.$route.query.sn;
oParams.deviceCode = "gps";
GET_DEVICE_LOCATION(oParams).then((res) => {
if (!res.data || res.data.length <= 0) {
return false;
}
let obj = res.data[0] || {};
this.deviceInfo = obj;
this.deviceList = res.data || [];
this.drawMarker(res);
this.drawFenceCircle(obj.gpsLocation);
});
},
pickDate(beforeDays) {},
// 保存围栏信息
submit() {
let _this = this;
_this.$refs.form.validate((valid) => {
if (!valid) {
return false;
}
let oParams = _this.getParams();
// 多边形围栏校验
if (
oParams.shapeType == 3 &&
(!_this.polygonPath || _this.polygonPath.length <= 0)
) {
showToast({
message: "请绘制线路",
});
return false;
}
console.log(oParams);
_this.isSubmitting = true;
SAVE_ELECFENCE_INFO(oParams)
.then((res) => {
_this.isSubmitting = false;
if (res.code != 200) {
showToast({
message: res.message,
});
return false;
}
showToast({
message: "保存成功",
type: "success",
});
})
.catch((error) => {
_this.isSubmitting = false;
});
});
},
updateFenceRadius(radius) {},
// 在地图上画圆形围栏
drawFenceCircle(info) {
let _this = this;
_this.form.lng = info.elng;
_this.form.lat = info.elat;
EventBus.$emit("uiMap.fence.createFenceCircle", {
lng: info.elng,
lat: info.elat,
radius: _this.form.radius,
});
},
// 在地图上画行政区域
drawDistrict(areaCode) {
console.log(areaCode);
EventBus.$emit("uiMap.fence.drawDistrict", areaCode);
},
// 在地图上画多边形
drawPolygon() {
EventBus.$emit("uiMap.fence.destroy");
EventBus.$emit("uiMap.fence.drawPolygon", this.polygonPath);
},
// 根据设备地址,在地图上画车辆
drawMarker(res) {
let query = this.$route.query;
let obj = res.data[0] || {};
let g = obj.gpsLocation || {};
let b = obj.bsLocation || {};
let option = {};
let sourceType = {
1: "有线",
2: "无线",
};
// GPS信息
option.lngGPS = g.elng;
option.latGPS = g.elat;
option.timeGPS = g.dateTime;
option.transferAddressGPS = g.address;
// 基站信息
option.lngBase = b.elng;
option.latBase = b.elat;
option.timeBase = b.dateTime;
option.transferAddressBase = b.address;
option.name = query.name;
option.standno = query.standno;
option.sn = query.sn;
option.sourceString = sourceType[obj.source] || "--";
option.status = obj.status;
option.battery = obj.battery;
import {CONSTANT} from '../../constant'
// 标记车辆信息
EventBus.$emit("uiMap.fence.createFenceMarker", option);
},
import AreaSelect from './AreaSelect.vue'
import MAPGEO from 'utils/mapgeo'
import MapControll from './MapControll.vue'
// 监听圆形围栏直径变化
onFenceRadiusChange(e) {
console.log("圆形围栏:", e);
this.$set(this.form, "radius", e);
},
export default{
data(){
let checkFenceName = (rule, vaule, cb)=>{
if(typeof this.restainFenceName != 'undefined' && this.form.electricFenceName === this.restainFenceName){
cb();
}
MONITOR_SERVICE.checkFenceName({name: this.form.electricFenceName}).then((res)=>{
if(res.returnCode == 0){
if(res.data.isExist == 1){
cb(new Error('该围栏名已存在,请重新输入!'))
}else{
cb();
}
}
})
}
let checkDaterange = (rule, vaule, cb)=>{
// 监听围栏类型变化
changeShapeType(e) {
let _this = this;
let _info = this.deviceInfo;
let areaCode = this.form.areaCode || [];
// 1:圆形围栏 4:行政区域 3:多边形
console.log(_info);
switch (e) {
case 4:
_this.drawDistrict(areaCode);
break;
case 3:
_this.drawPolygon();
break;
default:
_this.drawFenceCircle(_info.gpsLocation || {});
break;
}
},
const dateRange = this.form.dateRange;
if(!dateRange || !dateRange.length){
cb(new Error('请选择日期'))
}else{
let min = dateRange[0];
let max = dateRange[1];
if(!moment.isMoment(min)){
min = moment(min)
}
if(!moment.isMoment(max)){
max = moment(max)
}
if(min.isBefore( moment(max).subtract(30*6, 'days'), 'minute')){
cb(new Error('日期范围不能超过180天'))
}
}
cb()
}
// 监听多边形围栏变化
onFencePolyChange(e) {
this.polygonPath = e.polygonPath;
},
let checkRadius = (rule, vaule, cb)=>{
const fenceRadius = this.form.fenceRadius;
if(this.form.shapeType == 2 && (!/^\d+$/.test(fenceRadius) || fenceRadius<1000)){
cb(new Error('请输入整数且不小于1000'))
}else{
cb();
}
}
// 监听行政区域
changeArea(e) {
console.log(e);
this.form.areaCode = e.code;
this.form.areaText = e.name;
this.drawDistrict(e.code);
this.$refs.form.clearValidate();
},
let checkMsgtel = (rule, vaule, cb)=>{
if(this.form.msgtel && !/^1\d{10}(\,1\d{10})?$/.test(this.form.msgtel)){
cb(new Error('请输入正确的格式'))
}else{
cb();
}
}
return {
sn: this.$route.query.sn,
name: this.$route.query.name,
standno: this.$route.query.standno,
AMap: null,
mapObj: null,
mapLoading: false,
isInitMap: false,
searchText: '',
searchType: 'sn',
isSearching: false,
areaId: '',
areaStr: '',
isSubmitting: false,
form: {
fenceNo: '',
electricFenceName: '',
locationType: 1,
triggerType: 3,
dateRange: [],
shapeType: 2,
fenceRadius: '1000',
status: 1,
areaCode: '',
lng: '',
lat: '',
analysisAddress: '',
msgtel: ''
},
rules: {
electricFenceName: [
{required: true, message: '请输入围栏名称', trigger: 'blur'},
{pattern: /^\S{2,200}$/, message: '至少2字', trigger: 'blur' },
{validator: checkFenceName, trigger: 'blur'}
],
daterange: [{validator: checkDaterange}],
fenceRadius: [
{validator: checkRadius, trigger: 'blur'}
],
msgtel: [{validator: checkMsgtel, trigger: 'blur'}],
},
fenceId: undefined,
restainFenceName: '',
polygonPath: []
}
},
mounted(){
store.dispatch('setFullsize', true)
},
watch: {
'form.fenceRadius'(newVal){
if(this.form.shapeType === 2){
if(this._updateFenceRadiusTimeoutId){
clearTimeout(this._updateFenceRadiusTimeoutId)
}
this._updateFenceRadiusTimeoutId = setTimeout(()=>{
this.$refs.form.validateField('fenceRadius', (error)=>{
if(error){
return false;
}else{
this.updateFenceRadius(newVal)
}
});
/*this.$refs.form.validate((valid, field)=>{
if(valid){
this.updateFenceRadius(newVal)
}else{
return false;
}
});*/
}, 500);
}
},
'form.shapeType'(newVal){
this._shapeTypeTimeoutId && clearTimeout(this._shapeTypeTimeoutId);
this._shapeTypeTimeoutId = setTimeout(()=>{
if(newVal === 2){
this.$refs.form.validateField('fenceRadius', (error)=>{
if(error){
EventBus.$emit('uiMap.fence.destroy');
return false;
}else{
this.drawFenceCircle()
}
});
}else if(newVal === 3){
if(this.areaId){
this.drawDistrict(this.areaId)
}else{
EventBus.$emit('uiMap.fence.destroy');
}
}else if(newVal === 5){
this.drawPolygon()
}
}, 500)
}
},
methods: {
initMap(){
let check = ()=>{
this.checkMapLoaded && window.clearTimeout(this.checkMapLoaded);
// 获取参数
getParams() {
let _this = this;
let o = deepClone(_this.form);
console.log(o);
let oParams = {};
let deviceList = this.deviceList;
return setTimeout(()=>{
if('AMap' in window && typeof AMap.Map == 'function' && !this.mapObj){
window.AMap = AMap;
this.mapObj = mapService.init('map');
//this.bindEvent();
this.isInitMap = true;
this.initFence();
}else{
this.checkMapLoaded = check()
}
}, 100)
}
this.checkMapLoaded = check();
},
initFence(){
MONITOR_SERVICE.getSingleFence({
sn: this.sn
}).then((res)=>{
if(res.returnCode == 0){
const data = res.data;
if(data){
this.fenceId = data.fenceId;
const form = this.form;
form.locationType = data.locationType;
form.electricFenceName = data.electricFenceName;
this.restainFenceName = form.electricFenceName;
oParams.fenceName = o.fenceName;
oParams.bizFenceType = 14;
oParams.triggerType = o.triggerType;
oParams.enableStatus = o.enableStatus;
oParams.timeType = 2;
oParams.shapeType = o.shapeType;
oParams.telNumbers = o.telNumbers;
form.triggerType = data.electricFenceType;
form.dateRange = [moment(data.startTime),moment(data.endTime)];
form.shapeType = data.shapeType;
form.status = data.status;
form.areaCode = data.areaCode;
form.msgtel = data.telNumbers;
if(form.shapeType === 2){
form.fenceRadius = data.radius;
form.lng = data.lng;
form.lat = data.lat;
EventBus.$emit('uiMap.fence.createFenceCircle', {
lng: data.lng,
lat: data.lat,
radius: data.radius
});
}else if(form.shapeType === 3){
this.drawDistrict(data.areaCode)
}else if(form.shapeType === 5){
if(data.lnglat){
this.polygonPath = data.lnglat.split('|').map((item)=>{
return [item.split(',')[0], item.split(',')[1]]
})
}
this.drawPolygon()
}
}else{
this.restainFenceName = undefined;
}
this.initDetail();
}
});
},
initDetail(){
MONITOR_SERVICE.getTrackBySn({
sn: this.sn
}).then((res)=>{
if(res.returnCode == 0){
const data = res.data;
const form = this.form;
if(!this.restainFenceName){
form.electricFenceName = '单设备围栏-'+this.name;
}
if(!form.lng && !form.lat){
form.lng = data.lngGPS;
form.lat = data.latGPS;
this.drawFenceCircle();
}
EventBus.$emit('uiMap.fence.createFenceMarker', data);
}
});
},
pickDate(beforeDays){
this.form.dateRange = [moment().subtract(beforeDays, 'days'),moment().subtract(1, 'days')]
},
submit(){
if(this.form.shapeType == 5){
if(this.polygonPath.length === 0){
this.$message({
message: '请绘制围栏',
type: 'error'
});
return;
}
}
this.$refs.form.validate((valid, field)=>{
if(valid){
this.isSubmitting = true;
this.getParams().then((data)=>{
let params = data;
// 指定区间
if (o.dateRange && o.dateRange.length > 0) {
oParams.startTime = o.dateRange[0];
oParams.endTime = o.dateRange[1];
}
if(typeof this.fenceId != 'undefined'){
params.id = this.fenceId;
MONITOR_SERVICE.updateFence(JSON.stringify(params)).then((res)=>{
if(res.returnCode == 0){
//this.closeDialog();
this.$message({
message: res.message,
type: 'success'
});
}
this.isSubmitting = false;
});
}else{
MONITOR_SERVICE.getNewFenceId().then((res)=>{
if(res.returnCode == 0){
params.fenceNo = res.data.fenceNo;
MONITOR_SERVICE.saveFence(JSON.stringify(params)).then((res)=>{
if(res.returnCode == 0){
//this.closeDialog();
this.$message({
message: res.message,
type: 'success'
});
this.fenceId = res.data;
this.restainFenceName = this.form.electricFenceName;
}
this.isSubmitting = false;
});
}
});
}
});
}else{
return false;
}
});
},
getParams(){
return new Promise((resolve, reject)=>{
const form = this.form;
const params = {};
const transferItem = {
data: [{
elng: form.lng,
elat: form.lat
}]
}
MAPGEO.transferAddressByGroup(transferItem, ()=>{
params.electricFenceName = form.electricFenceName;
params.electricFenceType = form.triggerType;
params.shapeType = form.shapeType;
params.locationType = form.locationType;
// 圆形围栏
if (o.shapeType == 1) {
oParams.radius = o.radius;
oParams.lnglat = `${o.lng},${o.lat}`;
}
if(params.shapeType == 3){
params.areaCode = this.areaId;
params.areaString = this.areaStr;
}else if(params.shapeType == 2){
params.lng = form.lng;
params.lat = form.lat;
params.radius = form.fenceRadius;
params.analysisAddress = transferItem.data[0].transferAddress;
}else if(params.shapeType == 5){
params.lnglat = this.polygonPath.join('|')
}
params.status = form.status;
params.snList = [{sn: this.sn}]
params.startTime = moment(this.form.dateRange[0]).format('YYYY-MM-DD');
params.endTime = moment(this.form.dateRange[1]).format('YYYY-MM-DD');
if(form.msgtel){
params.telNumbers = form.msgtel
}
params.timeType = 2
// 多边形围栏
if (o.shapeType == 3) {
oParams.lnglat = this.polygonPath;
}
resolve(params)
});
});
},
areaChoose(areaId, areaStr){
this.areaId = areaId;
this.areaStr = areaStr;
if(this.form.shapeType === 3){
this.drawDistrict(areaId)
}
},
updateFenceRadius(radius){
EventBus.$emit('uiMap.fence.updateFenceRadius', radius)
},
drawFenceCircle(){
EventBus.$emit('uiMap.fence.createFenceCircle', {
lng: this.form.lng,
lat: this.form.lat,
radius: this.form.fenceRadius
});
},
drawDistrict(areaCode){
this._drawDistrictTimeoutId && clearTimeout(this._drawDistrictTimeoutId);
// 行政区域围栏
if (o.shapeType == 4) {
oParams.areaCode = o.areaCode[o.areaCode.length - 1];
oParams.areaText = o.areaText[o.areaText.length - 1];
}
this._drawDistrictTimeoutId = setTimeout(()=>{
EventBus.$emit('uiMap.fence.drawDistrict', areaCode);
}, 500);
},
drawPolygon(){
EventBus.$emit('uiMap.fence.drawPolygon', this.polygonPath)
}
},
created () {
if(window.AMap){
this.initMap();
}else{
remoteLoad(`${CONSTANT.AMAP_URL}`).then(()=>{
remoteLoad(`https://webapi.amap.com/ui/1.0/main.js?v=1.0.11`).then(()=>{
this.initMap();
})
})
}
EventBus.$on('uiMap.fence.loading', (isLoading)=>{
this.mapLoading = isLoading;
});
EventBus.$on('uiMap.fence.onFenceRadiusChange', (radius)=>{
this.form.fenceRadius = radius;
//this.$refs.form.validateField('fenceRadius');
});
EventBus.$on('uiMap.fence.onFenceLngLatChange', (data)=>{
this.form.lng = data.lng;
this.form.lat = data.lat;
});
EventBus.$on('uiMap.fence.polygonChange', (data)=>{
this.polygonPath = data.polygonPath
});
},
beforeDestroy(){
// 设备列表
let arr = [];
deviceList.map((k) => {
let cur = {};
let _gps = k.gpsLocation || {};
cur.address = _gps.address;
cur.lat = _gps.elat;
cur.lng = _gps.elng;
cur.name = k.ownerName;
cur.sn = k.sn;
cur.time = _gps.dateTime;
cur.userTel = "";
cur.vin = k.vin;
arr.push(cur);
});
oParams.snList = arr;
return oParams;
},
},
components: {
AreaSelect,
MapControll
}
}
// 监听圆形半径更改
changeRadius(e) {
let reg = /^\d+$/;
if (!reg.test(e) || e < 1000) {
showToast({
message: "请输入整数且不小于1000",
});
return false;
}
this.$refs.fenceMap.updateFence({
fenceType: "circle",
lng: this.form.lng,
lat: this.form.lat,
radius: this.form.radius,
});
},
},
};
</script>
<style scoped>
/*样式写在 scss/monitor.scss*/
.side_auto_h{
max-height: calc(100vh - 100px);
overflow: auto;
}
.shape_tip{
color:#999;
line-height:1.5;
margin-bottom: 10px;
}
<style lang="scss" scoped>
/*样式写在 scss/monitor.scss*/
.side_auto_h {
max-height: calc(100vh - 100px);
overflow: auto;
}
.shape_tip {
color: #999;
line-height: 1.5;
margin-bottom: 10px;
}
.search-box {
height: 100%;
display: block;
.info {
word-break: break-all;
}
.a_select {
width: 100%;
}
}
.map-wrap {
.controll-wrap {
top: 10px;
left: 10px;
bottom: 10px;
}
.el_scrollbar {
height: 100%;
z-index: 999;
/deep/ .el-scrollbar__wrap {
overflow-x: hidden;
}
}
}
.el_radio_group {
display: flex;
flex-direction: column;
.radio_cell {
display: flex;
align-items: center;
margin: 0 0 10px 0;
.el-radio {
margin-bottom: 15px;
}
.shape_tip {
font-size: 12px;
}
}
}
</style>
\ No newline at end of file
<template>
<!-- 围栏调用地图弹框 -->
<!-- <el-dialog id="fenceMapModal1" :visible="fenceMapModalVisible" @open="openDialog" @close="closeDialog" append-to-body width="1200px" top="10vh"> -->
<!-- <div class="dialog-header" slot="title">
<!-- 围栏调用地图弹框 -->
<!-- <el-dialog id="fenceMapModal1" :visible="fenceMapModalVisible" @open="openDialog" @close="closeDialog" append-to-body width="1200px" top="10vh"> -->
<!-- <div class="dialog-header" slot="title">
<h2 class="header-title">地图引用</h2>
</div> -->
<div class="fence-map" :visible="fenceMapModalVisible" v-loading="mapLoading">
<!-- <el-form :model="form" ref="fenceMapForm" :rules="rules" :inline="true" size="mini" >
<div class="fence-map" :visible="fenceMapModalVisible" v-loading="mapLoading">
<!-- <el-form :model="form" ref="fenceMapForm" :rules="rules" :inline="true" size="mini" >
<el-form-item label="经度" prop="lng">
<el-input v-model="form.lng" style="width:100px" @change="transfer"></el-input>
</el-form-item>
......@@ -24,93 +23,94 @@
</el-form-item>
<el-form-item><el-button type="primary" @click="updateFence">更新围栏</el-button></el-form-item>
</el-form>-->
<div id="mapContainer" class="map-container"></div>
<fence-map-controll @onRefreshMap="refreshMap" :isModalMap="true"></fence-map-controll>
<div class="map-seacrh-wrap">
<!-- <input type="text" id="fenceMapSearch"> -->
<el-input placeholder="请输入位置" id="fenceMapSearch" size="small" v-model="fenceMapSearch" :disabled="readonlyStatus">
<template slot="prepend">搜索</template>
<!-- <el-button slot="append" icon="el-icon-search" @click="search"></el-button> -->
</el-input>
</div>
</div>
<!-- <div slot="footer" class="dialog-footer">
<div id="mapContainer" class="map-container"></div>
<fence-map-controll @onRefreshMap="refreshMap" :isModalMap="true"></fence-map-controll>
<div class="map-seacrh-wrap">
<!-- <input type="text" id="fenceMapSearch"> -->
<el-input placeholder="请输入位置" id="fenceMapSearch" size="small" v-model="fenceMapSearch" :disabled="readonlyStatus">
<template slot="prepend">搜索</template>
<!-- <el-button slot="append" icon="el-icon-search" @click="search"></el-button> -->
</el-input>
</div>
</div>
<!-- <div slot="footer" class="dialog-footer">
<el-button type="primary" @click="sure" size="small">确认</el-button>
<el-button @click="$emit('onFenceMapModalChange', false)" size="small">关闭</el-button>
</div> -->
<!-- </el-dialog> -->
<!-- 围栏调用地图弹框 /-->
<!-- </el-dialog> -->
<!-- 围栏调用地图弹框 /-->
</template>
<script>
import {services} from '../../api'
import remoteLoad from 'utils/remoteLoad.js'
import mapService from 'utils/mapService.js'
import FenceMapControll from './FenceMapControll.vue'
const BUSINESS_SERVICE = services.business;
import {CONSTANT} from '../../constant'
export default{
props: ['fenceMapModalVisible', 'init', 'readonlyStatus'],
data(){
return {
fenceMapSearch: '',
geolocation: null,
circleEditor: null,
areaCodeMap:"",
polygons:[],
polygonEditor:null,
autoCenterMarker:null,
marke:null,
fenceMapModalVisible:false,
polygon:null,
mapDot:true,
circle: null,
tableData:[],
transferTimeoutId: undefined,
geocoder: null,
transferFlag: null,
opts : {
subdistrict: 1, //返回下一级行政区
showbiz:false //最后一级返回街道信息
},
mapObj: null,
fenceType: 'polygon', //'area' 'polygon'
lng: '',
lat: '',
radius: '',
fenceCircle: null,
fenceCenter: null,
areaCode: '',
isFenceInit: false,
mapLoading: false,
polygonPath: [
/* [116.403322, 39.920255],
import remoteLoad from "utils/remoteLoad.js";
import mapService from "utils/mapService.js";
import FenceMapControll from "./FenceMapControll.vue";
import { CONSTANT } from "../../constant";
export default {
props: ["fenceMapModalVisible", "init", "readonlyStatus"],
data() {
return {
fenceMapSearch: "",
geolocation: null,
circleEditor: null,
areaCodeMap: "",
polygons: [],
polygonEditor: null,
autoCenterMarker: null,
marke: null,
fenceMapModalVisible: false,
polygon: null,
mapDot: true,
circle: null,
tableData: [],
transferTimeoutId: undefined,
geocoder: null,
transferFlag: null,
opts: {
subdistrict: 1, //返回下一级行政区
showbiz: false, //最后一级返回街道信息
},
mapObj: null,
fenceType: "polygon", //'area' 'polygon'
lng: "",
lat: "",
radius: "",
fenceCircle: null,
fenceCenter: null,
areaCode: "",
isFenceInit: false,
mapLoading: false,
polygonPath: [
/* [116.403322, 39.920255],
[116.410703, 39.897555],
[116.402292, 39.892353],
[116.389846, 39.891365] */
]
}
},
mounted(){
},
watch: {
lng(newVal){
//this.transfer()
},
lat(newVal){
//this.transfer()
},
/* mapData(newVal){
],
};
},
async mounted() {
if (window.AMap) {
this.initMap();
} else {
await remoteLoad(`${CONSTANT.AMAP_URL}`, true);
this.initMap();
}
},
watch: {
lng(newVal) {
//this.transfer()
},
lat(newVal) {
//this.transfer()
},
/* mapData(newVal){
const fenceData = newVal;
this.initMapPromise.then(()=>{console.log(fenceData)
if(fenceData.fenceType === 'circle'){
......@@ -118,507 +118,481 @@ export default{
}
})
} */
},
async created () {
if(window.AMap){
this.initMap()
}else{
await remoteLoad(`${CONSTANT.AMAP_URL}`, true);
this.initMap()
}
},
methods: {
initMap(){
this.initMapPromise = new Promise((resolve, reject)=>{
let check = ()=>{
this.checkMapLoaded && window.clearTimeout(this.checkMapLoaded);
return setTimeout(()=>{
if('AMap' in window && typeof AMap.Map == 'function' && !this.mapObj){
window.AMap = AMap;
this.mapObj = mapService.init('mapContainer');
this.bindContextMenu();
this.bindSearch();
resolve()
}else{
this.checkMapLoaded = check()
}
}, 100)
}
this.checkMapLoaded = check();
})
},
bindSearch(){
const self = this;
this.auto = new AMap.Autocomplete({
input: 'fenceMapSearch'
});
this.autoCenterMarker = new AMap.Marker({
icon: require('images/auto-center-marker.gif'),
map: this.mapObj,
offset: new AMap.Pixel(-12,-12),
visible: false
});
this.autoCenterMarker.on('rightclick', (e)=> {
if(self.mapObj.getAllOverlays('circle').length){
window.mapMenu.contextMenu.open(self.mapObj, e.lnglat);
self.contextMenuPositon = e.lnglat; //右键菜单位置
}
});
AMap.event.addListener(this.auto, 'select', (e)=>{
if(e.poi && e.poi.location){
this.mapObj.setCenter(e.poi.location);
this.autoCenterMarker.setPosition(e.poi.location);
/*for(var i = 0, l = this.polygons.length; i < l; i++) {
},
async created() {
},
methods: {
initMap() {
this.initMapPromise = new Promise((resolve, reject) => {
let check = () => {
this.checkMapLoaded && window.clearTimeout(this.checkMapLoaded);
return setTimeout(() => {
if (
"AMap" in window &&
typeof AMap.Map == "function" &&
!this.mapObj
) {
window.AMap = AMap;
this.mapObj = mapService.init("mapContainer");
this.bindContextMenu();
this.bindSearch();
resolve();
} else {
this.checkMapLoaded = check();
}
}, 100);
};
this.checkMapLoaded = check();
});
},
bindSearch() {
const self = this;
AMap.plugin("AMap.Autocomplete", function () {
self.auto = new AMap.Autocomplete({
input: "fenceMapSearch",
});
self.autoCenterMarker = new AMap.Marker({
icon: require("images/auto-center-marker.gif"),
map: self.mapObj,
offset: new AMap.Pixel(-12, -12),
visible: false,
});
self.autoCenterMarker.on("rightclick", (e) => {
if (self.mapObj.getAllOverlays("circle").length) {
window.mapMenu.contextMenu.open(self.mapObj, e.lnglat);
self.contextMenuPositon = e.lnglat; //右键菜单位置
}
});
AMap.event.addListener(self.auto, "select", (e) => {
if (e.poi && e.poi.location) {
self.mapObj.setCenter(e.poi.location);
self.autoCenterMarker.setPosition(e.poi.location);
/*for(var i = 0, l = this.polygons.length; i < l; i++) {
this.polygons[i].setMap(null);
}*/
this.autoCenterMarker.show();
this.mapObj.add(this.autoCenterMarker);
//this.form.lng = e.poi.location.lng;
//this.form.lat = e.poi.location.lat;
//this.contextMenuPositon = e.poi.location
//window.mapMenu.contextMenu.open(this.mapObj, mapService.getLngLat(e.poi.location.lng, e.poi.location.lat))
}
this.mapObj.setZoom(14);
});
},
bindContextMenu(){
const self = this;
window.mapMenu = new ContextMenu(this.mapObj);//暴露mapMenu onclick要用
function ContextMenu(map) {
var me = this;
this.contextMenuPositon = null;
this.contextMenu = new AMap.ContextMenu({
isCustom: true,
content: `<div class="context_menu" >
<p onclick="mapMenu.moveCenter()"><span>设置围栏中心</span></p>
</div>`
});
map.on('rightclick', (e)=> {
if(self.mapObj.getAllOverlays('circle').length){
this.contextMenu.open(map, e.lnglat);
self.contextMenuPositon = e.lnglat; //右键菜单位置
}
});
}
ContextMenu.prototype.moveCenter = function addPOI() {
self.moveCenter()
this.contextMenu.close();
};
},
drawFence(){
if(!this.lng && !this.lat){
this.mapLoading = true;
this.getCurrentPosition().then((pos)=>{
this.lng = pos.lng;
this.lat = pos.lat;
this.radius = 1000;
this.drawFenceCircle(pos)
this.$emit('onUpdateMapData',{
lng: this.lng,
lat: this.lat,
radius: this.radius
});
this.mapLoading = false;
})
}else{
this.drawFenceCircle(mapService.getLngLat(this.lng, this.lat))
}
},
drawFenceCircle(fenceCenter){
const mapObj = this.mapObj;
if(this.fenceCircle){
this.fenceCircle.setCenter(mapService.getLngLat(this.lng, this.lat))
}else{
this.fenceCircle = new AMap.Circle({
map: mapObj,
center: fenceCenter,
radius: this.radius*1,
strokeColor: "#F33",
strokeOpacity: 1,
strokeWeight: 3,
fillColor: "ee2200",
fillOpacity: 0.35
});
mapObj.plugin(["AMap.CircleEditor"],()=>{
this.circleEditor = new AMap.CircleEditor(mapObj, this.fenceCircle);
AMap.event.addListener(this.circleEditor, 'adjust', (e)=>{
this.radius = e.radius/1;
this.$emit('onUpdateMapData',{
lng: this.lng,
lat: this.lat,
radius: this.radius
});
});
AMap.event.addListener(this.circleEditor, 'move', (e)=>{
this.lng = e.lnglat.lng;
this.lat = e.lnglat.lat;
this.$emit('onUpdateMapData',{
lng: this.lng,
lat: this.lat,
});
});
this.circleEditor.open();
});
}
mapService.setFitView()
mapObj.setZoom(14);
},
initFence(data){
this._mapPromiseTimeout && clearTimeout(this._mapPromiseTimeout)
if(this.initMapPromise){
if(data){
this.fenceType = data.fenceType
if(this.fenceType === 'circle'){
this.lng = data.lng;
this.lat = data.lat;
this.radius = data.radius;
}else if(this.fenceType === 'area'){
this.areaCode = data.areaCode
}else if(this.fenceType === 'polygon'){
if(data.polygonPath && data.polygonPath.length){
this.polygonPath = data.polygonPath
}
}
}
this.initMapPromise.then(()=>{
if(this.fenceType === 'circle'){
this.drawFence()
}else if(this.fenceType === 'area'){
this.drawArea()
}else if(this.fenceType === 'polygon'){
this.drawPolygon()
}
})
}else{
this._mapPromiseTimeout = setTimeout(() => {console.log('timeout')
this.initFence(data)
}, 100);
}
},
updateFence(data){
this.mapObj.clearMap()
this.fenceType = data.fenceType
this.polyEditor && this.polyEditor.close()
this.mouseTool && this.mouseTool.close()
if(this.fenceType === 'circle'){
this.fenceCircle = null;
if(data.lng){
this.lng = data.lng;
}
if(data.lat){
this.lat = data.lat;
}
if(data.radius){
this.radius = data.radius;
}
this.drawFence()
}else if(this.fenceType === 'area'){
if(data.areaCode){
this.areaCode = data.areaCode
}
if(this.areaCode){
this.drawArea()
}
}else if(this.fenceType === 'polygon'){
this.drawPolygon()
}
},
drawArea(){
let _this = this;
let areaCode = this.areaCode?this.areaCode.toString():'中国'
this.mapObj.clearMap()
for (var i = 0, l =this.polygons.length; i < l; i++) {
this.polygons[i].setMap(null);
}
let district,lng,lat
this.mapLoading = true;
AMap.service('AMap.DistrictSearch', function() {
var opts = {
subdistrict: 1, //返回下一级行政区
extensions: 'all',
showbiz:false //最后一级返回街道信息
};
areaCode === "中国"?delete opts.extensions :delete opts.showbiz
district = new AMap.DistrictSearch(opts);
district.setLevel('district');
district.search(areaCode, function(status, result) {
var bounds = result.districtList[0].boundaries;
lng = result.districtList[0].center.lng;
lat = result.districtList[0].center.lat;
if (bounds) {
for (var i = 0, l = bounds.length; i < l; i++) {
//生成行政区划polygon
let polygon = new AMap.Polygon({
map: _this.mapObj,
strokeWeight: 1,
path: bounds[i],
fillOpacity: 0.7,
fillColor: '#CCF3FF',
strokeColor: '#CC66CC',
});
_this.polygons.push(polygon);
}
lng = result.districtList[0].center.lng;
lat = result.districtList[0].center.lat;
let center = mapService.getLngLat(lng,lat);
mapService.setFitView();
//map.setZoom(10);
_this.mapLoading = false;
}
});
});
},
moveCenter(){
this.lng = this.contextMenuPositon.lng;
this.lat = this.contextMenuPositon.lat;
let center = mapService.getLngLat(this.lng, this.lat);
this.fenceCircle.setCenter(center);
this.$emit('onUpdateMapData', {
lng: this.lng,
lat: this.lat
})
},
getCurrentPosition(){
const mapObj = this.mapObj;
const self = this;
return new Promise((resolve, reject)=>{
mapObj.plugin('AMap.Geolocation', function(){
self.geolocation = new AMap.Geolocation();
self.geolocation.getCurrentPosition();
AMap.event.addListener(self.geolocation, 'complete', function(e){//返回定位信息
var lnglatXY = mapService.getLngLat(e.position.lng, e.position.lat);
resolve(lnglatXY)
});
AMap.event.addListener(self.geolocation, 'error', function(e){//返回定位出错信息
resolve(mapObj.getCenter())
});
});
})
},
drawPolygon(){
const mapObj = this.mapObj;
const self = this;
if(this.polygonPath.length){
self.polygon = new AMap.Polygon({
path: this.polygonPath,
strokeColor: "#FF33FF",
strokeWeight: 6,
strokeOpacity: 0.2,
fillOpacity: 0.4,
fillColor: '#1791fc',
zIndex: 50,
})
mapObj.add(self.polygon)
mapObj.setFitView([ self.polygon ])
self.polyEditor = new AMap.PolyEditor(mapObj, self.polygon)
self.polyEditor.open()
self.bindPolyEvent(self.polyEditor)
}else{
self.mouseTool = new AMap.MouseTool(mapObj)
self.mouseTool.polygon({
strokeColor: "#FF33FF",
strokeOpacity: 1,
strokeWeight: 6,
strokeOpacity: 0.2,
fillColor: '#1791fc',
fillOpacity: 0.4,
// 线样式还支持 'dashed'
strokeStyle: "solid",
// strokeStyle是dashed时有效
// strokeDasharray: [30,10],
})
self.mouseTool.on('draw', function(event) {
// event.obj 为绘制出来的覆盖物对象
self.polygon = event.obj;
self.polyEditor = new AMap.PolyEditor(mapObj, self.polygon)
self.polyEditor.open()
self.bindPolyEvent(self.polyEditor)
self.mouseTool.close()
self.emitPolyEvent()
})
}
},
emitPolyEvent(){
let pathArr = this.polygon.getPath()
let resultArr = pathArr.map((item)=>{
return [item.lng, item.lat]
})
this.polygonPath = resultArr
this.$emit('onUpdateMapData',{
polygonPath: this.polygonPath
});
console.log(resultArr.join('|'))
},
bindPolyEvent(polyEditor){
const self = this
polyEditor.on('addnode', function(event) {
console.log('触发事件:addnode')
self.emitPolyEvent()
})
self.autoCenterMarker.show();
self.mapObj.add(self.autoCenterMarker);
}
polyEditor.on('adjust', function(event) {
console.log('触发事件:adjust')
self.emitPolyEvent()
})
self.mapObj.setZoom(14);
});
});
},
bindContextMenu() {
const self = this;
var contextMenu = new AMap.ContextMenu();
contextMenu.addItem(
"设置围栏中心",
function () {
self.moveCenter();
},
0
);
//地图绑定鼠标右击事件——弹出右键菜单
self.mapObj.on("rightclick", function (e) {
console.log(e)
contextMenu.open(self.mapObj, e.lnglat);
self.contextMenuPositon = e.lnglat;
});
//contextMenu.open(self.mapObj, lnglat);
},
drawFence() {
if (!this.lng && !this.lat) {
this.mapLoading = true;
this.getCurrentPosition()
.then((pos) => {
console.log(pos);
this.lng = pos.lng;
this.lat = pos.lat;
this.radius = 1000;
this.drawFenceCircle(pos);
this.$emit("onUpdateMapData", {
lng: this.lng,
lat: this.lat,
radius: this.radius,
});
polyEditor.on('removenode', function(event) {
console.log('触发事件:removenode')
self.emitPolyEvent()
})
this.mapLoading = false;
})
.catch((error) => {
console.log(error);
});
} else {
this.drawFenceCircle(mapService.getLngLat(this.lng, this.lat));
}
},
drawFenceCircle(fenceCenter) {
const mapObj = this.mapObj;
if (this.fenceCircle) {
this.fenceCircle.setCenter(mapService.getLngLat(this.lng, this.lat));
} else {
this.fenceCircle = new AMap.Circle({
map: mapObj,
center: fenceCenter,
radius: this.radius * 1,
strokeColor: "#F33",
strokeOpacity: 1,
strokeWeight: 3,
fillColor: "ee2200",
fillOpacity: 0.35,
});
mapObj.plugin(["AMap.CircleEditor"], () => {
this.circleEditor = new AMap.CircleEditor(mapObj, this.fenceCircle);
AMap.event.addListener(this.circleEditor, "adjust", (e) => {
this.radius = e.radius / 1;
this.$emit("onUpdateMapData", {
lng: this.lng,
lat: this.lat,
radius: this.radius,
});
});
AMap.event.addListener(this.circleEditor, "move", (e) => {
this.lng = e.lnglat.lng;
this.lat = e.lnglat.lat;
this.$emit("onUpdateMapData", {
lng: this.lng,
lat: this.lat,
});
});
this.circleEditor.open();
});
}
polyEditor.on('end', function(event) {
console.log('触发事件: end')
self.emitPolyEvent()
// event.target 即为编辑后的多边形对象
})
},
transfer(){
this.transferTimeoutId && window.clearTimeout(this.transferTimeoutId);
this.transferTimeoutId = window.setTimeout(()=>{
const flag = new Date();
this.transferFlag = flag;
if(!this.geocoder){
mapService.getGeocoder().then((gc)=>{
this.geocoder = gc;
this.getAddress(flag);
});
}else{
this.getAddress(flag);
}
}, 500)
},
getAddress(flag){
const lnglatXY = [this.form.lng, this.form.lat];
this.transferAddr = '';
this.geocoder.getAddress(lnglatXY, (status, result)=>{
if(flag == this.transferFlag){
if (status === 'complete' && result.info === 'OK') {//获取地址成功
this.form.transferAddr = result.regeocode.formattedAddress;
this.$emit('onUpdateMapData',{
lng: this.form.lng,
lat: this.form.lat,
address: this.form.transferAddr,
radius: this.form.radius
});
}else{
this.form.transferAddr = '';
}
}
mapService.setFitView();
mapObj.setZoom(14);
},
initFence(data) {
this._mapPromiseTimeout && clearTimeout(this._mapPromiseTimeout);
if (this.initMapPromise) {
if (data) {
this.fenceType = data.fenceType;
if (this.fenceType === "circle") {
this.lng = data.lng;
this.lat = data.lat;
this.radius = data.radius;
} else if (this.fenceType === "area") {
this.areaCode = data.areaCode;
} else if (this.fenceType === "polygon") {
if (data.polygonPath && data.polygonPath.length) {
this.polygonPath = data.polygonPath;
}
}
}
this.initMapPromise.then(() => {
if (this.fenceType === "circle") {
this.drawFence();
} else if (this.fenceType === "area") {
this.drawArea();
} else if (this.fenceType === "polygon") {
this.drawPolygon();
}
});
} else {
this._mapPromiseTimeout = setTimeout(() => {
console.log("timeout");
this.initFence(data);
}, 100);
}
},
updateFence(data) {
let _this = this;
let mapInterval = setInterval(function () {
if (_this.mapObj) {
clearInterval(mapInterval);
_this.mapObj.clearMap();
_this.fenceType = data.fenceType;
_this.polyEditor && _this.polyEditor.close();
_this.mouseTool && _this.mouseTool.close();
if (_this.fenceType === "circle") {
_this.fenceCircle = null;
if (data.lng) {
_this.lng = data.lng;
}
if (data.lat) {
_this.lat = data.lat;
}
if (data.radius) {
_this.radius = data.radius;
}
_this.drawFence();
} else if (_this.fenceType === "area") {
if (data.areaCode) {
_this.areaCode = data.areaCode;
}
if (_this.areaCode) {
_this.drawArea();
}
} else if (_this.fenceType === "polygon") {
_this.drawPolygon();
}
}
}, 100);
},
drawArea() {
let _this = this;
let areaCode = this.areaCode ? this.areaCode.toString() : "中国";
this.mapObj.clearMap();
for (var i = 0, l = this.polygons.length; i < l; i++) {
this.polygons[i].setMap(null);
}
let district, lng, lat;
this.mapLoading = true;
AMap.service("AMap.DistrictSearch", function () {
var opts = {
subdistrict: 1, //返回下一级行政区
extensions: "all",
showbiz: false, //最后一级返回街道信息
};
areaCode === "中国" ? delete opts.extensions : delete opts.showbiz;
district = new AMap.DistrictSearch(opts);
district.setLevel("district");
district.search(areaCode, function (status, result) {
var bounds = result.districtList[0].boundaries;
lng = result.districtList[0].center.lng;
lat = result.districtList[0].center.lat;
if (bounds) {
for (var i = 0, l = bounds.length; i < l; i++) {
//生成行政区划polygon
let polygon = new AMap.Polygon({
map: _this.mapObj,
strokeWeight: 1,
path: bounds[i],
fillOpacity: 0.7,
fillColor: "#CCF3FF",
strokeColor: "#CC66CC",
});
_this.polygons.push(polygon);
}
lng = result.districtList[0].center.lng;
lat = result.districtList[0].center.lat;
let center = mapService.getLngLat(lng, lat);
mapService.setFitView();
//map.setZoom(10);
_this.mapLoading = false;
}
});
});
},
moveCenter() {
this.lng = this.contextMenuPositon.lng;
this.lat = this.contextMenuPositon.lat;
let center = mapService.getLngLat(this.lng, this.lat);
this.fenceCircle.setCenter(center);
this.$emit("onUpdateMapData", {
lng: this.lng,
lat: this.lat,
});
},
getCurrentPosition() {
const mapObj = this.mapObj;
const self = this;
return new Promise((resolve, reject) => {
mapObj.plugin("AMap.Geolocation", function () {
self.geolocation = new AMap.Geolocation();
self.geolocation.getCurrentPosition();
AMap.event.addListener(self.geolocation, "complete", function (e) {
console.log("complete", e);
//返回定位信息
var lnglatXY = mapService.getLngLat(e.position.lng, e.position.lat);
resolve(lnglatXY);
});
AMap.event.addListener(self.geolocation, "error", function (e) {
console.log("error", e);
//返回定位出错信息
resolve(mapObj.getCenter());
});
});
});
},
drawPolygon() {
const mapObj = this.mapObj;
const self = this;
if (this.polygonPath.length) {
self.polygon = new AMap.Polygon({
path: this.polygonPath,
strokeColor: "#FF33FF",
strokeWeight: 6,
strokeOpacity: 0.2,
fillOpacity: 0.4,
fillColor: "#1791fc",
zIndex: 50,
});
mapObj.add(self.polygon);
mapObj.setFitView([self.polygon]);
self.polyEditor = new AMap.PolyEditor(mapObj, self.polygon);
self.polyEditor.open();
self.bindPolyEvent(self.polyEditor);
} else {
self.mouseTool = new AMap.MouseTool(mapObj);
self.mouseTool.polygon({
strokeColor: "#FF33FF",
strokeOpacity: 1,
strokeWeight: 6,
strokeOpacity: 0.2,
fillColor: "#1791fc",
fillOpacity: 0.4,
// 线样式还支持 'dashed'
strokeStyle: "solid",
// strokeStyle是dashed时有效
// strokeDasharray: [30,10],
});
self.mouseTool.on("draw", function (event) {
// event.obj 为绘制出来的覆盖物对象
self.polygon = event.obj;
self.polyEditor = new AMap.PolyEditor(mapObj, self.polygon);
self.polyEditor.open();
self.bindPolyEvent(self.polyEditor);
self.mouseTool.close();
self.emitPolyEvent();
});
}
},
emitPolyEvent() {
let pathArr = this.polygon.getPath();
let resultArr = pathArr.map((item) => {
return [item.lng, item.lat];
});
this.polygonPath = resultArr;
this.$emit("onUpdateMapData", {
polygonPath: this.polygonPath,
});
console.log(resultArr.join("|"));
},
bindPolyEvent(polyEditor) {
const self = this;
polyEditor.on("addnode", function (event) {
console.log("触发事件:addnode");
self.emitPolyEvent();
});
polyEditor.on("adjust", function (event) {
console.log("触发事件:adjust");
self.emitPolyEvent();
});
polyEditor.on("removenode", function (event) {
console.log("触发事件:removenode");
self.emitPolyEvent();
});
polyEditor.on("end", function (event) {
console.log("触发事件: end");
self.emitPolyEvent();
// event.target 即为编辑后的多边形对象
});
},
transfer() {
this.transferTimeoutId && window.clearTimeout(this.transferTimeoutId);
this.transferTimeoutId = window.setTimeout(() => {
const flag = new Date();
this.transferFlag = flag;
if (!this.geocoder) {
mapService.getGeocoder().then((gc) => {
this.geocoder = gc;
this.getAddress(flag);
});
} else {
this.getAddress(flag);
}
}, 500);
},
getAddress(flag) {
const lnglatXY = [this.form.lng, this.form.lat];
this.transferAddr = "";
this.geocoder.getAddress(lnglatXY, (status, result) => {
if (flag == this.transferFlag) {
if (status === "complete" && result.info === "OK") {
//获取地址成功
this.form.transferAddr = result.regeocode.formattedAddress;
this.$emit("onUpdateMapData", {
lng: this.form.lng,
lat: this.form.lat,
address: this.form.transferAddr,
radius: this.form.radius,
});
},
} else {
this.form.transferAddr = "";
}
}
});
},
components:{
FenceMapControll
}
}
},
components: {
FenceMapControll,
},
};
</script>
<style scoped>
.fence-map{
position: relative;
}
.fence-map .map-container{
width: 100%;
height: 500px;
}
.fence-map .map-seacrh-wrap{
position: absolute;
top: 40px;
left: 10px;
z-index: 1000;
}
.el-form-item{
margin: -20px 0 20px 10px;
}
.fence-map {
position: relative;
}
.fence-map .map-container {
width: 100%;
height: 500px;
}
.fence-map .map-seacrh-wrap {
position: absolute;
top: 40px;
left: 10px;
z-index: 1000;
}
.el-form-item {
margin: -20px 0 20px 10px;
}
</style>
<style lang="scss">
.context_menu{
min-width: 10em;
background-color: #fff;
padding: 10px;
border: 1px solid #efefef;
border-radius: 2px;
cursor: pointer;
&>p{
margin: 0;
i{
font-size: 18px;
color: #094;
margin-right: 5px;
}
i,span{
vertical-align: middle;
}
}
}
.context_menu {
min-width: 10em;
background-color: #fff;
padding: 10px;
border: 1px solid #efefef;
border-radius: 2px;
cursor: pointer;
& > p {
margin: 0;
i {
font-size: 18px;
color: #094;
margin-right: 5px;
}
i,
span {
vertical-align: middle;
}
}
}
</style>
\ No newline at end of file
<template>
<!-- 关联用户弹框 -->
<el-dialog id="userListModal" :visible="userListModalVisible" @open="openDialog" @close="closeDialog" append-to-body width="1040px" top="8vh">
<div class="dialog-header" slot="title">
<h2 class="header-title">关联用户</h2>
</div>
<!-- 搜索区域 开始 -->
<el-form :model="form" :inline="true" size="mini" class="search_form">
<el-form-item label="用户查询" class="pull-left">
<el-input placeholder="请输入对应条件值" v-model="form.term" size="small" class="input-with-select" style="width:340px" maxlength="50" clearable>
<el-select v-model="form.termType" slot="prepend" style="width:100px;" placeholder="请选择" size="small">
<el-option label="设备号" value="1"></el-option>
<el-option label="车架号" value="2"></el-option>
<el-option label="姓名" value="3"></el-option>
<el-option label="工单号" value="4"></el-option>
</el-select>
</el-input>
</el-form-item>
<el-form-item>
<el-button type="primary" size="small" @click="search">查询</el-button>
</el-form-item>
<el-form-item>
<el-button type="primary" size="small" @click="restParams">重置</el-button>
</el-form-item>
<el-form-item>
<el-button type="primary" size="small" @click="showHighSearch">高级搜索</el-button>
</el-form-item>
<div v-show="highSearchVisible">
<el-form-item>
<div class="pre_select_box">
<el-select v-model="form.timeType" class="small_select mr5" placeholder="请选择">
<el-option label="激活时间" value="1"></el-option>
</el-select>
<el-date-picker v-model="form.timeDate" class="data_picker" value-format="yyyy-MM-dd" type="daterange" range-separator="~" start-placeholder="开始日期" end-placeholder="结束日期">
</el-date-picker>
</div>
</el-form-item>
<el-form-item label="车辆归属">
<el-popover v-model="showGlsxOranization" placement="bottom-start" width="400" trigger="click">
<div>
<glsx-organization @change="onChange"></glsx-organization>
</div>
<el-input v-model="form.orgName" placeholder="所属组织" slot="reference" readonly :clearable="true">
</el-input>
</el-popover>
</el-form-item>
</div>
</el-form>
<!-- 搜索区域 end -->
<el-row>
<el-col :span="12" class="choose-list-wrap">
<p class="right_title">结果列表</p>
<ul class="choose-list">
<li v-for="item in resultList" :key="item.vin">
<el-checkbox v-model="item.checked" @change="checkedChange(item)" class="choose-list-checkbox">
<div class="choose-list-content">
<p>{{item.name}}/{{item.vin}}</p>
<p class="choose-list-group">
<el-tag type="info" size="small" v-for="snItem in item.sns" :key="snItem">{{snItem}}</el-tag>
</p>
</div>
</el-checkbox>
</li>
<infinite-loading v-if="needInfinite" @infinite="infiniteHandler" ref="infiniteLoading">
<span slot="no-more">没有更多数据了</span>
<span slot="no-results">无结果</span>
</infinite-loading>
</ul>
<el-checkbox v-model="checkedAll">全选</el-checkbox>
<span class="pull-right">列表记录总数 {{total}} 条</span>
</el-col>
<el-col :span="12" class="choose-list-wrap">
<p class="right_title">
<span>已选列表</span>
<!-- <el-button type="primary" plain size="small" @click="groupImport">批量导入</el-button> -->
</p>
<ul class="choose-list">
<!-- <li v-for="item in chosenList" :key="item.vin">
<el-checkbox v-model="item.checked" @change="checkedChange(item)" class="choose-list-checkbox">
<div class="choose-list-content">
<p>{{item.name}}/{{item.vin}}</p>
<p class="choose-list-group">
<el-tag type="info" size="small" v-for="snItem in item.sns" :key="snItem">{{snItem}}</el-tag>
</p>
</div>
</el-checkbox>
</li> -->
<vxe-list height="340" class="my-list" :loading="loading1" :data="chosenList">
<template #default="{ items }">
<div class="my-list-item" v-for="(item, index) in items" :key="index">{{ item.label }}</div>
<li v-for="(item,index) in items" :key="index">
<el-checkbox v-model="item.checked" @change="checkedChange(item)" class="choose-list-checkbox">
<div class="choose-list-content">
<p>{{item.name}}/{{item.vin}}</p>
<p class="choose-list-group">
<el-tag type="info" size="small" v-for="snItem in item.sns" :key="snItem">{{snItem}}</el-tag>
</p>
</div>
</el-checkbox>
</li>
</template>
</vxe-list>
</ul>
<el-checkbox v-model="checkedCancel">取消</el-checkbox>
<span class="pull-right">列表记录总数 {{chosenList.length}} 条</span>
</el-col>
</el-row>
<div slot="footer" class="dialog-footer">
<el-button type="primary" @click="sure" size="small">确认</el-button>
<el-button @click="$emit('onUserListModalChange', false)" size="small">取消</el-button>
</div>
<!-- 批量导入弹框 -->
<!-- <user-list-import @exportDate="exportDate" v-if="userImportModalVisible" :userImportModalVisible="userImportModalVisible" @onUserImportModalChange="userImportModalChange" @onRefreshList="getData"></user-list-import> -->
<!-- 批量导入弹框 /-->
</el-dialog>
<!-- 关联用户弹框 /-->
</template>
<script>
import vVechicleSelect from "components/VechicleSelect.vue";
import userListImport from "./userListImport.vue";
import InfiniteLoading from "vue-infinite-loading";
import GlsxOrganization from "@/components/glsx-organization";
import { GET_ELECFENCE_LINKSNS } from "@/api/services/fence";
import { deepClone } from "@/utils/utils";
export default {
name: "UserList",
props: ["userListModalVisible", "userData", "init", "shopId"],
components: {
vVechicleSelect,
InfiniteLoading,
userListImport,
GlsxOrganization,
},
data() {
return {
form: {
termType: "1",
timeType: "1",
},
dateType: "1",
resultcheck: false,
resultItem: "",
highSearchVisible: false,
userImportModalVisible: false,
pageNumber: 1,
pageSize: 50,
total: 0,
maxPage: 1,
resultList: [],
chosenTotal: 0,
chosenList: [],
needInfinite: false,
checkedAll: false,
checkedCancel: false,
params: {},
showGlsxOranization: false,
orgInfo: {},
};
},
mounted() {
console.log(this.userData);
this.search();
},
watch: {
checkedCancel(newVal) {
if (newVal) {
this.chosenList.forEach((item) => {
item.checked = false;
item.sns = (item.sn && item.sn.split(",")) || [];
});
this.chosenList = [];
this.checkedAll = false;
}
},
init(newVal) {
if (newVal) {
this.reset();
this.$emit("onUserListInit", false);
}
},
checkedAll(newVal) {
if (newVal) {
this.resultList.forEach((item) => {
item.checked = true;
const findItem = this.chosenList.find((o) => o.vin === item.vin);
if (!findItem) {
this.chosenList.push(item);
}
});
this.checkedCancel = false;
} else {
this.resultList.forEach((item) => {
item.checked = false;
const findItem = this.chosenList.find((o) => o.vin === item.vin);
if (findItem) {
this.chosenList.splice(this.chosenList.indexOf(findItem), 1);
}
});
}
},
userData: {
handler: function (n, o) {
this.reset(n);
},
immediate: true,
},
},
methods: {
reset(date) {
this.userData = date;
this.checkedAll = false;
let arr = [];
this.userData.forEach((o) => {
o.checked = true;
o.sns = (o.sn && o.sn.split(",")) || [];
arr.push(o);
});
this.chosenList = arr;
},
// 保存数据
sure() {
const userdata = [];
this.chosenList.forEach((obj) => {
if (obj.sns && obj.sns.length > 0) {
obj.sns.forEach((snsItem) => {
userdata.push({
sn: snsItem,
name: obj.name,
vin: obj.vin,
userTel: obj.userTel,
address: obj.address,
time: obj.time,
});
});
} else {
userdata.push({
sn: obj.sns,
name: obj.name,
vin: obj.vin,
userTel: obj.userTel,
address: obj.address,
time: obj.time,
});
}
});
this.$emit("onUpdateUserData", userdata);
this.$emit("onUserListModalChange", false);
},
// 获取列表
search() {
this.resultList = [];
//this.chosenList = [];
this.pageNumber = 1;
this.needInfinite = false;
this.$nextTick(() => {
this.$refs.infiniteLoading &&
this.$refs.infiniteLoading.$emit("$InfiniteLoading:reset");
});
this.needInfinite = true;
},
checkedChange(item) {
if (item.checked) {
this.resultcheck = item.checked;
this.resultItem = item;
const findItem = this.chosenList.find((o) => o.sns === item.sns);
if (findItem) return;
this.chosenList.push(item);
this.checkedCancel = false;
} else {
this.chosenList.splice(this.chosenList.indexOf(item), 1);
}
},
exportDate(returnDate) {
var obj = {};
returnDate.map((obj) => {
if (obj.userTel) {
obj.sns = obj.sn.split(",");
} else {
obj.sns = [];
}
obj.checked = true;
});
console.log(returnDate);
for (var key in returnDate) {
returnDate;
obj = returnDate[key];
this.chosenList.push(obj);
this.resultcheck = true;
}
console.log(this.chosenList);
console.log(obj);
},
// 获取参数
getParams() {
let o = deepClone(this.form);
let oParams = {};
if (o.term) {
oParams.term = o.term.trim();
}
oParams.termType = o.termType;
oParams.orgType = o.orgType;
oParams.orgId = o.orgId;
if (o.timeDate && o.timeDate.length > 0) {
oParams.startTime = o.timeDate[0];
oParams.endTime = o.timeDate[1];
}
return oParams;
},
infiniteHandler($state) {
if (this.pageNumber > this.maxPage) {
$state.complete();
return;
}
let oParams = this.getParams();
oParams.pageNumber = this.pageNumber;
oParams.pageSize = this.pageSize;
GET_ELECFENCE_LINKSNS(oParams).then((res) => {
const { code, data, message } = res;
if (code == 200) {
const { list } = data;
if (list && list.length > 0) {
list.map((obj) => {
if (obj.sns) {
obj.sns = obj.sns.split(",");
} else {
obj.sns = [];
}
});
this.resultList = this.resultList.concat(list);
this.total = data.totalElements;
this.maxPage = data.totalPages;
this.pageNumber++;
$state.loaded();
} else {
$state.complete();
}
} else {
$state.complete();
}
});
},
// 打开批量导入
groupImport() {
this.userImportModalVisible = true;
},
// 关闭批量导入弹框
userImportModalChange() {
this.userImportModalVisible = false;
},
openDialog() {},
closeDialog() {
this.$emit("onUserListModalChange", false);
},
// 监听树
onChange(e) {
this.showGlsxOranization = false;
console.log(e);
if (e) {
this.orgInfo = e.origin;
this.form.orgId = e.origin.orgId;
this.form.orgType = e.origin.type;
this.form.orgName = e.origin.orgName;
}
},
// 打开高级搜索
showHighSearch() {
this.highSearchVisible = !this.highSearchVisible;
},
// 重置搜索条件
restParams() {
this.form = { termType: "1", timeType: "1" };
this.search();
},
},
};
</script>
<style lang="scss" scoped>
h3 {
margin: 10px 0px;
}
p {
margin: 0px;
}
form.main-form {
height: 540px;
overflow: auto;
margin: -30px -20px;
padding: 20px;
}
form.detail-search-form {
padding: 20px 0px;
}
.popover-footer {
border-top: 1px solid #eee;
overflow: auto;
margin: -12px;
padding: 10px;
}
.popover-footer .el-button.pull-right {
margin-left: 10px;
}
.tab-content {
margin-top: 20px;
}
.tag-list {
width: 100%;
max-height: 90px;
overflow: auto;
margin: -10px 0px 0px -10px;
}
.tag-list .el-tag {
margin-left: 10px;
/* margin-top: 10px; */
}
.choose-list-wrap {
padding: 10px;
}
ul.choose-list {
height: 340px;
overflow: auto;
margin-bottom: 5px;
border: 1px solid #eee;
padding: 10px;
border-radius: 4px;
}
.choose-list-checkbox {
line-height: 30px;
margin: 0 5px;
}
.choose-list-content {
display: inline-block;
vertical-align: middle;
}
.choose-list-content p {
line-height: 30px;
}
.choose-list-group {
font-size: 0px;
}
.choose-list-content .el-tag {
font-size: 12px;
margin-right: 4px;
}
.right_title {
display: flex;
justify-content: space-between;
align-items: center;
height: 32px;
padding: 4px 0;
}
.pre_select_box {
display: flex;
align-items: center;
.small_select {
width: 120px;
}
.data_picker {
width: 240px;
}
.mr5 {
margin-right: 5px;
}
}
</style>
\ No newline at end of file
......@@ -66,7 +66,7 @@
<el-option label="工单号" value="4"></el-option>
</el-select>
</el-input>
<div slot="tip" class="el-upload__tip">仅支持同时监控100台设备,还可导入{{100-monitorList.count}}台设备</div>
<div slot="tip" class="el-upload__tip">仅支持同时监控100台设备,还可导入{{100-monitorList.itemArr.length}}台设备</div>
</el-upload>
</el-form-item>
<el-button type="primary" class="upload-sure-btn" size="small" @click="submitUpload" :loading="importing" :disabled="uploadDisabled">确认</el-button>
......@@ -77,7 +77,7 @@
<div class="filter-dialog animated " :class="listDialogHidden?'fadeOut':'active fadeIn'">
<div class="filter-dialog-header monitor_dialog_header">
<span>监控列表({{monitorList.count}})</span>
<span>监控列表({{monitorList.itemArr.length}})</span>
<i class="el-icon-close pull-right" @click.stop="listDialogHidden=true"></i>
</div>
<div class="filter-dialog-body">
......@@ -147,7 +147,20 @@
</div>
<div class="filter-dialog-body">
<div class="monitor-list">
<el-tree ref="tree" :key="treeKey" :data="treeData" :props="treeProps" lazy :load="loadNode" show-checkbox node-key="id" :render-content="renderTreeContent" :default-expanded-keys="expandedKeys" :default-checked-keys="checkedKeys" @check="handleCheck" v-loading="treeLoading" @check-change="handleCheckChange">
<el-tree ref="tree" :key="treeKey" :data="treeData" :props="treeProps" lazy :load="loadNode" show-checkbox node-key="id" :default-expanded-keys="expandedKeys" :default-checked-keys="checkedKeys" @check="handleCheck" v-loading="treeLoading" @check-change="handleCheckChange">
<span class="custom-tree-node" slot-scope="{ node,data }">
<div v-if="node.data.leaf">
<div>姓名:{{node.data.label1 || "--"}}</div>
<div>设备号:{{node.data.label||'--'}}</div>
<div>车架号:{{node.data.label2}}</div>
<div class="load_more_link" v-if="data.showMore" v-loading="loadingMore" @click="loadNext(node, data)">
查看更多
</div>
</div>
<span v-else>
{{node.data.label}}
</span>
</span>
</el-tree>
</div>
......@@ -167,12 +180,12 @@ import mapService from "@/utils/mapService.js";
import "@/utils/mapEvent.js";
import EventBus from "@/event-bus";
import { services } from "@/api";
import mock from "../../mock";
const MONITOR_SERVICE = services.monitor;
import { CONSTANT } from "@/constant";
import MapControll from "./MapControll.vue";
import { exportExcel } from "@/utils";
import { GET_MONITOR_ONLINELIST } from "@/api/services/monitor";
export default {
data() {
let checkFilename = (rule, vaule, cb) => {
......@@ -231,6 +244,10 @@ export default {
treeLoading: true,
currentMessage: "", //当前是否有提示语弹框
treeKey: "",
treeDataList: {}, // 缓存车辆
pageSizeList: {},
pageSize: 10,
loadingMore: false,
};
},
computed: {
......@@ -340,23 +357,28 @@ export default {
} else {
this.removeMonitor(item);
}
} else {
if (this.isTreeChecked) {
this.$confirm(
"当所选分组包含车辆过多时,请尝试分多次查询,以防等待时间过久。",
"提示",
{
confirmButtonText: "确定",
cancelButtonText: "取消",
type: "warning",
}
).then(() => {
return false;
}
if (this.isTreeChecked) {
this.$confirm(
"当所选分组包含车辆过多时,请尝试分多次查询,以防等待时间过久。",
"提示",
{
confirmButtonText: "确定",
cancelButtonText: "取消",
type: "warning",
}
)
.then(() => {
this.checkFlow(data, node);
})
.catch(() => {
// 取消
this.$refs.tree.setChecked(data, false);
});
} else {
this.checkFlow(data, node);
}
return false;
}
this.checkFlow(data, node);
},
checkFlow(data, node) {
......@@ -491,6 +513,8 @@ export default {
},
loadNode(node, resolve) {
console.log(node);
let _this = this;
let id = node.data.id;
const nodeData = node.data;
const origin = nodeData.origin;
if (nodeData.children) {
......@@ -505,22 +529,27 @@ export default {
oParams.termType = this.searchType;
oParams.term = this.searchText;
}
oParams.pageSize = _this.pageSize;
oParams.pageNumber = _this.pageSizeList[id] || 1;
MONITOR_SERVICE.getVehicleTreeUserList(oParams).then(({ data }) => {
if (data.length) {
data.map((item) => {
item.leaf = true;
item.showMore = false;
});
data[data.length - 1].showMore = true;
_this.treeDataList[id] = data;
_this.pageSizeList[id] = oParams.pageNumber;
return resolve(data);
}
return resolve([]);
});
return;
}
}
}
return resolve(nodeData);
let isArray = Array.isArray(nodeData);
return resolve(isArray ? nodeData : []);
if (node.level === 0) {
return resolve([{ name: "region1" }, { name: "region2" }]);
......@@ -589,10 +618,11 @@ export default {
returnTrees: true,
}).then((res) => {
const items = res.data;
this.autoOpenLastInfoWindow = true;
this.expandTreeItems(items);
});
this.treeHidden = true;
this.treeHidden = false;
this.listDialogHidden = true;
}
} else {
this.checkLoadedTimeoutId = check();
......@@ -819,32 +849,36 @@ export default {
// 添加监控
addMonitor(item) {
let _this = this;
if (this.monitorList.count === 100) {
let obj = this.monitorList;
if (obj.count === 100) {
this.$message({
type: "error",
message: "监控设备数最大100台,无法添加",
});
} else {
if (this.monitorList[item.sn]) {
if (!_this.currentMessage) {
_this.currentMessage = this.$message({
type: "error",
message: "该列表中有设备正在监控中,请勿重复监控",
onClose: function () {
_this.currentMessage = "";
},
});
}
} else {
this.resetRefreshCount = true;
this.monitorList.count++;
item.eLocateType = "gpsLocation";
this.monitorList[item.sn] = item;
this.monitorList.itemArr.unshift(item.sn);
console.log(this.monitorList.itemArr);
this.getPositionData();
}
return false;
}
if (obj[item.sn] && !_this.currentMessage) {
_this.currentMessage = this.$message({
type: "error",
message: "该列表中有设备正在监控中,请勿重复监控",
onClose: function () {
_this.currentMessage = "";
},
});
return false;
}
this.resetRefreshCount = true;
item.eLocateType = "gpsLocation";
// 去重
if (!obj[item.sn]) {
obj[item.sn] = item;
obj.count++;
obj.itemArr.unshift(item.sn);
}
console.log(obj.itemArr);
this.getPositionData();
},
// standNoMonitor(item){
// this.resetRefreshCount = true;
......@@ -904,7 +938,7 @@ export default {
if (obj[item.sn]) {
delete obj[item.sn];
}
console.log(list);
this.monitorList.itemArr = list.filter((k) => k != item.sn);
//this.monitorList.itemArr.splice(this.monitorList.itemArr.indexOf(item.sn||item), 1)
this.monitorList = Object.assign({}, obj);
......@@ -931,8 +965,10 @@ export default {
let _this = this;
console.log(arr);
let o = this.monitorList;
o.itemArr = [];
arr.forEach((item) => {
let n = o[item.sn || item];
console.log(n);
if (n) {
_this.removeMonitor(n);
}
......@@ -943,6 +979,8 @@ export default {
_this.checkedKeys = [];
this.$refs.tree.setCheckedKeys([]);
},
// 获取设备位置点
getPositionData(arr) {
/* let _this = this;
arr = arr.filter((item)=>this.monitorList[item.sn]); */
......@@ -967,7 +1005,7 @@ export default {
data.forEach((item) => {
let relItem = this.monitorList[item.sn];
if (relItem) {
relItem.isOnLine = item.status === 2 ? false : true;
relItem.online = item.status === 2 ? false : true;
relItem.isHasPosition = true;
item.name = relItem.name;
item.standNo = relItem.standNo;
......@@ -1096,6 +1134,81 @@ export default {
this.expandedKeys = [];
this.checkedKeys = [];
},
// 展示更多
showMore(node, data) {
let o = this.treeDataList["u" + data.parentId];
console.log(node);
console.log(o);
// 不存在
if (!o || o.length <= 0) {
return false;
}
// 判断是否有下一页
let idx = o.findIndex((k) => k.id == node.data.id);
if (idx == o.length - 1) {
return true;
} else {
return false;
}
},
// 加载下一页
loadNext(node, data) {
console.log(node);
console.log(data);
let _this = this;
let id = "u" + node.data.parentId;
let pageNumber = this.pageSizeList[id];
let oParams = {};
oParams.uId = id;
oParams.termType = this.searchType;
oParams.term = this.searchText;
oParams.pageSize = this.pageSize;
oParams.pageNumber = pageNumber + 1;
data.showMore = false;
_this.loadingMore = true;
MONITOR_SERVICE.getVehicleTreeUserList(oParams)
.then((res) => {
_this.loadingMore = false;
let list = res.data || [];
if (list.length) {
list.map((item) => {
item.leaf = true;
item.showMore = false;
});
list[list.length - 1].showMore = true;
_this.pageSizeList[id] = oParams.pageNumber;
let treeDataList = _this.treeDataList[id];
if (treeDataList) {
treeDataList = treeDataList.concat(list);
_this.treeDataList[id] = treeDataList;
} else {
_this.treeDataList[id] = list;
}
list.map((k) => {
_this.$refs.tree.append(k, id);
_this.showMore(node, k);
});
}
})
.catch(() => {
_this.loadingMore = false;
});
},
// 获取设备在线状态
getDevinceStatus(sns) {
let obj = this.monitorList;
let list = obj.itemArr || [];
let oParams = {};
oParams.sns = sns;
GET_MONITOR_ONLINELIST(oParams).then((res) => {});
},
},
created() {
if (window.AMap) {
......@@ -1117,6 +1230,7 @@ export default {
this.getTreeData();
},
beforeDestroy() {
document.onkeydown = null;
EventBus.$emit("uiMap.monitor.destroy");
EventBus.$off("uiMap.monitor.drawDone", this.drawDoneCb);
this._drawTimeoutId && window.clearTimeout(this._drawTimeoutId);
......@@ -1184,4 +1298,7 @@ export default {
.monitor_dialog_header .i_refresh {
cursor: pointer;
}
.load_more_link {
color: #409eff;
}
</style>
\ No newline at end of file
......@@ -10,7 +10,7 @@
<div class="controll-wrap">
<div class="search-box" :class="resultBoxHidden?'active':''">
<h3>轨迹回放</h3>
<p class="info">{{name}}/{{standno}}/{{sn}}</p>
<p class="info">{{name||'--'}}/{{standno||'--'}}/{{sn||'--'}}</p>
<el-form ref="form" :model="form" :rules="rules" :inline="false" size="mini" class="form">
<el-form-item label="查询范围" prop="daterange">
<el-date-picker class="pull-left" style="width: 100%;" v-model="form.dateRange" type="datetimerange" range-separator="至" start-placeholder="开始日期" format="yyyy-MM-dd HH:mm" :clearable="false" :editable="false" :picker-options="{
......@@ -98,6 +98,7 @@ import { exportExcel } from "utils";
import { CONSTANT } from "../../constant";
import InfiniteLoading from "vue-infinite-loading";
import MapControll from "./MapControll.vue";
import { GET_ELECFENCE_INFO } from "@/api/services/fence";
export default {
data() {
......@@ -239,8 +240,12 @@ export default {
//this.bindEvent();
_this.isInitMap = true;
//_this.drawPoi();
console.log(_this.fenceId != 'undefined')
if (_this.isInitFence && _this.fenceId && _this.fenceId != 'undefined') {
console.log(_this.fenceId != "undefined");
if (
_this.isInitFence &&
_this.fenceId &&
_this.fenceId != "undefined"
) {
//_this.drawFence();
_this.getFence();
}
......@@ -483,8 +488,8 @@ export default {
if (data.length) {
data.forEach((item, idx) => {
item.idx = idx;
item.standno = _this.standno
item.name = _this.name
item.standno = _this.standno;
item.name = _this.name;
});
this.resultList = data;
}
......@@ -603,6 +608,8 @@ export default {
}
});
},
// 行政区域围栏
drawDistrict(areaCode) {
this._drawDistrictTimeoutId && clearTimeout(this._drawDistrictTimeoutId);
......@@ -610,6 +617,8 @@ export default {
EventBus.$emit("uiMap.fence.drawDistrict", areaCode);
}, 500);
},
// 多边形围栏
drawPolygon(path) {
console.log("path");
EventBus.$emit("uiMap.fence.drawPolygon", {
......@@ -620,56 +629,38 @@ export default {
// 获取围栏信息-并画围栏
getFence() {
MONITOR_SERVICE.getFenceInfo({
sn: this.sn,
GET_ELECFENCE_INFO({
//sn: this.sn,
fenceId: this.fenceId,
}).then((res) => {
console.log(res);
let list = res.data || [];
if (res.code != 200) {
return false;
// const data = res.data || [];
// if (data) {
// if (data.shapeType === 2) {
// EventBus.$emit("uiMap.fence.createFenceCircle", {
// lng: data.lng,
// lat: data.lat,
// radius: data.radius,
// isEdit: false,
// });
// } else if (data.shapeType === 3) {
// this.drawDistrict(data.areaCode);
// } else if (data.shapeType === 5) {
// if (data.lnglat) {
// let polygonPath = data.lnglat.split("|").map((item) => {
// return [item.split(",")[0], item.split(",")[1]];
// });
// this.drawPolygon(polygonPath);
// }
// }
// }
}
let obj = res.data || {};
// 圆形围栏
if (obj.shapeType == 1) {
EventBus.$emit("uiMap.fence.createFenceCircle", {
lng: obj.lnglat.split(",")[0],
lat: obj.lnglat.split(",")[1],
radius: obj.radius,
isEdit: false,
});
}
// 循环画围栏
list.map((k) => {
// 圆形围栏
if (k.shapeType == 1) {
EventBus.$emit("uiMap.fence.createFenceCircle", {
lng: k.lnglat.split(",")[0],
lat: k.lnglat.split(",")[1],
radius: k.radius,
isEdit: false,
});
}
// 多边形围栏
if (obj.shapeType == 3) {
let polygonPath = obj.lnglat.split("|").map((item) => {
return [item.split(",")[0], item.split(",")[1]];
});
this.drawPolygon(polygonPath);
}
// 多边形围栏
if (k.shapeType == 3) {
let polygonPath = k.lnglat.split("|").map((item) => {
return [item.split(",")[0], item.split(",")[1]];
});
this.drawPolygon(polygonPath);
}
});
// 行政区域围栏
if (obj.shapeType == 4) {
this.drawDistrict([obj.areaCode]);
}
});
},
},
......
<template>
<!-- 批量导入弹框 -->
<el-dialog class="import-dialog" title="批量导入" :visible="userImportModalVisible" @open="openDialog" @close="closeDialog" append-to-body width="600px" :close-on-click-modal="false">
<!-- 批量导入弹框 -->
<el-dialog class="import-dialog" title="批量导入" :visible="userImportModalVisible" @open="openDialog" @close="closeDialog" append-to-body width="600px" :close-on-click-modal="false">
<el-form ref="form" :model="form" :inline="false" size="mini" v-show="!showResult">
<el-upload ref="upload" class="upload-wrap"
action="ecFence/importDeviceManage"
:on-change="changeFile"
:before-upload="beforeUpload"
:multiple="false"
:show-file-list="false"
:on-success="successUpload"
:on-error="errorUpload"
:auto-upload="false">
<el-form ref="form" :model="form" :inline="false" size="mini" v-show="!showResult">
<el-upload ref="upload" class="upload-wrap" :action="IMPORT_ELECFENCE_LINKEDDEVICES" :data="uploadParams" :headers="uploadHeaders" :on-change="changeFile" :before-upload="beforeUpload" :multiple="false" :show-file-list="false" :on-success="successUpload" :on-error="errorUpload" :auto-upload="false">
<el-input v-model="filename" placeholder="未选取任何文件" class="input-with-select" size="small" >
<el-button slot="append" >浏览</el-button>
</el-input>
<el-input v-model="filename" placeholder="未选取任何文件" class="input-with-select" size="small">
<el-button slot="append">浏览</el-button>
</el-input>
<div slot="tip" class="el-upload__tip">请选择需要导入的工单表格</div>
</el-upload>
</el-form>
<el-row v-show="showResult" class="result-row">
<el-col :span="12" class="text-center">
<p><i class="el-icon-success el-alert--success"></i></p>
<p><strong>{{successNum}}</strong><br>成功记录</p>
</el-col>
<el-col :span="12" class="text-center">
<p><i class="el-icon-error el-alert--error"></i></p>
<p><strong>{{errorNum}}</strong><br>失败记录</p>
</el-col>
</el-row>
<div slot="tip" class="el-upload__tip">请选择需要导入的工单表格</div>
</el-upload>
</el-form>
<div slot="footer" class="dialog-footer">
<div v-show="!showResult" class="success">
<el-button type="primary" @click="downloadTpl" size="small" class="pull-left">下载模板</el-button>
<el-button type="primary" @click="submitUpload" size="small" :loading="importing">提交</el-button>
<el-button @click="$emit('onUserImportModalChange', false)" size="small">关闭</el-button>
</div>
<div v-show="showResult">
<el-button :type="errorNum!=0?'primary':'info'" @click="exportErrorResult" size="small" class="pull-left">导出失败结果</el-button>
<el-button @click="doneResult" size="small" type="primary">完成</el-button>
</div>
</div>
</el-dialog>
<el-row v-show="showResult" class="result-row">
<el-col :span="12" class="text-center">
<p><i class="el-icon-success el-alert--success"></i></p>
<p><strong>{{successNum}}</strong><br>成功记录</p>
</el-col>
<el-col :span="12" class="text-center">
<p><i class="el-icon-error el-alert--error"></i></p>
<p><strong>{{errorNum}}</strong><br>失败记录</p>
</el-col>
</el-row>
</template>
<script>
import {exportExcel} from 'utils'
export default{
props: ['userImportModalVisible'],
data(){
return {
form: {
<div slot="footer" class="dialog-footer">
<div v-show="!showResult" class="success">
<el-button type="primary" @click="downloadTpl" size="small" class="pull-left">下载模板</el-button>
<el-button type="primary" @click="submitUpload" size="small" :loading="importing">提交</el-button>
<el-button @click="$emit('onUserImportModalChange', false)" size="small">关闭</el-button>
</div>
},
showResult: false,
successNum: '',
errorNum: '',
seqNo: '',
importing: false,
filename: '',
flag:[]
}
},
methods: {
doneResult(){
this.$emit('onUserImportModalChange', false);
this.$emit('onRefreshList');
this.showResult = false;
this.successNum = '';
this.errorNum = '';
this.seqNo = '';
this.importing = false;
this.filename = '';
<div v-show="showResult">
<el-button :type="errorNum!=0?'primary':'info'" @click="exportErrorResult" size="small" class="pull-left">导出失败结果</el-button>
<el-button @click="doneResult" size="small" type="primary">完成</el-button>
</div>
</div>
</el-dialog>
},
exportErrorResult(){
if(this.errorNum!=0){
exportExcel('ecFence/exportFailSn', {seqNo: this.seqNo})
}else{
return false;
}
},
successUpload(res){
this.importing = false;
if(typeof res === 'object'){
if(res.returnCode == 0){
const data = res.data;
let returnDate=[];
if(this.flag.length!=0){
function noRepeat(obj1,obj2){
for(var key in obj2){
if(obj1[key]){
if(obj1[key].sn!=obj2[key].sn){
returnDate.push(obj2[key])
}
}else{
returnDate.push(obj2[key])
}
}
}
noRepeat(this.flag,res.data.returnDate)
</template>
<script>
import { exportExcel } from "utils";
import {
IMPORT_ELECFENCE_LINKEDDEVICES,
DOWN_ELECFENCE_EXCELTEMPLATE,
} from "@/api/services/fence";
import { downFileByPath } from "@/utils/utils";
export default {
props: ["userImportModalVisible"],
data() {
return {
form: {},
showResult: false,
successNum: "",
errorNum: "",
seqNo: "",
importing: false,
filename: "",
flag: [],
IMPORT_ELECFENCE_LINKEDDEVICES,
uploadHeaders: {},
uploadParams: {},
};
},
created() {
let query = this.$route.query;
let token = localStorage.getItem("token");
this.uploadHeaders = { Authorization: token };
if (query.id) {
this.uploadParams = { fenceId: query.id };
}
},
methods: {
doneResult() {
this.$emit("onUserImportModalChange", false);
this.$emit("onRefreshList");
this.showResult = false;
this.successNum = "";
this.errorNum = "";
this.seqNo = "";
this.importing = false;
this.filename = "";
},
exportErrorResult() {
if (this.errorNum != 0) {
exportExcel("ecFence/exportFailSn", { seqNo: this.seqNo });
} else {
return false;
}
},
successUpload(res) {
this.importing = false;
if (typeof res === "object") {
if (res.returnCode == 0) {
const data = res.data;
let returnDate = [];
if (this.flag.length != 0) {
function noRepeat(obj1, obj2) {
for (var key in obj2) {
if (obj1[key]) {
if (obj1[key].sn != obj2[key].sn) {
returnDate.push(obj2[key]);
}
} else {
returnDate.push(obj2[key]);
}
}
}
noRepeat(this.flag, res.data.returnDate);
this.$emit('exportDate', returnDate);
this.flag.push(...returnDate);
//console.log(this.flag)
this.successNum = returnDate.length;
this.errorNum = parseInt(data.fail);
this.seqNo = data.seqNo;
this.$refs.upload.clearFiles();
this.showResult = true;
}else{
this.flag = res.data.returnDate
this.$emit('exportDate', res.data.returnDate)
this.successNum = data.success;
this.errorNum = parseInt(data.fail);
this.seqNo = data.seqNo;
this.$emit("exportDate", returnDate);
this.flag.push(...returnDate);
this.$refs.upload.clearFiles();
this.showResult = true;
}
}
}else{
window.location.href = '../ots/login';
}
//console.log(this.flag)
this.successNum = returnDate.length;
this.errorNum = parseInt(data.fail);
this.seqNo = data.seqNo;
this.$refs.upload.clearFiles();
this.showResult = true;
} else {
this.flag = res.data.returnDate;
this.$emit("exportDate", res.data.returnDate);
this.successNum = data.success;
this.errorNum = parseInt(data.fail);
this.seqNo = data.seqNo;
},
submitUpload() {
this.$refs.upload.submit();
},
changeFile(file, filelist) {
this.filename = file.name;
},
beforeUpload(file){
if(file.name == this.filename){
this.importing = true;
return true
}
this.$refs.upload.clearFiles();
this.showResult = true;
}
}
} else {
//window.location.href = '../ots/login';
}
},
submitUpload() {
this.$refs.upload.submit();
},
changeFile(file, filelist) {
this.filename = file.name;
},
beforeUpload(file) {
if (file.name == this.filename) {
this.importing = true;
return true;
}
return false
},
downloadTpl(){
exportExcel('ecFence/downTemplates')
},
openDialog(){
this.$emit('onUserImportModalChange', true)
},
closeDialog(){
this.$emit('onUserImportModalChange', false);
},
errorUpload(err){
window.location.href = '../ots/login';
}
}
}
return false;
},
// 批量导入模板下载
downloadTpl() {
DOWN_ELECFENCE_EXCELTEMPLATE().then((res) => {
let obj = res.data;
if (obj.dictValue) {
downFileByPath(obj.dictValue);
}
});
},
openDialog() {
this.$emit("onUserImportModalChange", true);
},
closeDialog() {
this.$emit("onUserImportModalChange", false);
},
errorUpload(err) {
//window.location.href = '../ots/login';
},
},
};
</script>
<style>
.import-dialog .upload-wrap .el-upload{
width: 100%;
}
.import-dialog .el-icon-success, .import-dialog .el-icon-error{
font-size: 30px;
}
.import-dialog .result-row .el-col+.el-col{
border-left: 1px solid #eee;
}
.import-dialog .upload-wrap .el-upload {
width: 100%;
}
.import-dialog .el-icon-success,
.import-dialog .el-icon-error {
font-size: 30px;
}
.import-dialog .result-row .el-col + .el-col {
border-left: 1px solid #eee;
}
</style>
\ No newline at end of file
......@@ -34,6 +34,7 @@ const fence = () => import( /*webpackChunkName: "fence"*/ 'pages/monitor/fence.
const fenceManagement = () => import(/* webpackChunkName: "fenceManagement" */ 'pages/monitor/fenceManagement.vue');
const editFence = () => import(/* webpackChunkName: "editFence" */ 'pages/monitor/editFence.vue');
const addFence = () => import(/* webpackChunkName: "addFence" */ 'pages/monitor/addFence.vue');
const compareLocation = () => import(/* webpackChunkName: "compareLocation" */ 'pages/monitor/compareLocation.vue')
const userCarAdmin = () => import(/* webpackChunkName: "userCarAdmin" */ 'pages/business/userCarAdmin.vue');
......@@ -69,12 +70,12 @@ const routes = [
path: '/',
name: 'home',
icon: 'fa-home',
meta: {title:'首页'},
meta: { title: '首页' },
component: home
},
{
path: '/report',
meta: {title:'统计报表'},
meta: { title: '统计报表' },
icon: 'fa-bar-chart',
component: {
template: '<router-view></router-view>'
......@@ -82,115 +83,115 @@ const routes = [
children: [{
path: 'activeList',
name: 'activeList',
meta: {title:'设备激活'},
meta: { title: '设备激活' },
component: activeList
},
{
path: 'alarmList',
name: 'alarmList',
meta: {title:'围栏预警'},
meta: { title: '围栏预警' },
component: alarmList
},
{
path: 'outageAlarm',
name: 'outageAlarm',
meta: {title:'断电报警'},
meta: { title: '断电报警' },
notMenu: true,
component: outageAlarm
},
{
path: 'antiOffAlarm',
name: 'antiOffAlarm',
meta: {title:'防拆报警'},
meta: { title: '防拆报警' },
component: antiOffAlarm
},
{
path: 'lastLocation',
name: 'lastLocation',
meta: {title:'最后定位报表'},
meta: { title: '最后定位报表' },
component: lastLocation
},{
}, {
path: 'offlineReport',
name: 'offlineReport',
meta: {title:'离线报警'},
meta: { title: '离线报警' },
component: offlineReport
},{
}, {
path: 'shutdownReport',
name: 'shutdownReport',
meta: {title:'停驶报警'},
meta: { title: '停驶报警' },
component: shutdownReport
},{
}, {
path: 'speedAlarm',
name: 'speedAlarm',
meta: {title:'超速报警'},
meta: { title: '超速报警' },
component: speedAlarm
},{
}, {
path: 'singleDevice',
name: 'singleDevice',
meta: {title:'单个超速报警'},
meta: { title: '单个超速报警' },
component: singleDevice,
notMenu: true,
},{
}, {
path: 'mileageStatistics',
name: 'mileageStatistics',
meta: {title:'里程统计'},
meta: { title: '里程统计' },
component: mileageStatistics
},{
}, {
path: 'mileageMapModal',
name: 'mileageMapModal',
meta: {title:'单个里程统计'},
meta: { title: '单个里程统计' },
component: mileageMapModal,
notMenu: true,
},{
}, {
path: 'electricityStatistics',
name: 'electricityStatistics',
meta: {title:'电量统计'},
meta: { title: '电量统计' },
component: electricityStatistics
},{
}, {
path: 'alarmCenter',
name: 'alarmCenter',
meta: {title:'警情中心'},
meta: { title: '警情中心' },
component: alarmCenter
},{
}, {
path: 'alarmDispose',
name: 'alarmDispose',
meta: {title:'警情配置(广汽)'},
meta: { title: '警情配置(广汽)' },
component: alarmDispose
},{
}, {
path: 'alarmCore',
name: 'alarmCore',
meta: {title:'警情中心(广汽)'},
meta: { title: '警情中心(广汽)' },
component: alarmCore
},{
}, {
path: 'alarmDetail',
name: 'alarmDetail',
meta: {title:'警情中心/详情'},
meta: { title: '警情中心/详情' },
component: alarmDetail,
notMenu: true,
},{
}, {
path: 'alarmFocus',
name: 'alarmFocus',
meta: {title:'警情中心/我的关注'},
meta: { title: '警情中心/我的关注' },
component: alarmFocus,
notMenu: true,
},{
}, {
path: 'alarmIgnore',
name: 'alarmIgnore',
meta: {title:'警情中心/忽略的车辆'},
meta: { title: '警情中心/忽略的车辆' },
component: alarmIgnore,
notMenu: true,
},{
}, {
path: 'alarmLog',
name: 'alarmLog',
meta: {title:'警情中心/处理日志'},
meta: { title: '警情中心/处理日志' },
component: alarmLog,
notMenu: true,
}]
},
{
path: '/monitor',
meta: {title:'车辆监控'},
meta: { title: '车辆监控' },
icon: 'fa-car',
component: {
template: '<router-view></router-view>'
......@@ -198,68 +199,77 @@ const routes = [
children: [{
path: 'monitor',
name: 'monitor',
meta: {title:'车辆监控'},
meta: { title: '车辆监控' },
component: monitor
},
{
path: 'historyLocation',
name: 'historyLocation',
meta: {title:'历史停留'},
meta: { title: '历史停留' },
component: historyLocation,
notMenu: true,
},
{
path: 'replay',
name: 'replay',
meta: {title:'轨迹回放'},
meta: { title: '轨迹回放' },
component: replay,
notMenu: true,
},
{
path: 'resident',
name: 'resident',
meta: {title:'常驻地'},
meta: { title: '常驻地' },
component: resident,
notMenu: true,
},
{
path: 'fence',
name: 'fence',
meta: {title:'电子围栏'},
meta: { title: '电子围栏' },
component: fence,
notMenu: true,
},
{
path: 'fenceManagement',
name: 'fenceManagement',
meta: {title:'试驶线路管理'},
meta: { title: '试驶线路管理' },
component: fenceManagement
},
{
path: 'editFence',
name: 'editFence',
meta: {
title:'新增线路',
title: '新增线路',
pushState: true
},
component: editFence,
notMenu: true,
},{
path: 'addFence',
name: 'addFence',
meta: {
title: '新增围栏',
pushState: true
},
component: addFence,
notMenu: true,
}, {
path: 'compareLocation',
name: 'compareLocation',
meta: {title:'位置对比'},
meta: { title: '位置对比' },
component: compareLocation
},{
}, {
path: 'activeLocation',
name: 'activeLocation',
meta: {title:'设备激活位置'},
meta: { title: '设备激活位置' },
component: () => import('pages/monitor/activeLocation.vue'),
notMenu: true,
}]
},
{
path: '/business',
meta: {title:'业务管理'},
meta: { title: '业务管理' },
icon: 'fa-briefcase',
component: {
template: '<router-view></router-view>'
......@@ -267,7 +277,7 @@ const routes = [
children: [{
path: 'userCarAdmin',
name: 'userCarAdmin',
meta: {title:'车辆管理'},
meta: { title: '车辆管理' },
component: userCarAdmin
},
/*{
......@@ -279,34 +289,34 @@ const routes = [
{
path: 'workOrderAdmin',
name: 'workOrderAdmin',
meta: {title:'工单管理'},
meta: { title: '工单管理' },
component: workOrderAdmin
}, {
path: 'editOrderPage',
name: 'editOrderPage',
meta: {title: '编辑工单'},
meta: { title: '编辑工单' },
component: editOrderPage,
notMenu: true,
}, {
path: 'gqOrder',
name: 'gqOrder',
meta: {title:'工单管理(广汽)'},
meta: { title: '工单管理(广汽)' },
component: gqOrder
}, {
path: 'anjiAccount',
name: 'anjiAccount',
meta: {title:'对账管理(安吉)'},
meta: { title: '对账管理(安吉)' },
component: anjiAccount
}, {
path: 'gqReport',
name: 'gqReport',
meta: {title:'报表管理(广汽)'},
meta: { title: '报表管理(广汽)' },
component: gqReport
}]
},
{
path: '/device',
meta: {title:'设备管理'},
meta: { title: '设备管理' },
icon: 'fa-microchip',
component: {
template: '<router-view></router-view>'
......@@ -314,33 +324,33 @@ const routes = [
children: [{
path: 'deviceType',
name: 'deviceType',
meta: {title:'设备类型'},
meta: { title: '设备类型' },
component: deviceType
},{
}, {
path: 'deviceList',
name: 'deviceList',
meta: {title:'设备管理'},
meta: { title: '设备管理' },
component: deviceList
},{
}, {
path: 'deviceAdminList',
name: 'deviceAdminList',
meta: {title:'入库管理'},
meta: { title: '入库管理' },
component: deviceAdminList
},{
}, {
path: 'policyDeviceImport',
name: 'policyDeviceImport',
meta: {title:'保单设备导入'},
meta: { title: '保单设备导入' },
component: policyDeviceImport
},{
}, {
path: 'xfDeviceAdminList',
name: 'xfDeviceAdminList',
meta: {title:'先锋太盟设备管理'},
meta: { title: '先锋太盟设备管理' },
component: xfDeviceAdminList
}]
},
{
path: '/accounts',
meta: {title:'汇通分账'},
meta: { title: '汇通分账' },
icon: 'fa-cogs',
component: {
template: '<router-view></router-view>'
......@@ -348,19 +358,19 @@ const routes = [
children: [{
path: 'accountsList',
name: 'accountsList',
meta: {title:'汇通分账'},
meta: { title: '汇通分账' },
component: accountsList
}, {
path: 'accountsDetail',
name: 'accountsDetail',
meta: {title:'汇通分账详情'},
meta: { title: '汇通分账详情' },
component: accountsDetail,
notMenu: true
}]
},
{
path: '/stock',
meta: {title:'库存管理'},
meta: { title: '库存管理' },
icon: 'fa-cubes',
component: {
template: '<router-view></router-view>'
......@@ -368,18 +378,18 @@ const routes = [
children: [{
path: 'stockList',
name: 'stockList',
meta: {title:'库存信息'},
meta: { title: '库存信息' },
component: stockList,
}, {
path: 'stockDeviceList',
name: 'stockDeviceList',
meta: {title:'设备明细'},
meta: { title: '设备明细' },
component: stockDeviceList,
}]
},
{
path: '/system',
meta: {title:'系统管理'},
meta: { title: '系统管理' },
icon: 'fa-cogs',
component: {
template: '<router-view></router-view>'
......@@ -387,30 +397,30 @@ const routes = [
children: [{
path: 'personalInfo',
name: 'personalInfo',
meta: {title:'个人信息'},
meta: { title: '个人信息' },
component: personalInfo
}]
},
{
path: '/notice',
name: 'notice',
meta: {title:'系统公告'},
meta: { title: '系统公告' },
component: notice,
notMenu: true,
},
{
path: '/tool',
name: 'tool',
meta: {title:'工具'},
meta: { title: '工具' },
icon: 'fa-download',
component: tool
},
]
function getFullPath(arr, prefix=''){
return arr.map((item)=>{
function getFullPath(arr, prefix = '') {
return arr.map((item) => {
item.fullPath = `${prefix}${item.path}`
if(item.children && item.children.length){
if (item.children && item.children.length) {
let children = getFullPath([...item.children], `${item.path}/`)
return {
...item,
......@@ -421,7 +431,7 @@ function getFullPath(arr, prefix=''){
return {
...item,
url: item.fullPath,
title: item.meta&&item.meta.title,
title: item.meta && item.meta.title,
}
})
}
......@@ -429,26 +439,26 @@ function getFullPath(arr, prefix=''){
/* const _routes = getFullPath(routes)
console.log(JSON.stringify(_routes)) */
function filterRoutes(arr, path, initArr=[]){
function filterRoutes(arr, path, initArr = []) {
arr.reduce((prevArr, item)=>{
if(item.notMenu) {
arr.reduce((prevArr, item) => {
if (item.notMenu) {
initArr.push({
...item
})
}else{
if(path.indexOf(item.url)>-1){
if(item.children && item.children.length){
} else {
if (path.indexOf(item.url) > -1) {
if (item.children && item.children.length) {
initArr.push({
...item,
children: filterRoutes(item.children, path)
})
}else{
} else {
initArr.push({
...item
})
}
}
}
return initArr
......@@ -456,62 +466,62 @@ function filterRoutes(arr, path, initArr=[]){
return initArr
}
function getPathArr(arr, prevArr=[]){
return arr.reduce((prevArr, item)=>{
function getPathArr(arr, prevArr = []) {
return arr.reduce((prevArr, item) => {
prevArr.push(item.url)
if(item.children && item.children.length){
if (item.children && item.children.length) {
getPathArr(item.children, prevArr)
}
return prevArr
}, prevArr)
}
function filterMenuItems(arr, initArr=[]){
return arr.reduce((prevArr, item)=>{
if(!item.notMenu) {
if(item.children && item.children.length){
function filterMenuItems(arr, initArr = []) {
return arr.reduce((prevArr, item) => {
if (!item.notMenu) {
if (item.children && item.children.length) {
initArr.push({
...item,
children: filterMenuItems(item.children)
})
}else{
} else {
initArr.push({
...item
})
}
}
return initArr
}, initArr)
}
function getMenuItems(arr){
return arr.map((item)=>{
function getMenuItems(arr) {
return arr.map((item) => {
const _url = item.url.split('')
_url.shift()
let index = _url.join('')
if(item.children && item.children.length){
if (item.children && item.children.length) {
let children = getMenuItems([...item.children])
return {
index,
icon: item.icon,
title: item.meta&&item.meta.title,
title: item.meta && item.meta.title,
children,
}
}
return {
index,
icon: item.icon,
title: item.meta&&item.meta.title,
title: item.meta && item.meta.title,
}
})
}
function getFirstPath(arr){
function getFirstPath(arr) {
let _item = arr[0];
if(_item.children && _item.children.length){
if (_item.children && _item.children.length) {
return getFirstPath(_item.children)
}
return _item.url
......@@ -521,52 +531,52 @@ let firstPath = '/'
// router.beforeEach((to, from, next) => {
// document.title = '虎哥e盾|'+to.meta.title;
// if(store.getters.roleType === undefined){
// store.dispatch('getRoleInfo').then((data)=>{
// if(data && data.permission){
// const allPath = getPathArr(data.permission)
// const fullPathRoutes = getFullPath(routes)
// const allRoutes = filterRoutes(fullPathRoutes, allPath)
// const menuItems = getMenuItems(filterMenuItems([...allRoutes]))
// firstPath = getFirstPath(allRoutes)
// store.dispatch('setPermission', menuItems)
// router.addRoutes(allRoutes)
// }
// if(to.path === '/' && to.matched.length === 0){
// next({
// ...to,
// path: firstPath
// })
// return;
// }
// if(store.getters.zlAccount && to.path === '/'){
// next({path: '/monitor/monitor'})
// return;
// }
// next({...to})
// });
// }else{
// if(to.path === '/' && to.matched.length === 0){
// next({
// ...to,
// path: firstPath
// })
// return;
// }
// if(store.getters.zlAccount && to.path === '/'){
// next({path: '/monitor/monitor'})
// return;
// }
// next()
// }
// next();
// if(store.getters.roleType === undefined){
// store.dispatch('getRoleInfo').then((data)=>{
// if(data && data.permission){
// const allPath = getPathArr(data.permission)
// const fullPathRoutes = getFullPath(routes)
// const allRoutes = filterRoutes(fullPathRoutes, allPath)
// const menuItems = getMenuItems(filterMenuItems([...allRoutes]))
// firstPath = getFirstPath(allRoutes)
// store.dispatch('setPermission', menuItems)
// router.addRoutes(allRoutes)
// }
// if(to.path === '/' && to.matched.length === 0){
// next({
// ...to,
// path: firstPath
// })
// return;
// }
// if(store.getters.zlAccount && to.path === '/'){
// next({path: '/monitor/monitor'})
// return;
// }
// next({...to})
// });
// }else{
// if(to.path === '/' && to.matched.length === 0){
// next({
// ...to,
// path: firstPath
// })
// return;
// }
// if(store.getters.zlAccount && to.path === '/'){
// next({path: '/monitor/monitor'})
// return;
// }
// next()
// }
// next();
// })
export default routes
\ No newline at end of file
import EventBus from '../event-bus'
import EventBus from '@/event-bus'
import mapService from './mapService.js'
import MAPGEO from './mapgeo'
......@@ -7,36 +7,36 @@ const fence = {
polygons: [],
circle: null,
isEditMode: true,
bindEvent(){
EventBus.$on('uiMap.fence.drawDistrict', (data)=>{
bindEvent() {
EventBus.$on('uiMap.fence.drawDistrict', (data) => {
this.drawDistrict(data)
});
EventBus.$on('uiMap.fence.createFenceCircle', (data)=>{
if(('isEdit' in data)&&!data.isEdit){
EventBus.$on('uiMap.fence.createFenceCircle', (data) => {
if (('isEdit' in data) && !data.isEdit) {
this.isEditMode = false
}else{
} else {
this.isEditMode = true
}
this.createFenceCircle(data)
});
EventBus.$on('uiMap.fence.updateFenceRadius', (data)=>{
this.circle.setRadius(data*1);
EventBus.$on('uiMap.fence.updateFenceRadius', (data) => {
this.circle.setRadius(data * 1);
mapService.setFitView()
});
EventBus.$on('uiMap.fence.createFenceMarker', (data)=>{
EventBus.$on('uiMap.fence.createFenceMarker', (data) => {
this.createFenceMarker(data)
});
EventBus.$on('uiMap.fence.drawPolygon', (data)=>{
if(data){
if(Array.isArray(data)){
EventBus.$on('uiMap.fence.drawPolygon', (data) => {
if (data) {
if (Array.isArray(data)) {
this.polygonPath = data;
this.isEditMode = true;
}else if(('isEdit' in data)&&!data.isEdit){
} else if (('isEdit' in data) && !data.isEdit) {
this.polygonPath = data.path;
this.isEditMode = false;
}
......@@ -44,43 +44,63 @@ const fence = {
this.drawPolygon()
});
EventBus.$on('uiMap.fence.destroy', (data)=>{
EventBus.$on('uiMap.fence.destroy', (data) => {
this.polyEditor && this.polyEditor.close()
this.mouseTool && this.mouseTool.close()
});
},
destroy(){
destroy() {
const MAP = mapService.map;
this.polygons && MAP.remove(this.polygons);
this.circle && MAP.remove(this.circle);
this.circleEditor && this.circleEditor.close();//MAP.remove(this.circleEditor);
this.polygons = [];
this.polyEditor && this.polyEditor.close()
this.mouseTool && this.mouseTool.close()
this.polygon && MAP.remove(this.polygon)
this.clearTimeoutIds();
if (MAP) {
this.polygons && MAP.remove(this.polygons);
this.circle && MAP.remove(this.circle);
this.circleEditor && this.circleEditor.close();//MAP.remove(this.circleEditor);
this.polygons = [];
this.polyEditor && this.polyEditor.close()
this.mouseTool && this.mouseTool.close()
this.polygon && MAP.remove(this.polygon)
}
//this.clearTimeoutIds();
},
drawDistrict(data){
// 行政区域
drawDistrict(data) {
if (!data || data.length <= 0) {
return false;
}
const MAP = mapService.map;
this.destroy();
var opts = {
subdistrict: 1, //返回下一级行政区
subdistrict: 0, //返回下一级行政区
extensions: 'all',
showbiz:false //最后一级返回街道信息
showbiz: false //最后一级返回街道信息
};
data == "中国"?delete opts.extensions :delete opts.showbiz;
let oParams = data[data.length - 1];
//data == "中国" ? delete opts.extensions : delete opts.showbiz;
let district = new AMap.DistrictSearch(opts);
district.setLevel('district');
EventBus.$emit('uiMap.fence.loading', true);
switch (data.length) {
case 1:
district.setLevel('province');
break;
case 2:
district.setLevel('city');
break;
default:
district.setLevel('district');
break;
}
//EventBus.$emit('uiMap.fence.loading', true);
//行政区查询
district.search(data.toString(), function(status, result) {
district.search(oParams, function (status, result) {
console.log(result)
const dst = result.districtList[0];
var bounds = dst.boundaries;
let lng = dst.center.lng;
let lat = dst.center.lat;
if (bounds) {
if (bounds) {
for (var i = 0, l = bounds.length; i < l; i++) {
//生成行政区划polygon
var polygon = new AMap.Polygon({
......@@ -90,98 +110,87 @@ const fence = {
fillOpacity: 0.7,
fillColor: '#CCF3FF',
strokeColor: '#CC66CC',
});
fence.polygons.push(polygon);
}
let center = mapService.getLngLat(lng,lat);
}
let center = mapService.getLngLat(lng, lat);
mapService.setFitView();
EventBus.$emit('uiMap.fence.loading', false);
//EventBus.$emit('uiMap.fence.loading', false);
}
});
},
createFenceCircle(data){
createFenceCircle(data) {
const MAP = mapService.map;
//this.destroy();
this.destroy();
this.circle = new AMap.Circle({
map: MAP,
center: mapService.getLngLat(data.lng, data.lat),
radius: data.radius*1,
radius: data.radius * 1,
strokeColor: "#F33",
strokeOpacity: 1,
strokeWeight: 3,
fillColor: "ee2200",
fillOpacity: 0.35,
zIndex: 0,
});
this.circleEditor = new AMap.CircleEditor(MAP, this.circle);
AMap.event.addListener(this.circleEditor, 'adjust', (e)=>{
EventBus.$emit('uiMap.fence.onFenceRadiusChange', e.radius/1)
/*this.form.radius = e.radius/1;
this.$emit('onUpdateMapData',{
lng: this.form.lng,
lat: this.form.lat,
address: this.form.transferAddr,
radius: this.form.radius
});*/
//this.$refs.fenceMapForm.validateField('radius');
});
AMap.event.addListener(this.circleEditor, 'move', (e)=>{
this.circleEditor = new AMap.CircleEditor(MAP, this.circle);
this.circleEditor.on('adjust', function (e) {
//log.info('触发事件:adjust')
EventBus.$emit('uiMap.fence.onFenceRadiusChange', e.radius / 1)
})
this.circleEditor.on('move', function (e) {
EventBus.$emit('uiMap.fence.onFenceLngLatChange', {
lng: e.lnglat.lng,
lat: e.lnglat.lat
});
});
if(this.isEditMode){
this.circleEditor.open();
}else{
this.circleEditor.close();
})
if (this.isEditMode) {
this.circleEditor.open();
} else {
this.circleEditor.close();
}
mapService.setFitView()
MAP.setZoom(14);
},
createFenceMarker(data){
createFenceMarker(data) {
this.data = [{
elng: data.lngGPS,
elat: data.latGPS
}];
if(data.lngBase && data.latBase){
if (data.lngBase && data.latBase) {
this.data.push({
elng: data.lngBase,
elat: data.latBase
});
}
const MAP = mapService.map;
MAPGEO.transferAddressByGroup(this, ()=>{
data.transferAddressGPS = this.data[0].transferAddress;
if(this.data.length > 1){
data.transferAddressBase = this.data[1].transferAddress;
}
let marker = mapService.createCarMarker([data.lngGPS, data.latGPS], MAP);
let infoWindow = mapService.bindFenceInfoWindow(marker, MAP, data);
});
//MAPGEO.transferAddressByGroup(this, ()=>{
//data.transferAddressGPS = this.data[0].transferAddress;
// if(this.data.length > 1){
// data.transferAddressBase = this.data[1].transferAddress;
// }
console.log(data)
let marker = mapService.createCarMarker([data.lngGPS, data.latGPS], MAP);
let infoWindow = mapService.bindFenceInfoWindow(marker, MAP, data);
//});
},
drawPolygon(){
drawPolygon() {
const MAP = mapService.map;
const self = this;
//this.destroy();
this.destroy();
if(this.polygonPath.length){
if (this.polygonPath.length) {
self.polygon = new AMap.Polygon({
path: this.polygonPath,
strokeColor: "#FF33FF",
strokeColor: "#FF33FF",
strokeWeight: 6,
strokeOpacity: 0.2,
fillOpacity: 0.4,
......@@ -190,21 +199,21 @@ const fence = {
})
MAP.add(self.polygon)
MAP.setFitView([ self.polygon ])
MAP.setFitView([self.polygon])
self.polyEditor = new AMap.PolyEditor(MAP, self.polygon)
if(self.isEditMode){
if (self.isEditMode) {
self.polyEditor.open()
}else{
} else {
self.polyEditor.close()
}
self.bindPolyEvent(self.polyEditor)
}else if(self.isEditMode){
} else if (self.isEditMode) {
self.mouseTool = new AMap.MouseTool(MAP)
self.mouseTool.polygon({
strokeColor: "#FF33FF",
strokeColor: "#FF33FF",
strokeOpacity: 1,
strokeWeight: 6,
strokeOpacity: 0.2,
......@@ -216,7 +225,7 @@ const fence = {
// strokeDasharray: [30,10],
})
self.mouseTool.on('draw', function(event) {
self.mouseTool.on('draw', function (event) {
// event.obj 为绘制出来的覆盖物对象
self.polygon = event.obj;
self.polyEditor = new AMap.PolyEditor(MAP, self.polygon)
......@@ -227,46 +236,46 @@ const fence = {
})
}
},
bindPolyEvent(polyEditor){
bindPolyEvent(polyEditor) {
const self = this
polyEditor.on('addnode', function(event) {
polyEditor.on('addnode', function (event) {
console.log('触发事件:addnode')
self.emitPolyEvent()
})
polyEditor.on('adjust', function(event) {
polyEditor.on('adjust', function (event) {
console.log('触发事件:adjust')
self.emitPolyEvent()
})
polyEditor.on('removenode', function(event) {
polyEditor.on('removenode', function (event) {
console.log('触发事件:removenode')
self.emitPolyEvent()
})
polyEditor.on('end', function(event) {
polyEditor.on('end', function (event) {
console.log('触发事件: end')
self.emitPolyEvent()
// event.target 即为编辑后的多边形对象
})
},
emitPolyEvent(){
emitPolyEvent() {
let pathArr = this.polygon.getPath()
let resultArr = pathArr.map((item)=>{
let resultArr = pathArr.map((item) => {
return [item.lng, item.lat]
})
this.polygonPath = resultArr
EventBus.$emit('uiMap.fence.polygonChange',{
EventBus.$emit('uiMap.fence.polygonChange', {
polygonPath: this.polygonPath
});
console.log(resultArr.join('|'))
},
clearTimeoutIds(){
this.timeoutIds && this.timeoutIds.forEach((item)=>{
clearTimeoutIds() {
this.timeoutIds && this.timeoutIds.forEach((item) => {
item && window.clearTimeout(item);
});
this.timeoutIds = []
......
......@@ -3,48 +3,58 @@ window.ClipboardJS = ClipboardJS
import EventBus from '../event-bus'
import { Message } from "element-ui";
import store from '../vuex/store.js'
EventBus.$on('uiMap.copySuccess', (data)=>{
import vue from 'vue'
EventBus.$on('uiMap.copySuccess', (data) => {
Message({
type: 'success',
message: '已复制内容至粘贴板'
type: 'success',
message: '已复制内容至粘贴板'
});
});
function MapService(){
function MapService() {
this.map = null;
this.restainLayer = null;
}
var zhongliType = sessionStorage.getItem('zhongliType');//获取是否仲利账号状态,从本地内存中拿取数据
MapService.prototype = {
init: function(id){
init: function (id) {
var self = this;
self.map = new AMap.Map(id, {
var map = new AMap.Map(id, {
resizeEnable: true,
zoom: 11
});
// 添加比例尺
map.plugin(["AMap.Scale"], function () {
var scale = new AMap.Scale()
map.addControl(scale);
scale.show()
});
//距离测量
self.map.plugin(["AMap.RangingTool"],function(){
self.ruler = new AMap.RangingTool(self.map);
map.plugin(["AMap.RangingTool"], function () {
self.ruler = new AMap.RangingTool(map);
});
//定位
self.map.plugin('AMap.Geolocation', function(){
map.plugin('AMap.Geolocation', function () {
self.geolocation = new AMap.Geolocation();
});
self.map = map;
return self.map;
},
toggleMapType: function(){
toggleMapType: function () {
var self = this;
self.type = self.type?0:1; //0:使用2D地图,1:混合图
self.type = self.type ? 0 : 1; //0:使用2D地图,1:混合图
if(self.type === 1){
if (self.type === 1) {
// 构造官方卫星、路网图层
self.mixLayers = [
self.mixLayers = [
new AMap.TileLayer.Satellite(),
new AMap.TileLayer.RoadNet()
];
......@@ -52,7 +62,7 @@ MapService.prototype = {
let layers = self.mixLayers.concat(self.map.getLayers());
// 地图上设置图层
self.map.setLayers(layers);
}else{
} else {
// 地图上设置图层
self.map.remove(self.mixLayers);
/*self.map.plugin(["AMap.MapType"],function(){
......@@ -64,69 +74,69 @@ MapService.prototype = {
});*/
}
},
rulerTurnOn: function(){
rulerTurnOn: function () {
this.ruler.turnOn();
},
rulerTurnOff: function(){
rulerTurnOff: function () {
this.ruler.turnOff();
},
getCurrentLocation: function(){
getCurrentLocation: function () {
var self = this;
self.geolocation.getCurrentPosition();
self.currentMarker && self.map.remove(self.currentMarker);
AMap.event.addListener(self.geolocation, 'complete', function(e){//返回定位信息
AMap.event.addListener(self.geolocation, 'complete', function (e) {//返回定位信息
var lnglatXY = self.getLngLat(e.position.lng, e.position.lat);
self.currentMarker = self.createMarker(lnglatXY);
//self.map.setCenter(lnglatXY);
self.setFitView()
});
AMap.event.addListener(self.geolocation, 'error', function(e){//返回定位出错信息
AMap.event.addListener(self.geolocation, 'error', function (e) {//返回定位出错信息
});
});
},
createMarker: function (lnglatXY){
createMarker: function (lnglatXY) {
var marker = new AMap.Marker({
position: lnglatXY,
icon: require('images/mapLocation.gif'),
map: this.map,
offset: new AMap.Pixel(-12,-12)
offset: new AMap.Pixel(-12, -12)
});
return marker;
},
createPointMarker: function (lnglatXY){
createPointMarker: function (lnglatXY) {
var marker = new AMap.Marker({
position: lnglatXY,
icon: require('images/point.png'),
map: this.map,
offset: new AMap.Pixel(-9,-9)
offset: new AMap.Pixel(-9, -9)
});
return marker;
},
createConstantMarker: function (lnglatXY, map){
createConstantMarker: function (lnglatXY, map) {
var marker = new AMap.Marker({
position: lnglatXY,
icon: require('images/icon_constant.png'),
map: map,
offset: new AMap.Pixel(-12,-17)
offset: new AMap.Pixel(-12, -17)
});
return marker;
},
createCarMarker: function (lnglatXY, map){
createCarMarker: function (lnglatXY, map) {
var marker = new AMap.Marker({
position: lnglatXY,
icon: require('images/icon_car.png'),
map: map,
autoRotation: true,
offset: new AMap.Pixel(-18,-11),
offset: new AMap.Pixel(-18, -11),
zIndex: 1020,
animation: 'AMAP_ANIMATION_DROP'
});
return marker;
},
createPOIMarker(lnglatXY, map){
createPOIMarker(lnglatXY, map) {
var marker = new AMap.Marker({
position: lnglatXY,
content:`<span class="poi_marker"></span>`,
content: `<span class="poi_marker"></span>`,
//icon: require('images/poi-marker-default.png'),
map: map,
autoRotation: true,
......@@ -136,8 +146,8 @@ MapService.prototype = {
});
return marker;
},
createPOIInfo(info){
return `<div class="poi_infowin">
createPOIInfo(info) {
return `<div class="poi_infowin">
<h3 class="map-infowindow-title">POI信息</h3>
<div class="map-infowindow-ct">
<p class="poi_item"><label>经度:</label><span>${info.lng}</span></p>
......@@ -146,10 +156,10 @@ MapService.prototype = {
<p class="poi_item"><label>解析地址:</label><span>${info.address}</span>
</div></div>`
},
bindPOIInfoWindow(marker, map, info){
bindPOIInfoWindow(marker, map, info) {
var infoDiv = document.createElement('div');
infoDiv.innerHTML = this.createPOIInfo(info);
var infoWindow = new AMap.InfoWindow({
offset: new AMap.Pixel(0, -48),
content: infoDiv,
......@@ -157,59 +167,59 @@ MapService.prototype = {
});
marker.infoWindow = infoWindow;
marker.on('click', markerClick);
function markerClick(e){
function markerClick(e) {
//infoWindow.setContent(e.target.content);
infoWindow.open(map, e.target.getPosition());
}
return infoWindow;
},
setAlarmIcon(marker){
setAlarmIcon(marker) {
marker.setIcon(require('images/icon_car_alarm.png'))
},
setDefaultIcon(marker){
setDefaultIcon(marker) {
marker.setIcon(require('images/icon_car.png'))
},
createHistoryLocationMarker(lnglatXY, map){
createHistoryLocationMarker(lnglatXY, map) {
var marker = new AMap.Marker({
position: lnglatXY,
icon: require('images/icon_location.png'),
map: map,
autoRotation: true,
offset: new AMap.Pixel(-12,-17),
offset: new AMap.Pixel(-12, -17),
zIndex: 1020,
animation: 'AMAP_ANIMATION_DROP'
});
return marker;
},
createStartMarker: function(lnglatXY, map){
createStartMarker: function (lnglatXY, map) {
var marker = new AMap.Marker({
position: lnglatXY,
icon: require('images/icon_start.png'),
map: map,
offset: new AMap.Pixel(-12,-34),
offset: new AMap.Pixel(-12, -34),
zIndex: 100
});
return marker;
},
createEndMarker: function(lnglatXY, map){
createEndMarker: function (lnglatXY, map) {
var marker = new AMap.Marker({
position: lnglatXY,
icon: require('images/icon_end.png'),
map: map,
offset: new AMap.Pixel(-12,-34),
offset: new AMap.Pixel(-12, -34),
zIndex: 101
});
return marker;
},
createPolyline: function(map){
createPolyline: function (map) {
return new AMap.Polyline({
map: map,
strokeWeight: 2,
strokeColor: '#009944'
});
},
createCircle: function(lnglatXY, map, radius){
createCircle: function (lnglatXY, map, radius) {
return new AMap.Circle({
map: map,
center: lnglatXY,
......@@ -221,7 +231,7 @@ MapService.prototype = {
fillOpacity: 0.1
});
},
createPoint: function(lnglatXY, map){
createPoint: function (lnglatXY, map) {
return new AMap.Circle({
map: map,
center: lnglatXY,
......@@ -233,7 +243,7 @@ MapService.prototype = {
fillOpacity: 1
});
},
createInfoWindow(marker, map, div, isInfoOpen, isInfoAutoMove){
createInfoWindow(marker, map, div, isInfoOpen, isInfoAutoMove) {
var infoWindow = new AMap.InfoWindow({
offset: new AMap.Pixel(0, 0),
content: div,
......@@ -241,29 +251,32 @@ MapService.prototype = {
});
marker.infoWindow = infoWindow;
var clipboard = new ClipboardJS(div.querySelector('.copy-btn'));
clipboard.on('success', function(e) {
clipboard.on('success', function (e) {
e.clearSelection();
EventBus.$emit('uiMap.copySuccess');
});
clipboard.on('error', function(e) {
clipboard.on('error', function (e) {
console.error('Action:', e.action);
console.error('Trigger:', e.trigger);
});
if(isInfoOpen){
if (isInfoOpen) {
infoWindow.open(map, marker.getPosition());
}
//给Marker绑定单击事件
marker.on('click', markerClick);
function markerClick(e){
function markerClick(e) {
//infoWindow.setContent(e.target.content);
infoWindow.open(map, e.target.getPosition());
}
return infoWindow;
},
bindMonitorInfoWindow: function(marker, map, info, isInfoOpen, isInfoAutoMove){
// 车辆监控-查看位置点
bindMonitorInfoWindow: function (marker, map, info, isInfoOpen, isInfoAutoMove) {
console.log(info)
var self = this;
var infoDiv = document.createElement('div');
infoDiv.innerHTML = self.createMonitorInfo(info);
......@@ -271,41 +284,43 @@ MapService.prototype = {
let eLocation = info[info.eLocateType];
var statusArr = ['行驶中', '静止', '离线', '在线']
if(info.status === 2){
if (info.status === 2) {
infoDiv.querySelector('[data-status]').textContent = `${statusArr[info.status]} | 已离线${info.statusTime}`;
}else{
} else {
infoDiv.querySelector('[data-status]').textContent = statusArr[info.status];
}
infoDiv.querySelector('[data-time]').textContent = eLocation.dateTime;
infoDiv.querySelector('[data-transferAddress]').textContent = eLocation.transferAddress;
infoDiv.querySelector('[data-clipboard-text').setAttribute('data-clipboard-text', eLocation.transferAddress);
if(info.battery){
if (info.battery) {
infoDiv.querySelector('[data-battery]').classList.remove('hide');
infoDiv.querySelector('[data-battery-percentage]').style.width = info.battery;
infoDiv.querySelector('[data-battery-text]').textContent = info.battery;
}else{
} else {
infoDiv.querySelector('[data-battery]').classList.add('hide');
}
let gpsBtn = infoDiv.querySelector('[data-gps]')
let baseBtn = infoDiv.querySelector('[data-base]')
let wifiBtn = infoDiv.querySelector('[data-wifi]')
console.log(info.eLocateType)
if(info.eLocateType === 'bsLocation'){
gpsBtn&&gpsBtn.classList.remove('el-button--primary');
//console.log(info.eLocateType)
if (info.eLocateType === 'bsLocation') {
gpsBtn && gpsBtn.classList.remove('el-button--primary');
baseBtn.classList.add('el-button--primary');
}else{
gpsBtn&&gpsBtn.classList.add('el-button--primary');
baseBtn&&baseBtn.classList.remove('el-button--primary');
} else {
gpsBtn && gpsBtn.classList.add('el-button--primary');
baseBtn && baseBtn.classList.remove('el-button--primary');
}
baseBtn&&(baseBtn.onclick = function(e){console.log(info)
if(info.eLocateType === 'bsLocation') return;
baseBtn && (baseBtn.onclick = function (e) {
console.log(info)
if (info.eLocateType === 'bsLocation') return;
info.eLocateType = 'bsLocation'
eLocation = info[info.eLocateType];
if(!eLocation.elng || !eLocation.elat) {
if (!eLocation.elng || !eLocation.elat) {
Message({
type: 'info',
message: '暂无基站数据'
......@@ -319,13 +334,14 @@ MapService.prototype = {
infoDiv.querySelector('[data-time]').textContent = eLocation.dateTime;
EventBus.$emit('uiMap.monitor.changeELocate', info)
EventBus.$emit('uiMap.monitor.drawDone');
self.setFitView()
})
gpsBtn&&(gpsBtn.onclick = function(e){
if(info.eLocateType === 'gpsLocation') return;
gpsBtn && (gpsBtn.onclick = function (e) {
if (info.eLocateType === 'gpsLocation') return;
info.eLocateType = 'gpsLocation'
eLocation = info[info.eLocateType];
if(!eLocation.elng || !eLocation.elat) {
if (!eLocation.elng || !eLocation.elat) {
Message({
type: 'info',
message: '暂无GPS数据'
......@@ -339,22 +355,24 @@ MapService.prototype = {
infoDiv.querySelector('[data-time]').textContent = eLocation.dateTime;
EventBus.$emit('uiMap.monitor.changeELocate', info)
EventBus.$emit('uiMap.monitor.drawDone');
self.setFitView()
})
wifiBtn&&(wifiBtn.onclick = function(e){
wifiBtn && (wifiBtn.onclick = function (e) {
//infoDiv.querySelector('[data-transferAddress]').textContent = eLocation.transferAddress;
//infoDiv.querySelector('[data-time]').textContent = eLocation.time;
EventBus.$emit('uiMap.monitor.wifiLocate', {info, infoDiv, gpsBtn, baseBtn, wifiBtn})
EventBus.$emit('uiMap.monitor.wifiLocate', { info, infoDiv, gpsBtn, baseBtn, wifiBtn })
self.setFitView()
})
if(info.alarmTypeSet && info.alarmTypeSet.length){
if (info.alarmTypeSet && info.alarmTypeSet.length) {
let _html = '<i class="icon icon-info_device_alarm"></i>报警状态:'
info.alarmTypeSet.forEach((alarmType)=>{
if(alarmType === 1){
_html+=`<button type="button" class="el-button el-button--mini el-button--danger" data-alarmoff >断电</button>`
}else if(alarmType === 99){
_html+=`<button type="button" class="el-button el-button--mini el-button--danger" data-alarmlight >光感</button>`
info.alarmTypeSet.forEach((alarmType) => {
if (alarmType === 1) {
_html += `<button type="button" class="el-button el-button--mini el-button--danger" data-alarmoff >断电</button>`
} else if (alarmType === 99) {
_html += `<button type="button" class="el-button el-button--mini el-button--danger" data-alarmlight >光感</button>`
}
});
infoDiv.querySelector('[data-alarm]').innerHTML = _html;
......@@ -370,12 +388,54 @@ MapService.prototype = {
window.open(`#/report/antiOffAlarm?type=99&time=${e.target.dataset.alarmtime}&sn=${info.sn}`)
}
} */
infoDiv.querySelector('[data-alarm]').style.display = 'block';
}else{
} else {
infoDiv.querySelector('[data-alarm]').style.display = 'none';
}
// 通用参数
let queryCode = `sn=${info.sn}&name=${encodeURI(info.name)}&standno=${info.standNo}`;
// 跳转到历史停留页面
let historyBtn = infoDiv.querySelector('[data-history]');
if (historyBtn) {
historyBtn.onclick = function () {
mapService.openPage(`#/monitor/historyLocation?${queryCode}`)
}
}
// 跳转到常住地
let residentBtn = infoDiv.querySelector('[data-resident]');
if (residentBtn) {
residentBtn.onclick = function () {
mapService.openPage(`#/monitor/resident?${queryCode}`)
}
}
// 跳转到轨迹回放页面
let replayBtn = infoDiv.querySelector('[data-replay]');
if (replayBtn) {
replayBtn.onclick = function () {
mapService.openPage(`#/monitor/replay?${queryCode}`)
}
}
// 跳转到电子围栏页面 无线设备不能跳转电子围栏 isSource:1有线,其他无线
let fenceBtn = infoDiv.querySelector('[data-fence]');
if (fenceBtn) {
if (info.isSource != 1) {
fenceBtn.classList.add('fence_btn_grey');
}
fenceBtn.onclick = function () {
if (info.isSource == 1) {
mapService.openPage(`#/monitor/fence?${queryCode}`)
}
}
}
console.log(historyBtn)
const snSourceType = `${info.sn}:${info.isSource}`
/* EventBus.$on(`uiMap.monitor.changeStatus.${snSourceType}`, (status)=>{
if(status === 2){
......@@ -387,28 +447,28 @@ MapService.prototype = {
return this.createInfoWindow(marker, map, infoDiv, isInfoOpen, isInfoAutoMove);
},
bindLocationInfoWindow(marker, map, info){
bindLocationInfoWindow(marker, map, info) {
var self = this;
var infoDiv = document.createElement('div');
infoDiv.innerHTML = self.createLocationInfo(info);
return this.createInfoWindow(marker, map, infoDiv);
},
bindResidentInfoWindow(marker, map, info){
bindResidentInfoWindow(marker, map, info) {
var self = this;
var infoDiv = document.createElement('div');
infoDiv.innerHTML = self.createResidentInfo(info);
return this.createInfoWindow(marker, map, infoDiv);
},
bindFenceInfoWindow(marker, map, info){
bindFenceInfoWindow(marker, map, info) {
var self = this;
var infoDiv = document.createElement('div');
infoDiv.innerHTML = self.createFenceInfo(info);
var statusArr = ['行驶中', '静止', '离线', '在线'];
function fillGPS(){
function fillGPS() {
infoDiv.querySelector('[data-time]').textContent = info.timeGPS;
infoDiv.querySelector('[data-transferAddress]').textContent = info.transferAddressGPS;
infoDiv.querySelector('[data-clipboard-text').setAttribute('data-clipboard-text', info.transferAddressGPS);
......@@ -418,7 +478,7 @@ MapService.prototype = {
marker.infoWindow && marker.infoWindow.open(map, marker.getPosition());
}
function fillBase(){
function fillBase() {
infoDiv.querySelector('[data-time]').textContent = info.timeBase;
infoDiv.querySelector('[data-transferAddress]').textContent = info.transferAddressBase;
infoDiv.querySelector('[data-clipboard-text').setAttribute('data-clipboard-text', info.transferAddressBase);
......@@ -427,34 +487,34 @@ MapService.prototype = {
marker.setPosition(self.getLngLat(info.lngBase, info.latBase));
marker.infoWindow && marker.infoWindow.open(map, marker.getPosition());
}
infoDiv.querySelector('[data-status]').textContent = statusArr[info.status];
if(info.battery){
if (info.battery) {
infoDiv.querySelector('[data-battery]').classList.remove('hide');
infoDiv.querySelector('[data-battery-percentage]').style.width = info.battery;
infoDiv.querySelector('[data-battery-text]').textContent = info.battery;
}else{
} else {
infoDiv.querySelector('[data-battery]').classList.add('hide');
}
infoDiv.querySelector('#locateTypeGps').onclick = function(e){
infoDiv.querySelector('#locateTypeGps').onclick = function (e) {
fillGPS()
}
infoDiv.querySelector('#locateTypeBase').onclick = function(e){
infoDiv.querySelector('#locateTypeBase').onclick = function (e) {
fillBase()
}
fillGPS();
return this.createInfoWindow(marker, map, infoDiv);
},
getLngLat: function(lng, lat){
getLngLat: function (lng, lat) {
return new AMap.LngLat(lng, lat);
},
getGeocoder: function(){
return new Promise((resolve)=>{
AMap.service('AMap.Geocoder',function(){//回调函数
getGeocoder: function () {
return new Promise((resolve) => {
AMap.service('AMap.Geocoder', function () {//回调函数
var geocoder = new AMap.Geocoder({
batch: true
});
......@@ -462,23 +522,25 @@ MapService.prototype = {
});
})
},
getAddress: function(geocoder, lnglatXY){
geocoder.getAddress(lnglatXY, function(status, result) {
getAddress: function (geocoder, lnglatXY) {
geocoder.getAddress(lnglatXY, function (status, result) {
if (status === 'complete' && result.info === 'OK') {
//获得了有效的地址信息:
//即,result.regeocode.formattedAddress
}else{
//获取地址失败
//获得了有效的地址信息:
//即,result.regeocode.formattedAddress
} else {
//获取地址失败
}
});
},
zoomIn: function(){
zoomIn: function () {
this.map.zoomIn();
},
zoomOut: function(){
zoomOut: function () {
this.map.zoomOut();
},
createMonitorInfo: function(info){
// 监控弹框
createMonitorInfo: function (info) {
/*var _html = '<h3 class="uimap-info-title">'+ info.name+'/'+ info.standNo +'</h3><div class="uimap-info-ct"><p><span><i class="fa fa-inbox"></i></span>'+ info.sn +'</p>';
if(info.time){
_html += '<p><span><i class="fa fa-clock-o"></i></span>'+ info.time +'</p>';
......@@ -486,27 +548,43 @@ MapService.prototype = {
_html += '<p><span><i class="fa fa-map-marker"></i></span>'+ info.transferAddress +'</p>';
_html += '<p><span><i class="fa fa-car"></i></span>'+ '驻留次数:' +(info.totalTimes?info.totalTimes:'1')+'</p>';
return _html;*/
let _this = this;
let queryCode = `sn=${info.sn}&name=${encodeURI(info.name)}&standno=${info.standNo}`;
var _html = `<h3 class="map-infowindow-title">${info.name}/${info.standNo}</h3>`;
_html += `<div class="map-infowindow-ct">`;
var _html = `<h3 class="map-infowindow-title">${info.name}/${info.standNo}</h3>`;
_html += `<div class="map-infowindow-ct map_info_window">`;
console.log(zhongliType);
if(zhongliType == 'yes'){
if (zhongliType == 'yes') {
_html += `<div>`;
if(info.shopName){
if (info.shopName) {
_html += `<p><i class="icon icon-icon_store"></i> 店面名称: <span class="des">${info.shopName}</span></p>`;
}
if(info.shopContacts){
if (info.shopContacts) {
_html += `<p style="margin-left:29px;"> 店面联系人: <span class="des">${info.shopContacts}</span></p>`;
}
if(info.contactsPhone){
if (info.contactsPhone) {
_html += `<p style="margin-left:29px;"> 联系方式: <span class="des">${info.contactsPhone}</span></p>`;
}
if(info.idnum) {
if (info.idnum) {
_html += `<p style="margin-left:29px;"> 车牌号: <span class="des">${info.idnum}</span></p>`;
}
_html += `</div>`;
}
_html += `<p><i class="icon icon-info_device"></i> 设备号:<span class="des"> ${info.sn} (${info.isSource==='1'?'有线':'无线'})</span>
// 根据权限-显示店面名称、车牌号
let list = vue.prototype.$parentCommon.getAuthData();
let o = list.find(k => k.origin.permissionTag == 'oEshield_monitor_store_name');
let n = list.find(k => k.origin.permissionTag == 'oEshield_monitor_plate_number');
console.log(list)
if (o && info.shopName) {
_html += `<p><i class="icon_info_shop"></i> 店面名称: <span class="des">${info.shopName || '--'}</span></p>`;
}
if (n && info.licensePlate) {
_html += `<p><i class="icon_info_plate"></i>车牌号: <span class="des">${info.licensePlate || '--'}</span></p>`;
}
_html += `<p><i class="icon icon-info_device"></i> 设备号:<span class="des"> ${info.sn} (${info.isSource === '1' ? '有线' : '无线'})</span>
<span class="battery" data-battery>
<i class="fill"><i class="fill-percentage" data-battery-percentage></i></i>
<i class="icon icon-battery_enough"></i>
......@@ -514,7 +592,6 @@ MapService.prototype = {
</span></p>
<p><i class="icon icon-info_device_status"></i> 设备状态: <span class="des" data-status></span></p>
<p data-alarm>
<button type="button" class="el-button el-button--mini el-button--primary" data-alarmoff>断电</button>
<button type="button" class="el-button el-button--mini el-button--primary" data-alarmlight>光感</button>
</p>
......@@ -523,42 +600,40 @@ MapService.prototype = {
<a class="copy-btn" data-clipboard-text=""><i class="icon icon-info_copy"></i></a>
</p>
<p><i class="icon icon-info_type"></i> 定位类型:
${info.wifiLocation?
(info.eLocateSingle?
(info.eLocateType==='gpsLocation'?
`<span class="el-button-group">
${info.wifiLocation ?
(info.eLocateSingle ?
(info.eLocateType === 'gpsLocation' ?
`<span class="el-button-group">
<button type="button" class="el-button el-button--mini el-button--primary" data-gps>GPS</button>
<button type="button" class="el-button el-button--mini" data-wifi>wifi</button>
</span>`:
`<span class="el-button-group">
`<span class="el-button-group">
<button type="button" class="el-button el-button--mini el-button--primary" data-base>基站</button>
<button type="button" class="el-button el-button--mini" data-wifi>wifi</button>
</span>`
):
`<span class="el-button-group">
) :
`<span class="el-button-group">
<button type="button" class="el-button el-button--mini el-button--primary" data-gps>GPS</button>
<button type="button" class="el-button el-button--mini" data-base>基站</button>
<button type="button" class="el-button el-button--mini" data-wifi>wifi</button>
</span>`
):
info.eLocateSingle?
(info.eLocateType==='gpsLocation'?`<button type="button" class="el-button el-button--mini el-button--primary" data-gps>GPS</button> `:
`<button type="button" class="el-button el-button--mini el-button--primary" data-base>基站</button>`):
`<span class="el-button-group">
) :
info.eLocateSingle ?
(info.eLocateType === 'gpsLocation' ? `<button type="button" class="el-button el-button--mini el-button--primary" data-gps>GPS</button> ` :
`<button type="button" class="el-button el-button--mini el-button--primary" data-base>基站</button>`) :
`<span class="el-button-group">
<button type="button" class="el-button el-button--mini el-button--primary" data-gps>GPS</button>
<button type="button" class="el-button el-button--mini" data-base>基站</button>
</span>`
}
}
</p>
<p class="redirect-row">
<a class="redirect-btn" onclick="window.open('#/monitor/historyLocation?${queryCode}')" style="display:none;">历史停留</a>
<a class="redirect-btn" onclick="window.open('#/monitor/resident?${queryCode}')" style="display:none;">常驻地</a>
<a class="redirect-btn" onclick="location.href='oEshield#/monitor/replay?${queryCode}'">轨迹回放</a>
<a class="redirect-btn" onclick="window.open('#/monitor/fence?${queryCode}')" style="display:none;">电子围栏</a>
<a class="redirect-btn" id="btn_replay" data-replay>轨迹回放</a>
<a class="redirect-btn" id="btn_fence" data-fence>电子围栏</a>
</p>
</div>`;
// return `<h3 class="map-infowindow-title">${info.name}/${info.standNo}</h3>
// <div class="map-infowindow-ct">
// <div v-show="zhongliType">
......@@ -574,7 +649,7 @@ MapService.prototype = {
// </span></p>
// <p><i class="icon icon-info_device_status"></i> 设备状态: <span class="des" data-status></span></p>
// <p data-alarm>
// <button type="button" class="el-button el-button--mini el-button--primary" data-alarmoff>断电</button>
// <button type="button" class="el-button el-button--mini el-button--primary" data-alarmlight>光感</button>
// </p>
......@@ -619,7 +694,7 @@ MapService.prototype = {
// </div>`;
return _html;
},
createFenceInfo(info){
createFenceInfo(info) {
return `<h3 class="map-infowindow-title">${info.name}/${info.standno}</h3>
<div class="map-infowindow-ct">
<p><i class="icon icon-info_device"></i> 设备号:<span class="des"> ${info.sn} (${info.sourceString})</span>
......@@ -641,7 +716,7 @@ MapService.prototype = {
</p>
</div>`;
},
createLocationInfo(info){
createLocationInfo(info) {
return `<h3 class="map-infowindow-title">${info.name}/${info.standno}</h3>
<div class="map-infowindow-ct">
<p><i class="icon icon-info_time"></i> 停留时间: <span class="des">${info.begintime}</span></p>
......@@ -651,7 +726,7 @@ MapService.prototype = {
<p><i class="icon icon-info_stop"></i> 停留时长: <span class="des">${info.duration}</span></p>
</div>`;
},
createResidentInfo(info){
createResidentInfo(info) {
return `<h3 class="map-infowindow-title">${info.name}/${info.standNo}</h3>
<div class="map-infowindow-ct">
<p><i class="icon icon-info_device"></i> 设备号: <span class="des">${info.sn}</span></p>
......@@ -662,107 +737,115 @@ MapService.prototype = {
<p><i class="icon icon-info_stop"></i> 驻留时长: <span class="des">${info.totalDurationString}</span></p>
</div>`;
},
clearMap: function(map){
clearMap: function (map) {
this.map.clearMap();
},
setFitView: function(map){
setFitView: function (map) {
this.map.setFitView();
},
bindClickEvent(){
bindClickEvent() {
},
// 创建位置点弹框
createActiveInfo(info) {
let msg = '报警'
// 激活
if(info.type == 1){
msg = '激活'
}
createActiveInfo(info) {
let msg = '报警'
// 激活
if (info.type == 1) {
msg = '激活'
}
// 定位
if(info.type == 2){
msg = '定位'
}
// 定位
if (info.type == 2) {
msg = '定位'
}
return `<h3 class="map-infowindow-title">${info.name||'--'}/${info.standNo||'--'}</h3>
return `<h3 class="map-infowindow-title">${info.name || '--'}/${info.standNo || '--'}</h3>
<div class="map-infowindow-ct">
<p><i class="icon icon-info_device"></i> 设备号: <span class="des">${info.sn} (${info.source == 1?'有线':'无线'})</span></p>
<p><i class="icon icon-info_device"></i> 设备号: <span class="des">${info.sn} (${info.source == 1 ? '有线' : '无线'})</span></p>
<p><i class="icon icon-info_time"></i>${msg}时间: <span class="des"data-time>${info.time}</span></p>
<div style="display:${info.bsLng?'block':'none'}"><i class="icon icon-info_type"></i>定位类型: <a class="locate-btn active" id="locateTypeGps">GPS</a><a class="locate-btn" id="locateTypeBase">基站</a></div>
<div style="display:${info.bsLng ? 'block' : 'none'}"><i class="icon icon-info_type"></i>定位类型: <a class="locate-btn active" id="locateTypeGps">GPS</a><a class="locate-btn" id="locateTypeBase">基站</a></div>
<p><i class="icon icon-info_location"></i> ${msg}地址: <span class="des" data-transferAddress>${info.address}</span></p>
</div>`
},
},
// 位置点弹框
bindActiveLocationInfoWindow(marker, map, info) {
var self = this
var infoDiv = document.createElement('div')
infoDiv.innerHTML = self.createActiveInfo(info)
// gps位置信息
function fillGPS(){
infoDiv.querySelector('[data-time]').textContent = info.time;
infoDiv.querySelector('[data-transferAddress]').textContent = info.address;
infoDiv.querySelector('#locateTypeGps').classList.add('active');
infoDiv.querySelector('#locateTypeBase').classList.remove('active');
marker.setPosition(self.getLngLat(info.lng, info.lat));
self.setFitView()
marker.infoWindow && marker.infoWindow.open(map, marker.getPosition());
}
bindActiveLocationInfoWindow(marker, map, info) {
var self = this
var infoDiv = document.createElement('div')
infoDiv.innerHTML = self.createActiveInfo(info)
// gps位置信息
function fillGPS() {
infoDiv.querySelector('[data-time]').textContent = info.time;
infoDiv.querySelector('[data-transferAddress]').textContent = info.address;
infoDiv.querySelector('#locateTypeGps').classList.add('active');
infoDiv.querySelector('#locateTypeBase').classList.remove('active');
marker.setPosition(self.getLngLat(info.lng, info.lat));
self.setFitView()
marker.infoWindow && marker.infoWindow.open(map, marker.getPosition());
}
// 基站位置信息
function fillBase(){
infoDiv.querySelector('[data-time]').textContent = info.bsTime;
infoDiv.querySelector('[data-transferAddress]').textContent = info.bsAddress;
infoDiv.querySelector('#locateTypeGps').classList.remove('active');
infoDiv.querySelector('#locateTypeBase').classList.add('active');
marker.setPosition(self.getLngLat(info.bsLng, info.bsLat));
self.setFitView()
marker.infoWindow && marker.infoWindow.open(map, marker.getPosition());
}
// 基站位置信息
function fillBase() {
infoDiv.querySelector('[data-time]').textContent = info.bsTime;
infoDiv.querySelector('[data-transferAddress]').textContent = info.bsAddress;
infoDiv.querySelector('#locateTypeGps').classList.remove('active');
infoDiv.querySelector('#locateTypeBase').classList.add('active');
marker.setPosition(self.getLngLat(info.bsLng, info.bsLat));
self.setFitView()
marker.infoWindow && marker.infoWindow.open(map, marker.getPosition());
}
infoDiv.querySelector('#locateTypeGps').onclick = function(e){
fillGPS()
}
infoDiv.querySelector('#locateTypeBase').onclick = function(e){
fillBase()
}
infoDiv.querySelector('#locateTypeGps').onclick = function (e) {
fillGPS()
}
infoDiv.querySelector('#locateTypeBase').onclick = function (e) {
fillBase()
}
if(info.lng){
fillGPS()
}
if (info.lng) {
fillGPS()
}
if(!info.lng && info.bsLng){
fillBase()
}
if (!info.lng && info.bsLng) {
fillBase()
}
return this.createActiveInfoWindow(marker, map, infoDiv)
},
// 创建位置点弹框
createActiveInfoWindow(marker, map, div, isInfoOpen, isInfoAutoMove) {
var infoWindow = new AMap.InfoWindow({
offset: new AMap.Pixel(0, 0),
content: div,
autoMove: !!isInfoAutoMove,
})
console.log(infoWindow)
marker.infoWindow = infoWindow
if (isInfoOpen) {
infoWindow.open(map, marker.getPosition())
}
return this.createActiveInfoWindow(marker, map, infoDiv)
},
// 创建位置点弹框
createActiveInfoWindow(marker, map, div, isInfoOpen, isInfoAutoMove) {
var infoWindow = new AMap.InfoWindow({
offset: new AMap.Pixel(0, 0),
content: div,
autoMove: !!isInfoAutoMove,
})
console.log(infoWindow)
marker.infoWindow = infoWindow
if (isInfoOpen) {
infoWindow.open(map, marker.getPosition())
}
//给Marker绑定单击事件
marker.on('click', markerClick)
//给Marker绑定单击事件
marker.on('click', markerClick)
function markerClick(e) {
//infoWindow.setContent(e.target.content);
infoWindow.open(map, e.target.getPosition())
}
return infoWindow
},
function markerClick(e) {
//infoWindow.setContent(e.target.content);
infoWindow.open(map, e.target.getPosition())
// 页面跳转,打开新窗口
openPage(path) {
vue.prototype.$parentCommon.setBreadCrumbs(path);
window.open(path)
}
return infoWindow
},
}
const mapService = new MapService();
......
......@@ -194,7 +194,7 @@ const monitor = {
});
//mapService.setFitView(MAP);
mapService.setFitView(MAP);
this.allData = this.allData.concat(data);
EventBus.$emit('uiMap.monitor.drawDone');
if(this.isCompare){
......
import Vue from 'vue'
const EventBus = new Vue()
import { Message, MessageBox, Loading } from 'element-ui'
import moment from 'moment'
let loadingInstance = ''
export const Util = {
/**
* 简单alert
* title 标题
* message 内容
* className 自定义class
* showCancelButton 是否展示取消按钮
* confirmButtonText 确认按钮文案
* cancelButtonText 取消按钮文案
* confirmButtonColor 确认按钮颜色
* cancelButtonColor 取消按钮颜色
* type: success / info / warning / error
*/
msg: function (options) {
MessageBox({
title: options.title || '',
type: options.type || 'error',
message: options.message || '',
className: options.className || '',
showCancelButton: options.showCancelButton || false,
confirmButtonText: options.confirmButtonText || '确认',
cancelButtonText: options.cancelButtonText || '取消',
confirmButtonColor: options.confirmButtonColor || '#1989fa',
cancelButtonColor: options.cancelButtonColor || '#000',
dangerouslyUseHTMLString: true,
center: options.center || false,
callback: function (action, done) {
if (action == 'confirm') {
if (options.success) {
options.success(done)
}
} else {
console.log(done)
//done.close()
}
},
})
/* Vue.$vux.alert.show({
title: options.title||'',
content: options.message||'',
onShow() {
options.onShow?(options.onShow)():'';
},
onHide() {
options.onHide?(options.onHide)():'';
}
}) */
},
/**
* 提示框
*/
Info: function (options) {
Message({
message: options.message || '提示',
type: options.type || 'error',
duration: options.time || 2000,
onClose: options.onClose || '',
})
},
/**
* 轻提示
*/
Tips: function (options) {
Message({
message: options.message || '提示',
duration: options.duration || 3000,
type: options.type || 'text',
icon: options.icon || '',
})
},
/**
* loading
*/
loading: function (message) {
loadingInstance = Loading.service({
text: message || '加载中...',
})
},
/**
* 关闭loading
*/
closeLoading: function () {
loadingInstance.close()
},
/**
* 校验手机号码格式
*/
checkPhone: function (mobile) {
let myreg = /^(13[0-9]|15[0-9]|16[0-9]|17[0-9]|18[0-9]|19[0-9]|14[0-9])[0-9]{8}$/
return myreg.test(mobile)
},
/**
* 校验固定电话
*/
validationTel: function (tel) {
let reg = /^0[\d]{2,3}-[\d]{7,8}$/
return reg.test(tel)
},
/**
* 是否特殊字符
*/
isSpecialLetter: function (str) {
let reg = new RegExp(
"[`~!@#$^&*=|{}':;',\\[\\]<>?~!@#¥……&*——|{}【】‘;:”“'。,、? ]"
)
return reg.test(str)
},
/**
* 获取当前时间
*/
getCurrentDate: function () {
let time = new Date()
let y = time.getFullYear()
let m = time.getMonth() + 1
let d = time.getDate()
return {
date: y + '/' + m + '/' + d,
}
},
/**
* 获取浏览器参数
*/
getUrlParams: function (name) {
let vars = [],
hash
let oParams = {}
let hashes = window.location.href
.slice(window.location.href.indexOf('?') + 1)
.split('&')
for (let i = 0; i < hashes.length; i++) {
hash = hashes[i].split('=')
vars.push(hash[0])
oParams[hash[0]] = hash[1]
}
console.log(vars)
if (name) {
return oParams[name]
} else {
return oParams
}
},
/**
* 根据当前时间,计算往后30天的日期
*/
getAfterDate: function (day) {
let date1 = new Date()
let date2 = new Date(date1)
let time = 30
if (day) {
time = day
}
date2.setDate(date1.getDate() + time)
let _date =
date2.getFullYear() + '-' + (date2.getMonth() + 1) + '-' + date2.getDate()
return {
date: _date,
year: date2.getFullYear(),
month: date2.getMonth() + 1,
day: date2.getDate(),
}
},
/**
* 日期格式转换
*/
dateFormate: function (str, type) {
let txt = 'YYYY-MM-DD'
if (!str) {
return ''
}
if (type) {
txt = type
}
const m = moment(str).format(txt)
return m
},
/**
* 字段截取
*/
cutStr: function (str, num) {
if (!str) {
return ''
}
let m = 10
let n = str
if (num) {
m = num
}
if (str.length > m) {
n = str.slice(0, m) + '...'
}
return n
},
/**
* 深克隆 所有原型链上的对象和属性
* 例: const bar=deepClone(foo)
* console.log(bar===foo) false
* @param {*} obj
*/
deepClone: function (obj) {
// Handle the 3 simple types, and null or undefined or function
if (obj == null || typeof obj !== 'object') return obj
// Handle Date
if (obj instanceof Date) {
const copy = new Date()
copy.setTime(obj.getTime())
return copy
}
// Handle Array or Object
if ((obj instanceof Array) | (obj instanceof Object)) {
const copy = obj instanceof Array ? [] : {}
for (var attr in obj) {
if (obj.hasOwnProperty(attr)) {
copy[attr] = Util.deepClone(obj[attr])
}
}
return copy
}
throw new Error("Unable to clone obj! Its type isn't supported.")
},
// 传递消息
broadcast: function (msg, data) {
EventBus.$emit(msg, data)
},
// 接收消息
received: function (msg, callBack) {
EventBus.$off(msg)
EventBus.$on(msg, function (row) {
callBack(row)
})
},
}
// 通过url下载文件
export const downFileByPath = function(url){
if (!url) {
return false;
};
// let link = document.createElement('a')
// link.style.display = 'none'
// link.src = url
// link.target = '_blank'
// document.body.appendChild(link);
// link.click();
window.location.href = url
}
export const showModal = Util.msg
export const showToast = Util.Info
export const showLoading = Util.loading
export const hideLoading = Util.closeLoading
export const deepClone = Util.deepClone
// export const broadcast = Util.broadcast
// export const received = Util.received
......@@ -84,6 +84,7 @@ const mutations = {
[types.vehicleGenerate](state, data) {
state.vehicleGenerate = data
},
}
......
Markdown is supported
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!