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