派生自 wuyushui/SewerAndRainNetwork

chenyabin
2021-04-14 faadb3a39e89b2cb7a00e81e3778f480f1f09998
src/components/panel/topicSearch/SolidWasteSearch.vue
@@ -1,140 +1,202 @@
<template>
  <div class="sewers-search" v-if="judgeVisible">
    <div class="search-title">
      <span>固废</span>
    </div>
    <div class="panel-title">{{ title }}</div>
    <div class="search-panel ">
      <el-form ref="form" :model="form" label-width="90px" class="search-form">
        <el-form-item label="设施类型:" size="mini" class="search-panel-item">
        <el-form-item v-for="(item,index) in solidWasteTypeOptions" :key="index" :label="item.label+':'" size="mini"
                      class="search-panel-item">
          <el-select style="width: 100%" v-model="form.pipelineType" @change="handlePipelineType"
                     :popper-class="'select-down'">
            <el-option
                v-for="item in SolidWasteTypeOptions"
                v-for="item in solidWasteTypeOptions"
                :key="item.value"
                :label="item.label"
                :value="item.value">
            </el-option>
          </el-select>
        </el-form-item>
        <el-form-item :label="form.pipelineType+':'" size="mini">
          <el-select style="width: 100%" v-model="form.dataType" @change="handleDataType" :popper-class="'select-down'">
            <el-option
                v-for="item in dataTypeOptions"
                :key="item.value"
                :label="item.label"
                :value="item.value">
            </el-option>
          </el-select>
        </el-form-item>
        <el-input v-model="form.keyword" size="mini"
                  placeholder="在此输入关键字搜索">
          <i slot="suffix" class="search-btn el-input__icon el-icon-search" @click="handleSearch"></i>
        </el-input>
        <el-radio-group v-model="form.transferData" class="levelOfRisk">
          <el-radio v-for="(item,index) in levelOfRisk" :label="item.value" :key="index">
            <span class="levelOfRisk-type">{{ item.name }}</span>
          </el-radio>
        </el-radio-group>
        <div class="rightButtonSearch">
          <el-input v-model="form.keyword" size="mini" placeholder="在此输入关键字搜索"></el-input>
          <el-button class="el-icon-search" @click="handleSearch"></el-button>
        </div>
      </el-form>
    </div>
    <el-scrollbar style="height:100%">
      <div class="B-TMD-table-list" v-for="(item,index) in list" :key="index">
        <div class="B-TMD-table-list-title">
          <div class="B-TMD-table-list-head">
            <div class="B-TMD-table-list-title-y"
                 :class="['B-TMD-table-list-title-y-nam', { 'warning': item.vehicleStatus==='910003' }, { 'offline': item.vehicleStatus==='910001' }]">
              <span id="waybillNumber" class="" :title="item.properties.pipename">
                <span class="location-btn" @click="handleLocation(item)">{{ item.properties.pipename }}</span>
               </span>
            </div>
          </div>
        </div>
        <div class="B-TMD-table-list-content">
          <div v-for="itm in labelList" :key="itm.label">
            <span>{{ itm.label }}:</span>
            <span id="b_twe_loan" :title="item.properties[itm.key] ">{{ item.properties[itm.key] }}</span>
          </div>
    <el-scrollbar style="height:286.22px">
      <div class="environmental-risk-list" v-for="(item,index) in searchDataDisplay" :key="index"
           @click="setBounced(item)">
        <i class="state"></i>
        <div>
          <h3>###炼化部</h3>
          <p>所属部门:<span>{{ item.Name }}</span></p>
          <p>风险级别:<span>三级</span></p>
        </div>
      </div>
    </el-scrollbar>
    <el-card class="footer-page" v-if="total > 10">
      <el-pagination
          small
          @current-change="handlePage"
          :page-size=pageSize
          layout="prev, pager, next"
          :total=total
          :current-page=current
          class="warnPagination"
      >
      </el-pagination>
    </el-card>
  </div>
