feat(iot): 修复 antd Select 的 v-model 用法
将场景联动执行器配置、物模型数值单位的 Select 由 EP 风格的 `:model-value` 改为 antd 标准的 `:value`;前者不被 ant-design-vue 接收,导致下拉无法选中 / 回显失效。顺手把数值单位的 `getDictOptions` 提到 computed 缓存。pull/345/head
parent
6b1425d541
commit
5790211897
|
|
@ -226,11 +226,8 @@ function onActionTypeChange(action: Action, type: number) {
|
||||||
<div class="w-full">
|
<div class="w-full">
|
||||||
<Form.Item label="执行类型" required>
|
<Form.Item label="执行类型" required>
|
||||||
<Select
|
<Select
|
||||||
:model-value="action.type"
|
:value="action.type"
|
||||||
@update:model-value="
|
@change="(value) => updateActionType(index, value as number)"
|
||||||
(value: any) => updateActionType(index, value as number)
|
|
||||||
"
|
|
||||||
@change="(value: any) => onActionTypeChange(action, value as number)"
|
|
||||||
placeholder="请选择执行类型"
|
placeholder="请选择执行类型"
|
||||||
class="w-full"
|
class="w-full"
|
||||||
>
|
>
|
||||||
|
|
|
||||||
|
|
@ -4,6 +4,8 @@ import type { Ref } from 'vue';
|
||||||
|
|
||||||
import type { ThingModelApi } from '#/api/iot/thingmodel';
|
import type { ThingModelApi } from '#/api/iot/thingmodel';
|
||||||
|
|
||||||
|
import { computed } from 'vue';
|
||||||
|
|
||||||
import { DICT_TYPE } from '@vben/constants';
|
import { DICT_TYPE } from '@vben/constants';
|
||||||
import { getDictOptions } from '@vben/hooks';
|
import { getDictOptions } from '@vben/hooks';
|
||||||
|
|
||||||
|
|
@ -18,6 +20,11 @@ const dataSpecs = useVModel(
|
||||||
emits,
|
emits,
|
||||||
) as Ref<ThingModelApi.DataSpecsNumberData>;
|
) as Ref<ThingModelApi.DataSpecsNumberData>;
|
||||||
|
|
||||||
|
/** 单位字典选项 */
|
||||||
|
const unitOptions = computed(() =>
|
||||||
|
getDictOptions(DICT_TYPE.IOT_THING_MODEL_UNIT, 'string'),
|
||||||
|
);
|
||||||
|
|
||||||
/** 单位下拉变化时,拆出 unitName 与 unit 回写 */
|
/** 单位下拉变化时,拆出 unitName 与 unit 回写 */
|
||||||
function unitChange(unitSpecs: any) {
|
function unitChange(unitSpecs: any) {
|
||||||
if (!unitSpecs) {
|
if (!unitSpecs) {
|
||||||
|
|
@ -46,7 +53,7 @@ function unitChange(unitSpecs: any) {
|
||||||
</Form.Item>
|
</Form.Item>
|
||||||
<Form.Item label="单位">
|
<Form.Item label="单位">
|
||||||
<Select
|
<Select
|
||||||
:model-value="
|
:value="
|
||||||
dataSpecs.unit ? `${dataSpecs.unitName}-${dataSpecs.unit}` : ''
|
dataSpecs.unit ? `${dataSpecs.unitName}-${dataSpecs.unit}` : ''
|
||||||
"
|
"
|
||||||
show-search
|
show-search
|
||||||
|
|
@ -55,10 +62,7 @@ function unitChange(unitSpecs: any) {
|
||||||
@change="unitChange"
|
@change="unitChange"
|
||||||
>
|
>
|
||||||
<Select.Option
|
<Select.Option
|
||||||
v-for="(item, index) in getDictOptions(
|
v-for="(item, index) in unitOptions"
|
||||||
DICT_TYPE.IOT_THING_MODEL_UNIT,
|
|
||||||
'string',
|
|
||||||
)"
|
|
||||||
:key="index"
|
:key="index"
|
||||||
:value="`${item.label}-${item.value}`"
|
:value="`${item.label}-${item.value}`"
|
||||||
>
|
>
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue