<template>
    <div>
        <div class="communal-list userlist">
            <div class="communal-title">
                <div>员工列表</div>
                <div class="communal-box">
                    <el-input @input="Inquireclick()" placeholder="公司/部门/岗位/姓名" v-model="input" clearable>
                    </el-input>
                    <el-button @click="Inquireclick()" type="primary"><i class="iconfont icon-sousuo"></i></el-button>
                </div>
            </div>
            <template>
                <el-table :data="tableDatas.slice((currentPage - 1) * pageSize, currentPage * pageSize)" border
                    style="width: 100%">
                    <el-table-column prop="num" label="序 号" width="55">
                        <template slot-scope="scope">
                            {{ (currentPage - 1) * pageSize + scope.$index + 1 }}
                        </template>
                    </el-table-column>
                    <el-table-column prop="number" label="工号" width="80">
                    </el-table-column>
                    <el-table-column prop="cnName" label="姓名" width="200">
                    </el-table-column>
                    <el-table-column prop="companyName" label="公司名称" width="250">
                    </el-table-column>
                    <el-table-column prop="depName" label="部门名称" width="100">
                    </el-table-column>
                    <el-table-column prop="jobName" label="职位" width="140">
                    </el-table-column>
                    <el-table-column prop="ext" label="分机号" width="80">
                    </el-table-column>
                    <el-table-column prop="phone" label="手机号" width="180">
                    </el-table-column>
                    <el-table-column label="人事审核" prop="hrAudit">
                        <template slot-scope="hrAudit">
                            <span v-if="hrAudit.row.hrAudit == 1">审核通过</span>
                            <span v-else-if="hrAudit.row.hrAudit == 2">审核未通过</span>
                            <span v-else>
                                <a v-if="examine" style="color: cornflowerblue;" @click="hrAuditBtn(hrAudit.row.id, 1)">通过</a>
                                <a v-if="examine" style="color: red;" @click="hrAuditBtn(hrAudit.row.id, 2)">拒绝</a>
                                <span v-else>未审核</span>
                            </span>
                        </template>
                    </el-table-column>
                    <el-table-column label="操作" width="180">
                        <template slot-scope="scope">
                            <el-button v-if="examine" size="mini" @click="upDate(scope.$index, scope.row)">编辑</el-button>
                            <el-button size="mini" type="danger" @click="del(scope.$index, scope.row)">删除</el-button>
                        </template>
                    </el-table-column>
                </el-table>
            </template>
            <div class="block">
                <el-pagination align='center' @size-change="handleSizeChange" @current-change="handleCurrentChange"
                    :current-page="currentPage" :page-sizes="[10, 15, 20]" :page-size="pageSize"
                    layout="total, sizes, prev, pager, next" :total="tableDatas.length">
                </el-pagination>
            </div>
        </div>
        <el-dialog top="1vh" style="z-index:2013" title="修改员工信息" :visible.sync="upUserVisible" width="900px" :before-close="handleClose" :close-on-click-modal="false">
            <div>
                <el-form
                    :model="ruleForm"
                    :rules="rules"
                    ref="ruleForm"
                    label-width="100px"
                    class="demo-ruleForm"
                >
                    <div class="form-lis">
                        <el-form-item label="中文名称" prop="mandarinName">
                            <el-input @blur="emailpj" v-model="ruleForm.mandarinName" placeholder="与企业微信名称一致"></el-input>
                        </el-form-item>
                        <el-form-item label="英文名称" prop="eflName">
                            <el-input @blur="emailpj" v-model="ruleForm.eflName" placeholder="请输入英文名称"></el-input>
                        </el-form-item>
                    </div>
                    <div class="form-lis">
                        <el-form-item label="邮箱" prop="email">
                            <el-input v-model="ruleForm.email" placeholder="会自动识别">
                            <template slot="append">@pan-american-intl.com</template>
                            </el-input>
                        </el-form-item>
                        <el-form-item label="性别" prop="sex">
                            <el-radio-group v-model="ruleForm.sex">
                            <el-radio label="男"></el-radio>
                            <el-radio label="女"></el-radio>
                            </el-radio-group>
                        </el-form-item>
                        <el-form-item label="工号" prop="number">
                            <el-input v-model="ruleForm.number" placeholder="请填写工号"></el-input>
                        </el-form-item>
                        <el-form-item label="手机号" prop="phone">
                            <el-input v-model="ruleForm.phone" placeholder="与企业微信注册的手机号一致"></el-input>
                        </el-form-item>
                        <el-form-item label="紧急电话" prop="urgentphone">
                            <el-input v-model="ruleForm.urgentphone" placeholder="不能与使用的手机号相同"></el-input>
                        </el-form-item>
                        <el-form-item label="密码" prop="pass">
                            <el-input v-model="ruleForm.pass" show-password placeholder="输入密码"></el-input>
                        </el-form-item>
                        <el-form-item label="确认密码" prop="checkPass">
                            <el-input v-model="ruleForm.checkPass" show-password placeholder="确认密码"></el-input>
                        </el-form-item>
                        <el-form-item label="身份证号" prop="IDnumber">
                            <el-input v-model="ruleForm.IDnumber" placeholder="输入身份证号"></el-input>
                        </el-form-item>
                        <el-form-item label="入职时间" prop="datebirth">
                            <el-date-picker value-format="yyyy-MM-dd" type="date" placeholder="选择日期" v-model="ruleForm.datebirth" style="width: 100%;"></el-date-picker>
                            <!-- <el-input v-model="ruleForm.datebirth"></el-input> -->
                        </el-form-item>
                        <el-form-item label="学历" prop="educated">
                            <el-select v-model="ruleForm.educated" placeholder="请选择学历">
                                <el-option
                                v-for="item in educatedarr"
                                :key="item.value"
                                :label="item.label"
                                :value="item.value">
                                </el-option>
                            </el-select>
                        </el-form-item>
                        <el-form-item label="专业" prop="specialized">
                            <el-input v-model="ruleForm.specialized" placeholder="输入专业"></el-input>
                        </el-form-item>
                        <el-form-item label="毕业院校" prop="school">
                            <el-input v-model="ruleForm.school" placeholder="输入毕业院校"></el-input>
                        </el-form-item>
                        <el-form-item label="教育类型" prop="recruitment">
                            <el-select v-model="ruleForm.recruitment" placeholder="请选择教育类型">
                                <el-option
                                v-for="item in recruitmentarr"
                                :key="item.value"
                                :label="item.label"
                                :value="item.value">
                                </el-option>
                            </el-select>
                        </el-form-item>
                        <el-form-item label="婚姻状况" prop="maritalstatus">
                            <el-input v-model="ruleForm.maritalstatus" placeholder="输入婚姻状况"></el-input>
                        </el-form-item>
                        <el-form-item label="居住住址" prop="address">
                            <el-input v-model="ruleForm.address" placeholder="输入居住住址"></el-input>
                        </el-form-item>
                        <el-form-item label="家庭地址" prop="homeAddress">
                            <el-input v-model="ruleForm.homeAddress" placeholder="输入家庭地址"></el-input>
                        </el-form-item>
                        <el-form-item label="所属公司" prop="corporation">
                            <el-select v-model="ruleForm.corporation" value-key="id" @change="changeCorporation" placeholder="请选择所属公司">
                            <el-option
                            v-for="item in CorporationOption"
                            :key="item.companyId"
                            :label="item.companyName"
                            :value="item.companyId">
                            </el-option>
                            </el-select>
                        </el-form-item>
                        <el-form-item label="所属部门" prop="division">
                            <el-select v-model="ruleForm.division" value-key="id" @change="changeDivision" placeholder="请选择所属部门">
                            <el-option
                            v-for="item in DivisionOption"
                            :key="item.depId"
                            :label="item.depName"
                            :value="item.depId">
                            </el-option>
                            </el-select>
                        </el-form-item>
                        <el-form-item label="职位" prop="posts">
                            <el-select v-model="ruleForm.posts" placeholder="请选择职位">
                            <el-option
                            v-for="item in PostsOption"
                            :key="item.jobId"
                            :label="item.jobName"
                            :value="item.jobId">
                            </el-option>
                            </el-select>
                        </el-form-item>
                    </div>
                    <el-form-item label="工作经历">
                    <el-input type="textarea" v-model="ruleForm.desc"></el-input>
                    </el-form-item>
                    <!-- <div class="enroll-btn">
                        <el-button type="primary" @click="submitForm('ruleForm')">立即注册</el-button>
                        <el-button @click="resetForm('ruleForm')">重置</el-button>
                        <el-button @click="houtui()">返回</el-button>
                    </div> -->
                </el-form>
            </div>
            <span slot="footer" class="dialog-footer">
                <el-button @click="upUserVisible = false">取 消</el-button>
                <el-button type="primary" @click="confirmbtn('ruleForm')">确 定</el-button>
            </span>
        </el-dialog>
    </div>
