<template>
  <div>
    <div class="tableDistance">
      <el-table
        :data="tableData"
        :border="true"
        style="width: 100%"
        v-loading="loading"
      >
        <el-table-column prop="begainTime" label="聘任开始时间">
          <template slot-scope="scope">
            <span>{{ parseTime(scope.row.begainTime, "{y}-{m}-{d}") }}</span>
          </template>
        </el-table-column>
        <el-table-column prop="endTime" label="聘任结束时间">
          <template slot-scope="scope">
            <span>{{ parseTime(scope.row.endTime, "{y}-{m}-{d}") }}</span>
          </template>
        </el-table-column>
        <el-table-column prop="appointmentType" label="聘任序列类型">
          <template slot-scope="scope">
            {{ filterDict(scope.row.appointmentType, "appointmentType") }}
          </template>
        </el-table-column>
        <el-table-column prop="appointmentLevel" label="聘任层级">
          <template slot-scope="scope">
            {{
              filterDict(scope.row.appointmentLevel, "appointmentLevel")
            }}</template
          >
        </el-table-column>
        <el-table-column prop="appointmentInspectorType" label="聘任检查员类型">
          <template slot-scope="scope">
            {{
              filterDict(scope.row.appointmentInspectorType, "inspectorType")
            }}
          </template>
        </el-table-column>
        <el-table-column prop="situation" label="专/兼职情况">
        </el-table-column>
        <el-table-column prop="groupLeader" label="组长资格"> </el-table-column>
      </el-table>
    </div>
    <pagination
      v-show="total > 0"
      :total="total"
      :page.sync="queryParams.current"
      :limit.sync="queryParams.size"
      @pagination="getList"
    />
  </div>
</template>
<script>
import { dictList } from "@/api/jcy/index.js";
import { exportExcel } from "@/api/jcy";
export default {
  data() {
    return {
      dict: {},
      loading: false,
      total: 20,
      queryParams: {
        inspectorId: undefined,
        current: 1,
        size: 10,
      },
      tableData: [],
      allList: {},
    };
  },
  props: {
    //检查员id
    inspectorId: {
      type: Number,
    },
  },
  created() {
    this.queryParams.inspectorId = this.inspectorId;
    this.getDict("inspectorType,appointmentLevel,appointmentType");
  },
  methods: {
    /**导出 */
    exportExcel() {
      let params = {
        value: 2,
        ids: this.inspectorId,
      };
      exportExcel(params).then((res) => {
        if (res.data.code == 200) {
          this.uploadFile(
            res.data.data.result.url,
            res.data.data.result.originalFilename
          );
        }
      });
    },
    /**获取字典列表 */
    getDict(typeList) {
      let query = {
        list: typeList,
      };
      dictList(query).then((res) => {
        if (res.status == 200) {
          for (let key in res.result) {
            this.dict[key] = res.result[key];
          }
          this.getList();
        }
      });
    },
    /**过滤字典 */
    filterDict(value, type) {
      if (this.dict[type] == undefined) {
        return value;
      }

      let dictLable = this.dict[type].filter((item) => item.dictValue == value);
      return dictLable.length > 0 ? dictLable[0].dictLabel : "未知";
    },
    async getList() {
      this.loading = true;
      let msg1 = await this.$api.pinren.list(this.queryParams);
      if (msg1.status == 200) this.loading = false;
      this.total = msg1.result.total;
      this.tableData = msg1.result.records;
    },
  },
};
</script>
<style lang="scss" scoped></style>
