Compare commits
2 Commits
8fd4aba658
...
fffc4e8551
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
fffc4e8551 | ||
|
|
b5c1948ec2 |
@ -247,6 +247,7 @@
|
|||||||
"FormattedTimestamps": "Formatted Timestamps",
|
"FormattedTimestamps": "Formatted Timestamps",
|
||||||
"DevicePath": "DevicePath",
|
"DevicePath": "DevicePath",
|
||||||
"DeviceAddress": "MasterDeviceAddress",
|
"DeviceAddress": "MasterDeviceAddress",
|
||||||
|
"DataType": "DataType",
|
||||||
"SubDevice": "SubDevice",
|
"SubDevice": "SubDevice",
|
||||||
"CacheRefresh": "Cache Refresh",
|
"CacheRefresh": "Cache Refresh",
|
||||||
"TelemetryLog": "Telemetry Log",
|
"TelemetryLog": "Telemetry Log",
|
||||||
|
|||||||
@ -240,6 +240,7 @@
|
|||||||
"FormattedTimestamps": "本地时间",
|
"FormattedTimestamps": "本地时间",
|
||||||
"DevicePath": "设备路径",
|
"DevicePath": "设备路径",
|
||||||
"DeviceAddress": "主设备地址",
|
"DeviceAddress": "主设备地址",
|
||||||
|
"DataType": "测点数据类型",
|
||||||
"SubDevice": "从设备地址",
|
"SubDevice": "从设备地址",
|
||||||
"CacheRefresh": "缓存刷新",
|
"CacheRefresh": "缓存刷新",
|
||||||
"TelemetryLog": "遥测日志",
|
"TelemetryLog": "遥测日志",
|
||||||
|
|||||||
@ -1225,19 +1225,31 @@ const [ServiceCallModal, serviceCallModalApi] = useVbenModal({
|
|||||||
|
|
||||||
const serviceCallModalState = serviceCallModalApi.useStore();
|
const serviceCallModalState = serviceCallModalApi.useStore();
|
||||||
|
|
||||||
/** 服务入参:部分字段需为数值(如 Quantity),避免以字符串提交 */
|
/** 服务入参:部分字段需为数值,避免以字符串提交 */
|
||||||
function coerceServiceCallParamValue(
|
function coerceServiceCallParamValue(
|
||||||
fieldName: string,
|
fieldName: string,
|
||||||
raw: string,
|
raw: string,
|
||||||
|
ctx: { isOperateBreakerService: boolean },
|
||||||
): { ok: true; value: unknown } | { ok: false; message: string } {
|
): { ok: true; value: unknown } | { ok: false; message: string } {
|
||||||
const key = fieldName.trim();
|
const key = fieldName.trim().toLowerCase();
|
||||||
if (key.toLowerCase() === 'quantity') {
|
if (key === 'quantity') {
|
||||||
const n = Number(raw);
|
const n = Number(raw);
|
||||||
if (Number.isNaN(n)) {
|
if (Number.isNaN(n)) {
|
||||||
return { ok: false, message: '数量(Quantity)需填写有效数字' };
|
return { ok: false, message: '数量(Quantity)需填写有效数字' };
|
||||||
}
|
}
|
||||||
return { ok: true, value: n };
|
return { ok: true, value: n };
|
||||||
}
|
}
|
||||||
|
// 拉合闸服务:操作类型(OperateType)须为数值,不能传字符串
|
||||||
|
if (ctx.isOperateBreakerService && key === 'operatetype') {
|
||||||
|
const n = Number(raw);
|
||||||
|
if (Number.isNaN(n)) {
|
||||||
|
return {
|
||||||
|
ok: false,
|
||||||
|
message: '操作类型(OperateType)需为有效数字',
|
||||||
|
};
|
||||||
|
}
|
||||||
|
return { ok: true, value: n };
|
||||||
|
}
|
||||||
return { ok: true, value: raw };
|
return { ok: true, value: raw };
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -1261,10 +1273,13 @@ async function submitDeviceServiceCall() {
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
const serviceParams: Record<string, unknown> = {};
|
const serviceParams: Record<string, unknown> = {};
|
||||||
|
const coerceCtx = {
|
||||||
|
isOperateBreakerService: isOperateBreakerServiceItem(item),
|
||||||
|
};
|
||||||
for (const f of serviceParamFields.value) {
|
for (const f of serviceParamFields.value) {
|
||||||
const v = (serviceCallFormValues.value[f.name] ?? '').trim();
|
const v = (serviceCallFormValues.value[f.name] ?? '').trim();
|
||||||
if (v !== '') {
|
if (v !== '') {
|
||||||
const coerced = coerceServiceCallParamValue(f.name, v);
|
const coerced = coerceServiceCallParamValue(f.name, v, coerceCtx);
|
||||||
if (!coerced.ok) {
|
if (!coerced.ok) {
|
||||||
Message.warning(coerced.message);
|
Message.warning(coerced.message);
|
||||||
return;
|
return;
|
||||||
|
|||||||
@ -17,6 +17,7 @@ export const fieldNameMapping: FieldMapping = {
|
|||||||
// ProjectId: '项目ID',
|
// ProjectId: '项目ID',
|
||||||
// ProjectName: '项目名称',
|
// ProjectName: '项目名称',
|
||||||
IoTDataType: 'IoT数据类型',
|
IoTDataType: 'IoT数据类型',
|
||||||
|
DataType: '测点数据类型',
|
||||||
DeviceType: '设备类型',
|
DeviceType: '设备类型',
|
||||||
DeviceAddress: '设备ID',
|
DeviceAddress: '设备ID',
|
||||||
// Timestamps: '时间戳', // 已隐藏,使用TimestampStr替代
|
// Timestamps: '时间戳', // 已隐藏,使用TimestampStr替代
|
||||||
@ -43,6 +44,7 @@ const FIXED_FIELDS = [
|
|||||||
// 'DataBaseName',
|
// 'DataBaseName',
|
||||||
'DeviceType',
|
'DeviceType',
|
||||||
'IoTDataType',
|
'IoTDataType',
|
||||||
|
'DataType',
|
||||||
'SubDevice',
|
'SubDevice',
|
||||||
'TimestampStr',
|
'TimestampStr',
|
||||||
'FormattedTimestamps',
|
'FormattedTimestamps',
|
||||||
|
|||||||
@ -81,7 +81,7 @@ const { IoTDataType, DeviceAddress } = route.query;
|
|||||||
// 动态列定义
|
// 动态列定义
|
||||||
const dynamicColumns = ref<any[]>([]);
|
const dynamicColumns = ref<any[]>([]);
|
||||||
|
|
||||||
// 是否显示 Sub_Device 列
|
// 是否显示子设备场景下的固定列(Sub_Device、DataType;与 DeviceType=子设备 联动)
|
||||||
const showSubDeviceColumn = ref(false);
|
const showSubDeviceColumn = ref(false);
|
||||||
|
|
||||||
// 固定列定义(基础列,始终显示)- 基于 IoTDBTreeModelDeviceDataDto 类型
|
// 固定列定义(基础列,始终显示)- 基于 IoTDBTreeModelDeviceDataDto 类型
|
||||||
@ -133,22 +133,31 @@ const subDeviceColumn = {
|
|||||||
slots: {},
|
slots: {},
|
||||||
};
|
};
|
||||||
|
|
||||||
|
// DataType 固定列定义(与 Sub_Device 相同显示条件)
|
||||||
|
const dataTypeColumn = {
|
||||||
|
field: 'DataType',
|
||||||
|
title: $t('abp.IoTDBBase.DataType'),
|
||||||
|
minWidth: 150,
|
||||||
|
showOverflow: true,
|
||||||
|
slots: {},
|
||||||
|
};
|
||||||
|
|
||||||
// 合并固定列和动态列 - 使用计算属性确保响应式
|
// 合并固定列和动态列 - 使用计算属性确保响应式
|
||||||
const allColumns = computed(() => {
|
const allColumns = computed(() => {
|
||||||
// 如果表格未初始化,只返回固定列
|
// 如果表格未初始化,只返回固定列
|
||||||
if (!isGridInitialized.value) {
|
if (!isGridInitialized.value) {
|
||||||
const baseColumns = [...fixedBaseColumns];
|
const baseColumns = [...fixedBaseColumns];
|
||||||
if (showSubDeviceColumn.value) {
|
if (showSubDeviceColumn.value) {
|
||||||
baseColumns.push(subDeviceColumn);
|
baseColumns.push(subDeviceColumn, dataTypeColumn);
|
||||||
}
|
}
|
||||||
return baseColumns;
|
return baseColumns;
|
||||||
}
|
}
|
||||||
|
|
||||||
const columns = [...fixedBaseColumns];
|
const columns = [...fixedBaseColumns];
|
||||||
|
|
||||||
// 根据 DeviceType 控制 Sub_Device 列是否显示
|
// 根据 DeviceType 控制 Sub_Device、DataType 列是否显示
|
||||||
if (showSubDeviceColumn.value) {
|
if (showSubDeviceColumn.value) {
|
||||||
columns.push(subDeviceColumn);
|
columns.push(subDeviceColumn, dataTypeColumn);
|
||||||
}
|
}
|
||||||
|
|
||||||
// 安全地添加动态列
|
// 安全地添加动态列
|
||||||
@ -172,7 +181,7 @@ const initDefaultColumns = () => {
|
|||||||
dynamicColumns.value = [];
|
dynamicColumns.value = [];
|
||||||
}
|
}
|
||||||
|
|
||||||
// 默认不显示 Sub_Device 列,后续由表单值控制
|
// 默认不显示子设备相关固定列,后续由表单 DeviceType 控制
|
||||||
showSubDeviceColumn.value = false;
|
showSubDeviceColumn.value = false;
|
||||||
};
|
};
|
||||||
|
|
||||||
@ -184,6 +193,18 @@ const isInitializing = ref(false);
|
|||||||
// 初始化默认列
|
// 初始化默认列
|
||||||
initDefaultColumns();
|
initDefaultColumns();
|
||||||
|
|
||||||
|
// 根据当前表单 DeviceType 同步子设备相关列(Sub_Device、DataType)显示状态
|
||||||
|
const syncSubDeviceColumnsVisibilityFromForm = async () => {
|
||||||
|
try {
|
||||||
|
if (!gridApi?.formApi) return;
|
||||||
|
const v = await gridApi.formApi.getValues();
|
||||||
|
const deviceType = v.DeviceType;
|
||||||
|
showSubDeviceColumn.value = deviceType === 3 || deviceType === '3';
|
||||||
|
} catch {
|
||||||
|
// 静默处理
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
const formOptions: VbenFormProps = {
|
const formOptions: VbenFormProps = {
|
||||||
schema: querySchema.value,
|
schema: querySchema.value,
|
||||||
initialValues: {
|
initialValues: {
|
||||||
@ -200,7 +221,7 @@ const formOptions: VbenFormProps = {
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
// 根据 DeviceType 控制 Sub_Device 列是否显示
|
// 根据 DeviceType 控制 Sub_Device、DataType 列是否显示
|
||||||
if (changedFields.includes('DeviceType')) {
|
if (changedFields.includes('DeviceType')) {
|
||||||
// DeviceTypeEnum: 未知=0, 网关设备=1, 直连设备=2, 子设备=3
|
// DeviceTypeEnum: 未知=0, 网关设备=1, 直连设备=2, 子设备=3
|
||||||
const deviceType = values.DeviceType;
|
const deviceType = values.DeviceType;
|
||||||
@ -474,6 +495,7 @@ const initializeGrid = async () => {
|
|||||||
isGridInitialized.value = true;
|
isGridInitialized.value = true;
|
||||||
|
|
||||||
// 更新表格列定义
|
// 更新表格列定义
|
||||||
|
await syncSubDeviceColumnsVisibilityFromForm();
|
||||||
if (gridApi && gridApi.setState) {
|
if (gridApi && gridApi.setState) {
|
||||||
await nextTick();
|
await nextTick();
|
||||||
gridApi.setState({
|
gridApi.setState({
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user