fix: 添加 判断器 为空,不为空,不包含的条件

This commit is contained in:
shaohuzhang1 2024-06-28 11:14:44 +08:00
parent 84738d2832
commit fe58586be0
6 changed files with 80 additions and 2 deletions

View File

@ -0,0 +1,21 @@
# coding=utf-8
"""
@project: maxkb
@Author
@file is_not_null_compare.py
@date2024/6/28 10:45
@desc:
"""
from typing import List
from application.flow.step_node.condition_node.compare import Compare
class IsNotNullCompare(Compare):
def support(self, node_id, fields: List[str], source_value, compare, target_value):
if compare == 'is_not_null':
return True
def compare(self, source_value, compare, target_value):
return source_value is not None

View File

@ -0,0 +1,21 @@
# coding=utf-8
"""
@project: maxkb
@Author
@file is_null_compare.py
@date2024/6/28 10:45
@desc:
"""
from typing import List
from application.flow.step_node.condition_node.compare import Compare
class IsNullCompare(Compare):
def support(self, node_id, fields: List[str], source_value, compare, target_value):
if compare == 'is_null':
return True
def compare(self, source_value, compare, target_value):
return source_value is None

View File

@ -0,0 +1,23 @@
# coding=utf-8
"""
@project: maxkb
@Author
@file contain_compare.py
@date2024/6/11 10:02
@desc:
"""
from typing import List
from application.flow.step_node.condition_node.compare.compare import Compare
class ContainCompare(Compare):
def support(self, node_id, fields: List[str], source_value, compare, target_value):
if compare == 'not_contain':
return True
def compare(self, source_value, compare, target_value):
if isinstance(source_value, str):
return str(target_value) not in source_value
return not any([str(item) == str(target_value) for item in source_value])

View File

@ -25,7 +25,6 @@ const props = defineProps<{
modelValue: Array<any>
}>()
const emit = defineEmits(['update:modelValue'])
const data = computed({
set: (value) => {
emit('update:modelValue', value)

View File

@ -124,7 +124,10 @@ export const menuNodes = [
]
export const compareList = [
{ value: 'is_null', label: '为空' },
{ value: 'is_not_null', label: '不为空' },
{ value: 'contain', label: '包含' },
{ value: 'not_contain', label: '不包含' },
{ value: 'eq', label: '等于' },
{ value: 'ge', label: '大于等于' },
{ value: 'gt', label: '大于' },

View File

@ -67,6 +67,9 @@
}"
>
<el-select
@wheel="wheel"
@keydown="isKeyDown = true"
@keyup="isKeyDown = false"
:teleported="false"
v-model="condition.compare"
placeholder="请选择条件"
@ -153,7 +156,15 @@ const form = {
}
]
}
const isKeyDown = ref(false)
const wheel = (e: any) => {
if (isKeyDown.value) {
e.preventDefault()
} else {
e.stopPropagation()
return true
}
}
const resizeCondition = (wh: any, row: any, index: number) => {
const branch_condition_list = cloneDeep(
props.nodeModel.properties.branch_condition_list