<template>
    <div class="userAbility">
        <div class="topTitle container">
            申请入驻
            <div class="colra">云员工</div>
        </div>
        <div class="contentBig container">
            <div class="stepBox">
                <el-steps :active="active" align-center>
                    <el-step title="第一步: 实名认证">
                        <template slot="icon">
                            <img
                                v-if="active == 0"
                                src="/assets/ability/1ac.png"
                                style="width: 24px; height: 24px"
                                alt=""
                            />
                            <img v-else src="/assets/ability/1un.png" style="width: 24px; height: 24px" alt="" />
                        </template>
                    </el-step>
                    <el-step title="第二步: 工作经历">
                        <template slot="icon">
                            <img
                                v-if="active == 1"
                                src="/assets/ability/2ac.png"
                                style="width: 24px; height: 24px"
                                alt=""
                            />
                            <img v-else src="/assets/ability/2un.png" style="width: 24px; height: 24px" alt="" />
                        </template>
                    </el-step>
                    <el-step title="第三步: 项目经历">
                        <template slot="icon">
                            <img
                                v-if="active == 2"
                                src="/assets/ability/3ac.png"
                                style="width: 24px; height: 24px"
                                alt=""
                            />
                            <img v-else src="/assets/ability/3un.png" style="width: 24px; height: 24px" alt="" />
                        </template>
                    </el-step>
                    <el-step title="第四步: 个人简介">
                        <template slot="icon">
                            <img
                                v-if="active == 3"
                                src="/assets/ability/4ac.png"
                                style="width: 24px; height: 24px"
                                alt=""
                            />
                            <img v-else src="/assets/ability/4un.png" style="width: 24px; height: 24px" alt="" />
                        </template>
                    </el-step>
                    <el-step title="第五步: 资格证书">
                        <template slot="icon">
                            <img
                                v-if="active == 4"
                                src="/assets/ability/5ac.png"
                                style="width: 24px; height: 24px"
                                alt=""
                            />
                            <img v-else src="/assets/ability/5un.png" style="width: 24px; height: 24px" alt="" />
                        </template>
                    </el-step>
                    <el-step title="第六步: 教育经历">
                        <template slot="icon">
                            <img
                                v-if="active == 5"
                                src="/assets/ability/6ac.png"
                                style="width: 24px; height: 24px"
                                alt=""
                            />
                            <img v-else src="/assets/ability/6un.png" style="width: 24px; height: 24px" alt="" />
                        </template>
                    </el-step>
                    <el-step title="第七步: 提交检查">
                        <template slot="icon">
                            <img
                                v-if="active == 6"
                                src="/assets/ability/7ac.png"
                                style="width: 24px; height: 24px"
                                alt=""
                            />
                            <img v-else src="/assets/ability/7un.png" style="width: 24px; height: 24px" alt="" />
                        </template>
                    </el-step>
                </el-steps>
                <div class="stepBoxBtn">
                    <div class="backBtn" @click="back">上一步</div>
                    <div class="nextBtn" v-if="active == 6" @click="saveInfo">提交审核</div>
                    <div class="nextBtn" v-else @click="next">下一步</div>
                </div>
            </div>
            <div class="contentBox" v-show="!userForm.status">
                <div class="active1" v-show="active == 0">
                    <div class="activeTitle">
                        <div class="activeTitLine"></div>
                        实名认证
                    </div>
                    <div class="applytip">请放心认证，关键测试宝平台承诺保障你的个人信息安全</div>
                    <div class="workIt">
                        <el-form ref="certifform" :model="certifform" :rules="certifRules">
                            <el-form-item prop="name">
                                <el-input
                                    v-model="certifform.name"
                                    :disabled="certifform.applyId && certifform.status == 1"
                                    placeholder="请输入真实姓名"
                                />
                            </el-form-item>
                            <el-form-item prop="idNumber">
                                <el-input
                                    v-model="certifform.idNumber"
                                    :disabled="certifform.applyId && certifform.status == 1"
                                    placeholder="请输入身份证号码"
                                />
                            </el-form-item>
                        </el-form>
                    </div>
                    <div v-if="active == 0 && !certifform.applyId" class="addWork" @click="applyBegin">开始验证</div>
                    <div class="applySuccess" v-if="certifform.applyId && certifform.status == 1">
                        <img src="/assets/ability/applysuccess.png" alt="" />
                        验证通过
                    </div>
                </div>
                <div class="active2" v-show="active == 1 || active == 6">
                    <!-- 工作经历 -->
                    <div class="activeTitle">
                        <div class="activeTitLine"></div>
                        工作经历
                    </div>
                    <div class="workIt" v-for="(it, index) in workList" :key="index">
                        <el-form :rules="workRules" :model="it" label-width="90px" :ref="'workRef' + index">
                            <el-form-item label="公司名称: " prop="name">
                                <el-input
                                    v-model="it.name"
                                    placeholder="请输入公司名称"
                                    :disabled="active == 6 ? true : false"
                                ></el-input>
                            </el-form-item>
                            <div class="flexbox">
                                <el-form-item label="在职时间: " prop="startTime">
                                    <el-date-picker
                                        value-format="yyyy-MM"
                                        v-model="it.startTime"
                                        type="month"
                                        placeholder="开始时间"
                                        :disabled="active == 6 ? true : false"
                                    >
                                    </el-date-picker>
                                </el-form-item>
                                <span style="color: #bfbfbf; margin: -27px 15px 0 15px">-</span>
                                <el-form-item prop="endTime" class="endtime">
                                    <el-date-picker
                                        value-format="yyyy-MM"
                                        v-model="it.endTime"
                                        type="month"
                                        placeholder="结束时间"
                                        :disabled="active == 6 ? true : false"
                                    >
                                    </el-date-picker>
                                </el-form-item>
                            </div>
                            <el-form-item label="职位名称: " prop="title">
                                <el-input
                                    v-model="it.title"
                                    placeholder="请输入职位名称"
                                    :disabled="active == 6 ? true : false"
                                ></el-input>
                            </el-form-item>
                            <el-form-item label="工作内容: " prop="intro">
                                <el-input
                                    type="textarea"
                                    v-model="it.intro"
                                    :rows="5"
                                    placeholder="请输入工作内容"
                                    :disabled="active == 6 ? true : false"
                                ></el-input>
                            </el-form-item>
                        </el-form>
                        <div v-if="active == 1" class="delWork">
                            <div v-if="!it.caseId" class="saveWork" @click="saveWork(index)">保存</div>
                            <div v-else class="saveWork" @click="updateWork(index)">修改</div>
                            <img
                                src="/assets/ability/delicon.png"
                                style="width: 14px; height: 16px; margin-right: 5px"
                                alt=""
                                @click="delWork(index)"
                            />
                            <span @click="delWork(index)">删除</span>
                        </div>
                    </div>
                    <div v-if="active == 1" class="addWork" @click="addWork">+ 新增经历</div>
                </div>
                <div class="active3" v-show="active == 2 || active == 6">
                    <!-- 项目经历 -->
                    <div class="activeTitle">
                        <div class="activeTitLine"></div>
                        项目经历
                    </div>
                    <div class="workIt" v-for="(it, index) in projectList" :key="index">
                        <el-form :rules="projectRules" :model="it" label-width="90px" :ref="'projectRef' + index">
                            <el-form-item label="项目名称" prop="name">
                                <el-input
                                    v-model="it.name"
                                    placeholder="请输入项目名称"
                                    :disabled="active == 6 ? true : false"
                                ></el-input>
                            </el-form-item>
                            <div class="flexbox">
                                <el-form-item label="项目时间: " prop="startTime">
                                    <el-date-picker
                                        value-format="yyyy-MM"
                                        v-model="it.startTime"
                                        type="month"
                                        placeholder="开始时间"
                                        :disabled="active == 6 ? true : false"
                                    >
                                    </el-date-picker>
                                </el-form-item>
                                <span style="color: #bfbfbf; margin: -27px 15px 0 15px">-</span>
                                <el-form-item prop="endTime" class="endtime">
                                    <el-date-picker
                                        value-format="yyyy-MM"
                                        v-model="it.endTime"
                                        type="month"
                                        placeholder="结束时间"
                                        :disabled="active == 6 ? true : false"
                                    >
                                    </el-date-picker>
                                </el-form-item>
                            </div>
                            <el-form-item label="担任角色" prop="title">
                                <el-input
                                    v-model="it.title"
                                    placeholder="请输入担任角色"
                                    :disabled="active == 6 ? true : false"
                                ></el-input>
                            </el-form-item>
                            <el-form-item label="应用技术" prop="applyTech">
                                <el-input
                                    v-model="it.applyTech"
                                    placeholder="请输入应用技术"
                                    :disabled="active == 6 ? true : false"
                                ></el-input>
                            </el-form-item>
                            <el-form-item label="工作内容" prop="intro">
                                <el-input
                                    :rows="5"
                                    type="textarea"
                                    v-model="it.intro"
                                    placeholder="请输入工作内容"
                                    :disabled="active == 6 ? true : false"
                                ></el-input>
                            </el-form-item>
                        </el-form>
                        <div v-if="active == 2" class="delWork">
                            <div v-if="!it.caseId" class="saveWork" @click="saveProject(index)">保存</div>
                            <div v-else class="saveWork" @click="updateProject(index)">修改</div>
                            <img
                                src="/assets/ability/delicon.png"
                                style="width: 14px; height: 16px; margin-right: 5px"
                                alt=""
                                @click="delProject(index)"
                            />
                            <span @click="delProject(index)">删除</span>
                        </div>
                    </div>
                    <div v-if="active == 2" class="addWork" @click="addProject">+ 新增经历</div>
                </div>
                <div class="active4" v-show="active == 3 || active == 6">
                    <!-- 个人简介 -->
                    <div class="activeTitle">
                        <div class="activeTitLine"></div>
                        个人简介
                    </div>
                    <div class="workIt">
                        <el-form :rules="userRules" :model="userForm" label-width="80px" ref="userRef">
                            <el-form-item label="所在城市" prop="city">
                                <el-input v-model="userForm.city" v-show="false"></el-input>
                                <v-distpicker
                                    @province="onChangeProvince"
                                    @city="onChangeCity"
                                    :placeholders="placeholders"
                                    :province="province"
                                    :city="city"
                                    hide-area
                                    :disabled="active == 6 ? true : false"
                                ></v-distpicker>
                            </el-form-item>
                            <el-form-item label="技能方向" prop="testSkills">
                                <el-input
                                    v-model="userForm.testSkills"
                                    placeholder="请输入技能，如：测试工程师"
                                    :disabled="active == 6 ? true : false"
                                ></el-input>
                            </el-form-item>
                            <el-form-item label="个人优势" prop="personalAdvantage">
                                <el-input
                                    type="textarea"
                                    :rows="5"
                                    v-model="userForm.personalAdvantage"
                                    placeholder="请输入个人优势"
                                    :disabled="active == 6 ? true : false"
                                ></el-input>
                            </el-form-item>
                        </el-form>
                        <div v-if="active == 3" class="delWork">
                            <div class="saveWork" @click="saveUser">保存</div>
                        </div>
                    </div>
                </div>
                <div class="active5" v-show="active == 4 || active == 6">
                    <!-- 资格证书 -->
                    <div class="activeTitle">
                        <div class="activeTitLine"></div>
                        资格证书
                    </div>
                    <div class="workIt" v-for="(it, index) in certificateList" :key="index">
                        <el-form
                            :rules="certificateRules"
                            :model="it"
                            label-width="80px"
                            :ref="'certificateRef' + index"
                        >
                            <el-form-item label="证书名称" prop="credentialsName">
                                <el-input
                                    v-model="it.credentialsName"
                                    placeholder="请输入证书名称"
                                    :disabled="active == 6 ? true : false"
                                ></el-input>
                            </el-form-item>
                            <el-form-item prop="url">
                                <imageUpload
                                    v-model="it.url"
                                    fileName="publicize"
                                    :limit="1"
                                    :ref="'myupload' + index"
                                    :isDisabled="active == 4 ? false : true"
                                />
                            </el-form-item>
                        </el-form>
                        <div v-if="active == 4" class="delWork">
                            <div v-if="!it.fileId" class="saveWork" @click="saveCertificate(index)">保存</div>
                            <div v-else class="saveWork" @click="updateCertificate(index)">修改</div>
                            <img
                                src="/assets/ability/delicon.png"
                                style="width: 14px; height: 16px; margin-right: 5px"
                                @click="delCertificate(index)"
                            />
                            <span @click="delCertificate(index)">删除</span>
                        </div>
                    </div>
                    <div v-if="active == 4" class="addWork" @click="addCertificate">+ 新增证书</div>
                </div>
                <div class="active6" v-show="active == 5 || active == 6">
                    <!-- 教育经历 -->
                    <div class="activeTitle">
                        <div class="activeTitLine"></div>
                        教育经历
                    </div>
                    <div class="workIt" v-for="(it, index) in educationList" :key="index">
                        <el-form :rules="educationRules" :model="it" label-width="90px" :ref="'educationRef' + index">
                            <el-form-item label="学校名称" prop="name">
                                <el-input
                                    v-model="it.name"
                                    placeholder="请输入学校名称"
                                    :disabled="active == 6 ? true : false"
                                ></el-input>
                            </el-form-item>
                            <div class="flexbox">
                                <el-form-item label="在校时间: " prop="startTime">
                                    <el-date-picker
                                        value-format="yyyy-MM"
                                        v-model="it.startTime"
                                        type="month"
                                        placeholder="开始时间"
                                        :disabled="active == 6 ? true : false"
                                    >
                                    </el-date-picker>
                                </el-form-item>
                                <span style="color: #bfbfbf; margin: -27px 15px 0 15px">-</span>
                                <el-form-item prop="endTime" class="endtime">
                                    <el-date-picker
                                        value-format="yyyy-MM"
                                        v-model="it.endTime"
                                        type="month"
                                        placeholder="结束时间"
                                        :disabled="active == 6 ? true : false"
                                    >
                                    </el-date-picker>
                                </el-form-item>
                            </div>
                            <el-form-item label="学历" prop="education">
                                <el-select
                                    v-model="it.education"
                                    placeholder="请选择学历"
                                    :disabled="active == 6 ? true : false"
                                >
                                    <el-option label="专科" value="专科"> </el-option>
                                    <el-option label="本科" value="本科"> </el-option>
                                    <el-option label="硕士研究生" value="硕士研究生"> </el-option>
                                    <el-option label="博士研究生" value="博士研究生"> </el-option>
                                </el-select>
                            </el-form-item>
                            <el-form-item label="专业名称" prop="major">
                                <el-input
                                    v-model="it.major"
                                    placeholder="请输入专业名称"
                                    :disabled="active == 6 ? true : false"
                                ></el-input>
                            </el-form-item>
                        </el-form>
                        <div v-if="active == 5" class="delWork">
                            <div v-if="!it.caseId" class="saveWork" @click="saveEducation(index)">保存</div>
                            <div v-else class="saveWork" @click="updateEducation(index)">修改</div>
                            <img
                                src="/assets/ability/delicon.png"
                                style="width: 14px; height: 16px; margin-right: 5px"
                                alt=""
                                @click="delEducation(index)"
                            />
                            <span @click="delEducation(index)">删除</span>
                        </div>
                    </div>
                    <div v-if="active == 5" class="addWork" @click="addEducation">+ 新增经历</div>
                </div>
                <!-- <div class="active7" v-if="active == 6">
                </div> -->
            </div>
            <div class="contentBox" v-show="userForm.status == 1">
                <div class="applyIng">提交成功，等待审核</div>
            </div>
            <div class="applyFail" v-show="userForm.status == 3">
                <img src="/assets/ability/applyFail.png" alt="" />
                审核不通过
            </div>
            <div class="contentBox" v-show="userForm.status == 2">
                <div class="applySuccessAll">
                    <img src="/assets/ability/applysuccess.png" alt="" />
                    审核通过
                </div>
            </div>
        </div>
    </div>
