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) => {
const actionAlias = getActionAlias(actionPath);
const strategyAction = data?.strategy?.actions.find((action) => {
const strategyAction = data?.strategy?.actions?.find((action) => {
const [value] = action.split(':');
return value === actionAlias;
});

View File

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

View File

@ -25,18 +25,28 @@ export const mathFormula: IField = {
},
properties: {
...defaultProps,
expression: {
dataType: {
type: 'string',
title: '{{t("Expression")}}',
required: true,
description: '{{mathExpressionDescription}}',
'x-component': 'MathFormula.Expression',
title: '{{t("Data type")}}',
'x-component': 'Select',
'x-decorator': 'FormItem',
'x-component-props': {
supports: ['number', 'percent', 'integer'],
useCurrentFields: '{{ useCurrentFields }}',
default: 'number',
'x-disabled': '{{ !createOnly }}',
'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': {
type: 'string',
title: '{{t("Precision")}}',
@ -53,6 +63,18 @@ export const mathFormula: IField = {
{ 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: {
operators: operators.number,

View File

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