feat: 补充等式左右值form校验
parent
04f4f630ad
commit
401481662f
|
@ -42,7 +42,10 @@
|
||||||
>
|
>
|
||||||
</div>
|
</div>
|
||||||
</template>
|
</template>
|
||||||
<Condition v-model="routerGroups[index]" />
|
<Condition
|
||||||
|
:ref="($event) => (conditionRef[index] = $event)"
|
||||||
|
v-model="routerGroups[index]"
|
||||||
|
/>
|
||||||
</el-card>
|
</el-card>
|
||||||
</el-form>
|
</el-form>
|
||||||
|
|
||||||
|
@ -84,8 +87,17 @@ const { nodeName, showInput, clickIcon, blurEvent } = useNodeName(NodeType.ROUTE
|
||||||
const routerGroups = ref<RouterCondition[]>([])
|
const routerGroups = ref<RouterCondition[]>([])
|
||||||
const nodeOptions = ref()
|
const nodeOptions = ref()
|
||||||
|
|
||||||
|
const conditionRef = ref([])
|
||||||
// 保存配置
|
// 保存配置
|
||||||
const saveConfig = async () => {
|
const saveConfig = async () => {
|
||||||
|
// 校验表单
|
||||||
|
let valid = true
|
||||||
|
for (const item of conditionRef.value) {
|
||||||
|
if (!(await item.validate())) {
|
||||||
|
valid = false
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if (!valid) return false
|
||||||
const showText = getShowText()
|
const showText = getShowText()
|
||||||
if (!showText) return false
|
if (!showText) return false
|
||||||
currentNode.value.name = nodeName.value!
|
currentNode.value.name = nodeName.value!
|
||||||
|
|
|
@ -59,15 +59,24 @@
|
||||||
|
|
||||||
<div class="flex pt-2" v-for="(rule, rIdx) in equation.rules" :key="rIdx">
|
<div class="flex pt-2" v-for="(rule, rIdx) in equation.rules" :key="rIdx">
|
||||||
<div class="mr-2">
|
<div class="mr-2">
|
||||||
<el-select style="width: 160px" v-model="rule.leftSide">
|
<el-form-item
|
||||||
<el-option
|
:prop="`conditionGroups.conditions.${cIdx}.rules.${rIdx}.leftSide`"
|
||||||
v-for="(field, fIdx) in fieldOptions"
|
:rules="{
|
||||||
:key="fIdx"
|
required: true,
|
||||||
:label="field.title"
|
message: '左值不能为空',
|
||||||
:value="field.field"
|
trigger: 'change'
|
||||||
:disabled="!field.required"
|
}"
|
||||||
/>
|
>
|
||||||
</el-select>
|
<el-select style="width: 160px" v-model="rule.leftSide">
|
||||||
|
<el-option
|
||||||
|
v-for="(field, fIdx) in fieldOptions"
|
||||||
|
:key="fIdx"
|
||||||
|
:label="field.title"
|
||||||
|
:value="field.field"
|
||||||
|
:disabled="!field.required"
|
||||||
|
/>
|
||||||
|
</el-select>
|
||||||
|
</el-form-item>
|
||||||
</div>
|
</div>
|
||||||
<div class="mr-2">
|
<div class="mr-2">
|
||||||
<el-select v-model="rule.opCode" style="width: 100px">
|
<el-select v-model="rule.opCode" style="width: 100px">
|
||||||
|
@ -80,7 +89,16 @@
|
||||||
</el-select>
|
</el-select>
|
||||||
</div>
|
</div>
|
||||||
<div class="mr-2">
|
<div class="mr-2">
|
||||||
<el-input v-model="rule.rightSide" style="width: 160px" />
|
<el-form-item
|
||||||
|
:prop="`conditionGroups.conditions.${cIdx}.rules.${rIdx}.rightSide`"
|
||||||
|
:rules="{
|
||||||
|
required: true,
|
||||||
|
message: '右值不能为空',
|
||||||
|
trigger: 'blur'
|
||||||
|
}"
|
||||||
|
>
|
||||||
|
<el-input v-model="rule.rightSide" style="width: 160px" />
|
||||||
|
</el-form-item>
|
||||||
</div>
|
</div>
|
||||||
<div class="mr-1 flex items-center" v-if="equation.rules.length > 1">
|
<div class="mr-1 flex items-center" v-if="equation.rules.length > 1">
|
||||||
<Icon icon="ep:delete" :size="18" @click="deleteConditionRule(equation, rIdx)" />
|
<Icon icon="ep:delete" :size="18" @click="deleteConditionRule(equation, rIdx)" />
|
||||||
|
@ -122,8 +140,8 @@ import {
|
||||||
ConditionType,
|
ConditionType,
|
||||||
ProcessVariableEnum
|
ProcessVariableEnum
|
||||||
} from '../../consts'
|
} from '../../consts'
|
||||||
import {BpmModelFormType} from '@/utils/constants'
|
import { BpmModelFormType } from '@/utils/constants'
|
||||||
import {useFormFields} from '../../node'
|
import { useFormFields } from '../../node'
|
||||||
|
|
||||||
const props = defineProps({
|
const props = defineProps({
|
||||||
modelValue: {
|
modelValue: {
|
||||||
|
@ -202,10 +220,10 @@ const addConditionGroup = (conditions) => {
|
||||||
|
|
||||||
const validate = async () => {
|
const validate = async () => {
|
||||||
if (!formRef) return false
|
if (!formRef) return false
|
||||||
return await formRef.value.validate();
|
return await formRef.value.validate()
|
||||||
}
|
}
|
||||||
|
|
||||||
defineExpose({validate})
|
defineExpose({ validate })
|
||||||
</script>
|
</script>
|
||||||
|
|
||||||
<style lang="scss" scoped>
|
<style lang="scss" scoped>
|
||||||
|
|
Loading…
Reference in New Issue