<template>
  <div class="">

    <el-form label-width="180px">
      <el-form-item label="认证状态" prop="userType">
        <el-input readonly v-model="userType" placeholder="请输入内容" />
      </el-form-item>
    </el-form>

    <el-form v-if="cA || tAcA" :model="companyInfo" label-width="180px">
      <el-form-item label="公司名称" prop="name">
        <el-input readonly
          v-model="companyInfo.name"
          type="textarea"
          placeholder="请输入内容"
        />
      </el-form-item>
      <el-form-item label="统一信用代码" prop="creditCode">
        <el-input readonly
          v-model="companyInfo.creditCode"
          placeholder="请输入统一信用代码"
        />
      </el-form-item>
      <el-form-item label="通讯地址" prop="address">
        <el-input readonly
          v-model="companyInfo.address"
          type="textarea"
          placeholder="请输入内容"
        />
      </el-form-item>
      <el-form-item label="网址" prop="webSite">
        <el-input readonly v-model="companyInfo.webSite" placeholder="请输入网址" />
      </el-form-item>
      <el-form-item label="营业执照" prop="filePath">
        <!-- <multifile-link
          v-model="companyInfo.businessLicenseUrl"
          :serverAddr="materialServerAddr"
          fileName="营业执照"
          :limit="1"
        /> -->
        <AuthImg :authSrc="companyInfo.businessLicenseUrl" alt=""></AuthImg>
      </el-form-item>
      <el-form-item label="认证公司补充材料" prop="filePath">
        <multifile-link
          v-model="companyInfo.otherCQList"
          :serverAddr="materialServerAddr"
          fileName="认证公司补充材料"
          :limit="10"
        />
      </el-form-item>
      <el-form-item label="公司简介" prop="companyDesc">
        <el-input readonly
          v-model="companyInfo.companyDesc"
          type="textarea"
          placeholder="请输入内容"
        />
      </el-form-item>
      <el-form-item label="联系人姓名" prop="contactName">
        <el-input readonly
          v-model="companyInfo.contactName"
          placeholder="请输入联系人姓名"
        />
      </el-form-item>
      <el-form-item label="联系人职位" prop="contactPosition">
        <el-input readonly
          v-model="companyInfo.contactPosition"
          placeholder="请输入联系人职位"
        />
      </el-form-item>
    </el-form>
    <el-form v-if="tA || tAcA" :model="testerInfo" label-width="180px" readonly>
      <el-form-item label="真实姓名" prop="name" v-if="tA">
        <el-input readonly v-model="testerInfo.name" placeholder="请输入真实姓名" />
      </el-form-item>
      <el-form-item label="所在城市" prop="city" v-if="tA">
        <el-input readonly v-model="testerInfo.city" placeholder="请输入所在城市" />
      </el-form-item>
      <el-form-item label="身份证号码" prop="idNumber" v-if="tA">
        <el-input readonly
          v-model="testerInfo.idNumber"
          placeholder="请输入身份证号码"
        />
      </el-form-item>
      <el-form-item label="身份证正面" prop="filePath" v-if="tA">
        <!-- <multifile-link
          v-model="testerInfo.idCardFrontUrl"
          :serverAddr="materialServerAddr"
          fileName="身份证正面"
          :limit="1"
        /> -->
        <AuthImg :authSrc="testerInfo.idCardFrontUrl" alt=""></AuthImg>
      </el-form-item>
      <el-form-item label="身份证反面" prop="filePath" v-if="tA">
        <!-- <multifile-link
          v-model="testerInfo.idCardBackUrl"
          :serverAddr="materialServerAddr"
          fileName="身份证反面"
          :limit="1"
        /> -->
        <AuthImg :authSrc="testerInfo.idCardBackUrl" alt=""></AuthImg>
      </el-form-item>
      <el-form-item label="测试能力" prop="testSkills" v-if="tA">
        <el-input readonly
          v-model="testerInfo.testSkills"
          type="textarea"
          placeholder="请输入内容"
        />
        <el-popover
          placement="top-start"
          title="示例："
          width="400"
          trigger="hover"
        >
          <span>性能测试LoadRunner, Jmeter，自动化测试Selenium</span>
          <el-link slot="reference" style="color: #46a6ff;">查看示例</el-link>
        </el-popover>
      </el-form-item>
      <el-form-item label="奖项和证书" prop="certificate" v-if="tA">
        <el-input readonly
          v-model="testerInfo.certificate"
          type="textarea"
          placeholder="请输入内容"
        />
        <el-popover
          placement="top-start"
          title="示例："
          width="570"
          trigger="hover">
            <span>STQB认证软件测试工程师<br>国家软考认证软件评测师<br>或国家等级考试软件测试工程师证书 <br>
             2019年全国大学生软件测试大赛二等奖
            </span>
          <el-link slot="reference" style="color: #46a6ff;">查看示例</el-link>
        </el-popover>
      </el-form-item>
      <el-form-item label="工作经历" prop="workExperience" v-if="tA">
        <el-input readonly
          v-model="testerInfo.workExperience"
          type="textarea"
          placeholder="请输入内容"
        />
        <el-popover
          placement="top-start"
          title="示例："
          width="570"
          trigger="hover">
            <span>2017.5-2021.7 西安未央软件有限公司 软件测试工程师<br>
             2013.9-2017.4. 西安大唐软件有限公司 软件测试工程师<br>
             2009.9-2013.7 西安电子科技大学 软件工程专业 本科
            </span>
          <el-link slot="reference" style="color: #46a6ff;">查看示例</el-link>
        </el-popover>
      </el-form-item>

      <el-form-item label="测试项目案例" prop="testProjects" v-if="tA || tAcA">
        <el-input readonly
          v-model="testerInfo.testProjects"
          type="textarea"
          placeholder="请输入内容"
        />
        <el-popover
          placement="top-start"
          title="示例："
          width="570"
          trigger="hover">
            <span>2021年 航空仿真软件单元测试<br>
