<template>
  <div class="examku">
    <main id="main">
      <!--==========================
        Profile Section
      ============================-->
      <section id="profile">
        <div class="container mt30" style="margin-top: 0px">
          <!--    <el-row :gutter="20">-->
          <!-- <el-alert type="info" effect="dark" v-if="showAlert" :closable="false">
            您【{{appleTypeStr}}】的申请已提交，平台审核后会站内消息通知您。
          </el-alert> -->
          <div v-if="showAlert">
            <el-tag color='#F7F7F7' >您【{{appleTypeStr}}】的申请已提交，平台审核后会站内消息通知您。</el-tag>
            <el-tag color='#F2A51A' style="color:#FFFFFF;margin-left:17px;border:none;">{{appleTypeStr}}信息</el-tag>  
          </div>
          <br/>
          <div id="con_a_3" class="profile-info">
            <div v-if="bArray[0][0] != null" style="border: 1px solid #DCDCDC;border-radius:5px;padding:0 20px;margin:20px 0;width:80%">
              <h4 style="font-weight: bold;color:#0066EB;margin-bottom:0px">认证公司用户</h4>
              <div class="testuser">    
                  <div style="color:#808080;font-size:14px;line-height:15px;">
                      <p>普通用户可提交公司信息和认证所需材料，经通过平台审核后升级为认证公司用户。</p>
                      <p>认证公司用户可在测试众包市场中发布测试任务。</p>
                  </div>              
                  <el-button  @click="regCompanyChild" size="small" :disabled="!bArray[0][0]">
                    {{ bArray[1][0] }}
                  </el-button>
              </div>
            </div>
            <div></div>
            <div v-if="bArray[0][1] != null" style="border: 1px solid #DCDCDC;border-radius:5px;padding:0 20px;margin:20px 0;width:80%">
              <h4 style="font-weight: bold;color:#0066EB;margin-bottom:0px">测试认证</h4>
              <div class="testuser">                  
                  <div style="color:#808080;font-size:14px;line-height:15px;">   
                      <p >普通用户可提交个人身份信息和资历升级为个人测试者。</p>
                      <p>个人测试者可在测试任务众包市场竞标和承接测试项目，完成任务可获取赏金。</p>
                  </div>
                  <el-button size="small" :disabled="!bArray[0][1]"  @click="x2ctChild" >
                    {{ bArray[1][1] }}
                  </el-button>
              </div>
            </div>
            <!-- <div v-if="bArray[0][1] != null" style="border: 1px solid #DCDCDC;border-radius:5px;padding:0 20px;margin:20px 0;width:80%">
              <h4 style="font-weight: bold;color:#0066EB;margin-bottom:0px">认证测试公司</h4>
              <div class="testuser">                  
                  <div style="color:#808080;font-size:14px;line-height:15px;">   
                      <p >普通用户可提交公司信息和公司测试者认证所需材料，并通过平台审核后，升级为公司测试者。</p>
                      <p>认证公司用户也可以补充提交公司测试者认证所需材料，并通过平台审核后，升级为认证测试公司。 </p>
                      <p>认证测试公司可在测试任务众包市场中应征和承接测试项目，完成任务可获取赏金。</p>
                  </div>
                  <el-button size="small" :disabled="!bArray[0][1]"  @click="x2ctChild" >
                    {{ bArray[1][1] }}
                  </el-button>
              </div>
              
            </div>
            <div v-if="bArray[0][2] != null" style="border: 1px solid #DCDCDC;border-radius:5px;padding:0 20px;margin:20px 0;width:80%">
              <h4 style="font-weight: bold;color:#0066EB;margin-bottom:0px">个人测试者</h4>
              <div class="testuser"> 
                  <div style="color:#808080;font-size:14px;line-height:15px;">
                      <p >普通用户可提交个人身份信息和资历升级为个人测试者。</p>
                      <p>个人测试者可在测试任务众包市场中应征和承接测试项目，完成任务可获取赏金。</p>
                  </div>             
                  <el-button size="small"  :disabled="!bArray[0][2]"  @click="p2ptChild" >
                    {{ bArray[1][2] }}
                  </el-button>
              </div>
            </div> -->
          </div>
        </div>
      </section>
    </main>
    <!-- 添加或修改公司申请审核对话框 -->
    <el-dialog v-if="regCompanyOpen"  :title="title" :visible.sync="regCompanyOpen" width="800px" append-to-body :close-on-click-modal="false" >
      <el-form ref="form" :model="form" :rules="regCompanyRules" label-width="150px" >
        <el-form-item label="公司名称" prop="name">
          <el-input v-model="form.name" type="textarea" placeholder="请输入内容" />
        </el-form-item>
        <el-form-item label="统一信用代码" prop="creditCode">
          <el-input v-model="form.creditCode" placeholder="请输入统一信用代码" />
        </el-form-item>
        <el-form-item label="通讯地址" prop="address">
          <el-input v-model="form.address" type="textarea" placeholder="请输入内容" />
        </el-form-item>
        <el-form-item label="网址" prop="webSite">
          <el-input placeholder="请输入网址" v-model="form.webSite">
            <template slot="prepend">Http://</template>
          </el-input>
        </el-form-item>
        <el-form-item label="营业执照" prop="businessLicenseUrl">
          <multi-upload  v-if="allFileGetFlag" v-model="form.businessLicenseUrl"  :serverAddr="materialServerAddr" fileName="营业执照" :limit="1" />
        </el-form-item>
        <el-form-item label="认证公司补充材料" prop="filePath">
          <nonimage-upload v-if="allFileGetFlag" v-model="form.otherCQList" :serverAddr="materialServerAddr" fileName="认证公司补充材料" :limit="5" @setImgPath='setImgPath'/>
        </el-form-item>
        <el-form-item label="公司简介" prop="companyDesc">
          <el-input v-model="form.companyDesc" type="textarea" placeholder="请输入内容" />
        </el-form-item>
        <el-form-item label="联系人姓名" prop="contactName">
          <el-input v-model="form.contactName" placeholder="请输入联系人姓名"/>
        </el-form-item>
        <el-form-item label="联系人职位" prop="contactPosition">
          <el-input v-model="form.contactPosition" placeholder="请输入联系人职位" />
        </el-form-item>
      </el-form>
      <div slot="footer" class="dialog-footer">
        <div class="submitbtn"> 
          <el-button  @click="regCompanySubmitForm" >确 定 </el-button >
        </div>
        <el-button @click="regCompanyCancel">取 消</el-button>
      </div>
    </el-dialog>
    <!-- 添加或修改认证测试公司p2ct申请审核对话框 -->
    <el-dialog v-if="p2ctOpen" :title="title" :visible.sync="p2ctOpen" width="800px" append-to-body :close-on-click-modal="false" >
      <el-form ref="companyForm" :model="companyApply" :rules="p2ctRules" label-width="150px">
        <el-form-item label="公司名称" prop="name">
          <el-input v-model="companyApply.name" type="textarea" placeholder="请输入内容" />
        </el-form-item>
        <el-form-item label="统一信用代码" prop="creditCode">
          <el-input v-model="companyApply.creditCode" placeholder="请输入统一信用代码" />
        </el-form-item>
        <el-form-item label="通讯地址" prop="address">
          <el-input v-model="companyApply.address" type="textarea" placeholder="请输入内容" />
        </el-form-item>
        <el-form-item label="网址" prop="webSite">
          <el-input placeholder="请输入网址" v-model="companyApply.webSite">
            <template slot="prepend">Http://</template>
          </el-input>
        </el-form-item>
        <el-form-item label="营业执照" prop="businessLicenseUrl">
          <multi-upload v-if="allFileGetFlag" v-model="companyApply.businessLicenseUrl" :serverAddr="materialServerAddr" fileName="营业执照" :limit="1" />
        </el-form-item>
        <el-form-item label="认证公司补充材料" prop="otherCQList">
          <nonimage-upload v-if="allFileGetFlag" v-model="companyApply.otherCQList" :serverAddr="materialServerAddr" :p2ctapply='1' fileName="认证公司补充材料" :limit="5" @setImgPath='setImgPath'/>
        </el-form-item>
        <el-form-item label="公司简介" prop="companyDesc">
          <el-input v-model="companyApply.companyDesc" type="textarea" placeholder="请输入内容" />
        </el-form-item>
        <el-form-item label="联系人姓名" prop="contactName">
          <el-input v-model="companyApply.contactName" placeholder="请输入联系人姓名" />
        </el-form-item>
        <el-form-item label="联系人职位" prop="contactPosition">
          <el-input v-model="companyApply.contactPosition" placeholder="请输入联系人职位" />
        </el-form-item>
      </el-form>
      <el-form ref="testerForm" :model="testerApply" label-width="150px">
        <el-form-item label="测试项目案例" prop="testProjects">
          <el-input v-model="testerApply.testProjects" type="textarea" placeholder="请输入内容" />
          <el-popover placement="top-start" title="示例：" width="530" trigger="hover">
            <span>2021年 航空仿真软件单元测试<br>
                  2020年 企业供应链管理平台安全测试<br>
                  2020年 B2C的电商平台系统前后台会员管理、订单、支付及后台订单处理相关模块测试
            </span>
            <el-link slot="reference" style="color: #46a6ff;" :underline="false">查看示例</el-link>
          </el-popover>
        </el-form-item>
        <el-form-item label="其它补充材料" prop="otherTQList">
          <nonimage-upload v-if="allFileGetFlag" v-model="testerApply.otherTQList" :serverAddr="materialServerAddr" :p2ctapply='2' fileName="其它补充材料" :limit="5" @setnoniPath='setnoniPath'/>
        </el-form-item>
        <el-form-item label="补充说明" prop="otherInfo">
          <el-input v-model="testerApply.otherInfo" type="textarea" placeholder="请输入内容" />
        </el-form-item>
      </el-form>
      <div slot="footer" class="dialog-footer">
        <div class="submitbtn"> 
          <el-button type="primary" @click="p2ctSubmitForm">确 定</el-button>
        </div>
        <el-button @click="p2ctCancel">取 消</el-button>
      </div>
    </el-dialog>
    <!-- 添加或修改c2ct申请审核对话框 -->
    <el-dialog v-if="c2ctOpen" :title="title" :visible.sync="c2ctOpen" width="800px" append-to-body :close-on-click-modal="false" >
      <el-form ref="form" :model="form" :rules="c2ctRules" label-width="150px">
        <el-form-item label="测试项目案例" prop="testProjects">
          <el-input v-model="form.testProjects" type="textarea" placeholder="请输入内容" />
          <el-popover placement="top-start" title="示例：" width="530" trigger="hover">
            <span>2021年 航空仿真软件单元测试<br>
                  2020年 企业供应链管理平台安全测试<br>
                  2020年 B2C的电商平台系统前后台会员管理、订单、支付及后台订单处理相关模块测试
            </span>
            <el-link slot="reference" style="color: #46a6ff;" :underline="false">查看示例</el-link>
          </el-popover>
        </el-form-item>
        <el-form-item label="其它补充材料" prop="filePath">
          <nonimage-upload v-if="allFileGetFlag" v-model="form.otherTQList" :serverAddr="materialServerAddr" fileName="其它补充材料" :limit="5" @setImgPath='setImgPath'/>
        </el-form-item>
        <el-form-item label="补充说明" prop="otherInfo">
          <el-input v-model="form.otherInfo" type="textarea" placeholder="请输入内容" />
        </el-form-item>
      </el-form>
      <div slot="footer" class="dialog-footer">
        <div class="submitbtn"> 
          <el-button type="primary" @click="c2ctSubmitForm">确 定</el-button>
        </div>
        <el-button @click="c2ctCancel">取 消</el-button>
      </div>
    </el-dialog>
    <!-- 添加或修改个人测试者p2pt申请审核对话框 -->
    <el-dialog v-if="p2ptOpen" :title="title" :visible.sync="p2ptOpen" width="800px" append-to-body :close-on-click-modal="false" >
      <el-form ref="form" :model="form" :rules="p2ptRules" label-width="150px">
        <el-form-item label="真实姓名" prop="name">
          <el-input v-model="form.name" placeholder="请输入真实姓名"/>
        </el-form-item>
        <el-form-item label="所在城市" prop="city">
          <el-input v-model="form.city" placeholder="请输入所在城市"/>
        </el-form-item>
        <el-form-item label="身份证号码" prop="idNumber">
          <el-input v-model="form.idNumber" placeholder="请输入身份证号码"/>
        </el-form-item>
        <el-form-item label="身份证正面" prop="idCardFrontUrl">
          <multi-upload v-if="allFileGetFlag" v-model="form.idCardFrontUrl" :serverAddr="materialServerAddr" fileName="身份证正面" :limit="1" />
        </el-form-item>
        <el-form-item label="身份证反面" prop="idCardBackUrl">
          <multi-upload v-if="allFileGetFlag" v-model="form.idCardBackUrl" :serverAddr="materialServerAddr" fileName="身份证反面" :limit="1" />
        </el-form-item>
        <el-form-item label="测试能力" prop="testSkills">
          <el-input  v-model="form.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;" :underline="false">查看示例</el-link>
          </el-popover>
        </el-form-item>
        <el-form-item label="测试项目案例" prop="testProjects">
          <el-input v-model="form.testProjects" type="textarea" placeholder="请输入内容" />
          <el-popover placement="top-start" title="示例：" width="530" trigger="hover">
            <span>2021年 航空仿真软件单元测试<br>2020年 企业供应链管理平台安全测试<br>2020年 B2C的电商平台系统前后台会员管理、订单、支付及后台订单处理相关模块测试</span>
            <el-link slot="reference" style="color: #46a6ff;" :underline="false">查看示例</el-link>
          </el-popover>
        </el-form-item>
        <el-form-item label="奖项和证书" prop="certificate">
          <el-input  v-model="form.certificate" type="textarea" placeholder="请输入内容" />
          <el-popover placement="top-start" title="示例：" width="500" trigger="hover">
            <span>STQB认证软件测试工程师<br>国家软考认证软件评测师<br>或国家等级考试软件测试工程师证书 <br>
              2019年全国大学生软件测试大赛二等奖
            </span>
            <el-link slot="reference" style="color: #46a6ff;" :underline="false">查看示例</el-link>
          </el-popover>
        </el-form-item>
        <el-form-item label="工作经历" prop="workExperience">
          <el-input v-model="form.workExperience" type="textarea" placeholder="请输入内容" />
          <el-popover placement="top-start" title="示例：" width="500" 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;" :underline="false">查看示例</el-link>
          </el-popover>
        </el-form-item>
        <el-form-item label="其它补充材料" prop="filePath">
          <nonimage-upload v-if="allFileGetFlag"  v-model="form.otherTQList" :serverAddr="materialServerAddr" fileName="其它补充材料" :limit="5" @setImgPath='setImgPath'/>
        </el-form-item>
      </el-form>
      <div slot="footer" class="dialog-footer">
        <div class="submitbtn"> 
          <el-button type="primary" @click="p2ptSubmitForm">确 定</el-button>
        </div>
        <el-button  @click="p2ptCancel">取 消</el-button>
      </div>
    </el-dialog>
    <el-dialog v-if="certification" :title="title" :visible.sync="certification" width="800px" append-to-body :close-on-click-modal="false" >
      <el-form ref="form" :model="form" :rules="certifRules" label-width="150px">
        <el-form-item label="姓名" prop="name">
          <el-input v-model="form.name" placeholder="请输入真实姓名"/>
        </el-form-item>
        <el-form-item label="身份证号码" prop="idNumber">
          <el-input v-model="form.idNumber" placeholder="请输入身份证号码"/>
        </el-form-item>
        <el-form-item label="所在城市" prop="city">
          <el-input v-model="form.city" placeholder="请输入所在城市"/>
        </el-form-item>
        <el-form-item label="测试能力" prop="testSkills">
          <el-input  v-model="form.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;" :underline="false">查看示例</el-link>
          </el-popover>
        </el-form-item>
        <el-form-item label="技能证书" prop="idCardFrontUrl">
          <multi-upload v-if="allFileGetFlag" v-model="form.idCardFrontUrl" :serverAddr="materialServerAddr" fileName="技能证书" :limit="1" />
        </el-form-item>
        <el-form-item label="工作经历" prop="workExperience">
          <el-input v-model="form.workExperience" type="textarea" placeholder="请输入内容" />
          <el-popover placement="top-start" title="示例：" width="500" 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;" :underline="false">查看示例</el-link>
          </el-popover>
        </el-form-item>
      </el-form>
      <div slot="footer" class="dialog-footer">
        <div class="submitbtn"> 
          <el-button type="primary" @click="p2ptSubmitForm">确 定</el-button>
        </div>
        <el-button  @click="p2ptCancel">取 消</el-button>
      </div>
    </el-dialog>
  </div>
