| | |
| | | defineOptions({ name: 'WorkbenchRecordParamTab' }); |
| | | |
| | | const props = defineProps<{ |
| | | /** 当前任务编号(用于监听任务切换) */ |
| | | taskId?: number; |
| | | /** 当前工单编号 */ |
| | | workOrderId?: number; |
| | | /** 当前工作站编号 */ |
| | |
| | | await paramFormApi.resetForm(); |
| | | await nextTick(); |
| | | await paramFormApi.setState({ schema: [...baseSchemas, ...paramSchemas] }); |
| | | |
| | | // 显式设置已有值,确保表单模型绑定正确 |
| | | if (existingValues && existingValues.size > 0) { |
| | | for (const [detailId, value] of existingValues) { |
| | | // 根据参数类型转换值,数值类型需要转为 number |
| | | const detail = details.find((d) => d.id === detailId); |
| | | const paramType = detail?.paramType ?? 1; |
| | | let convertedValue: any = value; |
| | | if ((paramType === 1 || paramType === 2) && value != null && value !== '') { |
| | | convertedValue = Number(value); |
| | | } |
| | | await paramFormApi.setFieldValue(`param_${detailId}`, convertedValue); |
| | | } |
| | | } |
| | | } |
| | | |
| | | /** 新增参数记录 */ |
| | |
| | | recordLoading.value = true; |
| | | try { |
| | | const result = await getWorkOrderParamRecordPage({ |
| | | workOrderId: props.workOrderId, |
| | | taskId: props.workOrderId, |
| | | workstationId: props.workstationId, |
| | | pageNo: 1, |
| | | pageSize: 100, |
| | |
| | | } |
| | | } |
| | | |
| | | // 工单或工作站变更时加载记录 |
| | | // 任务/工单/工作站变更时加载记录 |
| | | watch( |
| | | () => [props.workOrderId, props.workstationId], |
| | | () => [props.taskId, props.workOrderId, props.workstationId], |
| | | () => { |
| | | handleCancelForm(); |
| | | refreshRecordList(); |