<template>
    <div class="flex-container">
        <!-- 查询区域 -->
        <div class="table-page-search-wrapper">
            <!-- 搜索区域 -->
            <a-form layout="inline">
                <a-row :gutter="24">
                    <a-col :md="4" :sm="12">
                        <a-form-item  label="姓名">
                            <a-input  placeholder="姓名" v-model="queryParam.name"></a-input>
                        </a-form-item>
                    </a-col>
                    <a-col :md="4" :sm="12">
                        <a-form-item  label="县分">
                            <a-input  placeholder="县分" v-model="queryParam.area"></a-input>
                        </a-form-item>
                    </a-col>
                    <a-col :md="4" :sm="12">
                        <a-form-item  label="学校">
                            <a-input  placeholder="学校" v-model="queryParam.school"></a-input>
                        </a-form-item>
                    </a-col>
                    <span class="table-page-search-submitButtons" style="float: left; overflow: hidden;">
                        <a-col :md="6" :sm="24">
                            <a-button @click="search()" type="primary">查询</a-button>
                            <a-button @click="openAddUser()" style="margin-left: 8px" icon="plus" type="primary">新增</a-button>
                        </a-col>
                    </span>
                </a-row>
            </a-form>

            <!--列表-->
            <s-table :columns="columns" :data="rowdata" bordered ref="table" size="small" class="flex-filling"  :locale="emptyText">
                <template slot="genderoperation" slot-scope="text">
                   <span v-if="text==1">男</span>
                    <span v-else>女</span>
                </template>
                <template slot="operation" slot-scope="text,record">
                    <a  @click="modifyfunction(record)">编辑</a>
                </template>
            </s-table>

            <!--新增用户--弹框-->
            <a-modal :title="titleName" :visible="addUser"  @ok="createOk" @cancel="createCancel" html-type="submit" width="720px">
                <a-form :form="addFormtable" autocomplete="off">
                    <a-form-item :labelCol="{span: 6}" :wrapperCol="{span: 8, offset: 1}" label="账号" >
                        <a-input placeholder="请输入账号" v-decorator="[ 'account', {rules: [{ required: true, message: '账号不能为空！' ,whitespace:true}]} ]"></a-input>
                    </a-form-item>
                    <a-form-item :labelCol="{span: 6}" :wrapperCol="{span: 8, offset: 1}" label="电话" >
                        <a-input placeholder="请输入电话" v-decorator="[ 'phone', {rules: [{ required: true, message: '电话不能为空！' ,whitespace:true}]} ]"></a-input>
                    </a-form-item>
                    <a-form-item :labelCol="{span: 6}" :wrapperCol="{span: 8, offset: 1}" label="姓名" >
                        <a-input placeholder="请输入姓名" v-decorator="[ 'name', {rules: [{ required: true, message: '姓名不能为空！' ,whitespace:true}]} ]"></a-input>
                    </a-form-item>

                    <a-form-item :labelCol="{span: 6}" :wrapperCol="{span: 8, offset: 1}" label="身份证号" >
                        <a-input placeholder="请输入身份证号" v-decorator="[ 'idCard', {rules: [{ required: true, message: '身份证号不能为空！' ,whitespace:true}]} ]"></a-input>
                    </a-form-item>

                    <a-form-item :labelCol="{span: 6}" :wrapperCol="{span: 8, offset: 1}" label="性别">
                        <a-select placeholder="请选择" v-decorator="[ 'sex', {rules: [{ required: true, message: '性别不能为空！' ,whitespace:true}]} ]">
                            <a-select-option key="">请选择</a-select-option>
                            <a-select-option key="1">男</a-select-option>
                            <a-select-option key="2">女</a-select-option>
                        </a-select>
                    </a-form-item>

                    <a-form-item :labelCol="{span: 6}" :wrapperCol="{span: 8, offset: 1}" label="年级">
                        <a-select placeholder="请选择" v-decorator="[ 'grade', {rules: [{ required: true, message: '年级不能为空！' ,whitespace:true}]} ]">
                            <a-select-option key="">请选择</a-select-option>
                            <a-select-option key="20级">20级</a-select-option>
                            <a-select-option key="19级">19级</a-select-option>
                            <a-select-option key="18级">18级</a-select-option>
                            <a-select-option key="17级">17级</a-select-option>
                            <a-select-option key="16级">16级</a-select-option>
                        </a-select>
                    </a-form-item>

                    <a-form-item :labelCol="{span: 6}" :wrapperCol="{span: 8, offset: 1}"  label="密码">
                        <a-input placeholder="请输入密码" type="password" v-decorator="[ 'password', {rules: [{ required: true, message: '密码不能为空！' ,whitespace:true}]} ]"></a-input>
                    </a-form-item>

                    <a-form-item :labelCol="{span: 6}" :wrapperCol="{span: 8, offset: 1}"  label="重复密码">
                        <a-input placeholder="请再次输入密码" type="password" v-decorator="[ 'repassword', {rules: [{ required: true, message: '重复密码不能为空！' ,whitespace:true}]} ]"></a-input>
                    </a-form-item>

                    <a-form-item :labelCol="{span: 6}"  :wrapperCol="{span: 8, offset: 1}"  label="县分">
                        <a-select placeholder="请选择" @change="changeSubst(1)" v-model="addForm.subName" >
                            <a-select-option key="">请选择</a-select-option>
                            <a-select-option v-for="data in subNameList" :value="data">
                                {{ data}}
                            </a-select-option>
                        </a-select>
                    </a-form-item>

                    <a-form-item :labelCol="{span: 6}" :wrapperCol="{span: 8, offset: 1}"  label="学校名称">
                        <a-select placeholder="请选择" v-decorator="[ 'schoolId', {rules: [{ required: true, type: 'number',message: '学校不能为空！' ,whitespace:true}]} ]">
                            <a-select-option key="">请选择</a-select-option>
                            <a-select-option v-for="data in schoolList"  :value="data.id">
                                {{ data.school_name}}
                            </a-select-option>
                        </a-select>
                    </a-form-item>

                    <a-form-item :labelCol="{span: 6}" :wrapperCol="{span: 8, offset: 1}" label="学子公司职位">
                        <a-select placeholder="请选择" v-model="addForm.position" @change="changePosition(1)">
                            <a-select-option key="">非学子公司成员</a-select-option>
                            <a-select-option key="督导">督导</a-select-option>
                            <a-select-option key="楼长">楼长</a-select-option>
                            <a-select-option key="成员">成员</a-select-option>
                        </a-select>
                    </a-form-item>

                    <a-form-item :labelCol="{span: 6}" :style="leaderDisplay" :wrapperCol="{span: 8, offset: 1}" label="学子公司上级">
                        <a-select placeholder="请选择" v-decorator="[ 'parentId', {rules: [{ required: false, message: '学子公司上级不能为空！' ,whitespace:true}]} ]">
                            <a-select-option key="">请选择</a-select-option>
                            <a-select-option v-for="data in xzUserList"  :value="data.id">
                                {{ data.name}}
                            </a-select-option>
                        </a-select>
                    </a-form-item>

                    <a-form-item :labelCol="{span: 6}" :wrapperCol="{span: 8, offset: 1}" label="角色" >
                        <!-- <a-input placeholder="请输入部门" v-model="modelData.content" @click="handelDepartment"></a-input> -->
                        <treecheck ref="tree1" @selectcheck="contentSelectCheck1"  :treeCheckable="true" :createFun="userRoleTreeList"></treecheck>
                    </a-form-item>
                </a-form>
            </a-modal>

            <!--编辑----弹框-->
            <a-modal :title="titleName" :visible="modifyvisible"  @ok="createfunctionOk" @cancel="createfunctionCancel" html-type="submit" width="720px">
                <a-form :form="Formtable">
                    <a-form-item :labelCol="{span: 6}" :wrapperCol="{span: 8, offset: 1}" label="电话号码">
                        <a-input placeholder="电话号码" v-decorator="[ 'phone', {rules: [{ required: true, message: '电话号码不能为空！' ,whitespace:true}]} ]"></a-input>
                    </a-form-item>
                    <a-form-item :labelCol="{span: 6}" :wrapperCol="{span: 8, offset: 1}" label="账号">
                        <a-input placeholder="账号" v-decorator="[ 'account', {rules: [{ required: true, message: '账号不能为空！' ,whitespace:true}]} ]"></a-input>
                    </a-form-item>
                    <a-form-item :labelCol="{span: 6}" :wrapperCol="{span: 8, offset: 1}" label="姓名">
                        <a-input placeholder="姓名" v-decorator="[ 'name', {rules: [{ required: true, message: '姓名不能为空！' ,whitespace:true}]} ]"></a-input>
                    </a-form-item>
                    <a-form-item :labelCol="{span: 6}" :wrapperCol="{span: 8, offset: 1}" label="身份证">
                        <a-input placeholder="身份证" v-decorator="[ 'idCard', {rules: [{ required: true, message: '身份证不能为空！' ,whitespace:true}]} ]"></a-input>
                    </a-form-item>
                    <a-form-item :labelCol="{span: 6}" :wrapperCol="{span: 8, offset: 1}" label="性别">
                        <a-radio-group  v-decorator="['sex', {rules: [{ required: true, message: '性别不能为空！' ,whitespace:true}]} ]" >
                            <a-radio value="1">男</a-radio>
                            <a-radio value="2">女</a-radio>
                        </a-radio-group>
                    </a-form-item>
                    <a-form-item :labelCol="{span: 6}" :wrapperCol="{span: 8, offset: 1}" label="年级">
                        <a-select placeholder="请选择" v-decorator="[ 'grade', {rules: [{ required: true, message: '年级不能为空！' ,whitespace:true}]} ]">
                            <a-select-option key="">请选择</a-select-option>
                            <a-select-option key="20级">20级</a-select-option>
                            <a-select-option key="19级">19级</a-select-option>
                            <a-select-option key="18级">18级</a-select-option>
                            <a-select-option key="17级">17级</a-select-option>
                            <a-select-option key="16级">16级</a-select-option>
                        </a-select>
                    </a-form-item>
                    <a-form-item :labelCol="{span: 6}"  :wrapperCol="{span: 8, offset: 1}"  label="县分">
                        <a-select placeholder="请选择" @change="changeSubst(2)" v-model="modifyForm.subName" >
                            <a-select-option key="">请选择</a-select-option>
                            <a-select-option v-for="data in subNameList" :value="data">
                                {{ data}}
                            </a-select-option>
                        </a-select>
                    </a-form-item>

                    <a-form-item :labelCol="{span: 6}" :wrapperCol="{span: 8, offset: 1}"  label="学校名称">
                        <a-select placeholder="请选择" v-model="modifyForm.schoolId">
                            <a-select-option key="">请选择</a-select-option>
                            <a-select-option v-for="data in schoolList"  :value="data.id">
                                {{ data.school_name}}
                            </a-select-option>
                        </a-select>
                    </a-form-item>

                    <a-form-item :labelCol="{span: 6}" :wrapperCol="{span: 8, offset: 1}" label="学子公司职位">
                        <a-select placeholder="请选择" v-model="modifyForm.position" @change="changePosition(2)">
                            <a-select-option key="">非学子公司成员</a-select-option>
                            <a-select-option key="督导">督导</a-select-option>
                            <a-select-option key="楼长">楼长</a-select-option>
                            <a-select-option key="成员">成员</a-select-option>
                        </a-select>
                    </a-form-item>

                    <a-form-item :labelCol="{span: 6}" :style="leaderDisplay" :wrapperCol="{span: 8, offset: 1}" label="学子公司上级">
                        <a-select placeholder="请选择" v-model="modifyForm.parentId">
                            <a-select-option key="">请选择</a-select-option>
                            <a-select-option v-for="data in xzUserList"  :value="data.id">
                                {{ data.name}}
                            </a-select-option>
                        </a-select>
                    </a-form-item>

                    <a-form-item :labelCol="{span: 6}" :wrapperCol="{span: 8, offset: 1}" label="角色" >
                        <!-- <a-input placeholder="请输入部门" v-model="modelData.content" @click="handelDepartment"></a-input> -->
                        <treecheck ref="tree2" @selectcheck="contentSelectCheck2"  :treeCheckable="true" :createFun="userRoleTreeList"></treecheck>
                    </a-form-item>
                    <a-form-item :labelCol="{span: 6}" :wrapperCol="{span: 12, offset: 1}" label="通过预实名账号">
                        <a-radio-group  v-decorator="['ysm']" >
                            <a-radio :value="data.id" v-for="data in autoCompleteResult">{{data.userName}}</a-radio>
                        </a-radio-group>
                    </a-form-item>
                </a-form>
            </a-modal>
        </div>
    </div>
