搜索关键字、筛选行业、筛选地区

1.template
          <el-input
            size="small"
            class="selectOuter"
            v-model="selectInput.Keyword"
            placeholder="请输入企业名称或关键字"
          >
            <i class="el-icon-search el-input__icon" slot="suffix" @click="getTableData"></i>
          </el-input>
          <el-select
            size="small"
            class="selectOuter"
            v-model="selectInput.county"
            placeholder="请选择地区"
            v-if="role==2"
            @change="getTableData"
          >
            <el-option
              v-for="(item, index) in regionList"
              :key="item.value"
              :label="item.label"
              :value="item.value"
            ></el-option>
          </el-select>
          <el-select
            size="small"
            class="selectOuter"
            v-model="selectInput.questionType"
            @change="getTableData"
          >
            <el-option
              v-for="(item, index) in sourceList"
              :key="item.value"
              :label="item.label"
              :value="item.value"
            ></el-option>
          </el-select>
2.script
data(){ return { 
 regionList: [],
 sourceList: [],     
 selectInput: {
        Keyword: "",
        county: "全部",
        questionType: "全部"
      }
}}

sourceList 是从后台获取数据,所以
  created() {
    this.getTableData();
  },
  methods:{
    getTableData() {
      let selectInput = Object.assign({}, this.selectInput);
      Object.keys(selectInput).forEach(v => {
        selectInput[v] = selectInput[v] === "全部" ? "" : selectInput[v];
      });
      let arr = Object.assign(
        {
          pageNum: this.pageData.currentPage,
          pageSize: this.pageData.pageSize
        },
        selectInput
      );
//把 pageNum 和 pageSize与selectInput合并成 一个params
      api.planProblem(arr).then(res => {
        if (res.code === "0000") {
          this.tableData = res.data.results || [];
          this.tableData.forEach((item, index) => { this.sourceList.push(item.questionType)})

//tableData 是数组,item 是数组里每一个对象,item.xxx  取到对象里对应属性的属性值
//对 获取的数据进行操作
 })
          this.pageData.total = res.data.totalRecord;
        } else {
          this.$message({ message: res.msg, type: "error" });
          this.tableData=[];
        }
      });
    },
}
1.template
                <div class='common-search-unit'>
                    <el-input v-model="key" :placeholder="dataFlag==1?'请输入企业名称/预警名称搜索':'请输入预警名称搜索'" clearable size='small'></el-input>
                </div>
                <div class='common-search-unit' v-if='dataFlag==1'>
                    <div class='unit-search-label'>地区:</div><el-cascader v-model="area" placeholder="请选择地区"  clearable :options="areaOptions" :props="{ expandTrigger: 'hover',label:'name',value:'areaCode'}" @change="areaChange" ref='areaCascader' size='small'></el-cascader>
                </div>
                <div class='common-search-unit' v-if='dataFlag==1'>
                    <div class='unit-search-label'>行业:</div><el-cascader v-model="industry" placeholder="请选择行业" clearable :options="industryOptions" :props="{ expandTrigger: 'hover',label:'industryName',value:'code'}" @change="industryChange" ref='industryCascader' size='small'></el-cascader>
                </div>
2.
    data() {
        return {
            key:'',
            area:[],
            areaName:[],
            areaOptions:[],
            industry:[],
            industryName:[],
            industryOptions:[],
        },
    created() {
        this.areaOptions=this.$store.getters.region;
        this.industryOptions=this.$store.getters.industry;
}

        getTableData(){
            let param={
                signalName:this.key,
                areaName:this.areaName?'浙江省'+this.areaName.join(''):'',
                industryName:this.industryName?this.industryName.join(''):'',
                province:'浙江省',
                city:this.areaName?this.areaName[0]:'',
                county:this.areaName?this.areaName[1]:'',
                industryTypeFrist:this.industryName?this.industryName[0]:'',
                industryTypeSecond:this.industryName?this.industryName[1]:'',
                industryTypeThird:this.industryName?this.industryName[2]:'',
            };

import {getCascaderLabel} from "../../../common/utils/index"
        //地区筛选
        areaChange(value) {
            if(value.length>0){
                let tempData=this.$refs['areaCascader'].getCheckedNodes();
                getCascaderLabel(tempData[0],this.areaName);
            }else{
                this.areaName=[];
            }
        },
        //行业筛选
        industryChange(value){
            if(value.length>0){
                let tempData=this.$refs['industryCascader'].getCheckedNodes();
                getCascaderLabel(tempData[0],this.industryName);
            }else{
                this.industryName=[];
            }
            
        },

 

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值