|
|
|
import { ref } from 'vue';
|
|
|
|
import { $t, axios, Environment } from 'platform-core';
|
|
|
|
import { Processor } from '../Processor';
|
|
|
|
|
|
|
|
const optionOptionsRef = ref(<any>[]);
|
|
|
|
|
|
|
|
class OptionValue extends Processor {
|
|
|
|
#editorDialogWidth: number = 400;
|
|
|
|
|
|
|
|
public getToolbarAction(): any {
|
|
|
|
return {
|
|
|
|
extend: 'add',
|
|
|
|
name: 'optionValue',
|
|
|
|
label: $t('io.sc.engine.rule.core.enums.ProcessorType.OPTION_VALUE'),
|
|
|
|
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', 'OPTION_VALUE');
|
|
|
|
},
|
|
|
|
};
|
|
|
|
}
|
|
|
|
|
|
|
|
public format(row: any): any {
|
|
|
|
return row.optionCode;
|
|
|
|
}
|
|
|
|
|
|
|
|
public getEditorFields(): any {
|
|
|
|
return [
|
|
|
|
{
|
|
|
|
colSpan: 7,
|
|
|
|
name: 'optionCode',
|
|
|
|
label: $t('re.resources.designer.processor.grid.entity.optionCode'),
|
|
|
|
type: 'w-select',
|
|
|
|
options: optionOptionsRef,
|
|
|
|
showIf: (args: any) => {
|
|
|
|
return 'OPTION_VALUE' === args.form.getFieldValue('type');
|
|
|
|
},
|
|
|
|
},
|
|
|
|
];
|
|
|
|
}
|
|
|
|
|
|
|
|
public getViewerFields(): any {
|
|
|
|
return [{ name: 'optionCode', label: $t('re.resources.designer.processor.grid.entity.optionCode') }];
|
|
|
|
}
|
|
|
|
|
|
|
|
public beforeEditorDataSubmit(args: any): void {}
|
|
|
|
|
|
|
|
public afterEditorOpen(args: any): void {
|
|
|
|
args.grid.getEditorDialog().setWidth(this.#editorDialogWidth);
|
|
|
|
// 获取选项输入参数列表
|
|
|
|
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 });
|
|
|
|
}
|
|
|
|
});
|
|
|
|
optionOptionsRef.value = options;
|
|
|
|
});
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
export { OptionValue };
|