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.

72 lines
2.1 KiB

import { ref } from 'vue';
import { $t, axios, Environment } from 'platform-core';
7 months ago
import { Processor } from '../Processor';
7 months ago
class OptionValue extends Processor {
6 months ago
optionOptionsRef = ref(<any>[]);
constructor(targetType: string, context?: any) {
super(targetType, context);
this.PROCESSOR_TYPE = 'OPTION_VALUE';
this.EDITOR_DIALOG_WIDTH = 400;
}
6 months ago
public getToolbarAction(): any {
return {
extend: 'add',
name: 'optionValue',
6 months ago
label: $t('io.sc.engine.rule.core.enums.ProcessorType.' + this.PROCESSOR_TYPE),
icon: 'bi-card-list',
enableIf: (args: any) => {
6 months ago
const type = this.context.target.type;
return type !== 'RULE_RESULT' && type !== 'SINGLE_RULE_RESULT';
},
afterClick: (args: any) => {
6 months ago
args.grid.getEditorForm().setFieldValue('type', this.PROCESSOR_TYPE);
},
};
}
7 months ago
public format(row: any): any {
return row.optionCode;
}
6 months ago
public getEditorFields(): any {
return [
{
6 months ago
colSpan: 12,
name: 'optionCode',
label: $t('re.resources.designer.processor.grid.entity.optionCode'),
type: 'w-select',
6 months ago
options: this.optionOptionsRef,
showIf: (args: any) => {
6 months ago
return args.form.getFieldValue('type') === this.PROCESSOR_TYPE;
},
},
];
}
6 months ago
public getViewerFields(): any {
return [{ name: 'optionCode', label: $t('re.resources.designer.processor.grid.entity.optionCode') }];
}
7 months ago
public beforeEditorDataSubmit(args: any): void {}
7 months ago
public afterEditorOpen(args: any): void {
6 months ago
args.grid.getEditorDialog().setWidth(this.EDITOR_DIALOG_WIDTH);
// 获取选项输入参数列表
6 months ago
axios.get(Environment.apiContextPath('/api/re/model/parameter/listParemtersByParameterId/' + this.context.target.id)).then((response) => {
const parameters: any[] = response.data;
const options: any[] = [];
parameters.forEach((item) => {
if (item.type === 'IN_OPTION') {
options.push({ label: item.name, value: item.code });
}
});
6 months ago
this.optionOptionsRef.value = options;
});
}
}
export { OptionValue };