属性UI(プロパティ)にチェックルール設定追加

This commit is contained in:
xiaozhe.ma
2024-08-22 17:15:49 +09:00
parent 1e3b2d6392
commit af22f6e603
18 changed files with 468 additions and 231 deletions

View File

@@ -1,6 +1,11 @@
<template>
<div>
<q-field :label="displayName" labelColor="primary" stack-label>
<q-field :label="displayName" labelColor="primary" stack-label
v-model="processingProps"
:rules="rulesExp"
lazy-rules="ondemand"
ref="fieldRef"
>
<template v-slot:control>
<q-card flat class="full-width">
<q-card-actions vertical>
@@ -120,9 +125,19 @@ export default defineComponent({
type: String,
default: '',
},
//例:[val=>!!val ||'入力してください']
rules: {
type: String,
default: undefined
},
required: {
type: Boolean,
default: false
}
},
setup(props, { emit }) {
const fieldRef=ref();
const source = props.context.find(element => element?.props?.name === 'sources')
if (source) {
@@ -155,6 +170,7 @@ export default defineComponent({
});
const closeDg = () => {
fieldRef.value.validate();
emit('update:modelValue', processingProps);
}
@@ -218,6 +234,24 @@ export default defineComponent({
"label": "最初の値"
}
]);
const checkInput=(val:ValueType)=>{
if(!val){
return false;
}
if(!val.name){
return "集計結果の変数名を入力してください";
}
if(!val.vars || val.vars.length==0){
return "集計処理を設定してください";
}
if(val.vars.some((x)=>!x.vName)){
return "集計結果変数名を入力してください";
}
return true;
}
const customExp = props.rules === undefined ? [] : eval(props.rules);
const requiredExp = props.required ? [(val: any) => checkInput(val)] : [];
const rulesExp = [...requiredExp, ...customExp];
watchEffect(() => {
emit('update:modelValue', processingProps);
@@ -232,6 +266,8 @@ export default defineComponent({
deleteProcessingObject,
logicalOperators,
processingObjectsInputDisplay,
rulesExp,
fieldRef
};
},
});