<template>
  <div class="page">
    <topBar
      v-if="topList.length > 0"
      :topList="topList"
      :moren="moren"
    ></topBar>
    <div class="thetopbox">
      <el-form label-width="100px">
        <el-row>
          <el-col :span="4">
            <el-form-item :label="$t('MN_T_1')">
              <el-input clearable v-model="queryParams.memberCode"></el-input>
            </el-form-item>
          </el-col>
          <el-col :span="4">
            <el-form-item :label="$t('CK_KS_14')">
              <el-input clearable v-model="queryParams.memberName"></el-input>
            </el-form-item>
          </el-col>

          <el-col :span="4">
            <el-form-item :label="$t('w_0052')">
              <el-input clearable v-model="queryParams.phone"></el-input>
            </el-form-item>
          </el-col>
          <el-col :span="4">
            <el-form-item :label="$t('PER_DA_5')">
              <el-select
                clearable
                :placeholder="$t('CK_KS_38')"
                v-model="queryParams.pkRegisterGrade"
              >
                <el-option
                  v-for="item in gradeRangList"
                  :key="item.pkId"
                  :label="item.gradeName"
                  :value="item.pkId"
                ></el-option>
              </el-select>
            </el-form-item>
          </el-col>

          <el-col :span="4">
            <el-form-item :label="$t('CK_KS_16')">
              <el-select
                clearable
                :placeholder="$t('CK_KS_38')"
                v-model="queryParams.pkAwards"
              >
                <el-option
                  v-for="item in awardsList"
                  :key="item.pkId"
                  :label="item.awardsName"
                  :value="item.pkId"
                ></el-option>
              </el-select>
            </el-form-item>
          </el-col>
          <el-col :span="4">
            <el-form-item label="荣誉奖衔">
              <el-select
                clearable
                :placeholder="$t('CK_KS_38')"
                v-model="queryParams.pkRangeAwards"
              >
                <el-option
                  v-for="item in awardsList"
                  :key="item.pkId"
                  :label="item.awardsName"
                  :value="item.pkId"
                ></el-option>
              </el-select>
            </el-form-item>
          </el-col>
          <!-- <el-col :span="4">
            <el-form-item :label="$t('MN_F_T_122')" >
              <el-select
                clearable
                :placeholder="$t('CK_KS_38')"
                v-model="queryParams.pkTeamCode"
              >
                <el-option
                  v-for="item in memberTeamList"
                  :key="item.pkId"
                  :label="item.teamName"
                  :value="item.pkId"
                ></el-option>
              </el-select>
            </el-form-item>
          </el-col> -->
          <el-col :span="4">
            <el-form-item label="晋升方式">
              <el-select
                clearable
                :placeholder="$t('CK_KS_38')"
                v-model="queryParams.upType"
              >
                <el-option
                  v-for="item in upList"
                  :key="item.value"
                  :label="item.label"
                  :value="item.value"
                ></el-option>
              </el-select>
            </el-form-item>
          </el-col>
          <el-col :span="8">
            <el-form-item :label="$t('w_0467')">
              <el-date-picker
                v-model="queryParams.thetimes"
                @change="changeTime"
                value-format="yyyy-MM-dd"
                type="daterange"
                :clearable="false"
                :range-separator="$t('w_0139')"
                :start-placeholder="$t('CK_KS_4')"
                :end-placeholder="$t('CK_KS_5')"
              >
              </el-date-picker>
            </el-form-item>
          </el-col>
          <el-col :span="8">
            <el-form-item :label="$t('奖衔有效期')">
              <el-date-picker
                v-model="queryParams.Dates"
                @change="changeTime1"
                value-format="yyyy-MM-dd"
                type="daterange"
                :clearable="false"
                :range-separator="$t('w_0139')"
                :start-placeholder="$t('CK_KS_4')"
                :end-placeholder="$t('CK_KS_5')"
              >
              </el-date-picker>
            </el-form-item>
          </el-col>
          <el-col :span="4">
            <div class="searchbox">
              <el-button
                class="my_search"
                @click="
                  () => {
                    getSearch();
                    getCzNum();
                  }
                "
              >
                {{ $t("MN_T_2") }}</el-button
              >
              <el-button class="my_reset" @click="reChongzhi">
                {{ $t("MN_T_3") }}</el-button
              >
            </div>
          </el-col>
        </el-row>
      </el-form>
    </div>
    <div class="main">
      <div class="maintop">
        <div class="mainbtn">
          <el-button size="small" class="thebtn1" @click="handleExport">
            {{ $t("MN_T_8") }}</el-button
          >
        </div>
      </div>
      <div class="maintable">
        <el-table
          :data="tableData"
          v-loading="loading"
          height="680px"
          style="width: 100%"
          :header-cell-style="{ background: '#EEEEEE' }"
          @selection-change="handleSelectionChange"
        >
          <el-table-column prop="colsele" type="selection" width="55">
          </el-table-column>

          <el-table-column
            align="center"
            prop="memberCode"
            :label="$t('MN_T_1')"
            min-width="120px"
          >
          </el-table-column>
          <el-table-column
            align="center"
            prop="memberName"
            :label="$t('CK_KS_14')"
            min-width="120px"
          >
          </el-table-column>

          <el-table-column
            align="center"
            prop="phone"
            :label="$t('w_0052')"
            min-width="120px"
          >
          </el-table-column>
          <el-table-column
            align="center"
            prop="pkRegisterGradeVal"
            :label="$t('PER_DA_5')"
          >
          </el-table-column>
          <el-table-column
            align="center"
            prop="pkAwardsVal"
            :label="$t('CK_KS_16')"
          >
          </el-table-column>
          <el-table-column
            align="center"
            prop="pkRangeAwardsVal"
            label="荣誉奖衔"
          >
          </el-table-column>
          <el-table-column
            align="center"
            prop="vertexName"
            :label="$t('MN_F_T_829')"
          >
          </el-table-column>
          <el-table-column
            align="center"
            min-width="150px"
            prop="endValidityDate"
            :label="$t('奖衔有效期')"
          >
          </el-table-column>
          <!-- <el-table-column
            align="center"
            prop="teamName"
            :label="$t('MN_F_T_122')"
          >
          </el-table-column>

          <el-table-column
            align="center"
            prop="asumRealPv"
            min-width="130px"
            :label="$t('w_0461') + `(PV)`"
          >
            <template slot-scope="scope">
              <span
                @click="goDetail(1, scope.row)"
                style="
                  color: #48b2fd;
                  cursor: pointer;
                  text-decoration: underline;
                "
                >{{ scope.row.asumRealPv | numFilter }}</span
              >
            </template>
          </el-table-column>
          <el-table-column
            align="center"
            prop="bsumRealPv"
            min-width="130px"
            :label="$t('w_0462') + `(PV)`"
          >
            <template slot-scope="scope">
              <span
                @click="goDetail(2, scope.row)"
                style="
                  color: #48b2fd;
                  cursor: pointer;
                  text-decoration: underline;
                "
              >
                {{ scope.row.bsumRealPv | numFilter }}</span
              >
            </template>
          </el-table-column> -->

          <el-table-column align="center" prop="upTypeVal" label="晋升方式">
          </el-table-column>
          <el-table-column
            min-width="150px"
            align="center"
            prop="creationTime"
            :label="$t('w_0467')"
          >
          </el-table-column>
        </el-table>
      </div>
    </div>
    <pagination
      v-show="total > 0"
      :total="total"
      :page.sync="queryParams.pageNum"
      :limit.sync="queryParams.pageSize"
      @pagination="getSearch"
    />
  </div>
