<template>
  <div class="page">
    <LayoutTable :data="tableData" :config="tableConfig">
    </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: {
    /** 重写新增方法 */
    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: {
        search: [
        ],
        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: (row) => {
          return (
             <div><el-link type="primary" onClick={() => {
               this.handleCountDays(row,1);
             }}>{row.personalLeaveDays}天</el-link></div>
          );
          }},

          {label: "调休", prop: "compensatedLeaveDays", formatter: this.formatterAmount},

          {label: "病假", prop: "sickLeaveDays", formatter: this.formatterAmount},

          {label: "年假", prop: "annualLeaveDays", formatter: this.formatterAmount},

          {label: "产假", prop: "maternityLeaveDays", formatter: this.formatterAmount},

          {label: "陪产假", prop: "paternityLeaveDays", formatter: this.formatterAmount},

          {label: "婚假", prop: "marriageLeaveDays", formatter: this.formatterAmount},

          {label: "例假", prop: "menstrualLeaveDays", formatter: this.formatterAmount},

          {label: "哺乳假", prop: "breastfeedingLeaveDays", formatter: this.formatterAmount},

          {label: "丧假", prop: "bereavementLeaveDays", formatter: this.formatterAmount},

          {label: "创建用户", prop: "createUserId", formatter: this.formatter},
          {
            label: "操作",
            width: 240,
            formatter: row => {
              return (
                  <table-buttons noAdd row={row} onEdit={this.toEdit} onView={this.toView} onDel={this.toDel} />
              );
            }
          }
        ]
      }
    };
  }
};
</script>
