2026-08-07 09:56:12 +08:00
|
|
|
import React, { useState, useEffect } from 'react';
|
|
|
|
|
import {
|
|
|
|
|
Table,
|
|
|
|
|
Input,
|
|
|
|
|
Button,
|
|
|
|
|
Form,
|
|
|
|
|
Select,
|
|
|
|
|
Space,
|
|
|
|
|
Tag,
|
|
|
|
|
Modal,
|
|
|
|
|
Checkbox,
|
|
|
|
|
Tooltip,
|
|
|
|
|
Typography,
|
|
|
|
|
App,
|
|
|
|
|
} from 'antd';
|
|
|
|
|
const { Text } = Typography;
|
|
|
|
|
import {
|
|
|
|
|
ReloadOutlined,
|
|
|
|
|
LinkOutlined,
|
|
|
|
|
DisconnectOutlined,
|
|
|
|
|
} from '@ant-design/icons';
|
|
|
|
|
|
|
|
|
|
import {
|
|
|
|
|
getPlaneDeviceList,
|
|
|
|
|
bindDrone,
|
|
|
|
|
unbindDrone,
|
|
|
|
|
} from '@/api/device';
|
|
|
|
|
import { getOrgList } from '@/api/organization/index';
|
|
|
|
|
import { getSiteByOrgId, getStationList } from '@/api/stationManage/index';
|
|
|
|
|
import { getUser } from '@/api/user/index';
|
|
|
|
|
import { useSelector } from 'react-redux';
|
|
|
|
|
import { RootState } from '@/src/store';
|
|
|
|
|
import utils from '@/lib/utils';
|
2026-08-12 11:29:44 +08:00
|
|
|
import { useTranslation } from 'react-i18next';
|
2026-08-07 09:56:12 +08:00
|
|
|
|
|
|
|
|
interface DroneManagementProps {
|
|
|
|
|
allOrgOptions: any[];
|
|
|
|
|
allSiteOptions: any[];
|
|
|
|
|
allUserOptions: any[];
|
|
|
|
|
onAllDataNeedRefresh?: () => void;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
export default function DroneManagement({
|
|
|
|
|
allOrgOptions,
|
|
|
|
|
allSiteOptions,
|
|
|
|
|
allUserOptions,
|
|
|
|
|
onAllDataNeedRefresh,
|
|
|
|
|
}: DroneManagementProps) {
|
2026-08-12 11:29:44 +08:00
|
|
|
const { t } = useTranslation();
|
2026-08-07 09:56:12 +08:00
|
|
|
const { modal } = App.useApp();
|
|
|
|
|
const { userInfo } = useSelector((state: RootState) => state.user);
|
|
|
|
|
const { stationId, currentStation } = useSelector((state: RootState) => state.station);
|
|
|
|
|
|
|
|
|
|
const [loading, setLoading] = useState(false);
|
|
|
|
|
const [droneList, setDroneList] = useState([]);
|
|
|
|
|
const [bindModalVisible, setBindModalVisible] = useState(false);
|
|
|
|
|
const [bindForm] = Form.useForm();
|
|
|
|
|
const [selectedDroneKeys, setSelectedDroneKeys] = useState<any[]>([]);
|
|
|
|
|
|
|
|
|
|
const [droneParams, setDroneParams] = useState({
|
|
|
|
|
pageNum: 1,
|
|
|
|
|
pageSize: 20,
|
|
|
|
|
sn: '',
|
|
|
|
|
status: ''
|
|
|
|
|
});
|
|
|
|
|
const [droneTotal, setDroneTotal] = useState(0);
|
|
|
|
|
|
|
|
|
|
const [droneOrgOptions, setDroneOrgOptions] = useState([]);
|
|
|
|
|
const [droneSiteOptions, setDroneSiteOptions] = useState([]);
|
|
|
|
|
const [droneUserOptions, setDroneUserOptions] = useState([]);
|
|
|
|
|
|
|
|
|
|
const isAdmin = userInfo?.roleKey === 'admin';
|
|
|
|
|
const isManager = userInfo?.roleKey === 'manager' || userInfo?.roleKey === 'Manager';
|
|
|
|
|
const orgFieldDisabled = !isAdmin;
|
|
|
|
|
const siteFieldDisabled = !(isAdmin || isManager);
|
|
|
|
|
const userFieldDisabled = false;
|
|
|
|
|
|
|
|
|
|
const defaultOrgId = currentStation?.orgId || userInfo?.orgId;
|
|
|
|
|
const defaultSiteId = stationId || currentStation?.siteId || currentStation?.id;
|
|
|
|
|
const defaultUserId = userInfo?.userId;
|
|
|
|
|
|
|
|
|
|
const fetchDroneList = async () => {
|
|
|
|
|
setLoading(true);
|
|
|
|
|
try {
|
|
|
|
|
const res = await getPlaneDeviceList(droneParams);
|
|
|
|
|
if (res.code === 200) {
|
|
|
|
|
setDroneList(res.rows || []);
|
|
|
|
|
setDroneTotal(res.total || res.rows?.length || 0);
|
|
|
|
|
}
|
|
|
|
|
} catch (err) {
|
2026-08-14 09:02:52 +08:00
|
|
|
utils.message.error(t('systemSetting.uavFixed2ListFixed2FailedFixed2'));
|
2026-08-07 09:56:12 +08:00
|
|
|
} finally {
|
|
|
|
|
setLoading(false);
|
|
|
|
|
}
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
const fetchOrgs = async () => {
|
|
|
|
|
try {
|
|
|
|
|
const res = await getOrgList({});
|
|
|
|
|
if (res.code === 200) {
|
|
|
|
|
setDroneOrgOptions(res.rows || []);
|
|
|
|
|
}
|
|
|
|
|
return res;
|
|
|
|
|
} catch (err) {
|
|
|
|
|
console.error('获取组织列表失败', err);
|
|
|
|
|
return null;
|
|
|
|
|
}
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
const fetchSites = async (orgId) => {
|
|
|
|
|
try {
|
|
|
|
|
const res = await getSiteByOrgId({ id: orgId });
|
|
|
|
|
if (res.code === 200) {
|
|
|
|
|
setDroneSiteOptions(res.data || []);
|
|
|
|
|
}
|
|
|
|
|
return res;
|
|
|
|
|
} catch (err) {
|
|
|
|
|
console.error(err);
|
|
|
|
|
return null;
|
|
|
|
|
}
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
const fetchUsers = async (siteId) => {
|
|
|
|
|
try {
|
|
|
|
|
const res = await getUser({
|
|
|
|
|
siteId,
|
|
|
|
|
pageNum: 1,
|
|
|
|
|
pageSize: 1000
|
|
|
|
|
});
|
|
|
|
|
if (res.code === 200) {
|
|
|
|
|
setDroneUserOptions(res.rows || []);
|
|
|
|
|
}
|
|
|
|
|
return res;
|
|
|
|
|
} catch (err) {
|
|
|
|
|
console.error(err);
|
|
|
|
|
return null;
|
|
|
|
|
}
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
useEffect(() => {
|
|
|
|
|
fetchDroneList();
|
|
|
|
|
}, [droneParams]);
|
|
|
|
|
|
|
|
|
|
const openBindModal = async () => {
|
|
|
|
|
if (!selectedDroneKeys.length) {
|
2026-08-14 09:02:52 +08:00
|
|
|
return utils.message.warning(t('systemSetting.listUavFixed2'));
|
2026-08-07 09:56:12 +08:00
|
|
|
}
|
|
|
|
|
bindForm.resetFields();
|
|
|
|
|
setBindModalVisible(true);
|
|
|
|
|
setDroneOrgOptions([]);
|
|
|
|
|
setDroneSiteOptions([]);
|
|
|
|
|
setDroneUserOptions([]);
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
useEffect(() => {
|
|
|
|
|
if (!bindModalVisible) {
|
|
|
|
|
bindForm.resetFields();
|
|
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
const fetchAndSetForm = async () => {
|
|
|
|
|
const orgRes = await fetchOrgs();
|
|
|
|
|
const orgList = orgRes?.code === 200 ? (orgRes?.rows || []) : [];
|
|
|
|
|
setDroneOrgOptions(orgList);
|
|
|
|
|
|
|
|
|
|
const finalOrgId = defaultOrgId && orgList.some(o => (o.id || o.orgId) == defaultOrgId)
|
|
|
|
|
? defaultOrgId
|
|
|
|
|
: (orgList[0]?.id || orgList[0]?.orgId);
|
|
|
|
|
|
|
|
|
|
let siteList = [];
|
|
|
|
|
if (finalOrgId) {
|
|
|
|
|
const siteRes = await fetchSites(finalOrgId);
|
|
|
|
|
siteList = siteRes?.code === 200 ? (siteRes?.data || []) : [];
|
|
|
|
|
}
|
|
|
|
|
setDroneSiteOptions(siteList);
|
|
|
|
|
|
|
|
|
|
const finalSiteId = defaultSiteId && siteList.some(s => (s.id || s.siteId) == defaultSiteId)
|
|
|
|
|
? defaultSiteId
|
|
|
|
|
: (siteList[0]?.id || siteList[0]?.siteId);
|
|
|
|
|
|
|
|
|
|
let userList = [];
|
|
|
|
|
if (finalSiteId) {
|
|
|
|
|
const userRes = await fetchUsers(finalSiteId);
|
|
|
|
|
userList = userRes?.code === 200 ? (userRes?.rows || []) : [];
|
|
|
|
|
}
|
|
|
|
|
setDroneUserOptions(userList);
|
|
|
|
|
|
|
|
|
|
const finalUserId = defaultUserId && userList.some(u => u.userId == defaultUserId)
|
|
|
|
|
? defaultUserId
|
|
|
|
|
: (userList[0]?.userId);
|
|
|
|
|
|
|
|
|
|
requestAnimationFrame(() => {
|
|
|
|
|
bindForm.setFieldsValue({
|
|
|
|
|
sns: selectedDroneKeys.join(', '),
|
|
|
|
|
orgId: finalOrgId,
|
|
|
|
|
siteId: finalSiteId,
|
|
|
|
|
userId: finalUserId,
|
|
|
|
|
});
|
|
|
|
|
});
|
|
|
|
|
};
|
|
|
|
|
fetchAndSetForm();
|
|
|
|
|
}, [bindModalVisible, defaultOrgId, defaultSiteId, defaultUserId, selectedDroneKeys]);
|
|
|
|
|
|
|
|
|
|
const handleBind = async (values) => {
|
|
|
|
|
try {
|
|
|
|
|
const payload = {
|
|
|
|
|
siteId: values.siteId,
|
|
|
|
|
orgId: values.orgId,
|
|
|
|
|
userId: values.userId,
|
|
|
|
|
sns: values.sns.split(',').map(s => s.trim()),
|
|
|
|
|
};
|
|
|
|
|
const res = await bindDrone(payload);
|
|
|
|
|
if (res.code === 200 && res.data == true) {
|
2026-08-14 09:02:52 +08:00
|
|
|
utils.message.success(t('systemSetting.successFixed22'));
|
2026-08-07 09:56:12 +08:00
|
|
|
setBindModalVisible(false);
|
|
|
|
|
setSelectedDroneKeys([]);
|
|
|
|
|
bindForm.resetFields();
|
|
|
|
|
fetchDroneList();
|
|
|
|
|
onAllDataNeedRefresh?.();
|
|
|
|
|
} else {
|
2026-08-14 09:02:52 +08:00
|
|
|
utils.message.error(res.msg || t('systemSetting.bindFail'));
|
2026-08-07 09:56:12 +08:00
|
|
|
}
|
|
|
|
|
} catch (err) {
|
2026-08-14 09:02:52 +08:00
|
|
|
utils.message.error(t('systemSetting.fixed2ActionsFixed2AbnormalFixed2'));
|
2026-08-07 09:56:12 +08:00
|
|
|
}
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
const handleUnbind = (sns, type) => {
|
|
|
|
|
const validSns = (sns || []).filter(item =>
|
|
|
|
|
item !== null && item !== undefined && item !== '' && item.trim() !== ''
|
|
|
|
|
);
|
|
|
|
|
if (validSns.length === 0) {
|
2026-08-14 09:02:52 +08:00
|
|
|
return utils.message.warning(t('systemSetting.device2'));
|
2026-08-07 09:56:12 +08:00
|
|
|
}
|
2026-08-14 09:02:52 +08:00
|
|
|
const typeText = { 1: t('systemSetting.person'), 2: t('systemSetting.s24'), 3: t('systemSetting.s34') }[type];
|
2026-08-07 09:56:12 +08:00
|
|
|
modal.confirm({
|
2026-08-14 09:02:52 +08:00
|
|
|
title: t('systemSetting.fixed2Confirm'),
|
|
|
|
|
content: t('systemSetting.confirmClearBinding', { type: typeText }),
|
2026-08-12 11:29:44 +08:00
|
|
|
okText: t('common.ok'),
|
|
|
|
|
cancelText: t('common.cancel'),
|
2026-08-07 09:56:12 +08:00
|
|
|
onOk: async () => {
|
|
|
|
|
try {
|
|
|
|
|
const res = await unbindDrone({ sns: validSns, type });
|
|
|
|
|
if (res.code === 200) {
|
2026-08-14 09:02:52 +08:00
|
|
|
utils.message.success(t('systemSetting.successFixed2'));
|
2026-08-07 09:56:12 +08:00
|
|
|
fetchDroneList();
|
|
|
|
|
setSelectedDroneKeys([]);
|
|
|
|
|
onAllDataNeedRefresh?.();
|
|
|
|
|
} else {
|
2026-08-14 09:02:52 +08:00
|
|
|
utils.message.error(res.msg || t('systemSetting.unbindFail'));
|
2026-08-07 09:56:12 +08:00
|
|
|
}
|
|
|
|
|
} catch (err) {
|
2026-08-14 09:02:52 +08:00
|
|
|
utils.message.error(t('systemSetting.fixed2ActionsFixed2AbnormalFixed2'));
|
2026-08-07 09:56:12 +08:00
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
});
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
const droneColumns = [
|
2026-08-12 11:29:44 +08:00
|
|
|
{ title: t('devices.deviceName'), width: 150, dataIndex: 'drone_callsign', key: 'name' },
|
|
|
|
|
{ title: t('systemSetting.snCode'), width: 180, dataIndex: 'device_sn', key: 'sn' },
|
2026-08-14 09:02:52 +08:00
|
|
|
{ title: t('systemSetting.sn'), width: 150, dataIndex: 'gateway_sn', key: 'gsn' },
|
2026-08-07 09:56:12 +08:00
|
|
|
{
|
2026-08-14 09:02:52 +08:00
|
|
|
title: t('systemSetting.belongingOrg'), width: 150, key: 'orgName',
|
2026-08-07 09:56:12 +08:00
|
|
|
render: (_, record) => {
|
|
|
|
|
const org = allOrgOptions.find(o => (o.orgId || o.id) == record.orgId);
|
2026-08-14 09:02:52 +08:00
|
|
|
return org ? (org.orgName || org.name) : <Text type="secondary">{t('systemSetting.s02')}</Text>;
|
2026-08-07 09:56:12 +08:00
|
|
|
},
|
|
|
|
|
},
|
|
|
|
|
{
|
2026-08-14 09:02:52 +08:00
|
|
|
title: t('systemSetting.s9'), width: 150, key: 'siteName',
|
2026-08-07 09:56:12 +08:00
|
|
|
render: (_, record) => {
|
|
|
|
|
const site = allSiteOptions.find(s => (s.siteId || s.id) == record.siteId);
|
2026-08-14 09:02:52 +08:00
|
|
|
return site ? (site.siteName || site.name) : <Text type="secondary">{t('systemSetting.s02')}</Text>;
|
2026-08-07 09:56:12 +08:00
|
|
|
},
|
|
|
|
|
},
|
|
|
|
|
{
|
2026-08-12 11:29:44 +08:00
|
|
|
title: t('systemSetting.leader'), width: 150, key: 'userName',
|
2026-08-07 09:56:12 +08:00
|
|
|
render: (_, record) => {
|
|
|
|
|
const user = allUserOptions.find(u => u.userId == record.userId);
|
2026-08-14 09:02:52 +08:00
|
|
|
return user ? (user.nickName || user.userName) : <Text type="secondary">{t('systemSetting.s02')}</Text>;
|
2026-08-07 09:56:12 +08:00
|
|
|
},
|
|
|
|
|
},
|
|
|
|
|
{
|
2026-08-12 11:29:44 +08:00
|
|
|
title: t('roles.status'), width: 150, dataIndex: 'onlineStatus', key: 'status',
|
|
|
|
|
render: s => <Tag color={s === 1 ? 'green' : 'default'}>{s === 1 ? t('devices.online') : t('devices.offline')}</Tag>
|
2026-08-07 09:56:12 +08:00
|
|
|
},
|
|
|
|
|
{
|
2026-08-12 11:29:44 +08:00
|
|
|
title: t('roles.actions'), key: 'action', fixed: 'right' as const, width: 250,
|
2026-08-07 09:56:12 +08:00
|
|
|
render: (_, record: any) => (
|
|
|
|
|
<Space>
|
2026-08-14 09:02:52 +08:00
|
|
|
<Tooltip title={t('systemSetting.s72')}>
|
|
|
|
|
<Button size="small" icon={<DisconnectOutlined />} onClick={() => handleUnbind([record.gateway_sn], 1)}>{t('systemSetting.s110')}</Button>
|
2026-08-07 09:56:12 +08:00
|
|
|
</Tooltip>
|
2026-08-14 09:02:52 +08:00
|
|
|
<Tooltip title={t('systemSetting.s83')}>
|
|
|
|
|
<Button size="small" icon={<DisconnectOutlined />} onClick={() => handleUnbind([record.gateway_sn], 2)}>{t('systemSetting.s24')}</Button>
|
2026-08-07 09:56:12 +08:00
|
|
|
</Tooltip>
|
2026-08-14 09:02:52 +08:00
|
|
|
<Tooltip title={t('systemSetting.s92')}>
|
|
|
|
|
<Button size="small" icon={<DisconnectOutlined />} onClick={() => handleUnbind([record.gateway_sn], 3)}>{t('systemSetting.s34')}</Button>
|
2026-08-07 09:56:12 +08:00
|
|
|
</Tooltip>
|
|
|
|
|
</Space>
|
|
|
|
|
),
|
|
|
|
|
},
|
|
|
|
|
];
|
|
|
|
|
|
|
|
|
|
const selectorgId = Form.useWatch('orgId', bindForm);
|
|
|
|
|
const selectsiteId = Form.useWatch('siteId', bindForm);
|
|
|
|
|
|
|
|
|
|
useEffect(() => {
|
|
|
|
|
if (selectorgId) {
|
|
|
|
|
fetchSites(selectorgId);
|
|
|
|
|
}
|
|
|
|
|
}, [selectorgId]);
|
|
|
|
|
|
|
|
|
|
useEffect(() => {
|
|
|
|
|
if (selectsiteId) {
|
|
|
|
|
fetchUsers(selectsiteId);
|
|
|
|
|
}
|
|
|
|
|
}, [selectsiteId]);
|
|
|
|
|
|
|
|
|
|
return (
|
|
|
|
|
<>
|
|
|
|
|
<div style={{ marginBottom: 16, display: 'flex', gap: 10, flexWrap: 'wrap' }}>
|
|
|
|
|
<Input
|
2026-08-14 09:02:52 +08:00
|
|
|
placeholder={t('systemSetting.sn')}
|
2026-08-07 09:56:12 +08:00
|
|
|
style={{ width: 200 }}
|
|
|
|
|
allowClear
|
|
|
|
|
value={droneParams.sn}
|
|
|
|
|
onChange={(e) => setDroneParams({ ...droneParams, sn: e.target.value })}
|
|
|
|
|
/>
|
|
|
|
|
<Select
|
2026-08-12 11:29:44 +08:00
|
|
|
placeholder={t('roles.status')}
|
2026-08-07 09:56:12 +08:00
|
|
|
style={{ width: 120 }}
|
|
|
|
|
value={droneParams.status}
|
|
|
|
|
allowClear
|
|
|
|
|
onChange={(val) => setDroneParams({ ...droneParams, status: val })}
|
|
|
|
|
>
|
2026-08-12 11:29:44 +08:00
|
|
|
<Select.Option value="1">{t('devices.online')}</Select.Option>
|
|
|
|
|
<Select.Option value="2">{t('devices.offline')}</Select.Option>
|
2026-08-07 09:56:12 +08:00
|
|
|
</Select>
|
2026-08-12 11:29:44 +08:00
|
|
|
<Button icon={<ReloadOutlined />} onClick={() => setDroneParams({ pageNum: 1, pageSize: 10, sn: '', status: '' })}>{t('common.reset')}</Button>
|
2026-08-14 09:02:52 +08:00
|
|
|
<Button type="primary" icon={<LinkOutlined />} onClick={openBindModal}>{t('systemSetting.uavFixed2')}</Button>
|
|
|
|
|
<Button disabled={selectedDroneKeys.length === 0} onClick={() => handleUnbind(selectedDroneKeys, 1)}>{t('systemSetting.batchUnbindUser')}</Button>
|
|
|
|
|
<Button disabled={selectedDroneKeys.length === 0} onClick={() => handleUnbind(selectedDroneKeys, 2)}>{t('systemSetting.batchUnbindStation')}</Button>
|
|
|
|
|
<Button disabled={selectedDroneKeys.length === 0} onClick={() => handleUnbind(selectedDroneKeys, 3)}>{t('systemSetting.batchUnbindGroup')}</Button>
|
2026-08-07 09:56:12 +08:00
|
|
|
</div>
|
|
|
|
|
|
|
|
|
|
<div style={{ height: 'calc(100vh - 220px)', overflowY: 'auto', paddingRight: '4px' }}>
|
|
|
|
|
<Table
|
|
|
|
|
rowSelection={{ selectedRowKeys: selectedDroneKeys, onChange: setSelectedDroneKeys as any }}
|
|
|
|
|
rowKey="gateway_sn"
|
|
|
|
|
columns={droneColumns}
|
|
|
|
|
dataSource={droneList}
|
|
|
|
|
loading={loading}
|
|
|
|
|
pagination={{
|
|
|
|
|
current: droneParams.pageNum,
|
|
|
|
|
pageSize: droneParams.pageSize,
|
|
|
|
|
total: droneTotal,
|
|
|
|
|
showSizeChanger: true,
|
2026-08-14 13:33:13 +08:00
|
|
|
showTotal: r => `${t('common.total')} ${r} ${t('common.items')}`,
|
2026-08-07 09:56:12 +08:00
|
|
|
onChange: (page, pageSize) => {
|
|
|
|
|
setDroneParams({ ...droneParams, pageNum: page, pageSize });
|
|
|
|
|
},
|
|
|
|
|
}}
|
|
|
|
|
scroll={{ y: 'auto', x: '700px' }}
|
|
|
|
|
/>
|
|
|
|
|
</div>
|
|
|
|
|
|
|
|
|
|
<Modal
|
|
|
|
|
title={
|
|
|
|
|
<div style={{ display: 'flex', alignItems: 'center', gap: 8 }}>
|
|
|
|
|
<span style={{ display: 'inline-block', width: 4, height: 18, background: 'linear-gradient(180deg, #1890ff 0%, #096dd9 100%)', borderRadius: 2 }}></span>
|
2026-08-14 09:02:52 +08:00
|
|
|
<span style={{ fontWeight: 600 }}>{t('systemSetting.uavFixed2')}</span>
|
2026-08-07 09:56:12 +08:00
|
|
|
</div>
|
|
|
|
|
}
|
|
|
|
|
open={bindModalVisible}
|
|
|
|
|
onCancel={() => {
|
|
|
|
|
setBindModalVisible(false);
|
|
|
|
|
setDroneOrgOptions([]);
|
|
|
|
|
setDroneSiteOptions([]);
|
|
|
|
|
setDroneUserOptions([]);
|
|
|
|
|
bindForm.resetFields();
|
|
|
|
|
}}
|
|
|
|
|
destroyOnClose={false}
|
|
|
|
|
onOk={() => bindForm.submit()}
|
|
|
|
|
width={540}
|
|
|
|
|
>
|
|
|
|
|
<Form form={bindForm} layout="vertical" onFinish={handleBind}>
|
2026-08-14 09:02:52 +08:00
|
|
|
<Form.Item label={t('systemSetting.selectedUavSn', { count: selectedDroneKeys.length })} name="sns" rules={[{ required: true, message: t('systemSetting.fixed2PleaseEnterSn') }]}>
|
|
|
|
|
<Input.TextArea placeholder={t('systemSetting.sn001Sn002')} rows={2} disabled style={{ resize: 'none', background: '#fafafa' }} />
|
2026-08-07 09:56:12 +08:00
|
|
|
</Form.Item>
|
|
|
|
|
<Form.Item
|
|
|
|
|
label={
|
|
|
|
|
<Space size={6}>
|
2026-08-14 09:02:52 +08:00
|
|
|
<span>{t('systemSetting.belongingOrg')}</span>
|
2026-08-07 09:56:12 +08:00
|
|
|
</Space>
|
|
|
|
|
}
|
2026-08-14 09:02:52 +08:00
|
|
|
name="orgId" rules={[{ required: true, message: t('systemSetting.pleaseSelectOrg') }]}
|
2026-08-07 09:56:12 +08:00
|
|
|
>
|
|
|
|
|
<Select
|
2026-08-14 09:02:52 +08:00
|
|
|
placeholder={t('systemSetting.pleaseSelectOrg')}
|
2026-08-07 09:56:12 +08:00
|
|
|
disabled={orgFieldDisabled}
|
|
|
|
|
allowClear={isAdmin}
|
|
|
|
|
onChange={(val) => {
|
|
|
|
|
if (isAdmin) {
|
|
|
|
|
bindForm.setFieldsValue({ siteId: undefined, userId: undefined });
|
|
|
|
|
}
|
|
|
|
|
}}
|
|
|
|
|
style={{ width: '100%' }}
|
|
|
|
|
>
|
|
|
|
|
{droneOrgOptions.map((org: any) => (
|
|
|
|
|
<Select.Option key={org.id || org.orgId} value={org.id || org.orgId}>{org.orgName || org.name}</Select.Option>
|
|
|
|
|
))}
|
|
|
|
|
</Select>
|
|
|
|
|
</Form.Item>
|
|
|
|
|
<Form.Item
|
|
|
|
|
label={
|
|
|
|
|
<Space size={6}>
|
2026-08-14 09:02:52 +08:00
|
|
|
<span>{t('systemSetting.s9')}</span>
|
2026-08-07 09:56:12 +08:00
|
|
|
</Space>
|
|
|
|
|
}
|
2026-08-14 09:02:52 +08:00
|
|
|
name="siteId" rules={[{ required: !siteFieldDisabled, message: t('systemSetting.fixed2PleaseSelect2') }]}
|
2026-08-07 09:56:12 +08:00
|
|
|
>
|
|
|
|
|
<Select
|
2026-08-14 09:02:52 +08:00
|
|
|
placeholder={t('systemSetting.s132')}
|
2026-08-07 09:56:12 +08:00
|
|
|
disabled={siteFieldDisabled}
|
|
|
|
|
allowClear={isAdmin || isManager}
|
|
|
|
|
onChange={(val) => {
|
|
|
|
|
if (isAdmin || isManager) {
|
|
|
|
|
bindForm.setFieldsValue({ userId: undefined });
|
|
|
|
|
}
|
|
|
|
|
}}
|
|
|
|
|
style={{ width: '100%' }}
|
|
|
|
|
>
|
|
|
|
|
{droneSiteOptions.map((site: any) => (
|
|
|
|
|
<Select.Option key={site.id || site.siteId} value={site.id || site.siteId}>{site.siteName || site.name}</Select.Option>
|
|
|
|
|
))}
|
|
|
|
|
</Select>
|
|
|
|
|
</Form.Item>
|
2026-08-14 09:02:52 +08:00
|
|
|
<Form.Item label={t('systemSetting.leader')} name="userId" rules={[{ required: true, message: t('systemSetting.fixed2PleaseSelectFixed2LeaderFixed2') }]}>
|
2026-08-07 09:56:12 +08:00
|
|
|
<Select
|
2026-08-14 09:02:52 +08:00
|
|
|
placeholder={t('systemSetting.leaderFixed2')}
|
2026-08-07 09:56:12 +08:00
|
|
|
allowClear
|
|
|
|
|
showSearch
|
|
|
|
|
optionFilterProp="children"
|
|
|
|
|
style={{ width: '100%' }}
|
|
|
|
|
>
|
|
|
|
|
{droneUserOptions.map((user: any) => (
|
|
|
|
|
<Select.Option key={user.userId} value={user.userId}>
|
|
|
|
|
{user.nickName || user.userName}
|
|
|
|
|
</Select.Option>
|
|
|
|
|
))}
|
|
|
|
|
</Select>
|
|
|
|
|
</Form.Item>
|
|
|
|
|
</Form>
|
|
|
|
|
</Modal>
|
|
|
|
|
</>
|
|
|
|
|
);
|
|
|
|
|
}
|