<template>
  <div class="data-search">
    <el-form :inline="true" :model="queryForm" class="demo-form-inline">
      <el-form-item label="文档标题:">
        <el-input
          v-model="queryForm.dcm_title"
          placeholder="请填写文档标题"
        ></el-input>
      </el-form-item>

      <el-form-item label="所属分类:">
        <el-select
          v-model="queryForm.dcm_type"
          clearable
          class="m-2"
          placeholder="请选择分类"
          size="large"
        >
          <!-- <el-option
            v-for="item in categoryList"
            :key="item.id"
            :label="item.name"
            :value="item.id"
          /> -->
          <el-option
            label="官方模板"
            :value="1"
          />
          <el-option
            label="私有模板"
            :value="2"
          />
          <el-option
            label="共享模板"
            :value="3"
          /> 
        </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-form-item>
      <el-form-item v-if="createNewDocument">
        <el-button
          type="primary"
          @click="addDocument"
          class="el-icon-circle-plus-outline"
          >创建文档</el-button
        >
      </el-form-item>
    </el-form>
  </div>
</template>

<script>
import { searchDocumentCategory } from "@/api/document";
export default {
  props: {
    queryForm: {
      type: Object,
      default: () => {
        return {
          page: 1,
          pageSize: 10,
          dcm_title: "",
          dcm_type: "",
          isContentShow: false,
        };
      },
    },
  },
  data() {
    return {
      statusOptions: [
        {
          value: "",
          label: "请选择状态",
        },
        {
          value: 5,
          label: "启用",
        },
        {
          value: 6,
          label: "停用",
        },
      ],
      dialogVisible: false,
      categoryList: [],
      createNewDocument: true,
    };
  },
  created() {
    this.initCategoryList();
    this.checkCreatePermission();
  },
  methods: {
    checkCreatePermission() {
      /* const createPermission = this.$store.state.user.authList.find(
        (e) => e.code === "createNewDocument"
      ); */
      /* this.createNewDocument = !!createPermission; */
    },

    initCategoryList() {
      let _this = this;
      searchDocumentCategory({ page: 1, pageSize: 999, status: 5 }).then(
        (res) => {
          if (res.status != 200) return;
          _this.categoryList = res.data.dataList;
        }
      );
    },
    onCreate(e) {
      this.dialogVisible = true;
    },
    //搜索
    onSubmit() {
      this.$emit("bindSetQuery", this.$props.queryForm);
    },
    /* 创建文档 */
    addDocument() {
      this.$router.push('system/document/create?type=document');
      /* let _this = this;
      let a = document.createElement("a");
      a.href = "#/document/create?type=document"; // 使用 hash
      a.target = "_blank";
      a.click(); */
    },
  },
};
</script>

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