fix: bug#11200、11201、11206、11207
This commit is contained in:
parent
a1affe20a8
commit
a422769c2f
|
@ -81,11 +81,9 @@
|
|||
@blur="changeQuantity"
|
||||
/>
|
||||
</j-form-item>
|
||||
|
||||
<j-form-item
|
||||
v-if="
|
||||
formData.configuration.function === 'HoldingRegisters' ||
|
||||
formData.configuration.function === 'InputRegisters'
|
||||
"
|
||||
v-if="formData.configuration.function === 'HoldingRegisters'"
|
||||
label="数据类型"
|
||||
:name="['configuration', 'codec', 'provider']"
|
||||
:rules="[
|
||||
|
@ -124,15 +122,23 @@
|
|||
"
|
||||
/>
|
||||
</j-form-item>
|
||||
<j-form-item label="访问类型" name="accessModes">
|
||||
<j-form-item
|
||||
v-if="formData.configuration.function"
|
||||
label="访问类型"
|
||||
name="accessModes"
|
||||
>
|
||||
<j-card-select
|
||||
multiple
|
||||
:showImage="false"
|
||||
v-model:value="formData.accessModes"
|
||||
:options="[
|
||||
{ label: '读', value: 'read' },
|
||||
{ label: '写', value: 'write' },
|
||||
]"
|
||||
:options="
|
||||
formData.configuration.function === 'InputRegisters'
|
||||
? [{ label: '读', value: 'read' }]
|
||||
: [
|
||||
{ label: '读', value: 'read' },
|
||||
{ label: '写', value: 'write' },
|
||||
]
|
||||
"
|
||||
:column="2"
|
||||
/>
|
||||
</j-form-item>
|
||||
|
@ -144,7 +150,10 @@
|
|||
"
|
||||
>
|
||||
<span style="margin-right: 10px">非标准协议写入配置</span>
|
||||
<j-switch v-model:checked="formData.nspwc" />
|
||||
<j-switch
|
||||
@change="changeNspwc"
|
||||
v-model:checked="formData.nspwc"
|
||||
/>
|
||||
</j-form-item>
|
||||
<j-form-item
|
||||
v-if="
|
||||
|
@ -262,7 +271,6 @@ const id = props.data.id;
|
|||
const collectorId = props.data.collectorId;
|
||||
const provider = props.data.provider;
|
||||
const oldPointKey = props.data.pointKey;
|
||||
console.log(22, props.data);
|
||||
|
||||
const InitAddress = {
|
||||
Coils: 1,
|
||||
|
@ -329,9 +337,21 @@ const handleCancel = () => {
|
|||
};
|
||||
|
||||
const changeQuantity = () => {
|
||||
if (formData.value.configuration.function === 'HoldingRegisters') {
|
||||
const { configuration, nspwc } = formData.value;
|
||||
if (configuration.function === 'HoldingRegisters') {
|
||||
formRef.value?.validate();
|
||||
}
|
||||
if (nspwc) {
|
||||
configuration.parameter.byteCount =
|
||||
Number(configuration.parameter.quantity) * 2;
|
||||
}
|
||||
};
|
||||
const changeNspwc = (value: boolean) => {
|
||||
const { configuration } = formData.value;
|
||||
if (value) {
|
||||
configuration.parameter.byteCount =
|
||||
Number(configuration.parameter.quantity || 0) * 2;
|
||||
}
|
||||
};
|
||||
const changeWriteByteCount = (value: Array<string>) => {
|
||||
formData.value.configuration.parameter.writeByteCount = value[0];
|
||||
|
@ -357,12 +377,13 @@ const checkPointKey = (_rule: Rule, value: string): Promise<any> =>
|
|||
new Promise(async (resolve, reject) => {
|
||||
if (value || Number(value) === 0) {
|
||||
if (Number(oldPointKey) === Number(value)) return resolve('');
|
||||
if (typeof value === 'object') return resolve('');
|
||||
const res: any = await _validateField(collectorId, {
|
||||
pointKey: value,
|
||||
});
|
||||
return res.result?.passed ? resolve('') : reject(res.result.reason);
|
||||
} else {
|
||||
return reject('');
|
||||
return reject('请输入地址');
|
||||
}
|
||||
});
|
||||
|
||||
|
@ -392,13 +413,6 @@ const setProviderList = (value: string | undefined) => {
|
|||
);
|
||||
};
|
||||
|
||||
watch(
|
||||
() => formData.value.configuration.parameter.quantity,
|
||||
(value) => {
|
||||
formData.value.configuration.parameter.byteCount = Number(value) * 2;
|
||||
},
|
||||
{ immediate: true, deep: true },
|
||||
);
|
||||
watch(
|
||||
() => formData.value.configuration.function,
|
||||
(value) => {
|
||||
|
|
|
@ -506,7 +506,7 @@ const clickRedo = async (data: any) => {
|
|||
|
||||
const getQuantity = (item: Partial<Record<string, any>>) => {
|
||||
const { quantity } = item.configuration?.parameter || '';
|
||||
return !!quantity ? quantity + '(读取寄存器)' : '';
|
||||
return !!quantity ? quantity + '(寄存器数量)' : '';
|
||||
};
|
||||
const getAddress = (item: Partial<Record<string, any>>) => {
|
||||
const { address } = item.configuration?.parameter || '';
|
||||
|
@ -571,21 +571,35 @@ const handleClick = (dt: any) => {
|
|||
}
|
||||
};
|
||||
|
||||
//节流
|
||||
let timer: any = null;
|
||||
function throttle(fn: any, delay = 1000) {
|
||||
if (timer == null) {
|
||||
timer = setTimeout(() => {
|
||||
fn();
|
||||
clearTimeout(timer);
|
||||
timer = null;
|
||||
}, delay);
|
||||
}
|
||||
}
|
||||
const subscribeProperty = (value: any) => {
|
||||
// const list = value.map((item: any) => item.id);
|
||||
// const id = `collector-${props.data?.channelId || 'channel'}-${
|
||||
// props.data?.id || 'point'
|
||||
// }-data-${list.join('-')}`;
|
||||
// const topic = `/collector/${props.data?.channelId || '*'}/${
|
||||
// props.data?.id || '*'
|
||||
// }/data`;
|
||||
// subRef.value = getWebSocket(id, topic, {
|
||||
// pointId: list.join(','),
|
||||
// })
|
||||
// ?.pipe(map((res: any) => res.payload))
|
||||
// .subscribe((payload: any) => {
|
||||
// propertyValue.value.set(payload.pointId, payload);
|
||||
// });
|
||||
const list = value.map((item: any) => item.id);
|
||||
const id = `collector-${props.data?.channelId || 'channel'}-${
|
||||
props.data?.id || 'point'
|
||||
}-data-${list.join('-')}`;
|
||||
const topic = `/collector/${props.data?.channelId || '*'}/${
|
||||
props.data?.id || '*'
|
||||
}/data`;
|
||||
subRef.value = getWebSocket(id, topic, {
|
||||
pointId: list.join(','),
|
||||
})
|
||||
?.pipe(map((res: any) => res.payload))
|
||||
.subscribe((payload: any) => {
|
||||
//防止刷新过快
|
||||
throttle(() => {
|
||||
propertyValue.value.set(payload.pointId, payload);
|
||||
});
|
||||
});
|
||||
};
|
||||
|
||||
const onCheckAllChange = (e: any) => {
|
||||
|
|
Loading…
Reference in New Issue