<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;
      this.$download("/attendance/vacation/balance/exportExcel", {
        "idList": this.selection,
        'name': this.$route.query['name'],
      }, { type: "excel" }).then(() => this.isExport = false).catch(error => {
        this.isExport = false;
        this.$message.error(error.message);
      })
    },
    /** 重写新增方法 */
    toAdd(row) {
      this.$refs.drawerform.add(row);
    },
    /** 重写编辑方法 */
    toEdit(row) {
      this.$refs.drawerform.edit(row);
    },
    /** 重写查看方法 */
    toView(row) {
      this.$refs.drawerform.view(row);
    },
    /** 查看不同类型假期记录 */
    handleCountDays(row,leavetype){
      this.$post("/attendance/vacation/record/list", {
        page: 1,
        size: -1,
        type:leavetype,
        staffId:row.staffId
      })
          .then((res) => {
            if (res.code == 1) {
              //todo 抽屉打开 假期明细信息
              //this.$message.success("激活设备成功！");
            }
          })
          .catch((error) => {
            this.$message.error(error.message);
          })
    }

  },
  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: "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>