移除日志打印

This commit is contained in:
ChenYi 2025-07-16 16:31:01 +08:00
parent 77e93996a3
commit 92c14fe460
2 changed files with 2 additions and 90 deletions

View File

@ -107,11 +107,9 @@ const handleValueChange = (value: string) => {
const selectedDevice = options.value.find(option => option.value === value);
if (selectedDevice) {
emit('device-change', selectedDevice);
console.log('DeviceSelect 发送设备信息:', selectedDevice);
}
} else {
emit('device-change', null);
console.log('DeviceSelect 清空设备信息');
}
};

View File

@ -26,7 +26,6 @@ const selectedDeviceInfo = ref<any>(null);
// ID
const fetchDeviceOptions = async () => {
try {
console.log('开始获取设备信息...');
const { data } = await postMetersPage({
body: {
pageIndex: 1,
@ -36,10 +35,6 @@ const fetchDeviceOptions = async () => {
if (data?.items) {
deviceOptions.value = data.items;
console.log('设备信息获取成功,总数:', data.items.length);
console.log('设备信息选项前3项:', deviceOptions.value.slice(0, 3));
} else {
console.log('设备信息为空');
}
} catch (error) {
console.error('获取设备信息失败:', error);
@ -118,7 +113,6 @@ const formOptions: VbenFormProps = {
// DeviceIdselectedDeviceInfo
if (changedFields.includes('DeviceId')) {
const deviceId = values.DeviceId;
console.log('DeviceId变化:', deviceId);
if (deviceId) {
// deviceOptions
@ -129,21 +123,17 @@ const formOptions: VbenFormProps = {
try {
// DeviceSelect
const deviceSelectRef = gridApi.formApi.getFieldComponentRef('DeviceId');
console.log('DeviceSelect组件实例:', deviceSelectRef);
if (deviceSelectRef && deviceSelectRef.getSelectedDevice) {
device = deviceSelectRef.getSelectedDevice();
console.log('从DeviceSelect组件获取设备信息:', device);
}
} catch (error) {
console.log('无法从DeviceSelect组件获取设备信息:', error);
//
}
}
if (device) {
selectedDeviceInfo.value = device;
console.log('同步设备信息成功:', device);
} else {
console.log('未找到匹配的设备deviceId:', deviceId);
//
setTimeout(() => {
try {
@ -152,31 +142,22 @@ const formOptions: VbenFormProps = {
const delayedDevice = deviceSelectRef.getSelectedDevice();
if (delayedDevice) {
selectedDeviceInfo.value = delayedDevice;
console.log('延迟获取设备信息成功:', delayedDevice);
}
}
} catch (error) {
console.log('延迟获取设备信息失败:', error);
//
}
}, 100);
}
} else {
selectedDeviceInfo.value = null;
console.log('DeviceId为空清空selectedDeviceInfo');
}
}
if (hasRelevantChange) {
console.log('表单字段变化:', { values, changedFields });
console.log(
'相关字段变化:',
changedFields.filter((field) => relevantFields.has(field)),
);
// 使 setTimeout
setTimeout(async () => {
const latestValues = await gridApi.formApi.getValues();
console.log('最新表单值:', latestValues);
gridApi.reload(latestValues);
}, 0);
}
@ -196,10 +177,8 @@ const gridOptions: VxeGridProps<any> = {
pageSize: 20,
//
onChange: (currentPage: number, pageSize: number) => {
console.log('分页变化:', { currentPage, pageSize });
// pageSize
if (pageSize !== gridOptions.pagerConfig.pageSize) {
console.log('页面大小变化,重置到第一页');
// pageSize
gridOptions.pagerConfig.pageSize = pageSize;
gridOptions.pagerConfig.currentPage = 1;
@ -218,7 +197,6 @@ const gridOptions: VxeGridProps<any> = {
proxyConfig: {
ajax: {
query: async ({ page }, formValues) => {
console.log('=== API调用开始 ===');
// DeviceTypeIoTDataType
const deviceTypeValue = formValues.DeviceType || DeviceType;
const deviceTypeNumber = deviceTypeValue
@ -227,38 +205,27 @@ const gridOptions: VxeGridProps<any> = {
const ioTDataTypeValue = formValues.IoTDataType;
console.log('=== API调用开始 ===2', ioTDataTypeValue);
// DeviceId(10)使focusId
let finalDeviceId = formValues.DeviceId || DeviceId;
let finalFocusAddress = formValues.FocusAddress;
// 使
console.log('API调用时的selectedDeviceInfo:', selectedDeviceInfo.value);
console.log('API调用时的formValues.DeviceId:', formValues.DeviceId);
const deviceInfo = selectedDeviceInfo.value || (formValues.DeviceId ? getDeviceInfoById(formValues.DeviceId) : null);
console.log('最终使用的deviceInfo:', deviceInfo);
if (deviceInfo) {
finalFocusAddress = deviceInfo.focusAddress;
console.log('使用focusAddress:', finalFocusAddress);
if (deviceTypeNumber === 10) {
// 使focusId
if (deviceInfo.focusId) {
finalDeviceId = deviceInfo.focusId;
console.log('集中器类型使用focusId:', finalDeviceId);
}
} else {
// 使meterId
if (deviceInfo.meterId) {
finalDeviceId = deviceInfo.meterId;
console.log('其他类型使用meterId:', finalDeviceId);
}
}
} else {
console.log('没有找到设备信息使用原始DeviceId:', finalDeviceId);
}
try {
const { data } = await postTreeModelDeviceDataInfoPage({
@ -275,38 +242,12 @@ const gridOptions: VxeGridProps<any> = {
},
});
console.log('API返回的原始数据:', data);
console.log('数据类型:', typeof data);
console.log(
'data是否为null/undefined:',
data === null || data === undefined,
);
if (data) {
console.log('data.items存在:', !!data.items);
console.log(
'data.items类型:',
Array.isArray(data.items) ? 'Array' : typeof data.items,
);
if (data.items) {
console.log('data.items长度:', data.items.length);
if (data.items.length > 0) {
console.log('第一条数据:', data.items[0]);
console.log(
'第一条数据的所有字段:',
Object.keys(data.items[0]),
);
}
}
}
// 使
if (data?.items && data.items.length > 0) {
console.log('原始items数据:', data.items);
//
const generatedColumns = generateDynamicColumns(data.items);
console.log('生成的列定义:', generatedColumns);
//
dynamicColumns.value = generatedColumns;
@ -326,22 +267,8 @@ const gridOptions: VxeGridProps<any> = {
totalCount: data.totalCount || 0,
};
console.log('返回给表格的数据:', result);
console.log(
'总数:',
result.totalCount,
'当前页数据量:',
result.items.length,
);
console.log('分页信息:', {
currentPage: page.currentPage,
pageSize: page.pageSize,
});
return result;
}
console.log('没有数据或数据为空');
return {
items: [],
totalCount: 0,
@ -358,19 +285,10 @@ const gridOptions: VxeGridProps<any> = {
const [Grid, gridApi] = useVbenVxeGrid({ formOptions, gridOptions });
//
watch(
() => gridApi?.pagerApi?.currentPage,
(newPage, oldPage) => {
console.log('当前页变化:', { newPage, oldPage });
},
);
watch(
() => gridApi?.pagerApi?.pageSize,
(newSize, oldSize) => {
console.log('页面大小变化:', { newSize, oldSize });
if (newSize !== oldSize && oldSize) {
console.log('页面大小从', oldSize, '变为', newSize, ',重置到第一页');
//
gridApi.pagerApi.currentPage = 1;
}
@ -381,14 +299,12 @@ watch(
watch(
() => [DeviceType, DeviceId, FocusAddress, SystemName],
async (newValues, oldValues) => {
console.log('路由参数变化:', { newValues, oldValues });
//
if (newValues.some(val => val) && gridApi) {
//
await fetchDeviceOptions();
//
setTimeout(() => {
console.log('自动触发查询,路由参数:', { DeviceType, DeviceId, FocusAddress, SystemName });
gridApi.reload();
}, 100);
}
@ -398,14 +314,12 @@ watch(
//
onMounted(async () => {
console.log('页面挂载完成,检查路由参数:', { DeviceType, DeviceId, FocusAddress, SystemName });
//
if (DeviceType || DeviceId || FocusAddress || SystemName) {
//
await fetchDeviceOptions();
//
setTimeout(() => {
console.log('页面初始化时自动触发查询');
gridApi.reload();
}, 200);
}