|
@@ -0,0 +1,162 @@
|
|
|
|
+<template>
|
|
|
|
+ <div class="chart-map">
|
|
|
|
+ <div class="chart-map-input">
|
|
|
|
+ <a-auto-complete
|
|
|
|
+ :dropdown-match-select-width="252"
|
|
|
|
+ style="width: 300px"
|
|
|
|
+ :options="options"
|
|
|
|
+ @search="onSearch"
|
|
|
|
+ @select="onSelect"
|
|
|
|
+ >
|
|
|
|
+ <template #option="item">
|
|
|
|
+ <div class="chart-map-item">
|
|
|
|
+ <div class="chart-map-item-icon">
|
|
|
|
+ <img src="~@/assets/icons/postion.png">
|
|
|
|
+ </div>
|
|
|
|
+ <div class="chart-map-item-text">
|
|
|
|
+ <div class="chart-map-item-wellname">井名:{{ item.well_common_name }}</div>
|
|
|
|
+ <div>地址:{{ item.geo_description }}</div>
|
|
|
|
+ </div>
|
|
|
|
+ </div>
|
|
|
|
+ </template>
|
|
|
|
+ <a-input-search size="large" placeholder="..." enter-button></a-input-search>
|
|
|
|
+ </a-auto-complete>
|
|
|
|
+ </div>
|
|
|
|
+ <iframe width="100%" height="100%" tyle="border: 0"
|
|
|
|
+ :src="iframeSrc" ref="iframeRef" id="iframeMap"
|
|
|
|
+ class="chart-map-iframe"></iframe>
|
|
|
|
+ </div>
|
|
|
|
+</template>
|
|
|
|
+
|
|
|
|
+<script lang="ts">
|
|
|
|
+ import {defineComponent, computed, ref} from 'vue';
|
|
|
|
+ import {get} from '@/api/common';
|
|
|
|
+
|
|
|
|
+ export default defineComponent ({
|
|
|
|
+ props:{
|
|
|
|
+ wellId: null as any
|
|
|
|
+ },
|
|
|
|
+ name : 'ChartMap',
|
|
|
|
+ data() {
|
|
|
|
+ return{
|
|
|
|
+ loading : false,
|
|
|
|
+ datas:null as any,
|
|
|
|
+ options:[] as any,
|
|
|
|
+ iframeWindow : null,
|
|
|
|
+ value : null
|
|
|
|
+ }
|
|
|
|
+ },
|
|
|
|
+ setup(props, context){
|
|
|
|
+ console.log("ChartMap setup" , props, context);
|
|
|
|
+ let iframeSrc = ref<string>("http://127.0.0.1:1936/a4gis/index.html");
|
|
|
|
+ let iframeRef = ref<any>(); // 和iframe标签的ref绑定
|
|
|
|
+
|
|
|
|
+ const wellId = computed(() => {
|
|
|
|
+ return props.wellId ? props.wellId : null
|
|
|
|
+ });
|
|
|
|
+ return{
|
|
|
|
+ wellId,
|
|
|
|
+ iframeSrc,
|
|
|
|
+ iframeRef
|
|
|
|
+ }
|
|
|
|
+ },
|
|
|
|
+ mounted(){
|
|
|
|
+ console.log("mounted chart-map" , this.wellId);
|
|
|
|
+ // 父项目绑定一个message事件给iframe handleMessage
|
|
|
|
+ window.addEventListener("message", this.handleMessage, false);
|
|
|
|
+ this.iframeWindow = this.iframeRef.contentWindow;
|
|
|
|
+ //加载数据
|
|
|
|
+ this.options = this.getDatas();
|
|
|
|
+ console.log("mounted options", this.options);
|
|
|
|
+ },
|
|
|
|
+ methods:{
|
|
|
|
+ getDatas:async function(){
|
|
|
|
+ //数据查询逻辑,如果不查询,改此方法返回数据即可
|
|
|
|
+ if(this.datas==null){
|
|
|
|
+ this.datas = [];
|
|
|
|
+ const result = await get('/wellInfo/getMapList',{ page: 1, rows:1000 });
|
|
|
|
+ this.datas = result.list.map((item, index) => {
|
|
|
|
+ item.value = item.well_id;
|
|
|
|
+ item.index = index;
|
|
|
|
+ return item;
|
|
|
|
+ });
|
|
|
|
+ }
|
|
|
|
+ console.log("getDatas", this.datas);
|
|
|
|
+ return this.datas;
|
|
|
|
+ },
|
|
|
|
+ onSearch:async function (searchText){
|
|
|
|
+ let datas = await this.getDatas();
|
|
|
|
+ if(searchText!=null && searchText!=undefined && searchText.length>0){
|
|
|
|
+ this.options = datas.filter((item) => {
|
|
|
|
+ return (item.well_common_name && item.well_common_name.indexOf(searchText) >=0)
|
|
|
|
+ || (item.geo_description && item.geo_description.indexOf(searchText)>=0);
|
|
|
|
+ });
|
|
|
|
+ }
|
|
|
|
+ else this.options = datas;
|
|
|
|
+ },
|
|
|
|
+ onSelect:function (value, item){
|
|
|
|
+ console.log("onSelect", value, item);
|
|
|
|
+ (document.getElementById('iframeMap') as any).contentWindow.postMessage({
|
|
|
|
+ action:'setCenter',
|
|
|
|
+ item : JSON.stringify(item)
|
|
|
|
+ },'*');
|
|
|
|
+ },
|
|
|
|
+ handleMessage:async function (event){
|
|
|
|
+ console.log("parent handle Message", event.data);
|
|
|
|
+ //(document.getElementById('iframeMap') as any).contentWindow.postMessage({message:'父页面传过来的数据'},'*');
|
|
|
|
+ //显示坐标点
|
|
|
|
+ let datas = await this.getDatas();
|
|
|
|
+ (document.getElementById('iframeMap') as any).contentWindow.postMessage({
|
|
|
|
+ action:'setSymbols',
|
|
|
|
+ datas : JSON.stringify(datas)
|
|
|
|
+ },'*');
|
|
|
|
+ this.options = datas;
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+ })
|
|
|
|
+</script>
|
|
|
|
+
|
|
|
|
+<style lang="less" scoped>
|
|
|
|
+ .chart-map{
|
|
|
|
+ width: 100%;
|
|
|
|
+ height: 100%;
|
|
|
|
+ }
|
|
|
|
+ .chart-map-iframe{
|
|
|
|
+ position: relative;
|
|
|
|
+ top:-50px;
|
|
|
|
+ z-index: 10;
|
|
|
|
+ }
|
|
|
|
+ .chart-map-input{
|
|
|
|
+ background-color: white;
|
|
|
|
+ position: relative;
|
|
|
|
+ width: 300px;
|
|
|
|
+ height: 50px;
|
|
|
|
+ left: 30px;
|
|
|
|
+ top: 30px;
|
|
|
|
+ z-index: 100;
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ .chart-map-item{
|
|
|
|
+ display: flex;
|
|
|
|
+ flex-direction: row;
|
|
|
|
+ }
|
|
|
|
+ .chart-map-item-icon{
|
|
|
|
+ width: 30px;
|
|
|
|
+ min-width: 30px;
|
|
|
|
+ min-height: 30px;
|
|
|
|
+ text-align: center;
|
|
|
|
+ }
|
|
|
|
+ .chart-map-item-icon img{
|
|
|
|
+ width: 20px;
|
|
|
|
+ height: 20px;
|
|
|
|
+ }
|
|
|
|
+ .chart-map-item-text{
|
|
|
|
+ flex-grow: 1;
|
|
|
|
+ font-size: 12px;
|
|
|
|
+ line-height: 20px;
|
|
|
|
+ }
|
|
|
|
+ .chart-map-item-wellname{
|
|
|
|
+ color: #1890ff;
|
|
|
|
+ font-size: 14px;
|
|
|
|
+ }
|
|
|
|
+</style>
|