Revert "feat: fix:15071"

This reverts commit 7a8340d3e8.
This commit is contained in:
XieYongHong 2023-06-07 18:21:50 +08:00
parent 462e9f150a
commit 93bfeb3a89
1 changed files with 13 additions and 34 deletions

View File

@ -23,12 +23,7 @@
<j-form-item
label="功能码"
:name="['configuration', 'function']"
:rules="[
...ModBusRules.function,
{
validator: checkFunction
}
]"
:rules="ModBusRules.function"
>
<j-select
style="width: 100%"
@ -48,8 +43,7 @@
</j-form-item>
<j-form-item
label="地址"
name="address"
:validateFirst="true"
:name="['pointKey']"
:rules="[
...ModBusRules.pointKey,
{
@ -61,14 +55,17 @@
<j-input-number
style="width: 100%"
placeholder="请输入地址"
v-model:value="formData.address"
v-model:value="formData.pointKey"
:min="0"
:max="999999999"
:precision="0"
/>
</j-form-item>
<p style="color: #616161" v-if="formData.configuration.function">
PLC地址: {{ plc }}
PLC地址: {{
InitAddress[formData.configuration.function] +
Number(formData.pointKey) || 0
}}
</p>
<j-form-item
label="寄存器数量"
@ -290,7 +287,7 @@ const formRef = ref<FormInstance>();
const id = props.data.id;
const collectorId = props.data.collectorId;
const provider = props.data.provider;
const oldPointKey = props.data?.configuration?.parameter?.address;
const oldPointKey = props.data.pointKey;
const InitAddress = {
Coils: 1,
@ -308,7 +305,7 @@ const formData = ref({
quantity: 1,
writeByteCount: '',
byteCount: 2,
address: undefined,
address: '',
},
codec: {
provider: undefined,
@ -318,7 +315,6 @@ const formData = ref({
},
},
},
address: undefined,
pointKey: undefined,
accessModes: [],
nspwc: false,
@ -326,11 +322,6 @@ const formData = ref({
description: '',
});
const plc = computed(() =>{
const configuration = formData.value.configuration
return configuration.function !== undefined && formData.value.address !== undefined ? InitAddress[configuration.function] + Number(formData.value.address) : 0
})
const handleOk = async () => {
const data = await formRef.value?.validate();
delete data?.nspwc;
@ -346,16 +337,15 @@ const handleOk = async () => {
provider,
collectorId,
interval,
pointKey: plc.value,
};
// addressreact使
params.configuration.parameter = {
...params.configuration.parameter,
address: data?.address,
address: data?.pointKey,
};
loading.value = true;
const response = !id
? await savePointBatch(params).catch(() => {})
: await updatePoint(id, { ...props.data, ...params }).catch(() => {});
@ -404,23 +394,13 @@ const checkProvider = (_rule: Rule, value: string): Promise<any> =>
}
});
const checkFunction = (_: any, value: string) => {
if (value) {
formRef.value!.validateFields('address')
}
return Promise.resolve('');
}
const checkPointKey = (_rule: Rule, value: string): Promise<any> =>
new Promise(async (resolve, reject) => {
console.log(value, formData.value!.configuration?.function)
if (value || Number(value) === 0) {
if (Number(oldPointKey) === Number(value)) return resolve('');
if (typeof value === 'object') return resolve('');
if (!formData.value!.configuration?.function) return resolve('');
const plc = InitAddress[formData.value!.configuration?.function] + Number(value)
const res: any = await _validateField(collectorId, {
pointKey: plc,
pointKey: value,
});
return res.result?.passed ? resolve('') : reject(res.result.reason);
} else {
@ -463,7 +443,6 @@ watch(
const { writeByteCount, byteCount } =
_value.configuration.parameter;
formData.value = _value;
formData.value.address = _value.configuration?.parameter?.address
if (!!_value.accessModes[0]?.value) {
formData.value.accessModes = value.accessModes.map(
(i: any) => i.value,