fix(aiot): 修复算法参数保存失败 + 添加中文参数标签
- 修复 Column 'priority' cannot be null 错误 - AlgorithmParamEditor 增加 priority/enabled props 并在保存时传递 - RoiAlgorithmBind 提取绑定的 priority/enabled 并传递给编辑器 - 添加中文参数名映射 (working_hours -> 工作时间段等) - 添加参数验证逻辑和详细错误日志 Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
This commit is contained in:
@@ -20,6 +20,8 @@ interface Props {
|
||||
paramSchema: string;
|
||||
currentParams: string;
|
||||
bindId: string;
|
||||
priority?: number;
|
||||
enabled?: number;
|
||||
}
|
||||
|
||||
const props = withDefaults(defineProps<Props>(), {
|
||||
@@ -27,6 +29,8 @@ const props = withDefaults(defineProps<Props>(), {
|
||||
paramSchema: '{}',
|
||||
currentParams: '{}',
|
||||
bindId: '',
|
||||
priority: 0,
|
||||
enabled: 1,
|
||||
});
|
||||
|
||||
const emit = defineEmits<{
|
||||
@@ -37,6 +41,26 @@ const emit = defineEmits<{
|
||||
const formData = ref<Record<string, any>>({});
|
||||
const newListItem = ref('');
|
||||
|
||||
// 参数名中英文映射
|
||||
const paramNameMap: Record<string, string> = {
|
||||
working_hours: '工作时间段',
|
||||
confirm_on_duty_sec: '确认在岗时间(秒)',
|
||||
confirm_leave_sec: '确认离岗时间(秒)',
|
||||
cooldown_sec: '冷却时间(秒)',
|
||||
cooldown_seconds: '冷却时间(秒)',
|
||||
confirm_seconds: '确认时间(秒)',
|
||||
min_confidence: '最小置信度',
|
||||
max_targets: '最大目标数',
|
||||
detection_interval: '检测间隔(秒)',
|
||||
enable_tracking: '启用跟踪',
|
||||
tracking_timeout: '跟踪超时(秒)',
|
||||
};
|
||||
|
||||
// 获取参数的中文名称
|
||||
function getParamLabel(key: string): string {
|
||||
return paramNameMap[key] || key;
|
||||
}
|
||||
|
||||
const parsedSchema = computed(() => {
|
||||
try {
|
||||
return JSON.parse(props.paramSchema);
|
||||
@@ -111,6 +135,8 @@ async function handleSave() {
|
||||
const payload = {
|
||||
bindId: props.bindId,
|
||||
params: paramsJson,
|
||||
priority: props.priority ?? 0, // 保留原有priority
|
||||
enabled: props.enabled ?? 1, // 保留原有enabled
|
||||
};
|
||||
console.log('[算法参数保存] 发送请求:', payload);
|
||||
|
||||
@@ -211,7 +237,7 @@ function validateParams(params: Record<string, any>): {
|
||||
<Form.Item
|
||||
v-for="(schema, key) in parsedSchema"
|
||||
:key="key"
|
||||
:label="String(key)"
|
||||
:label="getParamLabel(String(key))"
|
||||
>
|
||||
<!-- 整数类型 -->
|
||||
<InputNumber
|
||||
|
||||
@@ -43,6 +43,8 @@ const paramEditorOpen = ref(false);
|
||||
const currentParamSchema = ref('{}');
|
||||
const currentParams = ref('{}');
|
||||
const currentBindId = ref('');
|
||||
const currentPriority = ref(0);
|
||||
const currentEnabled = ref(1);
|
||||
|
||||
watch(
|
||||
() => props.roiId,
|
||||
@@ -102,6 +104,8 @@ function openParamEditor(item: AiotDeviceApi.RoiAlgoBinding) {
|
||||
currentBindId.value = item.bind.bindId || '';
|
||||
currentParams.value = item.bind.params || '{}';
|
||||
currentParamSchema.value = item.algorithm?.paramSchema || '{}';
|
||||
currentPriority.value = item.bind.priority ?? 0;
|
||||
currentEnabled.value = item.bind.enabled ?? 1;
|
||||
paramEditorOpen.value = true;
|
||||
}
|
||||
|
||||
@@ -223,6 +227,8 @@ function onParamSaved() {
|
||||
:param-schema="currentParamSchema"
|
||||
:current-params="currentParams"
|
||||
:bind-id="currentBindId"
|
||||
:priority="currentPriority"
|
||||
:enabled="currentEnabled"
|
||||
@saved="onParamSaved"
|
||||
/>
|
||||
</div>
|
||||
|
||||
Reference in New Issue
Block a user