<template>
  <div class="data-search">
    <el-form :inline="true" :model="queryForm" class="demo-form-inline">


        <el-form-item label="编码:">
          <el-input v-model="queryForm.code" placeholder="请选择编码"></el-input>
        </el-form-item>

        <el-form-item label="表名:">
          <el-input v-model="queryForm.name" placeholder="请选择表名"></el-input>
        </el-form-item>
        <el-form-item label="状态:">
          <el-select v-model="queryForm.status" class="m-2" placeholder="请选择状态" size="large">
              <el-option
                v-for="item in statusOptions"
                :key="item.value"
                :label="item.label"
                :value="item.value"
              />
            </el-select>
        </el-form-item>

        <el-form-item>
          <el-button type="primary" @click="onSubmit">  <svg-icon icon-class="search"/> 搜索</el-button>
          <el-button type="success" @click="onCreate"  v-if="allowCreate">  <svg-icon icon-class="edit"/> 创建数据表</el-button>
        </el-form-item>
      </el-form>



    <el-dialog  :visible.sync="dialogVisible" append-to-body v-el-drag-dialog  width="80%" custom-class="prod-verify" title="创建数据表">
         <dataInfo @onClose="onClose"></dataInfo>
     </el-dialog>

  </div>
</template>

<script>
import dataInfo from './dataInfo.vue';
import elDragDialog from '@/directive/el-drag-dialog'
export default{
  components:{
    dataInfo,
  },
  directives: { elDragDialog },
  props:{
    queryForm:{
        type:Object,
        default:()=>{
          return {
            page:1,
            pageSize:10,
            code:'',
            name:'',
            status:''
          }
        }
    },
    allowCreate:{
      type:Boolean,
      default:false
    }
  },
  data(){
    return{
        statusOptions:[
          {
            value:'',
            label:"请选择状态"
          },
          {
            value:5,
            label:'启用'
          },
          {
            value:6,
            label:"停用"
          },
        ],
        dialogVisible:false,
    }
  },
  created() {

  },
  methods:{

    onCreate(e){
      // this.dialogVisible=true;
      this.$router.push({path:'/knowledge/dataCenter/create'})
    },
    onClose(e){
      this.dialogVisible=false;
      this.queryForm.isUpdate=!this.queryForm.isUpdate;
    },
    //搜索
    onSubmit(){
      this.$emit("bindSetQuery",this.$props.queryForm);
    }
  }
}
</script>

<style lang="scss">
@import "./dataSearch.scss"
</style>
