<template>
  <div>
    <div class="app-container">
      <el-form :model="queryParams" ref="queryForm" size="mini" :inline="true" @submit.native.prevent>
        <el-row>
          <el-col :span="18">
            <el-form-item label="名称" prop="name">
              <el-input
                v-model="queryParams.name"
                clearable
                @keyup.enter.native="btnSearch"
              />
            </el-form-item>
          </el-col>
          <el-col :span="6">
            <el-form-item style="float:right">
              <el-button type="primary" icon="el-icon-search" size="mini" @click="btnSearch">搜索</el-button>
              <el-button icon="el-icon-refresh" size="mini" @click="btnResetQuery">重置</el-button>
            </el-form-item>
          </el-col>
        </el-row>
      </el-form>
      <el-table size="mini" v-loading="loading" :data="listData" height="500px" @row-dblclick="btnDetails">
        <el-table-column label="周期编号" align="center" prop="id" />
        <el-table-column label="名称" align="center" prop="name" />
        <el-table-column label="月份" align="center" prop="month" />
        <el-table-column label="创建时间" align="center" prop="createTime" />
        <el-table-column label="创建人" align="center" prop="createByName" />
        <el-table-column label="操作" fixed="right" align="center" class-name="small-padding fixed-width">
        <template slot-scope="scope">
            <el-button
              size="mini"
              type="text"
              @click="btnDetails(scope.row)"
            >详情</el-button>
          </template>
        </el-table-column>
      </el-table>
      <div class="paginationClass">
        <pagination
          v-show="total>0"
          :total="total"
          :page.sync="queryParams.pageNum"
          :limit.sync="queryParams.pageSize"
          @pagination="getList"
        />
      </div>
    </div>
  </div>
</template>

<script>
import { listStage,delStage} from "@/api/business/ehr/pm/stage";

export default {
  name: "KanbanList",
  dicts: ['ehr_pm_status'],
  data() {
    return {
      // 遮罩层
      loading: true,
      // 总条数
      total: 0,
      // 表格数据
      listData: [],
      // 弹出层标题
      title: "",
      // 是否显示弹出层
      open: false,
      // 查询参数
      queryParams: {
        pageNum: 1,
        pageSize: 10,
        name: null,
      },
    };
  },
  created() {
    this.getList();
  },
  methods: {
    /** 查询行动列表 */
    getList() {
      this.loading = true;
      listStage(this.queryParams).then(response => {
        this.listData = response.rows;
        this.ids = response.rows.map(item => item.id);
        this.total = response.total;
        this.loading = false;
      });
    },
    /** 搜索按钮操作 */
    btnSearch() {
      this.queryParams.pageNum = 1;
      this.getList();
    },
    /** 重置按钮操作 */
    btnResetQuery() {
      this.resetForm("queryForm");
      this.btnSearch();
    },
    /** 进入详情 */
    btnDetails(row){
      this.$router.push({ name: 'Kanban', query: { id: row.id}});
    },
  }
};
</script>

<style lang="scss" scoped>
.btn_grooup {
  margin-bottom: 10px;
  display: flex;
  justify-content: flex-end;
}
.paginationClass {
  z-index: 500;
  position: fixed;
  bottom: 10px;
  right: 10px;
  width: 100%;
  line-height: var(--footer-height);
  color: #fff;
}
</style>
