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) {
|
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);
|
//console.log('开始获取图层范围', layerIdentifier);
|
||||||
const url = `${baseUrl}/wms?service=WMS&version=1.1.1&request=GetCapabilities`;
|
const url = `${baseUrl}/wms?service=WMS&version=1.1.1&request=GetCapabilities`;
|
||||||
|
|
||||||
@@ -951,7 +951,7 @@ const CesiumMap = React.forwardRef(({ ifClear, ifClearPlanLine, ifClearNavLine,
|
|||||||
// 根据场站映射图层定位地图
|
// 根据场站映射图层定位地图
|
||||||
useEffect(() => {
|
useEffect(() => {
|
||||||
if (!mapLayer || !viewerRef.current) return;
|
if (!mapLayer || !viewerRef.current) return;
|
||||||
flyToLayer(mapLayer, envConfig.geoserver_url, 1000);
|
flyToLayer(mapLayer, envConfig.geoserver_url, 100);
|
||||||
}, [mapLayer]);
|
}, [mapLayer]);
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
@@ -14,12 +14,14 @@ import {
|
|||||||
App,
|
App,
|
||||||
Card,
|
Card,
|
||||||
InputNumber,
|
InputNumber,
|
||||||
|
Upload,
|
||||||
} from 'antd';
|
} from 'antd';
|
||||||
const { Text } = Typography;
|
const { Text } = Typography;
|
||||||
import {
|
import {
|
||||||
ReloadOutlined,
|
ReloadOutlined,
|
||||||
LinkOutlined,
|
LinkOutlined,
|
||||||
DisconnectOutlined,
|
DisconnectOutlined,
|
||||||
|
UploadOutlined,
|
||||||
EditOutlined,
|
EditOutlined,
|
||||||
} from '@ant-design/icons';
|
} from '@ant-design/icons';
|
||||||
|
|
||||||
@@ -27,6 +29,7 @@ import {
|
|||||||
getAllDevice,
|
getAllDevice,
|
||||||
bindSmartDevice,
|
bindSmartDevice,
|
||||||
unbindSmartDevice,
|
unbindSmartDevice,
|
||||||
|
importBindDevices,
|
||||||
getDeviceAuth,
|
getDeviceAuth,
|
||||||
hasPermission,
|
hasPermission,
|
||||||
} from '@/api/device';
|
} from '@/api/device';
|
||||||
@@ -261,6 +264,28 @@ export default function SmartDeviceManagement({
|
|||||||
}, 0);
|
}, 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) => {
|
const handleBindSmart = async (values) => {
|
||||||
try {
|
try {
|
||||||
const payload = {
|
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 icon={<ReloadOutlined />} onClick={() => setSmartParams({ pageNum: 1, pageSize: 10, serialNumber: '' })}>{t('common.reset')}</Button>
|
||||||
<Button type="primary" icon={<LinkOutlined />} onClick={openBindSmartModal}>{t('systemSetting.equipmentFixed22')}</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, 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, 2)}>{t('systemSetting.batchUnbindStation')}</Button>
|
||||||
<Button disabled={selectedSmartKeys.length === 0} onClick={() => handleUnbindSmart(selectedSmartKeys, 3)}>{t('systemSetting.batchUnbindOrg')}</Button>
|
<Button disabled={selectedSmartKeys.length === 0} onClick={() => handleUnbindSmart(selectedSmartKeys, 3)}>{t('systemSetting.batchUnbindOrg')}</Button>
|
||||||
|
|||||||
@@ -3132,6 +3132,8 @@ const en = {
|
|||||||
|
|
||||||
s92: 'nickname',
|
s92: 'nickname',
|
||||||
|
|
||||||
|
importSuccess: 'Import Success',
|
||||||
|
importFail: 'Import Failed',
|
||||||
successFixed22: 'Bind Success ',
|
successFixed22: 'Bind Success ',
|
||||||
|
|
||||||
device2: 'No valid Device was selected. Unbinding is not possible.',
|
device2: 'No valid Device was selected. Unbinding is not possible.',
|
||||||
|
|||||||
@@ -3167,6 +3167,8 @@ const zh = {
|
|||||||
|
|
||||||
s92: '昵称',
|
s92: '昵称',
|
||||||
|
|
||||||
|
importSuccess: '导入成功',
|
||||||
|
importFail: '导入失败',
|
||||||
successFixed22: '绑定成功',
|
successFixed22: '绑定成功',
|
||||||
|
|
||||||
device2: '未选择有效设备,无法解绑',
|
device2: '未选择有效设备,无法解绑',
|
||||||
|
|||||||
Reference in New Issue
Block a user