perf:【IoT 物联网】场景联动值输入组件优化

This commit is contained in:
puhui999
2025-08-03 19:42:43 +08:00
parent 26a4f0fee1
commit 300b844346

View File

@ -1,14 +1,15 @@
<!-- 值输入组件 --> <!-- 值输入组件 -->
<!-- TODO @yunai这个需要在看看 --> <!-- TODO @yunai这个需要在看看 -->
<template> <template>
<div class="value-input"> <div class="w-full min-w-0">
<!-- 布尔值选择 --> <!-- 布尔值选择 -->
<el-select <el-select
v-if="propertyType === 'bool'" v-if="propertyType === 'bool'"
v-model="localValue" v-model="localValue"
placeholder="请选择布尔值" placeholder="请选择布尔值"
@change="handleChange" @change="handleChange"
class="w-full" class="w-full!"
style="width: 100% !important"
> >
<el-option label="真 (true)" value="true" /> <el-option label="真 (true)" value="true" />
<el-option label="假 (false)" value="false" /> <el-option label="假 (false)" value="false" />
@ -20,7 +21,8 @@
v-model="localValue" v-model="localValue"
placeholder="请选择枚举值" placeholder="请选择枚举值"
@change="handleChange" @change="handleChange"
class="w-full" class="w-full!"
style="width: 100% !important"
> >
<el-option <el-option
v-for="option in enumOptions" v-for="option in enumOptions"
@ -31,41 +33,51 @@
</el-select> </el-select>
<!-- 范围输入 (between 操作符) --> <!-- 范围输入 (between 操作符) -->
<div v-else-if="operator === 'between'" class="range-input"> <div
v-else-if="operator === 'between'"
class="w-full! flex items-center gap-8px"
style="width: 100% !important"
>
<el-input <el-input
v-model="rangeStart" v-model="rangeStart"
:type="getInputType()" :type="getInputType()"
placeholder="最小值" placeholder="最小值"
@input="handleRangeChange" @input="handleRangeChange"
class="range-start" class="flex-1 min-w-0"
style="width: auto !important"
/> />
<span class="range-separator"></span> <span class="text-12px text-[var(--el-text-color-secondary)] whitespace-nowrap"></span>
<el-input <el-input
v-model="rangeEnd" v-model="rangeEnd"
:type="getInputType()" :type="getInputType()"
placeholder="最大值" placeholder="最大值"
@input="handleRangeChange" @input="handleRangeChange"
class="range-end" class="flex-1 min-w-0"
style="width: auto !important"
/> />
</div> </div>
<!-- 列表输入 (in 操作符) --> <!-- 列表输入 (in 操作符) -->
<div v-else-if="operator === 'in'" class="list-input"> <div v-else-if="operator === 'in'" class="w-full!" style="width: 100% !important">
<el-input <el-input
v-model="localValue" v-model="localValue"
placeholder="请输入值列表,用逗号分隔" placeholder="请输入值列表,用逗号分隔"
@input="handleChange" @input="handleChange"
class="w-full" class="w-full!"
style="width: 100% !important"
> >
<template #suffix> <template #suffix>
<el-tooltip content="多个值用逗号分隔1,2,3" placement="top"> <el-tooltip content="多个值用逗号分隔1,2,3" placement="top">
<Icon icon="ep:question-filled" class="input-tip" /> <Icon
icon="ep:question-filled"
class="text-[var(--el-text-color-placeholder)] cursor-help"
/>
</el-tooltip> </el-tooltip>
</template> </template>
</el-input> </el-input>
<div v-if="listPreview.length > 0" class="list-preview"> <div v-if="listPreview.length > 0" class="mt-8px flex items-center gap-6px flex-wrap">
<span class="preview-label">解析结果</span> <span class="text-12px text-[var(--el-text-color-secondary)]">解析结果</span>
<el-tag v-for="(item, index) in listPreview" :key="index" size="small" class="preview-tag"> <el-tag v-for="(item, index) in listPreview" :key="index" size="small" class="m-0">
{{ item }} {{ item }}
</el-tag> </el-tag>
</div> </div>
@ -80,7 +92,8 @@
format="YYYY-MM-DD HH:mm:ss" format="YYYY-MM-DD HH:mm:ss"
value-format="YYYY-MM-DD HH:mm:ss" value-format="YYYY-MM-DD HH:mm:ss"
@change="handleDateChange" @change="handleDateChange"
class="w-full" class="w-full!"
style="width: 100% !important"
/> />
<!-- 数字输入 --> <!-- 数字输入 -->
@ -93,7 +106,8 @@
:max="getMax()" :max="getMax()"
placeholder="请输入数值" placeholder="请输入数值"
@change="handleNumberChange" @change="handleNumberChange"
class="w-full" class="w-full!"
style="width: 100% !important"
/> />
<!-- 文本输入 --> <!-- 文本输入 -->
@ -103,7 +117,8 @@
:type="getInputType()" :type="getInputType()"
:placeholder="getPlaceholder()" :placeholder="getPlaceholder()"
@input="handleChange" @input="handleChange"
class="w-full" class="w-full!"
style="width: 100% !important"
> >
<template #suffix> <template #suffix>
<el-tooltip <el-tooltip
@ -111,13 +126,15 @@
:content="`单位:${propertyConfig.unit}`" :content="`单位:${propertyConfig.unit}`"
placement="top" placement="top"
> >
<span class="input-unit">{{ propertyConfig.unit }}</span> <span class="text-12px text-[var(--el-text-color-secondary)] px-4px">{{
propertyConfig.unit
}}</span>
</el-tooltip> </el-tooltip>
</template> </template>
</el-input> </el-input>
<!-- 验证提示 --> <!-- 验证提示 -->
<div v-if="validationMessage" class="validation-message"> <div v-if="validationMessage" class="mt-4px">
<el-text :type="isValid ? 'success' : 'danger'" size="small"> <el-text :type="isValid ? 'success' : 'danger'" size="small">
<Icon :icon="isValid ? 'ep:check' : 'ep:warning-filled'" /> <Icon :icon="isValid ? 'ep:check' : 'ep:warning-filled'" />
{{ validationMessage }} {{ validationMessage }}
@ -354,62 +371,3 @@ onMounted(() => {
} }
}) })
</script> </script>
<style scoped>
.value-input {
width: 100%;
}
.range-input {
display: flex;
align-items: center;
gap: 8px;
}
.range-start,
.range-end {
flex: 1;
}
.range-separator {
font-size: 12px;
color: var(--el-text-color-secondary);
white-space: nowrap;
}
.list-input {
width: 100%;
}
.input-tip {
color: var(--el-text-color-placeholder);
cursor: help;
}
.input-unit {
font-size: 12px;
color: var(--el-text-color-secondary);
padding: 0 4px;
}
.list-preview {
margin-top: 8px;
display: flex;
align-items: center;
gap: 6px;
flex-wrap: wrap;
}
.preview-label {
font-size: 12px;
color: var(--el-text-color-secondary);
}
.preview-tag {
margin: 0;
}
.validation-message {
margin-top: 4px;
}
</style>