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.

65 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 {
public getToolbarAction(target: any): any {
return {
extend: 'add',
name: 'optionValue',
label: $t('io.sc.engine.rule.core.enums.ProcessorType.OPTION_VALUE'),
icon: 'bi-card-list',
enableIf: (args: any) => {
7 months ago
return target.type !== 'RULE_RESULT' && target.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;
}
7 months ago
public getEditorFields(context?: any): any {
return [
{
colSpan: 5,
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');
},
},
];
}
7 months ago
public getViewerFields(context?: any): 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 {
args.grid.getEditorDialog().setWidth('40%');
// 获取选项输入参数列表
7 months ago
axios.get(Environment.apiContextPath('/api/re/model/parameter/listParemtersByParameterId/' + args.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 };