<template>
  <div >
    <el-input   clearable :value="inputvalue">
      <el-tooltip slot="append" effect="dark" :content="'搜索'" placement="top">
        <el-button size="mini"  icon="el-icon-search" @click="toggleSearch()" />
      </el-tooltip>
    </el-input>
  </div>
</template>

<script>
import {objdictList, objtableList} from "@/api/system/dict/type";
  export default {
    name: "BizTableEmbed",
    props: {
      value: {
        type: String,
        default: "",
      },
      visibleidx: {
        type: String,
        default: "2",
      },
      para1: {
        type: String,
        default: "",
      },
      para2: {
        type: String,
        default: "",
      },
      para3: {
        type: String,
        default: "",
      },
      para4: {
        type: String,
        default: "",
      },
      dictType: {
        type: String,
        default: "ds",
      },
      outType: {
        type: String,
        default: "0",
      },
      seltype: {
        type: String,
        default: "select",
      },
    },
    data() {
      return {
        loading: false,
        inputvalue:"",
      }
    },
    watch: {

    },
    methods: {
      toggleSearch()
      {
        var para={};
        para.dictType=this.dictType;
        para.outType=this.outType;
        para.seltype=this.seltype;
        para.para1=this.para1;
        para.para2=this.para2;
        para.para3=this.para3;
        para.para4=this.para4;
        para.para5=this.para5;
        this.$selywdata(para, (para) => {
          if (this.seltype==="select")
          {
            this.inputvalue = para[0].name;
          }
          else {
            this.inputvalue = para.name;
          }
          this.$emit('changeData', para);
        }, (para) => {
          console.log(para);
        })

      },

    },
    created() {

      if (this.value.length>0) {
        var para={};
        para.dictType=this.dictType;
        para.outType='1';
        para.para1=this.value;
        objtableList(para).then(response => {
          let data = response;
          if (data.code == 200) {
            if (data.data.data.length==1)
              this.inputvalue=data.data.data[0][this.visibleidx];
          }
        });
      }
    }
  }
</script>

<style scoped>

</style>
