Skip to content

Commit 4014816

Browse files
committed
feat: 补充等式左右值form校验
1 parent 04f4f63 commit 4014816

File tree

2 files changed

+45
-15
lines changed

2 files changed

+45
-15
lines changed

src/components/SimpleProcessDesignerV2/src/nodes-config/RouterNodeConfig.vue

Lines changed: 13 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -42,7 +42,10 @@
4242
>
4343
</div>
4444
</template>
45-
<Condition v-model="routerGroups[index]" />
45+
<Condition
46+
:ref="($event) => (conditionRef[index] = $event)"
47+
v-model="routerGroups[index]"
48+
/>
4649
</el-card>
4750
</el-form>
4851

@@ -84,8 +87,17 @@ const { nodeName, showInput, clickIcon, blurEvent } = useNodeName(NodeType.ROUTE
8487
const routerGroups = ref<RouterCondition[]>([])
8588
const nodeOptions = ref()
8689
90+
const conditionRef = ref([])
8791
// 保存配置
8892
const saveConfig = async () => {
93+
// 校验表单
94+
let valid = true
95+
for (const item of conditionRef.value) {
96+
if (!(await item.validate())) {
97+
valid = false
98+
}
99+
}
100+
if (!valid) return false
89101
const showText = getShowText()
90102
if (!showText) return false
91103
currentNode.value.name = nodeName.value!

src/components/SimpleProcessDesignerV2/src/nodes-config/components/Condition.vue

Lines changed: 32 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -59,15 +59,24 @@
5959

6060
<div class="flex pt-2" v-for="(rule, rIdx) in equation.rules" :key="rIdx">
6161
<div class="mr-2">
62-
<el-select style="width: 160px" v-model="rule.leftSide">
63-
<el-option
64-
v-for="(field, fIdx) in fieldOptions"
65-
:key="fIdx"
66-
:label="field.title"
67-
:value="field.field"
68-
:disabled="!field.required"
69-
/>
70-
</el-select>
62+
<el-form-item
63+
:prop="`conditionGroups.conditions.${cIdx}.rules.${rIdx}.leftSide`"
64+
:rules="{
65+
required: true,
66+
message: '左值不能为空',
67+
trigger: 'change'
68+
}"
69+
>
70+
<el-select style="width: 160px" v-model="rule.leftSide">
71+
<el-option
72+
v-for="(field, fIdx) in fieldOptions"
73+
:key="fIdx"
74+
:label="field.title"
75+
:value="field.field"
76+
:disabled="!field.required"
77+
/>
78+
</el-select>
79+
</el-form-item>
7180
</div>
7281
<div class="mr-2">
7382
<el-select v-model="rule.opCode" style="width: 100px">
@@ -80,7 +89,16 @@
8089
</el-select>
8190
</div>
8291
<div class="mr-2">
83-
<el-input v-model="rule.rightSide" style="width: 160px" />
92+
<el-form-item
93+
:prop="`conditionGroups.conditions.${cIdx}.rules.${rIdx}.rightSide`"
94+
:rules="{
95+
required: true,
96+
message: '右值不能为空',
97+
trigger: 'blur'
98+
}"
99+
>
100+
<el-input v-model="rule.rightSide" style="width: 160px" />
101+
</el-form-item>
84102
</div>
85103
<div class="mr-1 flex items-center" v-if="equation.rules.length > 1">
86104
<Icon icon="ep:delete" :size="18" @click="deleteConditionRule(equation, rIdx)" />
@@ -122,8 +140,8 @@ import {
122140
ConditionType,
123141
ProcessVariableEnum
124142
} from '../../consts'
125-
import {BpmModelFormType} from '@/utils/constants'
126-
import {useFormFields} from '../../node'
143+
import { BpmModelFormType } from '@/utils/constants'
144+
import { useFormFields } from '../../node'
127145
128146
const props = defineProps({
129147
modelValue: {
@@ -202,10 +220,10 @@ const addConditionGroup = (conditions) => {
202220
203221
const validate = async () => {
204222
if (!formRef) return false
205-
return await formRef.value.validate();
223+
return await formRef.value.validate()
206224
}
207225
208-
defineExpose({validate})
226+
defineExpose({ validate })
209227
</script>
210228

211229
<style lang="scss" scoped>

0 commit comments

Comments
 (0)