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


        <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.category_id" clearable class="m-2" placeholder="请选择分类" size="large">
              <el-option
                v-for="item in categoryList"
                :key="item.id"
                :label="item.name"
                :value="item.id"
              />
            </el-select>
        </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" >  <svg-icon icon-class="edit"/> 创建模块</el-button>
        </el-form-item>
      </el-form>




  </div>
</template>

<script>
import dataInfo from './dataInfo.vue';
import elDragDialog from '@/directive/el-drag-dialog'
import {searchTemplateCategory} from "@/api/template"
export default{
  components:{
    dataInfo,
  },
  directives: { elDragDialog },
  props:{
    queryForm:{
        type:Object,
        default:()=>{
          return {
             page:1,
             pageSize:10,
             name:'',
             category_id:'',
             status:'',
          }
        }
    },

  },
  data(){
    return{
        statusOptions:[
          {
            value:'',
            label:"请选择状态"
          },
          {
            value:5,
            label:'启用'
          },
          {
            value:6,
            label:"停用"
          },
        ],
        categoryList:[],
        dialogVisible:false,
    }
  },
  mounted() {
    this.initCategory();
  },
  methods:{


    initCategory (){
      let _this=this;
      searchTemplateCategory({page:1,pageSize:999,status:5}).then(res=>{
        if(res.status!=200)return;
        _this.categoryList=res.data.dataList;
      })
    },
    onCreate(e){
      /* this.dialogVisible=true; */
     /*  const url = this.$router.resolve({ path: 'new' }).href;
      window.open(url, '_blank'); */
      /* let _this=this;
        var a = document.createElement('a');
        a.href="#/document/create"
        a.target="_blank";
        a.click(); */
        this.$router.push('/document/create');
    },

    //搜索
    onSubmit(){
      this.$emit("bindSetQuery",this.$props.queryForm);
    }
  }
}
</script>

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