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.
63 lines
1.8 KiB
63 lines
1.8 KiB
7 months ago
|
import { ref } from 'vue';
|
||
|
import { $t, axios, Environment } from 'platform-core';
|
||
|
|
||
|
const optionOptionsRef = ref(<any>[]);
|
||
|
|
||
|
class OptionValue {
|
||
|
public static getToolbarAction(parameter: any) {
|
||
|
return {
|
||
|
extend: 'add',
|
||
|
name: 'optionValue',
|
||
|
label: $t('io.sc.engine.rule.core.enums.ProcessorType.OPTION_VALUE'),
|
||
|
icon: 'bi-card-list',
|
||
|
enableIf: (args: any) => {
|
||
|
return parameter.type !== 'RULE_RESULT' && parameter.type !== 'SINGLE_RULE_RESULT';
|
||
|
},
|
||
|
afterClick: (args: any) => {
|
||
|
args.grid.getEditorForm().setFieldValue('type', 'OPTION_VALUE');
|
||
|
},
|
||
|
};
|
||
|
}
|
||
|
|
||
|
public static format(row: any) {
|
||
|
return row.optionCode;
|
||
|
}
|
||
|
|
||
|
public static getEditorFields(properties: 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');
|
||
|
},
|
||
|
},
|
||
|
];
|
||
|
}
|
||
|
|
||
|
public static getViewerFields(properties: any) {
|
||
|
return [{ name: 'optionCode', label: $t('re.resources.designer.processor.grid.entity.optionCode') }];
|
||
|
}
|
||
|
|
||
|
public static beforeEditorDataSubmit(args: any) {}
|
||
|
|
||
|
public static afterEditorOpen(args: any) {
|
||
|
// 获取选项输入参数列表
|
||
|
axios.get(Environment.apiContextPath('/api/re/model/parameter/listParemtersByParameterId/' + args.parameter.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 };
|