excel批量导入设备 配置成功
This commit is contained in:
@@ -761,7 +761,7 @@ const CesiumMap = React.forwardRef(({ ifClear, ifClearPlanLine, ifClearNavLine,
|
||||
}
|
||||
}
|
||||
|
||||
function flyToLayer(layerIdentifier, baseUrl, flyHeight = 1000) {
|
||||
function flyToLayer(layerIdentifier, baseUrl, flyHeight = 100) {
|
||||
//console.log('开始获取图层范围', layerIdentifier);
|
||||
const url = `${baseUrl}/wms?service=WMS&version=1.1.1&request=GetCapabilities`;
|
||||
|
||||
@@ -951,7 +951,7 @@ const CesiumMap = React.forwardRef(({ ifClear, ifClearPlanLine, ifClearNavLine,
|
||||
// 根据场站映射图层定位地图
|
||||
useEffect(() => {
|
||||
if (!mapLayer || !viewerRef.current) return;
|
||||
flyToLayer(mapLayer, envConfig.geoserver_url, 1000);
|
||||
flyToLayer(mapLayer, envConfig.geoserver_url, 100);
|
||||
}, [mapLayer]);
|
||||
|
||||
|
||||
|
||||
@@ -14,12 +14,14 @@ import {
|
||||
App,
|
||||
Card,
|
||||
InputNumber,
|
||||
Upload,
|
||||
} from 'antd';
|
||||
const { Text } = Typography;
|
||||
import {
|
||||
ReloadOutlined,
|
||||
LinkOutlined,
|
||||
DisconnectOutlined,
|
||||
UploadOutlined,
|
||||
EditOutlined,
|
||||
} from '@ant-design/icons';
|
||||
|
||||
@@ -27,6 +29,7 @@ import {
|
||||
getAllDevice,
|
||||
bindSmartDevice,
|
||||
unbindSmartDevice,
|
||||
importBindDevices,
|
||||
getDeviceAuth,
|
||||
hasPermission,
|
||||
} from '@/api/device';
|
||||
@@ -261,6 +264,28 @@ export default function SmartDeviceManagement({
|
||||
}, 0);
|
||||
};
|
||||
|
||||
// 上传 Excel 批量导入绑定装备
|
||||
const handleImportDevices = async (options: any) => {
|
||||
const { file, onSuccess, onError } = options;
|
||||
try {
|
||||
const formData = new FormData();
|
||||
formData.append('file', file);
|
||||
const res = await importBindDevices(formData);
|
||||
if (res.code == 200 && res.data == true) {
|
||||
utils.message.success(res.msg || t('systemSetting.importSuccess'));
|
||||
onSuccess?.(res);
|
||||
fetchSmartList();
|
||||
onAllDataNeedRefresh?.();
|
||||
} else {
|
||||
utils.message.error(res.msg || t('systemSetting.importFail'));
|
||||
onError?.(new Error(res.msg || 'import failed'));
|
||||
}
|
||||
} catch (err) {
|
||||
utils.message.error(t('systemSetting.importFail'));
|
||||
onError?.(err);
|
||||
}
|
||||
};
|
||||
|
||||
const handleBindSmart = async (values) => {
|
||||
try {
|
||||
const payload = {
|
||||
@@ -386,6 +411,9 @@ export default function SmartDeviceManagement({
|
||||
/>
|
||||
<Button icon={<ReloadOutlined />} onClick={() => setSmartParams({ pageNum: 1, pageSize: 10, serialNumber: '' })}>{t('common.reset')}</Button>
|
||||
<Button type="primary" icon={<LinkOutlined />} onClick={openBindSmartModal}>{t('systemSetting.equipmentFixed22')}</Button>
|
||||
<Upload customRequest={handleImportDevices} showUploadList={false} accept='.xlsx,.xls'>
|
||||
<Button icon={<UploadOutlined />}>{t('common.import')}</Button>
|
||||
</Upload>
|
||||
<Button disabled={selectedSmartKeys.length === 0} onClick={() => handleUnbindSmart(selectedSmartKeys, 1)}>{t('systemSetting.batchUnbindUser')}</Button>
|
||||
<Button disabled={selectedSmartKeys.length === 0} onClick={() => handleUnbindSmart(selectedSmartKeys, 2)}>{t('systemSetting.batchUnbindStation')}</Button>
|
||||
<Button disabled={selectedSmartKeys.length === 0} onClick={() => handleUnbindSmart(selectedSmartKeys, 3)}>{t('systemSetting.batchUnbindOrg')}</Button>
|
||||
|
||||
Reference in New Issue
Block a user