<template>
  <div class="page">
    <div class="main">
      <el-form
        ref="select"
        style="padding:0 10px 0 10px;background: #fff"
        label-width="auto"
      >
        <el-row :gutter="20">
          <!-- 一层 -->
          <el-col :span="4">
            <el-form-item label="会员编号">
              <el-input
                v-model="form.memberCode"
                clearable
              />
            </el-form-item>
          </el-col>
          <el-col :span="6">
            <el-form-item label="考核类型">
              <el-select
                v-model="form.assessTypeList"
                clearable
                collapse-tags
                multiple
              >
                <el-option
                  v-for="item in assessmentEnum"
                  :key="item.value"
                  :label="item.label"
                  :value="item.value"
                />
              </el-select>
            </el-form-item>
          </el-col>
          <el-col :span="6">
            <el-form-item label="考核日期">
              <el-date-picker
                v-model="form.dateStr"
                style="width: 100%"
                type="month"
                value-format="yyyyMM"
              />
            </el-form-item>
          </el-col>

          <el-col
            :span="4"
          >
            <el-button
              type="primary"
              size="small"
              class="my_search"
              @click="getDataList"
            > 搜索</el-button>
            <el-button
              class="my_reset"
              @click="reset"
            > 重置</el-button>
          </el-col>
        </el-row>

      </el-form>

      <div class="mainTable">
        <div class="itemTrading">
          <el-table
            ref="mainTable"
            v-loading="loading"
            :data="tableData"
            height="730px"
            style="width: 100%"
            :header-cell-style="{ background: '#EEEEEE' }"
            :row-class-name="tableRowClassName"
            show-summary
          >
            <!-- <el-table-column
              type="selection"
              width="55"
            /> -->
            <el-table-column
              align="center"
              prop="memberCode"
              width="150"
              label="会员编号"
            />
            <el-table-column
              align="center"
              prop="memberName"
              width="auto"
              label="会员姓名"
            />
            <el-table-column
              align="center"
              prop="vertexName"
              width="auto"
              label="隶属体系"
            />
            <el-table-column
              align="center"
              prop="awardsName"
              width="120"
              label="奖衔"
            />
            <el-table-column
              align="center"
              prop="assessTypeVal"
              width="120"
              label="考核类型"
            />

            <el-table-column
              align="center"
              prop="assessStatusVal"
              width="120"
              label="考核状态"
            />
            <el-table-column
              align="center"
              prop="assessAwardsName"
              width="120"
              label="考核奖衔"
            />
            <el-table-column
              align="center"
              prop="assessTarget"
              width="120"
              label="考核目标"
            />
            <el-table-column
              align="center"
              prop="monthAdd"
              width="120"
              label="新增业绩"
            />

          </el-table>
        </div>
      </div>
    </div>
    <pagination
      v-show="total>0"
      :total="total"
      :page.sync="queryParams.pageNum"
      :limit.sync="queryParams.pageSize"
      @pagination="getDataList"
    />

  </div>
</template>

