完善设备数据查询
This commit is contained in:
parent
b5c1948ec2
commit
fffc4e8551
@ -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;
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user