feat(iot): 修复 antd Select 的 v-model 用法

将场景联动执行器配置、物模型数值单位的 Select 由 EP 风格的 `:model-value` 改为 antd 标准的 `:value`;前者不被 ant-design-vue 接收,导致下拉无法选中 / 回显失效。顺手把数值单位的 `getDictOptions` 提到 computed 缓存。
pull/345/head
YunaiV 2026-05-21 01:09:55 +08:00
parent 6b1425d541
commit 5790211897
2 changed files with 11 additions and 10 deletions

View File

@ -226,11 +226,8 @@ function onActionTypeChange(action: Action, type: number) {
<div class="w-full">
<Form.Item label="执行类型" required>
<Select
:model-value="action.type"
@update:model-value="
(value: any) => updateActionType(index, value as number)
"
@change="(value: any) => onActionTypeChange(action, value as number)"
:value="action.type"
@change="(value) => updateActionType(index, value as number)"
placeholder="请选择执行类型"
class="w-full"
>

View File

@ -4,6 +4,8 @@ import type { Ref } from 'vue';
import type { ThingModelApi } from '#/api/iot/thingmodel';
import { computed } from 'vue';
import { DICT_TYPE } from '@vben/constants';
import { getDictOptions } from '@vben/hooks';
@ -18,6 +20,11 @@ const dataSpecs = useVModel(
emits,
) as Ref<ThingModelApi.DataSpecsNumberData>;
/** 单位字典选项 */
const unitOptions = computed(() =>
getDictOptions(DICT_TYPE.IOT_THING_MODEL_UNIT, 'string'),
);
/** 单位下拉变化时,拆出 unitName 与 unit 回写 */
function unitChange(unitSpecs: any) {
if (!unitSpecs) {
@ -46,7 +53,7 @@ function unitChange(unitSpecs: any) {
</Form.Item>
<Form.Item label="单位">
<Select
:model-value="
:value="
dataSpecs.unit ? `${dataSpecs.unitName}-${dataSpecs.unit}` : ''
"
show-search
@ -55,10 +62,7 @@ function unitChange(unitSpecs: any) {
@change="unitChange"
>
<Select.Option
v-for="(item, index) in getDictOptions(
DICT_TYPE.IOT_THING_MODEL_UNIT,
'string',
)"
v-for="(item, index) in unitOptions"
:key="index"
:value="`${item.label}-${item.value}`"
>