<template>
  <div class="inspectorList">
    <div class="header-info">
      <van-image
        width="63"
        height="63"
        :src="require('../../assets/img_touxiang.png')"
      />
      <div class="text">
        <div class="name">{{ userInfo.nickname }}</div>
        <div class="sub">市政专家</div>
      </div>
      <div class="btn" @click="goLogin">切换账号</div>
    </div>

    <div class="list">
      <div class="empty" v-if="empty">
        <img src="../../assets/img_cailiao_kong.svg" alt="" />
        <div class="text">暂无评分列表</div>
      </div>

      <div
        class="item"
        v-for="item in tableData"
        :key="item.id"
        @click="handleEdit(item)"
      >
        <div class="left">
          <div class="name">{{ item.name }}</div>
          <div class="status">
            <img src="../../assets/icon_status.svg" alt="" />
            <van-tag
              type="success"
              v-if="item.status === 'REVIEW_PENDING'"
              size="large"
            >
              未审查
            </van-tag>
            <van-tag color="#C8C9CC" v-else size="large">已审查</van-tag>
          </div>

          <div class="location" v-if="item.address">
            <img src="../../assets/icon_dizhi.svg" alt="" />
            <span>{{ item.address }}</span>
          </div>
        </div>
        <van-icon name="arrow" :size="16" color="#000000" />
      </div>
    </div>
  </div>
</template>

<script>
import { mapState } from "vuex";
export default {
  name: "expertList",
  metaInfo() {
    return {
      title: "评分列表"
    };
  },
  data() {
    return {
      tableData: [],
      status: {
        NORMAL: "正常"
      },
      empty: false
    };
  },
  computed: {
    ...mapState(["userInfo"])
  },
  methods: {
    handleEdit(row) {
      this.$router.push({
        name: "expertDetail",
        query: {
          id: row.id
        }
      });
    },
    statusFormatter(row, column, cellValue) {
      return this.status[cellValue] || "";
    },
    goLogin() {
      localStorage.removeItem("token");
      this.$router.push("/login");
    }
  },
  mounted() {
    this.$http
      .post(
        "/rate/all2",
        {
          size: 20,
          query: {
            expertUserId: this.$store.state.userInfo.id,
            status: [
              "SUBMIT_GRADE",
              "REVIEW_PENDING",
              "SUBMIT_PAPER_MATERIALS",
              "COLLECT_PAPER_MATERIALS",
              "COMPLETE"
            ]
          }
        },
        { body: "json" }
      )
      .then(res => {
        this.empty = res.empty;
        this.tableData = res.content;
      });
  }
};
</script>
<style lang="less" scoped>
.inspectorList {
  .title {
    font-size: 36px;
    text-align: center;
    font-weight: 700;
    margin: 20px;
  }
  .table {
    margin-top: 50px;
  }

  background: linear-gradient(180deg, #ffffff 0%, #f5f7fa 235px);
}
// /deep/.el-table--scrollable-x .el-table__body-wrapper {
//   overflow-x: hidden;
// }
// /deep/.el-table__body {
//   width: 100%;
// }
.empty {
  display: flex;
  flex-direction: column;
  align-items: center;
  padding: 54px;

  img {
    width: 140px;
    display: block;
  }
  .text {
    font-size: 14px;
    color: #c4c7cc;
    line-height: 22px;
    margin-top: 13px;
  }
}
.header-info {
  display: flex;
  padding: 16px;
  align-items: center;
  .text {
    flex-grow: 1;
    margin-left: 12px;
    .name {
      font-size: 22px;
      font-weight: bold;
      color: #000000;
      line-height: 30px;
    }

    .sub {
      font-size: 14px;
      color: #939599;
      line-height: 20px;
      margin-top: 2px;
    }
  }

  .btn {
    font-size: 14px;
    color: #c4c7cc;
    line-height: 20px;
    align-self: flex-end;
  }
}

.list {
  padding: 20px 16px;
  .item {
    padding: 20px;
    background: #ffffff;
    border-radius: 12px;
    display: flex;
    align-items: center;

    .left {
      flex-grow: 1;
    }

    .name {
      font-size: 18px;
      font-weight: bold;
      color: #313233;
      line-height: 28px;
    }

    .status {
      display: flex;
      align-items: center;
      margin-top: 10px;
      img {
        margin-right: 6px;
      }
    }

    .location {
      display: flex;
      align-items: center;
      margin-top: 8px;
      img {
        margin-right: 6px;
      }
      span {
        font-size: 14px;
        color: #939599;
        line-height: 22px;
      }
    }

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