<template>
  <div class="page">
    <LayoutTable :data="tableData" :config="tableConfig" notAdd notDel>
      <el-button
        type="primary"
        @click="doExport"
        :disabled="isExport"
        size="mini"
        slot="table-head-left2"
        >导出</el-button
      >
    </LayoutTable>
    <drawer-show ref="drawerform" @ok="getData" />
  </div>
</template>

<script>
/** 表单弹出框模式需引入 */
import drawerShow from "./drawershow";
import table from "@/assets/mixins/table";
export default {
  name: "AttendanceVacationBalanceList",
  components: {
    drawerShow,
  },
  mixins: [table],
  created() {},
  methods: {
    // 导出
    doExport() {
      this.isExport = true;
      let params = {};
      for (let value of this.config.search) {
        if (this.query[value.name]) {
          params[value.name] = this.query[value.name];
        }
      }
      if (this.selection.length > 0) {
        params["idList"] = this.selection;
      }
      this.$download(
        "/attendance/vacation/balance/exportExcel",
        {
          ...params,
        },
        { type: "excel" }
      )
        .then(() => (this.isExport = false))
        .catch((error) => {
          this.isExport = false;
          this.$message.error(error.message);
        });
    },
    /** 查看不同类型假期记录 */
    handleCountDays(row, column, val) {
      this.$refs.drawerform.view({
        type: this.util_formatter("AllHolidays", column.property),
        staffId: row.staffId,
        id: row.id,
        val,
      });
    },
  },
  data() {
    return {
      config: {
        isshowTabPane: true,
        search: [
          {
            name: "deptId",
            type: "select",
            label: "全部部门",
            fuzzy: true,
          },
          {
            name: "staffName",
            type: "text",
            label: "员工姓名",
            fuzzy: true,
          },
        ],
        columns: [
          { type: "selection", width: 60 },
          { type: "index", label: "序号", width: 50 },
          { label: "员工姓名", prop: "staffName" },
          { label: "部门名称", prop: "deptName" },
          {
            label: "入职时间",
            prop: "entryTime",
            formatter: this.formatterDate,
          },
          {
            label: "事假（天）",
            prop: "personalLeaveDays",
            formatter: this.formatterDay,
          },
          {
            label: "调休（天）",
            prop: "compensatedLeaveDays",
            formatter: this.formatterDay,
          },
          {
            label: "病假（天）",
            prop: "sickLeaveDays",
            formatter: this.formatterDay,
          },
          {
            label: "年假（天）",
            prop: "annualLeaveDays",
            formatter: this.formatterDay,
          },
          {
            label: "婚假（天)",
            prop: "marriageLeaveDays",
            formatter: this.formatterDay,
          },
          {
            label: "哺乳假（天）",
            prop: "breastfeedingLeaveDays",
            formatter: this.formatterDay,
          },
          // {label: "创建用户", prop: "createUserId", formatter: this.formatter},
          // {
          //       label: "操作",
          //       width: 240,
          //       formatter: row => {
          //           return (
          //               <table-buttons noAdd noEdit noView noDel row={row}
          //               onEdit={this.toEdit} onView={this.toView} onDel={this.toDel} />
          //       )
          //       }
          // }
        ],
        isExport: false,
      },
    };
  },
};
</script>