</template>
<script>
import { mapGetters } from 'vuex'
import imageUpload from '@/page/common/imageUpload'
import { gettesterId, addtesterApply, updatetesterApply } from '@/api/tester/CompanyApply'
import {
    getCloudAll,
    couldInfoAdd,
    couldInfoUpdate,
    couldInfoDelete,
    couldUserInfoAdd,
    couldBookAdd,
    couldBookUpdate,
    couldApply,
    delBook
} from '@/api/tester/TesterApply'

export default {
    components: { imageUpload },
    data() {
        return {
            active: 0,
            // 实名认证
            certifform: {},
            certifRules: {
                name: [
                    { required: true, message: '真实姓名不能为空', trigger: 'blur' },
                    { max: 20, message: '最多输入20个中文', trigger: 'blur' },
                    {
                        pattern: /^(?:[\u4e00-\u9fa5·]{2,16})$/,
                        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',
                    },
                    { max: 18, message: '身份证长度为18', trigger: 'blur' },
                    { min: 18, message: '身份证长度为18', trigger: 'blur' },
                ],
            },
            // 工作经历
            workList: [],
            workRules: {
                name: [{ required: true, message: '请输入公司名称', trigger: 'blur' }],
                startTime: [{ required: true, message: '请输入开始时间', trigger: 'blur' }],
                endTime: [{ required: true, message: '请输入结束时间', trigger: 'blur' }],
                title: [{ required: true, message: '请输入职位名称', trigger: 'blur' }],
                intro: [{ required: true, message: '请输入工作内容', trigger: 'blur' }],
            },
            // 项目经历
            projectList: [{}],
            projectRules: {
                name: [{ required: true, message: '请输入公司名称', trigger: 'blur' }],
                startTime: [{ required: true, message: '请输入开始时间', trigger: 'blur' }],
                endTime: [{ required: true, message: '请输入结束时间', trigger: 'blur' }],
                title: [{ required: true, message: '请输入职位名称', trigger: 'blur' }],
                intro: [{ required: true, message: '请输入工作内容', trigger: 'blur' }],
                applyTech: [{ required: true, message: '请输入应用技术', trigger: 'blur' }],
            },
            // 个人简历
            userForm: {
                city: '北京市-北京市',
            },
            userRules: {
                testSkills: [{ required: true, message: '请输入技能方向', trigger: 'blur' }],
                personalAdvantage: [{ required: true, message: '请输入个人优势', trigger: 'blur' }],
            },
            province: '北京市',
            city: '北京市',
            placeholders: {
                province: '--- 省 ----',
                city: '--- 市 ---',
            },
            // 资格证书
            materialServerAddr: '',
            certificateList: [{}],
            certificateRules: {
                // credentialsName: [{ required: true, message: '请输入证书名称', trigger: 'blur' }],
                url: [{ required: true, message: '请上传证书', trigger: 'blur' }],
            },
            // 教育经历
            educationList: [{}],
            educationRules: {
                name: [{ required: true, message: '请输入学校名称', trigger: 'blur' }],
                startTime: [{ required: true, message: '请输入开始时间', trigger: 'blur' }],
                endTime: [{ required: true, message: '请输入结束时间', trigger: 'blur' }],
                education: [{ required: true, message: '请输入学历', trigger: 'change' }],
                major: [{ required: true, message: '请输入专业名称', trigger: 'blur' }],
            },
        }
    },
    watch: {
        active: {
            handler(newval, oldval) {
                if (newval == 0) {
                    this.searchApply()
                }
            },
            immediate: true,
        },
    },
    computed: {
        ...mapGetters(['userinform', 'token']),
    },
    created() {
        this.getCloudAllList()
    },
    methods: {
        // 提交审核
        saveInfo() {
            if (this.userForm.status == 1) return this.$message.warning('正在审核，请勿重复提交')
            if (this.userForm.status == 2) return this.$message.warning('审核已通过，请勿重复提交')
            couldApply().then((res) => {
                this.$message.success('提交审核成功')
                this.getCloudAllList()
            })
        },
        // 获取简历信息
        getCloudAllList() {
            getCloudAll().then((res) => {
                // 经历
                this.projectList = res.experience.filter((it) => it.type == 0)
                if (!this.projectList.length) {
                    this.projectList = [{}]
                }
                this.workList = res.experience.filter((it) => it.type == 1)
                if (!this.workList.length) {
                    this.workList = []
                }
                this.educationList = res.experience.filter((it) => it.type == 2)
                if (!this.educationList.length) {
                    this.educationList = [{}]
                }
                // 个人简介
                this.userForm = res.personalInfo
                this.province = this.userForm.city.split('-')[0]
                this.city = this.userForm.city.split('-')[1]

                // 审核状态 1审核通过 2不通过 没有或者0待审核
                if (res.personalInfo.status === 0) {
                } else if (res.personalInfo.status === 1) {
                    this.active = 6
                } else if (res.personalInfo.status === 2) {
                    this.active = 6
                } else {
                }

                // 证书
                this.certificateList = res.credentials.map((it) => {
                    return {
                        url: it.fileUrl,
                        credentialsName: it.fileName,
                        fileId: it.fileId,
                    }
                })
                if (!this.certificateList.length) {
                    this.certificateList = [{}]
                }
            })
        },
        // 查询用户认证信息
        searchApply() {
            gettesterId(this.userinform.userId).then((res) => {
                if (res.code == 200 && res.data.applyId) {
                    this.certifform = res.data
                }
            })
        },
        applyBegin() {
            this.$refs['certifform'].validate((valid) => {
                if (valid) {
                    let data = {
                        applyId: this.certifform.applyId,
                        userId: this.userinform.userId,
                        name: this.certifform.name,
                        idNumber: this.certifform.idNumber,
                    }
                    // return;
                    if (this.certifform.applyId) {
                        updatetesterApply(data)
                            .then((res) => {
                                if (res.code == 200) {
                                    this.$message.success('实名认证成功')
                                    this.searchApply()
                                } else {
                                }
                            })
                            .catch((error) => {})
                    } else {
                        addtesterApply(data)
                            .then((res) => {
                                if (res.code == 200) {
                                    this.$message.success('实名认证成功')
                                    this.searchApply()
                                } else {
                                }
                            })
                            .catch((error) => {})
                    }
                }
            })
        },
        // 返回上一步
        back() {
            if (this.userForm.status == 1 || this.userForm.status == 2) return
            if (this.active == 0) return
            this.active--
        },
        // 下一步
        next() {
            if (this.active == 0) {
                if (this.certifform.status != 1) {
                    return this.$message.warning('请先通过实名认证')
                }
            }
            this.active++
        },
        // 工作经历添加
        addWork() {
            if (this.workList.length >= 10) return this.$message.warning('工作经历最多添加10条')
            this.workList.push({})
        },
        // 工作经历保存
        saveWork(i) {
            this.$refs[`workRef${i}`][0].validate((valid) => {
                if (valid) {
                    const data = this.workList[i]
                    data.type = 1
                    couldInfoAdd(data).then((res) => {
                        this.$message.success('工作经历保存成功')
                        this.getCloudAllList()
                    })
                }
            })
        },
        // 工作经历修改
        updateWork(i) {
            this.$refs[`workRef${i}`][0].validate((valid) => {
                if (valid) {
                    const data = this.workList[i]
                    couldInfoUpdate(data).then((res) => {
                        this.$message.success('工作经历修改成功')
                        this.getCloudAllList()
                    })
                }
            })
        },
        // 工作经历删除
        delWork(i) {
            this.$confirm('此操作将永久删除, 是否继续?', '提示', {
                confirmButtonText: '确定',
                cancelButtonText: '取消',
                type: 'warning',
            }).then(() => {
                if (this.workList[i].caseId) {
                    couldInfoDelete(this.workList[i].caseId).then(() => {
                        this.$message({
                            type: 'success',
                            message: '删除成功!',
                        })
                        this.getCloudAllList()
                    })
                } else {
                    this.workList.splice(i, 1)
                    this.$message({
                        type: 'success',
                        message: '删除成功!',
                    })
                }
            })
        },
        // 项目经历添加
        addProject() {
            if (this.projectList.length >= 20) return this.$message.warning('项目经历最多添加20条')
            this.projectList.push({})
        },
        // 项目经历保存
        saveProject(i) {
            this.$refs[`projectRef${i}`][0].validate((valid) => {
                if (valid) {
                    const data = this.projectList[i]
                    data.type = 0
                    couldInfoAdd(data).then((res) => {
                        this.$message.success('项目经历保存成功')
                        this.getCloudAllList()
                    })
                }
            })
        },
        // 项目经历修改
        updateProject(i) {
            this.$refs[`projectRef${i}`][0].validate((valid) => {
                if (valid) {
                    const data = this.projectList[i]
                    couldInfoUpdate(data).then((res) => {
                        this.$message.success('项目经历修改成功')
                        this.getCloudAllList()
                    })
                }
            })
        },
        // 项目经历删除
        delProject(i) {
            this.$confirm('此操作将永久删除, 是否继续?', '提示', {
                confirmButtonText: '确定',
                cancelButtonText: '取消',
                type: 'warning',
            }).then(() => {
                if (this.projectList[i].caseId) {
                    couldInfoDelete(this.projectList[i].caseId).then(() => {
                        this.$message({
                            type: 'success',
                            message: '删除成功!',
                        })
                        this.getCloudAllList()
                    })
                } else {
                    if (this.projectList.length == 1) return this.$message.warning('最少有一项')
                    this.projectList.splice(i, 1)
                    this.$message({
                        type: 'success',
                        message: '删除成功!',
                    })
                }
            })
        },
        // 个人简介保存
        saveUser() {
            this.$refs[`userRef`].validate((valid) => {
                if (valid) {
                    if (this.userForm.city.indexOf('--- 市 ---') != -1) {
                        return this.$message.warning('请选择市')
                    }
                    couldUserInfoAdd(this.userForm).then((res) => {
                        this.$message.success('保存个人简介成功')
                    })
                }
            })
        },
        // 资格证书添加
        addCertificate() {
            this.certificateList.push({})
        },
        // 保存证书
        saveCertificate(i) {
            this.$refs[`certificateRef${i}`][0].validate((valid) => {
                if (valid) {
                    const data = {
                        credentialsList: [JSON.parse(JSON.stringify(this.certificateList[i]))],
                    }
                    data.credentialsList[0].url = data.credentialsList[0].url.replace(/.*\/profile/, '/profile')
                    couldBookAdd(data).then((res) => {
                        this.$message.success('资格证书保存成功')
                        this.getCloudAllList()
                    })
                }
            })
        },
        // 更新证书
        updateCertificate(i) {
            this.$refs[`certificateRef${i}`][0].validate((valid) => {
                if (valid) {
                    const data = {
                        credentialsList: JSON.parse(JSON.stringify(this.certificateList)),
                    }
                    data.credentialsList.forEach((it) => {
                        it.url = it.url.replace(/.*\/profile/, '/profile')
                    })
                    couldBookUpdate(data).then((res) => {
                        this.$message.success('资格证书修改成功')
                        this.getCloudAllList()
                    })
                }
            })
        },
        // 资格证书删除
        delCertificate(i) {
            this.$confirm('此操作将永久删除, 是否继续?', '提示', {
                confirmButtonText: '确定',
                cancelButtonText: '取消',
                type: 'warning',
            }).then(() => {
                if (this.certificateList[i].fileId) {
                    delBook(this.certificateList[i].fileId).then((res) => {
                        this.$message.success('资格证书删除成功')
                        this.getCloudAllList()
                    })
                } else {
                    this.certificateList.splice(i, 1)
                    this.$message({
                        type: 'success',
                        message: '删除成功!',
                    })
                }
            })


        },
        // 教育经历添加
        addEducation() {
            this.educationList.push({})
        },
        // 教育经历保存
        saveEducation(i) {
            this.$refs[`educationRef${i}`][0].validate((valid) => {
                if (valid) {
                    const data = this.educationList[i]
                    data.type = 2
                    couldInfoAdd(data).then((res) => {
                        this.$message.success('教育经历保存成功')
                        this.getCloudAllList()
                    })
                }
            })
        },
        // 教育经历修改
        updateEducation(i) {
            this.$refs[`educationRef${i}`][0].validate((valid) => {
                if (valid) {
                    const data = this.educationList[i]
                    couldInfoUpdate(data).then((res) => {
                        this.$message.success('教育经历修改成功')
                        this.getCloudAllList()
                    })
                }
            })
        },
        // 教育经历删除
        delEducation(i) {
            this.$confirm('此操作将永久删除, 是否继续?', '提示', {
                confirmButtonText: '确定',
                cancelButtonText: '取消',
                type: 'warning',
            }).then(() => {
                if (this.educationList[i].caseId) {
                    couldInfoDelete(this.educationList[i].caseId).then(() => {
                        this.$message({
                            type: 'success',
                            message: '删除成功!',
                        })
                        this.getCloudAllList()
                    })
                } else {
                    if (this.educationList.length == 1) return this.$message.warning('最少有一项')
                    this.educationList.splice(i, 1)
                    this.$message({
                        type: 'success',
                        message: '删除成功!',
                    })
                }
            })
        },
        // 省
        onChangeProvince(data) {
            if (data.value.indexOf('---') == -1) {
                this.province = data.value
                this.city = '--- 市 ---'
                this.userForm.city = this.province + '-' + this.city
            } else {
                this.province = ''
            }
        },
        // 市
        onChangeCity(data) {
            if (data.value.indexOf('---') == -1) {
                this.city = data.value
                this.userForm.city = this.province + '-' + this.city
            } else {
                this.city = ''
            }
        },
    },
}
</script>

