|
@@ -29,6 +29,8 @@ const emit = defineEmits<{
|
|
|
const { visible, showView, hideView } = useViewVisible();
|
|
|
const { handleRequest } = useRequest();
|
|
|
const { dictData: readWriteTypes, getDictData: getReadWriteTypes } = useDictData(DictCode.ReadWriteType);
|
|
|
+const { dictData: registerTypes, getDictData: getRegisterTypes } = useDictData(DictCode.RegisterType);
|
|
|
+const { dictData: wordLength, getDictData: getWordLength } = useDictData(DictCode.WordLength);
|
|
|
const { dictData: parsingTypes, getDictData: getParsingTypes } = useDictData(DictCode.ParsingType);
|
|
|
const { dictData: writeFuncCode, getDictData: getWriteFuncCode } = useDictData(DictCode.WriteFuncCode);
|
|
|
const { dictData: readFuncCode, getDictData: getReadFuncCode } = useDictData(DictCode.ReadFuncCode);
|
|
@@ -46,7 +48,13 @@ const customParamsForm = reactive<Partial<ProtocolParamInfo>>({
|
|
|
writeFuncCode: undefined,
|
|
|
readFuncCode: undefined,
|
|
|
addrLength: undefined,
|
|
|
+ addrNumber: '',
|
|
|
registerAddr: '',
|
|
|
+ registerType: undefined,
|
|
|
+ registerTypeCode: undefined,
|
|
|
+ wordLength: undefined,
|
|
|
+ wordLengthCode: undefined,
|
|
|
+ quantity: undefined,
|
|
|
coefficient: undefined,
|
|
|
isHighFreqParam: undefined,
|
|
|
isHighFreqParamCode: undefined,
|
|
@@ -92,6 +100,20 @@ const rules = computed<FormRules<ProtocolParamInfo>>(() => {
|
|
|
trigger: 'blur',
|
|
|
},
|
|
|
],
|
|
|
+ addrNumber: [
|
|
|
+ {
|
|
|
+ required: true,
|
|
|
+ message: t('common.plzEnter', { name: t('setupProtocol.protocolParamFields.addrNumber') }),
|
|
|
+ trigger: 'blur',
|
|
|
+ },
|
|
|
+ ],
|
|
|
+ registerType: [
|
|
|
+ {
|
|
|
+ required: true,
|
|
|
+ message: t('common.plzSelect', { name: t('setupProtocol.protocolParamFields.registerType') }),
|
|
|
+ trigger: 'blur',
|
|
|
+ },
|
|
|
+ ],
|
|
|
registerAddr: [
|
|
|
{
|
|
|
required: true,
|
|
@@ -99,12 +121,25 @@ const rules = computed<FormRules<ProtocolParamInfo>>(() => {
|
|
|
trigger: 'blur',
|
|
|
},
|
|
|
],
|
|
|
+ wordLength: [
|
|
|
+ {
|
|
|
+ required: true,
|
|
|
+ message: t('common.plzSelect', { name: t('setupProtocol.protocolParamFields.wordLength') }),
|
|
|
+ trigger: 'blur',
|
|
|
+ },
|
|
|
+ ],
|
|
|
};
|
|
|
});
|
|
|
|
|
|
+const isModbusProtocol = computed(() => {
|
|
|
+ return props.isModbusRtuProtocol || props.isModbusTcpProtocol;
|
|
|
+});
|
|
|
+
|
|
|
onMounted(() => {
|
|
|
handleRequest(async () => {
|
|
|
await getReadWriteTypes();
|
|
|
+ await getRegisterTypes();
|
|
|
+ await getWordLength();
|
|
|
await getParsingTypes();
|
|
|
await getWriteFuncCode();
|
|
|
await getReadFuncCode();
|
|
@@ -116,6 +151,14 @@ const handleReadWriteTypeChange = (_value: SelectValue, option: DefaultOptionTyp
|
|
|
customParamsForm.readWriteTypeCode = option.key;
|
|
|
};
|
|
|
|
|
|
+const handleRegisterTypeChange = (_value: SelectValue, option: DefaultOptionType) => {
|
|
|
+ customParamsForm.registerTypeCode = option.key;
|
|
|
+};
|
|
|
+
|
|
|
+const handleWordLengthChange = (_value: SelectValue, option: DefaultOptionType) => {
|
|
|
+ customParamsForm.wordLengthCode = option.key;
|
|
|
+};
|
|
|
+
|
|
|
const handleParsingTypeChange = (_value: SelectValue, option: DefaultOptionType) => {
|
|
|
customParamsForm.parsingTypeCode = option.key;
|
|
|
};
|
|
@@ -227,7 +270,7 @@ defineExpose({
|
|
|
</ASelect>
|
|
|
</AFormItem>
|
|
|
</ACol>
|
|
|
- <ACol :span="8">
|
|
|
+ <ACol v-if="isModbusProtocol" :span="8">
|
|
|
<AFormItem :label="$t('setupProtocol.protocolParamFields.writeFunctionCode')" name="writeFuncCode">
|
|
|
<ASelect
|
|
|
v-model:value="customParamsForm.writeFuncCode"
|
|
@@ -240,7 +283,7 @@ defineExpose({
|
|
|
</ASelect>
|
|
|
</AFormItem>
|
|
|
</ACol>
|
|
|
- <ACol :span="8">
|
|
|
+ <ACol v-if="isModbusProtocol" :span="8">
|
|
|
<AFormItem :label="$t('setupProtocol.protocolParamFields.readFunctionCode')" name="readFuncCode">
|
|
|
<ASelect
|
|
|
v-model:value="customParamsForm.readFuncCode"
|
|
@@ -253,7 +296,7 @@ defineExpose({
|
|
|
</ASelect>
|
|
|
</AFormItem>
|
|
|
</ACol>
|
|
|
- <ACol :span="8">
|
|
|
+ <ACol v-if="isModbusProtocol" :span="8">
|
|
|
<AFormItem :label="$t('setupProtocol.protocolParamFields.addressLength')" name="addrLength">
|
|
|
<AInputNumber
|
|
|
v-model:value="customParamsForm.addrLength"
|
|
@@ -264,6 +307,29 @@ defineExpose({
|
|
|
/>
|
|
|
</AFormItem>
|
|
|
</ACol>
|
|
|
+ <ACol v-if="isS7Protocol" :span="8">
|
|
|
+ <AFormItem :label="$t('setupProtocol.protocolParamFields.addrNumber')" name="addrNumber">
|
|
|
+ <AInput
|
|
|
+ v-model:value="customParamsForm.addrNumber"
|
|
|
+ class="protocol-input"
|
|
|
+ :placeholder="$t('common.plzEnter')"
|
|
|
+ />
|
|
|
+ </AFormItem>
|
|
|
+ </ACol>
|
|
|
+ <ACol v-if="isS7Protocol" :span="8">
|
|
|
+ <AFormItem :label="$t('setupProtocol.protocolParamFields.registerType')" name="registerType">
|
|
|
+ <ASelect
|
|
|
+ v-model:value="customParamsForm.registerType"
|
|
|
+ class="protocol-input"
|
|
|
+ :placeholder="$t('common.plzSelect')"
|
|
|
+ @change="handleRegisterTypeChange"
|
|
|
+ >
|
|
|
+ <ASelectOption v-for="item in registerTypes" :key="item.dictEngValue" :value="item.dictValue">
|
|
|
+ {{ item.dictValue }}
|
|
|
+ </ASelectOption>
|
|
|
+ </ASelect>
|
|
|
+ </AFormItem>
|
|
|
+ </ACol>
|
|
|
<ACol :span="8">
|
|
|
<AFormItem :label="$t('setupProtocol.protocolParamFields.registerAddress')" name="registerAddr">
|
|
|
<AInput
|
|
@@ -273,6 +339,31 @@ defineExpose({
|
|
|
/>
|
|
|
</AFormItem>
|
|
|
</ACol>
|
|
|
+ <ACol v-if="isS7Protocol" :span="8">
|
|
|
+ <AFormItem :label="$t('setupProtocol.protocolParamFields.wordLength')" name="wordLength">
|
|
|
+ <ASelect
|
|
|
+ v-model:value="customParamsForm.wordLength"
|
|
|
+ class="protocol-input"
|
|
|
+ :placeholder="$t('common.plzSelect')"
|
|
|
+ @change="handleWordLengthChange"
|
|
|
+ >
|
|
|
+ <ASelectOption v-for="item in wordLength" :key="item.dictEngValue" :value="item.dictValue">
|
|
|
+ {{ item.dictValue }}
|
|
|
+ </ASelectOption>
|
|
|
+ </ASelect>
|
|
|
+ </AFormItem>
|
|
|
+ </ACol>
|
|
|
+ <ACol v-if="isS7Protocol" :span="8">
|
|
|
+ <AFormItem :label="$t('setupProtocol.protocolParamFields.quantity')" name="quantity">
|
|
|
+ <AInputNumber
|
|
|
+ v-model:value="customParamsForm.quantity"
|
|
|
+ class="protocol-input"
|
|
|
+ :placeholder="$t('common.plzEnter')"
|
|
|
+ :min="0"
|
|
|
+ :precision="0"
|
|
|
+ />
|
|
|
+ </AFormItem>
|
|
|
+ </ACol>
|
|
|
<ACol :span="8">
|
|
|
<AFormItem :label="$t('setupProtocol.protocolParamFields.coefficient')" name="coefficient">
|
|
|
<AInputNumber
|