</template>
<script>
// 引入可选择数据
import { SolidWasteTypeOptions } from '@/conf/layers/LayerSolidWaste'
import WfsHelper from '@components/helpers/WfsHelper'
import AjaxUtils from '@utils/AjaxUtils'
import mapApi from '@/api/mapApi'
import publicBounced from '@/components/BaseNav/PublicBounced/PublicBounced'
export default {
  name: 'SolidWasteSearch',
  props: ['title'],
  data () {
    return {
      judgeVisible: true,
      list: [],
      labelList: SolidWasteTypeOptions[0].labelList,
      total: 0,
      SolidWasteTypeOptions: SolidWasteTypeOptions,
      dataTypeOptions: SolidWasteTypeOptions[0].options,
      solidWasteTypeOptions: [{
        value: '1',
        label: '区域',
        options: [{
          value: '1',
          layerName: '固废',
          key: 'pipename',
          label: '全部固废'
        }],
        labelList: [{
          label: '输送介质',
          key: 'mediumtype'
        }, {
          label: '长度(m)',
          key: 'length'
        }]
      }, {
        value: '2',
        label: '企业名称',
        options: [{
          value: '1',
          layerName: '固废',
          key: 'pipename',
          label: '全部固废'
        }],
        labelList: [{
          label: '输送介质',
          key: 'mediumtype'
        }, {
          label: '长度(m)',
          key: 'length'
        }]
      }, {
        value: '3',
        label: '二级单位',
        options: [{
          value: '1',
          layerName: '固废',
          key: 'pipename',
          label: '全部固废'
        }],
        labelList: [{
          label: '输送介质',
          key: 'mediumtype'
        }, {
          label: '长度(m)',
          key: 'length'
        }]
      }, {
        value: '4',
        label: '企业名称',
        options: [{
          value: '1',
          layerName: '固废',
          key: 'pipename',
          label: '全部固废'
        }],
        labelList: [{
          label: '输送介质',
          key: 'mediumtype'
        }, {
          label: '长度(m)',
          key: 'length'
        }]
      }],
      form: {
        pipelineType: SolidWasteTypeOptions[0].label,
        dataType: SolidWasteTypeOptions[0].options[0].label,
        query: SolidWasteTypeOptions[0].options[0],
        keyword: '固废面板数据查询'
        keyword: '固废面板数据查询',
        // 数据的传递
        transferData: 1
      },
      isWaybillHover: true,
      isRouteHover: false
      levelOfRisk: [
        {
          name: '全部',
          value: 1
        },
        {
          name: '正常',
          value: 2
        },
        {
          name: '预警',
          value: 3
        }
      ],
      // 数据搜索之后,存储数据的
      searchDataDisplay: [],
      searchDataDisplayName: '',
      searchDataDisplayId: ''
    }
  },
  props: ['title'],
  methods: {
    // 点击搜索实现数据的搜索展示
    async handleSearch (data) {
      // console.log(this.form.keyword)
      const result = await mapApi.getSolidWaste(data)
      console.log(result)
      this.searchDataDisplay = result.Result.DataInfo
      this.searchDataDisplayName = result.Result.DataInfo[0].Name
      this.searchDataDisplayId = result.Result.DataInfo[0].StoragePlaceId
      console.log(this.searchDataDisplayName)
    },
    // 数据展示,点击进行弹框及点的展示
    setBounced (val) {
      const pos = [val.Latitude, val.Longitude]
      window.map.flyTo(pos, 11)
      const t1 = setTimeout(async () => {
        const dataValue = {
          StoragePlaceId: this.searchDataDisplayId
        }
        // console.log(e.layer.options.totransferData.Name)
        // 弹框标题
        const title = this.searchDataDisplayName
        console.log(title)
        // 基本信息 tabs
        const resultBasic = await mapApi.getSolidWasteBaseInfo(dataValue)
        // 详细信息展示 table
        const resultDetailed = await mapApi.getSolidWasteDetail(dataValue)
        // 绑定弹框实例
        const PublicBounced = window.Vue.extend(publicBounced)
        const instance = new PublicBounced().$mount()
        document.body.appendChild(instance.$el)
        // document.body.removeChild(instance.$el)
        // 通过方法 向绑定弹框传递数据
        instance.setData(title, resultBasic.Result.DataInfo, resultDetailed.Result.DataInfo, 'gufei')
        // this.setPanTo(e.latlng, 300)
      }, 3000)
      console.log(t1)
      // clearTimeout(t1)
    },
    // flayTo() 弹框的可滑动事件
    setPanTo (pos, value) {
      var position = pos
      position = window.map.latLngToLayerPoint(position)
      position.y += value
      position = window.map.layerPointToLatLng(position)
      window.map.flyTo(position)
    },
    // select的option的数据选择
    handlePipelineType (val) {
      this.SolidWasteTypeOptions.forEach((itm) => {
        if (val === itm.value) {
          this.dataTypeOptions = itm.options
          this.form.pipelineType = itm.label
          this.form.labelList = itm.labelList
      this.solidWasteTypeOptions.forEach(item => {
        if (val === item.value) {
          this.handleSearch(item.value)
        }
      })
      this.form.dataType = this.dataTypeOptions[0].label
      this.form.key = this.dataTypeOptions[0].key
    },
    handleDataType (val) {
      this.dataTypeOptions.forEach((itm) => {
        if (val === itm.value) {
          this.form.query = itm
        }
      })
    },
    async handleSearch () {
      const param = {
        pipelineType: this.form.pipelineType,
        dataType: this.form.dataType
      }
      console.log(param)
      var wfsHelper = new WfsHelper()
      wfsHelper.addTypeName(this.form.query.layerName)
      wfsHelper.addLike(this.form.query.key, this.form.keyword)
      const res = await AjaxUtils.GetDataAsynByUrl(wfsHelper.getUrl(), {})
      if (res.data instanceof Object && Object.prototype.hasOwnProperty.call(res.data, 'features')) {
        this.list = res.data.features
      }
    },
    handleLocation (val) {
      console.log(val)
      const bound = this.L.geoJSON([val], {}).getBounds()
      var layer = window.serviceLayerHelper.getByLayerId(val.id)
      layer && layer.openPopup()
      this.$store.state.map.map.flyToBounds(bound)
    }
  }
}
@@ -142,42 +204,4 @@
<style lang="less" scoped>
.sewers-search {
  position: relative;
  overflow: hidden;
  .search-panel {
    background-color: transparent;
    border: 1px solid @background-color-split;
    padding: 10px;
    /deep/ input {
      border-radius: 0;
      background-color: @background-color-split;
      border: solid 1px @color;
      color: @color-gray;
      font-size: 0.01rem;
      .el-select .el-input.is-focus .el-input__inner {
        border-color: @color;
      }
    }
    /deep/ input:focus {
      border-color: @color;
    }
  }
  .search-btn {
  }
  //location-btn{
  //
  //}
  .location-btn:hover, .el-input__icon:hover {
    color: @color;
    cursor: pointer;
  }
}
</style>