|
@@ -1,5 +1,9 @@
|
|
<script setup lang="ts">
|
|
<script setup lang="ts">
|
|
-import { ref } from 'vue';
|
|
|
|
|
|
+import { computed, ref } from 'vue';
|
|
|
|
+
|
|
|
|
+import { addUnit } from '@/utils';
|
|
|
|
+
|
|
|
|
+import type { CSSProperties } from 'vue';
|
|
|
|
|
|
interface Props {
|
|
interface Props {
|
|
extInfo: {
|
|
extInfo: {
|
|
@@ -14,6 +18,8 @@ interface Props {
|
|
};
|
|
};
|
|
}
|
|
}
|
|
|
|
|
|
|
|
+type NumValue = string | number | undefined;
|
|
|
|
+
|
|
const props = defineProps<Props>();
|
|
const props = defineProps<Props>();
|
|
|
|
|
|
const emit = defineEmits<{
|
|
const emit = defineEmits<{
|
|
@@ -26,8 +32,30 @@ const emit = defineEmits<{
|
|
];
|
|
];
|
|
}>();
|
|
}>();
|
|
|
|
|
|
-const deviceNum = ref<string | number | undefined>(props.extInfo.deviceNum);
|
|
|
|
-const moduleNum = ref<string | number | undefined>(props.extInfo.moduleNum);
|
|
|
|
|
|
+const deviceNum = ref<NumValue>(props.extInfo.deviceNum);
|
|
|
|
+const moduleNum = ref<NumValue>(props.extInfo.moduleNum);
|
|
|
|
+
|
|
|
|
+const deviceNumInputStyle = computed<CSSProperties>(() => {
|
|
|
|
+ return {
|
|
|
|
+ width: addUnit(getInputWidth(deviceNum.value)),
|
|
|
|
+ };
|
|
|
|
+});
|
|
|
|
+
|
|
|
|
+const moduleNumInputStyle = computed<CSSProperties>(() => {
|
|
|
|
+ return {
|
|
|
|
+ width: addUnit(getInputWidth(moduleNum.value)),
|
|
|
|
+ };
|
|
|
|
+});
|
|
|
|
+
|
|
|
|
+const getInputWidth = (num: NumValue): number => {
|
|
|
|
+ if (!num || String(num).length < 2) {
|
|
|
|
+ return 32;
|
|
|
|
+ } else if (String(num).length < 3) {
|
|
|
|
+ return 40;
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ return 50;
|
|
|
|
+};
|
|
|
|
|
|
const handleChange = () => {
|
|
const handleChange = () => {
|
|
const { deviceName, deviceParam, moduleName, moduleParam, statusName, statusParam } = props.extInfo;
|
|
const { deviceName, deviceParam, moduleName, moduleParam, statusName, statusParam } = props.extInfo;
|
|
@@ -67,6 +95,7 @@ const handleChange = () => {
|
|
{{ extInfo.deviceName }}
|
|
{{ extInfo.deviceName }}
|
|
<AInputNumber
|
|
<AInputNumber
|
|
class="gateway-param-ext-input"
|
|
class="gateway-param-ext-input"
|
|
|
|
+ :style="deviceNumInputStyle"
|
|
v-model:value="deviceNum"
|
|
v-model:value="deviceNum"
|
|
:min="0"
|
|
:min="0"
|
|
:precision="0"
|
|
:precision="0"
|
|
@@ -78,6 +107,7 @@ const handleChange = () => {
|
|
{{ extInfo.moduleName }}
|
|
{{ extInfo.moduleName }}
|
|
<AInputNumber
|
|
<AInputNumber
|
|
class="gateway-param-ext-input"
|
|
class="gateway-param-ext-input"
|
|
|
|
+ :style="moduleNumInputStyle"
|
|
v-model:value="moduleNum"
|
|
v-model:value="moduleNum"
|
|
:min="0"
|
|
:min="0"
|
|
:precision="0"
|
|
:precision="0"
|