fix: typeError: Cannot read properties of undefined (reading 'find')

This commit is contained in:
chenos 2023-01-10 10:48:50 +08:00
parent 452ecb5fc7
commit 1dc4142da2
4 changed files with 35 additions and 12 deletions

View File

@ -107,7 +107,7 @@ export const useACLRolesCheck = () => {
}, },
getStrategyActionParams: (actionPath: string) => { getStrategyActionParams: (actionPath: string) => {
const actionAlias = getActionAlias(actionPath); const actionAlias = getActionAlias(actionPath);
const strategyAction = data?.strategy?.actions.find((action) => { const strategyAction = data?.strategy?.actions?.find((action) => {
const [value] = action.split(':'); const [value] = action.split(':');
return value === actionAlias; return value === actionAlias;
}); });

View File

@ -497,7 +497,7 @@ export default {
'General permissions': '通用配置', 'General permissions': '通用配置',
'Global action permissions': '全局操作权限', 'Global action permissions': '全局操作权限',
'General action permissions': '通用操作权限', 'General action permissions': '通用操作权限',
"Plugin settings permissions":"插件权限", "Plugin settings permissions":"插件配置权限",
'Allow to desgin pages':"允许界面配置", 'Allow to desgin pages':"允许界面配置",
"Allow to manage plugins":"允许管理插件", "Allow to manage plugins":"允许管理插件",
"Allow to configure plugins":"允许管理配置中心", "Allow to configure plugins":"允许管理配置中心",

View File

@ -25,17 +25,27 @@ export const mathFormula: IField = {
}, },
properties: { properties: {
...defaultProps, ...defaultProps,
expression: { dataType: {
type: 'string', type: 'string',
title: '{{t("Expression")}}', title: '{{t("Data type")}}',
required: true, 'x-component': 'Select',
description: '{{mathExpressionDescription}}',
'x-component': 'MathFormula.Expression',
'x-decorator': 'FormItem', 'x-decorator': 'FormItem',
'x-component-props': { default: 'number',
supports: ['number', 'percent', 'integer'], 'x-disabled': '{{ !createOnly }}',
useCurrentFields: '{{ useCurrentFields }}', 'x-reactions': [
}, {
target: 'uiSchema.x-component-props.step',
fulfill: {
state: {
display: '{{$self.value !== "string" ? "visible" : "none"}}',
},
},
},
],
enum: [
{ value: 'string', label: '{{t("String")}}' },
{ value: 'number', label: '{{t("Number")}}' },
],
}, },
'uiSchema.x-component-props.step': { 'uiSchema.x-component-props.step': {
type: 'string', type: 'string',
@ -53,6 +63,18 @@ export const mathFormula: IField = {
{ value: '0.00001', label: '1.00000' }, { value: '0.00001', label: '1.00000' },
], ],
}, },
expression: {
type: 'string',
title: '{{t("Expression")}}',
required: true,
description: '{{mathExpressionDescription}}',
'x-component': 'MathFormula.Expression',
'x-decorator': 'FormItem',
'x-component-props': {
supports: ['number', 'percent', 'integer'],
useCurrentFields: '{{ useCurrentFields }}',
},
},
}, },
filterable: { filterable: {
operators: operators.number, operators: operators.number,

View File

@ -5,7 +5,8 @@ import { evaluate } from '../utils/evaluate';
export class MathFormulaField extends Field { export class MathFormulaField extends Field {
get dataType() { get dataType() {
return DataTypes.DOUBLE; const { dataType } = this.options;
return dataType === 'string' ? DataTypes.STRING : DataTypes.DOUBLE;
} }
calculate(expression, scope) { calculate(expression, scope) {