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.

244 lines
8.8 KiB

1 year ago
<template>
<w-grid
ref="gridRef"
:title="$t('re.resources.designer.validator.grid.title')"
draggable="server"
1 year ago
dense-body
class="px-1"
hide-bottom
:config-button="false"
selection="multiple"
10 months ago
:checkbox-selection="true"
1 year ago
:tree="false"
1 year ago
:fetch-data-url="Environment.apiContextPath('/api/re/model/parameter/validator/findByParameterId?parameterId=' + parameter.id)"
1 year ago
:data-url="Environment.apiContextPath('/api/re/model/parameter/validator')"
:pageable="false"
:toolbar-configure="{ noIcon: false }"
10 months ago
:toolbar-actions="[
'refresh',
'separator',
{
extend: 'add',
enableIf: (arg) => {
return !readOnly;
},
},
{
extend: 'edit',
enableIf: (arg) => {
return !readOnly && arg.selected;
},
},
{
extend: 'remove',
enableIf: (arg) => {
return !readOnly && arg.selected;
},
},
'separator',
'view',
'separator',
'export',
]"
1 year ago
: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: [
8 months ago
{ name: 'parameter', label: 'parameter', type: 'w-text', defaultValue: parameter.id, showIf: false },
{ name: 'id', label: $t('id'), type: 'w-text', showIf: false },
1 year ago
{
name: 'description',
label: $t('description'),
8 months ago
type: 'w-text',
1 year ago
},
8 months ago
{ name: 'type', label: $t('type'), type: 'w-select', options: ValueTypeAndValidatorTypeMapping[parameter.valueType] },
1 year ago
{
name: 'minValue',
label: $t('minValue'),
8 months ago
type: 'w-text',
1 year ago
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'),
8 months ago
type: 'w-checkbox',
1 year ago
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'),
8 months ago
type: 'w-text',
1 year ago
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'),
8 months ago
type: 'w-checkbox',
1 year ago
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'),
8 months ago
type: 'w-text',
1 year ago
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'),
8 months ago
type: 'w-text',
1 year ago
},
6 months ago
{ name: 'order', label: $t('order'), type: 'w-number' },
1 year ago
],
},
}"
: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>
</template>
<script setup lang="ts">
import 'tailwindcss/utilities.css';
1 year ago
import { ref, onMounted } from 'vue';
1 year ago
import { useI18n } from 'vue-i18n';
1 year ago
import { Environment, EnumTools, Formater, Tools } from 'platform-core';
1 year ago
const props = defineProps({
fetchDataUrl: { type: String, default: '' },
dataUrl: { type: String, default: '' },
parameter: { type: Object, default: undefined },
10 months ago
readOnly: { type: Boolean, default: false },
1 year ago
});
const emit = defineEmits<{
(e: 'rowClick', evt: Event, row: any, index: number): void;
(e: 'beforeRequestData', requestParams: URLSearchParams | any, callback: any): void;
}>();
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 = () => {
gridRef.value.refresh();
};
1 year ago
onMounted(() => {
gridRef.value.refresh();
});
1 year ago
defineExpose({
refresh,
});
const Enums = await EnumTools.fetch(['io.sc.engine.rule.core.enums.ValidatorType']);
</script>