<template>
    <el-scrollbar > 
        <el-row class="title_body">
            <el-col :span="20">
                <span class="cont_header_title"><i class="el-icon-s-order"></i>基本信息</span>
            </el-col>
            <el-col :span="4" class="edit_buttion">
                <el-button
                icon="el-icon-edit"
                size="small"
                type="text"
                @click="showEditBase(myCont)"
                >编辑</el-button>
            </el-col>
        </el-row>
        <el-divider style="margin:0"></el-divider>
        <el-row>
            <el-col :span="24" class="cont_body">

                <template>
                    <el-descriptions class="margin-top" :column="6" direction="vertical">
                        
                        <el-descriptions-item label-class-name="my_label_c" content-class-name="bottment_cont" label="曾用名"><div class="bottment_line">{{ myCont.nameusedbefore }}</div></el-descriptions-item>
                        <el-descriptions-item label-class-name="my_label_c" content-class-name="bottment_cont" label="性别"><div class="bottment_line">{{ replace.gender }}</div></el-descriptions-item>
                        <el-descriptions-item label-class-name="my_label_c" content-class-name="bottment_cont" label="民族"><div class="bottment_line">{{ myCont.myfolk }}</div></el-descriptions-item>
                        <el-descriptions-item label-class-name="my_label_c" content-class-name="bottment_cont" label="健康状况"><div class="bottment_line">{{ replace.health }}</div></el-descriptions-item>
                        <el-descriptions-item label-class-name="my_label_c" content-class-name="bottment_cont" label="婚姻状况"><div class="bottment_line">{{ replace.maritalstatus }}</div></el-descriptions-item>
                        <el-descriptions-item label-class-name="my_label_c" content-class-name="bottment_cont" label="政治面貌"><div class="bottment_line">{{ replace.politicaloutlook }}</div></el-descriptions-item>
                        <el-descriptions-item label-class-name="my_label_c" content-class-name="bottment_cont" label="出生日期"><div class="bottment_line">{{ myCont.birthdaytime }}</div></el-descriptions-item>
                        <el-descriptions-item label-class-name="my_label_c" content-class-name="bottment_cont" label="身份证号"><div class="bottment_line">{{ myCont.idcardno }}</div></el-descriptions-item>
                        <el-descriptions-item label-class-name="my_label_c" content-class-name="bottment_cont" label="身份证有效期开始"><div class="bottment_line">{{ myCont.idcardstarttimedata }}</div></el-descriptions-item>
                        <el-descriptions-item label-class-name="my_label_c" content-class-name="bottment_cont" label="身份证有效期结束"><div class="bottment_line">{{ myCont.idcardendtimedata }}</div></el-descriptions-item>
                        <el-descriptions-item label-class-name="my_label_c" content-class-name="bottment_cont" label="身份证地址"><div class="bottment_line">{{ myCont.idcardaddress }}</div></el-descriptions-item>
                        <el-descriptions-item label-class-name="my_label_c" content-class-name="bottment_cont" label="身份证签发机关"><div class="bottment_line">{{ myCont.idcardIssued }}</div></el-descriptions-item>
                        <el-descriptions-item label-class-name="my_label_c" content-class-name="bottment_cont" label="手机号码"><div class="bottment_line">{{ myCont.mobilephone }}</div></el-descriptions-item>
                        <el-descriptions-item label-class-name="my_label_c" content-class-name="bottment_cont" label="现居住地址"><div class="bottment_line">{{ myCont.currentresidence }}</div></el-descriptions-item>
                        <el-descriptions-item label-class-name="my_label_c" content-class-name="bottment_cont" label="籍贯"><div class="bottment_line">{{ myCont.nativeplace }}</div></el-descriptions-item>
                        <el-descriptions-item label-class-name="my_label_c" content-class-name="bottment_cont" label="电子邮件"><div class="bottment_line">{{ myCont.email }}</div></el-descriptions-item>
                        <el-descriptions-item label-class-name="my_label_c" content-class-name="bottment_cont" label="内线电话"><div class="bottment_line">{{ myCont.internaltelephone }}</div></el-descriptions-item>
                        <el-descriptions-item label-class-name="my_label_c" content-class-name="bottment_cont" label="星座"><div class="bottment_line">{{ replace.constellationing }}</div></el-descriptions-item>
                        <el-descriptions-item label-class-name="my_label_c" content-class-name="bottment_cont" label="雇佣类型"><div class="bottment_line">{{ replace.hireclass }}</div></el-descriptions-item>
                        <el-descriptions-item label-class-name="my_label_c" content-class-name="bottment_cont" label="用工关系"><div class="bottment_line">{{ replace.emptype }}</div></el-descriptions-item>
                        <el-descriptions-item label-class-name="my_label_c" content-class-name="bottment_cont" label="入职日期"><div class="bottment_line">{{ myCont.entrydatetime }}</div></el-descriptions-item>
                        <el-descriptions-item label-class-name="my_label_c" content-class-name="bottment_cont" label="试用期"><div class="bottment_line">{{ myCont.probationperiod }}月</div></el-descriptions-item>
                        <el-descriptions-item label-class-name="my_label_c" content-class-name="bottment_cont" label="预计转正日期"><div class="bottment_line">{{ myCont.planformaldatetime }}</div></el-descriptions-item>
                        <el-descriptions-item label-class-name="my_label_c" content-class-name="bottment_cont" label="参加工作日期"><div class="bottment_line">{{ myCont.jobstartdatestr }}</div></el-descriptions-item>
                        <el-descriptions-item label-class-name="my_label_c" content-class-name="bottment_cont" label="是否为退役军人"><div class="bottment_line">{{ replace.isveterans }}</div></el-descriptions-item>
                        <el-descriptions-item label-class-name="my_label_c" content-class-name="bottment_cont" label="退役证编号"><div class="bottment_line">{{ myCont.veteransnumber }}</div></el-descriptions-item>
                        <el-descriptions-item label-class-name="my_label_c" content-class-name="bottment_cont" label="护照号码"><div class="bottment_line">{{ myCont.passportno }}</div></el-descriptions-item>
                        <el-descriptions-item label-class-name="my_label_c" content-class-name="bottment_cont" label="国际区号" ><div class="bottment_line">{{ myCont.globalroaming }}</div></el-descriptions-item>
                        <el-descriptions-item label-class-name="my_label_c" content-class-name="bottment_cont" label="绑定微信" ><div class="bottment_line">{{ myCont.wechat }}</div></el-descriptions-item>
                        <el-descriptions-item label-class-name="my_label_c" content-class-name="bottment_cont" label="绑定企业微信"><div class="bottment_line">{{ myCont.workwechat }}</div></el-descriptions-item>
                    </el-descriptions>
                </template>


            </el-col>
        </el-row>
        <el-row class="title_body">
            <el-col :span="20">
                <span class="cont_header_title"><i class="el-icon-s-order"></i>行政组织关系</span>
            </el-col>
            <el-col :span="4" class="edit_buttion">
                <el-button
                icon="el-icon-edit"
                size="small"
                type="text"
                @click="showEditBaseOrg(myCont)"
                >编辑</el-button>
            </el-col>
        </el-row>
        <el-divider style="margin:0"></el-divider>
        <el-row>
            <el-col :span="24" class="cont_body">
                <template>
                    <el-descriptions class="margin-top" :column="5" direction="vertical">
                        <el-descriptions-item label-class-name="my_label_c" content-class-name="bottment_cont" label="公司"><div class="bottment_line">{{ myCont.companyname }}</div></el-descriptions-item>
                        <el-descriptions-item label-class-name="my_label_c" content-class-name="bottment_cont" label="部门"><div class="bottment_line">{{ myCont.maindeparmentname }}  <i v-if="myCont.sunmaindeparmentname"> / </i>{{ myCont.sunmaindeparmentname }} <i v-if="myCont.workpostname"> / </i>{{ myCont.workpostname }} </div></el-descriptions-item>
                        <el-descriptions-item label-class-name="my_label_c" content-class-name="bottment_cont" label="班组"><div class="bottment_line">{{ myCont.teamname }}</div></el-descriptions-item>
                        <el-descriptions-item label-class-name="my_label_c" content-class-name="bottment_cont" label="岗位"><div class="bottment_line">{{ myCont.positionname }}</div></el-descriptions-item>
                        <el-descriptions-item label-class-name="my_label_c" content-class-name="bottment_cont" label="职务"><div class="bottment_line">{{ replace.jobleve }}{{ myCont.jobidname }} <span v-if="myCont.jobclassname">（ {{ myCont.jobclassname }} ）</span> </div></el-descriptions-item>
                    </el-descriptions>
                </template>
            </el-col>
        </el-row>
        <!--编辑员工基本信息-->
        <el-dialog :close-on-click-modal="false" :visible.sync="editSetUp.cont" title="编辑基本信息" :before-close="closeEditContDialog"  width="60%">
            <el-form ref="editContData" :model="editContData" :rules="editContRules" label-width="140px"  class="demo-ruleForm">

                <el-row>
                    <el-col :span="12">
                        <el-form-item label="手机号码" prop="mobilephone">
                            <el-input v-model="editContData.mobilephone" placeholder="请输入手机号码"></el-input>
                        </el-form-item>
                    </el-col>
                    <el-col :span="12">
                        <el-form-item label="身份证号" prop="idcardno">
                            <el-input v-model="editContData.idcardno"  placeholder="请输入身份证号"></el-input>
                        </el-form-item>
                    </el-col>
                </el-row>
                <el-row>
                    <el-col :span="12">
                        <el-form-item label="入职日期" prop="joinedDate">
                            <el-date-picker
                                format="yyyy 年 MM 月 dd 日"
                                @change="entryChangeDate"
                                v-model="joinedDate"
                                type="date"
                                placeholder="选择日期">
                            </el-date-picker>
                        </el-form-item>
                    </el-col>
                    <el-col :span="12">
                        <el-form-item label="试用期"  prop="probationperiod">
                            <el-input-number v-model="editContData.probationperiod"  :min="1" :max="12" label="试用期" placeholder="试用期" @change="handleChange"></el-input-number>
                        </el-form-item>
                    </el-col>
                </el-row>
                <el-row>
                    <el-col :span="12">
                        <el-form-item label="预计转正日期" >
                            <el-input v-model="confirmationdateval" disabled placeholder="预计转正日期"></el-input>
                        </el-form-item>
                    </el-col>
                    <el-col :span="12">
                        <el-form-item label="参加工作日期" >
                            <el-date-picker
                                format="yyyy 年 MM 月 dd 日"
                                @change="workdayChange"
                                v-model="workingdate"
                                type="date"
                                placeholder="选择日期">
                            </el-date-picker>
                        </el-form-item>
                    </el-col>
                </el-row>
                

                <el-row>
                    <el-col :span="12">
                        <el-form-item label="曾用名" >
                            <el-input v-model="editContData.nameusedbefore"  placeholder="曾用名"></el-input>
                        </el-form-item>
                    </el-col>
                    <el-col :span="12">
                        <el-form-item label="性别" >
                            <el-select v-model="editContData.gender" placeholder="请选择性别">
                                <el-option v-for="itemGender in genderList" :label="itemGender.tittle" :value="itemGender.id" :key="itemGender.id"></el-option>
                            </el-select>
                        </el-form-item>
                    </el-col>
                </el-row>
                <el-row>
                    <el-col :span="12">
                        <el-form-item label="民族" >
                            <el-input v-model="editContData.myfolk"  placeholder="民族"></el-input>
                        </el-form-item>
                    </el-col>
                    <el-col :span="12">
                        <el-form-item label="政治面貌" >
                            <el-select v-model="editContData.politicaloutlook" placeholder="请选择政治面貌">
                                <el-option v-for="itemPoliti in politicsList" :label="itemPoliti.tittle" :value="itemPoliti.id" :key="itemPoliti.id"></el-option>
                            </el-select>
                        </el-form-item>
                    </el-col>
                </el-row>
                <el-row>
                    <el-col :span="12">
                        <el-form-item label="健康状况" >
                            <el-select v-model="editContData.health" placeholder="请选择健康状况">
                                <el-option v-for="itemHeal in healthList" :label="itemHeal.tittle" :value="itemHeal.id" :key="itemHeal.id"></el-option>
                            </el-select>
                        </el-form-item>
                    </el-col>
                    <el-col :span="12">
                        <el-form-item label="生日" >
                            <el-date-picker
                                format="yyyy 年 MM 月 dd 日"
                                @change="birthdayChange"
                                v-model="birthday"
                                type="date"
                                placeholder="选择日期">
                            </el-date-picker>
                        </el-form-item>
                    </el-col>
                </el-row>
                <el-row>
                    <el-col :span="12">
                        <el-form-item label="身份证有效期开始" >
                            <el-date-picker
                                format="yyyy 年 MM 月 dd 日"
                                @change="idCodeTimeStartChange"
                                v-model="idCardStartTimeStr"
                                type="date"
                                placeholder="选择日期">
                            </el-date-picker>
                        </el-form-item>
                    </el-col>
                    <el-col :span="12">
                        <el-form-item label="身份证有效期结束" >
                            <el-date-picker
                                format="yyyy 年 MM 月 dd 日"
                                @change="idCodeTimeEndChange"
                                v-model="idCardEndTimeStr"
                                type="date"
                                placeholder="选择日期">
                            </el-date-picker>
                        </el-form-item>
                    </el-col>
                </el-row>
                <el-row>
                    <el-col :span="12">
                        <el-form-item label="身份证地址" >
                            <el-input v-model="editContData.idcardaddress"  placeholder="请输入身份证地址"></el-input>
                        </el-form-item>
                    </el-col>
                    <el-col :span="12">
                        <el-form-item label="身份证签发机关" >
                            <el-input v-model="editContData.idcardIssued"  placeholder="请输入身份证签发机关"></el-input>
                        </el-form-item>
                    </el-col>
                </el-row>

                <el-row>
                    <el-col :span="12">
                        <el-form-item label="现居住地址" >
                            <el-input v-model="editContData.currentresidence" placeholder="请输入现居住地址"></el-input>
                        </el-form-item>
                    </el-col>
                    <el-col :span="12">
                        <el-form-item label="籍贯" >
                            <el-input v-model="editContData.nativeplace" placeholder="请输入籍贯"></el-input>
                        </el-form-item>
                    </el-col>
                </el-row>
                <el-row>
                    <el-col :span="12">
                        <el-form-item label="电子邮件" >
                            <el-input v-model="editContData.email" placeholder="请输入电子邮件"></el-input>
                        </el-form-item>
                    </el-col>
                    <el-col :span="12">
                        <el-form-item label="内线电话" >
                            <el-input v-model="editContData.internaltelephone" placeholder="请输入内线电话"></el-input>
                        </el-form-item>
                    </el-col>
                </el-row>
                <el-row>
                    <el-col :span="12">
                        <el-form-item label="雇佣类型" >
                            <el-select v-model="editContData.hireclass" placeholder="请选择雇佣类型">
                                <el-option v-for="itemEmploy in employmentType" :label="itemEmploy.tittle" :value="itemEmploy.id" :key="itemEmploy.id"></el-option>
                            </el-select>
                        </el-form-item>
                    </el-col>
                    <el-col :span="12">
                        <el-form-item label="用工关系" >
                            <el-select v-model="editContData.emptype" placeholder="请选择用工关系">
                                <el-option v-for="itemEmpType in emptypeList" :label="itemEmpType.tittle" :value="itemEmpType.id" :key="itemEmpType.id"></el-option>
                            </el-select>
                        </el-form-item>
                    </el-col>
                </el-row>
                
                <el-row>
                    <el-col :span="12">
                        <el-form-item label="是否为退役军人">
                            <el-select v-model="editContData.isveterans" placeholder="请选择是否为退役军人">
                                <el-option label="是" :value="1"></el-option>
                                <el-option label="否" :value="2"></el-option>
                            </el-select>
                        </el-form-item>
                    </el-col>
                    <el-col :span="12">
                        <el-form-item label="退役证编号" >
                            <el-input v-model="editContData.veteransnumber"  placeholder="请输入退役证编号"></el-input>
                        </el-form-item>
                    </el-col>
                </el-row>
                <el-row>
                    <el-col :span="12">
                        <el-form-item label="护照号码" >
                            <el-input v-model="editContData.passportno"  placeholder="请输入护照号码"></el-input>
                        </el-form-item>
                    </el-col>
                    <el-col :span="12">
                        <el-form-item label="国际区号" >
                            <el-input v-model="editContData.globalroaming"  placeholder="请输入国际区号"></el-input>
                        </el-form-item>
                    </el-col>
                </el-row>
                <el-row>
                    <el-col :span="12">
                        <el-form-item label="绑定微信" >
                            <el-input v-model="editContData.wechat"  placeholder="请输入微信OpenId"></el-input>
                        </el-form-item>
                    </el-col>
                    <el-col :span="12">
                        <el-form-item label="绑定企业微信" >
                            <el-input v-model="editContData.workwechat"  placeholder="请输入企业微信OpenId"></el-input>
                        </el-form-item>
                    </el-col>
                </el-row>
                <el-row>
                    <el-col :span="12">
                        <el-form-item label="星座" >
                            <el-select v-model="editContData.constellationing" placeholder="请选择星座">
                                <el-option v-for="itemConstell in constellationList" :label="itemConstell.tittle" :value="itemConstell.id" :key="itemConstell.id"></el-option>
                            </el-select>
                        </el-form-item>
                    </el-col>
                    <el-col :span="12">
                        <el-form-item label="婚姻状况" >
                            <el-select v-model="editContData.maritalstatus" placeholder="婚姻状况">
                                <el-option v-for="itemConstell in marriageList" :label="itemConstell.tittle" :value="itemConstell.id" :key="itemConstell.id"></el-option>
                            </el-select>
                        </el-form-item>
                        
                    </el-col>
                </el-row>
                
            </el-form>
            <template #footer class="el_dialog__footer">
                <div class="dialog-footer ">  
                    <el-button size="small" type="primary" @click="editContContsubmit" :loading="editContIsTrue">确 定</el-button> 
                    <el-button size="small" @click="closeEditContDialog">取 消</el-button>
                </div>
            </template>
        </el-dialog>

        <!--编辑行政组织-->
        <el-dialog :close-on-click-modal="false" :visible.sync="editSetUp.org" title="编辑行政组织关系" :before-close="closeEditOrgDialog"  width="40%">
            <el-form ref="editForm" :model="ediOrgCont" :rules="editOrgRules" label-width="100px" >
                <el-form-item label="归属组织" prop="orglist">
                    <el-cascader clearable v-model="ediOrgCont.orglist" :options="grouplist" @change="orgChange" :props="propsdepart" style="width:100%"></el-cascader>
                </el-form-item>
                <el-form-item label="岗位"  prop="position">
                    <el-select filterable v-model="ediOrgCont.position" clearable placeholder="请选择" >
                        <el-option
                            v-for="item in postListAdd"
                            :key="item.id"
                            :label="item.name"
                            :value="item.id">
                        </el-option>
                    </el-select>
                </el-form-item>
                <el-form-item label="职务" prop="jobid">
                    <el-select filterable v-model="ediOrgCont.jobid" clearable placeholder="请选择">
                        <el-option
                            v-for="item in dutieslist"
                            :key="item.id"
                            :label="item.name"
                            :value="item.id">
                        </el-option>
                    </el-select>
                </el-form-item>
                <el-form-item label="职务等级" prop="jobleve">
                    <el-select filterable v-model="ediOrgCont.jobleve" clearable placeholder="请选择">
                        <el-option
                            v-for="item in positiongrade"
                            :key="item.id"
                            :label="item.tittle"
                            :value="item.id">
                        </el-option>
                    </el-select>
                </el-form-item>
                <el-form-item label="班组" prop="teamid">
                    <el-select filterable v-model="ediOrgCont.teamid" clearable placeholder="请选择">
                        <el-option
                            v-for="item in teamcontlist"
                            :key="item.id"
                            :label="item.name"
                            :value="item.id">
                        </el-option>
                    </el-select>
                </el-form-item>
            </el-form>
            <template #footer class="el_dialog__footer">
                <div class="dialog-footer "> 
                    <el-button size="small" type="primary" @click="editOrgContsubmit" :loading="editOrgIsTrue">确 定</el-button> 
                    <el-button size="small" @click="closeEditOrgDialog">取 消</el-button>
                </div>
            </template>
        </el-dialog>
    </el-scrollbar>
