<template>
  <div>
    <el-dialog
        title="过滤"
        :visible.sync="visible"
        width="500px"
        :before-close="handleClose"
        :append-to-body="true" 
        :close-on-click-modal="false">
        <div>
            <myFormSearch ref="myFormSearch" :list="list" :field="field" :searchValue="false" @search="search"></myFormSearch>
        </div>
    </el-dialog>
  </div>
</template>

<script>
export default {
  components: {},
  props: {
    DBType:{}
  },
  data() {
    return {
        visible:false,
        list:[],
        field:[],
    };
  },
  watch: {},
  computed: {},
  created() {},
  mounted() {},
  methods: {
    open(){
        this.list = []
        this.getField()
        this.visible = true
    },
    getField(){
      var data = JSON.parse(JSON.stringify(this.$constants.searchField))
      var fields = []
      for(var i = 0;i<data.length;i++){
        var item = data[i]
        if(item.DBType.indexOf(this.DBType)==-1 || item.value == 'project'){
          continue
        }
        var children = []
        for(var j = 0;j<item.children.length;j++){
            var child = item.children[j]
            if(child.value=='GJ' || child.DBType.indexOf(this.DBType)==-1){
                continue;
            }
            children.push(child)
            if(child.after && child.after.length){
              children.push(...child.after)
            }
        }
        if(children && children.length>0){
          fields.push(
            {
              ...item,
              children:children
            }
          )
        }
      }
      this.field = fields
    },
    handleClose(){
        this.visible = false
    },
    search(val,data){
        var a = {
            searchStr: `${val?val:''}`,
            data:data,
            isRepeat:true
        }
      this.$emit('search',a)
      this.handleClose()
    },
  },
};
</script>
<style lang="scss" scoped>
</style>