|
@@ -1,4 +1,6 @@
|
|
|
<script setup lang="ts">
|
|
|
+import { ref } from 'vue';
|
|
|
+
|
|
|
interface Props {
|
|
|
extInfo: {
|
|
|
deviceName?: string;
|
|
@@ -12,18 +14,91 @@ interface Props {
|
|
|
};
|
|
|
}
|
|
|
|
|
|
-defineProps<Props>();
|
|
|
+const props = defineProps<Props>();
|
|
|
+
|
|
|
+const emit = defineEmits<{
|
|
|
+ change: [
|
|
|
+ param: {
|
|
|
+ paramName: string;
|
|
|
+ paramCode: string;
|
|
|
+ gatewayParamExt: string;
|
|
|
+ },
|
|
|
+ ];
|
|
|
+}>();
|
|
|
+
|
|
|
+const deviceNum = ref<string | number | undefined>(props.extInfo.deviceNum);
|
|
|
+const moduleNum = ref<string | number | undefined>(props.extInfo.moduleNum);
|
|
|
+
|
|
|
+const handleChange = () => {
|
|
|
+ const { deviceName, deviceParam, moduleName, moduleParam, statusName, statusParam } = props.extInfo;
|
|
|
+
|
|
|
+ const deviceNumNameStr = deviceNum.value ? `#${deviceNum.value}` : '';
|
|
|
+ const deviceNumCodeStr = deviceNum.value ? `_${deviceNum.value}_` : '';
|
|
|
+
|
|
|
+ const moduleNumNameStr = moduleNum.value ? `#${moduleNum.value}` : '';
|
|
|
+ const moduleNumCodeStr = moduleNum.value ? `_${moduleNum.value}_` : '';
|
|
|
+
|
|
|
+ const paramName = `${deviceName ?? ''}${deviceNumNameStr}${moduleName ?? ''}${moduleNumNameStr}${statusName ?? ''}`;
|
|
|
+ const paramCode = `${deviceParam ?? ''}${deviceNumCodeStr}${moduleParam ?? ''}${moduleNumCodeStr}${statusParam ?? ''}`;
|
|
|
+
|
|
|
+ const gatewayParamExt = {
|
|
|
+ ...props.extInfo,
|
|
|
+ };
|
|
|
+
|
|
|
+ if (deviceName) {
|
|
|
+ gatewayParamExt.deviceNum = deviceNum.value ? String(deviceNum.value) : '';
|
|
|
+ }
|
|
|
+
|
|
|
+ if (moduleName) {
|
|
|
+ gatewayParamExt.moduleNum = moduleNum.value ? String(moduleNum.value) : '';
|
|
|
+ }
|
|
|
+
|
|
|
+ emit('change', {
|
|
|
+ paramName,
|
|
|
+ paramCode,
|
|
|
+ gatewayParamExt: JSON.stringify(gatewayParamExt),
|
|
|
+ });
|
|
|
+};
|
|
|
</script>
|
|
|
|
|
|
<template>
|
|
|
- <div>
|
|
|
- <div v-if="extInfo.deviceName && extInfo.deviceNum">
|
|
|
+ <div class="gateway-param-ext-container">
|
|
|
+ <template v-if="extInfo.deviceName && extInfo.deviceNum !== undefined">
|
|
|
{{ extInfo.deviceName }}
|
|
|
- <AInputNumber :value="extInfo.deviceNum" :min="0" :precision="0" />
|
|
|
- </div>
|
|
|
- <div v-if="extInfo.moduleName && extInfo.moduleNum">
|
|
|
+ <AInputNumber
|
|
|
+ class="gateway-param-ext-input"
|
|
|
+ v-model:value="deviceNum"
|
|
|
+ :min="0"
|
|
|
+ :precision="0"
|
|
|
+ :controls="false"
|
|
|
+ @change="handleChange"
|
|
|
+ />
|
|
|
+ </template>
|
|
|
+ <template v-if="extInfo.moduleName && extInfo.moduleNum !== undefined">
|
|
|
{{ extInfo.moduleName }}
|
|
|
- <AInputNumber :value="extInfo.moduleNum" :min="0" :precision="0" />
|
|
|
- </div>
|
|
|
+ <AInputNumber
|
|
|
+ class="gateway-param-ext-input"
|
|
|
+ v-model:value="moduleNum"
|
|
|
+ :min="0"
|
|
|
+ :precision="0"
|
|
|
+ :controls="false"
|
|
|
+ @change="handleChange"
|
|
|
+ />
|
|
|
+ </template>
|
|
|
+ <span>{{ extInfo.statusName }}</span>
|
|
|
</div>
|
|
|
</template>
|
|
|
+
|
|
|
+<style lang="scss" scoped>
|
|
|
+.gateway-param-ext-container {
|
|
|
+ display: flex;
|
|
|
+ flex-wrap: wrap;
|
|
|
+ align-items: center;
|
|
|
+}
|
|
|
+
|
|
|
+.gateway-param-ext-input {
|
|
|
+ width: 32px;
|
|
|
+ height: 32px;
|
|
|
+ margin-inline: 2px;
|
|
|
+}
|
|
|
+</style>
|