You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

218 lines
8.5 KiB

1 year ago
<template>
<div style="height: 100%">
<w-grid
ref="gridRef"
:title="$t('re.resources.designer.validator.grid.title')"
dense-body
hide-bottom
:config-button="false"
selection="multiple"
:checkbox-selection="false"
:tree="false"
:fetch-data-url="Environment.apiContextPath('/api/re/indicator/validator?indicator=' + indicator.id)"
:data-url="Environment.apiContextPath('/api/re/indicator/validator')"
:pageable="false"
:toolbar-configure="{ noIcon: false }"
:toolbar-actions="['refresh', 'separator', 'add', 'edit', 'remove', 'separator', 'view', 'separator', 'export']"
:columns="[
{ width: 60, name: 'order', label: $t('order'), sortable: false, align: 'right' },
{ width: 100, name: 'type', label: $t('type'), sortable: false, format: Formater.enum(Enums.ValidatorType) },
{
width: 300,
name: 'content',
label: $t('re.resources.designer.validator.grid.entity.content'),
sortable: false,
format: (value, row) => {
const type = row.type;
if (type == 'EMPTY' || type == 'NOT_EMPTY' || type == 'TRUE' || type == 'FALSE' || type == 'EMAIL') {
return '';
} else if (type == 'INTEGER_RANGE' || type == 'DECIMAL_RANGE' || type == 'LENGTH_RANGE' || type == 'DATE_RANGE') {
return Tools.generateIntervalRange(row.minInclude, row.minValue, row.maxValue, row.maxInclude);
} else if (type == 'PATTERN') {
return row.pattern;
}
return '';
},
},
{ width: '100%', name: 'tip', label: $t('re.resources.designer.validator.grid.entity.tip'), sortable: false },
]"
:editor="{
dialog: {
width: '600px',
},
form: {
colsNum: 1,
fields: [
{ name: 'indicator', label: 'indicator', type: 'text', defaultValue: indicator.id, hidden: true },
{ name: 'id', label: $t('id'), type: 'text', hidden: true },
{
name: 'description',
label: $t('description'),
type: 'text',
},
{
name: 'type',
label: $t('type'),
type: 'select',
required: true,
options:
ValueTypeAndValidatorTypeMapping[ValueTypeAndValidatorTypeMapping[indicator.valueType] == null ? 'java.lang.Object' : indicator.valueType],
},
{
name: 'minValue',
label: $t('minValue'),
type: 'text',
showIf: (arg) => {
const type = arg.form.getFieldValue('type');
if (type == 'INTEGER_RANGE' || type == 'DECIMAL_RANGE' || type == 'LENGTH_RANGE' || type == 'DATE_RANGE') {
return true;
}
return false;
},
},
{
name: 'minInclude',
label: $t('isMinValueInclude'),
type: 'checkbox',
showIf: (arg) => {
const type = arg.form.getFieldValue('type');
if (type == 'INTEGER_RANGE' || type == 'DECIMAL_RANGE' || type == 'LENGTH_RANGE' || type == 'DATE_RANGE') {
return true;
}
return false;
},
},
{
name: 'maxValue',
label: $t('maxValue'),
type: 'text',
showIf: (arg) => {
const type = arg.form.getFieldValue('type');
if (type == 'INTEGER_RANGE' || type == 'DECIMAL_RANGE' || type == 'LENGTH_RANGE' || type == 'DATE_RANGE') {
return true;
}
return false;
},
},
{
name: 'maxInclude',
label: $t('isMaxValueInclude'),
type: 'checkbox',
showIf: (arg) => {
const type = arg.form.getFieldValue('type');
if (type == 'INTEGER_RANGE' || type == 'DECIMAL_RANGE' || type == 'LENGTH_RANGE' || type == 'DATE_RANGE') {
return true;
}
return false;
},
},
{
name: 'pattern',
label: $t('RegExp'),
type: 'text',
showIf: (arg) => {
const type = arg.form.getFieldValue('type');
if (type == 'PATTERN') {
return true;
}
return false;
},
},
{
name: 'tip',
label: $t('re.resources.designer.validator.grid.entity.tip'),
type: 'text',
},
{ name: 'order', label: $t('order'), type: 'number', hidden: false },
],
},
}"
:viewer="{
panel: {
columnNum: 1,
fields: [
{ name: 'id', label: $t('id') },
{ name: 'order', label: $t('order') },
{ name: 'type', label: $t('type'), format: Formater.none() },
{ name: 'description', label: $t('description') },
{ name: 'tip', label: $t('re.resources.designer.validator.grid.entity.tip') },
{ name: 'minInclude', label: $t('isMinValueInclude') },
{ name: 'minValue', label: $t('minValue') },
{ name: 'maxValue', label: $t('maxValue') },
{ name: 'maxInclude', label: $t('isMaxValueInclude') },
{ name: 'pattern', label: $t('RegExp') },
{ name: 'dataComeFrom', label: $t('dataComeFrom') },
{ name: 'creator', label: $t('creator') },
{ name: 'createDate', label: $t('createDate') },
{ name: 'lastModifier', label: $t('lastModifier') },
{ name: 'lastModifyDate', label: $t('lastModifyDate'), format: Formater.none() },
{ name: 'corporationCode', label: $t('corporationCode') },
],
},
}"
></w-grid>
</div>
</template>
<script setup lang="ts">
import { ref, onMounted } from 'vue';
import { useI18n } from 'vue-i18n';
import { Environment, EnumTools, Formater, Tools } from 'platform-core';
const props = defineProps({
indicator: { type: Object, default: undefined },
});
const { t } = useI18n();
const gridRef = ref();
const ValueTypeAndValidatorTypeMapping = {
'java.lang.Boolean': [
{ value: 'NOT_EMPTY', label: t('io.sc.engine.rule.core.enums.ValidatorType.NOT_EMPTY') },
{ value: 'EMPTY', label: t('io.sc.engine.rule.core.enums.ValidatorType.EMPTY') },
{ value: 'TRUE', label: t('io.sc.engine.rule.core.enums.ValidatorType.TRUE') },
{ value: 'FALSE', label: t('io.sc.engine.rule.core.enums.ValidatorType.FALSE') },
],
'java.lang.Long': [
{ value: 'NOT_EMPTY', label: t('io.sc.engine.rule.core.enums.ValidatorType.NOT_EMPTY') },
{ value: 'EMPTY', label: t('io.sc.engine.rule.core.enums.ValidatorType.EMPTY') },
{ value: 'INTEGER_RANGE', label: t('io.sc.engine.rule.core.enums.ValidatorType.INTEGER_RANGE') },
],
'java.math.BigDecimal': [
{ value: 'NOT_EMPTY', label: t('io.sc.engine.rule.core.enums.ValidatorType.NOT_EMPTY') },
{ value: 'EMPTY', label: t('io.sc.engine.rule.core.enums.ValidatorType.EMPTY') },
{ value: 'DECIMAL_RANGE', label: t('io.sc.engine.rule.core.enums.ValidatorType.DECIMAL_RANGE') },
],
'java.lang.String': [
{ value: 'NOT_EMPTY', label: t('io.sc.engine.rule.core.enums.ValidatorType.NOT_EMPTY') },
{ value: 'EMPTY', label: t('io.sc.engine.rule.core.enums.ValidatorType.EMPTY') },
{ value: 'LENGTH_RANGE', label: t('io.sc.engine.rule.core.enums.ValidatorType.LENGTH_RANGE') },
{ value: 'EMAIL', label: t('io.sc.engine.rule.core.enums.ValidatorType.EMAIL') },
{ value: 'PATTERN', label: t('io.sc.engine.rule.core.enums.ValidatorType.PATTERN') },
],
'java.util.Date': [
{ value: 'NOT_EMPTY', label: t('io.sc.engine.rule.core.enums.ValidatorType.NOT_EMPTY') },
{ value: 'EMPTY', label: t('io.sc.engine.rule.core.enums.ValidatorType.EMPTY') },
{ value: 'DATE_RANGE', label: t('io.sc.engine.rule.core.enums.ValidatorType.DATE_RANGE') },
],
'java.lang.Object': [
{ value: 'NOT_EMPTY', label: t('io.sc.engine.rule.core.enums.ValidatorType.NOT_EMPTY') },
{ value: 'EMPTY', label: t('io.sc.engine.rule.core.enums.ValidatorType.EMPTY') },
],
};
const refresh = () => {
1 year ago
gridRef?.value?.refresh();
1 year ago
};
onMounted(() => {
1 year ago
gridRef?.value?.refresh();
1 year ago
});
defineExpose({
refresh,
});
const Enums = await EnumTools.fetch(['io.sc.engine.rule.core.enums.ValidatorType']);
</script>