环境配置调整

This commit is contained in:
dong 2023-12-12 14:54:12 +08:00
parent 2e17b4a71a
commit 144fedf110
3 changed files with 40 additions and 7 deletions

View File

@ -99,6 +99,7 @@ export interface Description {
// eslint-disable-next-line
val?: any;
selectOptions: null | { label: string; value: number }[];
defaultValue: string;
}
/**

View File

@ -79,16 +79,23 @@
<q-input
dense
type="number"
oninput="if(!/^\d+$/.test(value)) value=value.replace(/\D/g,''); "
@blur="blurFn"
v-model.number="menu.val"
v-else-if="
[
typeStr.int,
typeStr.uint8,
typeStr.uint16,
typeStr.uint32,
].includes(menu.type)
[typeStr.uint8, typeStr.uint16, typeStr.uint32].includes(
menu.type
)
"
/>
<q-input
dense
type="number"
oninput="if(/[\.]/.test(value)) value=value.replace(/[\.]/g,''); "
@blur="blurFn"
v-model.number="menu.val"
v-else-if="[typeStr.int, typeStr.int32].includes(menu.type)"
/>
<q-checkbox
v-model="menu.val"
v-else-if="menu.type == typeStr.bool"
@ -112,6 +119,8 @@ const menu = reactive<Description>({
type: typeStr.string,
itemTypeFields: null,
selectOptions: null,
defaultValue: '',
val: '',
});
onMounted(() => {
Object.assign(menu, props.cgData);
@ -139,4 +148,10 @@ watch(
function setVal(val: string | number | boolean | [], obj: Description) {
obj.val = val;
}
function blurFn() {
if (menu.val == '') {
menu.val = 0;
}
}
</script>

View File

@ -407,7 +407,24 @@ function setDefaultVal(fieldInfo: Description) {
});
} else {
if (basicsType.includes(fieldInfo.type)) {
fieldInfo.val = valObj[fieldInfo.type as keyof typeof valObj];
let val = valObj[fieldInfo.type as keyof typeof valObj];
if (fieldInfo.defaultValue) {
switch (fieldInfo.type) {
case typeStr.bool:
val = fieldInfo.defaultValue == 'true' ? true : false;
break;
case typeStr.int:
case typeStr.int32:
case typeStr.uint8:
case typeStr.uint16:
case typeStr.uint32:
val = Number(fieldInfo.defaultValue);
break;
default:
val = fieldInfo.defaultValue;
}
}
fieldInfo.val = val;
}
}
}