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