</template>

<script>
import topBar from "@/components/topBar";
import * as sta from "@/api/statistics";
import { getAwardsListChiose, getgradeRanglist } from "@/api/level";
import { getvertexValue, getmemberTeamList } from "@/api/financialCase";
import { isLocals, isLocalSymbol } from "@/utils/numberToCurrency";
export default {
  name: "AwardAnalysis",
  components: {
    topBar,
  },
  filters: {
    numFilter(value) {
      // 截取当前数据到小数点后两位
      let realVal = parseFloat(value).toFixed(2);
      return realVal;
    },
  },
  data() {
    return {
      moren: "awardAnalysis",
      topList: [
        {
          name: this.$t("w_0468"),
          path: "awardAnalysis",
        },
      ],
      tableData: [],
      loading: false,
      queryParams: {
        pageNum: 1,
        pageSize: 50,
        thetimes: [],
        placeDept: "",
        pkMember: "",
        Dates: [],
      },
      total: 0,
      multipleSelection: [],
      awardsList: [],
      memberTeamList: [],
      vertexList: [],
      gradeRangList: [],
      upList: [],
    };
  },
  created() {
    this.getSearch();
    this.getOthers();
  },
  methods: {
    //穿透到详情页 左区1右区2
    goDetail(index, row) {
      this.queryParams = {
        pageNum: 1,
        pageSize: 50,
        thetimes: [],
        placeDept: "",
        pkMember: "",
      };
      this.queryParams.placeDept = index;
      this.queryParams.pkMember = row.pkMember;
      sta.getUmbrellaAnalysisDetailList(this.queryParams).then((res) => {
        this.tableData = res.rows;
      });
    },
    isLocalSymbol,
    isLocals,
    changeTime(val) {
      this.queryParams.startDate = val[0];
      this.queryParams.endDate = val[1];
    },
    changeTime1(val) {
      this.queryParams.startEffectiveDate = val[0];
      this.queryParams.endEffectiveDate = val[1];
    },
    getOthers() {
      getAwardsListChiose().then((res) => {
        this.awardsList = res.rows;
      });
      sta.getUpListList().then((res) => {
        this.upList = res.data;
      });
      getmemberTeamList().then((res) => {
        this.memberTeamList = res.rows;
      });
      getvertexValue().then((res) => {
        this.vertexList = res.data;
      });
      getgradeRanglist().then((res) => {
        this.gradeRangList = res.data;
      });
    },
    //导出
    handleExport() {
      this.$confirm(this.$t("MN_F_T_407"), this.$t("MN_F_T_304"), {
        confirmButtonText: this.$t("w_0035"),
        cancelButtonText: this.$t("ENU_P_TYPE0"),
        type: "warning",
      }).then((_) => {
        if (this.queryParams.pkMember) {
          //穿透页导出
          this.download(
            "/report/manager/member-awards/export-analysis-details",
            {
              ...this.queryParams,
            },
            `${this.$t("w_0468")}${new Date().getTime()}.xlsx`
          );
        } else {
          this.download(
            "/report/manager/member-awards/export-analysis",
            {
              ...this.queryParams,
            },
            `${this.$t("w_0468")}${new Date().getTime()}.xlsx`
          );
        }
      });
    },
    handleSelectionChange(val) {
      this.multipleSelection = val;
    },
    reChongzhi() {
      this.queryParams = {
        pageNum: 1,
        pageSize: 50,
        thetimes: [],
        placeDept: "",
        pkMember: "",
      };
      this.getSearch();
    },
    getSearch() {
      this.loading = true;
      sta.getUmbrellaAnalysisList(this.queryParams).then((res) => {
        this.tableData = res.rows;
        this.total = res.total;
        this.loading = false;
      });
    },
    getCzNum() {
      this.queryParams.pageNum = 1;
    },
  },
};
</script>