<style scoped>
.userAbility {
    background: #f2f3f7;
    padding-bottom: 40px;
    overflow: hidden;
}
.container {
    width: 1200px;
    margin: auto;
}
.topTitle {
    font-weight: bold;
    font-size: 32px;
    color: #1a1a1a;
    display: flex;
    align-items: center;
    margin: 40px auto;
}
.colra {
    background: linear-gradient(-90deg, #fa2c3f 0%, #792bf9 100%);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
}
.stepBoxBtn {
    display: flex;
    align-items: center;
    justify-content: center;
    margin: 30px 0;
}
.backBtn {
    width: 130px;
    height: 40px;
    border-radius: 4px;
    border: 1px solid #0066eb;
    margin-right: 16px;
    line-height: 40px;
    text-align: center;
    font-weight: 500;
    font-size: 15px;
    color: #0066eb;
    cursor: pointer;
}
.nextBtn {
    width: 130px;
    height: 40px;
    background: #0066eb;
    border-radius: 4px;
    line-height: 40px;
    text-align: center;
    font-weight: 500;
    font-size: 15px;
    color: #ffffff;
    cursor: pointer;
}
.contentBig {
    background: #ffffff;
    padding: 40px;
    box-sizing: border-box;
}
.stepBox {
    margin: 30px auto;
    border-bottom: 2px dashed #ebebeb;
}
.stepBox >>> .el-steps {
    flex: 1;
}
.stepBox >>> .el-step__icon {
    width: 60px;
    height: 60px;
    background: #f2f3f7;
    border: unset;
}

.stepBox >>> .el-step__line {
    top: 30px !important;
    background: #f2f3f7;
    height: 3px;
}
/* 已完成 */
.stepBox >>> .el-step__head.is-finish {
    color: #f2f3f7;
    border-color: unset;
}
.stepBox >>> .el-step__title.is-finish {
    font-weight: 500;
    font-size: 15px;
    color: #666666;
}
.stepBox >>> .el-step__title.is-wait {
    font-weight: 500;
    font-size: 15px;
    color: #666666;
}
.stepBox >>> .el-step__title.is-process {
    font-weight: 500;
    font-size: 15px;
    color: #0066eb;
}
/* 当前 */
.stepBox >>> .el-step__head.is-process .el-step__icon {
    background: #0066eb !important;
}
.workIt >>> .distpicker-address-wrapper label select {
    width: 247px !important;
}
.addWork {
    width: 150px;
    height: 40px;
    background: linear-gradient(90deg, #0066eb, #2783fc);
    border-radius: 4px;
    font-weight: 500;
    font-size: 15px;
    color: #ffffff;
    line-height: 40px;
    text-align: center;
    margin-bottom: 30px;
}
.delWork {
    position: absolute;
    top: 20px;
    right: 20px;
    margin-left: 20px;
    display: flex;
    align-items: center;
    cursor: pointer;
    font-weight: 500;
    font-size: 14px;
    color: #fd4747;
}
.saveWork {
    margin-right: 30px;
    cursor: pointer;
    font-weight: 500;
    font-size: 14px;
    color: #23ca7d;
}
.workIt {
    border-radius: 4px;
    border: 1px solid #f2f2f2;
    margin-bottom: 20px;
    padding: 26px;
    box-sizing: border-box;
    position: relative;
}
.workIt >>> .el-input {
    width: 500px;
}
.workIt >>> .el-date-editor {
    width: 231px;
}
.workIt >>> .el-textarea__inner {
    width: 500px;
}
.activeTitle {
    display: flex;
    align-items: center;
    font-weight: bold;
    font-size: 20px;
    color: #000000;
    margin-bottom: 30px;
}
.activeTitLine {
    width: 5px;
    height: 17px;
    background: #0066eb;
    margin-right: 10px;
}
.applytip {
    font-weight: 500;
    font-size: 14px;
    color: #808080;
    margin-bottom: 30px;
    margin-top: -10px;
}
.applySuccess {
    display: flex;
    align-items: center;
    font-weight: 500;
    font-size: 18px;
    color: #23ca7d;
}
.applySuccess img {
    width: 27px;
    height: 27px;
    margin-right: 10px;
}
.applyIng {
    width: 275px;
    height: 50px;
    background: #fbefe1;
    border-radius: 4px;
    font-weight: 500;
    font-size: 18px;
    color: #fa912a;
    display: flex;
    align-items: center;
    justify-content: center;
    margin: 40px auto;
}
.applySuccessAll {
    width: 275px;
    height: 50px;
    background: #e0f9ed;
    border-radius: 4px;
    font-weight: 500;
    font-size: 18px;
    color: #23ca7d;
    display: flex;
    align-items: center;
    justify-content: center;
    margin: 40px auto;
}
.applyFail {
    width: 275px;
    height: 50px;
    background: #fceded;
    border-radius: 4px;
    font-weight: 500;
    font-size: 18px;
    color: #fc4444;
    display: flex;
    align-items: center;
    justify-content: center;
    margin: 40px auto;
}
.flexbox {
    display: flex;
    align-items: center;
}
.endtime >>> .el-form-item__content {
    margin-left: 0px !important;
}
.active5 >>> .el-upload--picture-card {
    width: 500px;
    height: 190px;
    line-height: 190px;
}
.active5 >>> .el-upload-list__item {
    width: 500px !important;
    height: 190px !important;
    line-height: 190px !important;
}
.active5 >>> .el-upload-list__item-status-label {
    display: flex !important;
    align-items: center !important;
    justify-content: center !important;
}
</style>