<template>
  <el-dialog
    title="任务名单"
    width="800px"
    :visible.sync="visible"
    :destroy-on-close="false"
    :close-on-click-modal="false"
    custom-class="roster-modal"
  >
    <div class="roster-content">
      <!-- 主体表格 -->
      <el-table
        :data="tableData"
        element-loading-text="加载中..."
        border
        fit
        highlight-current-row
      >
        <el-table-column align="center" width="80" label="序号">
          <template slot-scope="scope">
            {{
              (scope.$index + 1)
            }}
          </template>
        </el-table-column>
        <el-table-column label="姓名" align="center">
          <template slot-scope="scope">
            {{ scope.row.certName | matchNull }}
          </template>
        </el-table-column>
        <el-table-column label="身份证号" align="center">
          <template slot-scope="scope">
            {{ scope.row.certNo | matchNull }}
          </template>
        </el-table-column>
        <el-table-column label="手机号" align="center">
          <template slot-scope="scope">
            {{ scope.row.phone | matchNull }}
          </template>
        </el-table-column>
        <!--分页栏-->
      </el-table>
    </div>
    <div slot="footer" class="dialog-footer">
      <el-button type="primary" style="width: 160px" @click="onClose"> 关闭 </el-button>
    </div>
  </el-dialog>
</template>

<script>

export default {
  filters: {
    matchNull(str) {
      if (!str) {
        return '-'
      } else {
        return str
      }
    }
  },
  props: {
    roster: {
      type: Array,
      default: () => []
    }
  },
  data() {
    return {
      tableData: [],
      visible: false
    }
  },
  watch: {
    roster: {
      deep: true,
      handler(newVal, oldVal) {
        console.log(newVal)
        this.tableData = newVal
      }
    }
  },
  methods: {
    open(obj) {
      this.visible = true
      this.$nextTick(() => {
        console.log(this.roster)
      })
    },
    onClose() {
      this.visible = false
      this.$emit('success')
    }
  }
}
</script>
<style lang="scss">
.roster-modal {
  .dialog-footer {
    width: 100%;
    display: flex;
    justify-content: center;
    align-items: center;
  }
}
</style>

<style scoped lang="scss">
.roster-content {
  height: 600px;
  padding: 10px;
  overflow: scroll;
}
.access_record_item {
  padding: 10px;
  width: calc(100% );
  border: 1px solid #FFE3E3;
  background: #FFF1F1;
  //height: 80px;
  border-radius: 6px;
  display: flex;
  flex-direction: row;
  justify-content: space-between;
  align-items: center;

  .item_filed {
    flex: 1;
    font-size: 14px;
    height: 160px;
    display: flex;
    flex-direction: column;
    justify-content: space-around;
    &_card {
      width: 100%;
      background: rgba(255, 92, 92, 1);
      color: #fff;
      display: flex;
      flex-direction: column;
      padding: 10px;
      border-radius: 12px;
      &_item {
        line-height: 24px;
        height: 24px;
      }
    }
    .filed_value {
      min-height: 20px;
      line-height: 20px;
      font-weight: 400;
      color: rgba(177, 90, 90, 1);
      margin-left: 10px;
      span {
        color: rgba(51, 51, 51, 1);
      }
    }
  }

  .item_img {
    width: 160px;
    margin-left: 10px;
  }

  &:not(&:first-child) {
    margin-top: 10px;
  }
}
</style>