</template>

<script>
    import STable from '@/components/table';
    import {
        findByList,modify,getlistysm,
        addPartner,getSubstList,getSchoolList,getXzUserList
    } from "@/api/school-center/PartnerManagementAPI"
    import {cloneObject} from '@/utils/util'
    import treecheck from '@/components/sysmanage/treeCheck'
    import treeList from '@/components/sysmanage/treeList'
    import {
        getList,
        tabList,
        getUserInfo,
        deleteList,
        resetPass,
        getAddUser,
        userRoleTreeList,
        getEditUser,
        userFreeze,
        userUnFreeze,
        changeOtherPwd
    } from '@/api/system';

    export default {
        name: "PartnerManagement",
        components: {
            STable,
            treeList,
            treecheck,
        },
        data: function () {
            return {
                emptyText: {emptyText: '暂无数据'},
                Formtable: this.$form.createForm(this, {name: 'Formtable'}),
                addFormtable: this.$form.createForm(this, {name: 'addFormtable'}),
                queryParam: {
                    name: '',
                    area:'',
                    school:''
                },
                addForm: {
                    account: '',
                    phone:'',
                    name:'',
                    idCard: '',
                    sex: '',
                    grade: '',
                    password: '',
                    repassword: '',
                    subName: '',
                    substName: '',
                    schoolId: '',
                    roleId: '',
                    position:'',
                    parentId:'',
                    parentIds:'',
                },
                leaderDisplay:'display:none',
                modifyvisible:false,
                modifyForm: {
                    id:"",
                    phone: '',
                    school:'',
                    name: '',
                    account: '',
                    idCard: '',
                    sex: '',
                    grade: '',
                    area: '',
                    ysm: '',
                    schoolId: '',
                    roleId: '',
                    position:'',
                    parentId:'',
                },
                autoCompleteResult:[],
                subNameList: [],
                schoolList:[],
                xzUserList:[],
                addSubName:'',
                columns: [
                    {dataIndex: 'name', width: 100, title: '姓名 ', align: "center"},
                    {dataIndex: 'phone', width: 200, title: '电话', align: "center"},
                    {dataIndex: 'school', width: 200, title: '学校 ', align: "center"},
                    {dataIndex: 'idCard', width: 200, title: '身份证 ', align: "center"},
                    {dataIndex: 'account', width: 200, title: '账号 ', align: "center"},
                    {dataIndex: 'sex', width: 100, title: '性别 ', align: "center",scopedSlots: {customRender: 'genderoperation'},},
                    {dataIndex: 'area', width: 100, title: '县分 ', align: "center"},
                    {
                        dataIndex: 'operation',
                        width: 100,
                        title: '操作',
                        align: "center",
                        scopedSlots: {customRender: 'operation'},
                        fixed: "right"
                    }]
                ,
                rowdata: parameter => {
                    let params = {
                        pageNo: parameter.pageNo,
                        pageSize: parameter.pageSize
                    }

                    //表示
                    let obj = cloneObject(this.queryParam)
                    // 获取县分下拉清单
                    getSubstList(Object.assign(params,obj)).then(res => {
                        if (res.state == 'success') {
                            res.data.forEach((key)=>{
                                this.subNameList.push(key.sub_name)
                            })
                        }
                    })

                    return findByList(Object.assign(params,obj)).then(res => {
                        let data = {}
                        if (res.state !== 'success') {
                            this.$message.error("查询失败！", 5);
                            this.emptyText.emptyText = '查询失败！'
                            data = {
                                data: [],
                                pageSize: parameter.pageSize,
                                pageNo: 1,
                                totalCount: 0
                            }
                        } else {
                            data = {
                                data: res.data.records,
                                pageSize: parameter.pageSize,
                                pageNo: parameter.pageNo,
                                totalCount: res.data.total
                            }
                        }
                        return data
                    })
                },
                keyRecord: '',
                recordId: '',
                addUser: false,
                userRoleTreeList:userRoleTreeList,
            }
        },
        methods:{
            search() {
                this.$refs.table.refresh({search: true})
            },
            modifyfunction(data) {
                this.modifyForm.id = data.id
                this.titleName = "编辑"
                this.modifyvisible = true
                setTimeout(() => {
                    this.Formtable.setFieldsValue({
                        phone: data.phone,
                        schoolId: data.schoolId,
                        name: data.name,
                        account: data.account,
                        idCard: data.idCard,
                        sex: 2,
                        grade: '18级',
                        ysm: data.ysm,
                    })

                    this.modifyForm.subName = data.area;
                    this.modifyForm.roleId = data.roleid;
                    this.modifyForm.position = data.position;
                    this.recordId = data.parentId;
                    this.changeSchool(data.schoolId);
                    this.changePosition(2);
                    this.$refs.tree2.setValue2(data.roleid);
                }, 0)
                getlistysm().then(res => {
                    if (res.state == "success") {
                        this.autoCompleteResult = res.data
                    }
                })
            },
            //提交表单
            createfunctionOk(){
                this.Formtable.validateFields(["account",'phone','name',"idCard", 'sex','schoolId', 'roleid','ysm'], {force: true}, (err, values)=>{
                    if (!err){
                        this.modifyForm.account=values.account
                        this.modifyForm.phone=values.phone
                        this.modifyForm.name=values.name
                        this.modifyForm.idCard=values.idCard
                        this.modifyForm.sex=values.sex
                        this.modifyForm.ysm=values.ysm

                        if(this.modifyForm.idCard.length != 18){
                            this.$message.error( '身份证不合法', 5);
                            return null;
                        }
                        if(this.modifyForm.roleId == null || this.modifyForm.roleId == ''){
                            this.$message.error( '角色不能为空', 5);
                            return null;
                        }

                        if(this.modifyForm.roleId.substring(0,2) == '0,'){
                            // 剔除 '0,'
                            this.addForm.roleId = this.addForm.roleId.substring(2);
                        }

                        //修改数据
                        modify(this.modifyForm).then(res=>{
                            if (res.state=="success") {
                                this.$message.success(res.data ? res.data : '修改成功！', 5);
                                this.search();
                                this.modifyvisible = false;
                                return null;
                            }
                            this.$message.error(res.data ? res.data : '修改失败！', 5);
                        })
                    }

                })
            },
            createfunctionCancel(){
                this.modifyvisible=false
                this.autoCompleteResult=[]
                this.Formtable.setFieldsValue({
                    account: '',
                    phone: '',
                    name: '',
                    idCard: '',
                    sex: '',
                    grade: '',
                    password: '',
                    repassword: '',
                    schoolId: '',
                    parentId: '',
                    ysm: '',
                })

                this.addForm.subName = '';
                this.addForm.position = '';
                this.addForm.parentIds = '';
            },
            openAddUser() {
                this.titleName = "新增"
                this.addUser = true;
                this.addFormtable.setFieldsValue({
                    account: '',
                    phone: '',
                    name: '',
                    idCard: '',
                    sex: '',
                    grade: '',
                    password: '',
                    repassword: '',
                    schoolId: '',
                    parentId: '',
                    ysm: '',
                })

                this.addForm.subName = '';
                this.addForm.position = '';
                this.addForm.parentIds = '';
            },
            createOk(){
                this.addFormtable.validateFields(["account", 'phone', "name", "idCard", "sex", 'grade',"password", 'repassword','schoolId','role','position','parentId'], {force: true}, (err, values)=>{
                    if (!err){
                        this.addForm.account=values.account
                        this.addForm.phone=values.phone
                        this.addForm.name=values.name
                        this.addForm.idCard=values.idCard
                        this.addForm.sex=values.sex
                        this.addForm.grade=values.grade
                        this.addForm.password=values.password
                        this.addForm.repassword=values.repassword
                        this.addForm.schoolId=values.schoolId
                        this.addForm.postion=values.position
                        this.addForm.parentId=values.parentId

                        this.addForm.substName=""
                        if(this.addForm.idCard.length != 18){
                            this.$message.error( '身份证不合法', 5);
                            return null;
                        }
                        if(this.addForm.password.length != 8){
                            this.$message.error( '密码长度不对', 5);
                            return null;
                        }
                        if(this.addForm.password != this.addForm.repassword){
                            this.$message.error( '两次密码必须一致', 5);
                            return null;
                        }

                        if(this.addForm.roleId == null || this.addForm.roleId == ''){
                            this.$message.error( '角色不能为空', 5);
                            return null;
                        }

                        if(this.addForm.parentId == undefined){
                            this.addForm.parentId = ''
                            this.addForm.parentIds = ''
                        }else{
                            this.xzUserList.forEach((key) => {
                                if(this.addForm.parentId == key.id){
                                    if(this.addForm.position == '楼长'){
                                        this.addForm.parentIds = key.id + ',';
                                    }else{
                                        this.addForm.parentIds = key.parentIds + key.id + ',';
                                    }
                                }
                            })
                        }

                        if(this.addForm.roleId.substring(0,2) == '0,'){
                            // 剔除 '0,'
                            this.addForm.roleId = this.addForm.roleId.substring(2);
                        }
                        //修改数据
                        addPartner(this.addForm).then(res=>{
                            if (res.state=="success") {
                                this.$message.success(res.data ? res.data : '修改成功！', 5);
                                this.search();
                                this.addUser = false;
                                return null;
                            }
                            this.$message.error(res.data ? res.data : '修改失败！', 5);
                        })
                    }
                })
            },
            createCancel(){
                this.addUser=false;
                this.addFormtable.setFieldsValue({
                    account: '',
                    phone: '',
                    name: '',
                    idCard: '',
                    sex: '',
                    grade: '',
                    password: '',
                    repassword: '',
                    schoolId: '',
                    parentId: '',
                    ysm: '',
                })

                this.addForm.subName = '';
                this.addForm.position = '';
                this.addForm.parentIds = '';
            },
            contentSelectCheck1(data){
                let list = data.list;
                let textlist = new Array();
                let pObj = {};
                list.forEach(element => {
                    /*if(element.plist){
                      element.plist.forEach(item2 =>{
                        textlist.push(item2);
                      })
                    }*/
                    if(element !== undefined){
                        if(!pObj[element.pId]){
                            pObj[element.pId] = {len:element.plen,list:[element.id]}
                        }else{
                            pObj[element.pId].list.push(element.id)
                        }
                    }
                    //textlist.push(element.id);
                });
                for (let name in pObj) {
                    if(pObj[name].len === pObj[name].list.length){
                        textlist.push(name)
                        textlist = [...textlist,...pObj[name].list];
                    }else{
                        textlist = [...textlist,...pObj[name].list];
                    }
                }
                this.addForm.roleId = textlist.join(",");
            },
            contentSelectCheck2(data){
                let list = data.list;
                let textlist = new Array();
                let pObj = {};
                list.forEach(element => {
                    /*if(element.plist){
                      element.plist.forEach(item2 =>{
                        textlist.push(item2);
                      })
                    }*/
                    if(!pObj[element.pId]){
                        pObj[element.pId] = {len:element.plen,list:[element.id]}
                    }else{
                        pObj[element.pId].list.push(element.id)
                    }
                    //textlist.push(element.id);
                });
                for (let name in pObj) {
                    if(pObj[name].len === pObj[name].list.length){
                        textlist.push(name)
                        textlist = [...textlist,...pObj[name].list];
                    }else{
                        textlist = [...textlist,...pObj[name].list];
                    }
                }
                this.modifyForm.roleId = textlist.join(",");
            },
            changeSubst(type){
                let schoolParams = {};
                if(type == 1){
                    schoolParams.subName = this.addForm.subName;
                }else{
                    schoolParams.subName = this.modifyForm.subName;
                }

                this.schoolList = [];
                getSchoolList(schoolParams).then(res => {
                    if (res.state == 'success') {
                        res.data.forEach((key) => {
                            this.schoolList.push(key)
                        })
                    }
                })
            },
            changeSchool(schoolId){
                let schoolParams = {};
                schoolParams.subName = this.modifyForm.subName;
                this.schoolList = [];

                getSchoolList(schoolParams).then(res => {
                    if (res.state == 'success') {
                        res.data.forEach((key) => {
                            this.schoolList.push(key)
                        })

                        this.modifyForm.schoolId = schoolId;
                    }
                })
            },
            changePosition(type){
                let params = {};
                if(type == 1){
                    params.position = this.addForm.position;
                }else{
                    params.position = this.modifyForm.position;
                }

                this.addForm.parentIds = '';
                if(params.position != '' && params.position != '督导'){
                    this.leaderDisplay = '';
                    if(params.position == '楼长'){
                        params.position = '督导'
                    }else{
                        params.position = '楼长'
                    }

                    this.xzUserList = [];
                    getXzUserList(params).then(res => {
                        if (res.state == 'success') {
                            this.keyRecord = ''
                            res.data.forEach((key) => {
                                this.xzUserList.push(key)

                            })

                            if(type == 1){
                                this.addForm.parentId = '';
                            }else{
                                if(this.recordId != ''){
                                    this.modifyForm.parentId = this.recordId;
                                }
                            }

                        }
                    })
                }else {
                    this.leaderDisplay = 'display:none';
                    this.addForm.parentId = '';
                    this.modifyForm.parentId = '';
                }
            },
        }
    }
</script>

<style scoped>

</style>