<template>
  <div>
    <div class="menu-title">
      关联用户（{{ userId }}）
      <div class="icon icon-back" @click="backBtn">
        <i title="返回"></i>
      </div>
    </div>
    <div class="block_box" style="margin-top: 0">
      <div class="title">信息</div>
      <div>
        <el-form label-width="100px">
          <el-form-item label="标签">
            <template v-for="(tag,index) in user.labelsArr">
              <el-tag :key="index">{{ tag }}</el-tag>
            </template>
          </el-form-item>
        </el-form>
      </div>
    </div>
    <div class="block_box">
      <div class="title">Association Items</div>
      <div>
        <el-table :data="list" style="width: 100%">
          <el-table-column type="index" label="行号" width="60"></el-table-column>
          <el-table-column prop="vid" label="UserId"></el-table-column>
          <el-table-column label="操作" width="210">
            <template slot-scope="scope">
              <el-button @click.native.prevent="recommendItem(scope.row)" type="text" size="small">
                洞悉
              </el-button>
            </template>
          </el-table-column>
        </el-table>
      </div>
    </div>
  </div>
</template>

<script>
import request from '@/utils/request';

var _this;
export default {
  name: "linkUser",
  data() {
    return {
      qo: "",
      userId: '',
      user: {},
      list: []
    }
  },
  mounted() {
    _this = this;
    _this.qo = _this.$route.query.qo;
    _this.userId = _this.$route.query.userId;
    _this.queryUser();
    _this.getLinkUser();
  },
  methods: {
    queryUser() {
      request({
        url: '/risk-user/query_unique',
        method: 'post',
        data: {
          EQS_fid: _this.userId
        }
      }).then(res => {
        res.data.labelsArr = res.data.labels ? res.data.labels.split(',') : [];
        _this.user = res.data;
      });
    },
    getLinkUser() {
      let space = 'recom_gorse';
      request({
        url: `/nebula_operate/findonepathbyidwithrelation/${space}/${_this.userId}`,
        method: 'post',
        data: {
          relations: ['edge_6253525352']
        }
      }).then(res => {
        _this.list = res.data.nodes;
      });
    },
    recommendItem(item) {
      _this.$router.push({
        path: "recommendItem", query: {
          userId: item.vid,
          qo: JSON.stringify(_this.qo)
        }
      });
    },
    backBtn() {
      this.$router.push({
        path: "userManage", query: {
          qo: _this.qo
        }
      });
    },
  }
}
</script>
<style src="../../../css/back.css" scoped></style>
<style scoped lang="scss">

.block_box {
  margin: 25px;
  background: #FFFFFF;
  border-radius: 3px;

  .title {
    border-bottom: 1px solid #ccc;
    padding: 15px 25px;
  }

  >div {
    padding: 25px;

  }
}
</style>
