<template>
  <div class="content-main">
    <el-form
      :model="formInfo"
      label-width="75px"
      ref="formInfo"
      :inline="true"
      class="search-bm-boder"
    >
      <el-form-item label="系统模块:" prop="gnmk">
        <el-input
          placeholder="请输入"
          v-model="formInfo.gnmk"
          class="inputCompatible"
          clearable
        ></el-input>
      </el-form-item>
      <el-form-item label="文档标题:" prop="wdbt">
        <el-input
          placeholder="请输入"
          v-model="formInfo.wdbt"
          class="inputCompatible"
          clearable
        ></el-input>
      </el-form-item>
      <el-form-item label="推荐读者:" prop="tjdz">
        <el-select
          class="inputCompatible"
          v-model="formInfo.tjdz"
          placeholder="请选择"
          clearable
        >
          <el-option
            v-for="item in tjdzOptions"
            :key="item.value"
            :label="item.label"
            :value="item.value"
          ></el-option>
        </el-select>
      </el-form-item>
      <div class="search-button">
        <span class="search-line"></span>
        <el-button
          type="primary"
          @click="goSearch"
          size="small"
          class="iconfont iconchaxun"
          >查询</el-button
        >
        <el-button
          type="primary"
          @click="resetInfo('formInfo')"
          size="small"
          class="iconfont iconzhongzhi"
          >重置</el-button
        >
      </div>
    </el-form>
    <el-table
      :data="tableData"
      v-loading="listLoading"
      border
      stripe
      highlight-current-row
      @row-click="tableRowClick"
      style="width: 100%"
    >
      <el-table-column
        label="序号"
        type="index"
        align="center"
        width="60"
      ></el-table-column>
      <el-table-column
        align="center"
        :show-overflow-tooltip="true"
        prop="gnmk"
        label="系统模块"
        sortable
      ></el-table-column>
      <el-table-column
        align="center"
        :show-overflow-tooltip="true"
        prop="wdbt"
        label="文档标题"
        sortable
      ></el-table-column>
      <el-table-column
        align="center"
        :show-overflow-tooltip="true"
        prop="tjdz"
        label="推荐读者"
        sortable
      ></el-table-column>
      <!-- <el-table-column
        align="center"
        :show-overflow-tooltip="true"
        prop="bzrq"
        label="编制日期"
        sortable
      ></el-table-column>-->
      <el-table-column label="操作" align="center" width="200">
        <template slot-scope="scope">
          <el-tooltip
            class="item"
            effect="light"
            content="查看"
            placement="top"
          >
            <el-button
              type="primary"
              @click="goLook(scope.row)"
              size="small"
              class="operate_show_btn iconfont iconchakan2"
            ></el-button>
          </el-tooltip>
        </template>
      </el-table-column>
    </el-table>
    <!-- 分页开始 -->
    <div class="pag-right clearFix">
      <el-pagination
        class="right"
        :current-page.sync="limit.page"
        :page-size="limit.size"
        :page-sizes="[10, 20, 30, 40]"
        :total="limit.total"
        @current-change="handleCurrentChangeTask"
        @size-change="handleSizeChangeTask"
        layout="total, sizes, prev, pager, next, jumper"
        v-if="paginationShow"
      ></el-pagination>
    </div>
  </div>
</template>
<script>
import { helpList } from "@/api/publicfunction/helpDocument";
export default {
  data() {
    return {
      listLoading: false,
      paginationShow: true,
      tableData: [{}],
      formInfo: {
        gnmk: "",
        wdbt: "",
        tjdz: "",
        status: [1],
        yhcj: ["1", "1,2"],
      },
      limit: {
        page: 1,
        size: 10,
        total: 0,
      },
      tjdzOptions: [
        { value: "承储库", label: "承储库" },
        { value: "区粮办", label: "区粮办" },
        { value: "储备粮公司", label: "储备粮公司" },
        { value: "粮食局", label: "粮食局" },
        { value: "批发市场", label: "批发市场" },
        { value: "购销公司(利达集团)", label: "购销公司(利达集团)" },
      ],
    };
  },
  created() {
    this.getList();
  },
  methods: {
    tableRowClick(row, column, event) {
      //   if (event.label != "操作") {
      //     this.goLook(row);
      //   }
    },
    getList() {
      this.listLoading = true;
      helpList(this.formInfo, this.limit).then((res) => {
        if (res && res.items) {
          this.tableData = res.items;
          this.limit.total = res.total;
        } else {
          this.$message({
            message: res.msg,
            type: "error",
            duration: 2000,
          });
        }
        this.listLoading = false;
      });
    },
    //查询
    goSearch() {
      this.paginationShow = false;
      this.handleCurrentChangeTask(1);
      this.$nextTick(function () {
        this.paginationShow = true;
      });
    },
    resetInfo(formName) {
      this.$refs[formName].resetFields();
      this.getList();
    },
    goLook(row) {
      this.$router.push({
        path: "/publicfunction/helpDocumentDetail",
        query: { wdId: row.wdid },
      });
    },
    handleCurrentChangeTask(val) {
      this.limit.page = val;
      this.getList();
    },
    handleSizeChangeTask(val) {
      this.limit.size = val;
      this.getList();
    },
  },
};
</script>
<style>
</style>
