完善主站切换
This commit is contained in:
parent
90e0463306
commit
15cc3c7b14
@ -2232,7 +2232,7 @@ export const DeviceAuthenticationModeEnumSchema = {
|
||||
} as const;
|
||||
|
||||
export const DeviceBatchMasterSwitchInputSchema = {
|
||||
required: ['addressList', 'ioTPlatform', 'ioTPlatformProductId', 'masterStationAddress'],
|
||||
required: ['addressList', 'backupMasterStation', 'ioTPlatform', 'ioTPlatformProductId', 'masterStation'],
|
||||
type: 'object',
|
||||
properties: {
|
||||
addressList: {
|
||||
@ -2250,10 +2250,11 @@ export const DeviceBatchMasterSwitchInputSchema = {
|
||||
type: 'string',
|
||||
description: '物联网平台中对应的产品Id'
|
||||
},
|
||||
masterStationAddress: {
|
||||
minLength: 1,
|
||||
type: 'string',
|
||||
description: '目标主站地址(从主站下拉列表接口获取:OneNET 静态地址或 EMQX 配置地址)'
|
||||
masterStation: {
|
||||
'$ref': '#/components/schemas/MasterStationInput'
|
||||
},
|
||||
backupMasterStation: {
|
||||
'$ref': '#/components/schemas/MasterStationInput'
|
||||
}
|
||||
},
|
||||
additionalProperties: false,
|
||||
@ -2951,7 +2952,7 @@ export const DeviceManagementInfoDtoPagedResultDtoHttpDataResultSchema = {
|
||||
} as const;
|
||||
|
||||
export const DeviceMasterSwitchInputSchema = {
|
||||
required: ['id', 'ioTPlatformProductId', 'masterStationAddress'],
|
||||
required: ['backupMasterStation', 'id', 'ioTPlatformProductId', 'masterStation'],
|
||||
type: 'object',
|
||||
properties: {
|
||||
id: {
|
||||
@ -2963,10 +2964,11 @@ export const DeviceMasterSwitchInputSchema = {
|
||||
type: 'string',
|
||||
description: '物联网平台中对应的产品Id'
|
||||
},
|
||||
masterStationAddress: {
|
||||
minLength: 1,
|
||||
type: 'string',
|
||||
description: '目标主站地址(从主站下拉列表接口获取:OneNET 静态地址或 EMQX 配置地址)'
|
||||
masterStation: {
|
||||
'$ref': '#/components/schemas/MasterStationInput'
|
||||
},
|
||||
backupMasterStation: {
|
||||
'$ref': '#/components/schemas/MasterStationInput'
|
||||
}
|
||||
},
|
||||
additionalProperties: false,
|
||||
@ -7307,6 +7309,23 @@ export const LoginResultTypeSchema = {
|
||||
type: 'string'
|
||||
} as const;
|
||||
|
||||
export const MasterStationInputSchema = {
|
||||
required: ['ioTPlatform', 'masterStationAddress'],
|
||||
type: 'object',
|
||||
properties: {
|
||||
masterStationAddress: {
|
||||
minLength: 1,
|
||||
type: 'string',
|
||||
description: '主站地址(host:port)'
|
||||
},
|
||||
ioTPlatform: {
|
||||
'$ref': '#/components/schemas/IoTPlatformTypeEnum'
|
||||
}
|
||||
},
|
||||
additionalProperties: false,
|
||||
description: '主站信息入参(切换主站时选定的目标主站,地址与平台类型成对传入,取值来源为主站下拉列表接口)'
|
||||
} as const;
|
||||
|
||||
export const MasterStationOutputSchema = {
|
||||
type: 'object',
|
||||
properties: {
|
||||
|
||||
File diff suppressed because one or more lines are too long
@ -1264,10 +1264,8 @@ export type DeviceBatchMasterSwitchInput = {
|
||||
* 物联网平台中对应的产品Id
|
||||
*/
|
||||
ioTPlatformProductId: string;
|
||||
/**
|
||||
* 目标主站地址(从主站下拉列表接口获取:OneNET 静态地址或 EMQX 配置地址)
|
||||
*/
|
||||
masterStationAddress: string;
|
||||
masterStation: MasterStationInput;
|
||||
backupMasterStation: MasterStationInput;
|
||||
};
|
||||
|
||||
/**
|
||||
@ -1724,10 +1722,8 @@ export type DeviceMasterSwitchInput = {
|
||||
* 物联网平台中对应的产品Id
|
||||
*/
|
||||
ioTPlatformProductId: string;
|
||||
/**
|
||||
* 目标主站地址(从主站下拉列表接口获取:OneNET 静态地址或 EMQX 配置地址)
|
||||
*/
|
||||
masterStationAddress: string;
|
||||
masterStation: MasterStationInput;
|
||||
backupMasterStation: MasterStationInput;
|
||||
};
|
||||
|
||||
/**
|
||||
@ -3971,6 +3967,17 @@ export type LoginOutput = {
|
||||
|
||||
export type LoginResultType = 'Success' | 'InvalidUserNameOrPassword' | 'NotAllowed' | 'LockedOut' | 'RequiresTwoFactor';
|
||||
|
||||
/**
|
||||
* 主站信息入参(切换主站时选定的目标主站,地址与平台类型成对传入,取值来源为主站下拉列表接口)
|
||||
*/
|
||||
export type MasterStationInput = {
|
||||
/**
|
||||
* 主站地址(host:port)
|
||||
*/
|
||||
masterStationAddress: string;
|
||||
ioTPlatform: IoTPlatformTypeEnum;
|
||||
};
|
||||
|
||||
/**
|
||||
* 主站下拉项(切换主站时可选的目标主站,目前固定两项:OneNET 静态地址、EMQX 配置地址)
|
||||
*/
|
||||
@ -8566,6 +8573,10 @@ export type PostOneNetServiceDataServerReceiveEmqxDataResponse = (unknown);
|
||||
|
||||
export type PostOneNetServiceDataServerReceiveEmqxDataError = unknown;
|
||||
|
||||
export type PostOneNetServiceDataServerReceiveEmqxDeviceStatusResponse = (unknown);
|
||||
|
||||
export type PostOneNetServiceDataServerReceiveEmqxDeviceStatusError = unknown;
|
||||
|
||||
export type PostOrganizationUnitsTreeResponse = (Array<TreeOutput>);
|
||||
|
||||
export type PostOrganizationUnitsTreeError = (RemoteServiceErrorResponse);
|
||||
|
||||
@ -3056,7 +3056,9 @@ const masterStationOptions = ref<
|
||||
Array<{ ioTPlatform?: number; label: string; value: string }>
|
||||
>([]);
|
||||
const masterStationLoading = ref(false);
|
||||
// 主用 / 备用主站一次性下发,设备侧主备表整体刷新;现场只有一个主站时允许两者选同一个
|
||||
const selectedMasterAddress = ref<string | undefined>(undefined);
|
||||
const selectedBackupMasterAddress = ref<string | undefined>(undefined);
|
||||
|
||||
// 统一获取表格勾选的设备(与批量绑定一致的多重兜底方式)
|
||||
function getGridCheckboxRecords(): any[] {
|
||||
@ -3109,12 +3111,28 @@ async function fetchMasterStationOptions() {
|
||||
}
|
||||
}
|
||||
|
||||
// 按地址还原成后端要的主站对象(地址 + 平台类型),平台类型取自下拉项,不由前端猜
|
||||
function resolveMasterStation(address: string | undefined) {
|
||||
if (!address) {
|
||||
return undefined;
|
||||
}
|
||||
const option = masterStationOptions.value.find((m) => m.value === address);
|
||||
if (!option || option.ioTPlatform === undefined) {
|
||||
return undefined;
|
||||
}
|
||||
return {
|
||||
masterStationAddress: address,
|
||||
ioTPlatform: option.ioTPlatform,
|
||||
};
|
||||
}
|
||||
|
||||
const [MasterSwitchModal, masterSwitchModalApi] = useVbenModal({
|
||||
draggable: true,
|
||||
onConfirm: submitBatchMasterSwitch,
|
||||
onBeforeClose: () => {
|
||||
masterSwitchRows.value = [];
|
||||
selectedMasterAddress.value = undefined;
|
||||
selectedBackupMasterAddress.value = undefined;
|
||||
return true;
|
||||
},
|
||||
onOpenChange: async (isOpen: boolean) => {
|
||||
@ -3168,6 +3186,7 @@ function openBatchMasterSwitchModal() {
|
||||
|
||||
masterSwitchRows.value = checkboxRecords;
|
||||
selectedMasterAddress.value = undefined;
|
||||
selectedBackupMasterAddress.value = undefined;
|
||||
masterSwitchModalApi.open();
|
||||
}
|
||||
|
||||
@ -3178,8 +3197,17 @@ async function submitBatchMasterSwitch() {
|
||||
Message.warning('没有选中的设备');
|
||||
return;
|
||||
}
|
||||
if (!selectedMasterAddress.value) {
|
||||
Message.warning('请选择目标主站');
|
||||
const masterStation = resolveMasterStation(selectedMasterAddress.value);
|
||||
if (!masterStation) {
|
||||
Message.warning('请选择主用主站');
|
||||
return;
|
||||
}
|
||||
|
||||
const backupMasterStation = resolveMasterStation(
|
||||
selectedBackupMasterAddress.value,
|
||||
);
|
||||
if (!backupMasterStation) {
|
||||
Message.warning('请选择备用主站');
|
||||
return;
|
||||
}
|
||||
|
||||
@ -3200,7 +3228,8 @@ async function submitBatchMasterSwitch() {
|
||||
addressList,
|
||||
ioTPlatform,
|
||||
ioTPlatformProductId: String(firstRow.ioTPlatformProductId),
|
||||
masterStationAddress: selectedMasterAddress.value,
|
||||
masterStation,
|
||||
backupMasterStation,
|
||||
},
|
||||
});
|
||||
|
||||
@ -3792,18 +3821,34 @@ const [DeviceDataFlowModal, deviceDataFlowModalApi] = useVbenModal({
|
||||
个
|
||||
</div>
|
||||
<div>
|
||||
<div class="mb-2 text-sm">目标主站</div>
|
||||
<div class="mb-2 text-sm">
|
||||
主用主站 <span class="text-red-500">*</span>
|
||||
</div>
|
||||
<Select
|
||||
v-model:value="selectedMasterAddress"
|
||||
class="w-full"
|
||||
placeholder="请选择要切换到的目标主站"
|
||||
placeholder="请选择设备优先接入的主站"
|
||||
:options="masterStationOptions"
|
||||
:loading="masterStationLoading"
|
||||
allow-clear
|
||||
/>
|
||||
</div>
|
||||
<div>
|
||||
<div class="mb-2 text-sm">
|
||||
备用主站 <span class="text-red-500">*</span>
|
||||
</div>
|
||||
<Select
|
||||
v-model:value="selectedBackupMasterAddress"
|
||||
class="w-full"
|
||||
placeholder="请选择主用主站不可用时回落的主站"
|
||||
:options="masterStationOptions"
|
||||
:loading="masterStationLoading"
|
||||
allow-clear
|
||||
/>
|
||||
</div>
|
||||
<div class="text-xs text-gray-400">
|
||||
切换主站指令将下发到所选设备,指令下发成功不代表设备已完成切换,最终以设备上报的主站切换事件为准。
|
||||
主用与备用主站一次性下发,设备侧主备主站表整体刷新;现场只有一个主站时,两者可选同一个。
|
||||
指令下发成功不代表设备已完成切换,最终以设备上报的主站切换事件为准。
|
||||
</div>
|
||||
</div>
|
||||
<template #footer>
|
||||
@ -3814,7 +3859,7 @@ const [DeviceDataFlowModal, deviceDataFlowModalApi] = useVbenModal({
|
||||
<Button
|
||||
type="primary"
|
||||
:loading="masterSwitchModalState?.confirmLoading"
|
||||
:disabled="!selectedMasterAddress"
|
||||
:disabled="!selectedMasterAddress || !selectedBackupMasterAddress"
|
||||
@click="submitBatchMasterSwitch"
|
||||
>
|
||||
{{ $t('common.confirm') }}
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user