派生自 wuyushui/SewerAndRainNetwork

chenyabin
2021-04-01 175db8fd0f26c8f7b01c7bc717cbf46cebad9805
src/components/panel/topicSearch/SolidWasteSearch.vue
@@ -0,0 +1,234 @@
<template>
  <div class="solidwaste-search" v-if="judgeVisible">
    <div class="search-title">
      <span>固废</span>
      <!--      <span>{{ title }}</span>-->
    </div>
    <div class="search-panel ">
      <el-form ref="form" :model="form" label-width="90px" class="search-form">
        <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"
                :key="item.value"
                :label="item.label"
                :value="item.value">
            </el-option>
          </el-select>
        </el-form-item>
        <div class="search-radio">
          <el-radio v-model="radio" label="1">全部</el-radio>
          <el-radio v-model="radio" label="2">正常</el-radio>
          <el-radio v-model="radio" label="3">预警</el-radio>
        </div>
        <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-form>
      <el-card class="box-card"
               v-for="(item,index) in searchDataDisplay.slice((currentPage-1)*PageSize,currentPage*PageSize)"
               :key="index">
        <div v-if="totalCount > 0">
          {{ item.CompanyName }}
        </div>
      </el-card>
      <div class="search-pagination">
        <el-pagination
            small
            @size-change="handleSizeChange"
            @current-change="handleCurrentChange"
            :current-page="currentPage"
            :page-sizes="[1, 2, 3]"
            :page-size="1"
            layout="total, sizes, prev, pager, next, jumper"
            :total='totalCount'>
        </el-pagination>
      </div>
    </div>
    <!--      <el-scrollbar style="height:100%">-->
    <!--      </el-scrollbar>-->
  </div>
</template>
<script>
import mapApi from '@/api/mapApi'
export default {
  name: 'SolidWasteSearch',
  props: ['title'],
  data () {
    return {
      judgeVisible: true,
      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'
        }]
      }],
      radio: '1',
      form: {
        keyword: '固废面板数据查询',
        // 数据的传递
        transferData: ''
      },
      searchDataDisplay: [],
      // 默认显示第几页
      currentPage: 1,
      // 总条数,根据接口获取数据长度(注意:这里不能为空)
      totalCount: 1,
      // 个数选择器(可修改)
      pageSizes: [1, 2, 3, 4],
      // 默认每页显示的条数(可修改)
      PageSize: 1
    }
  },
  methods: {
    // 每页显示的条数
    handleSizeChange (val) {
      this.PageSize = val
      this.currentPage = 1
    },
    // 显示第几页
    handleCurrentChange (val) {
      this.currentPage = val
    },
    handlePipelineType (val) {
      // console.log(val)
      this.solidWasteTypeOptions.forEach(item => {
        // console.log(item.value)
        if (val === item.value) {
          // console.log('数据选择相同')
          // 接收数据 用于之后接口数据的调用
          // this.form.transferData = item.value
          this.handleSearch(item.value)
        }
      })
    },
    // 点击搜索实现数据的搜索展示
    async handleSearch (data) {
      // console.log(this.form.keyword)
      const result = await mapApi.getSolidWasteSurveyDetail(data)
      // console.log(result)
      this.searchDataDisplay = result.Result.DataInfo
      this.totalCount = result.Result.DataInfo.length
    }
  }
}
</script>
<style lang="less" scoped>
.solidwaste-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 {
  }
  .search-radio {
    margin: 15px auto;
    display: flex;
    align-items: center;
    justify-content: space-around;
  }
  .location-btn:hover, .el-input__icon:hover {
    color: @color;
    cursor: pointer;
  }
  .box-card {
    margin: 15px auto;
  }
  .search-pagination {
    padding: 0;
    margin: 15px auto;
  }
}
</style>