From f6ca44fd34e71b9d5ae9a52ac6b7781a13b8ed7b Mon Sep 17 00:00:00 2001
From: guoshilong <123456>
Date: Tue, 14 Feb 2023 11:00:57 +0800
Subject: [PATCH] 安保管理地图选点
---
src/views/security/security.vue | 882 ++++++++++++++++++++++++++++++----------------------------
1 files changed, 461 insertions(+), 421 deletions(-)
diff --git a/src/views/security/security.vue b/src/views/security/security.vue
index 8950505..839d6a8 100644
--- a/src/views/security/security.vue
+++ b/src/views/security/security.vue
@@ -1,440 +1,480 @@
<template>
- <basic-container>
- <avue-crud :option="option" :table-loading="loading" :data="data" :page.sync="page" :permission="permissionList"
- :before-open="beforeOpen" v-model="form" ref="crud" @row-update="rowUpdate" @row-save="rowSave"
- @row-del="rowDel" @search-change="searchChange" @search-reset="searchReset"
- @selection-change="selectionChange" @current-change="currentChange" @size-change="sizeChange"
- @refresh-change="refreshChange" @on-load="onLoad">
- <template slot="menuLeft">
- <el-button size="small" icon="el-icon-delete" plain v-if="permission.security_delete"
- @click="handleDelete">删 除
- </el-button>
- </template>
- <template slot-scope="{type,size,row,index}" slot="menu">
- <el-button icon="el-icon-coordinate" :size="size" :type="type"
- @click="handlePersonList(row)">活动人员</el-button>
- <el-button icon="el-icon-data-line" :size="size" :type="type"
- @click="handleCarList(row)">活动车辆</el-button>
- </template>
- <template slot="activityAreaForm">
- <map-box ref="OpenLayersMap" @toData="toData" :routeRange="form.activityArea"></map-box>
- </template>
+ <basic-container>
+ <avue-crud :option="option" :table-loading="loading" :data="data" :page.sync="page" :permission="permissionList"
+ :before-open="beforeOpen" v-model="form" ref="crud" @row-update="rowUpdate" @row-save="rowSave"
+ @row-del="rowDel" @search-change="searchChange" @search-reset="searchReset"
+ @selection-change="selectionChange" @current-change="currentChange" @size-change="sizeChange"
+ @refresh-change="refreshChange" @on-load="onLoad">
+ <template slot="menuLeft">
+ <el-button size="small" icon="el-icon-delete" plain v-if="permission.security_delete"
+ @click="handleDelete">删 除
+ </el-button>
+ </template>
+ <template slot-scope="{type,size,row,index}" slot="menu">
+ <el-button icon="el-icon-coordinate" :size="size" :type="type"
+ @click="handlePersonList(row)">活动人员
+ </el-button>
+ <el-button icon="el-icon-data-line" :size="size" :type="type"
+ @click="handleCarList(row)">活动车辆
+ </el-button>
+ </template>
+ <template slot="activityAreaForm">
+ <map-box ref="OpenLayersMap" @toData="toData" :routeRange="form.activityArea"></map-box>
+ </template>
- </avue-crud>
+ </avue-crud>
- <el-drawer title="活动人员区域" :visible.sync="personBox" :append-to-body="true" size="50%" :destroy-on-close="true">
- <securityManage ref="securityManage" :securityId="securityId" />
- </el-drawer>
+ <el-drawer title="活动人员区域" :visible.sync="personBox" :append-to-body="true" size="50%" :destroy-on-close="true">
+ <securityManage ref="securityManage" :securityId="securityId"/>
+ </el-drawer>
- <el-drawer title="活动车辆区域" :visible.sync="carBox" :append-to-body="true" size="50%" :destroy-on-close="true">
- <securityManageCar ref="car" :securityId="securityId" />
- </el-drawer>
- </basic-container>
+ <el-drawer title="活动车辆区域" :visible.sync="carBox" :append-to-body="true" size="50%" :destroy-on-close="true">
+ <securityManageCar ref="car" :securityId="securityId"/>
+ </el-drawer>
+
+ <el-dialog
+ title="提示"
+ :visible.sync="placeBox"
+ append-to-body
+ destroy-on-close
+ width="70%">
+ <search-map @getLonLat="getLonLat" :point-lon-lat="point"></search-map>
+ <span slot="footer" class="dialog-footer">
+ <el-button type="primary" @click="confirmLonLat">确 定</el-button>
+ </span>
+ </el-dialog>
+ </basic-container>
</template>
<script>
-import { getPage, getDetail, add, update, remove } from "@/api/security/security"
-import { getUserInfos } from "@/api/system/user"
+import {getPage, getDetail, add, update, remove} from "@/api/security/security"
+import {getUserInfos} from "@/api/system/user"
// import AvueMap from 'avue-plugin-map';
-import { mapGetters } from "vuex"
+import {mapGetters} from "vuex"
import securityManage from "@/views/securityManage/securityManage"
import securityManageCar from "@/views/securityManageCar/securityManageCar"
import MapBox from "@/components/map/mapBox";
+import SearchMap from "@/components/map/searchMap";
export default {
- components: {
- MapBox,
- securityManage,
- securityManageCar
- },
- data () {
- return {
- securityId: "",
- carBox: false,
- personBox: false,
- form: {},
- query: {},
- loading: true,
- page: {
- pageSize: 10,
- currentPage: 1,
- total: 0
+ components: {
+ SearchMap,
+ MapBox,
+ securityManage,
+ securityManageCar
+ },
+ data() {
+ return {
+ securityId: "",
+ carBox: false,
+ personBox: false,
+ placeBox: false,
+ point:"",
+ chosePoint:{},
+ form: {},
+ query: {},
+ loading: true,
+ page: {
+ pageSize: 10,
+ currentPage: 1,
+ total: 0
+ },
+ selectionList: [],
+ option: {
+ height: 'auto',
+ calcHeight: 30,
+ labelWidth: "100",
+ dialogWidth: 950,
+ tip: false,
+ searchShow: true,
+ searchMenuSpan: 6,
+ border: true,
+ index: true,
+ viewBtn: true,
+ selection: true,
+ excelBtn: true,
+ dialogClickModal: false,
+ menuWidth: 370,
+ column: [
+ {
+ label: "活动名称",
+ prop: "name",
+ search: true,
+ searchSpan: 4,
+ rules: [{
+ required: true,
+ message: "请输入活动名称",
+ trigger: "blur"
+ }],
+ },
+ {
+ label: "负责单位",
+ prop: "company",
+ },
+ {
+ label: "负责人",
+ prop: "person",
+ width: 80,
+ rules: [{
+ required: true,
+ message: "请输入负责人",
+ trigger: "blur"
+ }],
+ },
+ {
+ label: "联系方式",
+ prop: "contact",
+ width: 100,
+ rules: [{
+ required: true,
+ message: "请输入联系方式",
+ trigger: "blur"
+ }],
+ },
+ {
+ label: "活动地点",
+ prop: "place",
+ span: 24,
+ click: () => {
+ this.placeBox = !this.placeBox
},
- selectionList: [],
- option: {
- height: 'auto',
- calcHeight: 30,
- labelWidth: "100",
- dialogWidth: 950,
- tip: false,
- searchShow: true,
- searchMenuSpan: 6,
- border: true,
- index: true,
- viewBtn: true,
- selection: true,
- excelBtn: true,
- dialogClickModal: false,
- menuWidth: 370,
- column: [
- {
- label: "活动名称",
- prop: "name",
- search: true,
- searchSpan: 4,
- rules: [{
- required: true,
- message: "请输入活动名称",
- trigger: "blur"
- }],
- },
- {
- label: "负责单位",
- prop: "company",
- },
- {
- label: "负责人",
- prop: "person",
- width: 80,
- rules: [{
- required: true,
- message: "请输入负责人",
- trigger: "blur"
- }],
- },
- {
- label: "联系方式",
- prop: "contact",
- width: 100,
- rules: [{
- required: true,
- message: "请输入联系方式",
- trigger: "blur"
- }],
- },
- {
- label: "活动地点",
- prop: "place",
- span: 24
- // addDisplay: false,
- // editDisplay: false,
- // viewDisplay: false,
- },
- {
- label: "经度",
- prop: "longitude",
- span: 12,
- hide: true,
- rules: [{
- required: true,
- message: "请输入纬度",
- trigger: "blur"
- }],
- },
- {
- label: "纬度",
- prop: "latitude",
- span: 12,
- hide: true,
- rules: [{
- required: true,
- message: "请输入纬度",
- trigger: "blur"
- }],
- },
- {
- label: "活动区域",
- prop: "activityArea",
- type: "input",
- hide: true,
- span: 24,
- display: true,
- addDisplay: true
- },
- {
- label: "所属辖区",
- prop: "deptId",
- type: "tree",
- dicUrl: "api/blade-system/dept/lazy-list",
- props: {
- label: 'deptName',
- value: 'id',
- children: 'children'
- },
- search: true,
- searchSpan: 4,
- span: 24,
- width: 110,
- rules: [{
- required: true,
- message: "请选择所属辖区",
- trigger: "blur"
- }]
- },
- // {
- // label: "地址",
- // prop: "avueMap",
- // type: "map",
- // },
- {
- label: "开始时间",
- prop: "startTime",
- type: "datetime",
- defaultTime: '00:00:00',
- format: "yyyy-MM-dd HH:mm",
- valueFormat: "yyyy-MM-dd HH:mm:ss",
- rules: [{
- required: true,
- message: "请输入开始时间",
- trigger: "blur"
- }],
- width: 120,
- },
- {
- label: "结束时间",
- prop: "endTime",
- type: "datetime",
- defaultTime: '23:59:59',
- format: "yyyy-MM-dd HH:mm",
- valueFormat: "yyyy-MM-dd HH:mm",
- rules: [{
- required: true,
- message: "请输入结束时间",
- trigger: "blur"
- }],
- width: 120,
- },
- // {
- // label: "",
- // prop: "map",
- // labelWidth: 10,
- // searchSpan: 0,
- // // maxlength: 5,
- // hide: true,
- // span: 3,
- // // display:false,
- // component: "AvueMap",
- // },
- {
- label: "活动类型",
- prop: "type",
- type: "select",
- dicUrl: "/api/blade-system/dict-biz/dictionary?code=securityType",
- props: {
- label: "dictValue",
- value: "dictKey"
- },
- rules: [{
- required: true,
- message: "请选择活动类型",
- trigger: "blur"
- }],
- width: 90,
- },
- {
- label: "人数",
- prop: "number",
- width: 60,
- },
- {
- label: "活动内容",
- prop: "content",
- type: "textarea",
- span: 24
- },
- ]
+ // addDisplay: false,
+ // editDisplay: false,
+ // viewDisplay: false,
+ },
+ {
+ label: "经度",
+ prop: "longitude",
+ span: 12,
+ hide: true,
+ disabled:true,
+ rules: [{
+ required: true,
+ message: "请输入纬度",
+ trigger: "blur"
+ }],
+ },
+ {
+ label: "纬度",
+ prop: "latitude",
+ span: 12,
+ hide: true,
+ disabled: true,
+ rules: [{
+ required: true,
+ message: "请输入纬度",
+ trigger: "blur"
+ }],
+ },
+ {
+ label: "活动区域",
+ prop: "activityArea",
+ type: "input",
+ hide: true,
+ span: 24,
+ display: true,
+ addDisplay: true
+ },
+ {
+ label: "所属辖区",
+ prop: "deptId",
+ type: "tree",
+ dicUrl: "api/blade-system/dept/lazy-list",
+ props: {
+ label: 'deptName',
+ value: 'id',
+ children: 'children'
},
- data: []
- }
- },
- // watch: {
- // //latitude longitude formattedAddress
- // "form.avueMap":{
- // handler (newObj) {
- // if (newObj.length>0) {
- // this.form.place = newObj[2]
- // this.form.position = newObj[0]+","+newObj[1]
- // }
- // }
- // }
- // },
- computed: {
- ...mapGetters(["userInfo", "permission"]),
- permissionList () {
- return {
- addBtn: this.vaildData(this.permission.security_add, false),
- viewBtn: this.vaildData(this.permission.security_view, false),
- delBtn: this.vaildData(this.permission.security_delete, false),
- editBtn: this.vaildData(this.permission.security_edit, false)
- }
- },
- ids () {
- let ids = []
- this.selectionList.forEach(ele => {
- ids.push(ele.id)
- })
- return ids.join(",")
- }
- },
- created () {
- const tokenLength = window.location.href.indexOf('=')
- if (tokenLength > 0) {
- //取“=”之后的token
- this.getUserInfo()
- }
- },
- methods: {
- getUserInfo () {
- getUserInfos().then(res => {
- const data = res.data
- this.$store.commit('SET_TOKEN', data.access_token)
- this.$store.commit('SET_REFRESH_TOKEN', data.refresh_token)
- this.$store.commit('SET_TENANT_ID', data.tenant_id)
- this.$store.commit('SET_USER_INFO', data)
- this.$store.commit('DEL_ALL_TAG')
- this.$store.commit('CLEAR_LOCK')
- })
- },
- rowSave (row, done, loading) {
- row.position = row.longitude + " " + row.latitude
- add(row).then(() => {
- this.onLoad(this.page)
- this.$message({
- type: "success",
- message: "操作成功!"
- })
- done()
- }, error => {
- loading()
- window.console.log(error)
- })
- },
- rowUpdate (row, index, done, loading) {
- if (!row.activityArea){
- this.$message.warning("请绘制活动区域")
- loading()
- return
- }
-
- row.position = row.longitude + " " + row.latitude
- update(row).then(() => {
- this.onLoad(this.page)
- this.$message({
- type: "success",
- message: "操作成功!"
- })
- done()
- }, error => {
- loading()
- console.log(error)
- })
- },
- rowDel (row) {
- this.$confirm("确定将选择数据删除?", {
- confirmButtonText: "确定",
- cancelButtonText: "取消",
- type: "warning"
- })
- .then(() => {
- return remove(row.id)
- })
- .then(() => {
- this.onLoad(this.page)
- this.$message({
- type: "success",
- message: "操作成功!"
- })
- })
- },
- handleDelete () {
- if (this.selectionList.length === 0) {
- this.$message.warning("请选择至少一条数据")
- return
- }
- this.$confirm("确定将选择数据删除?", {
- confirmButtonText: "确定",
- cancelButtonText: "取消",
- type: "warning"
- })
- .then(() => {
- return remove(this.ids)
- })
- .then(() => {
- this.onLoad(this.page)
- this.$message({
- type: "success",
- message: "操作成功!"
- })
- this.$refs.crud.toggleSelection()
- })
- },
- beforeOpen (done, type) {
- if (["edit", "view"].includes(type)) {
- getDetail(this.form.id).then(res => {
- var data = res.data.data
- this.form = data
- this.form['longitude'] = data.position.split(" ")[0]
- this.form['latitude'] = data.position.split(" ")[1]
- })
- }
- done()
- },
- searchReset () {
- this.query = {}
- this.onLoad(this.page)
- },
- searchChange (params, done) {
- this.query = params
- this.page.currentPage = 1
- this.onLoad(this.page, params)
- done()
- },
- selectionChange (list) {
- this.selectionList = list
- },
- selectionClear () {
- this.selectionList = []
- this.$refs.crud.toggleSelection()
- },
- currentChange (currentPage) {
- this.page.currentPage = currentPage
- },
- sizeChange (pageSize) {
- this.page.pageSize = pageSize
- },
- refreshChange () {
- this.onLoad(this.page, this.query)
- },
- onLoad (page, params = {}) {
- this.loading = true
-
- if (this.userInfo.role_name != "admin" && this.userInfo.role_name != "administrator") {
- params["jurisdiction"] = this.userInfo.dept_id
- }
-
- getPage(page.currentPage, page.pageSize, Object.assign(params, this.query)).then(res => {
- const data = res.data.data
- this.page.total = data.total
- this.data = data.records
- this.loading = false
- this.selectionClear()
- })
- },
- //活动人员区域点击按钮事件
- handlePersonList (row) {
- this.personBox = true
- this.securityId = row.id
- },
- //活动车辆区域点击按钮事件
- handleCarList (row) {
- this.carBox = true
- this.securityId = row.id
- },
- //地图传回的polygon坐标
- toData(data){
- this.form.activityArea = data
- }
+ search: true,
+ searchSpan: 4,
+ span: 24,
+ width: 110,
+ rules: [{
+ required: true,
+ message: "请选择所属辖区",
+ trigger: "blur"
+ }]
+ },
+ // {
+ // label: "地址",
+ // prop: "avueMap",
+ // type: "map",
+ // },
+ {
+ label: "开始时间",
+ prop: "startTime",
+ type: "datetime",
+ defaultTime: '00:00:00',
+ format: "yyyy-MM-dd HH:mm",
+ valueFormat: "yyyy-MM-dd HH:mm:ss",
+ rules: [{
+ required: true,
+ message: "请输入开始时间",
+ trigger: "blur"
+ }],
+ width: 120,
+ },
+ {
+ label: "结束时间",
+ prop: "endTime",
+ type: "datetime",
+ defaultTime: '23:59:59',
+ format: "yyyy-MM-dd HH:mm",
+ valueFormat: "yyyy-MM-dd HH:mm",
+ rules: [{
+ required: true,
+ message: "请输入结束时间",
+ trigger: "blur"
+ }],
+ width: 120,
+ },
+ // {
+ // label: "",
+ // prop: "map",
+ // labelWidth: 10,
+ // searchSpan: 0,
+ // // maxlength: 5,
+ // hide: true,
+ // span: 3,
+ // // display:false,
+ // component: "AvueMap",
+ // },
+ {
+ label: "活动类型",
+ prop: "type",
+ type: "select",
+ dicUrl: "/api/blade-system/dict-biz/dictionary?code=securityType",
+ props: {
+ label: "dictValue",
+ value: "dictKey"
+ },
+ rules: [{
+ required: true,
+ message: "请选择活动类型",
+ trigger: "blur"
+ }],
+ width: 90,
+ },
+ {
+ label: "人数",
+ prop: "number",
+ width: 60,
+ },
+ {
+ label: "活动内容",
+ prop: "content",
+ type: "textarea",
+ span: 24
+ },
+ ]
+ },
+ data: []
}
+ },
+ // watch: {
+ // //latitude longitude formattedAddress
+ // "form.avueMap":{
+ // handler (newObj) {
+ // if (newObj.length>0) {
+ // this.form.place = newObj[2]
+ // this.form.position = newObj[0]+","+newObj[1]
+ // }
+ // }
+ // }
+ // },
+ computed: {
+ ...mapGetters(["userInfo", "permission"]),
+ permissionList() {
+ return {
+ addBtn: this.vaildData(this.permission.security_add, false),
+ viewBtn: this.vaildData(this.permission.security_view, false),
+ delBtn: this.vaildData(this.permission.security_delete, false),
+ editBtn: this.vaildData(this.permission.security_edit, false)
+ }
+ },
+ ids() {
+ let ids = []
+ this.selectionList.forEach(ele => {
+ ids.push(ele.id)
+ })
+ return ids.join(",")
+ }
+ },
+ created() {
+ const tokenLength = window.location.href.indexOf('=')
+ if (tokenLength > 0) {
+ //取“=”之后的token
+ this.getUserInfo()
+ }
+ },
+ methods: {
+ getUserInfo() {
+ getUserInfos().then(res => {
+ const data = res.data
+ this.$store.commit('SET_TOKEN', data.access_token)
+ this.$store.commit('SET_REFRESH_TOKEN', data.refresh_token)
+ this.$store.commit('SET_TENANT_ID', data.tenant_id)
+ this.$store.commit('SET_USER_INFO', data)
+ this.$store.commit('DEL_ALL_TAG')
+ this.$store.commit('CLEAR_LOCK')
+ })
+ },
+ rowSave(row, done, loading) {
+ row.position = row.longitude + " " + row.latitude
+ add(row).then(() => {
+ this.onLoad(this.page)
+ this.$message({
+ type: "success",
+ message: "操作成功!"
+ })
+ done()
+ }, error => {
+ loading()
+ window.console.log(error)
+ })
+ },
+ rowUpdate(row, index, done, loading) {
+ if (!row.activityArea) {
+ this.$message.warning("请绘制活动区域")
+ loading()
+ return
+ }
+
+ if (row.activityArea.startsWith("LINESTRING")){
+
+ }else {
+ row.activityArea = "'LINESTRING("+row.activityArea+")'"
+ }
+ row.position = row.longitude + " " + row.latitude
+ update(row).then(() => {
+ this.onLoad(this.page)
+ this.$message({
+ type: "success",
+ message: "操作成功!"
+ })
+ done()
+ }, error => {
+ loading()
+ console.log(error)
+ })
+ },
+ rowDel(row) {
+ this.$confirm("确定将选择数据删除?", {
+ confirmButtonText: "确定",
+ cancelButtonText: "取消",
+ type: "warning"
+ })
+ .then(() => {
+ return remove(row.id)
+ })
+ .then(() => {
+ this.onLoad(this.page)
+ this.$message({
+ type: "success",
+ message: "操作成功!"
+ })
+ })
+ },
+ handleDelete() {
+ if (this.selectionList.length === 0) {
+ this.$message.warning("请选择至少一条数据")
+ return
+ }
+ this.$confirm("确定将选择数据删除?", {
+ confirmButtonText: "确定",
+ cancelButtonText: "取消",
+ type: "warning"
+ })
+ .then(() => {
+ return remove(this.ids)
+ })
+ .then(() => {
+ this.onLoad(this.page)
+ this.$message({
+ type: "success",
+ message: "操作成功!"
+ })
+ this.$refs.crud.toggleSelection()
+ })
+ },
+ beforeOpen(done, type) {
+ if (["edit", "view"].includes(type)) {
+ getDetail(this.form.id).then(res => {
+ var data = res.data.data
+ this.form = data
+ this.form['longitude'] = data.position.split(" ")[0]
+ this.form['latitude'] = data.position.split(" ")[1]
+ this.point = "POINT("+this.form.longitude +" "+this.form.latitude+")"
+ })
+ }
+ done()
+ },
+ searchReset() {
+ this.query = {}
+ this.onLoad(this.page)
+ },
+ searchChange(params, done) {
+ this.query = params
+ this.page.currentPage = 1
+ this.onLoad(this.page, params)
+ done()
+ },
+ selectionChange(list) {
+ this.selectionList = list
+ },
+ selectionClear() {
+ this.selectionList = []
+ this.$refs.crud.toggleSelection()
+ },
+ currentChange(currentPage) {
+ this.page.currentPage = currentPage
+ },
+ sizeChange(pageSize) {
+ this.page.pageSize = pageSize
+ },
+ refreshChange() {
+ this.onLoad(this.page, this.query)
+ },
+ onLoad(page, params = {}) {
+ this.loading = true
+
+ if (this.userInfo.role_name != "admin" && this.userInfo.role_name != "administrator") {
+ params["jurisdiction"] = this.userInfo.dept_id
+ }
+
+ getPage(page.currentPage, page.pageSize, Object.assign(params, this.query)).then(res => {
+ const data = res.data.data
+ this.page.total = data.total
+ this.data = data.records
+ this.loading = false
+ this.selectionClear()
+ })
+ },
+ //活动人员区域点击按钮事件
+ handlePersonList(row) {
+ this.personBox = true
+ this.securityId = row.id
+ },
+ //活动车辆区域点击按钮事件
+ handleCarList(row) {
+ this.carBox = true
+ this.securityId = row.id
+ },
+ //地图传回的polygon坐标
+ toData(data) {
+ this.form.activityArea = data
+ },
+ getLonLat(data){
+ this.chosePoint.longitude = data[0]
+ this.chosePoint.latitude = data[1]
+ },
+ confirmLonLat(){
+ this.form.longitude = this.chosePoint.longitude
+ this.form.latitude = this.chosePoint.latitude
+ this.point = "POINT("+this.form.longitude +" "+this.form.latitude+")"
+ this.placeBox = false
+ }
+ }
}
</script>
--
Gitblit v1.9.3