index - 副本.html 19.5 KB
<!DOCTYPE html>
<html>
	<head>
		<meta charset="utf-8">
		<title></title>

		<script src="/assets/js/vue/vue.min.js"></script>

		<link rel="stylesheet" href="/assets/js/vue/elementui.css">
		<!-- 引入组件库 -->
		<script src="/assets/js/vue/elementui.js"></script>

		<script src="/assets/js/vue/axios.js"></script>
		<script charset="utf-8" src="https://map.qq.com/api/gljs?v=1.exp&key=OB4BZ-D4W3U-B7VVO-4PJWW-6TKDJ-WPB77">
		</script>


		<style>
			#mapContainer {
				width: 1000px;
				height: 1000px;
				background-color: red;
			}
		</style>

		<!-- <script src="https://unpkg.com/axios/dist/axios.min.js"></script> -->
	</head>
	<body>
		<!-- 创建一个根元素 -->
		<div class="home" id="home">

			<div id="mapContainer"></div>

		</div>
		<script>
			// 将vue挂载到id为home的根元素上
			var vm = new Vue({
				el: "#home",
				data: {
					'msg': 'aa',
					map: null,
					polylineLayer: null,
				},
				created() {


					/* 	axios.post('http://localhost:9211/base/sw_pipe_web/statistics', {
							startYear: '2023-09-12',
							endYear: 0,
							approval: 1,
							getWell: 1,
							lineDiameter: '0-50,50-100,100-200,200-400,400-0',
							endDate: '2023-09-12'
						}).then(res=>{
							console.log('---res',res)
						}) */

					setTimeout(() => {

					}, 1000)

				},
				mounted() {
					setTimeout(() => {
						this.initMap()
					}, 1000)

				},
				methods: {




					initMap() {
						let that = this;

						//初始化地图
						this.map = new TMap.Map('mapContainer', {
							center: new TMap.LatLng(40.040452, 116.273486), //地图显示中心点
							zoom: 16 //缩放级别
						});



						//创建 MultiPolyline
						this.polylineLayer = new TMap.MultiPolyline({
							id: 'polyline-layer', //图层唯一标识
							map: that.map, //设置折线图层显示到哪个地图实例中
							//折线样式定义
							styles: {
								'style_blue': new TMap.PolylineStyle({
									'color': '#3777FF', //线填充色
									'width': 6, //折线宽度
									'borderWidth': 5, //边线宽度
									'borderColor': '#FFF', //边线颜色
									'lineCap': 'butt' //线端头方式
								}),
								'style_red': new TMap.PolylineStyle({
									'color': '#CC0000', //线填充色
									'width': 6, //折线宽度
									'borderWidth': 5, //边线宽度
									'borderColor': '#CCC', //边线颜色
									'lineCap': 'round' //线端头方式
								})
							},
							//折线数据定义
							geometries: [{ //第1条线
									'id': 'pl_1', //折线唯一标识,删除时使用
									'styleId': 'style_blue', //绑定样式名
									'paths': [new TMap.LatLng(40.038540, 116.272389), new TMap.LatLng(
										40.038844, 116.275210), new TMap.LatLng(40.041407,
										116.274738)]
								},
								{ //第2条线
									'id': 'pl_2',
									'styleId': 'style_red',
									'paths': [new TMap.LatLng(40.039492, 116.271893), new TMap.LatLng(
										40.041562, 116.271421), new TMap.LatLng(40.041957,
										116.274211)]
								}
							]
						});




						this.polylineLayer.on('click', (e) => {
							 that.mapClick(e)
						})




					},



					mapClick(e) {
						console.log('--------e',e)
						mapItemEmt = e.target
						return false
						let data = e.target.getExtData()
						mapItemData = data
						//构建信息窗体中显示的内容
						var info
						if (data.lng) {
							info = ` <div style="background: #fff; width: 350px;padding: 20px;border-radius: 10px;position: relative">
					                <div style='display: flex;justify-content: space-between;align-items: center'>
					                    <div style="color: #17213c;font-size: 16px; font-style: normal;font-weight: 500;">放水口-${data.code}</div>
					                    <div id='closeMapOpen'>
					                        <img style='width: 20px;height: 20px' src='/src/assets/return.png' alt=''>
					                    </div>
					                </div>
					                <div style='margin-top: 14px'>
					                    <div style="display: flex;justify-content: space-between;align-items: center;">
					                        <div style='display: flex;align-items: center;'>
					                            <div style="color: #192c4e;font-size: 12px;">机构编号:</div>
					                            <div style="margin-left: 8px;color: #748094;font-size: 12px;">${data.oid}</div>
					                        </div>
					                        <div style='display: flex;align-items: center;'>
					                            <div style="color: #192c4e;font-size: 12px;">放水口编号:</div>
					                            <div style="margin-left: 8px;color: #748094;font-size: 12px;">${data.code}</div>
					                        </div>
					                    </div>
					
					                    <div style="display: flex;justify-content: space-between;align-items: center;">
					                        <div style='display: flex;align-items: center;'>
					                            <div style="color: #192c4e;font-size: 12px;">放水口名称:</div>
					                            <div style="margin-left: 8px;color: #748094;font-size: 12px;">${data.name}</div>
					                        </div>
					                        <div style='display: flex;align-items: center;'>
					                            <div style="color: #192c4e;font-size: 12px;">放水口附属物:</div>
					                            <div style="margin-left: 8px;color: #748094;font-size: 12px;">${data.attach}</div>
					                        </div>
					                    </div>
					
					                    <div style="display: flex;justify-content: space-between;align-items: center;">
					                        <div style='display: flex;align-items: center;'>
					                            <div style="color: #192c4e;font-size: 12px;">放水口底标高:</div>
					                            <div style="margin-left: 8px;color: #748094;font-size: 12px;">${data.wblElevation}</div>
					                        </div>
					                        <div style='display: flex;align-items: center;'>
					                            <div style="color: #192c4e;font-size: 12px;">所在位置:</div>
					                            <div style="margin-left: 8px;color: #748094;font-size: 12px;">${data.addr}</div>
					                        </div>
					                    </div>
					
					                    <div style="display: flex;justify-content: space-between;align-items: center;">
					                        <div style='display: flex;align-items: center;'>
					                            <div style="color: #192c4e;font-size: 12px;">放水口埋深:</div>
					                            <div style="margin-left: 8px;color: #748094;font-size: 12px;">${data.depth}</div>
					                        </div>
					                        <div style='display: flex;align-items: center;'>
					                            <div style="color: #192c4e;font-size: 12px;">材质:</div>
					                            <div style="margin-left: 8px;color: #748094;font-size: 12px;">${data.material}</div>
					                        </div>
					                    </div>
					                    <div style="display: flex;justify-content: space-between;align-items: center;">
					                        <div style='display: flex;align-items: center;'>
					                            <div style="color: #192c4e;font-size: 12px;">所属区域:</div>
					                            <div style="margin-left: 8px;color: #748094;font-size: 12px;">${data.area}</div>
					                        </div>
					                        <div style='display: flex;align-items: center;'>
					                            <div style="color: #192c4e;font-size: 12px;">建设日期:</div>
					                            <div style="margin-left: 8px;color: #748094;font-size: 12px;">${data.buildTime}</div>
					                        </div>
					                    </div>
					                    <div style="display: flex;justify-content: space-between;align-items: center;">
					
					                        <div style='display: flex;align-items: center;'>
					                            <div style="color: #192c4e;font-size: 12px;">所属点位:</div>
					                            <div style="margin-left: 8px;color: #748094;font-size: 12px;">${data.point}</div>
					                        </div>
					                         <div style='display: flex;align-items: center;'>
					                            <div style="color: #192c4e;font-size: 12px;">所属官网编号:</div>
					                            <div style="margin-left: 8px;color: #748094;font-size: 12px;">${data.pipeCode}</div>
					                        </div>
					                    </div>
					                    <div style="display: flex;justify-content: space-between;align-items: center;">
					                        <div style='display: flex;align-items: center;'>
					                            <div style="color: #192c4e;font-size: 12px;">经度:</div>
					                            <div style="margin-left: 8px;color: #748094;font-size: 12px;">${data.lng}</div>
					                        </div>
					                        <div style='display: flex;align-items: center;'>
					                            <div style="color: #192c4e;font-size: 12px;">纬度:</div>
					                            <div style="margin-left: 8px;color: #748094;font-size: 12px;">${data.lat}</div>
					                        </div>
					                    </div>
					                </div>
					                <div style='width: 100%; display: flex;justify-content: flex-end;align-items: center;margin-top: 20px'>
					                    <div id='marckEdit' style='padding: 5px;background: #EABA60;color: #fff;margin-right: 20px;border-radius: 5px;cursor: pointer'>编辑</div>
					                    <div id='marckDelete' style='padding: 5px;background: #FEE4DF;color: #D74025;border-radius: 5px;cursor: pointer'>删除</div>
					                </div>
					                <div style='width: 0;height: 0;
					                    position: absolute;
					                    left: 50%;
					                    bottom: -30px;
					                    transform: translate(-50%,0);
					                    border-top: 15px solid #fff;
					                    border-right: 15px solid transparent;
					                    border-left: 15px solid transparent;border-bottom: 15px solid transparent;'></div>
					            </div>`
						} else {
							info = ` <div style="background: #fff; width: 350px;padding: 20px;border-radius: 10px;position: relative">
					                <div style='display: flex;justify-content: space-between;align-items: center'>
					                    <div style="color: #17213c;font-size: 16px; font-style: normal;font-weight: 500;">管线-${data.code}</div>
					                    <div id='closeMapOpen'>
					                        <img style='width: 20px;height: 20px' src='/src/assets/return.png' alt=''>
					                    </div>
					                </div>
					                <div style='margin-top: 14px'>
					                    <div style="display: flex;justify-content: space-between;align-items: center;">
					                        <div style='display: flex;align-items: center;'>
					                            <div style="color: #192c4e;font-size: 12px;">机构编号:</div>
					                            <div style="margin-left: 8px;color: #748094;font-size: 12px;">${data.oid}</div>
					                        </div>
					                        <div style='display: flex;align-items: center;'>
					                            <div style="color: #192c4e;font-size: 12px;">管线编号:</div>
					                            <div style="margin-left: 8px;color: #748094;font-size: 12px;">${data.code}</div>
					                        </div>
					                    </div>
					
					                    <div style="display: flex;justify-content: space-between;align-items: center;">
					                        <div style='display: flex;align-items: center;'>
					                            <div style="color: #192c4e;font-size: 12px;">管直径:</div>
					                            <div style="margin-left: 8px;color: #748094;font-size: 12px;">${data.diameter}</div>
					                        </div>
					                        <div style='display: flex;align-items: center;'>
					                            <div style="color: #192c4e;font-size: 12px;">起点名称:</div>
					                            <div style="margin-left: 8px;color: #748094;font-size: 12px;">${data.bName}</div>
					                        </div>
					                    </div>
					                    <div style="display: flex;justify-content: space-between;align-items: center;">
					                        <div style='display: flex;align-items: center;'>
					                            <div style="color: #192c4e;font-size: 12px;">终点名称:</div>
					                            <div style="margin-left: 8px;color: #748094;font-size: 12px;">${data.eName}</div>
					                        </div>
					                        <div style='display: flex;align-items: center;'>
					                            <div style="color: #192c4e;font-size: 12px;">起点埋深:</div>
					                            <div style="margin-left: 8px;color: #748094;font-size: 12px;">${data.bDepth}</div>
					                        </div>
					                    </div>
					
					                    <div style="display: flex;justify-content: space-between;align-items: center;">
					                        <div style='display: flex;align-items: center;'>
					                            <div style="color: #192c4e;font-size: 12px;">终点埋深:</div>
					                            <div style="margin-left: 8px;color: #748094;font-size: 12px;">${data.eDepth}</div>
					                        </div>
					                        <div style='display: flex;align-items: center;'>
					                            <div style="color: #192c4e;font-size: 12px;">起点高程:</div>
					                            <div style="margin-left: 8px;color: #748094;font-size: 12px;">${data.bElevation}</div>
					                        </div>
					                    </div>
					                    <div style="display: flex;justify-content: space-between;align-items: center;">
					                        <div style='display: flex;align-items: center;'>
					                            <div style="color: #192c4e;font-size: 12px;">终点高程:</div>
					                            <div style="margin-left: 8px;color: #748094;font-size: 12px;">${data.eElevation}</div>
					                        </div>
					                        <div style='display: flex;align-items: center;'>
					                            <div style="color: #192c4e;font-size: 12px;">建设日期:</div>
					                            <div style="margin-left: 8px;color: #748094;font-size: 12px;">${data.buildTime}</div>
					                        </div>
					                    </div>
					
					                    <div style="display: flex;justify-content: space-between;align-items: center;">
					                        <div style='display: flex;align-items: center;'>
					                            <div style="color: #192c4e;font-size: 12px;">材质:</div>
					                            <div style="margin-left: 8px;color: #748094;font-size: 12px;">${data.material}</div>
					                        </div>
					                        <div style='display: flex;align-items: center;'>
					                            <div style="color: #192c4e;font-size: 12px;">所属区域:</div>
					                            <div style="margin-left: 8px;color: #748094;font-size: 12px;">${data.areaCode}</div>
					                        </div>
					                    </div>
					                    <div style="display: flex;justify-content: space-between;align-items: center;">
					                        <div style='display: flex;align-items: center;'>
					                            <div style="color: #192c4e;font-size: 12px;">所属路线:</div>
					                            <div style="margin-left: 8px;color: #748094;font-size: 12px;">${data.lineCode}</div>
					                        </div>
					                        <div style='display: flex;align-items: center;'>
					                            <div style="color: #192c4e;font-size: 12px;">所属官网编号:</div>
					                            <div style="margin-left: 8px;color: #748094;font-size: 12px;">${data.pipeCode}</div>
					                        </div>
					                    </div>
					                    <div style="display: flex;justify-content: space-between;align-items: center;">
					                        <div style='display: flex;align-items: center;'>
					                            <div style="color: #192c4e;font-size: 12px;">起点经度:</div>
					                            <div style="margin-left: 8px;color: #748094;font-size: 12px;">${data.bLng}</div>
					                        </div>
					                        <div style='display: flex;align-items: center;'>
					                            <div style="color: #192c4e;font-size: 12px;">起点纬度:</div>
					                            <div style="margin-left: 8px;color: #748094;font-size: 12px;">${data.bLat}</div>
					                        </div>
					                    </div>
					                    <div style="display: flex;justify-content: space-between;align-items: center;">
					                        <div style='display: flex;align-items: center;'>
					                            <div style="color: #192c4e;font-size: 12px;">终点经度:</div>
					                            <div style="margin-left: 8px;color: #748094;font-size: 12px;">${data.eLng}</div>
					                        </div>
					                        <div style='display: flex;align-items: center;'>
					                            <div style="color: #192c4e;font-size: 12px;">终点纬度:</div>
					                            <div style="margin-left: 8px;color: #748094;font-size: 12px;">${data.eLat}</div>
					                        </div>
					                    </div>
					                </div>
					                <div style='width: 100%; display: flex;justify-content: flex-end;align-items: center;margin-top: 20px'>
					                    <div id='plinEdit' style='padding: 5px;background: #EABA60;color: #fff;margin-right: 20px;border-radius: 5px;cursor: pointer'>编辑</div>
					                    <div id='plinDelete' style='padding: 5px;background: #FEE4DF;color: #D74025;border-radius: 5px;cursor: pointer'>删除</div>
					                </div>
					                <div style='width: 0;height: 0;
					                    position: absolute;
					                    left: 50%;
					                    bottom: -30px;
					                    transform: translate(-50%,0);
					                    border-top: 15px solid #fff;
					                    border-right: 15px solid transparent;
					                    border-left: 15px solid transparent;border-bottom: 15px solid transparent;'></div>
					            </div>`
						}
						infoWindow = new TMap.InfoWindow({
							isCustom: true,
							content: info, //使用默认信息窗体框样式,显示信息内容
						})
						infoWindow.open(map, [e.lnglat.getLng(), e.lnglat.getLat()])

						document.getElementById('closeMapOpen').onclick = closeInfo

						if (data.lng) {
							document.getElementById('marckEdit').onclick = marckEditFun
							document.getElementById('marckDelete').onclick = plinDeleteFun
						} else {
							document.getElementById('plinEdit').onclick = plinEditFun
							document.getElementById('plinDelete').onclick = plinDeleteFun
						}
					}





				},


			});
		</script>
	</body>

</html>