|
|
@ -19,99 +19,99 @@ import { useI18n } from 'vue-i18n' |
|
|
|
import type { IJsonItem } from '../types' |
|
|
|
import type { IJsonItem } from '../types' |
|
|
|
|
|
|
|
|
|
|
|
export function useNodeSelectors({ |
|
|
|
export function useNodeSelectors({ |
|
|
|
model, |
|
|
|
model, |
|
|
|
field, |
|
|
|
field, |
|
|
|
name, |
|
|
|
name, |
|
|
|
span = 24 |
|
|
|
span = 24 |
|
|
|
}: { |
|
|
|
}: { |
|
|
|
model: { [field: string]: any } |
|
|
|
model: { [field: string]: any } |
|
|
|
field: string |
|
|
|
field: string |
|
|
|
name?: string |
|
|
|
name?: string |
|
|
|
span?: Ref | number |
|
|
|
span?: Ref | number |
|
|
|
}): IJsonItem[] { |
|
|
|
}): IJsonItem[] { |
|
|
|
const { t } = useI18n() |
|
|
|
const { t } = useI18n() |
|
|
|
|
|
|
|
|
|
|
|
return [ |
|
|
|
return [ |
|
|
|
|
|
|
|
{ |
|
|
|
|
|
|
|
type: 'custom-parameters', |
|
|
|
|
|
|
|
field: field, |
|
|
|
|
|
|
|
name: t(`project.node.${name}`), |
|
|
|
|
|
|
|
class: 'btn-custom-parameters', |
|
|
|
|
|
|
|
span, |
|
|
|
|
|
|
|
children: [ |
|
|
|
{ |
|
|
|
{ |
|
|
|
type: 'custom-parameters', |
|
|
|
type: 'input', |
|
|
|
field: field, |
|
|
|
field: 'key', |
|
|
|
name: t(`project.node.${name}`), |
|
|
|
span: 8, |
|
|
|
class: 'btn-custom-parameters', |
|
|
|
class: 'node-selector-label-name', |
|
|
|
span, |
|
|
|
props: { |
|
|
|
children: [ |
|
|
|
placeholder: t('project.node.expression_name_tips'), |
|
|
|
{ |
|
|
|
maxLength: 256 |
|
|
|
type: 'input', |
|
|
|
}, |
|
|
|
field: 'key', |
|
|
|
validate: { |
|
|
|
span: 8, |
|
|
|
trigger: ['input', 'blur'], |
|
|
|
class: 'node-selector-label-name', |
|
|
|
required: true, |
|
|
|
props: { |
|
|
|
validator(validate: any, value: string) { |
|
|
|
placeholder: t('project.node.expression_name_tips'), |
|
|
|
if (!value) { |
|
|
|
maxLength: 256 |
|
|
|
return new Error(t('project.node.expression_name_tips')) |
|
|
|
}, |
|
|
|
} |
|
|
|
validate: { |
|
|
|
|
|
|
|
trigger: ['input', 'blur'], |
|
|
|
|
|
|
|
required: true, |
|
|
|
|
|
|
|
validator(validate: any, value: string) { |
|
|
|
|
|
|
|
if (!value) { |
|
|
|
|
|
|
|
return new Error(t('project.node.expression_name_tips')) |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
const sameItems = model[field].filter( |
|
|
|
const sameItems = model[field].filter( |
|
|
|
(item: { label: string }) => item.label === value |
|
|
|
(item: { label: string }) => item.label === value |
|
|
|
) |
|
|
|
) |
|
|
|
|
|
|
|
|
|
|
|
if (sameItems.length > 1) { |
|
|
|
if (sameItems.length > 1) { |
|
|
|
return new Error(t('project.node.label_repeat')) |
|
|
|
return new Error(t('project.node.label_repeat')) |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
}, |
|
|
|
}, |
|
|
|
{ |
|
|
|
{ |
|
|
|
type: 'select', |
|
|
|
type: 'select', |
|
|
|
field: 'operator', |
|
|
|
field: 'operator', |
|
|
|
span: 4, |
|
|
|
span: 4, |
|
|
|
options: OPERATOR_LIST, |
|
|
|
options: OPERATOR_LIST, |
|
|
|
value: 'In', |
|
|
|
value: 'In' |
|
|
|
}, |
|
|
|
}, |
|
|
|
{ |
|
|
|
{ |
|
|
|
type: 'input', |
|
|
|
type: 'input', |
|
|
|
field: 'values', |
|
|
|
field: 'values', |
|
|
|
span: 10, |
|
|
|
span: 10, |
|
|
|
class: 'node-selector-label-value', |
|
|
|
class: 'node-selector-label-value', |
|
|
|
props: { |
|
|
|
props: { |
|
|
|
placeholder: t('project.node.expression_value_tips'), |
|
|
|
placeholder: t('project.node.expression_value_tips'), |
|
|
|
maxLength: 256, |
|
|
|
maxLength: 256, |
|
|
|
disabled: false |
|
|
|
disabled: false |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
] |
|
|
|
|
|
|
|
} |
|
|
|
} |
|
|
|
] |
|
|
|
] |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
] |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
export const OPERATOR_LIST = [ |
|
|
|
export const OPERATOR_LIST = [ |
|
|
|
{ |
|
|
|
{ |
|
|
|
value: 'In', |
|
|
|
value: 'In', |
|
|
|
label: 'In' |
|
|
|
label: 'In' |
|
|
|
}, |
|
|
|
}, |
|
|
|
{ |
|
|
|
{ |
|
|
|
value: 'NotIn', |
|
|
|
value: 'NotIn', |
|
|
|
label: 'NotIn' |
|
|
|
label: 'NotIn' |
|
|
|
}, |
|
|
|
}, |
|
|
|
{ |
|
|
|
{ |
|
|
|
value: 'Exists', |
|
|
|
value: 'Exists', |
|
|
|
label: 'Exists' |
|
|
|
label: 'Exists' |
|
|
|
}, |
|
|
|
}, |
|
|
|
{ |
|
|
|
{ |
|
|
|
value: 'DoesNotExist', |
|
|
|
value: 'DoesNotExist', |
|
|
|
label: 'DoesNotExist' |
|
|
|
label: 'DoesNotExist' |
|
|
|
}, |
|
|
|
}, |
|
|
|
{ |
|
|
|
{ |
|
|
|
value: 'Gt', |
|
|
|
value: 'Gt', |
|
|
|
label: 'Gt' |
|
|
|
label: 'Gt' |
|
|
|
}, |
|
|
|
}, |
|
|
|
{ |
|
|
|
{ |
|
|
|
value: 'Lt', |
|
|
|
value: 'Lt', |
|
|
|
label: 'Lt' |
|
|
|
label: 'Lt' |
|
|
|
} |
|
|
|
} |
|
|
|
] |
|
|
|
] |