<template>
  <div class="page">
    <el-tabs v-model="activeName" @tab-click="handleClick">
      <el-tab-pane label="未处理" name="1">
        <LayoutTable :data="tableData" notAdd notDel :config="tableConfig">
        </LayoutTable>
      </el-tab-pane>
      <el-tab-pane label="已处理" name="2">
        <LayoutTable :data="tableData" notAdd notDel :config="tableConfig">
        </LayoutTable>
      </el-tab-pane>
      <el-tab-pane label="数据分析" name="3">
        <div class="content">
          <div class="search_box">
            <div class="search">
              <el-select
                v-model="dateValue"
                placeholder="请选择"
                style="margin: 0 10px;"
              >
                <el-option
                  v-for="item in optionsMonths"
                  :key="item.value"
                  :label="item.label"
                  :value="item.value"
                >
                </el-option>
              </el-select>
              <el-button type="primary">搜索</el-button>
            </div>
          </div>
          <div class="data_box">
            <div class="top">
              <div class="box">
                <bar-charts
                  :title="'申诉次数部门排名TOP20'"
                  :id="'dept_20'"
                  :legendName="'申诉次数'"
                  :styleObj="{ width: '800px', height: '360px' }"
                />
              </div>
              <div class="box">
                <bar-charts
                  :title="'申诉次数个人排名TOP20'"
                  :id="'person_20'"
                  :legendName="'申诉次数'"
                  :styleObj="{ width: '800px', height: '360px' }"
                />
              </div>
            </div>
            <div class="down">
              <bar-charts
                :title="'申诉次数规则排名TOP20'"
                :id="'rule_20'"
                :legendName="'申诉次数'"
                :styleObj="{ width: '1800px', height: '320px' }"
              />
            </div>
          </div>
        </div>
      </el-tab-pane>
    </el-tabs>
    <!-- <bar-charts
      :title="'部门扣分排名TOP10'"
      :id="'koufen_10'"
      :legendName="'部门扣分分值'"
      :styleObj="{ width: '100%', height: '300px' }"
    /> -->
    <drawer-show ref="drawerform" @ok="getData" />
  </div>
</template>

<script>
/** 表单弹出框模式需引入 */
import drawerShow from "./drawershow";
import table from "@/assets/mixins/table";
import BarCharts from "./components/BarCharts.vue";
export default {
  name: "PerformAttendAppealList",
  components: {
    drawerShow,
    BarCharts,
  },
  mixins: [table],
  created() {
    this.getData();
  },
  methods: {
    handleClick() {
      this.getData();
    },
    getData() {
      this.activeName == 1 || this.activeName == 2
        ? this.$post("/perform/attend/appeal/list", {
            processStatus: this.activeName,
          }).then((res) => {
            console.log(res);
            if (res.code == 1) {
              this.tableData = res.data;
            }
          })
        : "";
    },
    renderTable(tableData) {
      return (
        <el-table stripe data={tableData} class="total-table">
          {this.columnSet.map((item) => this.renderTableColumn(item))}
        </el-table>
      );
    },
    renderTableColumn(options) {
      return (
        <el-table-column
          prop={options.prop}
          label={options.label}
          width={options.width}
          formatter={options.formatter}
        ></el-table-column>
      );
    },
    /** 重写新增方法 */
    toAdd(row) {
      this.$refs.drawerform.add(row);
    },
    /** 重写编辑方法 */
    toEdit(row) {
      this.$refs.drawerform.edit(row);
    },
    /** 重写查看方法 */
    toView(row) {
      this.$refs.drawerform.view(row);
    },
  },
  data() {
    return {
      /** 子表列元素 */
      columnSet: [
        { label: "申诉Id", prop: "appealId", formatter: this.formatter },
        { label: "文件名称", prop: "fileName" },
        { label: "文件地址", prop: "filePath" },
      ],
      config: {
        isshowTabPane: false,
        search: [
          {
            name: "irregularOtherType",
            type: "select",
            label: "全部类型",
            fuzzy: false,
          },
          {
            name: "deptId",
            type: "select",
            label: "全部部门",
            fuzzy: false,
          },
          {
            name: "date",
            type: "date",
            label: "请选择日期",
            fuzzy: false,
          },
          {
            name: "staffName",
            type: "text",
            label: "员工姓名搜索",
            fuzzy: false,
          },
        ],
        columns: [
          { type: "selection", width: 60 },
          { type: "index", label: "序号", width: 50 },

          { label: "姓名", prop: "staffName" },

          { label: "所属部门", prop: "deptName" },

          { label: "违规类型", prop: "irregularOtherType" },
          { label: "绩效规则", prop: "ruleName" },

          { label: "扣分方式", prop: "subMethod", formatter: this.formatter },

          {
            label: "扣分时间",
            prop: "attendanceDate",
            formatter: this.formatterDate,
          },

          { label: "扣分分值", prop: "score", formatter: this.formatter },

          {
            label: "申诉时间",
            prop: "appealTime",
            formatter: this.formatterDate,
          },

          {
            label: "处理状态",
            prop: "processStatus",
            formatter: this.formatter,
          },

          /* {label: "绩效记录申诉附件信息",
                          width: 120,
                          prop: "subColumns",
                          formatter: (row) => {
                              let widthsize = this.columnSet.reduce((pre, cur) => {
                                  return pre + Number(cur.width);
                              }, 50);
                              return (
                                  <el-popover placement="right" width={widthsize} trigger="click">
                                      {this.renderTable(row.performAttendAppealFilesList)}
                                      <el-button type="text" slot="reference">详细</el-button>
                                  </el-popover>
                              );
                          },
                        },*/
          {
            label: "操作",
            formatter: (row) => {
              return row.processStatus == 2 ? (
                <table-buttons
                  noAdd
                  noDel
                  noEdit
                  row={row}
                  onEdit={this.toEdit}
                  onView={this.toView}
                  onDel={this.toDel}
                />
              ) : (
                <table-buttons
                  noAdd
                  noDel
                  noView
                  noEdit
                  chuli
                  row={row}
                  onEdit={this.toEdit}
                  onView={this.toView}
                  onDel={this.toDel}
                />
              );
            },
          },
        ],
      },
      activeName: "1",
      dateValue: "2023-01-00 00:00:00",
    };
  },
};
</script>
<style lang="less" scoped>
.page {
  width: 100%;
  height: 100%;
  overflow: hidden;

  /deep/.el-tabs__item {
    width: 120px;
    font-size: 14px;
    text-align: center;
  }

  .content {
    width: 100%;
    height: 730px;
    overflow: hidden;

    .search_box {
      width: 100%;
      height: auto;
      text-align: right;
      margin-bottom: 10px;
    }

    .data_box {
      width: 100%;
      height: 100%;

      .top {
        width: 100%;
        height: 380px;
        display: flex;
        justify-content: space-between;

        .box {
          width: 49%;
          height: 100%;
        }
      }
    }
  }
}
</style>
