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.

68 lines
1.9 KiB

import { ref } from 'vue';
import { $t, axios, Environment } from 'platform-core';
7 months ago
import { Processor } from '../Processor';
const optionOptionsRef = ref(<any>[]);
7 months ago
class OptionValue extends Processor {
6 months ago
#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) => {
6 months ago
const type = this.context.target.type;
return type !== 'RULE_RESULT' && type !== 'SINGLE_RULE_RESULT';
},
afterClick: (args: any) => {
args.grid.getEditorForm().setFieldValue('type', 'OPTION_VALUE');
},
};
}
7 months ago
public format(row: any): any {
return row.optionCode;
}
6 months ago
public getEditorFields(): any {
return [
{
6 months ago
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');
},
},
];
}
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.#editorDialogWidth);
// 获取选项输入参数列表
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 });
}
});
optionOptionsRef.value = options;
});
}
}
export { OptionValue };