</template>

<script>
  import {apple_type} from "@/api/system/user";
  import {
    listTesterApply,
    getTesterApplyByUid,
    delTesterApply,
    addC2CT,
    updateTesterApply,
    exportTesterApply,
    certificationStatus,
    addTesterApply,
  } from "@/api/tester/TesterApply";
  import {
    listCompanyApply,
    getCompanyApplyByUid,
    delCompanyApply,
    addCompanyApply,
    updateCompanyApply,
    exportCompanyApply,
  } from "@/api/tester/CompanyApply";
  import {VueCropper} from "vue-cropper";
  import MultiUpload from "@/page/common/MultiUpload";
  import NonimageUpload from "@/page/common/NonimageUpload";

  export default {
    components: {
      MultiUpload,
      NonimageUpload,
      VueCropper,
    },
    props: {
      user: {
        type: Object,
      },
      // regCompany: {
      //   type: Function,
      //   default: null,
      // },
      // p2pt: {
      //   type: Function,
      //   default: null,
      // },
      // x2ct: {
      //   type: Function,
      //   default: null,
      // },
      // refreshProfile: {
      //   type: Function,
      //   default: null,
      // },
    },
    data() {
      return {
        bArray: [
          [true, true],
          ["升级为认证公司用户", "升级为测试认证"],
          // ["升级为认证公司用户", "升级为认证测试公司", "升级为个人测试者"],
        ],
        certification:false,
        showAlert: false,
        appleTypeStr: "",
        testerApplyB: {},
        companyApplyB: {},
        // p2ct表单参数
        userInfo: {},
        testerApply: {},
        companyApply: {},
        form: {},
        // 弹出层标题
        title: "",
        // 是否显示regCompany弹出层
        regCompanyOpen: false,
        // 是否显示p2pt弹出层
        p2ptOpen: false,
        // 是否显示p2ct弹出层
        p2ctOpen: false,
        // 是否显示c2ct弹出层
        c2ctOpen: false,
        rules: {},
        // 个人测试者表单校验
        p2ptRules: {
          name: [
            {required: true, message: "真实姓名不能为空", trigger: "blur"},
          ],
          city: [
            {required: true, message: "所在城市不能为空", trigger: "blur"},
          ],
          idNumber: [
            {required: true, message: "身份证号码能为空", trigger: "blur"},
            {
              pattern:
                /^[1-9]\d{5}(18|19|20|(3\d))\d{2}((0[1-9])|(1[0-2]))(([0-2][1-9])|10|20|30|31)\d{3}[0-9Xx]$/,
              message: "请输入正确的身份证号码",
              trigger: "blur",
            },
          ],
          idCardFrontUrl: [
            {required: true, message: "身份证正面不能为空", trigger: "blur"},
          ],
          idCardBackUrl: [
            {required: true, message: "身份证反面不能为空", trigger: "blur"},
          ],
          testSkills: [
            {required: true, message: "测试能力不能为空", trigger: "blur"},
          ],
          testProjects: [
            {required: true, message: "测试项目案例不能为空", trigger: "blur"},
          ],
          idCardFrontUrl: [
            {
              required: true,
              message: "请上传身份证正面",
              trigger: "change",
            },
          ],
          idCardBackUrl: [
            {
              required: true,
              message: "请上传身份证反面",
              trigger: "change",
            },
          ],
        },
        // 认证公司用户表单校验
        regCompanyRules: {
          name: [
            {required: true, message: "公司名称不能为空", trigger: "blur"},
          ],
          creditCode: [
            {required: true, message: "统一信用代码不能为空", trigger: "blur"},
            {
              pattern:
                /^([0-9A-HJ-NPQRTUWXY]{2}\d{6}[0-9A-HJ-NPQRTUWXY]{10}|[1-9]\d{14})$/,
              message: "请输入正确的统一信用代码",
              trigger: "blur",
            },
          ],
          address: [
            {required: true, message: "通讯地址不能为空", trigger: "blur"},
          ],
          webSite: [
            {required: true, message: "网址不能为空", trigger: "blur"},
            {
              pattern:
                /^([hH][tT]{2}[pP]:\/\/|[hH][tT]{2}[pP][sS]:\/\/|www\.)(([A-Za-z0-9-~]+)\.)+([A-Za-z0-9-~\/])+$/,
              message: "请输入正确的网址",
              trigger: "blur",
            },
          ],
          companyDesc: [
            {required: true, message: "公司简介不能为空", trigger: "blur"},
          ],
          contactName: [
            {required: true, message: "联系人姓名不能为空", trigger: "blur"},
          ],
          contactPosition: [
            {required: true, message: "联系人职位不能为空", trigger: "blur"},
          ],
          businessLicenseUrl: [
            {
              required: true,
              message: "请上传营业执照",
              trigger: "change",
            },
          ],
        },
        // 认证测试公司表单校验
        p2ctRules: {
          name: [
            {required: true, message: "公司名称不能为空", trigger: "blur"},
          ],
          creditCode: [
            {required: true, message: "统一信用代码不能为空", trigger: "blur"},
            {
              pattern:
                /^([0-9A-HJ-NPQRTUWXY]{2}\d{6}[0-9A-HJ-NPQRTUWXY]{10}|[1-9]\d{14})$/,
              message: "请输入正确的统一信用代码",
              trigger: "blur",
            },
          ],
          address: [
            {required: true, message: "通讯地址不能为空", trigger: "blur"},
          ],
          webSite: [
            {required: true, message: "网址不能为空", trigger: "blur"},
            {
              pattern:
                /^([hH][tT]{2}[pP]:\/\/|[hH][tT]{2}[pP][sS]:\/\/|www\.)(([A-Za-z0-9-~]+)\.)+([A-Za-z0-9-~\/])+$/,
              message: "请输入正确的网址",
              trigger: "blur",
            },
          ],

          companyDesc: [
            {required: true, message: "公司简介不能为空", trigger: "blur"},
          ],
          contactName: [
            {required: true, message: "联系人姓名不能为空", trigger: "blur"},
          ],
          contactPosition: [
            {required: true, message: "联系人职位不能为空", trigger: "blur"},
          ],
          businessLicenseUrl: [
            {
              required: true,
              message: "请上传营业执照",
              trigger: "change",
            },
          ],
        },
        // 认证测试公司其他状态表单校验
        c2ctRules: {
          testProjects: [
            {required: true, message: "测试项目案例不能为空", trigger: "blur"},
          ],
        },
        materialServerAddr: "",
        allFileGetFlag: false,
      };
    },
    created() {
      this.getCertificationStatus();
      this.getClientConfigKey("material.server").then((response) => {
        this.materialServerAddr = response.msg;
      });
    },
    methods: {
      getCertificationStatus() {
        certificationStatus().then((response) => {
          this.testerApplyB = response.testerApply;
          this.companyApplyB = response.companyApply;
          this.initBArray();
        });
      },
      initBArray() {
        this.bArray = this.checkStatus();
      },
      checkStatus() {
        

        let stateArr = [
          [true, true],
          ["升级为认证公司用户", "升级为测试认证"],
        ];
        if (this.user.companyStatus == 2) {
          if (this.user.testerStatus == 2) {
            stateArr[0][0] = null;
            stateArr[0][1] = true;
            stateArr[0][2] = null;
            stateArr[1][1] = "更新测试公司信息";
          } else {
            stateArr[0][0] = true;
            stateArr[0][1] = true;
            stateArr[0][2] = null;
            stateArr[1][0] = "更新公司信息";
            stateArr[1][1] = "升级为认证测试公司";
          }
        } else {
          if (this.user.testerStatus == 2) {
            stateArr[0][0] = null;
            stateArr[0][1] = null;
            stateArr[0][2] = true;
            stateArr[1][2] = "更新个人测试者信息";
          }
        }

        //只要有申请按钮就都变灰
        //check 第一次认证或更新认证信息申请都需要变灰 status 状态：0:unaudit;1:pass;2:unpass;
        if (
          this.user.companyStatus == 1 ||
          this.user.testerStatus == 1 ||
          (this.testerApplyB && this.testerApplyB.status == 0) ||
          (this.companyApplyB && this.companyApplyB.status == 0)
        ) {
          if (stateArr[0][0] != null) {
            stateArr[0][0] = false;
          }
          if (stateArr[0][1] != null) {
            stateArr[0][1] = false;
          }
          if (stateArr[0][2] != null) {
            stateArr[0][2] = false;
          }

          // return stateArr;
          this.showAlert = true; //有申请在审核中

          var result = 0;
          var cS = this.user.companyStatus;
          var tS = this.user.testerStatus;
          /***
           * 申请：
           * 0 p2c
           * 1 p2pt
           * 2 p2ct
           * 3 c2ct
           * 或更新：
           * 4 更新公司 uc
           * 5 更新测试公司 uct
           * 6 更新个人测试者 upt
           */
          if (cS == 2) {
            if (tS == 2) {
              result = 5; //uct
            } else if (tS == 1) {
              result = 3; //c2ct
            } else {
              result = 4; //uc
            }
          } else if (cS == 1) {
            if (tS == 2) {
              // 个人测试者无法再继续认证为公司
            } else if (tS == 1) {
              result = 2; //p2ct
            } else {
              result = 0; //p2c
            }
          } else {
            if (tS == 2) {
              result = 6; //upt
            } else if (tS == 1) {
              result = 1; //p2pt
            } else {
              // 啥都没做哦
            }
          }
          this.appleTypeStr = apple_type.getDescFromValue(result);
        } else {
          this.showAlert = false;
        }

        return stateArr;
      },
      regCompanyChild() {
        this.getCompanyApplyByUserID(this.user.userId);
      },
      /** 加载审核页面数据操作 */
      getCompanyApplyByUserID(userId) {
        this.allFileGetFlag = false;
        getCompanyApplyByUid(userId).then((response) => {
          if (response.data) {
            this.form = response.data;
          } else {
            this.form = {
              applyId: null,
              name: null,
              creditCode: null,
              address: null,
              webSite: null,
              companyDesc: null,
              contactName: null,
              contactPosition: null,
              createTime: null,
              updateTime: null,
              businessLicenseUrl: [],
              otherCQList: [],
            };
          }
          this.allFileGetFlag = true;
          this.regCompanyOpen = true;
          this.title = "公司用户认证信息";
        });
      },
      p2ptChild() {
        this.p2ptGetApplyByUserID(this.user.userId);
      },
      /** 加载审核页面数据操作 */
      p2ptGetApplyByUserID(userId) {
        getTesterApplyByUid(userId).then((response) => {
          if (response.data) {
            this.form = response.data;
          } else {
            this.form = {
              applyId: null,
              name: null,
              city: null,
              idNumber: null,
              testSkills: null,
              testProjects: null,
              workExperience: null,
              certificate: null,
              createTime: null,
              updateTime: null,
              idCardFrontUrl: [],
              idCardBackUrl: [],
              otherTQList: [],
            };
          }
          this.allFileGetFlag = true;
          this.p2ptOpen = true;
          this.title = "个人测试者认证信息";
        });
      },
      p2ctChild() {
        this.p2ctGetApplyByUserID(this.user.userId);
      },
      /** 加载审核页面数据操作 */
      p2ctGetApplyByUserID(userId) {
        certificationStatus().then((response) => {
          if (response.testerApply) {
            this.testerApply = response.testerApply;
          } else {
            this.testerApply = {
              testProjects: null,
              otherInfo: null,
              otherTQList: [],
            };
          }
          if (response.companyApply) {
            this.companyApply = response.companyApply;
          } else {
            this.companyApply = {
              applyId: null,
              name: null,
              creditCode: null,
              address: null,
              webSite: null,
              companyDesc: null,
              contactName: null,
              contactPosition: null,
              createTime: null,
              updateTime: null,
              businessLicenseUrl: [],
              otherCQList: [],
            };
          }
          if (response.data) {
            this.userInfo = response.data;
          } else {
          }
          this.allFileGetFlag = true;
          this.p2ctOpen = true;
          this.title = "测试公司认证信息";
        });
      },
      c2ctChild() {
        this.c2ctGetApplyByUserID(this.user.userId);
      },
      /** 加载审核页面数据操作 */
      c2ctGetApplyByUserID(userId) {
        getTesterApplyByUid(userId).then((response) => {
          if (response.data) {
            this.form = response.data;
          } else {
            this.form = {
              testProjects: null,
              otherInfo: null,
              otherTQList: [],
            };
          }
          this.allFileGetFlag = true;
          this.c2ctOpen = true;
          this.title = "测试公司认证信息";
        });
      },
      // 取消按钮
      p2ptCancel() {
        this.p2ptOpen = false;
        this.reset();
      },
      // 取消按钮
      regCompanyCancel() {
        this.regCompanyOpen = false;
        this.reset();
      },
      p2ctCancel() {
        this.p2ctOpen = false;
        this.p2ctReset();
      },
      c2ctCancel() {
        this.c2ctOpen = false;
        this.reset();
      },
      // 表单重置
      reset() {
        this.form = {};
        this.resetForm("form");
      },
      //TODO p2ct中包含的两个表单重置
      p2ctReset() {
        this.companyApply = {};
        this.resetForm("companyApply");
        this.testerApply = {};
        this.resetForm("testerApply");
      },
      /** 添加或修改认证公司用户提交按钮 */
      regCompanySubmitForm() {
        this.$refs["form"].validate((valid) => {
          if (valid) {
            if (this.form.applyId != null) {
              updateCompanyApply(this.form).then((response) => {
                this.$message.success("更新提交成功，请等待审核结果");
                this.regCompanyOpen = false;
                this.refreshUserProfile();
              });
            } else {
              addCompanyApply(this.form).then((response) => {
                this.$message.success("申请提交成功，请等待审核结果");
                this.regCompanyOpen = false;
                this.refreshUserProfile();
              });
            }
          }
        });
      },

      // 添加或修改认证测试公司提交按钮
      p2ctSubmitForm() {
        this.$refs["companyForm"].validate((valid) => {
          if (valid) {
            if (this.testerApply.applyId != null) {
              updateCompanyApply(this.companyApply).then((response) => {
                updateTesterApply(this.testerApply).then((response) => {
                  this.$message.success("更新提交成功，请等待审核结果");
                  this.p2ctOpen = false;
                  this.refreshUserProfile();
                });
              });
            } else {
              this.testerApply.applyType = 1;
              addCompanyApply(this.companyApply).then((response) => {
                addTesterApply(this.testerApply).then((response) => {
                  this.$message.success("申请提交成功，请等待审核结果");
                  this.p2ctOpen = false;
                  this.refreshUserProfile();
                });
              });
            }
          }
        });
      },
      //不同状态下添加或修改认证测试公司提交按钮
      c2ctSubmitForm() {
        this.$refs["form"].validate((valid) => {
          if (valid) {
            this.form.applyType = 2;
            if (this.form.applyId != null) {
              updateTesterApply(this.form).then((response) => {
                this.$message.success("更新提交成功，请等待审核结果");
                this.c2ctOpen = false;
                this.refreshUserProfile();
              });
            } else {
              addC2CT(this.form).then((response) => {
                this.$message.success("申请提交成功，请等待审核结果");
                this.c2ctOpen = false;
                this.refreshUserProfile();
              });
            }
          }
        });
      },
      setImgPath(value) {
        if(value){
          if(this.regCompanyOpen){
            this.form.otherCQList= value;
          }else if(this.p2ctOpen){
            this.companyApply.otherCQList= value;
          }else if(this.c2ctOpen){
            this.form.otherTQList=value
          }else if(this.p2ptOpen){
            this.form.otherTQList= value;
          }
        }
      },
      setnoniPath(value){
        if(value){
          this.testerApply.otherTQList= value;
        }
      },
      /** 添加或修改个人测试者提交按钮 */
      p2ptSubmitForm() {
        this.$refs["form"].validate((valid) => {
          if (valid) {
            this.form.applyType = 0;
            if (this.form.applyId != null) {
              updateTesterApply(this.form).then((response) => {
                this.$message.success("更新提交成功，请等待审核结果");
                this.p2ptOpen = false;
                this.refreshUserProfile();
              });
            } else {
              addTesterApply(this.form).then((response) => {
                this.$message.success("申请提交成功，请等待审核结果");
                this.p2ptOpen = false;
                this.refreshUserProfile();
              });
            }
          }
        });
      },
      refreshUserProfile() {
        if (this.refreshProfile) {
          this.refreshProfile();
        }
      },
      x2ctChild(){
        this.certification=true
      },
      //TODO check 第一次认证成功或更新认证信息成功
      x2ctChild() {
        // if (this.user.companyStatus == 2) {
        //   if (this.user.testerStatus == 2) {
        //     this.p2ctChild();
        //   } else {
        //     this.c2ctChild();
        //   }
        // } else {
        //   if (this.user.testerStatus == 2) {
        //     //TODO do nothing ???
        //   } else {
        //     this.p2ctChild();
        //   }
        // }
      },
    },
  };
</script>
<style scoped >
  .user-userUpgrade-span {
    text-align: center;
  }
  .testuser{
    display:flex;
    align-items:center;
    justify-content:space-between;
  }
  .testuser>>>.el-button{
    background:#F2A51A;
    color:#FFFFFF;
    margin-left:50px;
    border: none;
  }
  .dialog-footer{
    display:flex;
    text-align:right;
    margin-left:550px
  }
  .submitbtn>>>.el-button{
    background:#0066EB;
    color:#FFFFFF;
    margin-right:30px;
    border: none;
  }
   .examku>>>.el-dialog__title{
        font-weight:bold;
        color: #0969bd
    }
</style>
