<template>
  <div class="page">
    <div class="btn_box" style="position: absolute;top: 54px;left: 10px;">
      <el-radio-group v-model="radio1" @input="changeRadio">
        <el-radio-button label="1">窗口考核</el-radio-button>
        <el-radio-button label="2">工作人员考核</el-radio-button>
        <el-radio-button label="3">工作人员一张表</el-radio-button>
      </el-radio-group>
      <el-button
        slot="table-head-left2"
        style="margin-left: 10px"
        icon="el-icon-tickets"
        size="mini"
        @click="doExport"
        :disabled="isExport"
        >导出</el-button
      >
    </div>
    <LayoutTable :data="tableData" notAdd notDel :config="tableConfig">
    </LayoutTable>
  </div>
</template>

<script>
import {
  timestampToTime,
  getFirstDay,
  getLastDay,
} from "@/assets/utils/dateFormat";
/** 表单弹出框模式需引入 */
import table from "@/assets/mixins/table";
export default {
  name: "WindowWorkmanPerformDetailList",

  mixins: [table],
  created() {
    this.query.yearmonth = timestampToTime(new Date(), 2);
    this.query.year = timestampToTime(new Date(), 2).slice(0, 4);
    this.query.month = timestampToTime(new Date(), 2).slice(5);
    console.log(this.query);
  },
  methods: {
    /** 导出Excel */
    doExport() {
      this.isExport = true;
      this.$download(
        "window/workman/perform/detail/exportExcel",
        {
          page: 1,
          size: -1,
        },
        { type: "excel" }
      )
        .then(() => (this.isExport = false))
        .catch((error) => {
          this.isExport = false;
          this.$message.error(error.message);
        });
    },
    // 切换表格
    changeRadio() {
      this.radio1 == 1
        ? this.$router.push("/check/window/perform/list?page=1")
        : this.radio1 == 2
        ? this.$router.push("/check/window/workman/perform/list?page=1")
        : this.radio1 == 3
        ? this.$router.push("/check/window/workman/perform/detail/list?page=1")
        : "";
    },
  },
  data() {
    return {
      radio1: "3",
      isExport: false,
      config: {
        isshowTabPane: true,
        search: [
          {
            name: "salaId",
            type: "selectSalaId",
            label: "大厅",
            fuzzy: false,
          },
          {
            name: "deptId",
            type: "selectDeptId",
            label: "部门",
            fuzzy: false,
          },

          {
            name: "yearmonth",
            type: "month",
            label: "请选择考评年月",
            fuzzy: false,
          },
          {
            name: "staffName",
            type: "text",
            width: 200,
            label: "工作人员姓名搜索",
            fuzzy: false,
          },
        ],
        columns: [
          { type: "selection", width: 60 },
          { type: "index", label: "序号", width: 50 },

          { label: "工作人员名称", prop: "staffName" },
          {
            label: "考评年月",
            formatter: (row) => {
              return `${row.year ? row.year : "--"}-${
                row.month
                  ? [1, 2, 3, 4, 5, 6, 7, 8, 9].includes(row.month)
                    ? "0" + row.month
                    : row.month
                  : "--"
              }`;
            },
          },

          {
            label: "所属大厅",
            prop: "salaName",
            formatter: this.formatter,
          },
          {
            label: "部门（单位）名称",
            prop: "deptName",
            formatter: this.formatter,
          },
          {
            label: "工作纪律",
            prop: "discipline",
            formatter: this.formatter,
          },

          {
            label: "服务规范",
            prop: "specification",
            formatter: this.formatter,
          },

          {
            label: "综合管理",
            prop: "management",
            formatter: this.formatter,
          },

          {
            label: "群众评议",
            prop: "evaluation",
            formatter: this.formatter,
          },

          {
            label: "工作效能",
            prop: "efficiency",
            formatter: this.formatter,
          },

          {
            label: "加分",
            prop: "bonusScore",
            formatter: this.formatter,
          },

          {
            label: "合计得分",
            prop: "sumScore",
            formatter: this.formatter,
          },

          {
            label: "考核等级",
            prop: "examineLevel",
            formatter: this.formatter,
          },
        ],
      },
    };
  },
};
</script>
<style lang="less" scoped>
/deep/.el-radio-button__inner {
  border: 1px solid #eee !important;
  height: 28px;
  line-height: 3px;
}
/deep/.el-radio-button__orig-radio:checked + .el-radio-button__inner {
  background: #00b565;
  border: none !important;
  color: #fff !important;
  line-height: 3px;
}
</style>
