fix: default precision error

This commit is contained in:
allen
2026-04-13 21:08:03 +08:00
parent a096073a8e
commit 991408b451
3 changed files with 17 additions and 7 deletions

View File

@@ -20,7 +20,7 @@ const finalOption = computed(() => {
step: props.data.option.step ?? 1, step: props.data.option.step ?? 1,
min: props.data.option.min, min: props.data.option.min,
max: props.data.option.max, max: props.data.option.max,
precision: props.data.option.precision ?? 0, precision: props.data.option.precision,
...otherOption, ...otherOption,
}; };
} }

View File

@@ -1,7 +1,7 @@
<script setup lang="ts"> <script setup lang="ts">
import type { CollapsibleParamSchema } from './type'; import type { CollapsibleParamSchema } from './type';
import { computed, nextTick, ref, useTemplateRef } from 'vue'; import { computed, nextTick, ref, useTemplateRef, watch } from 'vue';
import { useNamespace } from '@vben-core/composables'; import { useNamespace } from '@vben-core/composables';
@@ -46,6 +46,10 @@ const collapsibleRows = computed(() => {
}); });
const bodyStyle = computed(() => { const bodyStyle = computed(() => {
if (!open.value || props.maxHeight == null) {
return undefined;
}
return { return {
maxHeight: maxHeight:
typeof props.maxHeight === 'number' typeof props.maxHeight === 'number'
@@ -89,7 +93,11 @@ function resetValue() {
init(true); init(true);
} }
init(); watch(
() => props.params,
() => init(),
{ immediate: true, deep: true },
);
defineExpose({ defineExpose({
toggleCollapsed, toggleCollapsed,
@@ -112,17 +120,17 @@ defineExpose({
<div <div
class="header-cell pt-2 pb-2 px-5 leading-[1.5rem] flex items-center flex-nowrap" class="header-cell pt-2 pb-2 px-5 leading-[1.5rem] flex items-center flex-nowrap"
> >
参数名称 Name
</div> </div>
<div <div
class="header-cell pt-2 pb-2 px-5 leading-[1.5rem] flex items-center flex-nowrap" class="header-cell pt-2 pb-2 px-5 leading-[1.5rem] flex items-center flex-nowrap"
> >
配置 Value
</div> </div>
<div <div
class="header-cell pt-2 pb-2 px-5 leading-[1.5rem] flex items-center flex-nowrap" class="header-cell pt-2 pb-2 px-5 leading-[1.5rem] flex items-center flex-nowrap"
> >
说明 Description
</div> </div>
</div> </div>
@@ -178,7 +186,7 @@ defineExpose({
'rotate-180': open, 'rotate-180': open,
}" }"
/> />
{{ open ? '收起' : '展开' }} {{ open ? 'Fold' : 'Unfold' }}
</CollapsibleTrigger> </CollapsibleTrigger>
</div> </div>
</CollapsibleRoot> </CollapsibleRoot>

View File

@@ -52,6 +52,8 @@ const paramsSchema: CollapsibleParamSchema[] = [
option: { option: {
step: 1e-4, step: 1e-4,
type: 'exponential', type: 'exponential',
min: 0,
max: 1,
}, },
}, },
{ {