Commit 6209d2cf9cd40c6352d4130e423cad57739c736a
1 parent
cfe71af3
fix: 修复任务中心生成modbus指令,设置多个寄存器,默认值未生效
Showing
1 changed file
with
9 additions
and
2 deletions
... | ... | @@ -68,6 +68,7 @@ |
68 | 68 | } as FormSchema; |
69 | 69 | }); |
70 | 70 | |
71 | + const allDefaultValue = ref({}); | |
71 | 72 | const getSchemas = () => { |
72 | 73 | const { itemProps, itemLabel, length, component } = props; |
73 | 74 | let label = isFunction(itemLabel) ? itemLabel : (index: number) => `#${index}`; |
... | ... | @@ -89,8 +90,12 @@ |
89 | 90 | } as FormSchema) |
90 | 91 | ); |
91 | 92 | |
93 | + console.log(schemas); | |
92 | 94 | length && schemas.unshift(toRaw(getTotalControlItem.value)); |
93 | - | |
95 | + allDefaultValue.value = unref(schemas).reduce( | |
96 | + (prev, next) => ({ ...prev, [next.field]: next.defaultValue }), | |
97 | + {} | |
98 | + ); | |
94 | 99 | return schemas; |
95 | 100 | }; |
96 | 101 | |
... | ... | @@ -108,7 +113,9 @@ |
108 | 113 | } |
109 | 114 | const allValue = getFieldsValue(); |
110 | 115 | const sortKeyList = Array.from({ length: props.length }, (_v, key) => key); |
111 | - const res = sortKeyList.map((item) => ({ value: allValue[item] } as ValueItemType)); | |
116 | + const res = sortKeyList.map( | |
117 | + (item) => ({ value: allValue[item] ?? unref(allDefaultValue)[item] } as ValueItemType) | |
118 | + ); | |
112 | 119 | |
113 | 120 | emit(EmitEventEnum.UPDATE_VALUE, res); |
114 | 121 | }; | ... | ... |