Skip to content

Commit

Permalink
fix(editor): 值格式设置文本1后自动转为了数字1
Browse files Browse the repository at this point in the history
  • Loading branch information
yangwei9012 committed Jan 16, 2024
1 parent 79a29f9 commit b2520da
Show file tree
Hide file tree
Showing 2 changed files with 25 additions and 5 deletions.
1 change: 1 addition & 0 deletions packages/amis-editor-core/src/tpl.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,7 @@ export function valuePipeOut(value: any) {
return undefined;
}

// 文本1会被转为数字1,值格式慎用
return JSON.parse(value);
} catch (e) {
return value;
Expand Down
29 changes: 24 additions & 5 deletions packages/amis-editor/src/plugin/Form/Select.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,8 @@ import {
getSchemaTpl,
BasePlugin,
tipedLabel,
JSONPipeOut
JSONPipeOut,
undefinedPipeOut
} from 'amis-editor-core';

import {ValidatorTag} from '../../validator';
Expand Down Expand Up @@ -221,9 +222,6 @@ export class SelectControlPlugin extends BasePlugin {
]
}),
getSchemaTpl('checkAll'),
getSchemaTpl('valueFormula', {
rendererSchema: (schema: Schema) => schema
}),
getSchemaTpl('labelRemark'),
getSchemaTpl('remark'),
getSchemaTpl('placeholder'),
Expand All @@ -234,7 +232,28 @@ export class SelectControlPlugin extends BasePlugin {
title: '选项',
body: [
getSchemaTpl('optionControlV2'),
getSchemaTpl('selectFirst'),
getSchemaTpl('selectFirst', {
onChange: (
value: any,
oldValue: any,
model: any,
form: any
) => {
if (value) {
form.deleteValueByName('value');
}
}
}),
getSchemaTpl('valueFormula', {
rendererSchema: (schema: Schema) => ({
...schema,
type: 'input-text'
}),
pipeOut: undefinedPipeOut,
// 默认值组件设计有些问题,自动发起了请求,接口数据作为了默认值选项,接口形式应该是设置静态值或者FX
needDeleteProps: ['source'],
hiddenOn: 'this.selectFirst === true'
}),
getSchemaTpl(
'loadingConfig',
{
Expand Down

0 comments on commit b2520da

Please sign in to comment.