Compare commits

..

No commits in common. "0ffc2a3098a4bf6b32d4f048a6a0452a41071f1f" and "e860a539fa80af076b26673282b07eeca6743361" have entirely different histories.

7 changed files with 811 additions and 878 deletions

View File

@ -467,14 +467,10 @@ export const BatchCreateDeviceAggregationInputSchema = {
export const BindingDeviceThingModelInputSchema = { export const BindingDeviceThingModelInputSchema = {
type: 'object', type: 'object',
properties: { properties: {
devieDataIdList: { devieDataId: {
type: 'array', type: 'string',
items: { description: '设备数据Id',
type: 'string', format: 'uuid'
format: 'uuid'
},
description: '设备数据Id集合',
nullable: true
}, },
isNeedConfigDevicMdoel: { isNeedConfigDevicMdoel: {
type: 'boolean', type: 'boolean',
@ -2144,11 +2140,6 @@ export const DeviceManagementInfoDtoSchema = {
description: '设备物模型数据Id', description: '设备物模型数据Id',
format: 'uuid', format: 'uuid',
nullable: true nullable: true
},
deviceThingModelName: {
type: 'string',
description: '设备物模型名称',
nullable: true
} }
}, },
additionalProperties: false additionalProperties: false
@ -5222,50 +5213,12 @@ export const IoTDBDynamicObjectPagedResultDtoSchema = {
additionalProperties: false additionalProperties: false
} as const; } as const;
export const IoTPlatformAccountInfoInputSchema = {
required: ['ioTPlatformType'],
type: 'object',
properties: {
ioTPlatformType: {
'$ref': '#/components/schemas/IoTPlatformTypeEnum'
}
},
additionalProperties: false,
description: '平台账号信息输入'
} as const;
export const IoTPlatformAccountInfoOutputSchema = {
type: 'object',
properties: {
ioTPlatformType: {
'$ref': '#/components/schemas/IoTPlatformTypeEnum'
},
ioTPlatformAccount: {
type: 'string',
description: '平台账号',
nullable: true
},
ioTPlatformPhoneNumber: {
type: 'string',
description: '平台账号手机号',
nullable: true
}
},
additionalProperties: false,
description: '平台账号信息'
} as const;
export const IoTPlatformProductInfoInputSchema = { export const IoTPlatformProductInfoInputSchema = {
required: ['ioTPlatformType'], required: ['ioTPlatformType'],
type: 'object', type: 'object',
properties: { properties: {
ioTPlatformType: { ioTPlatformType: {
'$ref': '#/components/schemas/IoTPlatformTypeEnum' '$ref': '#/components/schemas/IoTPlatformTypeEnum'
},
ioTPlatformAccount: {
type: 'string',
description: '平台账号',
nullable: true
} }
}, },
additionalProperties: false, additionalProperties: false,
@ -6928,11 +6881,6 @@ export const PageDeviceInputSchema = {
description: '物联网平台中对应的设备Id或者名称', description: '物联网平台中对应的设备Id或者名称',
nullable: true nullable: true
}, },
ioTPlatformProductId: {
type: 'string',
description: '物联网平台中对应的产品Id',
nullable: true
},
searchKeyword: { searchKeyword: {
type: 'string', type: 'string',
description: '搜索关键字', description: '搜索关键字',

File diff suppressed because one or more lines are too long

View File

@ -177,9 +177,9 @@ export type BatchCreateDeviceAggregationInput = {
*/ */
export type BindingDeviceThingModelInput = { export type BindingDeviceThingModelInput = {
/** /**
* Id集合 * Id
*/ */
devieDataIdList?: Array<(string)> | null; devieDataId?: string;
/** /**
* false * false
*/ */
@ -1183,10 +1183,6 @@ export type DeviceManagementInfoDto = {
* Id * Id
*/ */
deviceThingModelDataId?: (string) | null; deviceThingModelDataId?: (string) | null;
/**
*
*/
deviceThingModelName?: (string) | null;
}; };
export type DeviceManagementInfoDtoPagedResultDto = { export type DeviceManagementInfoDtoPagedResultDto = {
@ -2600,37 +2596,11 @@ export type IoTDBDynamicObjectPagedResultDto = {
totalCount?: number; totalCount?: number;
}; };
/**
*
*/
export type IoTPlatformAccountInfoInput = {
ioTPlatformType: IoTPlatformTypeEnum;
};
/**
*
*/
export type IoTPlatformAccountInfoOutput = {
ioTPlatformType?: IoTPlatformTypeEnum;
/**
*
*/
ioTPlatformAccount?: (string) | null;
/**
*
*/
ioTPlatformPhoneNumber?: (string) | null;
};
/** /**
* *
*/ */
export type IoTPlatformProductInfoInput = { export type IoTPlatformProductInfoInput = {
ioTPlatformType: IoTPlatformTypeEnum; ioTPlatformType: IoTPlatformTypeEnum;
/**
*
*/
ioTPlatformAccount?: (string) | null;
}; };
/** /**
@ -3678,10 +3648,6 @@ export type PageDeviceInput = {
* Id或者名称 * Id或者名称
*/ */
ioTPlatformDeviceOpenInfo?: (string) | null; ioTPlatformDeviceOpenInfo?: (string) | null;
/**
* Id
*/
ioTPlatformProductId?: (string) | null;
/** /**
* *
*/ */
@ -6335,16 +6301,6 @@ export type PostAggregationIoTplatformGetIoTplatformProductInfoAsyncResponse = (
export type PostAggregationIoTplatformGetIoTplatformProductInfoAsyncError = unknown; export type PostAggregationIoTplatformGetIoTplatformProductInfoAsyncError = unknown;
export type PostAggregationIoTplatformGetIoTplatformAccountInfoAsyncData = {
query?: {
input?: IoTPlatformAccountInfoInput;
};
};
export type PostAggregationIoTplatformGetIoTplatformAccountInfoAsyncResponse = (Array<IoTPlatformAccountInfoOutput>);
export type PostAggregationIoTplatformGetIoTplatformAccountInfoAsyncError = unknown;
export type PostAggregationIoTplatformGetIoTplatformProductPropertyInfoAsyncData = { export type PostAggregationIoTplatformGetIoTplatformProductPropertyInfoAsyncData = {
query?: { query?: {
input?: IoTPlatformProductPropertyInfoInput; input?: IoTPlatformProductPropertyInfoInput;

View File

@ -216,9 +216,7 @@
"LastOnlineTime": "LastOnlineTime", "LastOnlineTime": "LastOnlineTime",
"LastOfflineTime": "LastOfflineTime", "LastOfflineTime": "LastOfflineTime",
"deviceInfoManage": "DeviceInfoManage", "deviceInfoManage": "DeviceInfoManage",
"thingModelInfoManage": "ThingModelInfoManage", "thingModelInfoManage": "ThingModelInfoManage"
"isNeedConfigDevicMdoel": "IsNeedConfigDevicMdoel",
"deviceThingModelName": "ThingModelInfoManage"
}, },
"thingModelInfos": { "thingModelInfos": {
"FiledType": "FiledType", "FiledType": "FiledType",

View File

@ -209,9 +209,7 @@
"LastOnlineTime": "最后在线时间", "LastOnlineTime": "最后在线时间",
"LastOfflineTime": "最后离线时间", "LastOfflineTime": "最后离线时间",
"deviceInfoManage": "设备管理", "deviceInfoManage": "设备管理",
"thingModelInfoManage": "物模型管理", "thingModelInfoManage": "物模型管理"
"isNeedConfigDevicMdoel": "是否绑定设备模型",
"deviceThingModelName": "设备物模型名称"
}, },
"thingModelInfos": { "thingModelInfos": {
"FiledType": "物模型类型", "FiledType": "物模型类型",

View File

@ -52,23 +52,6 @@ const router = useRouter();
const route = useRoute(); const route = useRoute();
const formOptions: VbenFormProps = { const formOptions: VbenFormProps = {
schema: querySchema.value, schema: querySchema.value,
submitOnChange: false,
handleValuesChange: async (values, changedFields) => {
//
if (changedFields.includes('ioTPlatformProductId')) {
//
await nextTick();
if (gridApi?.reload && gridApi?.formApi) {
try {
// reload
const latestValues = await gridApi.formApi.getValues();
await gridApi.reload(latestValues);
} catch (error) {
console.error('重新加载数据时出错:', error);
}
}
}
},
}; };
const gridOptions: VxeGridProps<any> = { const gridOptions: VxeGridProps<any> = {
checkboxConfig: { checkboxConfig: {
@ -88,101 +71,17 @@ const gridOptions: VxeGridProps<any> = {
proxyConfig: { proxyConfig: {
ajax: { ajax: {
query: async ({ page }, formValues) => { query: async ({ page }, formValues) => {
// APIformValues
const currentFormValues = gridApi?.formApi
? await gridApi.formApi.getValues()
: formValues || {};
// 使API使formValues
const finalFormValues = { ...(formValues || {}), ...currentFormValues };
const { data } = await postDeviceInfoPage({ const { data } = await postDeviceInfoPage({
body: { body: {
pageIndex: page.currentPage, pageIndex: page.currentPage,
pageSize: page.pageSize, pageSize: page.pageSize,
...finalFormValues, ...formValues,
}, },
}); });
return data; return data;
}, },
}, },
}, },
//
onCheckboxChange: ({ row, checked }: any) => {
if (!checked) {
//
return;
}
//
let currentSelected: any[] = [];
if (gridApi?.grid) {
const gridInstance = gridApi.grid as any;
if (typeof gridInstance.getCheckboxRecords === 'function') {
currentSelected = gridInstance.getCheckboxRecords();
} else if (gridInstance.checkboxRecords) {
currentSelected = gridInstance.checkboxRecords;
}
}
// ID
if (currentSelected.length > 0) {
const firstProductId = currentSelected[0]?.ioTPlatformProductId;
const currentProductId = row?.ioTPlatformProductId;
// ID
if (firstProductId && currentProductId && firstProductId !== currentProductId) {
// ID
Message.warning('只能选择同一种产品的设备进行批量绑定,当前设备的产品与已选设备的产品不一致');
//
setTimeout(() => {
if (gridApi?.grid) {
const gridInstance = gridApi.grid as any;
if (typeof gridInstance.setCheckboxRow === 'function') {
gridInstance.setCheckboxRow(row, false);
} else if (typeof gridInstance.clearCheckboxRow === 'function') {
gridInstance.clearCheckboxRow(row);
}
}
}, 100);
return;
}
}
},
//
onCheckboxAll: ({ checked, records }: any) => {
if (!checked || records.length <= 1) {
//
return;
}
// ID
const productIds = records
.map((r: any) => r.ioTPlatformProductId)
.filter((id: any) => id);
if (productIds.length > 0) {
const uniqueProductIds = [...new Set(productIds)];
if (uniqueProductIds.length > 1) {
// ID
Message.warning('只能选择同一种产品的设备进行批量绑定,当前页面包含多种产品');
//
setTimeout(() => {
if (gridApi?.grid) {
const gridInstance = gridApi.grid as any;
if (typeof gridInstance.clearCheckboxAll === 'function') {
gridInstance.clearCheckboxAll();
} else if (typeof gridInstance.setAllCheckboxRow === 'function') {
gridInstance.setAllCheckboxRow(false);
}
}
}, 100);
return;
}
}
},
}; };
const [Grid, gridApi] = useVbenVxeGrid({ formOptions, gridOptions }); const [Grid, gridApi] = useVbenVxeGrid({ formOptions, gridOptions });
@ -205,8 +104,12 @@ watch(
} }
if (newQuery.ioTPlatformDeviceOpenInfo) { if (newQuery.ioTPlatformDeviceOpenInfo) {
// ID // ID
filterValues.ioTPlatformProductId = newQuery.ioTPlatformDeviceOpenInfo; if (newQuery.ioTPlatform === '2' || newQuery.ioTPlatform === 2) {
filterValues.oneNETProductId = newQuery.ioTPlatformDeviceOpenInfo;
} else if (newQuery.ioTPlatform === '1' || newQuery.ioTPlatform === 1) {
filterValues.ctWingProductId = newQuery.ioTPlatformDeviceOpenInfo;
}
// //
filterValues.ioTPlatformDeviceOpenInfo = newQuery.ioTPlatformDeviceOpenInfo; filterValues.ioTPlatformDeviceOpenInfo = newQuery.ioTPlatformDeviceOpenInfo;
} }
@ -232,14 +135,22 @@ watch(
() => gridApi?.formApi?.getValues, () => gridApi?.formApi?.getValues,
(formValues) => { (formValues) => {
if (formValues) { if (formValues) {
const { ioTPlatformProductId } = formValues; const { oneNETProductId, ctWingProductId } = formValues;
// ioTPlatformDeviceOpenInfo // OneNETioTPlatformDeviceOpenInfo
if (ioTPlatformProductId) { if (oneNETProductId) {
console.log('检测到产品选择变化:', ioTPlatformProductId); console.log('检测到OneNET产品选择变化:', oneNETProductId);
gridApi?.formApi?.setFieldValue('ioTPlatformDeviceOpenInfo', ioTPlatformProductId); gridApi?.formApi?.setFieldValue('ioTPlatformDeviceOpenInfo', oneNETProductId);
console.log('已设置ioTPlatformDeviceOpenInfo为:', ioTPlatformProductId); console.log('已设置ioTPlatformDeviceOpenInfo为:', oneNETProductId);
} else { }
// CTWingioTPlatformDeviceOpenInfo
else if (ctWingProductId) {
console.log('检测到CTWing产品选择变化:', ctWingProductId);
gridApi?.formApi?.setFieldValue('ioTPlatformDeviceOpenInfo', ctWingProductId);
console.log('已设置ioTPlatformDeviceOpenInfo为:', ctWingProductId);
}
// ioTPlatformDeviceOpenInfo
else if (!oneNETProductId && !ctWingProductId) {
console.log('清空产品选择'); console.log('清空产品选择');
gridApi?.formApi?.setFieldValue('ioTPlatformDeviceOpenInfo', ''); gridApi?.formApi?.setFieldValue('ioTPlatformDeviceOpenInfo', '');
} }
@ -254,7 +165,7 @@ const loadingTip = ref('缓存刷新中...');
const commandRow: Record<string, any> = ref({}); const commandRow: Record<string, any> = ref({});
// //
const bindRows: Array<Record<string, any>> = ref([]); const bindRow: Record<string, any> = ref({});
// - // -
interface CommandProperty { interface CommandProperty {
@ -363,18 +274,9 @@ const [BindModal, bindModalApi] = useVbenModal({
draggable: true, draggable: true,
onConfirm: submitBindDeviceThingModel, onConfirm: submitBindDeviceThingModel,
onBeforeClose: () => { onBeforeClose: () => {
bindRows.value = []; bindRow.value = {};
return true; return true;
}, },
onOpenChange: async (isOpen: boolean) => {
if (isOpen) {
console.log('绑定弹窗打开,选中的设备:', bindRows.value);
await nextTick();
//
const formValues = await bindFormApi.getValues();
console.log('弹窗打开时的表单值:', formValues);
}
},
}); });
const [AddForm, addFormApi] = useVbenForm({ const [AddForm, addFormApi] = useVbenForm({
@ -392,12 +294,6 @@ const [AddForm, addFormApi] = useVbenForm({
showCollapseButton: false, showCollapseButton: false,
showDefaultActions: false, showDefaultActions: false,
wrapperClass: 'grid-cols-2', wrapperClass: 'grid-cols-2',
handleValuesChange: async (values, changedFields) => {
//
if (changedFields.includes('ioTPlatformAccountId')) {
await addFormApi.setFieldValue('ioTPlatformProductId', undefined);
}
},
}); });
const [EditForm, editFormApi] = useVbenForm({ const [EditForm, editFormApi] = useVbenForm({
@ -416,12 +312,6 @@ const [EditForm, editFormApi] = useVbenForm({
showCollapseButton: false, showCollapseButton: false,
showDefaultActions: false, showDefaultActions: false,
wrapperClass: 'grid-cols-2', wrapperClass: 'grid-cols-2',
handleValuesChange: async (values, changedFields) => {
//
if (changedFields.includes('ioTPlatformAccountId')) {
await editFormApi.setFieldValue('ioTPlatformProductId', undefined);
}
},
}); });
const [CommandForm, commandFormApi] = useVbenForm({ const [CommandForm, commandFormApi] = useVbenForm({
@ -453,36 +343,6 @@ const [BindForm, bindFormApi] = useVbenForm({
showCollapseButton: false, showCollapseButton: false,
showDefaultActions: false, showDefaultActions: false,
wrapperClass: 'grid-cols-1', wrapperClass: 'grid-cols-1',
handleValuesChange: async (values, changedFields) => {
//
if (changedFields.includes('isNeedConfigDevicMdoel') && values.isNeedConfigDevicMdoel) {
console.log('开关打开,准备触发设备物模型下拉框重新加载');
await nextTick();
setTimeout(async () => {
try {
const productId = values._ioTPlatformProductId || values.ioTPlatformProductId;
console.log('手动触发下拉框重新加载产品ID:', productId);
if (productId) {
const fieldRef = bindFormApi.getFieldComponentRef('deviceThingModelDataId');
if (fieldRef && typeof fieldRef.updateParam === 'function') {
fieldRef.updateParam({
query: {
input: {
id: String(productId),
},
},
});
console.log('已手动触发下拉框重新加载');
} else {
console.warn('无法获取设备物模型下拉框的引用');
}
}
} catch (error) {
console.error('手动触发下拉框重新加载失败:', error);
}
}, 100);
}
},
}); });
const [BatchAddForm, batchAddFormApi] = useVbenForm({ const [BatchAddForm, batchAddFormApi] = useVbenForm({
@ -502,12 +362,6 @@ const [BatchAddForm, batchAddFormApi] = useVbenForm({
wrapperClass: 'grid-cols-2', wrapperClass: 'grid-cols-2',
// //
autoSubmitOnEnter: false, autoSubmitOnEnter: false,
handleValuesChange: async (values, changedFields) => {
//
if (changedFields.includes('ioTPlatformAccountId')) {
await batchAddFormApi.setFieldValue('ioTPlatformProductId', undefined);
}
},
}); });
const [BatchAddModal, batchAddModalApi] = useVbenModal({ const [BatchAddModal, batchAddModalApi] = useVbenModal({
@ -544,13 +398,36 @@ async function submit() {
const formValues = await formApi.getValues(); const formValues = await formApi.getValues();
//
const processedFormValues = { ...formValues };
if (formValues.ioTPlatform === 2 || formValues.ioTPlatform === '2') {
// OneNET
processedFormValues.ioTPlatformAccountId = formValues.oneNETAccountId;
processedFormValues.ioTPlatformProductId = formValues.oneNETProductId;
//
delete processedFormValues.oneNETAccountId;
delete processedFormValues.oneNETProductId;
delete processedFormValues.ctWingAccountId;
delete processedFormValues.ctWingProductId;
} else if (formValues.ioTPlatform === 1 || formValues.ioTPlatform === '1') {
// CTWing
processedFormValues.ioTPlatformAccountId = formValues.ctWingAccountId;
processedFormValues.ioTPlatformProductId = formValues.ctWingProductId;
//
delete processedFormValues.ctWingAccountId;
delete processedFormValues.ctWingProductId;
delete processedFormValues.oneNETAccountId;
delete processedFormValues.oneNETProductId;
}
const fetchParams: any = isEdit const fetchParams: any = isEdit
? { ? {
id: editRow.value.id, id: editRow.value.id,
...formValues, ...processedFormValues,
} }
: { : {
...formValues, ...processedFormValues,
}; };
try { try {
@ -582,7 +459,7 @@ async function onEdit(record: any) {
editRow.value = record; editRow.value = record;
userModalApi.open(); userModalApi.open();
// //
const formValues = { ...record }; const formValues = { ...record };
// ioTPlatformApiSelectvalueField'key' // ioTPlatformApiSelectvalueField'key'
@ -590,6 +467,16 @@ async function onEdit(record: any) {
formValues.ioTPlatform = String(formValues.ioTPlatform); formValues.ioTPlatform = String(formValues.ioTPlatform);
} }
if (record.ioTPlatform === 2 || record.ioTPlatform === '2') {
// OneNET
formValues.oneNETAccountId = record.ioTPlatformAccountId;
formValues.oneNETProductId = record.ioTPlatformProductId;
} else if (record.ioTPlatform === 1 || record.ioTPlatform === '1') {
// CTWing
formValues.ctWingAccountId = record.ioTPlatformAccountId;
formValues.ctWingProductId = record.ioTPlatformProductId;
}
editFormApi.setValues(formValues); editFormApi.setValues(formValues);
} }
@ -698,96 +585,17 @@ const openCommandModal = (row: Record<string, any>) => {
commandModalApi.open(); commandModalApi.open();
}; };
// //
const openBindModal = async (rowOrRows?: Record<string, any> | Array<Record<string, any>>) => { const openBindModal = async (row: Record<string, any>) => {
// bindRow.value = row;
let selectedRows: Array<Record<string, any>> = [];
if (rowOrRows) {
// 使
if (Array.isArray(rowOrRows)) {
selectedRows = rowOrRows;
} else {
//
selectedRows = [rowOrRows];
}
} else {
//
try {
let checkboxRecords: any[] = [];
// grid
if (gridApi?.grid) {
const gridInstance = gridApi.grid as any;
if (typeof gridInstance.getCheckboxRecords === 'function') {
checkboxRecords = gridInstance.getCheckboxRecords();
} else if (gridInstance.checkboxRecords) {
checkboxRecords = gridInstance.checkboxRecords;
}
}
// store
if (checkboxRecords.length === 0 && gridApi?.store) {
const store = gridApi.store as any;
if (store.checkboxRecords) {
checkboxRecords = store.checkboxRecords;
}
}
selectedRows = checkboxRecords;
} catch (error) {
console.warn('无法获取表格选中的设备:', error);
}
}
if (selectedRows.length === 0) {
Message.warning('请先选择要绑定的设备');
return;
}
//
if (selectedRows.length > 1) {
const productIds = selectedRows
.map((row) => row.ioTPlatformProductId)
.filter((id) => id); //
if (productIds.length === 0) {
Message.error('选中的设备中没有有效的产品ID无法进行绑定');
return;
}
// ID
const uniqueProductIds = [...new Set(productIds)];
if (uniqueProductIds.length > 1) {
Message.error(`选中的设备包含 ${uniqueProductIds.length} 种不同的产品,请只选择同一种产品的设备进行批量绑定`);
return;
}
}
console.log('打开绑定弹窗,选中的设备:', selectedRows);
bindRows.value = selectedRows;
// ID
const firstDevice = selectedRows[0];
const productId = firstDevice.ioTPlatformProductId;
console.log('设置表单值产品ID:', productId, '类型:', typeof productId);
if (!productId) {
console.warn('警告:设备行数据中没有 ioTPlatformProductId 字段,请检查表格数据是否包含该字段');
}
bindModalApi.open(); bindModalApi.open();
// 使ID
await nextTick(); await nextTick();
await bindFormApi.setValues({ await bindFormApi.setValues({
isNeedConfigDevicMdoel: false, isNeedConfigDevicMdoel: false,
deviceThingModelDataId: undefined, deviceThingModelDataId: undefined,
_ioTPlatformProductId: productId ? String(productId) : undefined, _ioTPlatformProductId: row.ioTPlatformProductId,
}); });
const formValues = await bindFormApi.getValues();
console.log('表单值设置完成,当前表单值:', formValues);
console.log('表单值中的 _ioTPlatformProductId:', formValues._ioTPlatformProductId);
}; };
// //
@ -879,35 +687,27 @@ async function submitBindDeviceThingModel() {
return; return;
} }
if (!bindRows.value || bindRows.value.length === 0) { if (!bindRow.value?.id) {
Message.error('请选择要绑定的设备'); Message.error('设备信息缺失,无法绑定设备端物模型');
return;
}
// ID
const deviceIds = bindRows.value
.map((row) => row.id)
.filter((id) => id); //
if (deviceIds.length === 0) {
Message.error('选中的设备中没有有效的设备ID');
return; return;
} }
try { try {
bindModalApi.setState({ loading: true, confirmLoading: true }); bindModalApi.setState({ loading: true, confirmLoading: true });
const result = await postDeviceInfoBindingDeviceThingModel({ const result = await postDeviceInfoBindingDeviceThingModel({
body: { query: {
devieDataIdList: deviceIds, input: {
isNeedConfigDevicMdoel: isNeedConfig, devieDataId: bindRow.value.id,
deviceThingModelDataId: isNeedConfig ? deviceThingModelDataId : null, isNeedConfigDevicMdoel: isNeedConfig,
deviceThingModelDataId: isNeedConfig ? deviceThingModelDataId : null,
},
}, },
}); });
if (result.data) { if (result) {
Message.success(`成功绑定 ${deviceIds.length} 个设备的设备端物模型`); Message.success('绑定设备端物模型成功');
bindModalApi.close(); bindModalApi.close();
bindRows.value = []; bindRow.value = {};
gridApi.reload(); gridApi.reload();
} else { } else {
Message.error('绑定设备端物模型失败'); Message.error('绑定设备端物模型失败');
@ -953,11 +753,15 @@ async function submitBatchAdd() {
return; return;
} }
// ID //
const ioTPlatformProductId = let ioTPlatformProductId = '';
formValues.ioTPlatformProductId || if (formValues.ioTPlatform === 2 || formValues.ioTPlatform === '2') {
formValues.oneNETProductId || // OneNET
formValues.ctWingProductId; ioTPlatformProductId = formValues.oneNETProductId;
} else if (formValues.ioTPlatform === 1 || formValues.ioTPlatform === '1') {
// CTWing
ioTPlatformProductId = formValues.ctWingProductId;
}
if (!ioTPlatformProductId) { if (!ioTPlatformProductId) {
Message.error('请选择产品'); Message.error('请选择产品');
@ -1147,94 +951,6 @@ const handleCacheRefresh = async () => {
} }
}; };
//
const openBatchBindModal = async () => {
//
try {
console.log('gridApi:', gridApi);
console.log('gridApi.grid:', gridApi?.grid);
//
let checkboxRecords: any[] = [];
// 1 grid
if (gridApi?.grid) {
console.log('grid 可用,尝试获取选中行');
const gridInstance = gridApi.grid as any;
//
if (typeof gridInstance.getCheckboxRecords === 'function') {
checkboxRecords = gridInstance.getCheckboxRecords();
console.log('通过 grid.getCheckboxRecords 获取:', checkboxRecords);
} else if (typeof gridInstance.getCheckboxReserveRecords === 'function') {
checkboxRecords = gridInstance.getCheckboxReserveRecords();
console.log('通过 grid.getCheckboxReserveRecords 获取:', checkboxRecords);
}
// 访
if (checkboxRecords.length === 0 && gridInstance.checkboxRecords) {
checkboxRecords = gridInstance.checkboxRecords;
console.log('通过 grid.checkboxRecords 属性获取:', checkboxRecords);
}
// store
if (checkboxRecords.length === 0 && gridInstance.$store) {
const store = gridInstance.$store;
if (store.checkboxRecords) {
checkboxRecords = store.checkboxRecords;
console.log('通过 grid.$store.checkboxRecords 获取:', checkboxRecords);
}
}
}
// 2 gridApi.store
if (checkboxRecords.length === 0 && gridApi?.store) {
const store = gridApi.store as any;
if (store.checkboxRecords) {
checkboxRecords = store.checkboxRecords;
console.log('通过 gridApi.store.checkboxRecords 获取:', checkboxRecords);
}
}
// 3 gridApi
if (checkboxRecords.length === 0 && typeof (gridApi as any).getCheckboxRecords === 'function') {
checkboxRecords = (gridApi as any).getCheckboxRecords();
console.log('通过 gridApi.getCheckboxRecords 获取:', checkboxRecords);
}
console.log('最终获取到的选中设备:', checkboxRecords);
console.log('选中设备数量:', checkboxRecords.length);
if (!checkboxRecords || checkboxRecords.length === 0) {
Message.warning('请先在表格中勾选要绑定的设备(点击每行前面的复选框)');
return;
}
//
const productIds = checkboxRecords
.map((row) => row.ioTPlatformProductId)
.filter((id) => id); //
if (productIds.length === 0) {
Message.error('选中的设备中没有有效的产品ID无法进行绑定');
return;
}
// ID
const uniqueProductIds = [...new Set(productIds)];
if (uniqueProductIds.length > 1) {
Message.error(`选中的设备包含 ${uniqueProductIds.length} 种不同的产品,请只选择同一种产品的设备进行批量绑定`);
return;
}
await openBindModal(checkboxRecords);
} catch (error) {
console.error('获取表格选中的设备失败:', error);
console.error('错误详情:', error);
Message.error('获取表格选中的设备失败,请确保已勾选设备');
}
};
// //
const toolbarActions = computed(() => [ const toolbarActions = computed(() => [
{ {
@ -1251,13 +967,6 @@ const toolbarActions = computed(() => [
onClick: openBatchAddModal.bind(null), onClick: openBatchAddModal.bind(null),
auth: ['AbpIdentity.Users.Create'], auth: ['AbpIdentity.Users.Create'],
}, },
{
label: '批量绑定设备端物模型',
type: 'default',
icon: 'ant-design:link-outlined',
onClick: openBatchBindModal,
auth: ['AbpIdentity.Users.Create'],
},
{ {
label: cacheRefreshLoading.value label: cacheRefreshLoading.value
? $t('common.loading') ? $t('common.loading')
@ -1452,21 +1161,7 @@ const toolbarActions = computed(() => [
</div> </div>
</div> </div>
</CommandModal> </CommandModal>
<BindModal :title="`绑定设备端物模型${bindRows.length > 0 ? ` (已选择 ${bindRows.length} 个设备)` : ''}`" class="w-[600px]"> <BindModal title="绑定设备端物模型" class="w-[600px]">
<div v-if="bindRows.length > 0" class="mb-4 p-3 bg-blue-50 rounded border border-blue-200">
<div class="text-sm font-medium text-blue-800 mb-2">
已选择 {{ bindRows.length }} 个设备
</div>
<div class="text-xs text-blue-600 max-h-32 overflow-y-auto">
<div
v-for="(row, index) in bindRows"
:key="row.id || index"
class="mb-1"
>
{{ index + 1 }}. {{ row.deviceName || row.deviceAddress || row.id }}
</div>
</div>
</div>
<BindForm /> <BindForm />
</BindModal> </BindModal>
<BatchAddModal title="批量添加设备" class="w-[800px]"> <BatchAddModal title="批量添加设备" class="w-[800px]">

File diff suppressed because it is too large Load Diff