Commit fd33c9ed by zhangxw
2 parents 2df94fd2 589c39eb
...@@ -15,6 +15,13 @@ ...@@ -15,6 +15,13 @@
"libraryName": "element-ui", "libraryName": "element-ui",
"styleLibraryName": "theme-chalk" "styleLibraryName": "theme-chalk"
} }
],
[
"import",
{
"libraryName": "vxe-table",
"style": true // 样式是否也按需加载
}
] ]
] ]
} }
...@@ -34,7 +34,7 @@ module.exports = { ...@@ -34,7 +34,7 @@ module.exports = {
}, },
externals: { externals: {
vue: 'Vue', vue: 'Vue',
'element-ui': 'ElementUI' //'element-ui': 'ElementUI'
}, },
module: { module: {
rules: [ rules: [
...@@ -90,6 +90,7 @@ module.exports = { ...@@ -90,6 +90,7 @@ module.exports = {
test: /\.(png|jpg|gif|svg)$/, test: /\.(png|jpg|gif|svg)$/,
loader: 'file-loader', loader: 'file-loader',
options: { options: {
limit: 10000,
name: 'images/[name].[ext]?[hash]', name: 'images/[name].[ext]?[hash]',
publicPath: resourcesPath publicPath: resourcesPath
} }
......
This diff could not be displayed because it is too large.
...@@ -11,6 +11,7 @@ ...@@ -11,6 +11,7 @@
"build": "cross-env NODE_ENV=production webpack --progress --hide-modules --config config/webpack.config.js" "build": "cross-env NODE_ENV=production webpack --progress --hide-modules --config config/webpack.config.js"
}, },
"dependencies": { "dependencies": {
"@amap/amap-jsapi-loader": "^1.0.1",
"animate.css": "^3.7.0", "animate.css": "^3.7.0",
"axios": "^0.18.0", "axios": "^0.18.0",
"calendar-months": "^1.0.1", "calendar-months": "^1.0.1",
...@@ -22,14 +23,16 @@ ...@@ -22,14 +23,16 @@
"es6-promise": "^4.2.4", "es6-promise": "^4.2.4",
"font-awesome": "^4.7.0", "font-awesome": "^4.7.0",
"moment": "^2.22.0", "moment": "^2.22.0",
"node-sass": "^7.0.1",
"qs": "^6.5.1", "qs": "^6.5.1",
"sass": "^1.45.1",
"vue": "^2.5.11", "vue": "^2.5.11",
"vue-infinite-loading": "^2.3.1", "vue-infinite-loading": "^2.3.1",
"vue-router": "^3.0.1", "vue-router": "^3.0.1",
"vue-template-compiler": "^2.6.14",
"vuex": "^3.0.1", "vuex": "^3.0.1",
"xlsx": "^0.14.0", "vxe-table": "^3.5.5",
"node-sass":"7.0.1" "xe-utils": "^3.5.4",
"xlsx": "^0.14.0"
}, },
"browserslist": [ "browserslist": [
"> 1%", "> 1%",
...@@ -60,7 +63,6 @@ ...@@ -60,7 +63,6 @@
"url-loader": "^1.0.1", "url-loader": "^1.0.1",
"vue-loader": "^14.2.2", "vue-loader": "^14.2.2",
"vue-style-loader": "^4.1.0", "vue-style-loader": "^4.1.0",
"vue-template-compiler": "^2.5.16",
"webpack": "^4.6.0", "webpack": "^4.6.0",
"webpack-bundle-analyzer": "^2.11.1", "webpack-bundle-analyzer": "^2.11.1",
"webpack-cli": "^2.0.14", "webpack-cli": "^2.0.14",
......
...@@ -25,26 +25,26 @@ ...@@ -25,26 +25,26 @@
</template> </template>
<script> <script>
import store from './vuex/store.js' import store from "./vuex/store.js";
import { mapGetters, mapActions } from 'vuex' import { mapGetters, mapActions } from "vuex";
import vSideBar from 'components/SideBar.vue' import vSideBar from "components/SideBar.vue";
export default { export default {
name: 'app', name: "app",
data() { data() {
return { return {
isQiankun: window.__POWERED_BY_QIANKUN__, isQiankun: window.__POWERED_BY_QIANKUN__,
logo: require('images/logo.png') logo: require("images/logo.png"),
} };
}, },
watch: { watch: {
$route(to, from) { $route(to, from) {
if(this.isQiankun) { if (this.isQiankun) {
this.getBreadcrumb(); this.getBreadcrumb();
} }
}
}, },
mounted(){ },
mounted() {
// store.dispatch('getDeviceResources') // store.dispatch('getDeviceResources')
// store.dispatch('getLoginUser').then((res)=>{ // store.dispatch('getLoginUser').then((res)=>{
// if(store.state.common.username === 'gqgdcx'){ // if(store.state.common.username === 'gqgdcx'){
...@@ -67,85 +67,102 @@ export default { ...@@ -67,85 +67,102 @@ export default {
// } // }
// window.onresize() // window.onresize()
this.$onGlobalStateChange((state, prev) => { this.$onGlobalStateChange((state, prev) => {
if(state.isCollapsed != this.isCollapse) { if (state.isCollapsed != this.isCollapse) {
this.toggleCollapse() this.toggleCollapse();
} }
});
})
}, },
computed: { computed: {
...mapGetters([ ...mapGetters(["isCollapse", "isFullsize"]),
'isCollapse',
'isFullsize'
])
}, },
methods: { methods: {
getBreadcrumb() { getBreadcrumb() {
const { getters: {curBreadCrumb}} = this.$root.parentVuex; const {
let matched = this.$route.matched.filter(item => item.name); // this.$route.matched 可以获取到一个数组,包含当前路由的所有嵌套路径片段的路由记录 getters: { curBreadCrumb },
} = this.$root.parentVuex;
let matched = this.$route.matched.filter((item) => item.name); // this.$route.matched 可以获取到一个数组,包含当前路由的所有嵌套路径片段的路由记录
const first = matched[0]; const first = matched[0];
const { meta, path } = first; const { meta, path } = first;
const basePath = '/oEshield#'; const basePath = "/oEshield#";
let breadcrumb = []; let breadcrumb = [];
if(meta) { if (meta) {
const { title, pushState } = meta; const { title, pushState } = meta;
if(pushState && title) { if (pushState && title) {
breadcrumb.push({ breadcrumb.push({
name: title, name: title,
path: basePath + path path: basePath + path,
}) });
history.state.pushState = pushState; history.state.pushState = pushState;
history.state.breadcrumb = [...curBreadCrumb, breadcrumb[0]]; history.state.breadcrumb = [...curBreadCrumb, breadcrumb[0]];
// this.$root.parentVuex.dispatch('menu/setBreadCrumb', [...curBreadCrumb, breadcrumb]); // this.$root.parentVuex.dispatch('menu/setBreadCrumb', [...curBreadCrumb, breadcrumb]);
} }
} }
}, },
toggle(){ toggle() {
this.toggleCollapse() this.toggleCollapse();
}, },
...mapActions([ ...mapActions(["toggleCollapse"]),
'toggleCollapse' navigate() {
]),
navigate(){
let routeData = this.$router.resolve({ let routeData = this.$router.resolve({
path: '/notice', path: "/notice",
query: { query: {},
}
}); });
window.open(routeData.href, '_blank'); window.open(routeData.href, "_blank");
} },
}, },
components: { components: {
vSideBar vSideBar,
}, },
store store,
} };
</script> </script>
<style scoped> <style scoped>
.topbar { .topbar {
min-height: 50px; min-height: 50px;
padding: 15px 10px; padding: 15px 10px;
} }
.toggle-btn, .logo{ .toggle-btn,
.logo {
vertical-align: middle; vertical-align: middle;
} }
.logo{ .logo {
margin-left: 10px; margin-left: 10px;
} }
a.right-link{ a.right-link {
color: #999; color: #999;
font-size: 14px; font-size: 14px;
margin-right: 20px; margin-right: 20px;
line-height: 30px; line-height: 30px;
text-decoration: none; text-decoration: none;
} }
.full-size main{ .full-size main {
margin: 0; margin: 0;
} }
.full-size .sidebar, .full-size .topbar{ .full-size .sidebar,
.full-size .topbar {
display: none; display: none;
}
</style>
<style lang="scss">
.el_table {
thead {
th {
background: rgba($color: #f2f2f2, $alpha: 0.5) !important;
}
} }
}
.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> </style>
import api from '../config.js' import api from '../config.js'
import request from './request'
export default { export default {
getLoginUser (request = {}) { getLoginUser(request = {}) {
return api.get('common/getLoginUser', request) return api.get('common/getLoginUser', request)
}, },
...@@ -11,7 +12,7 @@ export default { ...@@ -11,7 +12,7 @@ export default {
}, },
/*车辆品牌*/ /*车辆品牌*/
getAllVehicleBrand (request = {}) { getAllVehicleBrand(request = {}) {
return api.get('vehicle/getAllVehicleBrand', request) return api.get('vehicle/getAllVehicleBrand', request)
}, },
getBrandTypeByBrandId(request = {}) { getBrandTypeByBrandId(request = {}) {
...@@ -19,15 +20,21 @@ export default { ...@@ -19,15 +20,21 @@ export default {
}, },
/*车辆分组分类*/ /*车辆分组分类*/
getAllVehicleGroup (request = {}) { getAllVehicleGroup(request = {}) {
return api.get('vehiclegroup/getAllVehicleGroup', request) return api.get('vehiclegroup/getAllVehicleGroup', request)
}, },
getClassListByGroupId (request = {}) { getClassListByGroupId(request = {}) {
return api.get('vehicleclass/getClassListByGroupId', request) return api.get('vehicleclass/getClassListByGroupId', request)
}, },
/*获取菜单权限*/ /*获取菜单权限*/
getDeviceResources (request = {}) { getDeviceResources(request = {}) {
return api.get('user/userDeviceResources', 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 \ 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 \ No newline at end of file
...@@ -142,3 +142,13 @@ export default { ...@@ -142,3 +142,13 @@ export default {
export const GET_DEVICEINFO_BYSNS = params => { export const GET_DEVICEINFO_BYSNS = params => {
return request(params, '/trialdrive/monitor/vehiclelocation') 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 \ 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 \ No newline at end of file
This diff could not be displayed because it is too large.
...@@ -6,13 +6,14 @@ ...@@ -6,13 +6,14 @@
margin: 0; margin: 0;
//background-color: #f3f3f4; //background-color: #f3f3f4;
/*min-height: 949px; /*min-height: 949px;
*/position: relative; */
position: relative;
-webkit-transition: margin .1s linear; -webkit-transition: margin .1s linear;
transition: margin .1s linear; transition: margin .1s linear;
-moz-transition: margin .1s linear; -moz-transition: margin .1s linear;
-ms-transition: margin .1s linear; -ms-transition: margin .1s linear;
-o-transition: margin .1s linear; -o-transition: margin .1s linear;
} }
.sidebar { .sidebar {
position: absolute; position: absolute;
...@@ -23,9 +24,11 @@ ...@@ -23,9 +24,11 @@
-webkit-transition: width .1s linear; -webkit-transition: width .1s linear;
transition: width .1s linear; transition: width .1s linear;
font-size: 13px !important; font-size: 13px !important;
* { * {
font-size: 13px !important; font-size: 13px !important;
} }
color:#a7b1c2; color:#a7b1c2;
} }
...@@ -36,13 +39,15 @@ ...@@ -36,13 +39,15 @@
/* -webkit-transition: margin .3s linear; /* -webkit-transition: margin .3s linear;
transition: margin .3s linear; */ transition: margin .3s linear; */
} }
.sidebar { .sidebar {
width: 64px; width: 64px;
/* -webkit-transition: width .3s linear; /* -webkit-transition: width .3s linear;
transition: width .3s linear; */ transition: width .3s linear; */
} }
.nav-footer{
.nav-footer {
display: none; display: none;
} }
} }
...@@ -69,33 +74,38 @@ ...@@ -69,33 +74,38 @@
.el-popper[x-placement^="bottom"] { .el-popper[x-placement^="bottom"] {
margin-top: 2px; margin-top: 2px;
} }
.el-input.is-disabled .el-input__inner{
.el-input.is-disabled .el-input__inner {
color: #666; color: #666;
} }
/* .el-table--scrollable-x .el-table__body-wrapper{解决被遮挡 /* .el-table--scrollable-x .el-table__body-wrapper{解决被遮挡
z-index: 100; z-index: 100;
} */ } */
.el-date-editor{ .el-date-editor {
vertical-align: middle; vertical-align: middle;
} }
.table-header-ctrl { .table-header-ctrl {
margin: 0px; margin: 0px;
min-height: 70px; min-height: 70px;
.el-input, .el-input,
.el-date-editor, .el-date-editor,
.el-select { .el-select {
width: 100%; width: 100%;
} }
.el-input__suffix { .el-input__suffix {
right: 15px; right: 15px;
} }
input{ input {
border-radius: 0px; border-radius: 0px;
} }
.el-date-editor{
.el-date-editor {
border-radius: 0px; border-radius: 0px;
margin-top: 7px; margin-top: 7px;
} }
...@@ -103,6 +113,7 @@ ...@@ -103,6 +113,7 @@
td.ctrl-column { td.ctrl-column {
padding-left: 50px; padding-left: 50px;
.el-dropdown { .el-dropdown {
margin-top: 5px; margin-top: 5px;
} }
...@@ -120,37 +131,62 @@ td.ctrl-column { ...@@ -120,37 +131,62 @@ td.ctrl-column {
.el-table th>.cell { .el-table th>.cell {
color: #666; color: #666;
} }
.pull-right{
.pull-right {
float: right; float: right;
} }
.pull-left{
.pull-left {
float: left; float: left;
} }
.text-center{
.text-center {
text-align: center; text-align: center;
} }
.table-page-wrap{
.table-page-wrap {
float: right; float: right;
margin: 20px 0px; margin: 20px 0px;
} }
.el-message{//避免被el-dialog遮罩层遮住
.el-message {
//避免被el-dialog遮罩层遮住
z-index: 3000 !important; z-index: 3000 !important;
} }
.el-tree .device-invalid{ .el-tree .device-invalid {
color: #999; color: #999;
} }
.el-tree-node:focus > .el-tree-node__content{
.el-tree-node:focus>.el-tree-node__content {
background-color: inherit; background-color: inherit;
} }
#editOrderModal #color .el-form-item__label{
#editOrderModal #color .el-form-item__label {
color: red !important; color: red !important;
} }
.el-alert--success { .el-alert--success {
background-color: #f0f9eb; background-color: #f0f9eb;
color: #67c23a; color: #67c23a;
} }
.el-alert--error { .el-alert--error {
background-color: #fef0f0; background-color: #fef0f0;
color: #f56c6c; 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 \ No newline at end of file
...@@ -34,7 +34,10 @@ h3.uimap-info-title{ ...@@ -34,7 +34,10 @@ h3.uimap-info-title{
word-break: break-all; word-break: break-all;
} }
.amap-controls{ .amap-controls{
display: none; //display: none;
}
.amap-logo,.amap-copyright{
display: none !important;
} }
.navg-info-window{ .navg-info-window{
background-color: #fff; background-color: #fff;
......
.map-wrap{ .map-wrap {
// position: absolute; // position: absolute;
// top: 100px; // top: 100px;
// left: 0; // left: 0;
...@@ -6,31 +6,36 @@ ...@@ -6,31 +6,36 @@
height: calc(100% - 100px); height: calc(100% - 100px);
overflow: hidden; overflow: hidden;
.map-controll{ .map-controll {
position: absolute; position: absolute;
top: 40px; top: 40px;
right: 250px; right: 250px;
z-index: 102; z-index: 102;
.fullsize-btn{
.fullsize-btn {
margin-left: 20px; margin-left: 20px;
} }
} }
.map-bottom-controll{
.map-bottom-controll {
position: absolute; position: absolute;
bottom: 30px; bottom: 30px;
right: 20px; right: 20px;
z-index: 102; z-index: 102;
ul{
ul {
border: 1px solid #eee; border: 1px solid #eee;
color: #094; color: #094;
} }
.ctrl-item{
.ctrl-item {
background-color: #fff; background-color: #fff;
padding: 6px 10px; padding: 6px 10px;
font-size: 16px; font-size: 16px;
} }
} }
.controll-wrap{
.controll-wrap {
position: absolute; position: absolute;
top: 40px; top: 40px;
left: 40px; left: 40px;
...@@ -38,40 +43,49 @@ ...@@ -38,40 +43,49 @@
width: 320px; width: 320px;
max-height: 716px; max-height: 716px;
} }
.menu-search{
.el-select{ .menu-search {
.el-select {
width: 100px; width: 100px;
} }
.input-with-select{
.input-with-select {
width: 100%; width: 100%;
} }
.el-input-group__append{
.el-input-group__append {
background: #094; background: #094;
border-color: #094; border-color: #094;
color: #fff; color: #fff;
font-size: 16px; font-size: 16px;
} }
.el-input-group__append:hover, .el-input-group__append:focus {
.el-input-group__append:hover,
.el-input-group__append:focus {
background: #33ad69; background: #33ad69;
border-color: #33ad69; border-color: #33ad69;
} }
} }
.filter-entrance{
.filter-entrance {
margin-top: 10px; margin-top: 10px;
background-color: rgba(255,255,255,0.9); background-color: rgba(255, 255, 255, 0.9);
//border: 1px solid #dcdfe6; //border: 1px solid #dcdfe6;
box-shadow: 1px 1px 5px #dcdfe6; box-shadow: 1px 1px 5px #dcdfe6;
.el-button{
.el-button {
padding: 6px; padding: 6px;
} }
} }
.filter-dialog-set{
.filter-dialog-set {
margin-top: 10px; margin-top: 10px;
height: 100%; height: 100%;
position: relative; position: relative;
} }
.filter-dialog{
.filter-dialog {
position: absolute; position: absolute;
top: 0; top: 0;
left: 0; left: 0;
...@@ -79,188 +93,223 @@ ...@@ -79,188 +93,223 @@
background-color: #fff; background-color: #fff;
border: 1px solid #dcdfe6; border: 1px solid #dcdfe6;
box-sizing: border-box; box-sizing: border-box;
.filter-dialog-header{
.filter-dialog-header {
text-align: center; text-align: center;
padding: 8px; padding: 8px;
border-bottom: 1px solid #eee; border-bottom: 1px solid #eee;
.el-icon-close{
.el-icon-close {
font-size: 16px; font-size: 16px;
cursor: pointer; cursor: pointer;
} }
} }
.filter-dialog-body{
.filter-dialog-body {
padding: 15px; padding: 15px;
.upload-wrap{
.el-select{ .upload-wrap {
.el-select {
width: 100px; width: 100px;
} }
.input-with-select{
.input-with-select {
width: 100%; width: 100%;
} }
} }
} }
.upload-sure-btn{
.upload-sure-btn {
width: 100%; width: 100%;
} }
animation-duration: .5s; animation-duration: .5s;
animation-delay: 0s; animation-delay: 0s;
display: none; display: none;
&.active{ &.active {
display: block display: block
} }
.sub-filter{ .sub-filter {
padding-bottom: 15px; padding-bottom: 15px;
border-bottom: 1px solid #eee; border-bottom: 1px solid #eee;
} }
.monitor-list{
.monitor-list {
max-height: calc(100vh - 280px); max-height: calc(100vh - 280px);
/* max-height: 568px; */ /* max-height: 568px; */
overflow: auto; overflow: auto;
margin-right: -10px; margin-right: -10px;
padding-right: 10px; padding-right: 10px;
} }
.monitor-list-item{
.monitor-list-item {
display: flex; display: flex;
border-bottom: 1px solid #eee; border-bottom: 1px solid #eee;
.user-info{
.user-info {
flex: 1; flex: 1;
color: #666; color: #666;
&>p{
&>p {
margin: 8px 0; margin: 8px 0;
} }
.name{
.name {
color: #333; color: #333;
margin-right: 15px; margin-right: 15px;
} }
} }
&:last-child{
&:last-child {
border-bottom: none; border-bottom: none;
} }
.device-icon{
.device-icon {
margin-right: 5px; margin-right: 5px;
margin-top: 12px; margin-top: 12px;
} }
} }
.device-icon-label{
.device-icon-label {
display: inline-block; display: inline-block;
margin-left: 5px; margin-left: 5px;
} }
.device-icon{
.device-icon {
display: inline-block; display: inline-block;
vertical-align: middle; vertical-align: middle;
width: 8px; width: 8px;
height: 8px; height: 8px;
border-radius: 5px; border-radius: 5px;
background-color: rgba(0,153,68,0.8); background-color: rgba(0, 153, 68, 0.8);
&.offline{ &.offline {
background-color: rgba(255,0,0,0.8); background-color: rgba(255, 0, 0, 0.8);
} }
} }
.filter-dialog-footer{ .filter-dialog-footer {
border-top: 1px solid #eee; border-top: 1px solid #eee;
padding: 10px; padding: 10px;
span{
span {
vertical-align: middle; vertical-align: middle;
} }
} }
} }
.search-box{ .search-box {
.date-filter{ .date-filter {
position: absolute; position: absolute;
top: 0px; top: 0px;
right: 0px; right: 0px;
} }
.el-form--inline .el-form-item{
.el-form--inline .el-form-item {
margin-right: 0px; margin-right: 0px;
} }
.stay-ctrl{ .stay-ctrl {
margin-top: 5px; margin-top: 5px;
input{
input {
width: 100%; width: 100%;
} }
.el-form-item{
.el-form-item {
margin-bottom: 0px; margin-bottom: 0px;
} }
.unit{
.unit {
line-height: 30px; line-height: 30px;
margin-left: 10px; margin-left: 10px;
} }
} }
.el-range-editor--mini .el-range-input{
.el-range-editor--mini .el-range-input {
width: 115px; width: 115px;
} }
.el-form-item{
.el-form-item {
margin-bottom: 15px; margin-bottom: 15px;
} }
.submit-el-form-item{
.submit-el-form-item {
margin-top: 20px; margin-top: 20px;
} }
} }
.search-box, .result-box{
.search-box,
.result-box {
padding: 20px; padding: 20px;
background: #fff; background: #fff;
box-shadow: 1px 1px 4px #ccc; box-shadow: 1px 1px 4px #ccc;
display: none; display: none;
} }
.search-box.active, .result-box.active{
.search-box.active,
.result-box.active {
display: block; display: block;
} }
.result-box{ .result-box {
/* height: 100%; /* height: 100%;
max-height: 660px; */ max-height: 660px; */
padding: 0px; padding: 0px;
.result-box-head{
.result-box-head {
text-align: center; text-align: center;
border-bottom: 1px solid #ddd; border-bottom: 1px solid #ddd;
padding: 10px 15px; padding: 10px 15px;
&>*{ &>* {
vertical-align: middle; vertical-align: middle;
} }
} }
.result-box-filter{ .result-box-filter {
font-size: 0px; font-size: 0px;
padding: 5px 0px; padding: 5px 0px;
border-bottom: 1px solid #eee; border-bottom: 1px solid #eee;
.el-button{
.el-button {
font-size: 13px; font-size: 13px;
padding: 2px 10px; padding: 2px 10px;
margin: 0; margin: 0;
&:first-child{
&:first-child {
border-right: 1px solid #eee; border-right: 1px solid #eee;
} }
i{
i {
margin: 0 3px; margin: 0 3px;
} }
} }
} }
.stay-list{
.stay-list {
/* height: calc(100% - 70px); */ /* height: calc(100% - 70px); */
max-height: calc(100vh - 200px); max-height: calc(100vh - 200px);
overflow-y: auto; overflow-y: auto;
} }
.stay-list-item{
.stay-list-item {
line-height: 1.5; line-height: 1.5;
padding: 10px 15px; padding: 10px 15px;
border-bottom: 1px solid #eee; border-bottom: 1px solid #eee;
p{
p {
margin: 0px; margin: 0px;
} }
.datetime{ .datetime {
font-size: 13px; font-size: 13px;
color: #666; color: #666;
} }
...@@ -268,7 +317,7 @@ ...@@ -268,7 +317,7 @@
} }
} }
.replay-player{ .replay-player {
max-width: 400px; max-width: 400px;
position: absolute; position: absolute;
top: 20px; top: 20px;
...@@ -277,123 +326,156 @@ ...@@ -277,123 +326,156 @@
background: #fff; background: #fff;
padding: 5px 10px; padding: 5px 10px;
margin-top: 10px; margin-top: 10px;
.el-progress{
.el-progress {
display: inline-block; display: inline-block;
width: 200px; width: 200px;
margin: 0; margin: 0;
height: 10px; height: 10px;
border-radius: 0; border-radius: 0;
} }
&>a{
&>a {
margin: 0 5px; margin: 0 5px;
cursor: pointer; cursor: pointer;
&:hover{
&:hover {
color: #094; color: #094;
} }
} }
} }
.row-form-item .el-form-item__label{ .row-form-item .el-form-item__label {
float: none; float: none;
} }
} }
.full-width .map-wrap{
.full-width .map-wrap {
// top: 0px; // top: 0px;
height: 100%; height: 100%;
} }
.map-container{
.map-container {
width: 100%; width: 100%;
height: 100%; height: 100%;
z-index: 100; z-index: 100;
} }
.el-loading-mask{
.el-loading-mask {
z-index: 500; z-index: 500;
} }
.map-infowindow-ct{
&>p{ .map-infowindow-ct {
&>p {
display: flex; display: flex;
} }
.lb{
} .lb {}
.des{
.des {
flex: 1; flex: 1;
word-break: break-all; word-break: break-all;
} }
.icon{
.icon {
margin-right: 5px; margin-right: 5px;
} }
.battery{
.battery {
position: relative; position: relative;
width: 42px; width: 42px;
height: 20px; height: 20px;
i{
i {
position: absolute; position: absolute;
top: 0; top: 0;
left: 0; left: 0;
width: 100%; width: 100%;
height: 100%; height: 100%;
} }
.fill{
.fill {
width: 39px; width: 39px;
} }
.fill-percentage{
.fill-percentage {
padding: 3px; padding: 3px;
box-sizing: border-box; box-sizing: border-box;
background-color: #d4f1dc; background-color: #d4f1dc;
} }
.text{
.text {
color: #37c060; color: #37c060;
font-size: 12px; font-size: 12px;
text-align: center; text-align: center;
} }
&.empty .fill-percentage{
&.empty .fill-percentage {
background-color: #f0d0d0; background-color: #f0d0d0;
} }
&.empty .fill-percentage{
&.empty .fill-percentage {
color: #df2222; color: #df2222;
} }
&.hide{ &.hide {
display: none; display: none;
} }
} }
.redirect-row{
.redirect-row {
display: flex; display: flex;
} }
a.redirect-btn{
a.redirect-btn {
flex: 1; flex: 1;
border: 1px solid rgba(0,153,68,0.8); border: 1px solid rgba(0, 153, 68, 0.8);
border-radius: 2px; border-radius: 2px;
text-align: center; text-align: center;
padding: 4px 0px; padding: 4px 0px;
color: rgba(0,153,68,0.8); color: rgba(0, 153, 68, 0.8);
margin: 2px; margin: 2px;
cursor: pointer; cursor: pointer;
&:hover{
color: rgba(0,153,68, 1); &:hover {
border-color: rgba(0,153,68, 1); color: rgba(0, 153, 68, 1);
border-color: rgba(0, 153, 68, 1);
} }
} }
a.locate-btn{
a.locate-btn {
padding: 2px 8px; padding: 2px 8px;
border: 1px solid #094; border: 1px solid #094;
border-radius: 4px 0 0 4px; border-radius: 4px 0 0 4px;
& + .locate-btn{
&+.locate-btn {
border-radius: 0 4px 4px 0; border-radius: 0 4px 4px 0;
border-left: none; border-left: none;
} }
&.active{
&.active {
background-color: #094; background-color: #094;
color: #fff; 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{ .poi_marker {
display: inline-block; display: inline-block;
width: 40px; width: 40px;
height: 48px; height: 48px;
...@@ -403,25 +485,32 @@ ...@@ -403,25 +485,32 @@
color: #fff; color: #fff;
padding-top: 2px; padding-top: 2px;
} }
.poi_infowin{
.poi_item{ .poi_infowin {
.poi_item {
display: flex; display: flex;
justify-content: space-between; justify-content: space-between;
label{
label {
color: #666; color: #666;
} }
span, input{
span,
input {
flex: 1; flex: 1;
} }
input{
input {
border: 1px solid #ccc; border: 1px solid #ccc;
height: 22px; height: 22px;
padding: 2px 8px; padding: 2px 8px;
} }
} }
.poi_ctrl{
.poi_ctrl {
justify-content: flex-end; justify-content: flex-end;
&>a{
&>a {
display: inline-block; display: inline-block;
border: 1px solid rgba(0, 153, 68, 0.8); border: 1px solid rgba(0, 153, 68, 0.8);
border-radius: 12px; border-radius: 12px;
...@@ -432,7 +521,7 @@ ...@@ -432,7 +521,7 @@
cursor: pointer; cursor: pointer;
} }
&>a[data-delete]{ &>a[data-delete] {
border: 1px solid #dcdfe6; border: 1px solid #dcdfe6;
color: #606266; color: #606266;
} }
......
<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 \ 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 \ 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 = { export const CONSTANT = {
//ROOT: process.env.NODE_ENV === 'development'?'ots/':'', //ROOT: process.env.NODE_ENV === 'development'?'ots/':'',
API_URL: '/ots/', API_URL: '/ots/',
MAP_KEY, 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 \ No newline at end of file
import 'font-awesome/css/font-awesome.min.css' 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 Vue from 'vue'
//import ElementUI from 'element-ui'; import ElementUI from 'element-ui';
import 'animate.css/animate.min.css' import 'animate.css/animate.min.css'
import './assets/scss/style.scss' import '@/assets/scss/style.scss'
//import 'element-ui/lib/theme-chalk/index.css'; import 'element-ui/lib/theme-chalk/index.css';
import './assets/spritesmith-generated/sprite.css' import '@/assets/spritesmith-generated/sprite.css'
import Router from 'vue-router' import Router from 'vue-router'
import routes from './router' import routes from '@/router'
import './core/public-path'; import '@/core/public-path';
import actions from './core/actions'; import actions from '@/core/actions';
import vLayout from 'pages/Layout.vue' import vLayout from '@/pages/Layout.vue'
import vFullLayout from 'pages/FullWidthLayout.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('vLayout', vLayout)
Vue.component('vFullLayout',vFullLayout) 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({ // new Vue({
// el: '#app', // el: '#app',
...@@ -34,16 +41,19 @@ Vue.component('vFullLayout',vFullLayout) ...@@ -34,16 +41,19 @@ Vue.component('vFullLayout',vFullLayout)
let router = null; let router = null;
let instance = null; let instance = null;
function render({ data = {} , container } = {}) { function render({ data = {}, container } = {}) {
router = new Router({ router = new Router({
base: window.__POWERED_BY_QIANKUN__ ? '/oEshield' : '/', base: window.__POWERED_BY_QIANKUN__ ? '/oEshield' : '/',
routes routes
}); });
store.commit('SET_BASE_URL', data.baseURL); 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({ instance = new Vue({
router, router,
store, store,
data(){ data() {
return { return {
parentRouter: data.router, parentRouter: data.router,
parentVuex: data.store, parentVuex: data.store,
......
<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 \ 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 \ No newline at end of file
...@@ -4,86 +4,68 @@ ...@@ -4,86 +4,68 @@
<el-breadcrumb-item>电子围栏</el-breadcrumb-item> <el-breadcrumb-item>电子围栏</el-breadcrumb-item>
</template> </template>
<template slot="main"> <template slot="main">
<div class="map-wrap" > <div class="map-wrap">
<div id="map" class="map-container" v-loading="mapLoading"></div> <div id="map" class="map-container" v-loading="mapLoading"></div>
<map-controll></map-controll> <map-controll></map-controll>
<div class="controll-wrap"> <div class="controll-wrap">
<div class="search-box active side_auto_h"> <el-scrollbar class="el_scrollbar">
<div class="search-box">
<h3>电子围栏</h3> <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 ref="form" :model="form" :rules="rules" size="mini" class="form" label-position="top">
<el-form-item label="定位方式"> <el-form-item label="定位方式">
<el-select v-model="form.locationType" placeholder="请选择" size="small" style="width: 280px"> <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="GPS" :value="1"></el-option>
<el-option label="基站" :value="2"></el-option> <el-option label="基站" :value="2"></el-option>
</el-select> </el-select>
</el-form-item> </el-form-item>
<el-form-item label="围栏名称" prop="electricFenceName"> <el-form-item label="围栏名称" prop="fenceName">
<el-input v-model.trim="form.electricFenceName" maxlength="200"></el-input> <el-input v-model.trim="form.fenceName" maxlength="200"></el-input>
</el-form-item> </el-form-item>
<el-form-item label="触发类型"> <el-form-item label="触发类型" prop="triggerType">
<el-select v-model="form.triggerType" placeholder="请选择" size="small" style="width: 280px"> <el-select v-model="form.triggerType" class="a_select" placeholder="请选择" size="small">
<el-option label="驶出" :value="2"></el-option> <el-option label="驶出" :value="2"></el-option>
<el-option label="驶入" :value="1"></el-option> <el-option label="驶入" :value="1"></el-option>
<el-option label="驶入驶出" :value="3"></el-option> <el-option label="驶入驶出" :value="3"></el-option>
</el-select> </el-select>
</el-form-item> </el-form-item>
<el-form-item label="指定区间" prop="daterange"> <el-form-item label="指定区间" prop="dateRange">
<el-date-picker <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">
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-date-picker>
</el-form-item> </el-form-item>
<el-form-item label="监控区域" class="row-form-item"> <el-form-item label="监控区域" class="row-form-item">
<el-row> <div class="el_radio_group">
<el-col :span="8"> <div class="radio_cell">
<el-radio v-model="form.shapeType" :label="2">圆形</el-radio> <el-radio :label="1" v-model="form.shapeType">圆形</el-radio>
</el-col> <el-form-item label="" prop="radius">
<el-col :span="16"> <el-input v-model.trim="form.radius" style="width: 80px;" maxlength="200" @change="changeRadius"></el-input>米
<el-form-item label="" prop="fenceRadius">
<el-input v-model.trim="form.fenceRadius" style="width: 80px;" maxlength="200"></el-input>米
</el-form-item> </el-form-item>
</el-col> </div>
</el-row> <div class="radio_cell">
<el-row> <el-radio :label="3" v-model="form.shapeType">多边形</el-radio>
<el-col :span="8"> <div class="shape_tip">*注:地图任意位置,单击新增双击结束绘制。</div>
<el-radio v-model="form.shapeType" :label="5">多边形</el-radio> </div>
</el-col> <div class="radio_cell">
<el-col :span="16" class="shape_tip">*注:地图任意位置,单击新增双击结束绘制。</el-col> <el-radio :label="4" v-model="form.shapeType">行政区域</el-radio>
</el-row> <el-form-item label="" prop="areaName">
<el-row> <city-select v-model="form.areaName" :checkStrictly="true" :disabled="form.shapeType != 4" @change="changeArea"></city-select>
<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-form-item>
</el-col> </div>
</el-row> </div>
</el-form-item> </el-form-item>
<el-form-item label="短信通知" prop="msgtel"> <el-form-item label="短信通知" prop="telNumbers">
<el-input v-model.trim="form.msgtel" maxlength="100" placeholder="输入格式:手机号码,手机号码(支持双号)"></el-input> <el-input v-model.trim="form.telNumbers" maxlength="100" placeholder="输入格式:手机号码,手机号码(支持双号)"></el-input>
</el-form-item> </el-form-item>
<el-form-item label="围栏状态"> <el-form-item label="围栏状态">
<el-radio v-model="form.status" :label="1">启用</el-radio> <el-radio v-model="form.enableStatus" :label="1">启用</el-radio>
<el-radio v-model="form.status" :label="0">停用</el-radio> <el-radio v-model="form.enableStatus" :label="0">停用</el-radio>
</el-form-item> </el-form-item>
<el-form-item> <el-form-item>
<el-button type="primary" @click="submit" size="small" :loading="isSubmitting">保存</el-button> <el-button type="primary" @click="submit" size="small" :loading="isSubmitting">保存</el-button>
</el-form-item> </el-form-item>
</el-form> </el-form>
</div> </div>
</el-scrollbar>
</div> </div>
</div> </div>
...@@ -91,77 +73,97 @@ ...@@ -91,77 +73,97 @@
</v-full-layout> </v-full-layout>
</template> </template>
<script> <script>
import '../../assets/spritesmith-generated/sprite.css' import "@/assets/spritesmith-generated/sprite.css";
import store from '../../vuex/store.js' import mapService from "@/utils/mapService.js";
import remoteLoad from 'utils/remoteLoad.js' import "@/utils/mapEvent.js";
import mapService from 'utils/mapService.js' import EventBus from "@/event-bus";
import 'utils/mapEvent.js' import { services } from "@/api";
import EventBus from '../../event-bus' const MONITOR_SERVICE = services.monitor;
import {services} from '../../api'
import mock from '../../mock' import { CONSTANT } from "@/constant";
const MONITOR_SERVICE = services.monitor; import { deepClone, showToast } from "@/utils/utils";
import AreaSelect from "./AreaSelect.vue";
import {CONSTANT} from '../../constant' import MapControll from "./MapControll.vue";
import AMapLoader from "@amap/amap-jsapi-loader";
import AreaSelect from './AreaSelect.vue' import { GET_DEVICE_LOCATION } from "@/api/services/monitor";
import MAPGEO from 'utils/mapgeo' import CitySelect from "@/components/area";
import MapControll from './MapControll.vue' import { SAVE_ELECFENCE_INFO } from "@/api/services/fence";
export default {
export default{ components: {
data(){ AreaSelect,
let checkFenceName = (rule, vaule, cb)=>{ MapControll,
if(typeof this.restainFenceName != 'undefined' && this.form.electricFenceName === this.restainFenceName){ CitySelect,
},
data() {
let checkFenceName = (rule, vaule, cb) => {
if (
typeof this.restainFenceName != "undefined" &&
this.form.electricFenceName === this.restainFenceName
) {
cb(); cb();
} }
MONITOR_SERVICE.checkFenceName({name: this.form.electricFenceName}).then((res)=>{ MONITOR_SERVICE.checkFenceName({
if(res.returnCode == 0){ name: this.form.electricFenceName,
if(res.data.isExist == 1){ }).then((res) => {
cb(new Error('该围栏名已存在,请重新输入!')) if (res.returnCode == 0) {
}else{ if (res.data.isExist == 1) {
cb(new Error("该围栏名已存在,请重新输入!"));
} else {
cb(); cb();
} }
} }
}) });
} };
let checkDaterange = (rule, vaule, cb)=>{ let checkDaterange = (rule, vaule, cb) => {
const dateRange = this.form.dateRange; const dateRange = this.form.dateRange;
if(!dateRange || !dateRange.length){ if (!dateRange || !dateRange.length) {
cb(new Error('请选择日期')) cb(new Error("请选择日期"));
}else{ } else {
let min = dateRange[0]; let min = dateRange[0];
let max = dateRange[1]; let max = dateRange[1];
if(!moment.isMoment(min)){ if (!moment.isMoment(min)) {
min = moment(min) min = moment(min);
} }
if(!moment.isMoment(max)){ if (!moment.isMoment(max)) {
max = moment(max) max = moment(max);
} }
if(min.isBefore( moment(max).subtract(30*6, 'days'), 'minute')){ if (min.isBefore(moment(max).subtract(30 * 6, "days"), "minute")) {
cb(new Error('日期范围不能超过180天')) cb(new Error("日期范围不能超过180天"));
} }
} }
cb() 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 checkRadius = (rule, vaule, cb)=>{ let checkMsgtel = (rule, vaule, cb) => {
const fenceRadius = this.form.fenceRadius; let reg = /^1\d{10}((\,1\d{10})|(\,1\d{10}))?$/;
if(this.form.shapeType == 2 && (!/^\d+$/.test(fenceRadius) || fenceRadius<1000)){ if (this.form.telNumbers && !reg.test(this.form.telNumbers)) {
cb(new Error('请输入整数且不小于1000')) cb(new Error("请输入正确的格式"));
}else{ } else {
cb(); cb();
} }
} };
let checkMsgtel = (rule, vaule, cb)=>{ let checkArea = (rule, vaule, cb) => {
if(this.form.msgtel && !/^1\d{10}(\,1\d{10})?$/.test(this.form.msgtel)){ if (this.form.shapeType == 4 && !this.form.areaCode) {
cb(new Error('请输入正确的格式')) cb(new Error("请选择行政区域"));
}else{ } else {
cb(); cb();
} }
} };
return { return {
sn: this.$route.query.sn, sn: this.$route.query.sn,
name: this.$route.query.name, name: this.$route.query.name,
...@@ -170,368 +172,357 @@ ...@@ -170,368 +172,357 @@
mapObj: null, mapObj: null,
mapLoading: false, mapLoading: false,
isInitMap: false, isInitMap: false,
searchText: '', searchText: "",
searchType: 'sn', searchType: "sn",
isSearching: false, isSearching: false,
areaId: '', areaId: "",
areaStr: '', areaStr: "",
isSubmitting: false, isSubmitting: false,
form: { form: {
fenceNo: '',
electricFenceName: '',
locationType: 1, locationType: 1,
triggerType: 3, triggerType: 3,
dateRange: [], shapeType: 1,
shapeType: 2, radius: 1000,
fenceRadius: '1000', enableStatus: 1,
status: 1,
areaCode: '',
lng: '',
lat: '',
analysisAddress: '',
msgtel: ''
}, },
rules: { rules: {
electricFenceName: [ fenceName: [
{required: true, message: '请输入围栏名称', trigger: 'blur'}, { required: true, message: "请输入围栏名称", trigger: "blur" },
{pattern: /^\S{2,200}$/, message: '至少2字', trigger: 'blur' }, { pattern: /^\S{2,200}$/, message: "至少2字", trigger: "blur" },
{validator: checkFenceName, trigger: 'blur'} // { validator: checkFenceName, trigger: "blur" },
], ],
daterange: [{validator: checkDaterange}], triggerType: [
fenceRadius: [ { required: true, message: "请选择触发类型", trigger: "change" },
{validator: checkRadius, trigger: 'blur'}
], ],
msgtel: [{validator: checkMsgtel, trigger: 'blur'}], dateRange: [
}, { required: true, message: "请选择指定区间", trigger: "change" },
fenceId: undefined, { validator: checkDaterange, trigger: "change" },
restainFenceName: '', ],
polygonPath: [] raidus: [{ validator: checkRadius, trigger: "blur" }],
} telNumbers: [{ validator: checkMsgtel, trigger: "blur" }],
areaName: [{ validator: checkArea, trigger: "blur" }],
}, },
mounted(){ fenceId: "",
store.dispatch('setFullsize', true) restainFenceName: "",
polygonPath: [],
deviceInfo: {}, // 设备信息
deviceList: [], // 设备列表
};
}, },
watch: { created() {
'form.fenceRadius'(newVal){ EventBus.$on("uiMap.fence.onFenceRadiusChange", this.onFenceRadiusChange);
if(this.form.shapeType === 2){ EventBus.$on("uiMap.fence.polygonChange", this.onFencePolyChange);
if(this._updateFenceRadiusTimeoutId){ this.initMap();
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){ mounted() {
this._shapeTypeTimeoutId && clearTimeout(this._shapeTypeTimeoutId); //store.dispatch("setFullsize", true);
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)
}
}, },
// watch: {
// "form.shapeType": {
// handler: function (n, o) {
// this.changeShapeType(n);
// },
// immediate: true,
// },
// },
methods: { methods: {
initMap(){ // 初始化地图
let check = ()=>{ initMap() {
this.checkMapLoaded && window.clearTimeout(this.checkMapLoaded); let _this = this;
AMapLoader.load({
return setTimeout(()=>{ key: CONSTANT.MAP_KEY, // 申请好的Web端开发者Key,首次调用 load 时必填
if('AMap' in window && typeof AMap.Map == 'function' && !this.mapObj){ version: "2.0", // 指定要加载的 JSAPI 的版本,缺省时默认为 1.4.15
plugins: CONSTANT.MAP_PLUGINS, // 需要使用的的插件列表,如比例尺'AMap.Scale'等
}).then((AMap) => {
window.AMap = AMap; window.AMap = AMap;
this.mapObj = mapService.init('map'); _this.map = mapService.init("map");
_this.getDevinceInfo();
//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; getDevinceInfo() {
form.lat = data.latGPS; let oParams = {};
this.drawFenceCircle(); oParams.sns = this.$route.query.sn;
} oParams.deviceCode = "gps";
EventBus.$emit('uiMap.fence.createFenceMarker', data); 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){ pickDate(beforeDays) {},
this.form.dateRange = [moment().subtract(beforeDays, 'days'),moment().subtract(1, 'days')] // 保存围栏信息
}, submit() {
submit(){ let _this = this;
if(this.form.shapeType == 5){ _this.$refs.form.validate((valid) => {
if(this.polygonPath.length === 0){ if (!valid) {
this.$message({ return false;
message: '请绘制围栏',
type: 'error'
});
return;
}
} }
this.$refs.form.validate((valid, field)=>{ let oParams = _this.getParams();
if(valid){ // 多边形围栏校验
this.isSubmitting = true; if (
oParams.shapeType == 3 &&
this.getParams().then((data)=>{ (!_this.polygonPath || _this.polygonPath.length <= 0)
let params = data; ) {
showToast({
if(typeof this.fenceId != 'undefined'){ message: "请绘制线路",
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'
}); });
return false;
} }
this.isSubmitting = false;
}); console.log(oParams);
}else{ _this.isSubmitting = true;
MONITOR_SERVICE.getNewFenceId().then((res)=>{ SAVE_ELECFENCE_INFO(oParams)
if(res.returnCode == 0){ .then((res) => {
params.fenceNo = res.data.fenceNo; _this.isSubmitting = false;
MONITOR_SERVICE.saveFence(JSON.stringify(params)).then((res)=>{ if (res.code != 200) {
if(res.returnCode == 0){ showToast({
//this.closeDialog();
this.$message({
message: res.message, message: res.message,
type: 'success'
}); });
this.fenceId = res.data; return false;
this.restainFenceName = this.form.electricFenceName;
} }
this.isSubmitting = false; showToast({
message: "保存成功",
type: "success",
}); });
} })
.catch((error) => {
_this.isSubmitting = false;
}); });
}
}); });
},
}else{ updateFenceRadius(radius) {},
return false;
} // 在地图上画圆形围栏
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,
}); });
}, },
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}] drawDistrict(areaCode) {
console.log(areaCode);
EventBus.$emit("uiMap.fence.drawDistrict", areaCode);
},
params.startTime = moment(this.form.dateRange[0]).format('YYYY-MM-DD'); // 在地图上画多边形
params.endTime = moment(this.form.dateRange[1]).format('YYYY-MM-DD'); drawPolygon() {
if(form.msgtel){ EventBus.$emit("uiMap.fence.destroy");
params.telNumbers = form.msgtel EventBus.$emit("uiMap.fence.drawPolygon", this.polygonPath);
} },
params.timeType = 2
resolve(params) // 根据设备地址,在地图上画车辆
}); 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;
// 标记车辆信息
EventBus.$emit("uiMap.fence.createFenceMarker", option);
},
// 监听圆形围栏直径变化
onFenceRadiusChange(e) {
console.log("圆形围栏:", e);
this.$set(this.form, "radius", e);
}, },
areaChoose(areaId, areaStr){
this.areaId = areaId; // 监听围栏类型变化
this.areaStr = areaStr; changeShapeType(e) {
if(this.form.shapeType === 3){ let _this = this;
this.drawDistrict(areaId) 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;
} }
}, },
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); onFencePolyChange(e) {
}, 500); this.polygonPath = e.polygonPath;
}, },
drawPolygon(){
EventBus.$emit('uiMap.fence.drawPolygon', this.polygonPath) // 监听行政区域
} changeArea(e) {
console.log(e);
this.form.areaCode = e.code;
this.form.areaText = e.name;
this.drawDistrict(e.code);
this.$refs.form.clearValidate();
}, },
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)=>{ getParams() {
this.mapLoading = isLoading; let _this = this;
}); let o = deepClone(_this.form);
EventBus.$on('uiMap.fence.onFenceRadiusChange', (radius)=>{ console.log(o);
this.form.fenceRadius = radius; let oParams = {};
//this.$refs.form.validateField('fenceRadius'); let deviceList = this.deviceList;
});
EventBus.$on('uiMap.fence.onFenceLngLatChange', (data)=>{ oParams.fenceName = o.fenceName;
this.form.lng = data.lng; oParams.bizFenceType = 14;
this.form.lat = data.lat; oParams.triggerType = o.triggerType;
oParams.enableStatus = o.enableStatus;
oParams.timeType = 2;
oParams.shapeType = o.shapeType;
oParams.telNumbers = o.telNumbers;
// 指定区间
if (o.dateRange && o.dateRange.length > 0) {
oParams.startTime = o.dateRange[0];
oParams.endTime = o.dateRange[1];
}
// 圆形围栏
if (o.shapeType == 1) {
oParams.radius = o.radius;
oParams.lnglat = `${o.lng},${o.lat}`;
}
// 多边形围栏
if (o.shapeType == 3) {
oParams.lnglat = this.polygonPath;
}
// 行政区域围栏
if (o.shapeType == 4) {
oParams.areaCode = o.areaCode[o.areaCode.length - 1];
oParams.areaText = o.areaText[o.areaText.length - 1];
}
// 设备列表
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;
},
EventBus.$on('uiMap.fence.polygonChange', (data)=>{ // 监听圆形半径更改
this.polygonPath = data.polygonPath 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,
}); });
}, },
beforeDestroy(){
}, },
components: { };
AreaSelect,
MapControll
}
}
</script> </script>
<style scoped> <style lang="scss" scoped>
/*样式写在 scss/monitor.scss*/ /*样式写在 scss/monitor.scss*/
.side_auto_h{ .side_auto_h {
max-height: calc(100vh - 100px); max-height: calc(100vh - 100px);
overflow: auto; overflow: auto;
} }
.shape_tip{ .shape_tip {
color:#999; color: #999;
line-height:1.5; line-height: 1.5;
margin-bottom: 10px; 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> </style>
\ No newline at end of file \ No newline at end of file
...@@ -5,7 +5,6 @@ ...@@ -5,7 +5,6 @@
<h2 class="header-title">地图引用</h2> <h2 class="header-title">地图引用</h2>
</div> --> </div> -->
<div class="fence-map" :visible="fenceMapModalVisible" v-loading="mapLoading"> <div class="fence-map" :visible="fenceMapModalVisible" v-loading="mapLoading">
<!-- <el-form :model="form" ref="fenceMapForm" :rules="rules" :inline="true" size="mini" > <!-- <el-form :model="form" ref="fenceMapForm" :rules="rules" :inline="true" size="mini" >
<el-form-item label="经度" prop="lng"> <el-form-item label="经度" prop="lng">
...@@ -45,51 +44,47 @@ ...@@ -45,51 +44,47 @@
</div> --> </div> -->
<!-- </el-dialog> --> <!-- </el-dialog> -->
<!-- 围栏调用地图弹框 /--> <!-- 围栏调用地图弹框 /-->
</template> </template>
<script> <script>
import {services} from '../../api' import remoteLoad from "utils/remoteLoad.js";
import remoteLoad from 'utils/remoteLoad.js' import mapService from "utils/mapService.js";
import mapService from 'utils/mapService.js' import FenceMapControll from "./FenceMapControll.vue";
import FenceMapControll from './FenceMapControll.vue' import { CONSTANT } from "../../constant";
const BUSINESS_SERVICE = services.business; export default {
import {CONSTANT} from '../../constant' props: ["fenceMapModalVisible", "init", "readonlyStatus"],
data() {
export default{
props: ['fenceMapModalVisible', 'init', 'readonlyStatus'],
data(){
return { return {
fenceMapSearch: '', fenceMapSearch: "",
geolocation: null, geolocation: null,
circleEditor: null, circleEditor: null,
areaCodeMap:"", areaCodeMap: "",
polygons:[], polygons: [],
polygonEditor:null, polygonEditor: null,
autoCenterMarker:null, autoCenterMarker: null,
marke:null, marke: null,
fenceMapModalVisible:false, fenceMapModalVisible: false,
polygon:null, polygon: null,
mapDot:true, mapDot: true,
circle: null, circle: null,
tableData:[], tableData: [],
transferTimeoutId: undefined, transferTimeoutId: undefined,
geocoder: null, geocoder: null,
transferFlag: null, transferFlag: null,
opts : { opts: {
subdistrict: 1, //返回下一级行政区 subdistrict: 1, //返回下一级行政区
showbiz:false //最后一级返回街道信息 showbiz: false, //最后一级返回街道信息
}, },
mapObj: null, mapObj: null,
fenceType: 'polygon', //'area' 'polygon' fenceType: "polygon", //'area' 'polygon'
lng: '', lng: "",
lat: '', lat: "",
radius: '', radius: "",
fenceCircle: null, fenceCircle: null,
fenceCenter: null, fenceCenter: null,
areaCode: '', areaCode: "",
isFenceInit: false, isFenceInit: false,
mapLoading: false, mapLoading: false,
polygonPath: [ polygonPath: [
...@@ -97,17 +92,22 @@ export default{ ...@@ -97,17 +92,22 @@ export default{
[116.410703, 39.897555], [116.410703, 39.897555],
[116.402292, 39.892353], [116.402292, 39.892353],
[116.389846, 39.891365] */ [116.389846, 39.891365] */
] ],
} };
}, },
mounted(){ async mounted() {
if (window.AMap) {
this.initMap();
} else {
await remoteLoad(`${CONSTANT.AMAP_URL}`, true);
this.initMap();
}
}, },
watch: { watch: {
lng(newVal){ lng(newVal) {
//this.transfer() //this.transfer()
}, },
lat(newVal){ lat(newVal) {
//this.transfer() //this.transfer()
}, },
/* mapData(newVal){ /* mapData(newVal){
...@@ -119,160 +119,148 @@ export default{ ...@@ -119,160 +119,148 @@ export default{
}) })
} */ } */
}, },
async created () { async created() {
if(window.AMap){
this.initMap()
}else{
await remoteLoad(`${CONSTANT.AMAP_URL}`, true);
this.initMap()
}
}, },
methods: { methods: {
initMap(){ initMap() {
this.initMapPromise = new Promise((resolve, reject)=>{ this.initMapPromise = new Promise((resolve, reject) => {
let check = ()=>{ let check = () => {
this.checkMapLoaded && window.clearTimeout(this.checkMapLoaded); this.checkMapLoaded && window.clearTimeout(this.checkMapLoaded);
return setTimeout(()=>{ return setTimeout(() => {
if('AMap' in window && typeof AMap.Map == 'function' && !this.mapObj){ if (
"AMap" in window &&
typeof AMap.Map == "function" &&
!this.mapObj
) {
window.AMap = AMap; window.AMap = AMap;
this.mapObj = mapService.init('mapContainer'); this.mapObj = mapService.init("mapContainer");
this.bindContextMenu(); this.bindContextMenu();
this.bindSearch(); this.bindSearch();
resolve() resolve();
}else{ } else {
this.checkMapLoaded = check() this.checkMapLoaded = check();
}
}, 100)
} }
}, 100);
};
this.checkMapLoaded = check(); this.checkMapLoaded = check();
}) });
}, },
bindSearch(){ bindSearch() {
const self = this; const self = this;
this.auto = new AMap.Autocomplete({ AMap.plugin("AMap.Autocomplete", function () {
input: 'fenceMapSearch' self.auto = new AMap.Autocomplete({
input: "fenceMapSearch",
}); });
this.autoCenterMarker = new AMap.Marker({ self.autoCenterMarker = new AMap.Marker({
icon: require('images/auto-center-marker.gif'), icon: require("images/auto-center-marker.gif"),
map: this.mapObj, map: self.mapObj,
offset: new AMap.Pixel(-12,-12), offset: new AMap.Pixel(-12, -12),
visible: false visible: false,
}); });
this.autoCenterMarker.on('rightclick', (e)=> { self.autoCenterMarker.on("rightclick", (e) => {
if(self.mapObj.getAllOverlays('circle').length){ if (self.mapObj.getAllOverlays("circle").length) {
window.mapMenu.contextMenu.open(self.mapObj, e.lnglat); window.mapMenu.contextMenu.open(self.mapObj, e.lnglat);
self.contextMenuPositon = e.lnglat; //右键菜单位置 self.contextMenuPositon = e.lnglat; //右键菜单位置
} }
}); });
AMap.event.addListener(this.auto, 'select', (e)=>{ AMap.event.addListener(self.auto, "select", (e) => {
if(e.poi && e.poi.location){ if (e.poi && e.poi.location) {
this.mapObj.setCenter(e.poi.location); self.mapObj.setCenter(e.poi.location);
this.autoCenterMarker.setPosition(e.poi.location); self.autoCenterMarker.setPosition(e.poi.location);
/*for(var i = 0, l = this.polygons.length; i < l; i++) { /*for(var i = 0, l = this.polygons.length; i < l; i++) {
this.polygons[i].setMap(null); this.polygons[i].setMap(null);
}*/ }*/
this.autoCenterMarker.show(); self.autoCenterMarker.show();
this.mapObj.add(this.autoCenterMarker); self.mapObj.add(self.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); self.mapObj.setZoom(14);
});
}); });
}, },
bindContextMenu(){ bindContextMenu() {
const self = this; const self = this;
window.mapMenu = new ContextMenu(this.mapObj);//暴露mapMenu onclick要用 var contextMenu = new AMap.ContextMenu();
function ContextMenu(map) { contextMenu.addItem(
var me = this; "设置围栏中心",
this.contextMenuPositon = null; function () {
this.contextMenu = new AMap.ContextMenu({ self.moveCenter();
isCustom: true, },
content: `<div class="context_menu" > 0
<p onclick="mapMenu.moveCenter()"><span>设置围栏中心</span></p> );
</div>` //地图绑定鼠标右击事件——弹出右键菜单
}); self.mapObj.on("rightclick", function (e) {
map.on('rightclick', (e)=> { console.log(e)
if(self.mapObj.getAllOverlays('circle').length){ contextMenu.open(self.mapObj, e.lnglat);
this.contextMenu.open(map, e.lnglat); self.contextMenuPositon = e.lnglat;
self.contextMenuPositon = e.lnglat; //右键菜单位置
}
}); });
}
ContextMenu.prototype.moveCenter = function addPOI() { //contextMenu.open(self.mapObj, lnglat);
self.moveCenter()
this.contextMenu.close();
};
}, },
drawFence(){ drawFence() {
if(!this.lng && !this.lat){ if (!this.lng && !this.lat) {
this.mapLoading = true; this.mapLoading = true;
this.getCurrentPosition().then((pos)=>{ this.getCurrentPosition()
.then((pos) => {
console.log(pos);
this.lng = pos.lng; this.lng = pos.lng;
this.lat = pos.lat; this.lat = pos.lat;
this.radius = 1000; this.radius = 1000;
this.drawFenceCircle(pos) this.drawFenceCircle(pos);
this.$emit('onUpdateMapData',{ this.$emit("onUpdateMapData", {
lng: this.lng, lng: this.lng,
lat: this.lat, lat: this.lat,
radius: this.radius radius: this.radius,
}); });
this.mapLoading = false; this.mapLoading = false;
}) })
}else{ .catch((error) => {
this.drawFenceCircle(mapService.getLngLat(this.lng, this.lat)) console.log(error);
});
} else {
this.drawFenceCircle(mapService.getLngLat(this.lng, this.lat));
} }
}, },
drawFenceCircle(fenceCenter){ drawFenceCircle(fenceCenter) {
const mapObj = this.mapObj; const mapObj = this.mapObj;
if(this.fenceCircle){ if (this.fenceCircle) {
this.fenceCircle.setCenter(mapService.getLngLat(this.lng, this.lat)) this.fenceCircle.setCenter(mapService.getLngLat(this.lng, this.lat));
}else{ } else {
this.fenceCircle = new AMap.Circle({ this.fenceCircle = new AMap.Circle({
map: mapObj, map: mapObj,
center: fenceCenter, center: fenceCenter,
radius: this.radius*1, radius: this.radius * 1,
strokeColor: "#F33", strokeColor: "#F33",
strokeOpacity: 1, strokeOpacity: 1,
strokeWeight: 3, strokeWeight: 3,
fillColor: "ee2200", fillColor: "ee2200",
fillOpacity: 0.35 fillOpacity: 0.35,
}); });
mapObj.plugin(["AMap.CircleEditor"],()=>{ mapObj.plugin(["AMap.CircleEditor"], () => {
this.circleEditor = new AMap.CircleEditor(mapObj, this.fenceCircle); this.circleEditor = new AMap.CircleEditor(mapObj, this.fenceCircle);
AMap.event.addListener(this.circleEditor, 'adjust', (e)=>{ AMap.event.addListener(this.circleEditor, "adjust", (e) => {
this.radius = e.radius/1; this.radius = e.radius / 1;
this.$emit('onUpdateMapData',{ this.$emit("onUpdateMapData", {
lng: this.lng, lng: this.lng,
lat: this.lat, lat: this.lat,
radius: this.radius radius: this.radius,
}); });
}); });
AMap.event.addListener(this.circleEditor, 'move', (e)=>{ AMap.event.addListener(this.circleEditor, "move", (e) => {
this.lng = e.lnglat.lng; this.lng = e.lnglat.lng;
this.lat = e.lnglat.lat; this.lat = e.lnglat.lat;
this.$emit('onUpdateMapData',{ this.$emit("onUpdateMapData", {
lng: this.lng, lng: this.lng,
lat: this.lat, lat: this.lat,
}); });
...@@ -281,106 +269,104 @@ export default{ ...@@ -281,106 +269,104 @@ export default{
}); });
} }
mapService.setFitView() mapService.setFitView();
mapObj.setZoom(14); mapObj.setZoom(14);
}, },
initFence(data){ initFence(data) {
this._mapPromiseTimeout && clearTimeout(this._mapPromiseTimeout) this._mapPromiseTimeout && clearTimeout(this._mapPromiseTimeout);
if(this.initMapPromise){ if (this.initMapPromise) {
if(data){ if (data) {
this.fenceType = data.fenceType this.fenceType = data.fenceType;
if(this.fenceType === 'circle'){ if (this.fenceType === "circle") {
this.lng = data.lng; this.lng = data.lng;
this.lat = data.lat; this.lat = data.lat;
this.radius = data.radius; this.radius = data.radius;
}else if(this.fenceType === 'area'){ } else if (this.fenceType === "area") {
this.areaCode = data.areaCode this.areaCode = data.areaCode;
}else if(this.fenceType === 'polygon'){ } else if (this.fenceType === "polygon") {
if(data.polygonPath && data.polygonPath.length){ if (data.polygonPath && data.polygonPath.length) {
this.polygonPath = data.polygonPath this.polygonPath = data.polygonPath;
} }
} }
} }
this.initMapPromise.then(()=>{ this.initMapPromise.then(() => {
if(this.fenceType === 'circle'){ if (this.fenceType === "circle") {
this.drawFence() this.drawFence();
}else if(this.fenceType === 'area'){ } else if (this.fenceType === "area") {
this.drawArea() this.drawArea();
}else if(this.fenceType === 'polygon'){ } else if (this.fenceType === "polygon") {
this.drawPolygon() this.drawPolygon();
} }
});
}) } else {
}else{ this._mapPromiseTimeout = setTimeout(() => {
console.log("timeout");
this._mapPromiseTimeout = setTimeout(() => {console.log('timeout') this.initFence(data);
this.initFence(data)
}, 100); }, 100);
} }
}, },
updateFence(data){ updateFence(data) {
let _this = this;
this.mapObj.clearMap() let mapInterval = setInterval(function () {
if (_this.mapObj) {
clearInterval(mapInterval);
_this.mapObj.clearMap();
this.fenceType = data.fenceType _this.fenceType = data.fenceType;
this.polyEditor && this.polyEditor.close() _this.polyEditor && _this.polyEditor.close();
this.mouseTool && this.mouseTool.close() _this.mouseTool && _this.mouseTool.close();
if(this.fenceType === 'circle'){ if (_this.fenceType === "circle") {
this.fenceCircle = null; _this.fenceCircle = null;
if(data.lng){ if (data.lng) {
this.lng = data.lng; _this.lng = data.lng;
} }
if(data.lat){ if (data.lat) {
this.lat = data.lat; _this.lat = data.lat;
} }
if(data.radius){ if (data.radius) {
this.radius = data.radius; _this.radius = data.radius;
} }
this.drawFence() _this.drawFence();
}else if(this.fenceType === 'area'){ } else if (_this.fenceType === "area") {
if(data.areaCode){ if (data.areaCode) {
this.areaCode = data.areaCode _this.areaCode = data.areaCode;
} }
if(this.areaCode){ if (_this.areaCode) {
this.drawArea() _this.drawArea();
} }
} else if (_this.fenceType === "polygon") {
}else if(this.fenceType === 'polygon'){ _this.drawPolygon();
this.drawPolygon()
} }
}
}, 100);
}, },
drawArea(){ drawArea() {
let _this = this; let _this = this;
let areaCode = this.areaCode?this.areaCode.toString():'中国' let areaCode = this.areaCode ? this.areaCode.toString() : "中国";
this.mapObj.clearMap() this.mapObj.clearMap();
for (var i = 0, l =this.polygons.length; i < l; i++) { for (var i = 0, l = this.polygons.length; i < l; i++) {
this.polygons[i].setMap(null); this.polygons[i].setMap(null);
} }
let district,lng,lat let district, lng, lat;
this.mapLoading = true; this.mapLoading = true;
AMap.service('AMap.DistrictSearch', function() { AMap.service("AMap.DistrictSearch", function () {
var opts = { var opts = {
subdistrict: 1, //返回下一级行政区 subdistrict: 1, //返回下一级行政区
extensions: 'all', extensions: "all",
showbiz:false //最后一级返回街道信息 showbiz: false, //最后一级返回街道信息
}; };
areaCode === "中国"?delete opts.extensions :delete opts.showbiz areaCode === "中国" ? delete opts.extensions : delete opts.showbiz;
district = new AMap.DistrictSearch(opts); district = new AMap.DistrictSearch(opts);
district.setLevel('district'); district.setLevel("district");
district.search(areaCode, function(status, result) { district.search(areaCode, function (status, result) {
var bounds = result.districtList[0].boundaries; var bounds = result.districtList[0].boundaries;
lng = result.districtList[0].center.lng; lng = result.districtList[0].center.lng;
lat = result.districtList[0].center.lat; lat = result.districtList[0].center.lat;
...@@ -393,232 +379,220 @@ export default{ ...@@ -393,232 +379,220 @@ export default{
strokeWeight: 1, strokeWeight: 1,
path: bounds[i], path: bounds[i],
fillOpacity: 0.7, fillOpacity: 0.7,
fillColor: '#CCF3FF', fillColor: "#CCF3FF",
strokeColor: '#CC66CC', strokeColor: "#CC66CC",
}); });
_this.polygons.push(polygon); _this.polygons.push(polygon);
} }
lng = result.districtList[0].center.lng; lng = result.districtList[0].center.lng;
lat = result.districtList[0].center.lat; lat = result.districtList[0].center.lat;
let center = mapService.getLngLat(lng,lat); let center = mapService.getLngLat(lng, lat);
mapService.setFitView(); mapService.setFitView();
//map.setZoom(10); //map.setZoom(10);
_this.mapLoading = false; _this.mapLoading = false;
} }
}); });
}); });
}, },
moveCenter(){ moveCenter() {
this.lng = this.contextMenuPositon.lng; this.lng = this.contextMenuPositon.lng;
this.lat = this.contextMenuPositon.lat; this.lat = this.contextMenuPositon.lat;
let center = mapService.getLngLat(this.lng, this.lat); let center = mapService.getLngLat(this.lng, this.lat);
this.fenceCircle.setCenter(center); this.fenceCircle.setCenter(center);
this.$emit('onUpdateMapData', { this.$emit("onUpdateMapData", {
lng: this.lng, lng: this.lng,
lat: this.lat lat: this.lat,
}) });
}, },
getCurrentPosition(){ getCurrentPosition() {
const mapObj = this.mapObj; const mapObj = this.mapObj;
const self = this; const self = this;
return new Promise((resolve, reject) => {
return new Promise((resolve, reject)=>{ mapObj.plugin("AMap.Geolocation", function () {
mapObj.plugin('AMap.Geolocation', function(){
self.geolocation = new AMap.Geolocation(); self.geolocation = new AMap.Geolocation();
self.geolocation.getCurrentPosition(); self.geolocation.getCurrentPosition();
AMap.event.addListener(self.geolocation, 'complete', function(e){//返回定位信息 AMap.event.addListener(self.geolocation, "complete", function (e) {
console.log("complete", e);
//返回定位信息
var lnglatXY = mapService.getLngLat(e.position.lng, e.position.lat); var lnglatXY = mapService.getLngLat(e.position.lng, e.position.lat);
resolve(lnglatXY) resolve(lnglatXY);
});
AMap.event.addListener(self.geolocation, "error", function (e) {
console.log("error", e);
//返回定位出错信息
resolve(mapObj.getCenter());
}); });
AMap.event.addListener(self.geolocation, 'error', function(e){//返回定位出错信息
resolve(mapObj.getCenter())
}); });
}); });
})
}, },
drawPolygon(){ drawPolygon() {
const mapObj = this.mapObj; const mapObj = this.mapObj;
const self = this; const self = this;
if(this.polygonPath.length){ if (this.polygonPath.length) {
self.polygon = new AMap.Polygon({ self.polygon = new AMap.Polygon({
path: this.polygonPath, path: this.polygonPath,
strokeColor: "#FF33FF", strokeColor: "#FF33FF",
strokeWeight: 6, strokeWeight: 6,
strokeOpacity: 0.2, strokeOpacity: 0.2,
fillOpacity: 0.4, fillOpacity: 0.4,
fillColor: '#1791fc', fillColor: "#1791fc",
zIndex: 50, zIndex: 50,
}) });
mapObj.add(self.polygon) mapObj.add(self.polygon);
mapObj.setFitView([ self.polygon ]) mapObj.setFitView([self.polygon]);
self.polyEditor = new AMap.PolyEditor(mapObj, self.polygon) self.polyEditor = new AMap.PolyEditor(mapObj, self.polygon);
self.polyEditor.open() self.polyEditor.open();
self.bindPolyEvent(self.polyEditor) self.bindPolyEvent(self.polyEditor);
}else{ } else {
self.mouseTool = new AMap.MouseTool(mapObj) self.mouseTool = new AMap.MouseTool(mapObj);
self.mouseTool.polygon({ self.mouseTool.polygon({
strokeColor: "#FF33FF", strokeColor: "#FF33FF",
strokeOpacity: 1, strokeOpacity: 1,
strokeWeight: 6, strokeWeight: 6,
strokeOpacity: 0.2, strokeOpacity: 0.2,
fillColor: '#1791fc', fillColor: "#1791fc",
fillOpacity: 0.4, fillOpacity: 0.4,
// 线样式还支持 'dashed' // 线样式还支持 'dashed'
strokeStyle: "solid", strokeStyle: "solid",
// strokeStyle是dashed时有效 // strokeStyle是dashed时有效
// strokeDasharray: [30,10], // strokeDasharray: [30,10],
}) });
self.mouseTool.on('draw', function(event) { self.mouseTool.on("draw", function (event) {
// event.obj 为绘制出来的覆盖物对象 // event.obj 为绘制出来的覆盖物对象
self.polygon = event.obj; self.polygon = event.obj;
self.polyEditor = new AMap.PolyEditor(mapObj, self.polygon) self.polyEditor = new AMap.PolyEditor(mapObj, self.polygon);
self.polyEditor.open() self.polyEditor.open();
self.bindPolyEvent(self.polyEditor) self.bindPolyEvent(self.polyEditor);
self.mouseTool.close() self.mouseTool.close();
self.emitPolyEvent() self.emitPolyEvent();
}) });
} }
}, },
emitPolyEvent(){ emitPolyEvent() {
let pathArr = this.polygon.getPath() let pathArr = this.polygon.getPath();
let resultArr = pathArr.map((item)=>{ let resultArr = pathArr.map((item) => {
return [item.lng, item.lat] return [item.lng, item.lat];
}) });
this.polygonPath = resultArr this.polygonPath = resultArr;
this.$emit('onUpdateMapData',{ this.$emit("onUpdateMapData", {
polygonPath: this.polygonPath polygonPath: this.polygonPath,
}); });
console.log(resultArr.join('|')) console.log(resultArr.join("|"));
}, },
bindPolyEvent(polyEditor){ bindPolyEvent(polyEditor) {
const self = this const self = this;
polyEditor.on('addnode', function(event) { polyEditor.on("addnode", function (event) {
console.log('触发事件:addnode') console.log("触发事件:addnode");
self.emitPolyEvent() self.emitPolyEvent();
}) });
polyEditor.on('adjust', function(event) { polyEditor.on("adjust", function (event) {
console.log('触发事件:adjust') console.log("触发事件:adjust");
self.emitPolyEvent() self.emitPolyEvent();
}) });
polyEditor.on('removenode', function(event) { polyEditor.on("removenode", function (event) {
console.log('触发事件:removenode') console.log("触发事件:removenode");
self.emitPolyEvent() self.emitPolyEvent();
}) });
polyEditor.on('end', function(event) { polyEditor.on("end", function (event) {
console.log('触发事件: end') console.log("触发事件: end");
self.emitPolyEvent() self.emitPolyEvent();
// event.target 即为编辑后的多边形对象 // event.target 即为编辑后的多边形对象
}) });
}, },
transfer(){ transfer() {
this.transferTimeoutId && window.clearTimeout(this.transferTimeoutId); this.transferTimeoutId && window.clearTimeout(this.transferTimeoutId);
this.transferTimeoutId = window.setTimeout(()=>{ this.transferTimeoutId = window.setTimeout(() => {
const flag = new Date(); const flag = new Date();
this.transferFlag = flag; this.transferFlag = flag;
if(!this.geocoder){ if (!this.geocoder) {
mapService.getGeocoder().then((gc)=>{ mapService.getGeocoder().then((gc) => {
this.geocoder = gc; this.geocoder = gc;
this.getAddress(flag); this.getAddress(flag);
}); });
}else{ } else {
this.getAddress(flag); this.getAddress(flag);
} }
}, 500) }, 500);
}, },
getAddress(flag){ getAddress(flag) {
const lnglatXY = [this.form.lng, this.form.lat]; const lnglatXY = [this.form.lng, this.form.lat];
this.transferAddr = ''; this.transferAddr = "";
this.geocoder.getAddress(lnglatXY, (status, result)=>{ this.geocoder.getAddress(lnglatXY, (status, result) => {
if(flag == this.transferFlag){ if (flag == this.transferFlag) {
if (status === 'complete' && result.info === 'OK') {//获取地址成功 if (status === "complete" && result.info === "OK") {
//获取地址成功
this.form.transferAddr = result.regeocode.formattedAddress; this.form.transferAddr = result.regeocode.formattedAddress;
this.$emit('onUpdateMapData',{ this.$emit("onUpdateMapData", {
lng: this.form.lng, lng: this.form.lng,
lat: this.form.lat, lat: this.form.lat,
address: this.form.transferAddr, address: this.form.transferAddr,
radius: this.form.radius radius: this.form.radius,
}); });
} else {
}else{ this.form.transferAddr = "";
this.form.transferAddr = '';
} }
} }
}); });
}, },
}, },
components:{ components: {
FenceMapControll FenceMapControll,
} },
} };
</script> </script>
<style scoped> <style scoped>
.fence-map{ .fence-map {
position: relative; position: relative;
} }
.fence-map .map-container{ .fence-map .map-container {
width: 100%; width: 100%;
height: 500px; height: 500px;
} }
.fence-map .map-seacrh-wrap{ .fence-map .map-seacrh-wrap {
position: absolute; position: absolute;
top: 40px; top: 40px;
left: 10px; left: 10px;
z-index: 1000; z-index: 1000;
} }
.el-form-item{ .el-form-item {
margin: -20px 0 20px 10px; margin: -20px 0 20px 10px;
} }
</style> </style>
<style lang="scss"> <style lang="scss">
.context_menu{ .context_menu {
min-width: 10em; min-width: 10em;
background-color: #fff; background-color: #fff;
padding: 10px; padding: 10px;
border: 1px solid #efefef; border: 1px solid #efefef;
border-radius: 2px; border-radius: 2px;
cursor: pointer; cursor: pointer;
&>p{ & > p {
margin: 0; margin: 0;
i{ i {
font-size: 18px; font-size: 18px;
color: #094; color: #094;
margin-right: 5px; margin-right: 5px;
} }
i,span{ i,
span {
vertical-align: middle; vertical-align: middle;
} }
} }
} }
</style> </style>
\ No newline at end of file \ 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 \ No newline at end of file
...@@ -66,7 +66,7 @@ ...@@ -66,7 +66,7 @@
<el-option label="工单号" value="4"></el-option> <el-option label="工单号" value="4"></el-option>
</el-select> </el-select>
</el-input> </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-upload>
</el-form-item> </el-form-item>
<el-button type="primary" class="upload-sure-btn" size="small" @click="submitUpload" :loading="importing" :disabled="uploadDisabled">确认</el-button> <el-button type="primary" class="upload-sure-btn" size="small" @click="submitUpload" :loading="importing" :disabled="uploadDisabled">确认</el-button>
...@@ -77,7 +77,7 @@ ...@@ -77,7 +77,7 @@
<div class="filter-dialog animated " :class="listDialogHidden?'fadeOut':'active fadeIn'"> <div class="filter-dialog animated " :class="listDialogHidden?'fadeOut':'active fadeIn'">
<div class="filter-dialog-header monitor_dialog_header"> <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> <i class="el-icon-close pull-right" @click.stop="listDialogHidden=true"></i>
</div> </div>
<div class="filter-dialog-body"> <div class="filter-dialog-body">
...@@ -147,7 +147,20 @@ ...@@ -147,7 +147,20 @@
</div> </div>
<div class="filter-dialog-body"> <div class="filter-dialog-body">
<div class="monitor-list"> <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> </el-tree>
</div> </div>
...@@ -167,12 +180,12 @@ import mapService from "@/utils/mapService.js"; ...@@ -167,12 +180,12 @@ import mapService from "@/utils/mapService.js";
import "@/utils/mapEvent.js"; import "@/utils/mapEvent.js";
import EventBus from "@/event-bus"; import EventBus from "@/event-bus";
import { services } from "@/api"; import { services } from "@/api";
import mock from "../../mock";
const MONITOR_SERVICE = services.monitor; const MONITOR_SERVICE = services.monitor;
import { CONSTANT } from "@/constant"; import { CONSTANT } from "@/constant";
import MapControll from "./MapControll.vue"; import MapControll from "./MapControll.vue";
import { exportExcel } from "@/utils"; import { exportExcel } from "@/utils";
import { GET_MONITOR_ONLINELIST } from "@/api/services/monitor";
export default { export default {
data() { data() {
let checkFilename = (rule, vaule, cb) => { let checkFilename = (rule, vaule, cb) => {
...@@ -231,6 +244,10 @@ export default { ...@@ -231,6 +244,10 @@ export default {
treeLoading: true, treeLoading: true,
currentMessage: "", //当前是否有提示语弹框 currentMessage: "", //当前是否有提示语弹框
treeKey: "", treeKey: "",
treeDataList: {}, // 缓存车辆
pageSizeList: {},
pageSize: 10,
loadingMore: false,
}; };
}, },
computed: { computed: {
...@@ -340,7 +357,8 @@ export default { ...@@ -340,7 +357,8 @@ export default {
} else { } else {
this.removeMonitor(item); this.removeMonitor(item);
} }
} else { return false;
}
if (this.isTreeChecked) { if (this.isTreeChecked) {
this.$confirm( this.$confirm(
"当所选分组包含车辆过多时,请尝试分多次查询,以防等待时间过久。", "当所选分组包含车辆过多时,请尝试分多次查询,以防等待时间过久。",
...@@ -350,13 +368,17 @@ export default { ...@@ -350,13 +368,17 @@ export default {
cancelButtonText: "取消", cancelButtonText: "取消",
type: "warning", type: "warning",
} }
).then(() => { )
.then(() => {
this.checkFlow(data, node); this.checkFlow(data, node);
})
.catch(() => {
// 取消
this.$refs.tree.setChecked(data, false);
}); });
} else { return false;
this.checkFlow(data, node);
}
} }
this.checkFlow(data, node);
}, },
checkFlow(data, node) { checkFlow(data, node) {
...@@ -491,6 +513,8 @@ export default { ...@@ -491,6 +513,8 @@ export default {
}, },
loadNode(node, resolve) { loadNode(node, resolve) {
console.log(node); console.log(node);
let _this = this;
let id = node.data.id;
const nodeData = node.data; const nodeData = node.data;
const origin = nodeData.origin; const origin = nodeData.origin;
if (nodeData.children) { if (nodeData.children) {
...@@ -505,22 +529,27 @@ export default { ...@@ -505,22 +529,27 @@ export default {
oParams.termType = this.searchType; oParams.termType = this.searchType;
oParams.term = this.searchText; oParams.term = this.searchText;
} }
oParams.pageSize = _this.pageSize;
oParams.pageNumber = _this.pageSizeList[id] || 1;
MONITOR_SERVICE.getVehicleTreeUserList(oParams).then(({ data }) => { MONITOR_SERVICE.getVehicleTreeUserList(oParams).then(({ data }) => {
if (data.length) { if (data.length) {
data.map((item) => { data.map((item) => {
item.leaf = true; 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(data);
} }
return resolve([]); return resolve([]);
}); });
return; return;
} }
} }
} }
let isArray = Array.isArray(nodeData);
return resolve(nodeData); return resolve(isArray ? nodeData : []);
if (node.level === 0) { if (node.level === 0) {
return resolve([{ name: "region1" }, { name: "region2" }]); return resolve([{ name: "region1" }, { name: "region2" }]);
...@@ -589,10 +618,11 @@ export default { ...@@ -589,10 +618,11 @@ export default {
returnTrees: true, returnTrees: true,
}).then((res) => { }).then((res) => {
const items = res.data; const items = res.data;
this.autoOpenLastInfoWindow = true;
this.expandTreeItems(items); this.expandTreeItems(items);
}); });
this.treeHidden = true; this.treeHidden = false;
this.listDialogHidden = true;
} }
} else { } else {
this.checkLoadedTimeoutId = check(); this.checkLoadedTimeoutId = check();
...@@ -819,14 +849,15 @@ export default { ...@@ -819,14 +849,15 @@ export default {
// 添加监控 // 添加监控
addMonitor(item) { addMonitor(item) {
let _this = this; let _this = this;
if (this.monitorList.count === 100) { let obj = this.monitorList;
if (obj.count === 100) {
this.$message({ this.$message({
type: "error", type: "error",
message: "监控设备数最大100台,无法添加", message: "监控设备数最大100台,无法添加",
}); });
} else { return false;
if (this.monitorList[item.sn]) { }
if (!_this.currentMessage) { if (obj[item.sn] && !_this.currentMessage) {
_this.currentMessage = this.$message({ _this.currentMessage = this.$message({
type: "error", type: "error",
message: "该列表中有设备正在监控中,请勿重复监控", message: "该列表中有设备正在监控中,请勿重复监控",
...@@ -834,17 +865,20 @@ export default { ...@@ -834,17 +865,20 @@ export default {
_this.currentMessage = ""; _this.currentMessage = "";
}, },
}); });
return false;
} }
} else {
this.resetRefreshCount = true; this.resetRefreshCount = true;
this.monitorList.count++;
item.eLocateType = "gpsLocation"; item.eLocateType = "gpsLocation";
this.monitorList[item.sn] = item;
this.monitorList.itemArr.unshift(item.sn); // 去重
console.log(this.monitorList.itemArr); if (!obj[item.sn]) {
this.getPositionData(); obj[item.sn] = item;
} obj.count++;
obj.itemArr.unshift(item.sn);
} }
console.log(obj.itemArr);
this.getPositionData();
}, },
// standNoMonitor(item){ // standNoMonitor(item){
// this.resetRefreshCount = true; // this.resetRefreshCount = true;
...@@ -904,7 +938,7 @@ export default { ...@@ -904,7 +938,7 @@ export default {
if (obj[item.sn]) { if (obj[item.sn]) {
delete obj[item.sn]; delete obj[item.sn];
} }
console.log(list);
this.monitorList.itemArr = list.filter((k) => k != item.sn); this.monitorList.itemArr = list.filter((k) => k != item.sn);
//this.monitorList.itemArr.splice(this.monitorList.itemArr.indexOf(item.sn||item), 1) //this.monitorList.itemArr.splice(this.monitorList.itemArr.indexOf(item.sn||item), 1)
this.monitorList = Object.assign({}, obj); this.monitorList = Object.assign({}, obj);
...@@ -931,8 +965,10 @@ export default { ...@@ -931,8 +965,10 @@ export default {
let _this = this; let _this = this;
console.log(arr); console.log(arr);
let o = this.monitorList; let o = this.monitorList;
o.itemArr = [];
arr.forEach((item) => { arr.forEach((item) => {
let n = o[item.sn || item]; let n = o[item.sn || item];
console.log(n);
if (n) { if (n) {
_this.removeMonitor(n); _this.removeMonitor(n);
} }
...@@ -943,6 +979,8 @@ export default { ...@@ -943,6 +979,8 @@ export default {
_this.checkedKeys = []; _this.checkedKeys = [];
this.$refs.tree.setCheckedKeys([]); this.$refs.tree.setCheckedKeys([]);
}, },
// 获取设备位置点
getPositionData(arr) { getPositionData(arr) {
/* let _this = this; /* let _this = this;
arr = arr.filter((item)=>this.monitorList[item.sn]); */ arr = arr.filter((item)=>this.monitorList[item.sn]); */
...@@ -967,7 +1005,7 @@ export default { ...@@ -967,7 +1005,7 @@ export default {
data.forEach((item) => { data.forEach((item) => {
let relItem = this.monitorList[item.sn]; let relItem = this.monitorList[item.sn];
if (relItem) { if (relItem) {
relItem.isOnLine = item.status === 2 ? false : true; relItem.online = item.status === 2 ? false : true;
relItem.isHasPosition = true; relItem.isHasPosition = true;
item.name = relItem.name; item.name = relItem.name;
item.standNo = relItem.standNo; item.standNo = relItem.standNo;
...@@ -1096,6 +1134,81 @@ export default { ...@@ -1096,6 +1134,81 @@ export default {
this.expandedKeys = []; this.expandedKeys = [];
this.checkedKeys = []; 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() { created() {
if (window.AMap) { if (window.AMap) {
...@@ -1117,6 +1230,7 @@ export default { ...@@ -1117,6 +1230,7 @@ export default {
this.getTreeData(); this.getTreeData();
}, },
beforeDestroy() { beforeDestroy() {
document.onkeydown = null;
EventBus.$emit("uiMap.monitor.destroy"); EventBus.$emit("uiMap.monitor.destroy");
EventBus.$off("uiMap.monitor.drawDone", this.drawDoneCb); EventBus.$off("uiMap.monitor.drawDone", this.drawDoneCb);
this._drawTimeoutId && window.clearTimeout(this._drawTimeoutId); this._drawTimeoutId && window.clearTimeout(this._drawTimeoutId);
...@@ -1184,4 +1298,7 @@ export default { ...@@ -1184,4 +1298,7 @@ export default {
.monitor_dialog_header .i_refresh { .monitor_dialog_header .i_refresh {
cursor: pointer; cursor: pointer;
} }
.load_more_link {
color: #409eff;
}
</style> </style>
\ No newline at end of file \ No newline at end of file
...@@ -10,7 +10,7 @@ ...@@ -10,7 +10,7 @@
<div class="controll-wrap"> <div class="controll-wrap">
<div class="search-box" :class="resultBoxHidden?'active':''"> <div class="search-box" :class="resultBoxHidden?'active':''">
<h3>轨迹回放</h3> <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 ref="form" :model="form" :rules="rules" :inline="false" size="mini" class="form">
<el-form-item label="查询范围" prop="daterange"> <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="{ <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"; ...@@ -98,6 +98,7 @@ import { exportExcel } from "utils";
import { CONSTANT } from "../../constant"; import { CONSTANT } from "../../constant";
import InfiniteLoading from "vue-infinite-loading"; import InfiniteLoading from "vue-infinite-loading";
import MapControll from "./MapControll.vue"; import MapControll from "./MapControll.vue";
import { GET_ELECFENCE_INFO } from "@/api/services/fence";
export default { export default {
data() { data() {
...@@ -239,8 +240,12 @@ export default { ...@@ -239,8 +240,12 @@ export default {
//this.bindEvent(); //this.bindEvent();
_this.isInitMap = true; _this.isInitMap = true;
//_this.drawPoi(); //_this.drawPoi();
console.log(_this.fenceId != 'undefined') console.log(_this.fenceId != "undefined");
if (_this.isInitFence && _this.fenceId && _this.fenceId != 'undefined') { if (
_this.isInitFence &&
_this.fenceId &&
_this.fenceId != "undefined"
) {
//_this.drawFence(); //_this.drawFence();
_this.getFence(); _this.getFence();
} }
...@@ -483,8 +488,8 @@ export default { ...@@ -483,8 +488,8 @@ export default {
if (data.length) { if (data.length) {
data.forEach((item, idx) => { data.forEach((item, idx) => {
item.idx = idx; item.idx = idx;
item.standno = _this.standno item.standno = _this.standno;
item.name = _this.name item.name = _this.name;
}); });
this.resultList = data; this.resultList = data;
} }
...@@ -603,6 +608,8 @@ export default { ...@@ -603,6 +608,8 @@ export default {
} }
}); });
}, },
// 行政区域围栏
drawDistrict(areaCode) { drawDistrict(areaCode) {
this._drawDistrictTimeoutId && clearTimeout(this._drawDistrictTimeoutId); this._drawDistrictTimeoutId && clearTimeout(this._drawDistrictTimeoutId);
...@@ -610,6 +617,8 @@ export default { ...@@ -610,6 +617,8 @@ export default {
EventBus.$emit("uiMap.fence.drawDistrict", areaCode); EventBus.$emit("uiMap.fence.drawDistrict", areaCode);
}, 500); }, 500);
}, },
// 多边形围栏
drawPolygon(path) { drawPolygon(path) {
console.log("path"); console.log("path");
EventBus.$emit("uiMap.fence.drawPolygon", { EventBus.$emit("uiMap.fence.drawPolygon", {
...@@ -620,56 +629,38 @@ export default { ...@@ -620,56 +629,38 @@ export default {
// 获取围栏信息-并画围栏 // 获取围栏信息-并画围栏
getFence() { getFence() {
MONITOR_SERVICE.getFenceInfo({ GET_ELECFENCE_INFO({
sn: this.sn, //sn: this.sn,
fenceId: this.fenceId, fenceId: this.fenceId,
}).then((res) => { }).then((res) => {
console.log(res); console.log(res);
let list = res.data || []; let list = res.data || [];
if (res.code != 200) { if (res.code != 200) {
return false; return false;
// const data = res.data || []; }
// if (data) { let obj = res.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);
// }
// }
// }
}
// 循环画围栏
list.map((k) => {
// 圆形围栏 // 圆形围栏
if (k.shapeType == 1) { if (obj.shapeType == 1) {
EventBus.$emit("uiMap.fence.createFenceCircle", { EventBus.$emit("uiMap.fence.createFenceCircle", {
lng: k.lnglat.split(",")[0], lng: obj.lnglat.split(",")[0],
lat: k.lnglat.split(",")[1], lat: obj.lnglat.split(",")[1],
radius: k.radius, radius: obj.radius,
isEdit: false, isEdit: false,
}); });
} }
// 多边形围栏 // 多边形围栏
if (k.shapeType == 3) { if (obj.shapeType == 3) {
let polygonPath = k.lnglat.split("|").map((item) => { let polygonPath = obj.lnglat.split("|").map((item) => {
return [item.split(",")[0], item.split(",")[1]]; return [item.split(",")[0], item.split(",")[1]];
}); });
this.drawPolygon(polygonPath); this.drawPolygon(polygonPath);
} }
});
// 行政区域围栏
if (obj.shapeType == 4) {
this.drawDistrict([obj.areaCode]);
}
}); });
}, },
}, },
......
...@@ -3,18 +3,10 @@ ...@@ -3,18 +3,10 @@
<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-form ref="form" :model="form" :inline="false" size="mini" v-show="!showResult">
<el-upload ref="upload" class="upload-wrap" <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">
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-input v-model="filename" placeholder="未选取任何文件" class="input-with-select" size="small" > <el-input v-model="filename" placeholder="未选取任何文件" class="input-with-select" size="small">
<el-button slot="append" >浏览</el-button> <el-button slot="append">浏览</el-button>
</el-input> </el-input>
<div slot="tip" class="el-upload__tip">请选择需要导入的工单表格</div> <div slot="tip" class="el-upload__tip">请选择需要导入的工单表格</div>
...@@ -48,65 +40,76 @@ ...@@ -48,65 +40,76 @@
</template> </template>
<script> <script>
import {exportExcel} from 'utils' import { exportExcel } from "utils";
import {
export default{ IMPORT_ELECFENCE_LINKEDDEVICES,
props: ['userImportModalVisible'], DOWN_ELECFENCE_EXCELTEMPLATE,
data(){ } from "@/api/services/fence";
import { downFileByPath } from "@/utils/utils";
export default {
props: ["userImportModalVisible"],
data() {
return { return {
form: { form: {},
},
showResult: false, showResult: false,
successNum: '', successNum: "",
errorNum: '', errorNum: "",
seqNo: '', seqNo: "",
importing: false, importing: false,
filename: '', filename: "",
flag:[] 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: { methods: {
doneResult(){ doneResult() {
this.$emit('onUserImportModalChange', false); this.$emit("onUserImportModalChange", false);
this.$emit('onRefreshList'); this.$emit("onRefreshList");
this.showResult = false; this.showResult = false;
this.successNum = ''; this.successNum = "";
this.errorNum = ''; this.errorNum = "";
this.seqNo = ''; this.seqNo = "";
this.importing = false; this.importing = false;
this.filename = ''; this.filename = "";
}, },
exportErrorResult(){ exportErrorResult() {
if(this.errorNum!=0){ if (this.errorNum != 0) {
exportExcel('ecFence/exportFailSn', {seqNo: this.seqNo}) exportExcel("ecFence/exportFailSn", { seqNo: this.seqNo });
}else{ } else {
return false; return false;
} }
}, },
successUpload(res){ successUpload(res) {
this.importing = false; this.importing = false;
if(typeof res === 'object'){ if (typeof res === "object") {
if(res.returnCode == 0){ if (res.returnCode == 0) {
const data = res.data; const data = res.data;
let returnDate=[]; let returnDate = [];
if(this.flag.length!=0){ if (this.flag.length != 0) {
function noRepeat(obj1,obj2){ function noRepeat(obj1, obj2) {
for(var key in obj2){ for (var key in obj2) {
if(obj1[key]){ if (obj1[key]) {
if(obj1[key].sn!=obj2[key].sn){ if (obj1[key].sn != obj2[key].sn) {
returnDate.push(obj2[key]) returnDate.push(obj2[key]);
} }
}else{ } else {
returnDate.push(obj2[key]) returnDate.push(obj2[key]);
} }
} }
} }
noRepeat(this.flag,res.data.returnDate) noRepeat(this.flag, res.data.returnDate);
this.$emit('exportDate', returnDate); this.$emit("exportDate", returnDate);
this.flag.push(...returnDate); this.flag.push(...returnDate);
//console.log(this.flag) //console.log(this.flag)
...@@ -115,10 +118,9 @@ ...@@ -115,10 +118,9 @@
this.seqNo = data.seqNo; this.seqNo = data.seqNo;
this.$refs.upload.clearFiles(); this.$refs.upload.clearFiles();
this.showResult = true; this.showResult = true;
} else {
}else{ this.flag = res.data.returnDate;
this.flag = res.data.returnDate this.$emit("exportDate", res.data.returnDate);
this.$emit('exportDate', res.data.returnDate)
this.successNum = data.success; this.successNum = data.success;
this.errorNum = parseInt(data.fail); this.errorNum = parseInt(data.fail);
this.seqNo = data.seqNo; this.seqNo = data.seqNo;
...@@ -126,13 +128,10 @@ ...@@ -126,13 +128,10 @@
this.$refs.upload.clearFiles(); this.$refs.upload.clearFiles();
this.showResult = true; this.showResult = true;
} }
} }
}else{ } else {
window.location.href = '../ots/login'; //window.location.href = '../ots/login';
} }
}, },
submitUpload() { submitUpload() {
this.$refs.upload.submit(); this.$refs.upload.submit();
...@@ -140,41 +139,45 @@ ...@@ -140,41 +139,45 @@
changeFile(file, filelist) { changeFile(file, filelist) {
this.filename = file.name; this.filename = file.name;
}, },
beforeUpload(file){ beforeUpload(file) {
if(file.name == this.filename){ if (file.name == this.filename) {
this.importing = true; this.importing = true;
return true return true;
} }
return false return false;
}, },
downloadTpl(){ // 批量导入模板下载
exportExcel('ecFence/downTemplates') downloadTpl() {
DOWN_ELECFENCE_EXCELTEMPLATE().then((res) => {
let obj = res.data;
if (obj.dictValue) {
downFileByPath(obj.dictValue);
}
});
}, },
openDialog(){ openDialog() {
this.$emit('onUserImportModalChange', true) this.$emit("onUserImportModalChange", true);
}, },
closeDialog(){ closeDialog() {
this.$emit('onUserImportModalChange', false); this.$emit("onUserImportModalChange", false);
}, },
errorUpload(err){ errorUpload(err) {
window.location.href = '../ots/login'; //window.location.href = '../ots/login';
} },
} },
} };
</script> </script>
<style> <style>
.import-dialog .upload-wrap .el-upload{ .import-dialog .upload-wrap .el-upload {
width: 100%; width: 100%;
} }
.import-dialog .el-icon-success, .import-dialog .el-icon-error{ .import-dialog .el-icon-success,
.import-dialog .el-icon-error {
font-size: 30px; font-size: 30px;
} }
.import-dialog .result-row .el-col+.el-col{ .import-dialog .result-row .el-col + .el-col {
border-left: 1px solid #eee; border-left: 1px solid #eee;
} }
</style> </style>
\ No newline at end of file \ No newline at end of file
...@@ -34,6 +34,7 @@ const fence = () => import( /*webpackChunkName: "fence"*/ 'pages/monitor/fence. ...@@ -34,6 +34,7 @@ const fence = () => import( /*webpackChunkName: "fence"*/ 'pages/monitor/fence.
const fenceManagement = () => import(/* webpackChunkName: "fenceManagement" */ 'pages/monitor/fenceManagement.vue'); const fenceManagement = () => import(/* webpackChunkName: "fenceManagement" */ 'pages/monitor/fenceManagement.vue');
const editFence = () => import(/* webpackChunkName: "editFence" */ 'pages/monitor/editFence.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 compareLocation = () => import(/* webpackChunkName: "compareLocation" */ 'pages/monitor/compareLocation.vue')
const userCarAdmin = () => import(/* webpackChunkName: "userCarAdmin" */ 'pages/business/userCarAdmin.vue'); const userCarAdmin = () => import(/* webpackChunkName: "userCarAdmin" */ 'pages/business/userCarAdmin.vue');
...@@ -69,12 +70,12 @@ const routes = [ ...@@ -69,12 +70,12 @@ const routes = [
path: '/', path: '/',
name: 'home', name: 'home',
icon: 'fa-home', icon: 'fa-home',
meta: {title:'首页'}, meta: { title: '首页' },
component: home component: home
}, },
{ {
path: '/report', path: '/report',
meta: {title:'统计报表'}, meta: { title: '统计报表' },
icon: 'fa-bar-chart', icon: 'fa-bar-chart',
component: { component: {
template: '<router-view></router-view>' template: '<router-view></router-view>'
...@@ -82,115 +83,115 @@ const routes = [ ...@@ -82,115 +83,115 @@ const routes = [
children: [{ children: [{
path: 'activeList', path: 'activeList',
name: 'activeList', name: 'activeList',
meta: {title:'设备激活'}, meta: { title: '设备激活' },
component: activeList component: activeList
}, },
{ {
path: 'alarmList', path: 'alarmList',
name: 'alarmList', name: 'alarmList',
meta: {title:'围栏预警'}, meta: { title: '围栏预警' },
component: alarmList component: alarmList
}, },
{ {
path: 'outageAlarm', path: 'outageAlarm',
name: 'outageAlarm', name: 'outageAlarm',
meta: {title:'断电报警'}, meta: { title: '断电报警' },
notMenu: true, notMenu: true,
component: outageAlarm component: outageAlarm
}, },
{ {
path: 'antiOffAlarm', path: 'antiOffAlarm',
name: 'antiOffAlarm', name: 'antiOffAlarm',
meta: {title:'防拆报警'}, meta: { title: '防拆报警' },
component: antiOffAlarm component: antiOffAlarm
}, },
{ {
path: 'lastLocation', path: 'lastLocation',
name: 'lastLocation', name: 'lastLocation',
meta: {title:'最后定位报表'}, meta: { title: '最后定位报表' },
component: lastLocation component: lastLocation
},{ }, {
path: 'offlineReport', path: 'offlineReport',
name: 'offlineReport', name: 'offlineReport',
meta: {title:'离线报警'}, meta: { title: '离线报警' },
component: offlineReport component: offlineReport
},{ }, {
path: 'shutdownReport', path: 'shutdownReport',
name: 'shutdownReport', name: 'shutdownReport',
meta: {title:'停驶报警'}, meta: { title: '停驶报警' },
component: shutdownReport component: shutdownReport
},{ }, {
path: 'speedAlarm', path: 'speedAlarm',
name: 'speedAlarm', name: 'speedAlarm',
meta: {title:'超速报警'}, meta: { title: '超速报警' },
component: speedAlarm component: speedAlarm
},{ }, {
path: 'singleDevice', path: 'singleDevice',
name: 'singleDevice', name: 'singleDevice',
meta: {title:'单个超速报警'}, meta: { title: '单个超速报警' },
component: singleDevice, component: singleDevice,
notMenu: true, notMenu: true,
},{ }, {
path: 'mileageStatistics', path: 'mileageStatistics',
name: 'mileageStatistics', name: 'mileageStatistics',
meta: {title:'里程统计'}, meta: { title: '里程统计' },
component: mileageStatistics component: mileageStatistics
},{ }, {
path: 'mileageMapModal', path: 'mileageMapModal',
name: 'mileageMapModal', name: 'mileageMapModal',
meta: {title:'单个里程统计'}, meta: { title: '单个里程统计' },
component: mileageMapModal, component: mileageMapModal,
notMenu: true, notMenu: true,
},{ }, {
path: 'electricityStatistics', path: 'electricityStatistics',
name: 'electricityStatistics', name: 'electricityStatistics',
meta: {title:'电量统计'}, meta: { title: '电量统计' },
component: electricityStatistics component: electricityStatistics
},{ }, {
path: 'alarmCenter', path: 'alarmCenter',
name: 'alarmCenter', name: 'alarmCenter',
meta: {title:'警情中心'}, meta: { title: '警情中心' },
component: alarmCenter component: alarmCenter
},{ }, {
path: 'alarmDispose', path: 'alarmDispose',
name: 'alarmDispose', name: 'alarmDispose',
meta: {title:'警情配置(广汽)'}, meta: { title: '警情配置(广汽)' },
component: alarmDispose component: alarmDispose
},{ }, {
path: 'alarmCore', path: 'alarmCore',
name: 'alarmCore', name: 'alarmCore',
meta: {title:'警情中心(广汽)'}, meta: { title: '警情中心(广汽)' },
component: alarmCore component: alarmCore
},{ }, {
path: 'alarmDetail', path: 'alarmDetail',
name: 'alarmDetail', name: 'alarmDetail',
meta: {title:'警情中心/详情'}, meta: { title: '警情中心/详情' },
component: alarmDetail, component: alarmDetail,
notMenu: true, notMenu: true,
},{ }, {
path: 'alarmFocus', path: 'alarmFocus',
name: 'alarmFocus', name: 'alarmFocus',
meta: {title:'警情中心/我的关注'}, meta: { title: '警情中心/我的关注' },
component: alarmFocus, component: alarmFocus,
notMenu: true, notMenu: true,
},{ }, {
path: 'alarmIgnore', path: 'alarmIgnore',
name: 'alarmIgnore', name: 'alarmIgnore',
meta: {title:'警情中心/忽略的车辆'}, meta: { title: '警情中心/忽略的车辆' },
component: alarmIgnore, component: alarmIgnore,
notMenu: true, notMenu: true,
},{ }, {
path: 'alarmLog', path: 'alarmLog',
name: 'alarmLog', name: 'alarmLog',
meta: {title:'警情中心/处理日志'}, meta: { title: '警情中心/处理日志' },
component: alarmLog, component: alarmLog,
notMenu: true, notMenu: true,
}] }]
}, },
{ {
path: '/monitor', path: '/monitor',
meta: {title:'车辆监控'}, meta: { title: '车辆监控' },
icon: 'fa-car', icon: 'fa-car',
component: { component: {
template: '<router-view></router-view>' template: '<router-view></router-view>'
...@@ -198,68 +199,77 @@ const routes = [ ...@@ -198,68 +199,77 @@ const routes = [
children: [{ children: [{
path: 'monitor', path: 'monitor',
name: 'monitor', name: 'monitor',
meta: {title:'车辆监控'}, meta: { title: '车辆监控' },
component: monitor component: monitor
}, },
{ {
path: 'historyLocation', path: 'historyLocation',
name: 'historyLocation', name: 'historyLocation',
meta: {title:'历史停留'}, meta: { title: '历史停留' },
component: historyLocation, component: historyLocation,
notMenu: true, notMenu: true,
}, },
{ {
path: 'replay', path: 'replay',
name: 'replay', name: 'replay',
meta: {title:'轨迹回放'}, meta: { title: '轨迹回放' },
component: replay, component: replay,
notMenu: true, notMenu: true,
}, },
{ {
path: 'resident', path: 'resident',
name: 'resident', name: 'resident',
meta: {title:'常驻地'}, meta: { title: '常驻地' },
component: resident, component: resident,
notMenu: true, notMenu: true,
}, },
{ {
path: 'fence', path: 'fence',
name: 'fence', name: 'fence',
meta: {title:'电子围栏'}, meta: { title: '电子围栏' },
component: fence, component: fence,
notMenu: true, notMenu: true,
}, },
{ {
path: 'fenceManagement', path: 'fenceManagement',
name: 'fenceManagement', name: 'fenceManagement',
meta: {title:'试驶线路管理'}, meta: { title: '试驶线路管理' },
component: fenceManagement component: fenceManagement
}, },
{ {
path: 'editFence', path: 'editFence',
name: 'editFence', name: 'editFence',
meta: { meta: {
title:'新增线路', title: '新增线路',
pushState: true pushState: true
}, },
component: editFence, component: editFence,
notMenu: true, notMenu: true,
},{ },{
path: 'addFence',
name: 'addFence',
meta: {
title: '新增围栏',
pushState: true
},
component: addFence,
notMenu: true,
}, {
path: 'compareLocation', path: 'compareLocation',
name: 'compareLocation', name: 'compareLocation',
meta: {title:'位置对比'}, meta: { title: '位置对比' },
component: compareLocation component: compareLocation
},{ }, {
path: 'activeLocation', path: 'activeLocation',
name: 'activeLocation', name: 'activeLocation',
meta: {title:'设备激活位置'}, meta: { title: '设备激活位置' },
component: () => import('pages/monitor/activeLocation.vue'), component: () => import('pages/monitor/activeLocation.vue'),
notMenu: true, notMenu: true,
}] }]
}, },
{ {
path: '/business', path: '/business',
meta: {title:'业务管理'}, meta: { title: '业务管理' },
icon: 'fa-briefcase', icon: 'fa-briefcase',
component: { component: {
template: '<router-view></router-view>' template: '<router-view></router-view>'
...@@ -267,7 +277,7 @@ const routes = [ ...@@ -267,7 +277,7 @@ const routes = [
children: [{ children: [{
path: 'userCarAdmin', path: 'userCarAdmin',
name: 'userCarAdmin', name: 'userCarAdmin',
meta: {title:'车辆管理'}, meta: { title: '车辆管理' },
component: userCarAdmin component: userCarAdmin
}, },
/*{ /*{
...@@ -279,34 +289,34 @@ const routes = [ ...@@ -279,34 +289,34 @@ const routes = [
{ {
path: 'workOrderAdmin', path: 'workOrderAdmin',
name: 'workOrderAdmin', name: 'workOrderAdmin',
meta: {title:'工单管理'}, meta: { title: '工单管理' },
component: workOrderAdmin component: workOrderAdmin
}, { }, {
path: 'editOrderPage', path: 'editOrderPage',
name: 'editOrderPage', name: 'editOrderPage',
meta: {title: '编辑工单'}, meta: { title: '编辑工单' },
component: editOrderPage, component: editOrderPage,
notMenu: true, notMenu: true,
}, { }, {
path: 'gqOrder', path: 'gqOrder',
name: 'gqOrder', name: 'gqOrder',
meta: {title:'工单管理(广汽)'}, meta: { title: '工单管理(广汽)' },
component: gqOrder component: gqOrder
}, { }, {
path: 'anjiAccount', path: 'anjiAccount',
name: 'anjiAccount', name: 'anjiAccount',
meta: {title:'对账管理(安吉)'}, meta: { title: '对账管理(安吉)' },
component: anjiAccount component: anjiAccount
}, { }, {
path: 'gqReport', path: 'gqReport',
name: 'gqReport', name: 'gqReport',
meta: {title:'报表管理(广汽)'}, meta: { title: '报表管理(广汽)' },
component: gqReport component: gqReport
}] }]
}, },
{ {
path: '/device', path: '/device',
meta: {title:'设备管理'}, meta: { title: '设备管理' },
icon: 'fa-microchip', icon: 'fa-microchip',
component: { component: {
template: '<router-view></router-view>' template: '<router-view></router-view>'
...@@ -314,33 +324,33 @@ const routes = [ ...@@ -314,33 +324,33 @@ const routes = [
children: [{ children: [{
path: 'deviceType', path: 'deviceType',
name: 'deviceType', name: 'deviceType',
meta: {title:'设备类型'}, meta: { title: '设备类型' },
component: deviceType component: deviceType
},{ }, {
path: 'deviceList', path: 'deviceList',
name: 'deviceList', name: 'deviceList',
meta: {title:'设备管理'}, meta: { title: '设备管理' },
component: deviceList component: deviceList
},{ }, {
path: 'deviceAdminList', path: 'deviceAdminList',
name: 'deviceAdminList', name: 'deviceAdminList',
meta: {title:'入库管理'}, meta: { title: '入库管理' },
component: deviceAdminList component: deviceAdminList
},{ }, {
path: 'policyDeviceImport', path: 'policyDeviceImport',
name: 'policyDeviceImport', name: 'policyDeviceImport',
meta: {title:'保单设备导入'}, meta: { title: '保单设备导入' },
component: policyDeviceImport component: policyDeviceImport
},{ }, {
path: 'xfDeviceAdminList', path: 'xfDeviceAdminList',
name: 'xfDeviceAdminList', name: 'xfDeviceAdminList',
meta: {title:'先锋太盟设备管理'}, meta: { title: '先锋太盟设备管理' },
component: xfDeviceAdminList component: xfDeviceAdminList
}] }]
}, },
{ {
path: '/accounts', path: '/accounts',
meta: {title:'汇通分账'}, meta: { title: '汇通分账' },
icon: 'fa-cogs', icon: 'fa-cogs',
component: { component: {
template: '<router-view></router-view>' template: '<router-view></router-view>'
...@@ -348,19 +358,19 @@ const routes = [ ...@@ -348,19 +358,19 @@ const routes = [
children: [{ children: [{
path: 'accountsList', path: 'accountsList',
name: 'accountsList', name: 'accountsList',
meta: {title:'汇通分账'}, meta: { title: '汇通分账' },
component: accountsList component: accountsList
}, { }, {
path: 'accountsDetail', path: 'accountsDetail',
name: 'accountsDetail', name: 'accountsDetail',
meta: {title:'汇通分账详情'}, meta: { title: '汇通分账详情' },
component: accountsDetail, component: accountsDetail,
notMenu: true notMenu: true
}] }]
}, },
{ {
path: '/stock', path: '/stock',
meta: {title:'库存管理'}, meta: { title: '库存管理' },
icon: 'fa-cubes', icon: 'fa-cubes',
component: { component: {
template: '<router-view></router-view>' template: '<router-view></router-view>'
...@@ -368,18 +378,18 @@ const routes = [ ...@@ -368,18 +378,18 @@ const routes = [
children: [{ children: [{
path: 'stockList', path: 'stockList',
name: 'stockList', name: 'stockList',
meta: {title:'库存信息'}, meta: { title: '库存信息' },
component: stockList, component: stockList,
}, { }, {
path: 'stockDeviceList', path: 'stockDeviceList',
name: 'stockDeviceList', name: 'stockDeviceList',
meta: {title:'设备明细'}, meta: { title: '设备明细' },
component: stockDeviceList, component: stockDeviceList,
}] }]
}, },
{ {
path: '/system', path: '/system',
meta: {title:'系统管理'}, meta: { title: '系统管理' },
icon: 'fa-cogs', icon: 'fa-cogs',
component: { component: {
template: '<router-view></router-view>' template: '<router-view></router-view>'
...@@ -387,30 +397,30 @@ const routes = [ ...@@ -387,30 +397,30 @@ const routes = [
children: [{ children: [{
path: 'personalInfo', path: 'personalInfo',
name: 'personalInfo', name: 'personalInfo',
meta: {title:'个人信息'}, meta: { title: '个人信息' },
component: personalInfo component: personalInfo
}] }]
}, },
{ {
path: '/notice', path: '/notice',
name: 'notice', name: 'notice',
meta: {title:'系统公告'}, meta: { title: '系统公告' },
component: notice, component: notice,
notMenu: true, notMenu: true,
}, },
{ {
path: '/tool', path: '/tool',
name: 'tool', name: 'tool',
meta: {title:'工具'}, meta: { title: '工具' },
icon: 'fa-download', icon: 'fa-download',
component: tool component: tool
}, },
] ]
function getFullPath(arr, prefix=''){ function getFullPath(arr, prefix = '') {
return arr.map((item)=>{ return arr.map((item) => {
item.fullPath = `${prefix}${item.path}` item.fullPath = `${prefix}${item.path}`
if(item.children && item.children.length){ if (item.children && item.children.length) {
let children = getFullPath([...item.children], `${item.path}/`) let children = getFullPath([...item.children], `${item.path}/`)
return { return {
...item, ...item,
...@@ -421,7 +431,7 @@ function getFullPath(arr, prefix=''){ ...@@ -421,7 +431,7 @@ function getFullPath(arr, prefix=''){
return { return {
...item, ...item,
url: item.fullPath, url: item.fullPath,
title: item.meta&&item.meta.title, title: item.meta && item.meta.title,
} }
}) })
} }
...@@ -429,21 +439,21 @@ function getFullPath(arr, prefix=''){ ...@@ -429,21 +439,21 @@ function getFullPath(arr, prefix=''){
/* const _routes = getFullPath(routes) /* const _routes = getFullPath(routes)
console.log(JSON.stringify(_routes)) */ console.log(JSON.stringify(_routes)) */
function filterRoutes(arr, path, initArr=[]){ function filterRoutes(arr, path, initArr = []) {
arr.reduce((prevArr, item)=>{ arr.reduce((prevArr, item) => {
if(item.notMenu) { if (item.notMenu) {
initArr.push({ initArr.push({
...item ...item
}) })
}else{ } else {
if(path.indexOf(item.url)>-1){ if (path.indexOf(item.url) > -1) {
if(item.children && item.children.length){ if (item.children && item.children.length) {
initArr.push({ initArr.push({
...item, ...item,
children: filterRoutes(item.children, path) children: filterRoutes(item.children, path)
}) })
}else{ } else {
initArr.push({ initArr.push({
...item ...item
}) })
...@@ -456,25 +466,25 @@ function filterRoutes(arr, path, initArr=[]){ ...@@ -456,25 +466,25 @@ function filterRoutes(arr, path, initArr=[]){
return initArr return initArr
} }
function getPathArr(arr, prevArr=[]){ function getPathArr(arr, prevArr = []) {
return arr.reduce((prevArr, item)=>{ return arr.reduce((prevArr, item) => {
prevArr.push(item.url) prevArr.push(item.url)
if(item.children && item.children.length){ if (item.children && item.children.length) {
getPathArr(item.children, prevArr) getPathArr(item.children, prevArr)
} }
return prevArr return prevArr
}, prevArr) }, prevArr)
} }
function filterMenuItems(arr, initArr=[]){ function filterMenuItems(arr, initArr = []) {
return arr.reduce((prevArr, item)=>{ return arr.reduce((prevArr, item) => {
if(!item.notMenu) { if (!item.notMenu) {
if(item.children && item.children.length){ if (item.children && item.children.length) {
initArr.push({ initArr.push({
...item, ...item,
children: filterMenuItems(item.children) children: filterMenuItems(item.children)
}) })
}else{ } else {
initArr.push({ initArr.push({
...item ...item
}) })
...@@ -486,32 +496,32 @@ function filterMenuItems(arr, initArr=[]){ ...@@ -486,32 +496,32 @@ function filterMenuItems(arr, initArr=[]){
} }
function getMenuItems(arr){ function getMenuItems(arr) {
return arr.map((item)=>{ return arr.map((item) => {
const _url = item.url.split('') const _url = item.url.split('')
_url.shift() _url.shift()
let index = _url.join('') let index = _url.join('')
if(item.children && item.children.length){ if (item.children && item.children.length) {
let children = getMenuItems([...item.children]) let children = getMenuItems([...item.children])
return { return {
index, index,
icon: item.icon, icon: item.icon,
title: item.meta&&item.meta.title, title: item.meta && item.meta.title,
children, children,
} }
} }
return { return {
index, index,
icon: item.icon, 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]; let _item = arr[0];
if(_item.children && _item.children.length){ if (_item.children && _item.children.length) {
return getFirstPath(_item.children) return getFirstPath(_item.children)
} }
return _item.url return _item.url
...@@ -522,51 +532,51 @@ let firstPath = '/' ...@@ -522,51 +532,51 @@ let firstPath = '/'
// router.beforeEach((to, from, next) => { // router.beforeEach((to, from, next) => {
// document.title = '虎哥e盾|'+to.meta.title; // document.title = '虎哥e盾|'+to.meta.title;
// if(store.getters.roleType === undefined){ // if(store.getters.roleType === undefined){
// store.dispatch('getRoleInfo').then((data)=>{ // store.dispatch('getRoleInfo').then((data)=>{
// if(data && data.permission){ // if(data && data.permission){
// const allPath = getPathArr(data.permission) // const allPath = getPathArr(data.permission)
// const fullPathRoutes = getFullPath(routes) // const fullPathRoutes = getFullPath(routes)
// const allRoutes = filterRoutes(fullPathRoutes, allPath) // const allRoutes = filterRoutes(fullPathRoutes, allPath)
// const menuItems = getMenuItems(filterMenuItems([...allRoutes])) // const menuItems = getMenuItems(filterMenuItems([...allRoutes]))
// firstPath = getFirstPath(allRoutes) // firstPath = getFirstPath(allRoutes)
// store.dispatch('setPermission', menuItems) // store.dispatch('setPermission', menuItems)
// router.addRoutes(allRoutes) // router.addRoutes(allRoutes)
// } // }
// if(to.path === '/' && to.matched.length === 0){ // if(to.path === '/' && to.matched.length === 0){
// next({ // next({
// ...to, // ...to,
// path: firstPath // path: firstPath
// }) // })
// return; // return;
// } // }
// if(store.getters.zlAccount && to.path === '/'){ // if(store.getters.zlAccount && to.path === '/'){
// next({path: '/monitor/monitor'}) // next({path: '/monitor/monitor'})
// return; // return;
// } // }
// next({...to}) // next({...to})
// }); // });
// }else{ // }else{
// if(to.path === '/' && to.matched.length === 0){ // if(to.path === '/' && to.matched.length === 0){
// next({ // next({
// ...to, // ...to,
// path: firstPath // path: firstPath
// }) // })
// return; // return;
// } // }
// if(store.getters.zlAccount && to.path === '/'){ // if(store.getters.zlAccount && to.path === '/'){
// next({path: '/monitor/monitor'}) // next({path: '/monitor/monitor'})
// return; // return;
// } // }
// next() // next()
// } // }
// next(); // next();
// }) // })
export default routes export default routes
\ No newline at end of file \ No newline at end of file
import EventBus from '../event-bus' import EventBus from '@/event-bus'
import mapService from './mapService.js' import mapService from './mapService.js'
import MAPGEO from './mapgeo' import MAPGEO from './mapgeo'
...@@ -7,36 +7,36 @@ const fence = { ...@@ -7,36 +7,36 @@ const fence = {
polygons: [], polygons: [],
circle: null, circle: null,
isEditMode: true, isEditMode: true,
bindEvent(){ bindEvent() {
EventBus.$on('uiMap.fence.drawDistrict', (data)=>{ EventBus.$on('uiMap.fence.drawDistrict', (data) => {
this.drawDistrict(data) this.drawDistrict(data)
}); });
EventBus.$on('uiMap.fence.createFenceCircle', (data)=>{ EventBus.$on('uiMap.fence.createFenceCircle', (data) => {
if(('isEdit' in data)&&!data.isEdit){ if (('isEdit' in data) && !data.isEdit) {
this.isEditMode = false this.isEditMode = false
}else{ } else {
this.isEditMode = true this.isEditMode = true
} }
this.createFenceCircle(data) this.createFenceCircle(data)
}); });
EventBus.$on('uiMap.fence.updateFenceRadius', (data)=>{ EventBus.$on('uiMap.fence.updateFenceRadius', (data) => {
this.circle.setRadius(data*1); this.circle.setRadius(data * 1);
mapService.setFitView() mapService.setFitView()
}); });
EventBus.$on('uiMap.fence.createFenceMarker', (data)=>{ EventBus.$on('uiMap.fence.createFenceMarker', (data) => {
this.createFenceMarker(data) this.createFenceMarker(data)
}); });
EventBus.$on('uiMap.fence.drawPolygon', (data)=>{ EventBus.$on('uiMap.fence.drawPolygon', (data) => {
if(data){ if (data) {
if(Array.isArray(data)){ if (Array.isArray(data)) {
this.polygonPath = data; this.polygonPath = data;
this.isEditMode = true; this.isEditMode = true;
}else if(('isEdit' in data)&&!data.isEdit){ } else if (('isEdit' in data) && !data.isEdit) {
this.polygonPath = data.path; this.polygonPath = data.path;
this.isEditMode = false; this.isEditMode = false;
} }
...@@ -44,13 +44,14 @@ const fence = { ...@@ -44,13 +44,14 @@ const fence = {
this.drawPolygon() this.drawPolygon()
}); });
EventBus.$on('uiMap.fence.destroy', (data)=>{ EventBus.$on('uiMap.fence.destroy', (data) => {
this.polyEditor && this.polyEditor.close() this.polyEditor && this.polyEditor.close()
this.mouseTool && this.mouseTool.close() this.mouseTool && this.mouseTool.close()
}); });
}, },
destroy(){ destroy() {
const MAP = mapService.map; const MAP = mapService.map;
if (MAP) {
this.polygons && MAP.remove(this.polygons); this.polygons && MAP.remove(this.polygons);
this.circle && MAP.remove(this.circle); this.circle && MAP.remove(this.circle);
this.circleEditor && this.circleEditor.close();//MAP.remove(this.circleEditor); this.circleEditor && this.circleEditor.close();//MAP.remove(this.circleEditor);
...@@ -58,23 +59,42 @@ const fence = { ...@@ -58,23 +59,42 @@ const fence = {
this.polyEditor && this.polyEditor.close() this.polyEditor && this.polyEditor.close()
this.mouseTool && this.mouseTool.close() this.mouseTool && this.mouseTool.close()
this.polygon && MAP.remove(this.polygon) this.polygon && MAP.remove(this.polygon)
this.clearTimeoutIds(); }
//this.clearTimeoutIds();
}, },
drawDistrict(data){
// 行政区域
drawDistrict(data) {
if (!data || data.length <= 0) {
return false;
}
const MAP = mapService.map; const MAP = mapService.map;
this.destroy(); this.destroy();
var opts = { var opts = {
subdistrict: 1, //返回下一级行政区 subdistrict: 0, //返回下一级行政区
extensions: 'all', 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); let district = new AMap.DistrictSearch(opts);
switch (data.length) {
case 1:
district.setLevel('province');
break;
case 2:
district.setLevel('city');
break;
default:
district.setLevel('district'); district.setLevel('district');
EventBus.$emit('uiMap.fence.loading', true); 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]; const dst = result.districtList[0];
var bounds = dst.boundaries; var bounds = dst.boundaries;
let lng = dst.center.lng; let lng = dst.center.lng;
...@@ -93,25 +113,22 @@ const fence = { ...@@ -93,25 +113,22 @@ const fence = {
}); });
fence.polygons.push(polygon); fence.polygons.push(polygon);
} }
let center = mapService.getLngLat(lng, lat);
let center = mapService.getLngLat(lng,lat);
mapService.setFitView(); mapService.setFitView();
EventBus.$emit('uiMap.fence.loading', false); //EventBus.$emit('uiMap.fence.loading', false);
} }
}); });
}, },
createFenceCircle(data){ createFenceCircle(data) {
const MAP = mapService.map; const MAP = mapService.map;
//this.destroy(); this.destroy();
this.circle = new AMap.Circle({ this.circle = new AMap.Circle({
map: MAP, map: MAP,
center: mapService.getLngLat(data.lng, data.lat), center: mapService.getLngLat(data.lng, data.lat),
radius: data.radius*1, radius: data.radius * 1,
strokeColor: "#F33", strokeColor: "#F33",
strokeOpacity: 1, strokeOpacity: 1,
strokeWeight: 3, strokeWeight: 3,
...@@ -121,29 +138,20 @@ const fence = { ...@@ -121,29 +138,20 @@ const fence = {
}); });
this.circleEditor = new AMap.CircleEditor(MAP, this.circle); 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)
})
AMap.event.addListener(this.circleEditor, 'adjust', (e)=>{ this.circleEditor.on('move', function (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)=>{
EventBus.$emit('uiMap.fence.onFenceLngLatChange', { EventBus.$emit('uiMap.fence.onFenceLngLatChange', {
lng: e.lnglat.lng, lng: e.lnglat.lng,
lat: e.lnglat.lat lat: e.lnglat.lat
}); });
}); })
if(this.isEditMode){ if (this.isEditMode) {
this.circleEditor.open(); this.circleEditor.open();
}else{ } else {
this.circleEditor.close(); this.circleEditor.close();
} }
...@@ -151,34 +159,35 @@ const fence = { ...@@ -151,34 +159,35 @@ const fence = {
mapService.setFitView() mapService.setFitView()
MAP.setZoom(14); MAP.setZoom(14);
}, },
createFenceMarker(data){ createFenceMarker(data) {
this.data = [{ this.data = [{
elng: data.lngGPS, elng: data.lngGPS,
elat: data.latGPS elat: data.latGPS
}]; }];
if(data.lngBase && data.latBase){ if (data.lngBase && data.latBase) {
this.data.push({ this.data.push({
elng: data.lngBase, elng: data.lngBase,
elat: data.latBase elat: data.latBase
}); });
} }
const MAP = mapService.map; const MAP = mapService.map;
MAPGEO.transferAddressByGroup(this, ()=>{ //MAPGEO.transferAddressByGroup(this, ()=>{
data.transferAddressGPS = this.data[0].transferAddress; //data.transferAddressGPS = this.data[0].transferAddress;
if(this.data.length > 1){ // if(this.data.length > 1){
data.transferAddressBase = this.data[1].transferAddress; // data.transferAddressBase = this.data[1].transferAddress;
} // }
console.log(data)
let marker = mapService.createCarMarker([data.lngGPS, data.latGPS], MAP); let marker = mapService.createCarMarker([data.lngGPS, data.latGPS], MAP);
let infoWindow = mapService.bindFenceInfoWindow(marker, MAP, data); let infoWindow = mapService.bindFenceInfoWindow(marker, MAP, data);
}); //});
}, },
drawPolygon(){ drawPolygon() {
const MAP = mapService.map; const MAP = mapService.map;
const self = this; const self = this;
//this.destroy(); this.destroy();
if(this.polygonPath.length){ if (this.polygonPath.length) {
self.polygon = new AMap.Polygon({ self.polygon = new AMap.Polygon({
path: this.polygonPath, path: this.polygonPath,
strokeColor: "#FF33FF", strokeColor: "#FF33FF",
...@@ -190,17 +199,17 @@ const fence = { ...@@ -190,17 +199,17 @@ const fence = {
}) })
MAP.add(self.polygon) MAP.add(self.polygon)
MAP.setFitView([ self.polygon ]) MAP.setFitView([self.polygon])
self.polyEditor = new AMap.PolyEditor(MAP, self.polygon) self.polyEditor = new AMap.PolyEditor(MAP, self.polygon)
if(self.isEditMode){ if (self.isEditMode) {
self.polyEditor.open() self.polyEditor.open()
}else{ } else {
self.polyEditor.close() self.polyEditor.close()
} }
self.bindPolyEvent(self.polyEditor) self.bindPolyEvent(self.polyEditor)
}else if(self.isEditMode){ } else if (self.isEditMode) {
self.mouseTool = new AMap.MouseTool(MAP) self.mouseTool = new AMap.MouseTool(MAP)
self.mouseTool.polygon({ self.mouseTool.polygon({
...@@ -216,7 +225,7 @@ const fence = { ...@@ -216,7 +225,7 @@ const fence = {
// strokeDasharray: [30,10], // strokeDasharray: [30,10],
}) })
self.mouseTool.on('draw', function(event) { self.mouseTool.on('draw', function (event) {
// event.obj 为绘制出来的覆盖物对象 // event.obj 为绘制出来的覆盖物对象
self.polygon = event.obj; self.polygon = event.obj;
self.polyEditor = new AMap.PolyEditor(MAP, self.polygon) self.polyEditor = new AMap.PolyEditor(MAP, self.polygon)
...@@ -229,44 +238,44 @@ const fence = { ...@@ -229,44 +238,44 @@ const fence = {
} }
}, },
bindPolyEvent(polyEditor){ bindPolyEvent(polyEditor) {
const self = this const self = this
polyEditor.on('addnode', function(event) { polyEditor.on('addnode', function (event) {
console.log('触发事件:addnode') console.log('触发事件:addnode')
self.emitPolyEvent() self.emitPolyEvent()
}) })
polyEditor.on('adjust', function(event) { polyEditor.on('adjust', function (event) {
console.log('触发事件:adjust') console.log('触发事件:adjust')
self.emitPolyEvent() self.emitPolyEvent()
}) })
polyEditor.on('removenode', function(event) { polyEditor.on('removenode', function (event) {
console.log('触发事件:removenode') console.log('触发事件:removenode')
self.emitPolyEvent() self.emitPolyEvent()
}) })
polyEditor.on('end', function(event) { polyEditor.on('end', function (event) {
console.log('触发事件: end') console.log('触发事件: end')
self.emitPolyEvent() self.emitPolyEvent()
// event.target 即为编辑后的多边形对象 // event.target 即为编辑后的多边形对象
}) })
}, },
emitPolyEvent(){ emitPolyEvent() {
let pathArr = this.polygon.getPath() let pathArr = this.polygon.getPath()
let resultArr = pathArr.map((item)=>{ let resultArr = pathArr.map((item) => {
return [item.lng, item.lat] return [item.lng, item.lat]
}) })
this.polygonPath = resultArr this.polygonPath = resultArr
EventBus.$emit('uiMap.fence.polygonChange',{ EventBus.$emit('uiMap.fence.polygonChange', {
polygonPath: this.polygonPath polygonPath: this.polygonPath
}); });
console.log(resultArr.join('|')) console.log(resultArr.join('|'))
}, },
clearTimeoutIds(){ clearTimeoutIds() {
this.timeoutIds && this.timeoutIds.forEach((item)=>{ this.timeoutIds && this.timeoutIds.forEach((item) => {
item && window.clearTimeout(item); item && window.clearTimeout(item);
}); });
this.timeoutIds = [] this.timeoutIds = []
......
...@@ -3,7 +3,8 @@ window.ClipboardJS = ClipboardJS ...@@ -3,7 +3,8 @@ window.ClipboardJS = ClipboardJS
import EventBus from '../event-bus' import EventBus from '../event-bus'
import { Message } from "element-ui"; import { Message } from "element-ui";
import store from '../vuex/store.js' import store from '../vuex/store.js'
EventBus.$on('uiMap.copySuccess', (data)=>{ import vue from 'vue'
EventBus.$on('uiMap.copySuccess', (data) => {
Message({ Message({
type: 'success', type: 'success',
message: '已复制内容至粘贴板' message: '已复制内容至粘贴板'
...@@ -12,37 +13,46 @@ EventBus.$on('uiMap.copySuccess', (data)=>{ ...@@ -12,37 +13,46 @@ EventBus.$on('uiMap.copySuccess', (data)=>{
function MapService(){ function MapService() {
this.map = null; this.map = null;
this.restainLayer = null; this.restainLayer = null;
} }
var zhongliType = sessionStorage.getItem('zhongliType');//获取是否仲利账号状态,从本地内存中拿取数据 var zhongliType = sessionStorage.getItem('zhongliType');//获取是否仲利账号状态,从本地内存中拿取数据
MapService.prototype = { MapService.prototype = {
init: function(id){ init: function (id) {
var self = this; var self = this;
self.map = new AMap.Map(id, { var map = new AMap.Map(id, {
resizeEnable: true, resizeEnable: true,
zoom: 11 zoom: 11
}); });
// 添加比例尺
map.plugin(["AMap.Scale"], function () {
var scale = new AMap.Scale()
map.addControl(scale);
scale.show()
});
//距离测量 //距离测量
self.map.plugin(["AMap.RangingTool"],function(){ map.plugin(["AMap.RangingTool"], function () {
self.ruler = new AMap.RangingTool(self.map); self.ruler = new AMap.RangingTool(map);
}); });
//定位 //定位
self.map.plugin('AMap.Geolocation', function(){ map.plugin('AMap.Geolocation', function () {
self.geolocation = new AMap.Geolocation(); self.geolocation = new AMap.Geolocation();
}); });
self.map = map;
return self.map; return self.map;
}, },
toggleMapType: function(){ toggleMapType: function () {
var self = this; 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.Satellite(),
...@@ -52,7 +62,7 @@ MapService.prototype = { ...@@ -52,7 +62,7 @@ MapService.prototype = {
let layers = self.mixLayers.concat(self.map.getLayers()); let layers = self.mixLayers.concat(self.map.getLayers());
// 地图上设置图层 // 地图上设置图层
self.map.setLayers(layers); self.map.setLayers(layers);
}else{ } else {
// 地图上设置图层 // 地图上设置图层
self.map.remove(self.mixLayers); self.map.remove(self.mixLayers);
/*self.map.plugin(["AMap.MapType"],function(){ /*self.map.plugin(["AMap.MapType"],function(){
...@@ -64,69 +74,69 @@ MapService.prototype = { ...@@ -64,69 +74,69 @@ MapService.prototype = {
});*/ });*/
} }
}, },
rulerTurnOn: function(){ rulerTurnOn: function () {
this.ruler.turnOn(); this.ruler.turnOn();
}, },
rulerTurnOff: function(){ rulerTurnOff: function () {
this.ruler.turnOff(); this.ruler.turnOff();
}, },
getCurrentLocation: function(){ getCurrentLocation: function () {
var self = this; var self = this;
self.geolocation.getCurrentPosition(); self.geolocation.getCurrentPosition();
self.currentMarker && self.map.remove(self.currentMarker); 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); var lnglatXY = self.getLngLat(e.position.lng, e.position.lat);
self.currentMarker = self.createMarker(lnglatXY); self.currentMarker = self.createMarker(lnglatXY);
//self.map.setCenter(lnglatXY); //self.map.setCenter(lnglatXY);
self.setFitView() 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({ var marker = new AMap.Marker({
position: lnglatXY, position: lnglatXY,
icon: require('images/mapLocation.gif'), icon: require('images/mapLocation.gif'),
map: this.map, map: this.map,
offset: new AMap.Pixel(-12,-12) offset: new AMap.Pixel(-12, -12)
}); });
return marker; return marker;
}, },
createPointMarker: function (lnglatXY){ createPointMarker: function (lnglatXY) {
var marker = new AMap.Marker({ var marker = new AMap.Marker({
position: lnglatXY, position: lnglatXY,
icon: require('images/point.png'), icon: require('images/point.png'),
map: this.map, map: this.map,
offset: new AMap.Pixel(-9,-9) offset: new AMap.Pixel(-9, -9)
}); });
return marker; return marker;
}, },
createConstantMarker: function (lnglatXY, map){ createConstantMarker: function (lnglatXY, map) {
var marker = new AMap.Marker({ var marker = new AMap.Marker({
position: lnglatXY, position: lnglatXY,
icon: require('images/icon_constant.png'), icon: require('images/icon_constant.png'),
map: map, map: map,
offset: new AMap.Pixel(-12,-17) offset: new AMap.Pixel(-12, -17)
}); });
return marker; return marker;
}, },
createCarMarker: function (lnglatXY, map){ createCarMarker: function (lnglatXY, map) {
var marker = new AMap.Marker({ var marker = new AMap.Marker({
position: lnglatXY, position: lnglatXY,
icon: require('images/icon_car.png'), icon: require('images/icon_car.png'),
map: map, map: map,
autoRotation: true, autoRotation: true,
offset: new AMap.Pixel(-18,-11), offset: new AMap.Pixel(-18, -11),
zIndex: 1020, zIndex: 1020,
animation: 'AMAP_ANIMATION_DROP' animation: 'AMAP_ANIMATION_DROP'
}); });
return marker; return marker;
}, },
createPOIMarker(lnglatXY, map){ createPOIMarker(lnglatXY, map) {
var marker = new AMap.Marker({ var marker = new AMap.Marker({
position: lnglatXY, position: lnglatXY,
content:`<span class="poi_marker"></span>`, content: `<span class="poi_marker"></span>`,
//icon: require('images/poi-marker-default.png'), //icon: require('images/poi-marker-default.png'),
map: map, map: map,
autoRotation: true, autoRotation: true,
...@@ -136,7 +146,7 @@ MapService.prototype = { ...@@ -136,7 +146,7 @@ MapService.prototype = {
}); });
return marker; return marker;
}, },
createPOIInfo(info){ createPOIInfo(info) {
return `<div class="poi_infowin"> return `<div class="poi_infowin">
<h3 class="map-infowindow-title">POI信息</h3> <h3 class="map-infowindow-title">POI信息</h3>
<div class="map-infowindow-ct"> <div class="map-infowindow-ct">
...@@ -146,7 +156,7 @@ MapService.prototype = { ...@@ -146,7 +156,7 @@ MapService.prototype = {
<p class="poi_item"><label>解析地址:</label><span>${info.address}</span> <p class="poi_item"><label>解析地址:</label><span>${info.address}</span>
</div></div>` </div></div>`
}, },
bindPOIInfoWindow(marker, map, info){ bindPOIInfoWindow(marker, map, info) {
var infoDiv = document.createElement('div'); var infoDiv = document.createElement('div');
infoDiv.innerHTML = this.createPOIInfo(info); infoDiv.innerHTML = this.createPOIInfo(info);
...@@ -157,59 +167,59 @@ MapService.prototype = { ...@@ -157,59 +167,59 @@ MapService.prototype = {
}); });
marker.infoWindow = infoWindow; marker.infoWindow = infoWindow;
marker.on('click', markerClick); marker.on('click', markerClick);
function markerClick(e){ function markerClick(e) {
//infoWindow.setContent(e.target.content); //infoWindow.setContent(e.target.content);
infoWindow.open(map, e.target.getPosition()); infoWindow.open(map, e.target.getPosition());
} }
return infoWindow; return infoWindow;
}, },
setAlarmIcon(marker){ setAlarmIcon(marker) {
marker.setIcon(require('images/icon_car_alarm.png')) marker.setIcon(require('images/icon_car_alarm.png'))
}, },
setDefaultIcon(marker){ setDefaultIcon(marker) {
marker.setIcon(require('images/icon_car.png')) marker.setIcon(require('images/icon_car.png'))
}, },
createHistoryLocationMarker(lnglatXY, map){ createHistoryLocationMarker(lnglatXY, map) {
var marker = new AMap.Marker({ var marker = new AMap.Marker({
position: lnglatXY, position: lnglatXY,
icon: require('images/icon_location.png'), icon: require('images/icon_location.png'),
map: map, map: map,
autoRotation: true, autoRotation: true,
offset: new AMap.Pixel(-12,-17), offset: new AMap.Pixel(-12, -17),
zIndex: 1020, zIndex: 1020,
animation: 'AMAP_ANIMATION_DROP' animation: 'AMAP_ANIMATION_DROP'
}); });
return marker; return marker;
}, },
createStartMarker: function(lnglatXY, map){ createStartMarker: function (lnglatXY, map) {
var marker = new AMap.Marker({ var marker = new AMap.Marker({
position: lnglatXY, position: lnglatXY,
icon: require('images/icon_start.png'), icon: require('images/icon_start.png'),
map: map, map: map,
offset: new AMap.Pixel(-12,-34), offset: new AMap.Pixel(-12, -34),
zIndex: 100 zIndex: 100
}); });
return marker; return marker;
}, },
createEndMarker: function(lnglatXY, map){ createEndMarker: function (lnglatXY, map) {
var marker = new AMap.Marker({ var marker = new AMap.Marker({
position: lnglatXY, position: lnglatXY,
icon: require('images/icon_end.png'), icon: require('images/icon_end.png'),
map: map, map: map,
offset: new AMap.Pixel(-12,-34), offset: new AMap.Pixel(-12, -34),
zIndex: 101 zIndex: 101
}); });
return marker; return marker;
}, },
createPolyline: function(map){ createPolyline: function (map) {
return new AMap.Polyline({ return new AMap.Polyline({
map: map, map: map,
strokeWeight: 2, strokeWeight: 2,
strokeColor: '#009944' strokeColor: '#009944'
}); });
}, },
createCircle: function(lnglatXY, map, radius){ createCircle: function (lnglatXY, map, radius) {
return new AMap.Circle({ return new AMap.Circle({
map: map, map: map,
center: lnglatXY, center: lnglatXY,
...@@ -221,7 +231,7 @@ MapService.prototype = { ...@@ -221,7 +231,7 @@ MapService.prototype = {
fillOpacity: 0.1 fillOpacity: 0.1
}); });
}, },
createPoint: function(lnglatXY, map){ createPoint: function (lnglatXY, map) {
return new AMap.Circle({ return new AMap.Circle({
map: map, map: map,
center: lnglatXY, center: lnglatXY,
...@@ -233,7 +243,7 @@ MapService.prototype = { ...@@ -233,7 +243,7 @@ MapService.prototype = {
fillOpacity: 1 fillOpacity: 1
}); });
}, },
createInfoWindow(marker, map, div, isInfoOpen, isInfoAutoMove){ createInfoWindow(marker, map, div, isInfoOpen, isInfoAutoMove) {
var infoWindow = new AMap.InfoWindow({ var infoWindow = new AMap.InfoWindow({
offset: new AMap.Pixel(0, 0), offset: new AMap.Pixel(0, 0),
content: div, content: div,
...@@ -241,29 +251,32 @@ MapService.prototype = { ...@@ -241,29 +251,32 @@ MapService.prototype = {
}); });
marker.infoWindow = infoWindow; marker.infoWindow = infoWindow;
var clipboard = new ClipboardJS(div.querySelector('.copy-btn')); var clipboard = new ClipboardJS(div.querySelector('.copy-btn'));
clipboard.on('success', function(e) { clipboard.on('success', function (e) {
e.clearSelection(); e.clearSelection();
EventBus.$emit('uiMap.copySuccess'); EventBus.$emit('uiMap.copySuccess');
}); });
clipboard.on('error', function(e) { clipboard.on('error', function (e) {
console.error('Action:', e.action); console.error('Action:', e.action);
console.error('Trigger:', e.trigger); console.error('Trigger:', e.trigger);
}); });
if(isInfoOpen){ if (isInfoOpen) {
infoWindow.open(map, marker.getPosition()); infoWindow.open(map, marker.getPosition());
} }
//给Marker绑定单击事件 //给Marker绑定单击事件
marker.on('click', markerClick); marker.on('click', markerClick);
function markerClick(e){ function markerClick(e) {
//infoWindow.setContent(e.target.content); //infoWindow.setContent(e.target.content);
infoWindow.open(map, e.target.getPosition()); infoWindow.open(map, e.target.getPosition());
} }
return infoWindow; return infoWindow;
}, },
bindMonitorInfoWindow: function(marker, map, info, isInfoOpen, isInfoAutoMove){
// 车辆监控-查看位置点
bindMonitorInfoWindow: function (marker, map, info, isInfoOpen, isInfoAutoMove) {
console.log(info)
var self = this; var self = this;
var infoDiv = document.createElement('div'); var infoDiv = document.createElement('div');
infoDiv.innerHTML = self.createMonitorInfo(info); infoDiv.innerHTML = self.createMonitorInfo(info);
...@@ -271,9 +284,9 @@ MapService.prototype = { ...@@ -271,9 +284,9 @@ MapService.prototype = {
let eLocation = info[info.eLocateType]; let eLocation = info[info.eLocateType];
var statusArr = ['行驶中', '静止', '离线', '在线'] var statusArr = ['行驶中', '静止', '离线', '在线']
if(info.status === 2){ if (info.status === 2) {
infoDiv.querySelector('[data-status]').textContent = `${statusArr[info.status]} | 已离线${info.statusTime}`; infoDiv.querySelector('[data-status]').textContent = `${statusArr[info.status]} | 已离线${info.statusTime}`;
}else{ } else {
infoDiv.querySelector('[data-status]').textContent = statusArr[info.status]; infoDiv.querySelector('[data-status]').textContent = statusArr[info.status];
} }
...@@ -281,31 +294,33 @@ MapService.prototype = { ...@@ -281,31 +294,33 @@ MapService.prototype = {
infoDiv.querySelector('[data-transferAddress]').textContent = eLocation.transferAddress; infoDiv.querySelector('[data-transferAddress]').textContent = eLocation.transferAddress;
infoDiv.querySelector('[data-clipboard-text').setAttribute('data-clipboard-text', 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]').classList.remove('hide');
infoDiv.querySelector('[data-battery-percentage]').style.width = info.battery; infoDiv.querySelector('[data-battery-percentage]').style.width = info.battery;
infoDiv.querySelector('[data-battery-text]').textContent = info.battery; infoDiv.querySelector('[data-battery-text]').textContent = info.battery;
}else{ } else {
infoDiv.querySelector('[data-battery]').classList.add('hide'); infoDiv.querySelector('[data-battery]').classList.add('hide');
} }
let gpsBtn = infoDiv.querySelector('[data-gps]') let gpsBtn = infoDiv.querySelector('[data-gps]')
let baseBtn = infoDiv.querySelector('[data-base]') let baseBtn = infoDiv.querySelector('[data-base]')
let wifiBtn = infoDiv.querySelector('[data-wifi]') let wifiBtn = infoDiv.querySelector('[data-wifi]')
console.log(info.eLocateType)
if(info.eLocateType === 'bsLocation'){ //console.log(info.eLocateType)
gpsBtn&&gpsBtn.classList.remove('el-button--primary'); if (info.eLocateType === 'bsLocation') {
gpsBtn && gpsBtn.classList.remove('el-button--primary');
baseBtn.classList.add('el-button--primary'); baseBtn.classList.add('el-button--primary');
}else{ } else {
gpsBtn&&gpsBtn.classList.add('el-button--primary'); gpsBtn && gpsBtn.classList.add('el-button--primary');
baseBtn&&baseBtn.classList.remove('el-button--primary'); baseBtn && baseBtn.classList.remove('el-button--primary');
} }
baseBtn&&(baseBtn.onclick = function(e){console.log(info) baseBtn && (baseBtn.onclick = function (e) {
if(info.eLocateType === 'bsLocation') return; console.log(info)
if (info.eLocateType === 'bsLocation') return;
info.eLocateType = 'bsLocation' info.eLocateType = 'bsLocation'
eLocation = info[info.eLocateType]; eLocation = info[info.eLocateType];
if(!eLocation.elng || !eLocation.elat) { if (!eLocation.elng || !eLocation.elat) {
Message({ Message({
type: 'info', type: 'info',
message: '暂无基站数据' message: '暂无基站数据'
...@@ -319,13 +334,14 @@ MapService.prototype = { ...@@ -319,13 +334,14 @@ MapService.prototype = {
infoDiv.querySelector('[data-time]').textContent = eLocation.dateTime; infoDiv.querySelector('[data-time]').textContent = eLocation.dateTime;
EventBus.$emit('uiMap.monitor.changeELocate', info) EventBus.$emit('uiMap.monitor.changeELocate', info)
EventBus.$emit('uiMap.monitor.drawDone'); EventBus.$emit('uiMap.monitor.drawDone');
self.setFitView()
}) })
gpsBtn&&(gpsBtn.onclick = function(e){ gpsBtn && (gpsBtn.onclick = function (e) {
if(info.eLocateType === 'gpsLocation') return; if (info.eLocateType === 'gpsLocation') return;
info.eLocateType = 'gpsLocation' info.eLocateType = 'gpsLocation'
eLocation = info[info.eLocateType]; eLocation = info[info.eLocateType];
if(!eLocation.elng || !eLocation.elat) { if (!eLocation.elng || !eLocation.elat) {
Message({ Message({
type: 'info', type: 'info',
message: '暂无GPS数据' message: '暂无GPS数据'
...@@ -339,22 +355,24 @@ MapService.prototype = { ...@@ -339,22 +355,24 @@ MapService.prototype = {
infoDiv.querySelector('[data-time]').textContent = eLocation.dateTime; infoDiv.querySelector('[data-time]').textContent = eLocation.dateTime;
EventBus.$emit('uiMap.monitor.changeELocate', info) EventBus.$emit('uiMap.monitor.changeELocate', info)
EventBus.$emit('uiMap.monitor.drawDone'); 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-transferAddress]').textContent = eLocation.transferAddress;
//infoDiv.querySelector('[data-time]').textContent = eLocation.time; //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>报警状态:' let _html = '<i class="icon icon-info_device_alarm"></i>报警状态:'
info.alarmTypeSet.forEach((alarmType)=>{ info.alarmTypeSet.forEach((alarmType) => {
if(alarmType === 1){ if (alarmType === 1) {
_html+=`<button type="button" class="el-button el-button--mini el-button--danger" data-alarmoff >断电</button>` _html += `<button type="button" class="el-button el-button--mini el-button--danger" data-alarmoff >断电</button>`
}else if(alarmType === 99){ } else if (alarmType === 99) {
_html+=`<button type="button" class="el-button el-button--mini el-button--danger" data-alarmlight >光感</button>` _html += `<button type="button" class="el-button el-button--mini el-button--danger" data-alarmlight >光感</button>`
} }
}); });
infoDiv.querySelector('[data-alarm]').innerHTML = _html; infoDiv.querySelector('[data-alarm]').innerHTML = _html;
...@@ -372,10 +390,52 @@ MapService.prototype = { ...@@ -372,10 +390,52 @@ MapService.prototype = {
} */ } */
infoDiv.querySelector('[data-alarm]').style.display = 'block'; infoDiv.querySelector('[data-alarm]').style.display = 'block';
}else{ } else {
infoDiv.querySelector('[data-alarm]').style.display = 'none'; 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}` const snSourceType = `${info.sn}:${info.isSource}`
/* EventBus.$on(`uiMap.monitor.changeStatus.${snSourceType}`, (status)=>{ /* EventBus.$on(`uiMap.monitor.changeStatus.${snSourceType}`, (status)=>{
if(status === 2){ if(status === 2){
...@@ -387,28 +447,28 @@ MapService.prototype = { ...@@ -387,28 +447,28 @@ MapService.prototype = {
return this.createInfoWindow(marker, map, infoDiv, isInfoOpen, isInfoAutoMove); return this.createInfoWindow(marker, map, infoDiv, isInfoOpen, isInfoAutoMove);
}, },
bindLocationInfoWindow(marker, map, info){ bindLocationInfoWindow(marker, map, info) {
var self = this; var self = this;
var infoDiv = document.createElement('div'); var infoDiv = document.createElement('div');
infoDiv.innerHTML = self.createLocationInfo(info); infoDiv.innerHTML = self.createLocationInfo(info);
return this.createInfoWindow(marker, map, infoDiv); return this.createInfoWindow(marker, map, infoDiv);
}, },
bindResidentInfoWindow(marker, map, info){ bindResidentInfoWindow(marker, map, info) {
var self = this; var self = this;
var infoDiv = document.createElement('div'); var infoDiv = document.createElement('div');
infoDiv.innerHTML = self.createResidentInfo(info); infoDiv.innerHTML = self.createResidentInfo(info);
return this.createInfoWindow(marker, map, infoDiv); return this.createInfoWindow(marker, map, infoDiv);
}, },
bindFenceInfoWindow(marker, map, info){ bindFenceInfoWindow(marker, map, info) {
var self = this; var self = this;
var infoDiv = document.createElement('div'); var infoDiv = document.createElement('div');
infoDiv.innerHTML = self.createFenceInfo(info); infoDiv.innerHTML = self.createFenceInfo(info);
var statusArr = ['行驶中', '静止', '离线', '在线']; var statusArr = ['行驶中', '静止', '离线', '在线'];
function fillGPS(){ function fillGPS() {
infoDiv.querySelector('[data-time]').textContent = info.timeGPS; infoDiv.querySelector('[data-time]').textContent = info.timeGPS;
infoDiv.querySelector('[data-transferAddress]').textContent = info.transferAddressGPS; infoDiv.querySelector('[data-transferAddress]').textContent = info.transferAddressGPS;
infoDiv.querySelector('[data-clipboard-text').setAttribute('data-clipboard-text', info.transferAddressGPS); infoDiv.querySelector('[data-clipboard-text').setAttribute('data-clipboard-text', info.transferAddressGPS);
...@@ -418,7 +478,7 @@ MapService.prototype = { ...@@ -418,7 +478,7 @@ MapService.prototype = {
marker.infoWindow && marker.infoWindow.open(map, marker.getPosition()); marker.infoWindow && marker.infoWindow.open(map, marker.getPosition());
} }
function fillBase(){ function fillBase() {
infoDiv.querySelector('[data-time]').textContent = info.timeBase; infoDiv.querySelector('[data-time]').textContent = info.timeBase;
infoDiv.querySelector('[data-transferAddress]').textContent = info.transferAddressBase; infoDiv.querySelector('[data-transferAddress]').textContent = info.transferAddressBase;
infoDiv.querySelector('[data-clipboard-text').setAttribute('data-clipboard-text', info.transferAddressBase); infoDiv.querySelector('[data-clipboard-text').setAttribute('data-clipboard-text', info.transferAddressBase);
...@@ -430,31 +490,31 @@ MapService.prototype = { ...@@ -430,31 +490,31 @@ MapService.prototype = {
infoDiv.querySelector('[data-status]').textContent = statusArr[info.status]; 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]').classList.remove('hide');
infoDiv.querySelector('[data-battery-percentage]').style.width = info.battery; infoDiv.querySelector('[data-battery-percentage]').style.width = info.battery;
infoDiv.querySelector('[data-battery-text]').textContent = info.battery; infoDiv.querySelector('[data-battery-text]').textContent = info.battery;
}else{ } else {
infoDiv.querySelector('[data-battery]').classList.add('hide'); infoDiv.querySelector('[data-battery]').classList.add('hide');
} }
infoDiv.querySelector('#locateTypeGps').onclick = function(e){ infoDiv.querySelector('#locateTypeGps').onclick = function (e) {
fillGPS() fillGPS()
} }
infoDiv.querySelector('#locateTypeBase').onclick = function(e){ infoDiv.querySelector('#locateTypeBase').onclick = function (e) {
fillBase() fillBase()
} }
fillGPS(); fillGPS();
return this.createInfoWindow(marker, map, infoDiv); return this.createInfoWindow(marker, map, infoDiv);
}, },
getLngLat: function(lng, lat){ getLngLat: function (lng, lat) {
return new AMap.LngLat(lng, lat); return new AMap.LngLat(lng, lat);
}, },
getGeocoder: function(){ getGeocoder: function () {
return new Promise((resolve)=>{ return new Promise((resolve) => {
AMap.service('AMap.Geocoder',function(){//回调函数 AMap.service('AMap.Geocoder', function () {//回调函数
var geocoder = new AMap.Geocoder({ var geocoder = new AMap.Geocoder({
batch: true batch: true
}); });
...@@ -462,23 +522,25 @@ MapService.prototype = { ...@@ -462,23 +522,25 @@ MapService.prototype = {
}); });
}) })
}, },
getAddress: function(geocoder, lnglatXY){ getAddress: function (geocoder, lnglatXY) {
geocoder.getAddress(lnglatXY, function(status, result) { geocoder.getAddress(lnglatXY, function (status, result) {
if (status === 'complete' && result.info === 'OK') { if (status === 'complete' && result.info === 'OK') {
//获得了有效的地址信息: //获得了有效的地址信息:
//即,result.regeocode.formattedAddress //即,result.regeocode.formattedAddress
}else{ } else {
//获取地址失败 //获取地址失败
} }
}); });
}, },
zoomIn: function(){ zoomIn: function () {
this.map.zoomIn(); this.map.zoomIn();
}, },
zoomOut: function(){ zoomOut: function () {
this.map.zoomOut(); 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>'; /*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){ if(info.time){
_html += '<p><span><i class="fa fa-clock-o"></i></span>'+ info.time +'</p>'; _html += '<p><span><i class="fa fa-clock-o"></i></span>'+ info.time +'</p>';
...@@ -486,27 +548,43 @@ MapService.prototype = { ...@@ -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-map-marker"></i></span>'+ info.transferAddress +'</p>';
_html += '<p><span><i class="fa fa-car"></i></span>'+ '驻留次数:' +(info.totalTimes?info.totalTimes:'1')+'</p>'; _html += '<p><span><i class="fa fa-car"></i></span>'+ '驻留次数:' +(info.totalTimes?info.totalTimes:'1')+'</p>';
return _html;*/ return _html;*/
let _this = this;
let queryCode = `sn=${info.sn}&name=${encodeURI(info.name)}&standno=${info.standNo}`; let queryCode = `sn=${info.sn}&name=${encodeURI(info.name)}&standno=${info.standNo}`;
var _html = `<h3 class="map-infowindow-title">${info.name}/${info.standNo}</h3>`; var _html = `<h3 class="map-infowindow-title">${info.name}/${info.standNo}</h3>`;
_html += `<div class="map-infowindow-ct">`; _html += `<div class="map-infowindow-ct map_info_window">`;
console.log(zhongliType); console.log(zhongliType);
if(zhongliType == 'yes'){ if (zhongliType == 'yes') {
_html += `<div>`; _html += `<div>`;
if(info.shopName){ if (info.shopName) {
_html += `<p><i class="icon icon-icon_store"></i> 店面名称: <span class="des">${info.shopName}</span></p>`; _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>`; _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>`; _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 += `<p style="margin-left:29px;"> 车牌号: <span class="des">${info.idnum}</span></p>`;
} }
_html += `</div>`; _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> <span class="battery" data-battery>
<i class="fill"><i class="fill-percentage" data-battery-percentage></i></i> <i class="fill"><i class="fill-percentage" data-battery-percentage></i></i>
<i class="icon icon-battery_enough"></i> <i class="icon icon-battery_enough"></i>
...@@ -514,7 +592,6 @@ MapService.prototype = { ...@@ -514,7 +592,6 @@ MapService.prototype = {
</span></p> </span></p>
<p><i class="icon icon-info_device_status"></i> 设备状态: <span class="des" data-status></span></p> <p><i class="icon icon-info_device_status"></i> 设备状态: <span class="des" data-status></span></p>
<p data-alarm> <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-alarmoff>断电</button>
<button type="button" class="el-button el-button--mini el-button--primary" data-alarmlight>光感</button> <button type="button" class="el-button el-button--mini el-button--primary" data-alarmlight>光感</button>
</p> </p>
...@@ -523,9 +600,9 @@ MapService.prototype = { ...@@ -523,9 +600,9 @@ MapService.prototype = {
<a class="copy-btn" data-clipboard-text=""><i class="icon icon-info_copy"></i></a> <a class="copy-btn" data-clipboard-text=""><i class="icon icon-info_copy"></i></a>
</p> </p>
<p><i class="icon icon-info_type"></i> 定位类型: <p><i class="icon icon-info_type"></i> 定位类型:
${info.wifiLocation? ${info.wifiLocation ?
(info.eLocateSingle? (info.eLocateSingle ?
(info.eLocateType==='gpsLocation'? (info.eLocateType === 'gpsLocation' ?
`<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 el-button--primary" data-gps>GPS</button>
<button type="button" class="el-button el-button--mini" data-wifi>wifi</button> <button type="button" class="el-button el-button--mini" data-wifi>wifi</button>
...@@ -534,16 +611,16 @@ MapService.prototype = { ...@@ -534,16 +611,16 @@ MapService.prototype = {
<button type="button" class="el-button el-button--mini el-button--primary" data-base>基站</button> <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> <button type="button" class="el-button el-button--mini" data-wifi>wifi</button>
</span>` </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 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-base>基站</button>
<button type="button" class="el-button el-button--mini" data-wifi>wifi</button> <button type="button" class="el-button el-button--mini" data-wifi>wifi</button>
</span>` </span>`
): ) :
info.eLocateSingle? info.eLocateSingle ?
(info.eLocateType==='gpsLocation'?`<button type="button" class="el-button el-button--mini el-button--primary" data-gps>GPS</button> `: (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>`): `<button type="button" class="el-button el-button--mini el-button--primary" data-base>基站</button>`) :
`<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 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-base>基站</button>
...@@ -551,10 +628,8 @@ MapService.prototype = { ...@@ -551,10 +628,8 @@ MapService.prototype = {
} }
</p> </p>
<p class="redirect-row"> <p class="redirect-row">
<a class="redirect-btn" onclick="window.open('#/monitor/historyLocation?${queryCode}')" style="display:none;">历史停留</a> <a class="redirect-btn" id="btn_replay" data-replay>轨迹回放</a>
<a class="redirect-btn" onclick="window.open('#/monitor/resident?${queryCode}')" style="display:none;">常驻地</a> <a class="redirect-btn" id="btn_fence" data-fence>电子围栏</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>
</p> </p>
</div>`; </div>`;
...@@ -619,7 +694,7 @@ MapService.prototype = { ...@@ -619,7 +694,7 @@ MapService.prototype = {
// </div>`; // </div>`;
return _html; return _html;
}, },
createFenceInfo(info){ createFenceInfo(info) {
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"> <div class="map-infowindow-ct">
<p><i class="icon icon-info_device"></i> 设备号:<span class="des"> ${info.sn} (${info.sourceString})</span> <p><i class="icon icon-info_device"></i> 设备号:<span class="des"> ${info.sn} (${info.sourceString})</span>
...@@ -641,7 +716,7 @@ MapService.prototype = { ...@@ -641,7 +716,7 @@ MapService.prototype = {
</p> </p>
</div>`; </div>`;
}, },
createLocationInfo(info){ createLocationInfo(info) {
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"> <div class="map-infowindow-ct">
<p><i class="icon icon-info_time"></i> 停留时间: <span class="des">${info.begintime}</span></p> <p><i class="icon icon-info_time"></i> 停留时间: <span class="des">${info.begintime}</span></p>
...@@ -651,7 +726,7 @@ MapService.prototype = { ...@@ -651,7 +726,7 @@ MapService.prototype = {
<p><i class="icon icon-info_stop"></i> 停留时长: <span class="des">${info.duration}</span></p> <p><i class="icon icon-info_stop"></i> 停留时长: <span class="des">${info.duration}</span></p>
</div>`; </div>`;
}, },
createResidentInfo(info){ createResidentInfo(info) {
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"> <div class="map-infowindow-ct">
<p><i class="icon icon-info_device"></i> 设备号: <span class="des">${info.sn}</span></p> <p><i class="icon icon-info_device"></i> 设备号: <span class="des">${info.sn}</span></p>
...@@ -663,13 +738,13 @@ MapService.prototype = { ...@@ -663,13 +738,13 @@ MapService.prototype = {
</div>`; </div>`;
}, },
clearMap: function(map){ clearMap: function (map) {
this.map.clearMap(); this.map.clearMap();
}, },
setFitView: function(map){ setFitView: function (map) {
this.map.setFitView(); this.map.setFitView();
}, },
bindClickEvent(){ bindClickEvent() {
}, },
...@@ -677,20 +752,20 @@ MapService.prototype = { ...@@ -677,20 +752,20 @@ MapService.prototype = {
createActiveInfo(info) { createActiveInfo(info) {
let msg = '报警' let msg = '报警'
// 激活 // 激活
if(info.type == 1){ if (info.type == 1) {
msg = '激活' msg = '激活'
} }
// 定位 // 定位
if(info.type == 2){ if (info.type == 2) {
msg = '定位' 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"> <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> <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> <p><i class="icon icon-info_location"></i> ${msg}地址: <span class="des" data-transferAddress>${info.address}</span></p>
</div>` </div>`
}, },
...@@ -702,7 +777,7 @@ MapService.prototype = { ...@@ -702,7 +777,7 @@ MapService.prototype = {
infoDiv.innerHTML = self.createActiveInfo(info) infoDiv.innerHTML = self.createActiveInfo(info)
// gps位置信息 // gps位置信息
function fillGPS(){ function fillGPS() {
infoDiv.querySelector('[data-time]').textContent = info.time; infoDiv.querySelector('[data-time]').textContent = info.time;
infoDiv.querySelector('[data-transferAddress]').textContent = info.address; infoDiv.querySelector('[data-transferAddress]').textContent = info.address;
infoDiv.querySelector('#locateTypeGps').classList.add('active'); infoDiv.querySelector('#locateTypeGps').classList.add('active');
...@@ -713,7 +788,7 @@ MapService.prototype = { ...@@ -713,7 +788,7 @@ MapService.prototype = {
} }
// 基站位置信息 // 基站位置信息
function fillBase(){ function fillBase() {
infoDiv.querySelector('[data-time]').textContent = info.bsTime; infoDiv.querySelector('[data-time]').textContent = info.bsTime;
infoDiv.querySelector('[data-transferAddress]').textContent = info.bsAddress; infoDiv.querySelector('[data-transferAddress]').textContent = info.bsAddress;
infoDiv.querySelector('#locateTypeGps').classList.remove('active'); infoDiv.querySelector('#locateTypeGps').classList.remove('active');
...@@ -723,18 +798,18 @@ MapService.prototype = { ...@@ -723,18 +798,18 @@ MapService.prototype = {
marker.infoWindow && marker.infoWindow.open(map, marker.getPosition()); marker.infoWindow && marker.infoWindow.open(map, marker.getPosition());
} }
infoDiv.querySelector('#locateTypeGps').onclick = function(e){ infoDiv.querySelector('#locateTypeGps').onclick = function (e) {
fillGPS() fillGPS()
} }
infoDiv.querySelector('#locateTypeBase').onclick = function(e){ infoDiv.querySelector('#locateTypeBase').onclick = function (e) {
fillBase() fillBase()
} }
if(info.lng){ if (info.lng) {
fillGPS() fillGPS()
} }
if(!info.lng && info.bsLng){ if (!info.lng && info.bsLng) {
fillBase() fillBase()
} }
...@@ -763,6 +838,14 @@ MapService.prototype = { ...@@ -763,6 +838,14 @@ MapService.prototype = {
} }
return infoWindow return infoWindow
}, },
// 页面跳转,打开新窗口
openPage(path) {
vue.prototype.$parentCommon.setBreadCrumbs(path);
window.open(path)
}
} }
const mapService = new MapService(); const mapService = new MapService();
......
...@@ -194,7 +194,7 @@ const monitor = { ...@@ -194,7 +194,7 @@ const monitor = {
}); });
//mapService.setFitView(MAP); mapService.setFitView(MAP);
this.allData = this.allData.concat(data); this.allData = this.allData.concat(data);
EventBus.$emit('uiMap.monitor.drawDone'); EventBus.$emit('uiMap.monitor.drawDone');
if(this.isCompare){ 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 = { ...@@ -84,6 +84,7 @@ const mutations = {
[types.vehicleGenerate](state, data) { [types.vehicleGenerate](state, data) {
state.vehicleGenerate = 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!