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.

258 lines
8.9 KiB

1 year ago
<template>
10 months ago
<div style="height: 100%">
<w-grid
ref="gridRef"
:title="$t('re.resources.designer.processor.grid.title')"
draggable="server"
10 months ago
dense
hide-bottom
db-click-operation="edit"
:config-button="true"
selection="multiple"
:checkbox-selection="false"
:tree="false"
:fetch-data-url="Environment.apiContextPath('/api/re/indicator/processor?indicator=' + indicator.id)"
:data-url="Environment.apiContextPath('/api/re/indicator/processor')"
:pageable="false"
:toolbar-configure="{ noIcon: false }"
:toolbar-actions="[
'refresh',
'separator',
[
{
extend: 'add',
click: undefined,
enableIf: (arg) => {
return !readOnly;
},
10 months ago
},
7 months ago
objectProperties.getToolbarAction(indicator),
mathFormula.getToolbarAction(indicator),
arithmetic.getToolbarAction(indicator),
ternary.getToolbarAction(indicator),
whenThen.getToolbarAction(indicator),
numberRange.getToolbarAction(indicator),
conditionRange.getToolbarAction(indicator),
groovyScript.getToolbarAction(indicator),
sql.getToolbarAction(indicator),
10 months ago
],
1 year ago
{
10 months ago
extend: 'clone',
1 year ago
enableIf: (arg) => {
10 months ago
return !readOnly && arg.selected;
1 year ago
},
},
{
10 months ago
extend: 'edit',
1 year ago
enableIf: (arg) => {
10 months ago
return !readOnly && arg.selected;
1 year ago
},
},
{
10 months ago
extend: 'remove',
1 year ago
enableIf: (arg) => {
10 months ago
return !readOnly && arg.selected;
1 year ago
},
},
10 months ago
'separator',
'view',
'separator',
'export',
]"
:columns="[
{ width: 60, name: 'order', label: $t('order'), sortable: false, align: 'right' },
{
width: 120,
name: 'type',
label: $t('type'),
sortable: false,
format: (value, row) => {
return $t('io.sc.engine.rule.core.enums.ProcessorType.' + value);
},
},
10 months ago
{
width: '100%',
name: 'content',
label: $t('re.resources.designer.processor.grid.entity.content'),
sortable: false,
format: (value, row) => {
switch (row.type) {
case 'ARITHMETIC':
7 months ago
return arithmetic.format(row);
case 'CONDITION_RANGE':
7 months ago
return conditionRange.format(row);
case 'GROOVY_SCRIPT':
7 months ago
return groovyScript.format(row);
case 'MATH_FORMULA':
7 months ago
return mathFormula.format(row);
case 'NUMBER_RANGE':
7 months ago
return numberRange.format(row);
case 'OBJECT_PROPERTIES':
7 months ago
return objectProperties.format(row);
case 'SQL':
7 months ago
return sql.format(row);
case 'TERNARY':
7 months ago
return ternary.format(row);
case 'WHEN_THEN':
7 months ago
return whenThen.format(row);
10 months ago
}
return '';
10 months ago
},
1 year ago
},
10 months ago
]"
:editor="{
dialog: {
width: '80%',
},
form: {
colsNum: 5,
fields: [
8 months ago
{ colSpan: 5, name: 'indicator', label: 'indicator', type: 'w-text', defaultValue: indicator.id, showIf: false },
{ colSpan: 5, name: 'id', label: $t('id'), type: 'w-text', showIf: false },
{ colSpan: 5, name: 'order', label: $t('order'), type: 'w-number', showIf: false },
{ colSpan: 5, name: 'type', label: $t('type'), type: 'w-text', showIf: false },
7 months ago
...arithmetic.getEditorFields(),
...conditionRange.getEditorFields(),
...groovyScript.getEditorFields(),
...mathFormula.getEditorFields(),
...numberRange.getEditorFields(),
...objectProperties.getEditorFields({ objectPropertiesMatcherDialogRef }),
...sql.getEditorFields(),
...ternary.getEditorFields(),
...whenThen.getEditorFields(),
10 months ago
],
},
}"
:viewer="{
panel: {
columnNum: 1,
fields: [
{ name: 'order', label: $t('order') },
{ name: 'id', label: $t('id'), primaryKey: true },
{ name: 'indicator', label: $t('indicator') },
{ name: 'description', label: $t('description') },
{ name: 'enable', label: $t('enable') },
{ name: 'type', label: $t('type') },
1 year ago
7 months ago
...arithmetic.getViewerFields(),
...conditionRange.getViewerFields(),
...groovyScript.getViewerFields(),
...mathFormula.getViewerFields(),
...numberRange.getViewerFields(),
...objectProperties.getViewerFields(),
...sql.getViewerFields(),
...ternary.getViewerFields(),
...whenThen.getViewerFields(),
1 year ago
10 months ago
{ 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() },
],
},
}"
@before-editor-data-submit="
(args) => {
switch (args.data.type) {
case 'ARITHMETIC':
7 months ago
return arithmetic.beforeEditorDataSubmit(args);
case 'CONDITION_RANGE':
7 months ago
return conditionRange.beforeEditorDataSubmit(args);
case 'GROOVY_SCRIPT':
7 months ago
return groovyScript.beforeEditorDataSubmit(args);
case 'MATH_FORMULA':
7 months ago
return mathFormula.beforeEditorDataSubmit(args);
case 'NUMBER_RANGE':
7 months ago
return numberRange.beforeEditorDataSubmit(args);
case 'OBJECT_PROPERTIES':
7 months ago
return objectProperties.beforeEditorDataSubmit(args);
case 'SQL':
7 months ago
return sql.beforeEditorDataSubmit(args);
case 'TERNARY':
7 months ago
return ternary.beforeEditorDataSubmit(args);
case 'WHEN_THEN':
7 months ago
return whenThen.beforeEditorDataSubmit(args);
10 months ago
}
}
10 months ago
"
@after-editor-open="
8 months ago
(args) => {
7 months ago
args.target = indicator;
switch (args.grid.getEditorForm().getFieldValue('type')) {
case 'ARITHMETIC':
7 months ago
return arithmetic.afterEditorOpen(args);
case 'CONDITION_RANGE':
7 months ago
return conditionRange.afterEditorOpen(args);
case 'GROOVY_SCRIPT':
7 months ago
return groovyScript.afterEditorOpen(args);
case 'MATH_FORMULA':
7 months ago
return mathFormula.afterEditorOpen(args);
case 'NUMBER_RANGE':
7 months ago
return numberRange.afterEditorOpen(args);
case 'OBJECT_PROPERTIES':
7 months ago
return objectProperties.afterEditorOpen(args);
case 'SQL':
7 months ago
return sql.afterEditorOpen(args);
case 'TERNARY':
7 months ago
return ternary.afterEditorOpen(args);
case 'WHEN_THEN':
7 months ago
return whenThen.afterEditorOpen(args);
10 months ago
}
}
10 months ago
"
></w-grid>
<ObjectPropertiesMatcherDialog
ref="objectPropertiesMatcherDialogRef"
target-type="indicator"
:target="indicator"
10 months ago
@after-matched="
(objectProperties) => {
const grid = gridRef.getEditorForm().getFieldComponent('objectProperties');
grid.setLocalData(objectProperties);
}
"
></ObjectPropertiesMatcherDialog>
</div>
1 year ago
</template>
<script setup lang="ts">
import 'tailwindcss/utilities.css';
import { ref, onMounted } from 'vue';
import { axios, Environment, Formater } from 'platform-core';
7 months ago
import { Processor } from '@/views/shared/Processor';
10 months ago
import { PlaceHolder } from '@/utils/PlaceHolder';
import ObjectPropertiesMatcherDialog from '@/views/shared/ObjectPropertiesMatcherDialog.vue';
import { Arithmetic, ConditionRange, GroovyScript, MathFormula, NumberRange, ObjectProperties, Sql, Ternary, WhenThen } from '@/views/shared/processors';
1 year ago
7 months ago
const arithmetic = new Arithmetic(Processor.INDICATOR);
const conditionRange = new ConditionRange(Processor.INDICATOR);
const groovyScript = new GroovyScript(Processor.INDICATOR);
const mathFormula = new MathFormula(Processor.INDICATOR);
const numberRange = new NumberRange(Processor.INDICATOR);
const objectProperties = new ObjectProperties(Processor.INDICATOR);
const sql = new Sql(Processor.INDICATOR);
const ternary = new Ternary(Processor.INDICATOR);
const whenThen = new WhenThen(Processor.INDICATOR);
1 year ago
const props = defineProps({
indicator: { type: Object, default: undefined },
10 months ago
readOnly: { type: Boolean, default: false },
1 year ago
});
const gridRef = ref();
10 months ago
const objectPropertiesMatcherDialogRef = ref();
1 year ago
const refresh = () => {
1 year ago
gridRef?.value?.refresh();
1 year ago
};
onMounted(() => {
1 year ago
gridRef?.value?.refresh();
1 year ago
});
defineExpose({
refresh,
});
</script>