|
|
@@ -0,0 +1,383 @@
|
|
|
+<template>
|
|
|
+ <div class="conatiner">
|
|
|
+ <div class="leftSide">
|
|
|
+ <div class="title">作业项目</div>
|
|
|
+ <div v-for="(item,index) in items" :key="index" :class="checkItemIndex===index?'item active':'item'" @click="checkItem(item,index)">
|
|
|
+ <img :src="item.icon" alt="" class="icon">
|
|
|
+ <div class="name">{{ item.name }}</div>
|
|
|
+ </div>
|
|
|
+ </div>
|
|
|
+ <div class="map-warp">
|
|
|
+ <div id="vmap" />
|
|
|
+ </div>
|
|
|
+ <div class="rightSide">
|
|
|
+ <div v-if="type==1" class="remark">
|
|
|
+ <div class="title">使用说明</div>
|
|
|
+ <ul>
|
|
|
+ <li>1.点击作业项目下面的图标</li>
|
|
|
+ <li>2.点击地图绘制点</li>
|
|
|
+ <li>3.编辑信息保存点位</li>
|
|
|
+ </ul>
|
|
|
+ </div>
|
|
|
+ <div v-if="type==2" class="saveForm">
|
|
|
+ <div class="title">作业点基本信息</div>
|
|
|
+ <div class="item">
|
|
|
+ <div class="lable">作业项目:</div>
|
|
|
+ <div class="content">
|
|
|
+ <img class="icon" :src="saveForm.icon" alt="">
|
|
|
+ <span>{{ saveForm.name }}</span>
|
|
|
+ </div>
|
|
|
+ </div>
|
|
|
+ <div class="item">
|
|
|
+ <div class="lable">名称:</div>
|
|
|
+ <div class="content">
|
|
|
+ <span>{{ saveForm.name }}</span>
|
|
|
+ </div>
|
|
|
+ </div>
|
|
|
+ <div class="bt-wrap">
|
|
|
+ <div class="bt save" @click="save">保存</div>
|
|
|
+ <div class="bt margin" @click="cancel">撤销</div>
|
|
|
+ </div>
|
|
|
+ </div>
|
|
|
+ <div v-if="type==3" class="deleteForm">
|
|
|
+ <div class="title">作业点基本信息</div>
|
|
|
+ <div class="item">
|
|
|
+ <div class="lable">作业项:</div>
|
|
|
+ <div class="content">
|
|
|
+ <img class="icon" :src="deleteForm.icon" alt="">
|
|
|
+ <span>{{ deleteForm.name }}</span>
|
|
|
+ </div>
|
|
|
+ </div>
|
|
|
+ <div class="item">
|
|
|
+ <div class="lable">名称:</div>
|
|
|
+ <div class="content">
|
|
|
+ <span>{{ deleteForm.name }}</span>
|
|
|
+ </div>
|
|
|
+ </div>
|
|
|
+ <div class="bt-wrap">
|
|
|
+ <div class="bt">保存</div>
|
|
|
+ <div class="bt delete margin" @click="delMarker">删除</div>
|
|
|
+ </div>
|
|
|
+ </div>
|
|
|
+ </div>
|
|
|
+ </div>
|
|
|
+</template>
|
|
|
+<script>
|
|
|
+import * as L from 'leaflet'
|
|
|
+import '@geoman-io/leaflet-geoman-free'
|
|
|
+export default {
|
|
|
+ data() {
|
|
|
+ return {
|
|
|
+ checkItemIndex: -1,
|
|
|
+ type: 1,
|
|
|
+ items: [],
|
|
|
+ saveForm: {
|
|
|
+ icon: '',
|
|
|
+ name: ''
|
|
|
+ },
|
|
|
+ deleteForm: {
|
|
|
+ icon: '',
|
|
|
+ name: ''
|
|
|
+ },
|
|
|
+ map: undefined,
|
|
|
+ mapList: [],
|
|
|
+ mapId: undefined,
|
|
|
+ mapRasterLayer: require('./images/bg.png'),
|
|
|
+ layer: null,
|
|
|
+ state: 0
|
|
|
+ }
|
|
|
+ },
|
|
|
+ created() {
|
|
|
+ this.init()
|
|
|
+ },
|
|
|
+ methods: {
|
|
|
+
|
|
|
+ init() {
|
|
|
+ this.initProject()
|
|
|
+
|
|
|
+ this.$nextTick(() => {
|
|
|
+ this.initMap()
|
|
|
+ })
|
|
|
+ },
|
|
|
+ initProject() {
|
|
|
+ this.items = [
|
|
|
+ { icon: require('./images/layers/1.png'), name: '动火作业' },
|
|
|
+ { icon: require('./images/layers/2.png'), name: '有限空间作业' },
|
|
|
+ { icon: require('./images/layers/3.png'), name: '高处作业' },
|
|
|
+ { icon: require('./images/layers/4.png'), name: '起重作业' },
|
|
|
+ { icon: require('./images/layers/5.png'), name: '预热器清堵作业' },
|
|
|
+ { icon: require('./images/layers/6.png'), name: '篦冷机清大块作业' },
|
|
|
+ { icon: require('./images/layers/7.png'), name: '交叉作业' },
|
|
|
+ { icon: require('./images/layers/8.png'), name: '临时用电作业' },
|
|
|
+ { icon: require('./images/layers/9.png'), name: '动土作业' },
|
|
|
+ { icon: require('./images/layers/10.png'), name: '断路作业' },
|
|
|
+ { icon: require('./images/layers/11.png'), name: '防护设备拆除' },
|
|
|
+ { icon: require('./images/layers/12.png'), name: '高温及其他危险作业' },
|
|
|
+ { icon: require('./images/layers/13.png'), name: '盲板抽堵作业' }
|
|
|
+ ]
|
|
|
+ },
|
|
|
+ checkItem(item, index) {
|
|
|
+ if (this.state === 1) {
|
|
|
+ this.$message('请保存后再操作!')
|
|
|
+ return
|
|
|
+ }
|
|
|
+ this.checkItemIndex = index
|
|
|
+ this.type = 2
|
|
|
+ this.saveForm.icon = item.icon
|
|
|
+ this.saveForm.name = item.name
|
|
|
+ this.map.pm.enableDraw('Marker', { snappable: true })
|
|
|
+ this.state = 1
|
|
|
+ },
|
|
|
+ save() {
|
|
|
+ if (this.type === 3) {
|
|
|
+ // 删除表单里面的保存
|
|
|
+ this.type = 1
|
|
|
+ } else {
|
|
|
+ // 新增
|
|
|
+ console.log(this.layer)
|
|
|
+ this.type = 1
|
|
|
+ this.checkItemIndex = -1
|
|
|
+ this.state = 2
|
|
|
+ this.saveForm.icon = ''
|
|
|
+ this.saveForm.name = ''
|
|
|
+ }
|
|
|
+ },
|
|
|
+ cancel() {
|
|
|
+ this.type = 1
|
|
|
+ this.state = 2
|
|
|
+ this.checkItemIndex = -1
|
|
|
+ this.saveForm.icon = ''
|
|
|
+ this.saveForm.name = ''
|
|
|
+ if (this.map._layers[this.layer._leaflet_id]) {
|
|
|
+ this.map.removeLayer(this.map._layers[this.layer._leaflet_id])
|
|
|
+ }
|
|
|
+ },
|
|
|
+ delMarker() {
|
|
|
+ this.type = 1
|
|
|
+ this.state = 2
|
|
|
+ if (this.map._layers[this.markerId]) {
|
|
|
+ this.map.removeLayer(this.map._layers[this.markerId])
|
|
|
+ }
|
|
|
+ },
|
|
|
+ initMap() {
|
|
|
+ this.map = L.map('vmap', {
|
|
|
+ minZoom: 1,
|
|
|
+ maxZoom: 3,
|
|
|
+ center: [0, 0],
|
|
|
+ zoom: 1,
|
|
|
+ crs: L.CRS.Simple,
|
|
|
+ zoomControl: false
|
|
|
+ })
|
|
|
+ // L.control.zoom({
|
|
|
+ // position: 'bottomleft',
|
|
|
+ // zoomInTitle: '放大',
|
|
|
+ // zoomOutTitle: '缩小'
|
|
|
+ // }).addTo(this.map)
|
|
|
+ this.setRasterLayer()
|
|
|
+ this.mapListener()
|
|
|
+ },
|
|
|
+ setRasterLayer() {
|
|
|
+ var yx = L.latLng
|
|
|
+ var xy = function xy(x, y) {
|
|
|
+ if (L.Util.isArray(x)) {
|
|
|
+ return yx(x[1], x[0])
|
|
|
+ }
|
|
|
+ return yx(y, x)
|
|
|
+ }
|
|
|
+ var bounds = [xy(-200, -200), xy(200, 150)]
|
|
|
+ L.imageOverlay(this.mapRasterLayer, bounds).addTo(this.map)
|
|
|
+ this.map.fitBounds(bounds)
|
|
|
+ },
|
|
|
+ resetMapControl() {
|
|
|
+
|
|
|
+ },
|
|
|
+ mapListener() {
|
|
|
+ const self = this
|
|
|
+ this.map.on('pm:drawstart', (e) => { // 绘制开始时事件
|
|
|
+ if (e.shape === 'Marker') {
|
|
|
+ const iconUrl = this.saveForm.icon
|
|
|
+ const layer = e.workingLayer
|
|
|
+ var icon = L.icon({
|
|
|
+ iconUrl,
|
|
|
+ iconSize: [27, 33]
|
|
|
+ })
|
|
|
+ layer.setIcon(icon)
|
|
|
+ }
|
|
|
+ })
|
|
|
+ this.map.on('pm:create', (e) => {
|
|
|
+ if (e.shape === 'Marker') {
|
|
|
+ const iconUrl = this.saveForm.icon
|
|
|
+ const name = this.saveForm.name
|
|
|
+ const layer = e.layer
|
|
|
+ var icon = L.icon({
|
|
|
+ iconUrl,
|
|
|
+ name,
|
|
|
+ iconSize: [27, 33]
|
|
|
+ })
|
|
|
+ layer.setIcon(icon)
|
|
|
+ layer.on('click', function(ev) {
|
|
|
+ self.type = 3
|
|
|
+ self.markerId = ev.target._leaflet_id
|
|
|
+ self.deleteForm.name = ev.target.options.icon.options.name
|
|
|
+ self.deleteForm.icon = ev.target.options.icon.options.iconUrl
|
|
|
+ })
|
|
|
+ self.layer = layer
|
|
|
+ }
|
|
|
+ this.map.pm.disableDraw(e.shape)
|
|
|
+ })
|
|
|
+ this.map.on('pm:cut', () => {
|
|
|
+ this.$message.success('裁剪完毕!')
|
|
|
+ })
|
|
|
+ this.map.on('pm:remove', (e) => {
|
|
|
+ console.log(e, '移除')
|
|
|
+ })
|
|
|
+ this.map.on('pm:globaldragmodetoggled', e => {
|
|
|
+ console.log(e, '拖拽结束')
|
|
|
+ })
|
|
|
+ this.map.on('pm:rotateend', (e) => {
|
|
|
+ console.log(e, 'rotateend')
|
|
|
+ this.handleType = undefined
|
|
|
+ })
|
|
|
+ this.map.on('contextmenu', () => {
|
|
|
+ // 取消所有状态
|
|
|
+ this.resetMapControl()
|
|
|
+ })
|
|
|
+ }
|
|
|
+ }
|
|
|
+}
|
|
|
+</script>
|
|
|
+<style lang="scss" scoped>
|
|
|
+.conatiner{
|
|
|
+ height: calc(100vh - 74px);
|
|
|
+ min-width: 1000px;
|
|
|
+ margin: 0 auto;
|
|
|
+ padding: 0 16px;
|
|
|
+ box-sizing: border-box;
|
|
|
+ background-color: #071C2B;
|
|
|
+ color: #fff;
|
|
|
+ display: flex;
|
|
|
+ justify-content: space-between;
|
|
|
+ align-items: center;
|
|
|
+ overflow-x: auto;
|
|
|
+ .leftSide{
|
|
|
+ min-width: 266px;
|
|
|
+ height: 100%;
|
|
|
+ overflow-y: auto;
|
|
|
+ background-color: #193142;
|
|
|
+ box-sizing: border-box;
|
|
|
+ .title{
|
|
|
+ height: 42px;
|
|
|
+ line-height: 42px;
|
|
|
+ background-color: #36556b;
|
|
|
+ font-size: 16px;
|
|
|
+ color: #666;
|
|
|
+ text-indent: 10px;
|
|
|
+ color: #fff;
|
|
|
+ }
|
|
|
+ .item{
|
|
|
+ display: flex;
|
|
|
+ align-items: center;
|
|
|
+ height: 48px;
|
|
|
+ padding-left: 10px;
|
|
|
+ cursor: default;
|
|
|
+ &.active{
|
|
|
+ background-color: rgba(45, 140, 240, 0.16);
|
|
|
+ }
|
|
|
+ .icon{
|
|
|
+ width: 17.5px;
|
|
|
+ display: block;
|
|
|
+ }
|
|
|
+ .name{
|
|
|
+ font-size: 14px;
|
|
|
+ padding-left: 12px;
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+ .map-warp{
|
|
|
+ flex: 1;
|
|
|
+ height: 100%;
|
|
|
+ background-color: #071c2b;
|
|
|
+ #vmap{
|
|
|
+ background-color: inherit;
|
|
|
+ width: 100%;
|
|
|
+ height: 100%;
|
|
|
+ }
|
|
|
+ }
|
|
|
+ .rightSide{
|
|
|
+ width: 269px;
|
|
|
+ height: 100%;
|
|
|
+ overflow-y: auto;
|
|
|
+ background-color: #193142;
|
|
|
+ box-sizing: border-box;
|
|
|
+ padding: 17px 16px;
|
|
|
+ .title{
|
|
|
+ color: #fff;
|
|
|
+ font-size: 16px;
|
|
|
+ margin-bottom: 16px;
|
|
|
+ }
|
|
|
+ .remark{
|
|
|
+ ul,li{
|
|
|
+ list-style: none;
|
|
|
+ margin: 0;
|
|
|
+ padding: 0;
|
|
|
+ }
|
|
|
+ li{
|
|
|
+ color: rgba(255, 255, 255, 0.7);
|
|
|
+ line-height: 28px;
|
|
|
+ font-size: 14px;
|
|
|
+ margin-bottom: 8px;
|
|
|
+ }
|
|
|
+ }
|
|
|
+ .saveForm,.deleteForm{
|
|
|
+ .item{
|
|
|
+ height: 48px;
|
|
|
+ display: flex;
|
|
|
+ justify-content: flex-start;
|
|
|
+ align-items: center;
|
|
|
+ font-size: 14px;
|
|
|
+ border-bottom:2px solid rgba(45, 140, 240, 0.16);
|
|
|
+ .lable{
|
|
|
+ width: 80px;
|
|
|
+ font-size: 14px;
|
|
|
+ }
|
|
|
+ .content{
|
|
|
+ display: flex;
|
|
|
+ justify-content: flex-start;
|
|
|
+ align-items: center;
|
|
|
+ overflow: hidden;
|
|
|
+ text-overflow: ellipsis;
|
|
|
+ .icon{
|
|
|
+ width: 17.5px;
|
|
|
+ display: block;
|
|
|
+ margin-right:8px;
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ }
|
|
|
+ .bt-wrap{
|
|
|
+ margin-top: 65px;
|
|
|
+ .bt{
|
|
|
+ width: 100px;
|
|
|
+ height: 36px;
|
|
|
+ color: #fff;
|
|
|
+ font-size: 14px;
|
|
|
+ line-height: 36px;
|
|
|
+ text-align: center;
|
|
|
+ background-color: rgba(24, 144, 255, 0.3);
|
|
|
+ display: inline-block;
|
|
|
+ cursor: pointer;
|
|
|
+ &.save{
|
|
|
+ background-color: #1890ff;
|
|
|
+ }
|
|
|
+ &.delete{
|
|
|
+ background-color: #f97647;
|
|
|
+ }
|
|
|
+ &.margin{
|
|
|
+ margin-left: 12px;
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+}
|
|
|
+</style>
|