<template>
  <div>
    <div class="tableDistance">
      <el-table
        :data="tableData"
        :border="true"
        style="width: 100%"
        v-loading="loading"
      >
        <el-table-column
          prop="assignUnit"
          label="调派单位"
          :show-overflow-tooltip="true"
        >
          <template slot-scope="scope">
            {{ filterDict(scope.row.assignUnit, "assignUnit") }}
          </template>
        </el-table-column>
        <el-table-column prop="assignMechanism" label="调派机制">
          <template slot-scope="scope">
            {{ filterDict(scope.row.assignMechanism, "assignMechanism") }}
          </template>
        </el-table-column>
        <el-table-column prop="taskType" label="任务类型"> </el-table-column>
        <el-table-column prop="begainTime" label="检查时间起">
        </el-table-column>
        <el-table-column prop="endTime" label="检查时间止"> </el-table-column>
        <el-table-column prop="assignStatus" label="是否接受调派">
        </el-table-column>
        <el-table-column
          prop="reaseons"
          label="原因说明"
          :show-overflow-tooltip="true"
        >
        </el-table-column>
      </el-table>
      <pagination
        v-show="total > 0"
        :total="total"
        :page.sync="queryParams.current"
        :limit.sync="queryParams.size"
        @pagination="getList"
      />
    </div>
  </div>
</template>
<script>
import { getList } from "@/api/deployRecord";
import { dictList } from "@/api/jcy";
export default {
  props: {
    //检查员id
    inspectorId: {
      type: Number,
    },
  },
  data() {
    return {
      dict: {},
      loading: false,
      tableData: [],
      // 总条数
      total: 0,
      queryParams: {
        inspectorId: undefined,
        current: 1,
        size: 10,
      },
    };
  },
  created() {
    this.queryParams.inspectorId = this.inspectorId;
    this.getDict("assignMechanism,taskType,assignStatus");
  },
  methods: {
    /**获取字典列表 */
    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 (value) {
        if (this.dict[type] == undefined) {
          return value;
        }
        let dictLable = this.dict[type].filter(
          (item) => item.dictValue == value
        );
        return dictLable.length > 0 ? dictLable[0].dictLabel : "未知";
      }
    },
    getList() {
      this.loading = true;
      getList(this.queryParams).then((res) => {
        this.tableData = res.result.records;
        this.total = res.result.total;
        this.loading = false;
      });
    },
  },
};
</script>
<style lang="scss" scoped></style>