<style lang="scss" scoped>
::v-deep .el-image-viewer__close {
  right: 500px;
}

::v-deep .dizhi .el-cascader {
  width: 100%;
}

::v-deep .el-range-editor.el-input__inner {
  width: 100%;
}

::v-deep .el-table thead {
  color: #000000;
}

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

.page {
  padding: 10px 20px;
  background: #f9f9f9;
  font-size: 14px;

  .thetopbox {
    padding: 15px 20px 15px 0;
    background: #ffffff;
    border-radius: 8px;

    .searchbox {
      display: flex;
      align-items: center;
      margin-left: 40px;
    }

    .searchtitle {
      margin-right: 10px;
    }

    .searchbtn {
      background: #08143f;
      color: #ffffff;
    }
  }

  .main {
    //margin-top: 20px;
    background: #f9f9f9;
    //border-radius: 8px;
    //box-shadow: 0px 2px 20px 0px rgba(238, 238, 238, 0.5);

    .maintop {
      display: flex;
      // padding: 10px 0;
      justify-content: space-between;
      align-items: center;

      .mainbtn {
        .thebtn1 {
          color: #ffffff;
          background: #ffad41;
          width: 68px;
          height: 32px;
        }

        .thebtn2 {
          color: #ffffff;
          background: #009b58;
          width: 68px;
          height: 32px;
        }

        .thebtn3 {
          color: #ffffff;
          background: #c8161d;
          width: 68px;
          height: 32px;
        }
      }
    }
  }
}
</style>