</template>
<script>
import { co, el } from '@fullcalendar/core/internal-common';
import { del } from 'vue';
export default {
    data() {
        var validatePass = (rule, value, callback) => {
            if (value === "") {
                callback(new Error("请输入密码"));
            } else {
                if (this.ruleForm.checkPass !== "") {
                this.$refs.ruleForm.validateField("checkPass");
                }
                callback();
            }
        };
        var validatePass2 = (rule, value, callback) => {
            if (value === "") {
                callback(new Error("请再次输入密码"));
            } else if (value !== this.ruleForm.pass) {
                callback(new Error("两次输入密码不一致!"));
            } else {
                callback();
            }
        };
        var phonePass = (rule, value, callback) => {
            if (value === "") {
                callback(new Error("请输入紧急电话"));
            }else if (value === this.ruleForm.phone) {
                callback(new Error("紧急电话与联系电话不能一致!"));
            }else {
                callback();
            }
        };
        return {
            // rules: {
            //     Number: [
            //         { required: true, message: '请输入工号', trigger: 'blur' },
            //     ],
            //     CompanyId: [
            //         { required: true, message: '请选择所属公司', trigger: 'blur' },
            //     ],
            //     DepId: [
            //         { required: true, message: '请选择所属部门', trigger: 'change' }
            //     ],
            //     JobPostId: [
            //         { required: true, message: '请选择所属职位', trigger: 'change' }
            //     ],
            // },
            tableDatas: [],
            tableData: [],
            companyData: [],
            depData: [],
            JobData: [],
            currentPage: 1, // 当前页码
            pageSize: 15,// 每页的数据条数


            input: '',
            token: '',
            userId: 0,
            ID:0,
            upUserVisible: false,
            upData: {
                Id: 0,
                Number: '',
                CompanyId: 0,
                DepId: 0,
                JobPostId: 0,
                Ext: '',
                UsePeriod: '',
                HrAudit: 0,
                currUserId:0
            },
            HrAuditSelect: [{
                value: 0,
                label: '未审核'
            },
            {
                value: 1,
                label: '已通过'
            },
            {
                value: 2,
                label: '已拒绝'
            },],
            Permissions:[],
            examine:false,
            CorporationOption:[],//公司
            DivisionOption:[],//部门
            PostsOption:[],//职位
            ruleForm: {
                mandarinName: "",//中文名称
                eflName: "",//英文名称
                sex: "",//性别
                number:"",//工号
                email: "",//邮箱
                phone: "",//手机号
                urgentphone: "",//紧急电话
                pass: "",//密码
                checkPass: "",//确认密码
                IDnumber: "",//身份证号
                educated: "",//学历
                specialized: "",//专业
                school: "",//毕业院校
                recruitment: "",//统招/成教
                datebirth: "",//入职时间
                homeAddress:"",//家庭地址
                maritalstatus: "",//婚姻状况
                address: "",//现在居住住址
                corporation: "",//所属公司
                division: "",//所属部门
                posts:"",//职位
                desc: "",//工作经历
            },
            educatedarr:[
                {
                    
                    label:'未设置',
                    value:0
                },
                {
                    label:'小学',
                    value:1
                },{
                    label:'初中',
                    value:2
                },{
                    label:'高中',
                    value:3
                },{
                    label:'专科',
                    value:4
                },{
                    label:'本科',
                    value:5
                },{
                    label:'研究生',
                    value:6
                }
            ],
            recruitmentarr:[
                {
                    label:'未设置',
                    value:0
                },
                {
                    label:'统招',
                    value:1
                }, {
                    label:'成教',
                    value:2
                },{
                    label:'留学',
                    value:3
                },
            ],
            rules: {
                mandarinName: [
                { required: true, message: "中文名称", trigger: "blur" },
                { min: 2, max: 6, message: "长度在 2 到 6 个字符", trigger: "blur" },
                ],
                eflName: [
                { required: true, message: "英文名称", trigger: "blur" },
                { min: 0, max: 10, message: "长度在 0 到 10 个字符", trigger: "blur" },
                ],
                sex: [{ required: true, message: "请选择性别", trigger: "change" }],
                email: [
                { required: true, message: "请输入邮箱地址", trigger: "blur" },
                // {
                //   type: "email",
                //   message: "请输入正确的邮箱地址",
                //   trigger: ["blur", "change"],
                // },
                ],
                phone: [
                { required: true, message: "手机号必填", trigger: "blur" },
                {
                    pattern: /^1[3456789]\d{9}$/,
                    message: "手机号码格式不正确",
                    trigger: "blur",
                },
                ],
                urgentphone: [
                { required: true, message: "手机号必填", trigger: "blur" },
                { required: true,validator: phonePass, trigger: "blur" },
                {
                    pattern: /^1[3456789]\d{9}$/,
                    message: "紧急号码格式不正确",
                    trigger: "blur",
                },
                ],
                pass: [
                { required: true, validator: validatePass, trigger: "blur" },
                {
                    min: 6,
                    max: 18,
                    message: "长度在 6 到 18 个字符",
                    trigger: "blur",
                },
                ],
                checkPass: [
                { required: true, validator: validatePass2, trigger: "blur" },
                {
                    min: 6,
                    max: 18,
                    message: "长度在 6 到 18 个字符",
                    trigger: "blur",
                },
                ],
                IDnumber: [
                { required: true, message: "请填写证件号码", trigger: "blur" },
                {
                    pattern:
                    /(^[1-9]\d{5}(18|19|([23]\d))\d{2}((0[1-9])|(10|11|12))(([0-2][1-9])|10|20|30|31)\d{3}[0-9Xx]$)|(^[1-9]\d{5}\d{2}((0[1-9])|(10|11|12))(([0-2][1-9])|10|20|30|31)\d{2}$)/,
                    message: "证件号码格式有误！",
                    trigger: "blur",
                },
                ],
                datebirth: [
                {
                    required: true,
                    message: "请选择入职日期",
                    trigger: "change",
                },
                ],
                educated: [{ required: true, message: "请选择学历", trigger: "change" }],
                specialized: [
                { required: true, message: "请填写专业", trigger: "blur" },
                ],
                school: [
                { required: true, message: "请填写毕业院校", trigger: "blur" },
                ],
                recruitment: [
                { required: true, message: "请填写统招/成教", trigger: "blur" },
                ],
                maritalstatus: [
                { required: true, message: "请填写婚姻状况", trigger: "blur" },
                ],
                address: [
                { required: true, message: "请填写现在居住住址", trigger: "blur" },
                ],
                homeAddress: [
                { required: true, message: "请填写家庭地址", trigger: "blur" },
                ],
                corporation: [
                { required: true, message: "请选择所属公司", trigger: "change" },
                ],
                division: [
                { required: true, message: "请选择所属部门", trigger: "blur" },
                ],
                posts: [
                { required: true, message: "请选择职位", trigger: "blur" },
                ],
                desc: [{ required: true, message: "请填写工作经历", trigger: "blur" }],
                number: [{ required: true, message: "请填写工号", trigger: "blur" }],
            },
        }
    },
    methods: {
        //每页条数改变时触发 选择一页显示多少行
        handleSizeChange(val) {
            this.currentPage = 1;
            this.pageSize = val;
        },
        //当前页改变时触发 跳转其他页
        handleCurrentChange(val) {
            this.currentPage = val;
        },
        //获取公司
        daraSource(){
            var url = "/api/register/daraSource"
            var that = this
            this.$axios({
                method: 'post',
                url: url,
                headers: {
                    Authorization: 'Bearer ' + this.token
                }
            }).then(function (res) {
                if(res.data.code==200){
                    console.log(res)
                    that.CorporationOption=res.data.data;
                }else{
                    that.$message({
                        message: res.data.msg,
                        type: 'warning'
                    });
                }
            })
        },
        //切换公司
        changeCorporation(item){
            this.ruleForm.division='';
            this.ruleForm.posts='';
            for(let i=0;i<this.CorporationOption.length;i++){
                if(this.CorporationOption[i].companyId==item){
                    this.DivisionOption=this.CorporationOption[i].subDep
                }
            }
        },
        //切换部门
        changeDivision(item){
            this.ruleForm.posts='';
            for(let j=0;j<this.DivisionOption.length;j++){
                if(this.DivisionOption[j].depId==item){
                    this.PostsOption=this.DivisionOption[j].subJob
                }
            }
        },
        //邮箱拼接
        emailpj(){
            let emailall;
            let surname=pinyin(this.ruleForm.mandarinName[0], {toneType: 'none'})
            this.ruleForm.email=this.ruleForm.eflName+'.'+surname
            emailall=this.ruleForm.eflName+'.'+surname+'@pan-american-intl.com'
        },
        //确定
        confirmbtn(ruleForm){
            this.$refs[ruleForm].validate((valid) => {
                if (valid) {
                    this.EditUserInfo()
                } else {
                    this.$message.error('请完善信息在保存！');
                    return false;
                }
            });
        },
        //修改
        EditUserInfo() {
            var url = "/api/System/EditUserInfo"
            var that = this
            that.depData = [];
            that.$axios({
                method: 'post',
                url: url,
                headers: {
                    Authorization: 'Bearer '
                },
                data: {
                    currUserId:that.userId,
                    id: that.ID,
                    cnName: that.ruleForm.mandarinName,//中文姓名
                    enName: that.ruleForm.eflName,//英文姓名
                    number: that.ruleForm.number,//工号
                    companyId: that.ruleForm.corporation,//公司Id
                    depId: that.ruleForm.division,//部门Id
                    jobPostId: that.ruleForm.posts,//岗位Id
                    password: that.ruleForm.pass,//密码
                    comfirmPassword: that.ruleForm.checkPass,//确认密码
                    sex: that.ruleForm.sex=='男'?0:1,//性别0 男 1 女 2 未设置
                    ext: '',//分机号
                    phone: that.ruleForm.phone,//手机号
                    urgentPhone:that.ruleForm.urgentphone,//紧急联系人 手机号
                    email: that.ruleForm.email+'@pan-american-intl.com',//邮箱
                    address: that.ruleForm.address,//住址
                    edate: that.ruleForm.datebirth,//入职时间
                    birthday: '',//生日
                    idCard: that.ruleForm.IDnumber,//身份证号码
                    startWorkDate: '',//开始工作时
                    graduateInstitutions: that.ruleForm.school,//毕业学校
                    professional: that.ruleForm.specialized,//专业
                    education: that.ruleForm.educated,//学历 0 未设置 1 小学、2 初中、3 高中、4 专科、5 本科、6 研究生
                    theOrAdultEducation:  that.ruleForm.recruitment,//学历类型 0 未设置 1 成教 2 统招 3 留学
                    maritalStatus: that.ruleForm.maritalstatus,//婚姻状态
                    homeAddress: that.ruleForm.homeAddress,//家庭地址
                    usePeriod: '',//试用期
                    workExperience: that.ruleForm.desc,//工作经历
                    certificate: '',//证书上传
                    qiyeChatUserId: '',//企微Id
                    remark: '',//备注
                }
            }).then(function (res) {
                if (res.data.code == 200) {
                    that.$message({
                        type: 'success',
                        message: res.data.msg,
                    });
                    that.upUserVisible=false;
                    that.user();
                }else{
                    that.$message({
                        message: res.data.msg,
                        type: 'warning'
                    });
                }
            })
        },
        //部门数据查询
        Department(companyId) {
            var url = "/api/System/QueryDepartmentList"
            var that = this
            that.depData = [];
            that.$axios({
                method: 'post',
                url: url,
                headers: {
                    Authorization: 'Bearer ' + this.token
                },
                data: {
                    portType: 1,
                    CompanyId: companyId
                }
            }).then(function (res) {
                if (res.data.code == 200) {
                    that.depData = res.data.data;
                }
            })
        },
        //公司数据查询
        company() {
            var url = "/api/System/getCompanyList"
            var that = this
            that.$axios({
                method: 'post',
                url: url,
                headers: {
                    Authorization: 'Bearer ' + this.token
                },
                data: {
                    portType: 1,
                }
            }).then(function (res) {
                if (res.data.code == 200) {
                    that.companyData = res.data.data;
                }
            })
        },
        companyChange(event) {
            this.upData.DepId = null;
            this.upData.JobPostId = null;
            this.Department(event)
            this.Job(event, 0)
        },
        depChange(event) {
            this.upData.JobPostId = null;
            this.Job(this.upData.CompanyId, event)
        },
        //职位数据查询
        Job(companyId, depId) {
            var url = "/api/System/QueryJobPost"
            var that = this
            that.JobData = [];
            that.$axios({
                method: 'post',
                url: url,
                headers: {
                    Authorization: 'Bearer ' + this.token
                },
                data: {
                    portType: 1,
                    CompanyId: companyId,
                    DepId: depId
                }
            }).then(function (res) {
                if (res.data.code == 200) {
                    that.JobData = res.data.data;
                }
            })
        },
        user() {
            var url = "/api/System/QueryUserList"
            var that = this
            this.$axios({
                method: 'post',
                url: url,
                headers: {
                    Authorization: 'Bearer ' + this.token
                },
                data: {
                    portType: 1,
                }
            }).then(function (res) {
                if (res.data.code == 200) {
                    that.tableDatas = res.data.data;
                    that.tableData = that.tableDatas
                    if (that.tableDatas.slice((that.currentPage - 1) * that.pageSize, that.currentPage * that.pageSize).length == 0) {
                        if (that.currentPage > 1) {
                            that.currentPage = that.currentPage - 1;
                        }
                    }
                }
            })
        },
        Inquireclick() {
            var newarr = [];
            if (this.input == "") {
                newarr = this.tableData;
            } else {
                for (var i = 0; i < this.tableData.length; i++) {
                    if (this.tableData[i].cnName.indexOf(this.input) != -1) {
                        newarr.push(this.tableData[i]);
                    } else if (this.tableData[i].companyName.indexOf(this.input) != -1) {
                        newarr.push(this.tableData[i]);
                    } else if (this.tableData[i].depName.indexOf(this.input) != -1) {
                        newarr.push(this.tableData[i]);
                    } else if (this.tableData[i].jobName.indexOf(this.input) != -1) {
                        newarr.push(this.tableData[i]);
                    }
                }
            }
            this.tableDatas = newarr;
            this.currentPage = 1;
        },
        //#region  修改操作
        upDate(index, row) {
            this.ruleForm= {
                mandarinName: "",//中文名称
                eflName: "",//英文名称
                sex: "",//性别
                number:"",//工号
                email: "",//邮箱
                phone: "",//手机号
                urgentphone: "",//紧急电话
                pass: "",//密码
                checkPass: "",//确认密码
                IDnumber: "",//身份证号
                educated: "",//学历
                specialized: "",//专业
                school: "",//毕业院校
                recruitment: "",//统招/成教
                datebirth: "",//入职时间
                homeAddress:"",//家庭地址
                maritalstatus: "",//婚姻状况
                address: "",//现在居住住址
                corporation: "",//所属公司
                division: "",//所属部门
                posts:"",//职位
                desc: "",//工作经历
            }
            this.ID=row.id;
            this.upUserVisible = true;
            this.getuserinfo(row.id);
        },
        //获取详细信息
        getuserinfo(val){
            var url = "/api/System/UserInfo"
            var that = this
            this.$axios({
                method: 'post',
                url: url,
                headers: {
                    Authorization: 'Bearer '
                },
                data: {
                    portType:1,
                    id: val,
                }
            }).then(function (res) {
                if (res.data.code == 200) {
                    var datainfo=res.data.data;
                    that.ruleForm.mandarinName=datainfo.cnName;
                    that.ruleForm.eflName=datainfo.enName; 
                    that.ruleForm.number=datainfo.number;
                    that.ruleForm.email=datainfo.email.split('@')[0];
                    that.ruleForm.sex=datainfo.sex==0?'男':'女';
                    that.ruleForm.phone=datainfo.phone;
                    that.ruleForm.urgentphone=datainfo.urgentPhone;
                    that.ruleForm.pass=datainfo.password;
                    that.ruleForm.checkPass=datainfo.password;
                    that.ruleForm.IDnumber=datainfo.idCard;
                    that.ruleForm.educated=datainfo.education;
                    that.ruleForm.specialized=datainfo.professional;
                    that.ruleForm.school=datainfo.graduateInstitutions;
                    that.ruleForm.recruitment=datainfo.theOrAdultEducation;
                    that.ruleForm.datebirth=datainfo.edate;
                    that.ruleForm.homeAddress=datainfo.homeAddress;
                    that.ruleForm.maritalstatus=datainfo.maritalStatus;
                    that.ruleForm.address=datainfo.address;
                    that.ruleForm.corporation=datainfo.companyId;
                    that.ruleForm.division=datainfo.depId;
                    that.ruleForm.posts=datainfo.jobPostId;
                    that.ruleForm.desc=datainfo.workExperience;
                    for(let i=0;i<that.CorporationOption.length;i++){
                        if(that.CorporationOption[i].companyId==that.ruleForm.corporation){
                            that.DivisionOption=that.CorporationOption[i].subDep
                        }
                    }
                    for(let j=0;j<that.DivisionOption.length;j++){
                        if(that.DivisionOption[j].depId==that.ruleForm.division){
                            that.PostsOption=that.DivisionOption[j].subJob
                        }
                    }
                } else {
                    that.$message.error(res.data.msg);
                }
            })
        },
        upBtn() {
            this.$refs.upData.validate((valid) => {
                if (valid) {
                    
                    
                } else { 
                    this.$message.error('请完善信息在保存！');
                    return false;
                }
            })
        },
        //关闭修改框
        handleClose(done) {
            done();
        },
        //#endregion
        del(index, row) {

            this.$confirm('此操作将删除该员工, 是否继续?', '提示', {
                confirmButtonText: '确定',
                cancelButtonText: '取消',
                type: 'warning'
            }).then(() => {
                var url = "/api/System/PostUserDelById"
                var that = this
                this.$axios({
                    method: 'post',
                    url: url,
                    headers: {
                        Authorization: 'Bearer ' + this.token
                    },
                    data: {
                        Id: row.id,
                    }
                }).then(function (res) {
                    console.log(res)

                    if (res.data.code == 200) {
                        that.$message({
                            type: 'success',
                            message: '删除成功!'
                        });
                        that.user();
                    } else {
                        that.$message.error(res.data.msg);
                    }
                })

            }).catch(() => {
                this.$message({
                    type: 'info',
                    message: '操作已取消！'
                });
            });

        },
        hrAuditBtn(id, HrAudit) {
            debugger
            this.$confirm('是否进行此操作?', '提示', {
                confirmButtonText: '确定',
                cancelButtonText: '取消',
                type: 'warning'
            }).then(() => {
                var url = "/api/System/PersonnelAudit"
                var that = this
                this.$axios({
                    method: 'post',
                    url: url,
                    headers: {
                        Authorization: 'Bearer ' + this.token
                    },
                    data: {
                        userId:that.userId,
                        Id: id,
                        isAudit: HrAudit
                    }
                }).then(function (res) {
                    console.log(res)

                    if (res.data.code == 200) {
                        that.$message({
                            type: 'success',
                            message: '操作成功!'
                        });
                        that.user();
                    } else {
                        that.$message.error(res.data.msg);
                    }
                })
            }).catch(() => {
                debugger
                this.$message({
                    type: 'info',
                    message: '操作已取消！'
                });
            });

        }
        //#endregion

    },
    mounted() {
        this.token = JSON.parse(localStorage.getItem('userinif')).token;
        this.userId = JSON.parse(localStorage.getItem('userinif')).userInfo.userId;
        this.upData.currUserId=this.userId;
        this.Permissions = JSON.parse(localStorage.getItem('Permissions'));
        console.log(this.Permissions)
        for(let k=0;k<this.Permissions.length;k++){
            if(this.Permissions[k].funid==12){
                this.examine=true;
            }
        }
        this.daraSource()
        this.Department(0);
        this.company();
        this.user();
    }
}
</script>
<style>
.communal-list {
    background-color: #fff;
    padding: 10px;
    box-shadow: 0 0 5px #0005;
    border-radius: 10px;
}

.communal-title {
    display: flex;
    font-size: 17px;
    font-weight: 600;
    color: #555;
    margin-top: 8px;
    margin-bottom: 2px;
    justify-content: space-between;
    align-items: center;
}

.communal-box {
    display: flex;
}

.communal-box>button {
    margin-left: 10px;
    padding: 8px 20px;
}

.form-lis {
    display: flex;
    flex-wrap: wrap;
}
.form-lis > div {
    width: 50%;
}
.form-lis .el-select{
    width: 100%;
}
</style>