</template>
<script>
import {  positionlist,archiveslist,teamcontlist,orgThreeList,positionlistIsMe,dutieslist } from "@/api/personnel/post";
import { getOnlyOnePeopleCont,editManOrgCont,editManPeopleCont } from "@/api/systemaccredit/systemhrapi"
import { peopleMethod,judgeArray } from "@/api/people/peopledata"
import {
        getgroupdepartmap,
    } from '@/api/duty/group' //组织建构
import { calculationDate } from "@/api/time/dateval"

export default {
    name:"peopleinfor",
    props:['userid'],
   
    data() {
        return {
            confirmationdateval:"",     //转正日期
            joinedDate:"",    //入职日期
            birthday:"",    //生日
            workingdate:"", //参加工作日期
            idCardStartTimeStr:"", //身份证有效期开始
            idCardEndTimeStr:"", //身份证有效期结束
            genderList:peopleMethod.sexData,    //性别
            healthList:peopleMethod.healthList, //健康状况
            politicsList:peopleMethod.politicsList, //政治面貌
            constellationList:peopleMethod.constellationList, //星座
            employmentType:peopleMethod.employmentType, //雇佣类型
            emptypeList:peopleMethod.emptypeList, //	用工关系
            marriageList:peopleMethod.marriageList, //	婚姻状态
            editContIsTrue:false,
            positiongrade:peopleMethod.positiongrade, //入职等级
            editOrgIsTrue:false,
            grouplist:[], //部门列表
            dutieslist:[], //职务
            postListAdd: [],           //岗位
            teamcontlist:[],           //班组
            propsdepart: {
                // checkStrictly: true,
                value: "id",
                label: "name",
                children: "children",
                // emitPath:false,
                // multiple: false
            },  //关联部门
            ediOrgCont:{},  //  行政组织
            myCont:{},          //个人信息
            replace:{
                probationperiod: 0,
                isveterans: "否",
                number: "300450",
                name: "秦东",
                gender: "男",
                adminorg: 0,
                position: 0,
                team: 0,
                jobid: 0,
                positiongrade: 0,
                emptype: 0,
                hiretype: 0,
                maritalstatus: 0,
                nation: "",
                mobilephone: "",
                health: 0,
                workingdate: "",
                icon: "",
                confirmationdate: "",
                entrydate: "",
                birthday: "",
                idcardno: "",
                idcardstartdate: "",
                idcardenddate: "",
                politicaloutlook: 0,
                weorwechat: "",
                constellation: 7,
                veteransnumber: "",
                globalroaming: "",
                passportno: "",
                nativeplace: "",
                currentresidence: ""
            },
            editSetUp:{
                cont:false,
                org:false
            },
            editContData:{
                mobilephone:"",     //手机号码
                idcardno:"", //身份证号
                entrydatetime:"", //入职日期
                probationperiod:"", //试用期
                confirmationdate:"",// 预计转正日期
                jobstartdatestr:"", //参加工作日期
                nameusedbefore:"",      //曾用名
                gender:1,   //性别
                myfolk:"",  //民族
                politicaloutlook:0, //政治面貌
                health:1,   //健康状况
                birthdaytime:"",    //生日
                idcardstarttimedata:"", //身份证有效期开始
                idcardendtimedata:"", //身份证有效期结束
                idcardaddress:"",   //身份证地址
                idcardIssued:"",    //身份证签发机关
                currentresidence:"",    //现居住地址
                nativeplace:"", //籍贯
                email:"", //电子邮件
                internaltelephone:"",   //内线电话
                hireclass:1,    //雇佣类型
                emptype:1,  //用工关系
                isveterans:2, //是否为退役军人
                veteransnumber:"",  //退役证编号
                passportno:"",  //护照号码
                globalroaming:"",   //国际区号
                wechat:"",  //绑定微信
                workwechat:"", //绑定企业微信
                constellationing:1,   //星座
            },        //编辑个人信息
            editOrgRules:{      //验证规则
                orglist: [{ required: true, message: '必填', trigger: 'blur' }],
                position: [{ required: true, message: '必填', trigger: 'blur' }],
                jobid: [{ required: true, message: '必填', trigger: 'blur' }],
                jobleve: [{ required: true, message: '必填', trigger: 'blur' }],
                teamid: [{ required: true, message: '必填', trigger: 'blur' }], 
            },
            editContData:{},        //编辑个人信息
            editContRules:{
                idcardno: [
                    { required: true, message: '必填', trigger: 'blur' }
                ],
                mobilephone: [
                    { required: true, message: '必填', trigger: 'blur' },
                    { min: 11, max: 11, message: "请输入11位手机号码", trigger: "blur" },
                    {
                        pattern: /^(13[0-9]|14[579]|15[0-3,5-9]|16[6]|17[0135678]|18[0-9]|19[89])\d{8}$/,
                        message: "请输入正确的手机号码", 
                        trigger: "blur"
                    },
                    
                ],
                
                probationperiod: [
                    { type: 'number', required: true, message: '请输入试用期', trigger: 'change' }
                ],
            },          //编辑个人信息验证规则
            
        }
    },
    
    created(){
        console.log("userId---------->",this.userid)  
        this.getMyCont(this.userid)
        this.getDutieslist();
        let myId = this.userid * 1
        this.ediOrgCont.id = myId.toString()
    },
    methods:{
        // 获取部门
        async getGrouplist(){
            let sendData = {
                id:313,
                all:1
            };
            const res = await getgroupdepartmap(sendData)
            this.grouplist=res.data
        },
        //选择行政组织
        orgChange(val){
            if(val){
                if(judgeArray(val) && val.length > 0){
                    let postId = val[val.length-1];
                    this.getPostAdd(postId);
                }else{
                    this.postListAdd = [];
                }
            }else{
                this.postListAdd = [];
            }
            // 
            // this.ediOrgCont.position = null
            console.log("选择行政组织---------------->",val)
        },
        //获取刚问列表
        async getPostAdd(val) {
            const from = {
                organization: val.toString(),
                page: 1,
                pagesize: 500,
            };
            const res = await positionlistIsMe(from);
            this.postListAdd = res.data.list;
            console.log("获取刚问列表---------------->",res)
        },
        //获取职务
        async getDutieslist(){
            let res = await dutieslist();
            this.dutieslist = res.data.list
            console.log("班组---------------->",res,res.list)
        },
        //获取班组
        async getTeam(){
            
            let res = await teamcontlist();
            this.teamcontlist = res.data.list
            console.log("班组---------------->",res)
        },
        //获取人员基本信息
        async getMyCont(id){
            let sendData = {
                id:id,
                idstr: id.toString(),
            }
            let res = await getOnlyOnePeopleCont(sendData);
            this.myCont = res.data
            if(!this.myCont.probationperiod) this.myCont.probationperiod = 3;
            //处理性别
            peopleMethod.sexData.forEach(item=>{
                if(item.id == this.myCont.gender){
                    this.replace.gender = item.tittle
                }
            })
            //雇佣类型
            peopleMethod.employmentType.forEach(item=>{
                console.log("雇佣类型--------->",item,this.myCont.hireclass)  
                if(item.id == this.myCont.hireclass){
                    this.replace.hireclass = item.tittle
                }
            })
            //用工关系
            peopleMethod.emptypeList.forEach(item=>{
                if(item.id == this.myCont.emptype){
                    this.replace.emptype = item.tittle
                }
            })
            //健康状况
            peopleMethod.healthList.forEach(item=>{
                if(item.id == this.myCont.health){
                    this.replace.health = item.tittle
                }
            })
            //婚姻状态
            peopleMethod.marriageList.forEach(item=>{
                if(item.id == this.myCont.maritalstatus){
                    this.replace.maritalstatus = item.tittle
                }
            })
            //星座
            peopleMethod.constellationList.forEach(item=>{
                if(item.id == this.myCont.constellationing){
                    this.replace.constellationing = item.tittle
                }
            })
            //政治面貌
            peopleMethod.politicsList.forEach(item=>{
                if(item.id == this.myCont.politicaloutlook){
                    this.replace.politicaloutlook = item.tittle
                }
            })
            //判断是否未退役军人
            if(this.myCont.isveterans == 1){
                this.replace.isveterans = "是" 
            }else{
                this.replace.isveterans = "否"
            }
            //职务等级
            peopleMethod.positiongrade.forEach(item=>{
                if(item.id == this.myCont.jobleve){
                    this.replace.jobleve = item.tittle
                }
            })
            
            
            console.log("获取人员基本信息--------->",this.myCont.isveterans)  
        },
        //编辑基本信息
        showEditBase(val){
            this.editSetUp.cont = true
            this.editContData.birthdaytime = val.birthdaytime
            console.log("编辑基本信息--------->",val)  
            this.confirmationdateval = this.myCont.planformaldatetime     //转正日期
            this.joinedDate = this.myCont.entrydatetime    //入职日期
            this.birthday = this.myCont.birthdaytime    //生日
            this.workingdate = this.myCont.jobstartdatestr //参加工作日期
            this.idCardStartTimeStr = this.myCont.idcardstarttimedata //身份证有效期开始
            this.idCardEndTimeStr = this.myCont.idcardendtimedata //身份证有效期结束

            this.editContData = {
                id:this.myCont.idstr,  
                mobilephone:this.myCont.mobilephone,     //手机号码
                idcardno:this.myCont.idcardno, //身份证号
                entrydatetime:this.myCont.entrydatetime, //入职日期
                probationperiod:this.myCont.probationperiod?this.myCont.probationperiod:3, //试用期
                confirmationdate:this.myCont.planformaldatetime,// 预计转正日期
                jobstartdatestr:this.myCont.jobstartdatestr, //参加工作日期
                nameusedbefore:this.myCont.nameusedbefore,      //曾用名
                gender:this.myCont.gender,   //性别
                myfolk:this.myCont.myfolk,  //民族
                politicaloutlook:this.myCont.politicaloutlook, //政治面貌
                health:this.myCont.health,   //健康状况
                birthdaytime:this.myCont.birthdaytime,    //生日
                idcardstarttimedata:this.myCont.idcardstarttimedata, //身份证有效期开始
                idcardendtimedata:this.myCont.idcardendtimedata, //身份证有效期结束
                idcardaddress:this.myCont.idcardaddress,   //身份证地址
                idcardIssued:this.myCont.idcardIssued,    //身份证签发机关
                currentresidence:this.myCont.currentresidence,    //现居住地址
                nativeplace:this.myCont.nativeplace, //籍贯
                email:this.myCont.email, //电子邮件
                internaltelephone:this.myCont.internaltelephone,   //内线电话
                hireclass:this.myCont.hireclass,    //雇佣类型
                emptype:this.myCont.emptype,  //用工关系
                isveterans:this.myCont.isveterans, //是否为退役军人
                veteransnumber:this.myCont.veteransnumber,  //退役证编号
                passportno:this.myCont.passportno,  //护照号码
                globalroaming:this.myCont.globalroaming,   //国际区号
                wechat:this.myCont.wechat,  //绑定微信
                workwechat:this.myCont.workwechat, //绑定企业微信
                constellationing:this.myCont.constellationing,   //星座
                maritalstatus:this.myCont.maritalstatus
            };        //编辑个人信息
        },
        //编辑行政组织
        showEditBaseOrg(val){
            console.log("编辑行政组织--------->",val) 
            this.getGrouplist() 
            this.getTeam()
            this.getPostAdd(this.myCont.adminorg)
            this.ediOrgCont.orglist = this.myCont.allorglist
            if(this.myCont.teamid != 0){
                this.ediOrgCont.teamid = this.myCont.teamid
            }
            if(this.myCont.jobid != 0){
                this.ediOrgCont.jobid = this.myCont.jobid
            }
            if(this.myCont.position != 0){
                this.ediOrgCont.position = this.myCont.position
            }
            if(this.myCont.jobleve != 0){
                this.ediOrgCont.jobleve = this.myCont.jobleve
            }
            
            this.ediOrgCont.id = this.myCont.id.toString()
            this.editSetUp.org = true
            console.log("编辑行政组织-----123---->",this.joinedDate) 
        },
        //关闭编辑行政组织框
        closeEditOrgDialog(){
            this.editOrgIsTrue = false
            this.editSetUp.org = false
            this.initOrgCont()
        },
        //提交行政组织修改数据
        async editOrgContsubmit(){
            this.editOrgIsTrue = true
            console.log("编辑行政组织--------->",this.ediOrgCont) 
            this.$refs.editForm.validate(async valid => {
                if (valid) {
                    if(this.ediOrgCont.id == ""){
                        this.tispOrgBox('参数错误！不可提交！请刷新页面！','error');
                        return
                    }
                    if(this.ediOrgCont.orglist){
                        if(judgeArray(this.ediOrgCont.orglist) && this.ediOrgCont.orglist.length > 0){
                            let orgAry = this.ediOrgCont.orglist
                            console.log("编辑行政组织----223----->",orgAry.length) 
                            let postId = orgAry[orgAry.length-1];
                            this.ediOrgCont.orgid = postId
                        }else{
                            this.tispOrgBox('请选择归属行政组织！','error');
                            return
                        }
                    }else{
                        this.tispOrgBox('请选择归属行政组织！','error');
                        return
                    }
                    if(this.ediOrgCont.position){
                        if(this.ediOrgCont.position == 0 || this.ediOrgCont.position == ""  || this.ediOrgCont.position == null){
                            this.tispOrgBox('请选择职务！','error');
                            return
                        }
                    }else{
                        this.tispOrgBox('请选择职务！','error');
                        return
                    }
                    if(this.ediOrgCont.teamid){
                        if(this.ediOrgCont.teamid == 0 || this.ediOrgCont.teamid == ""  || this.ediOrgCont.teamid == null){
                            this.tispOrgBox('请选择班组！','error');
                            return
                        }
                    }else{
                        this.tispOrgBox('请选择班组！','error');
                        return
                    }
                    if(this.ediOrgCont.jobleve){
                        if(this.ediOrgCont.jobleve == 0 || this.ediOrgCont.jobleve == ""  || this.ediOrgCont.jobleve == null){
                            this.tispOrgBox('请选择班组！','error');
                            return
                        }
                    }else{
                        this.tispOrgBox('请选择班组！','error');
                        return
                    }
                    console.log("提交数据--------->",this.ediOrgCont) 

                    let res = await editManOrgCont(this.ediOrgCont)
                    this.editOrgIsTrue = false
                    if (res.code === 0) {
                        this.$message({
                            type: 'success',
                            message: res.msg,
                            showClose: true
                        })
                        this.getMyCont(this.userid)
                        this.getDutieslist();
                        this.closeEditOrgDialog()
                    }


                }else{
                    this.editOrgIsTrue = false
                }
            });
        },
        openOrgButton(){
            this.editOrgIsTrue = false
        },
        //提示
        tispOrgBox(msg,typeClass){
            this.$message({
                showClose: true,
                message: msg,
                type: typeClass,
                duration:1000,
                onClose:this.openOrgButton
            });
        },
        //编辑行政组织关系数据初始化
        initOrgCont(){
            let myId = this.userid * 1
            this.ediOrgCont.id = myId.toString()
        },

        //关闭基本信息编辑框
        closeEditContDialog(){
            this.editSetUp.cont = false
            this.editContIsTrue = false
        },
        //提交个人基本信息
        async editContContsubmit(){
            this.editContIsTrue = true
            console.log("提交个人基本信息---------------1--",this.editContData)
            this.$refs.editContData.validate(async valid => {
                console.log("提交个人基本信息---------------2--",valid)
                if (valid) {
                    console.log("提交个人基本信息",this.editContData)
                    let res = await editManPeopleCont(this.editContData)
                    this.editContIsTrue = false
                    if (res.code === 0) {
                        this.$message({
                            type: 'success',
                            message: res.msg,
                            showClose: true
                        })
                        this.getMyCont(this.userid)
                        this.closeEditContDialog()
                    }
                } else {
                    console.log('error submit!!');
                    return false;
                }
            });
        },
        //入职日期操作
        async entryChangeDate(){
            if(this.editContData.probationperiod == 0) this.editContData.probationperiod = 3;
            console.log("入职日期操作",this.joinedDate,this.editContData.probationperiod)
            if(this.editContData.probationperiod && this.joinedDate != null){
                let yearVal = this.joinedDate.getFullYear();
                let monthVal = this.joinedDate.getMonth()+1;
                let dayVal = this.joinedDate.getDate();
                if(monthVal < 10) monthVal = "0"+newMonthVal;
                if(dayVal < 10) dayVal = "0"+dayVal;
                let dataVal = yearVal + "-" + monthVal + "-" + dayVal
                const res = await calculationDate(dataVal,this.editContData.probationperiod)
                this.editContData.confirmationdate = res.newYear + "-" + res.newMonth + "-" + res.newDay;           //预计转正日期(提交表)
                this.editContData.entrydatetime = dataVal //入职日期(提交表)
                this.confirmationdateval = res.newYear + " 年 " + res.newMonth + " 月 " + res.newDay + " 日"; //(回填表格)
                console.log("入职日期操作---------1---->",dataVal,this.joinedDate,res)
            }
        },
        //改变试用期设置转正日期
        async handleChange(){
            
            if(this.joinedDate && this.joinedDate != null){
                let yearVal = this.joinedDate.getFullYear();
                let monthVal = this.joinedDate.getMonth()+1;
                let dayVal = this.joinedDate.getDate();
                if(monthVal < 10) monthVal = "0"+newMonthVal;
                if(dayVal < 10) dayVal = "0"+dayVal;
                let dataVal = yearVal + "-" + monthVal + "-" + dayVal
                const res = await calculationDate(dataVal,this.editContData.probationperiod)
                this.editContData.confirmationdate = res.newYear + "-" + res.newMonth + "-" + res.newDay; //预计转正日期(提交表)
                this.confirmationdateval = res.newYear + " 年 " + res.newMonth + " 月 " + res.newDay + " 日"; //预计转正日期(回填表格)
            }
        },
        //生日
        async birthdayChange(){
            if(this.birthday && this.birthday != null){
                let yearVal = this.birthday.getFullYear();
                let monthVal = this.birthday.getMonth()+1;
                let dayVal = this.birthday.getDate();
                if(monthVal < 10) monthVal = "0"+newMonthVal;
                if(dayVal < 10) dayVal = "0"+dayVal;
                this.editContData.birthdaytime= yearVal + "-" + monthVal + "-" + dayVal
            }
        },
        //参加工作日期
        async workdayChange(){
            if(this.workingdate && this.workingdate != null){
                let yearVal = this.workingdate.getFullYear();
                let monthVal = this.workingdate.getMonth()+1;
                let dayVal = this.workingdate.getDate();
                if(monthVal < 10) monthVal = "0"+newMonthVal;
                if(dayVal < 10) dayVal = "0"+dayVal;
                this.editContData.jobstartdatestr= yearVal + "-" + monthVal + "-" + dayVal
            }
        },
        //身份证有效期开始
        idCodeTimeStartChange(){
            if(this.idCardStartTimeStr && this.idCardStartTimeStr != null){
                let yearVal = this.idCardStartTimeStr.getFullYear();
                let monthVal = this.idCardStartTimeStr.getMonth()+1;
                let dayVal = this.idCardStartTimeStr.getDate();
                if(monthVal < 10) monthVal = "0"+newMonthVal;
                if(dayVal < 10) dayVal = "0"+dayVal;
                this.editContData.idcardstarttimedata= yearVal + "-" + monthVal + "-" + dayVal
            }
        },
        //身份证有效期结束
        idCodeTimeEndChange(){
            if(this.idCardEndTimeStr && this.idCardEndTimeStr != null){
                let yearVal = this.idCardEndTimeStr.getFullYear();
                let monthVal = this.idCardEndTimeStr.getMonth()+1;
                let dayVal = this.idCardEndTimeStr.getDate();
                if(monthVal < 10) monthVal = "0"+newMonthVal;
                if(dayVal < 10) dayVal = "0"+dayVal;
                this.editContData.idcardendtimedata= yearVal + "-" + monthVal + "-" + dayVal
            }
        },
        // 身份证验证
        isCardID (rule, value, callback) {
            console.log(value)
            if (!/(^\d{15}$)|(^\d{17}(\d|X|x)$)/.test(value)) {
                callback(new Error('你输入的身份证长度或格式错误'))
            }
            //身份证城市
            var aCity = { 11: "北京", 12: "天津", 13: "河北", 14: "山西", 15: "内蒙古", 21: "辽宁", 22: "吉林", 23: "黑龙江", 31: "上海", 32: "江苏", 33: "浙江", 34: "安徽", 35: "福建", 36: "江西", 37: "山东", 41: "河南", 42: "湖北", 43: "湖南", 44: "广东", 45: "广西", 46: "海南", 50: "重庆", 51: "四川", 52: "贵州", 53: "云南", 54: "西藏", 61: "陕西", 62: "甘肃", 63: "青海", 64: "宁夏", 65: "新疆", 71: "台湾", 81: "香港", 82: "澳门", 91: "国外" };
            if (!aCity[parseInt(value.substr(0, 2))]) {
                callback(new Error('你的身份证地区非法'))
            }
        
            // 出生日期验证
            var sBirthday = (value.substr(6, 4) + "-" + Number(value.substr(10, 2)) + "-" + Number(value.substr(12, 2))).replace(/-/g, "/"),
                d = new Date(sBirthday)
            if (sBirthday != (d.getFullYear() + "/" + (d.getMonth() + 1) + "/" + d.getDate())) {
                callback(new Error('身份证上的出生日期非法'))
            }
        
            // 身份证号码校验
            var sum = 0,
                weights = [7, 9, 10, 5, 8, 4, 2, 1, 6, 3, 7, 9, 10, 5, 8, 4, 2],
                codes = "10X98765432"
            for (var i = 0; i < value.length - 1; i++) {
                sum += value[i] * weights[i];
            }
            var last = codes[sum % 11]; //计算出来的最后一位身份证号码
            if (value[value.length - 1] != last) {
                callback(new Error('你输入的身份证号非法'))
            }
            console.log("End------>",value)
            return true
        }
    }
}
</script>
<style>
.el-scrollbar {
    height: 100%;
    width: 100%;
}
.el-scrollbar__wrap {
    
    overflow: auto;
    overflow: scroll;
    overflow-x: hidden;
}
.el-tree-node.is-current>.el-tree-node__content {
    color:#2E89DE!important
}
.el-tree-node_black {
    background-color:red !important;
    color:#2E89DE!important
}
div::-webkit-scrollbar {
    width: 5px;
    height: 5px;
}
div::-webkit-scrollbar-thumb {
    border-radius: 10px;
    -webkit-box-shadow: inset 0 0 5px rgba(0, 0, 0, 0.2);
    opacity: 0.2;
   
}
div::-webkit-scrollbar-track {
    -webkit-box-shadow: inset 0 0 5px rgba(0, 0, 0, 0.2);
    border-radius: 0;
}
.title_body{
    padding: 10px 0;
}
.cont_header_title{
    font-size: 20px;
    font-weight: bold;
    color: #388CFF;
}
.cont_header_title i{
    margin-right: 10px;
}
.edit_buttion{
    text-align: right; 
    padding-right: 5px;
}
.el-divider--horizontal{
    margin: 0;
}
.cont_body{
    margin-top: 20px;
}
.my_label_c{
    padding-top: 10px;
}
.bottment_cont{
    padding-right: 15px;
    color: #000000;
    display:table-cell; 
    vertical-align:bottom;
}
.bottment_line{
    width: 100%;
    border-bottom: 1px solid #EEEEEE;
 
    padding: 5px 0;
}
</style>