<template>
  <div class="doc_manage_container">
    <apass-list
      ref="list"
      search-placeholder="请输入关键字"
      :hide-search="true"
      :list-total="listTotal"
      :list-header="listHeader"
      :list-data="listData"
      :list-padding-left="paddingLeft"
      @list-action="init"
    >
      <el-breadcrumb separator="/" slot="breadcrumb">
        <el-breadcrumb-item to="/technical_support">
          技术支持
        </el-breadcrumb-item>
        <el-breadcrumb-item to="/technical_support/doc_manage">
          开发文档
        </el-breadcrumb-item>
        <el-breadcrumb-item>
          管理列表
        </el-breadcrumb-item>
      </el-breadcrumb>

      <template slot="header-left">
        <el-button type="primary" @click="addNew">
          新建
        </el-button>
      </template>

      <template slot="top">
        <div class="top_fliter">
          <show-more-filter class="filter_list">
            <div class="filter_item">
              <span class="filter_title">文档名称：</span>
              <el-input
                v-model="topFilter.name"
                placeholder="请输入banner关键词"
                @keyup.enter.native="topFilterAction"
              ></el-input>
            </div>
            <div class="filter_item">
              <span class="filter_title">文档类型：</span>
              <el-select v-model="topFilter.type" placeholder="请选择">
                <el-option label="全部" value=""></el-option>
                <el-option
                  v-for="(item, index) in types"
                  :key="'top_type_' + index"
                  :label="item.label"
                  :value="item.value"
                >
                </el-option>
              </el-select>
            </div>
            <div class="filter_item">
              <span class="filter_title">最后更新时间：</span>
              <el-date-picker
                v-model="topFilter.time"
                type="daterange"
                range-separator="至"
                start-placeholder="开始日期"
                end-placeholder="结束日期"
                value-format="yyyy-MM-dd"
              >
              </el-date-picker>
            </div>
          </show-more-filter>
          <div class="filter_action apaas_button">
            <el-button type="primary" @click="topFilterAction">
              查询
            </el-button>
            <el-button type="defalut" @click="topFilterClear">
              重置
            </el-button>
          </div>
        </div>
      </template>
    </apass-list>
  </div>
</template>

<script>
import apassList from "@/components/apass-list";
import apassDialog from "@/components/apass-dialog";
import showMoreFilter from "@/components/show-more-filter";

export default {
  components: {
    apassList,
    apassDialog,
    showMoreFilter,
  },
  data() {
    return {
      paddingLeft: 25,
      listTotal: 50,
      listHeader: [
        {
          label: "文档名称",
          prop: "name",
          type: "button",
          callback: this.viewItem,
          width: 320,
        },
        {
          label: "文档类型",
          prop: "type",
          align: "center",
        },
        {
          label: "操作人",
          prop: "person",
          align: "center",
        },
        {
          label: "最后更新时间",
          prop: "update_time",
          align: "center",
        },
        {
          label: "操作",
          type: "buttons",
          align: "center",
          width: 240,
          actionList: [
            {
              label: "编辑",
              callback: this.editItem,
            },
            {
              label: "删除",
              callback: this.deleteItem,
              class: "warn",
            },
          ],
        },
      ],
      listData: [
        {
          id: "1000001",
          type: "平台简介",
          name: "BD-aPaaS平台（V3.0）平台简介",
          person: "江阳",
          update_time: "2016-09-21  08:50:08",
        },
        {
          id: "1000002",
          type: "平台简介",
          name: "BD-aPaaS平台（V3.0）平台简介",
          person: "江阳",
          update_time: "2016-09-21  08:50:08",
        },
        {
          id: "1000003",
          type: "平台简介",
          name: "BD-aPaaS平台（V3.0）平台简介",
          person: "江阳",
          update_time: "2016-09-21  08:50:08",
        },
      ],
      topFilter: {
        name: "",
        type: "",
        time: "",
      },
      types: [
        { label: "平台简介", value: "introductory" },
        { label: "使用须知", value: "notice" },
        { label: "术语说明", value: "trem" },
        { label: "标准规范", value: "standard" },
        { label: "操作指南", value: "guide" },
        { label: "接口文档", value: "api" },
        { label: "常见问题", value: "questions" },
      ],
    };
  },
  computed: {},
  created() {},
  methods: {
    init(filter) {
      let fullFilter = {
        ...filter,
        ...this.topFilter,
      };

      console.log(fullFilter);
    },
    topFilterAction() {
      this.refreshPage();
    },
    topFilterClear() {
      this.topFilter = {
        name: "",
        type: "",
        time: "",
      };
      this.refreshPage();
    },
    refreshPage() {
      this.$refs.list.resetCurrentPage();
    },
    viewItem(item) {
      console.log(`view ${item.name}`);
    },
    editItem(item) {
      console.log(`edit ${item.name}`);
    },
    deleteItem(item) {
      console.log(`delete ${item.name}`);
    },
    addNew() {
      console.log("addNew");
    },
  },
};
</script>

<style scoped>
.doc_manage_container {
  height: 100%;
}
</style>
