excel批量导入设备 配置成功
This commit is contained in:
@@ -198,6 +198,19 @@ export function unbindSmartDevice(data) {
|
||||
})
|
||||
}
|
||||
|
||||
// 批量导入绑定智能装备(上传 Excel)
|
||||
// 上传文件必须用 data(FormData)且带 multipart/form-data 头
|
||||
export function importBindDevices(data) {
|
||||
return request({
|
||||
url: '/iot/deviceRunParam/importData',
|
||||
method: 'post',
|
||||
data,
|
||||
headers: {
|
||||
'Content-Type': 'multipart/form-data'
|
||||
}
|
||||
})
|
||||
}
|
||||
|
||||
// 直播心跳
|
||||
|
||||
export function postLiveHeartbeat(data) {
|
||||
|
||||
@@ -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>
|
||||
|
||||
@@ -3132,6 +3132,8 @@ const en = {
|
||||
|
||||
s92: 'nickname',
|
||||
|
||||
importSuccess: 'Import Success',
|
||||
importFail: 'Import Failed',
|
||||
successFixed22: 'Bind Success ',
|
||||
|
||||
device2: 'No valid Device was selected. Unbinding is not possible.',
|
||||
|
||||
@@ -3167,6 +3167,8 @@ const zh = {
|
||||
|
||||
s92: '昵称',
|
||||
|
||||
importSuccess: '导入成功',
|
||||
importFail: '导入失败',
|
||||
successFixed22: '绑定成功',
|
||||
|
||||
device2: '未选择有效设备,无法解绑',
|
||||
|
||||
Reference in New Issue
Block a user