diff --git a/src/views/mkmj/area/components/editGate.vue b/src/views/mkmj/area/components/editGate.vue index c1ebfa6..188b7ea 100644 --- a/src/views/mkmj/area/components/editGate.vue +++ b/src/views/mkmj/area/components/editGate.vue @@ -19,6 +19,15 @@ + + + + + + + + + @@ -87,6 +96,7 @@ export default { GATE_NAME: '', GATE_NUMBER: '', GATE_TYPE: '', + GATE_CATEGORY: '', GATE_MODEL: '', GATE_POSITION: '', IS_ADJACENT: '', @@ -99,6 +109,7 @@ export default { rules: { GATE_NAME: [{ required: true, message: '闸机名称不为空', trigger: 'blur' }], GATE_TYPE: [{ required: true, message: '闸机类型不为空', trigger: 'blur' }], + GATE_CATEGORY: [{ required: true, message: '闸机类别不为空', trigger: 'blur' }], IS_ADJACENT: [{ required: true, message: '是否相邻区域不为空', trigger: 'blur' }], ADJACENT_AREA_ID: [{ required: true, message: '相邻区域不为空', trigger: 'blur' }] }, @@ -111,6 +122,10 @@ export default { }, multipleSelection: [], accidentList: [], + categoryList: [ + { ID: '1', NAME: '人员' }, + { ID: '2', NAME: '车辆' } + ], leaveList: [ { ID: '1', NAME: '入' }, { ID: '2', NAME: '出' } diff --git a/src/views/mkmj/area/components/listGate.vue b/src/views/mkmj/area/components/listGate.vue index 7b7974a..6d0e5d3 100644 --- a/src/views/mkmj/area/components/listGate.vue +++ b/src/views/mkmj/area/components/listGate.vue @@ -34,15 +34,28 @@ + + + + + + + @@ -85,14 +113,23 @@ import { requestFN } from '@/utils/request' import waves from '@/directive/waves' // waves directive import SelectTree from '@/components/SelectTree' +import TiandiMap from '../../../../components/TianMap/TiandiMap' export default { - components: { Pagination, SelectTree }, + components: { Pagination, SelectTree, TiandiMap }, directives: { waves }, data() { return { + map: null, + marker: null, + BMap: '', + clientHeight: 500, + inputLocation: '', + msg: 'add', + config: config, + dialogFormMap: false, AREA_ID: '', AREA_LEAVE: '', addBtnType: true, @@ -104,6 +141,11 @@ export default { page: 1, limit: 20 }, + form: { + AREA_GATE_ID: '', + LATITUDE: '', + LONGITUDE: '' + }, ls: [], dates: [], total: 0, @@ -131,6 +173,67 @@ export default { this.hasButton() }, methods: { + /** + * 初始化天地图对象 + */ + initTDT() { + return new Promise((resolve, reject) => { + if (window.T) { + console.log('天地图初始化成功...') + resolve(window.T) + reject('error') + } + }).then(T => { + window.T = T + }) + }, + /** + * 初始化地图 + * @param {*} lng 经度 + * @param {*} lat 纬度 + * @param {*} zoom 缩放比例(1~18) + */ + initMap(lng, lat, zoom) { + this.initTDT().then((T) => { + const imageURL = 'http://t0.tianditu.gov.cn/img_w/wmts?' + 'SERVICE=WMTS&REQUEST=GetTile&VERSION=1.0.0&LAYER=img&STYLE=default&TILEMATRIXSET=w&FORMAT=tiles' + '&TILEMATRIX={z}&TILEROW={y}&TILECOL={x}&tk=e8a16137fd226a62a23cc7ba5c9c78ce' + // 创建自定义图层对象 + this.lay = new window.T.TileLayer(imageURL, { minZoom: 1, maxZoom: 18 }) + // 初始化地图对象 + this.map = new window.T.Map('map') + this.initCenter(lng, lat, zoom) + }) + }, + initCenter(lng, lat, zoom) { + // 设置显示地图的中心点和级别 + if (!this.form.LONGITUDE && !this.form.LATITUDE) { + this.map.centerAndZoom(new window.T.LngLat(119.58, 39.94), zoom) + this.marker && this.map.removeOverLay(this.marker) + } else { + this.map.centerAndZoom(new window.T.LngLat(lng, lat), zoom) + this.marker && this.map.removeOverLay(this.marker) + this.form.LONGITUDE = lng + this.form.LATITUDE = lat + this.marker = new window.T.Marker(new window.T.LngLat(lng, lat)) + // 向地图上添加标注 + this.map.addOverLay(this.marker) + } + // 创建卫星和路网的混合视图 + this.map.setMapType(window.TMAP_HYBRID_MAP) + // 允许鼠标滚轮缩放地图 + this.map.enableScrollWheelZoom() + // 允许鼠标移动地图 + this.map.enableInertia() + // 向地图上添加标注 + this.map.addEventListener('click', this.MapClick) + }, + MapClick(event) { + this.marker && this.map.removeOverLay(this.marker) + this.form.LONGITUDE = event.lnglat.getLng() + this.form.LATITUDE = event.lnglat.getLat() + this.marker = new window.T.Marker(new window.T.LngLat(event.lnglat.getLng(), event.lnglat.getLat())) + // 向地图上添加标注 + this.map.addOverLay(this.marker) + }, filterNode(value, data) { if (!value) return true return data.name.indexOf(value) !== -1 @@ -145,7 +248,12 @@ export default { handleAdd() { this.$parent.activeName = 'EditGate' this.$parent.AREA_ID = this.AREA_ID - this.$parent.AREA_GATE_ID == '' + this.$parent.AREA_GATE_ID = '' + }, + handleVideo(row) { + this.$parent.activeName = 'VideoList' + this.$parent.AREA_GATE_ID = row.AREA_GATE_ID + console.log(this.$parent.AREA_GATE_ID) }, // 搜索 getQuery() { @@ -179,6 +287,18 @@ export default { this.$parent.AREA_GATE_ID = AREA_GATE_ID this.$parent.activeName = 'EditGate' }, + handleMap(row) { + this.dialogFormMap = true + this.form = { + AREA_GATE_ID: row.AREA_GATE_ID, + LATITUDE: row.LATITUDE, + LONGITUDE: row.LONGITUDE + } + this.$nextTick(() => { + if (!this.map) this.initMap(this.form.LONGITUDE, this.form.LATITUDE, 16) + else this.initCenter(this.form.LONGITUDE, this.form.LATITUDE, 16) + }) + }, handleDelete(row) { this.$confirm('确定要删除[' + row.GATE_NAME + ']吗?', { confirmButtonText: '确定', @@ -206,7 +326,24 @@ export default { }).catch(() => { }) }, - + setPosition() { + this.dialogFormMap = false + this.listLoading = true + requestFN( + '/mkmjAreaGate/savePosition', + { + LATITUDE: this.form.LATITUDE, + LONGITUDE: this.form.LONGITUDE, + AREA_GATE_ID: this.form.AREA_GATE_ID + } + ).then((data) => { + this.listLoading = false + this.dialogForm = false + this.getList() + }).catch((e) => { + this.listLoading = false + }) + }, hasButton: function() { var keys = 'mkmjArea:add,mkmjArea:del,mkmjArea:edit,toExcel' requestFN( @@ -238,6 +375,10 @@ export default { diff --git a/src/views/mkmj/area/index.vue b/src/views/mkmj/area/index.vue index 4f16102..b5472f0 100644 --- a/src/views/mkmj/area/index.vue +++ b/src/views/mkmj/area/index.vue @@ -8,6 +8,7 @@ + @@ -19,9 +20,11 @@ import ListGate from './components/listGate' import Edit from './components/edit' import EditGate from './components/editGate' import ListLog from './components/listLog' +import VideoList from './components/videoList' export default { components: { + VideoList: VideoList, List: List, Edit: Edit, ListTwo: ListTwo,