优化参数值为空和传递空参数的逻辑

This commit is contained in:
fofolee
2025-01-07 17:50:13 +08:00
parent 5c2d9a5d89
commit a13580d53f
7 changed files with 275 additions and 199 deletions

View File

@@ -67,13 +67,17 @@ export default defineComponent({
return this.modelValue;
},
set(value) {
this.$emit("update:modelValue", value);
if (value === null || value === undefined || value === "") {
this.$emit("update:modelValue", null);
} else {
this.$emit("update:modelValue", value);
}
},
},
},
methods: {
updateNumber(delta) {
this.$emit("update:modelValue", this.localValue + delta);
this.$emit("update:modelValue", (this.localValue || 0) + delta);
},
},
});

View File

@@ -43,6 +43,8 @@
<q-select
v-else-if="config.type === 'select'"
filled
emit-value
map-options
:model-value="values[index]"
@update:model-value="$emit('update', index, $event)"
:options="config.options"
@@ -113,9 +115,16 @@ export default defineComponent({
emits: ["update"],
methods: {
getColumnStyle(width = 12) {
if (width === "auto") {
return {
flex: "1 1 0%",
minWidth: "0",
};
}
const columnWidth = (width / 12) * 100;
return {
width: `calc(${columnWidth}% - var(--grid-gap))`,
flex: "0 0 auto",
};
},
},
@@ -134,11 +143,18 @@ export default defineComponent({
.grid-item {
min-width: 50px;
margin-bottom: 0;
display: flex;
}
.grid-item > * {
flex: 1;
min-width: 0;
}
@media (max-width: 600px) {
.grid-item {
width: 100% !important;
flex: 1 1 100% !important;
}
}
</style>