<script>
import { getAssessmentRecorsList, getAssessmentTypeEnum } from '@/api/assessment-records'
import { mapGetters } from 'vuex'
const initForm = {
  memberCode: '',
  dateStr: '',
  assessTypeList: []
}
export default {
  name: 'BonusExpansionDelay',
  data() {
    return {
      queryParams: {
        pageNum: 1,
        pageSize: 50
      },
      assessmentEnum: [],
      total: 0,
      tableData: [],
      loading: false,
      form: {
        ...initForm
      }
    }
  },
  computed: {
    ...mapGetters(['getUser'])
  },
  created() {
    // dateStr默认当月
    this.form.dateStr = new Date().getFullYear() + (new Date().getMonth() + 1).toString().padStart(2, '0')
    console.log(this.form.dateStr)
  },
  mounted() {
    this.getDataList()
    this.getAssessmentTypeEnum()
  },
  methods: {
    assessTypeFormat(val) {
      return this.assessmentEnum.find(item => item.value === val)?.label || '-'
    },

    reset() {
      this.form = {
        ...initForm
      }
      this.queryParams.pageNum = 1
      this.queryParams.pageSize = 50
      this.getDataList()
    },
    getAssessmentTypeEnum() {
      getAssessmentTypeEnum()
        .then((res) => {
          if (res.code === 200) {
            this.assessmentEnum = res.data || []
          }
        })
    },
    getDataList() {
      this.loading = true
      console.log(this.form.dateStr)
      const params = Object.assign({}, this.queryParams, this.form, {
        assessTypeList: this.form.assessTypeList.join(',')
      })
      getAssessmentRecorsList(params)
        .then((res) => {
          this.tableData = res.rows
          this.total = res.total
        }).finally(() => {
          this.loading = false
        })
    },

    tableRowClassName({ row, rowIndex }) {
      if (rowIndex % 2 === 1) {
        return 'warning-row'
      } else if (rowIndex % 2 === 0) {
        return 'success-row'
      }
      return ''
    }
  }
}
</script>
<style scoped lang="scss">
::v-deep .el-range-editor.el-input__inner {
  width: 100%;
}
::v-deep .el-button {
  //height: 32px;
  //line-height: 32px;
  padding: 8px 20px;
}
::v-deep .el-date-editor .el-range__close-icon {
  margin-top: -10px;
}
::v-deep .el-date-editor .el-range-separator {
  margin-top: -10px;
}
::v-deep .el-date-editor .el-range__icon {
  margin-top: -10px;
}
::v-deep .el-cascader input {
  height: 32px !important;;
  //line-height: 28px;
}
::v-deep .el-form-item {
  margin-bottom: 0;
}
::v-deep .el-form-item__label {
  color: #333;
  font-weight: inherit;
}

::v-deep .el-table .warning-row {
  background: #f9f9f9;
}

::v-deep .el-table .success-row {
  background: #ffffff;
}
::v-deep .el-table thead {
  color: #000000;
}
::v-deep .el-select {
  width: 100%;
}
.uploadIcon ::v-deep .el-upload--picture-card {
  display: none !important; /* 上传按钮隐藏 */
}
.page {
  padding: 20px;
  background: #f9f9f9;
  font-size: 14px;
  .main {
    background: #f9f9f9;
    //border-radius: 8px;
    //box-shadow: 0px 2px 20px 0px rgba(238, 238, 238, 0.5);
    overflow: hidden;
    display: flex;
    flex-direction: column;
    .maintop {
      display: flex;
      //padding: 10px 20px;
      //padding: 10px 0;
      justify-content: space-between;
      align-items: center;
      .mainbtn {
        .thebtn1 {
          background: #3181e5;
          color: #ffffff;
        }
        .thebtn2 {
          background: #ffad41;
          color: #ffffff;
        }
      }
      .maintitle {
        font-size: 10px;
        font-family: MicrosoftYaHei;
        color: #999999;
      }
    }
    .mainTable{
      flex: 1;
      overflow-y: auto;
    }
  }
  .tem {
    display: flex;
    align-items: center;
    justify-content: center;
    img {
      width: 28px;
      height: 20px;
      margin-right: 3px;
    }
  }
  .isRed {
    color: #ed1d25;
  }
  .isGreen {
    color: #1ab62b;
  }
  .bgImg {
    width: 48px;
    height: 48px;
  }
}
.openClose {
  text-align: right;
  margin-right: 10px;
  color: #3181e5;
}
.kuang {
  padding: 5px 20px;
  background: rgba(255, 255, 255, 0);
  border-radius: 4px;
  border: 1px solid #cccccc;
}
.heji {
  margin-top: 10px;
  .dis {
    display: flex;
    justify-content: right;
    padding: 5px 10px;
    font-size: 14px;
    color: #333333;
    :nth-child(1) {
      font-size: 14px;
      font-weight: bold;
      color: #333333;
      margin-right: 20px;
    }
  }
}
</style>