2020年 企业供应链管理平台安全测试<br>
2020年 B2C的电商平台系统前后台会员管理、订单、支付及后台订单处理相关模块测试
</span>
          <el-link slot="reference" style="color: #46a6ff;">查看示例</el-link>
        </el-popover>
      </el-form-item>
      <el-form-item label="其它补充材料" prop="filePath" v-if="tA || tAcA">
        <multifile-link
          v-model="testerInfo.otherTQList"
          :serverAddr="materialServerAddr"
          fileName="其它补充材料"
          :limit="10"
        />
      </el-form-item>
      <el-form-item label="补充说明" prop="otherInfo" v-if="tAcA">
        <el-input readonly
          v-model="testerInfo.otherInfo"
          type="textarea"
          placeholder="请输入内容"
        />
      </el-form-item>
    </el-form>
  </div>
</template>

<script>
import MultifileLink from "@/views/components/MultifileLink";
import AuthImg from "@/views/components/AuthImg";

export default {
  props: {
    user: {
      type: Object,
    },
    cResponse: {
      type: Object,
    },
  },
  components: {
    MultifileLink,
    AuthImg,
  },
  data() {
    return {
      // 表单校验
      rules: {},
      // 表单参数
      testerInfo: {},
      companyInfo: {},
      materialServerAddr: "",
      allFileGetFlag: false,
      cA: false,
      tA: false,
      tAcA: false,
      userType: "",
    };
  },
  created() {
    this.getList();
    this.getClientConfigKey("material.server").then((response) => {
      this.materialServerAddr = response.msg;
    });
  },
  methods: {
    /** 查询所有认证信息 */
    getList() {
      // getCertifications(this.user.userId).then((response) => {
        const response = this.cResponse;
        // console.log(response.companyInfo);
        // console.log(response.testerInfo);

        this.userType = "普通用户";
        if (response.testerInfo) {
          if (response.companyInfo) {
            this.userType = "认证测试公司";
            this.tAcA = true;
          } else {
            this.userType = "个人测试者";
            this.tA = true;
          }
        } else {
          if (response.companyInfo) {
            this.userType = "认证公司";
            this.cA = true;
          } else {
            this.userType = "普通用户";
          }
        }

        if (response.testerInfo) {
          this.testerInfo = response.testerInfo;
        } else {
          // this.testerInfo = {
          //   applyId: null,
          //   name: null,
          //   city: null,
          //   idNumber: null,
          //   testSkills: null,
          //   testProjects: null,
          //   workExperience: null,
          //   certificate: null,
          //   createTime: null,
          //   updateTime: null,
          //   idCardFrontUrl: [],
          //   idCardBackUrl: [],
          //   otherTQList: [],
          //   otherInfo: null,
          // };
        }
        if (response.companyInfo) {
          this.companyInfo = response.companyInfo;
        } else {
          // this.companyInfo = {
          //   applyId: null,
          //   name: null,
          //   creditCode: null,
          //   address: null,
          //   webSite: null,
          //   companyDesc: null,
          //   contactName: null,
          //   contactPosition: null,
          //   createTime: null,
          //   updateTime: null,
          //   businessLicenseUrl: [],
          //   otherCQList: [],
          // };
        }
      // });
    },
  },
};
</script>

<style lang="scss" scoped>
</style>
