13404089107
2 天以前 025c4c6e32a1c06ea604a9f2b67c4b8cbc29ce2c
management/src/pages/setting/user/components/addAndEdit.jsx
@@ -1,7 +1,9 @@
import { Form, Input, Modal, Tree, Button, Spin, Row, Col, Select, Radio, Cascader } from 'antd';
import { Form, Input, Modal, Tree, Button, Spin, Row, Col, Select, Radio, Cascader, Card } from 'antd';
import { forwardRef, useImperativeHandle, useState } from 'react';
import { useEffect } from 'react';
import { getDepartmentList, systemPostList, systemRoleList, getSystemUserInfo, getCityList, addSystemUserInfo, editSystemUserInfo } from '../service';
import { DeleteOutlined } from '@ant-design/icons';
import '../index.less'
import { getDepartmentList, systemPostList, systemRoleList, getSystemUserInfo, getCityList, addSystemUserInfo, editSystemUserInfo, getCascaderData } from '../service';
import CryptoJS from 'crypto-js';
const formItemLayout = {
    labelCol: { span: 8 },
@@ -27,7 +29,10 @@
    //所属角色
    const [roleList, setRoleList] = useState([])
    //账号层级
    const [levelList, setLevelList] = useState([{ name: '市级账号', value: 1 }, { name: '区县账号', value: 2 }, { name: '街道账号', value: 3 }, { name: '社区账号', value: 4 }, { name: '党员账号', value: 5 }])
    const [levelList, setLevelList] = useState([])
    //级联数据
    const [cascaderData, setCascaderData] = useState([])
    //选择的层级
    const [activeLevel, setActiveLevel] = useState('')
    //所属区县
@@ -37,11 +42,11 @@
    const [streetList, setStreetList] = useState([])
    const [activeStreet, setActiveStreet] = useState({})
    //所属社区
    const [communityList, setCommunityList] = useState([])
    const [activeCommunity, setActiveCommunity] = useState({})
    const [accountLevels, setAccountLevels] = useState([
        { area: [], isDiscipline: 0, options: [] }
    ]);
    useEffect(() => {
        // 获取单位
@@ -51,63 +56,14 @@
    useImperativeHandle(ref, () => {
        return {
            refreshData: (data, companyList) => {
                getCountyList()
                getCascaderDatas()
                setOneCompanyList(() => companyList)
                console.log('companyList', companyList)
                systemPostList({ pageNum: 1, pageSize: 10000 }).then(res => {
                    setPositionList(() => res.data.records)
                })
                systemRoleList({ pageNum: 1, pageSize: 10000 }).then(res => {
                    setRoleList(() => res.data.records)
                })
                // 权限判断
                let adminInfo = JSON.parse(localStorage.getItem('userInfo'))
                setAdminLevel(() => adminInfo.accountLevel)
                switch (adminInfo.accountLevel) {
                    case 1:
                        setLevelList(() => [{ name: '市级账号', value: 1 }, { name: '区县账号', value: 2 }, { name: '街道账号', value: 3 }, { name: '社区账号', value: 4 }, { name: '党员账号', value: 5 }])
                        break;
                    case 2:
                        getStreetList(adminInfo.districtsCode)
                        setLevelList(() => [{ name: '区县账号', value: 2 }, { name: '街道账号', value: 3 }, { name: '社区账号', value: 4 }, { name: '党员账号', value: 5 }])
                        this.$nextTick(() => {
                            form.setFieldsValue({ districtsCode: adminInfo.districtsCode })
                        })
                        break;
                    case 3:
                        getStreetList(adminInfo.districtsCode)
                        getcommunityList(adminInfo.streetId)
                        setLevelList(() => [{ name: '街道账号', value: 3 }, { name: '社区账号', value: 4 }, { name: '党员账号', value: 5 }])
                        form.setFieldsValue({ districtsCode: adminInfo.districtsCode })
                        form.setFieldsValue({ streetId: adminInfo.streetId })
                        break;
                    case 4:
                        getStreetList(adminInfo.districtsCode)
                        getcommunityList(adminInfo.streetId)
                        setLevelList(() => [{ name: '社区账号', value: 4 }, { name: '党员账号', value: 5 }])
                        // this.$nextTick(() => {
                        form.setFieldsValue({ districtsCode: adminInfo.districtsCode })
                        form.setFieldsValue({ streetId: adminInfo.streetId })
                        form.setFieldsValue({ communityId: adminInfo.communityId * 1 })
                        // })
                        break;
                    case 5:
                        getStreetList(adminInfo.districtsCode)
                        getcommunityList(adminInfo.streetId)
                        setLevelList(() => [{ name: '党员账号', value: 5 }])
                        form.setFieldsValue({ districtsCode: adminInfo.districtsCode })
                        form.setFieldsValue({ streetId: adminInfo.streetId })
                        form.setFieldsValue({ communityId: adminInfo.communityId * 1 })
                        break;
                    default:
                        break;
                }
                if (data.id) {
                    getInfo(data.id)
@@ -128,9 +84,51 @@
    // 保存
    const okHandle = () => {
        form.validateFields().then((values) => {
            if(values.password){
            // 校验accountLevels必填
            if (!accountLevels.length || accountLevels.some(item => !item.area || item.area.length === 0)) {
                if (window?.antd?.message?.error) {
                    window.antd.message.error('请完整选择账号所属层级区域!');
                } else {
                    alert('请完整选择账号所属层级区域!');
                }
                return;
            }
            // 打印提交时的accountLevels数组
            console.log('提交时的accountLevels:', accountLevels);
            // 组装 systemUserLevels,严格按照接口字段,优先用原始字段
            const systemUserLevels = accountLevels.map(item => {
                // Get the first selected option's id as the level
                const firstSelectedOption = item.selectedOptions?.[0];
                const level = firstSelectedOption?.id || item.level || '';
                // 判断不同级别(假设市级别id为1,区县级别id为2,街道级别id为3,社区级别id为4)
                const isCityLevel = level === '1';
                const isDistrictLevel = level === '2';
                const isStreetLevel = level === '3';
                const isCommunityLevel = level === '4';
                return {
                    // 市级别:所有下级字段为空
                    // 区县级别:街道和社区字段为空
                    // 街道级别:社区字段为空
                    // 社区级别:不做处理
                    community: (isCityLevel || isDistrictLevel || isStreetLevel) ? '' : (item.community || item.selectedOptions?.[3]?.name || ''),
                    communityId: (isCityLevel || isDistrictLevel || isStreetLevel) ? '' : (item.communityId || item.selectedOptions?.[3]?.id || ''),
                    districts: isCityLevel ? '' : (item.districts || item.selectedOptions?.[1]?.name || ''),
                    districtsCode: isCityLevel ? '' : (item.districtsCode || item.selectedOptions?.[1]?.id || ''),
                    id: item.id || '', // 编辑时可用
                    level: level, // Use the determined level value
                    status: 1,
                    street: (isCityLevel || isDistrictLevel) ? '' : (item.street || item.selectedOptions?.[2]?.name || ''),
                    streetId: (isCityLevel || isDistrictLevel) ? '' : (item.streetId || item.selectedOptions?.[2]?.id || ''),
                    superviseFlag: typeof item.isDiscipline === 'number' ? item.isDiscipline : (item.isDiscipline ? 1 : 0),
                    // systemUserId: 可选,如有需要补充
                };
            });
            values.systemUserLevels = systemUserLevels;
            if (values.password) {
                values.password = CryptoJS.MD5(values.password).toString();
            }else{
            } else {
                delete values.password
            }
            if (values.DepartmentId) {
@@ -144,54 +142,73 @@
                onUpdate(values)
            } else {
                onSave(values);
                setAccountLevels([{ area: [], isDiscipline: 0, options: [] }]); // 清空
            }
        });
    };
    const getCountyList = (id) => {
        getCityList({ id: '510400', tier: 2 }).then(res => {
            setCountyList(() => res.data)
        })
    }
    const getStreetList = (id) => {
        getCityList({ id: id, tier: 3 }).then(res => {
            setStreetList(() => res.data)
        })
    }
    const getcommunityList = (id) => {
        getCityList({ id: id, tier: 4 }).then(res => {
            setCommunityList(() => res.data)
        })
    }
    const changeCountry = (value, label) => {
        setActiveCounty(label)
        getStreetList(value)
        form.setFieldsValue({ streetId: '', communityId: '' })
        setActiveCommunity({ name: '', id: '' })
        setActiveStreet({ name: '', id: '' })
    // 获取级联数据
    const getCascaderDatas = () => {
        getCascaderData().then(res => {
            // 处理级联数据
            const processedData = res.data.map(item => {
                // 根据第一级类型处理数据
                if (item.children) {
                    // 区县级别
                    if (item.id == 2) { // 假设type=2表示区县
                        // 只保留第一级children
                        item.children = item.children.map(child => {
                            const { children, ...childWithoutChildren } = child;
                            return childWithoutChildren;
                        });
                    }
                    // 街道级别
                    else if (item.id == 3) { // 假设type=3表示街道
                        // 保留区县和街道两级
                        item.children = item.children.map(child => {
                            if (child.children) {
                                child.children = child.children.map(street => {
                                    const { children, ...streetWithoutChildren } = street;
                                    return streetWithoutChildren;
                                });
                            }
                            return child;
                        });
                    }
                    // 社区级别
                    else if (item.id == 4) { // 假设type=4表示社区
                        // 保留所有层级数据
                        return item;
                    }
                }
                return item;
            });
            let arr = JSON.parse(JSON.stringify(processedData))
            let accountLevels = localStorage.getItem('userInfo')
            let accountLevel = JSON.parse(accountLevels).accountLevel
            if (accountLevel == 2) {
                arr = arr.filter(item => item.id != 1)
            } else if (accountLevel == 3) {
                arr = arr.filter(item => item.id != 1 && item.id != 2)
            } else if (accountLevel == 4) {
                arr = arr.filter(item => item.id != 1 && item.id != 2 && item.id != 3)
            }
            setCascaderData(() => arr);
        });
    }
    const changeStreet = (value, label) => {
        setActiveStreet(label)
        getcommunityList(value)
        form.setFieldsValue({ communityId: '' })
        setActiveCommunity({ name: '', id: '' })
    }
    const changeCommunity = (value, label) => {
        setActiveCommunity(label)
    }
    const getInfo = (id) => {
        getSystemUserInfo(id).then(res => {
            if (res.data.districtsCode) {
                setActiveStreet({ name: res.data.districts, id: res.data.districtsCode })
                getStreetList(res.data.districtsCode)
            }
            if (res.data.streetId) {
                setActiveCounty({ name: res.data.street, id: res.data.streetId })
                getcommunityList(res.data.streetId)
            }
            if (res.data.communityId) {
                setActiveCommunity({ name: res.data.community, id: res.data.communityId })
            }
            // delete res.data.password
            let departmentId = []
@@ -208,8 +225,89 @@
                departmentId.push(res.data.fourDepartmentId)
            }
            res.data.DepartmentId = departmentId
            console.log('departmentId', departmentId)
            setActiveLevel(() => res.data.accountLevel)
            // 先获取级联数据再回显
            getCascaderData().then(cascadeRes => {
                // 处理级联数据
                const processedData = cascadeRes.data.map(item => {
                    // 根据第一级类型处理数据
                    if (item.children) {
                        // 区县级别
                        if (item.id == 2) { // 假设type=2表示区县
                            // 只保留第一级children
                            item.children = item.children.map(child => {
                                const { children, ...childWithoutChildren } = child;
                                return childWithoutChildren;
                            });
                        }
                        // 街道级别
                        else if (item.id == 3) { // 假设type=3表示街道
                            // 保留区县和街道两级
                            item.children = item.children.map(child => {
                                if (child.children) {
                                    child.children = child.children.map(street => {
                                        const { children, ...streetWithoutChildren } = street;
                                        return streetWithoutChildren;
                                    });
                                }
                                return child;
                            });
                        }
                        // 社区级别
                        else if (item.id == 4) { // 假设type=4表示社区
                            // 保留所有层级数据
                            return item;
                        }
                    }
                    return item;
                });
                let arr = JSON.parse(JSON.stringify(processedData))
                let accountLevels = localStorage.getItem('userInfo')
                let accountLevel = JSON.parse(accountLevels).accountLevel
                if (accountLevel == 2) {
                    arr = arr.filter(item => item.id != 1)
                } else if (accountLevel == 3) {
                    arr = arr.filter(item => item.id != 1 && item.id != 2)
                } else if (accountLevel == 4) {
                    arr = arr.filter(item => item.id != 1 && item.id != 2 && item.id != 3)
                }
                setCascaderData(() => arr);
                // 回显accountLevels,area始终为4级,id类型统一
                if (res.data.systemUserLevels && Array.isArray(res.data.systemUserLevels)) {
                    const newAccountLevels = res.data.systemUserLevels.map(level => {
                        const toId = v => (v === undefined || v === null) ? undefined : String(v);
                        const area = [
                            toId(level.level),
                            toId(level.twoLevelId || level.districtsCode),
                            toId(level.threeLevelId || level.streetId),
                            toId(level.fourLevelId || level.communityId)
                        ].filter(v => v !== undefined && v !== null && v !== '');
                        return {
                            area,
                            isDiscipline: Number(level.superviseFlag) === 1 ? 1 : 0,
                            options: [],
                            selectedOptions: [
                                level.level ? { id: toId(level.level), name: '' } : undefined,
                                level.twoLevelName ? { id: toId(level.twoLevelId), name: level.twoLevelName } : undefined,
                                level.threeLevelName ? { id: toId(level.threeLevelId), name: level.threeLevelName } : undefined,
                                level.fourLevelName ? { id: toId(level.fourLevelId), name: level.fourLevelName } : undefined,
                            ].filter(Boolean),
                            level: toId(level.level) || '',
                            community: level.community || '',
                            communityId: level.communityId || '',
                            districts: level.districts || '',
                            districtsCode: level.districtsCode || '',
                            id: level.id || '',
                            street: level.street || '',
                            streetId: level.streetId || '',
                        };
                    });
                    setAccountLevels(newAccountLevels.length ? newAccountLevels : [{ area: [], isDiscipline: 0, options: [], level: '', community: '', communityId: '', districts: '', districtsCode: '', id: '', street: '', streetId: '' }]);
                }
            });
            form.setFieldsValue({ ...res.data, password: '' })
        })
@@ -235,13 +333,32 @@
        return false
    }
    // 动态添加账号层级项
    const addAccountLevel = () => {
        setAccountLevels([...accountLevels, { area: [], isDiscipline: 0, options: [] }]);
    };
    // 删除账号层级项
    const removeAccountLevel = (idx) => {
        if (accountLevels.length === 1) return;
        setAccountLevels(accountLevels.filter((_, i) => i !== idx));
    };
    // 纪检委单选变更
    const handleDisciplineChange = (e, idx) => {
        setAccountLevels(levels => {
            const newLevels = [...levels];
            newLevels[idx].isDiscipline = e.target.value;
            return newLevels;
        });
    };
    return (
        <Modal
            getContainer={false}
            width="65%"
            width="75%"
            destroyOnClose
            title={data.type == 'detail' ? '人员详情' : data.type == 'edit' ? '编辑人员' : '添加人员'}
            open={visible}
            className='addAndEditModal'
            onCancel={() => onCancel(false)}
            afterClose={() => {
                form.resetFields()
@@ -258,8 +375,8 @@
                    <Button key="back" onClick={() => onCancel(false)}>关闭</Button>
            }
        >
            <Form layout="horizontal" {...formItemLayout} form={form} scrollToFirstError>
                <Row>
            <Form layout="horizontal" form={form} scrollToFirstError labelCol={{ span: 6 }} wrapperCol={{ span: 20 }}>
                <Row gutter={16}>
                    <Col span={8}>
                        <Form.Item
                            name="name"
@@ -269,90 +386,6 @@
                            <Input disabled={data.type == 'detail'} placeholder='请输入人员姓名' />
                        </Form.Item>
                    </Col>
                </Row>
                <Row>
                    <Col span={16}>
                        <Form.Item
                            name="DepartmentId"
                            label="所属单位"
                            labelCol={{ span: 4 }}
                            rules={[{ required: true, message: '请选择所属单位' }]}
                        >
                            {/* <Select
                                key="searchSelect"
                                allowClear
                                disabled={data.type == 'detail'}
                                placeholder="请选择"
                                options={oneCompanyList}
                                fieldNames={{ label: 'name', value: 'id' }}
                                filterOption={false}
                            >
                            </Select > */}
                            <Cascader
                                changeSelect
                                options={oneCompanyList}
                                fieldNames={{ value: 'key', label: 'name' }}
                                placeholder="请选择"
                                // displayRender={(label) => label[label.length - 1]}
                                changeOnSelect={true}
                            />
                        </Form.Item>
                    </Col>
                    {/* <Col span={8}>
                        <Form.Item
                            name="twoDepartmentId"
                            label="所属二级单位"
                        >
                            <Select
                                key="searchSelect"
                                allowClear
                                disabled={data.type == 'detail'}
                                placeholder="请选择"
                                options={twoCompanyList}
                                fieldNames={{ label: 'name', value: 'id' }}
                                filterOption={false}
                            >
                            </Select >
                        </Form.Item>
                    </Col>
                    <Col span={8}>
                        <Form.Item
                            name="threeDepartmentId"
                            label="所属三级单位"
                        >
                            <Select
                                key="searchSelect"
                                allowClear
                                disabled={data.type == 'detail'}
                                placeholder="请选择"
                                options={threeCompanyList}
                                fieldNames={{ label: 'name', value: 'id' }}
                                filterOption={false}
                            >
                            </Select >
                        </Form.Item>
                    </Col> */}
                </Row>
                {/* <Row>
                    <Col span={8}>
                        <Form.Item
                            name="fourDepartmentId"
                            label="所属四级单位"
                        >
                            <Select
                                key="searchSelect"
                                allowClear
                                disabled={data.type == 'detail'}
                                placeholder="请选择"
                                options={fourCompanyList}
                                fieldNames={{ label: 'name', value: 'id' }}
                                filterOption={false}
                            >
                            </Select >
                        </Form.Item>
                    </Col>
                </Row> */}
                <Row>
                    <Col span={8}>
                        <Form.Item
                            name="systemPostId"
@@ -360,197 +393,120 @@
                            rules={[{ required: true, message: '请选择所属职位' }]}
                        >
                            <Select
                                key="searchSelect"
                                allowClear
                                disabled={data.type == 'detail'}
                                placeholder="请选择"
                                options={positionList}
                                fieldNames={{ label: 'name', value: 'id' }}
                                filterOption={false}
                            >
                            </Select >
                            />
                        </Form.Item>
                    </Col>
                    <Col span={8}>
                        <Form.Item
                            name="systemRoleId"
                            label="所属角色"
                            rules={[{ required: true, message: '请选择所属角色' }]}
                            label="后台权限"
                            rules={[{ required: true, message: '请选择后台权限' }]}
                        >
                            <Select
                                key="searchSelect"
                                allowClear
                                disabled={data.type == 'detail'}
                                placeholder="请选择"
                                options={roleList}
                                fieldNames={{ label: 'name', value: 'id' }}
                                filterOption={false}
                            >
                            </Select >
                            />
                        </Form.Item>
                    </Col>
                </Row>
                <Row>
                <Row gutter={16}>
                    <Col span={24}>
                        <Form.Item
                            label="账号所属层级"
                            colon={true}
                            required
                            labelCol={{ span: 2 }}
                            wrapperCol={{ span: 12 }}
                            style={{ marginBottom: 0 }}
                        >
                            <Button type={'primary'} onClick={addAccountLevel} style={{ marginBottom: 8 }}>添加</Button>
                            {accountLevels.map((item, idx) => (
                                <Card key={idx} style={{ marginBottom: 8 }} size='small' >
                                    <div style={{ display: 'flex', alignItems: 'center' }}>
                                        <Cascader
                                            style={{ width: 320, marginRight: 16 }}
                                            placeholder="请选择区域"
                                            options={cascaderData}
                                            fieldNames={{ label: 'name', value: 'id' }}
                                            value={item.area}
                                            onChange={(value, selectedOptions) => {
                                                setAccountLevels(levels => {
                                                    const newLevels = [...levels];
                                                    newLevels[idx] = {
                                                        ...newLevels[idx],
                                                        area: value,
                                                        selectedOptions: selectedOptions,
                                                        // 清空原有数据,确保新选择的数据生效
                                                        community: '',
                                                        communityId: '',
                                                        districts: '',
                                                        districtsCode: '',
                                                        street: '',
                                                        streetId: '',
                                                        level: selectedOptions?.[0]?.id || ''
                                                    };
                                                    return newLevels;
                                                });
                                            }}
                                        />
                                        <div style={{ marginLeft: 16, marginTop: 22 }}>
                                            <span style={{ marginRight: 8 }}>是否为纪检委账号:</span>
                                            <Radio.Group
                                                style={{ marginRight: 16 }}
                                                value={item.isDiscipline ?? 0}
                                                onChange={e => handleDisciplineChange(e, idx)}
                                                options={[
                                                    { label: '否', value: 0 },
                                                    { label: '是', value: 1 }
                                                ]}
                                            />
                                        </div>
                                        {idx > 0 && <DeleteOutlined style={{ marginRight: 16 }} onClick={() => removeAccountLevel(idx)} disabled={accountLevels.length === 1} />}
                                    </div>
                                </Card>
                            ))}
                        </Form.Item>
                    </Col>
                </Row>
                <Row gutter={16}>
                    <Col span={8}>
                        <Form.Item
                            name="accountLevel"
                            label="账号层级"
                            rules={[{ required: true, message: '请选择账号层级' }]}
                        >
                            <Select
                                key="searchSelect"
                                allowClear
                                onChange={(e) => setActiveLevel(e)}
                                disabled={data.type == 'detail'}
                                placeholder="请选择"
                                options={levelList}
                                fieldNames={{ label: 'name', value: 'value' }}
                            // filterOption={false}
                            >
                            </Select >
                        </Form.Item>
                    </Col>
                    <Col span={16}>
                        <Form.Item
                            label="是否管理员"
                            labelCol={{ span: 4 }}
                            wrapperCol={{ span: 20 }}
                            style={{ marginBottom: 0 }}
                        >
                            <div style={{ display: "flex", flex: 1 }}>
                                <Form.Item
                                    name="isAdmin"
                                    rules={[{ required: true, message: '是否管理员' }]}
                                >
                                    <Radio.Group
                                        disabled={data.type == 'detail'}
                                        // style={style}
                                        // onChange={onChange}
                                        // value={value}
                                        options={[{ value: 0, label: '否', }, { value: 1, label: '是', },
                                        ]}
                                    />
                                </Form.Item>
                                <div style={{ fontSize: '12px', color: "rgba(0,0,0,0.5)", marginLeft: "10px" }}>管理员主要用于接收实现临期提醒,以及上级端登录</div>
                            </div>
                        </Form.Item>
                    </Col>
                </Row>
                {activeLevel != 1 && (
                    <Row>
                        {[2, 3, 4, 5].includes(activeLevel) && (
                            <Col span={8}>
                                <Form.Item
                                    name="districtsCode"
                                    label="所属区县"
                                    rules={[{ required: true, message: '请选择所属区县' }]}
                                >
                                    {/* <Select
                                // onChange={changeCountry}
                                // value={activeCounty}
                                placeholder="请选择"
                                options={levelList}
                                fieldNames={{ label: 'name', value: 'id' }}
                            >
                            </Select > */}
                                    <Select
                                        key="searchSelect"
                                        allowClear
                                        disabled={data.type == 'detail' || [2, 3, 4, 5].includes(adminLevel)}
                                        onChange={changeCountry}
                                        value={activeCounty.id}
                                        placeholder="请选择"
                                        options={countyList}
                                        fieldNames={{ label: 'name', value: 'id' }}
                                    // filterOption={false}
                                    >
                                    </Select >
                                </Form.Item>
                            </Col>
                        )}
                        {[3, 4, 5].includes(activeLevel) && (
                            <Col span={8}>
                                <Form.Item
                                    name="streetId"
                                    label="所属街道"
                                    rules={[{ required: true, message: '请选择所属街道' }]}
                                >
                                    <Select
                                        onChange={changeStreet}
                                        disabled={!activeCounty || data.type == 'detail' || [3, 4, 5].includes(adminLevel)}
                                        key="searchSelect"
                                        allowClear
                                        value={activeStreet.id}
                                        placeholder="请选择"
                                        options={streetList}
                                        fieldNames={{ label: 'name', value: 'id' }}
                                    >
                                    </Select >
                                </Form.Item>
                            </Col>
                        )}
                        {[4, 5].includes(activeLevel) && (
                            <Col span={8}>
                                <Form.Item
                                    name="communityId"
                                    label="所属社区"
                                    rules={[{ required: true, message: '请选择所属社区' }]}
                                >
                                    <Select
                                        onChange={changeCommunity}
                                        disabled={!activeStreet || data.type == 'detail' || [4, 5].includes(adminLevel)}
                                        key="searchSelect"
                                        allowClear
                                        value={activeCommunity.id}
                                        placeholder="请选择"
                                        options={communityList}
                                        fieldNames={{ label: 'name', value: 'id' }}
                                    >
                                    </Select >
                                </Form.Item>
                            </Col>
                        )}
                    </Row>
                )}
                <Row>
                    <Col span={16}>
                        <Form.Item
                            label="联系方式"
                            required
                            labelCol={{ span: 4 }}
                            wrapperCol={{ span: 20 }}
                            style={{ marginBottom: 0 }}
                            name="phone"
                            extra={'联系方式将作为登录账号使用'}
                            rules={[{
                                validator: (rule, value) => {
                                    return new Promise((resolve, reject) => {
                                        if (!value) {
                                            reject('请输入联系方式');
                                        }
                                        const phoneRegex = /^((\+86)?(13|14|15|16|17|18|19)[0-9]{9})|((\+86)?(0[0-9]{2,3})?([2-9][0-9]{6,7}))$/;
                                        if (!phoneRegex.test(value)) {
                                            reject('请输入正确的电话号码');
                                        }
                                        resolve('');
                                    });
                                },
                            }]}
                        >
                            <div style={{ display: "flex", flex: 1 }}>
                                <Form.Item
                                    name="phone"
                                    rules={[{
                                        validator: (rule, value) => {
                                            return new Promise((resolve, reject) => {
                                                if (!value) {
                                                    reject('请输入联系方式');
                                                }
                                                const phoneRegex = /^((\+86)?(13|14|15|16|17|18|19)[0-9]{9})|((\+86)?(0[0-9]{2,3})?([2-9][0-9]{6,7}))$/;
                                                if (!phoneRegex.test(value)) {
                                                    reject('请输入正确的电话号码');
                                                }
                                                resolve('');
                                            });
                                        },
                                    }]}
                                >
                                    <Input disabled={data.type == 'detail'} placeholder='请输入联系方式' />
                                </Form.Item>
                                <div style={{ fontSize: '12px', color: "rgba(0,0,0,0.5)", marginLeft: "10px" }}>联系方式将作为登录账号使用</div>
                            </div>
                            <Input disabled={data.type == 'detail'} placeholder='请输入联系方式' />
                        </Form.Item>
                    </Col>
                </Row>
                <Row>
                <Row gutter={16}>
                    <Col span={8}>
                        <Form.Item
                            required={data.type == 'add'}
@@ -574,39 +530,32 @@
                            <Input.Password disabled={data.type == 'detail'} placeholder='请输入' />
                        </Form.Item>
                    </Col>
                    <Col span={16}>
                </Row>
                <Row gutter={16}>
                    <Col span={8}>
                        <Form.Item
                            label="确认密码"
                            name="surePassword"
                            extra={'密码需要包含大小写字母,数字和特殊符号,且长度为8位以上'}
                            required={data.type == 'add'}
                            labelCol={{ span: 4 }}
                            wrapperCol={{ span: 20 }}
                            style={{ marginBottom: 0 }}
                            rules={[{
                                validator: (rule, value) => {
                                    return new Promise((resolve, reject) => {
                                        if (!value && data.type == 'add') {
                                            reject('请再次输入新密码');
                                        }
                                        if (value != form.getFieldValue('password') && data.type == 'add') {
                                            reject('两次密码请保持一致');
                                        }
                                        resolve('');
                                    });
                                },
                            }]}
                        >
                            <div style={{ display: "flex", flex: 1 }}>
                                <Form.Item
                                    name="surePassword"
                                    rules={[{
                                        validator: (rule, value) => {
                                            return new Promise((resolve, reject) => {
                                                if (!value && data.type == 'add') {
                                                    reject('请再次输入新密码');
                                                }
                                                if (value != form.getFieldValue('password') && data.type == 'add') {
                                                    reject('两次密码请保持一致');
                                                }
                                                resolve('');
                                            });
                                        },
                                    },]}
                                >
                                    <Input.Password disabled={data.type == 'detail'} placeholder='请输入' />
                                </Form.Item>
                                <div style={{ fontSize: '12px', color: "rgba(0,0,0,0.5)", marginLeft: "10px" }}>密码需要包含大小写字母,数字和特殊符号,且长度为8位以上</div>
                            </div>
                            <Input.Password disabled={data.type == 'detail'} placeholder='请输入' />
                        </Form.Item>
                    </Col>
                </Row>
            </Form>
            <Spin spinning={spinning} fullscreen />