<template>
  <el-dialog title="竞标者详情" :visible.sync="open" :close-on-click-modal="false" width="800px" append-to-body>
  <el-form label-width="130px" class="demo-ruleForm" v-loading="loading">
    <el-row>
      <el-col :span="24" v-if="tester.name">
        <el-form-item label="测试者姓名"> {{tester.name}} </el-form-item>
      </el-col>
      <el-col :span="24" v-if="user.nickName">
        <el-form-item label="昵称"> {{user.nickName}} </el-form-item>
      </el-col>
    </el-row>
    <el-row>
      <el-col :span="12" v-if="user.userName">
        <el-form-item label="用户名"> {{user.userName}} </el-form-item>
      </el-col>
      <el-col :span="12">
        <el-form-item label="性别"> {{user.sex == 0 ? "男" : "女"}} </el-form-item>
      </el-col>
      <el-col :span="12" v-if="tester.city">
        <el-form-item label="现居住地"> {{tester.city}} </el-form-item>
      </el-col>
    
     
    </el-row>
    <el-row>
      <el-col :span="12">
        <el-form-item label="手机"> {{user.phonenumber}} </el-form-item>
      </el-col>
      <el-col :span="12">
        <el-form-item label="邮箱"> {{user.email}} </el-form-item>
      </el-col>
    </el-row>
    <!-- <el-row v-if="user.companyStatus==0">
      <el-col :span="24" v-if="tester&&tester.testProjects">
        <el-form-item label="测试项目经验"> {{tester.testProjects}} </el-form-item>
      </el-col>
    </el-row> -->
    <el-row  v-if="user.companyStatus==0">
      <el-col :span="24" v-if="tester.certificate">
        <el-form-item label="证书和奖励"> {{tester.certificate}} </el-form-item>
      </el-col>
    </el-row>
    <el-row  v-if="user.companyStatus==0">
      <el-col :span="24" v-if="tester.workExperience" >
        <el-form-item label="工作简历">
          {{tester.workExperience}}
        </el-form-item>
      </el-col>
    </el-row>
    <el-row v-if="user.companyStatus==2">
      <el-col :span="24">
        <el-form-item label="公司名称"> {{company.name}} </el-form-item>
      </el-col>
    </el-row>
    <el-row v-if="user.companyStatus==2">
      <el-col :span="24">
        <el-form-item label="公司地址">  {{company.address}} </el-form-item>
      </el-col>
    </el-row>
    <el-row v-if="user.companyStatus==2">
      <el-col :span="12">
        <el-form-item label="联系人"> {{company.contactName}} </el-form-item>
      </el-col>
      <el-col :span="12">
        <el-form-item label="联系人电话"> {{company.contactTel}} </el-form-item>
      </el-col>
    </el-row>
    <el-row v-if="user.companyStatus==2">
      <el-col :span="24">
        <el-form-item label="公司简介"> {{company.companyDesc}} </el-form-item>
      </el-col>
    </el-row>
    <el-row v-if="user.companyStatus==2">
      <el-col :span="24"  v-if="tester&&tester.testProjects">
        <el-form-item label="测试项目经验"> {{tester.testProjects}} </el-form-item>
      </el-col>
    </el-row>
    <el-form-item label="备注信息"  v-if="tester.remark"> {{tester.remark}} </el-form-item>
    <!-- <el-form-item label="相关资料">
      <div v-for="(item,key) in fileList " :key='key'> {{item.fileName}} <el-link @click="downloadFile(item.fileId)"  type="primary">下载</el-link></div>
    </el-form-item> -->
    <el-form-item style="text-align:center" label-width="0px">
      <!-- <el-button type="primary" @click="assign" :disabled="status!=0" style="margin-right:10px">选中</el-button> -->
      <el-button type="primary" @click="cancel(false)" >取消</el-button>
    </el-form-item>
  </el-form>
  </el-dialog>
</template>

<script>

  import {getUserDetail} from "@/api/system/user.js";
  import {assignTester} from "@/api/crowdsource/crowdsource";

  export default {
    name: "TesterDetail",
    props:  {
      status: Number,
      taskId: Number
    },
    data() {
      return {
        open:false,
        user: {},
        tester: {},
        company: {},
        fileList:[],
        loading:true,
        userId:0,
      }
    },
    methods: {
      viewDetail(userId){
        this.userId = userId;
        this.open = true;
        this.loading = true;
        getUserDetail(userId).then(response => {
          this.user = response.user;
          if (response.company != null)
            this.company = response.company;
          if (response.tester != null)
            this.tester = response.tester;
          if (response.fileList != null) {
            this.fileList = response.fileList;
          }
         this.loading = false;
        })
      },
      assign(){
        this.$confirm("确认要将众包任务指定给该测试者吗?").then(() => {
          let param = {};
          param.testerId = this.userId;
          param.taskId = this.taskId;
          assignTester(param).then(response => {
            this.cancel(true);
          })
        })
      },
      cancel(isFresh){
        this.open = false;
        this.$emit("closeDialog", isFresh)
      },
      downloadFile(fileUrl) {
        const loading = this.$loading({
          lock: true,
          text: '正在下载，请稍后...',
          spinner: 'el-icon-loading',
          background: 'rgba(0, 0, 0, 0.7)'
        });
          downloadFast(fileUrl, loading);
      }
    },
    created() {

    }
  }
</script>

<style scoped>

</style>
