mirror of
https://gitee.com/baidu/amis.git
synced 2024-12-02 20:09:08 +08:00
feat: 评分 动作
This commit is contained in:
parent
0b32350151
commit
690baef6a0
@ -15,8 +15,26 @@ export default {
|
||||
body: [
|
||||
{
|
||||
name: "input-rating",
|
||||
type: "input-rating",
|
||||
option: "事件",
|
||||
type: "action",
|
||||
label: 'clear触发器',
|
||||
level: 'primary',
|
||||
onEvent: {
|
||||
click: {
|
||||
actions: [
|
||||
{
|
||||
actionType: 'clear',
|
||||
componentId: 'clear-input-rating-receiver',
|
||||
description: '点击清空指定输入框的内容'
|
||||
}
|
||||
]
|
||||
}
|
||||
}
|
||||
},
|
||||
{
|
||||
name: 'rate',
|
||||
id: 'clear-input-rating-receiver',
|
||||
type: 'input-rating',
|
||||
value: 3,
|
||||
onEvent: {
|
||||
change: {
|
||||
actions: [
|
||||
|
@ -1,6 +1,7 @@
|
||||
import React from 'react';
|
||||
import {FormItem, FormControlProps, FormBaseControl} from './Item';
|
||||
import {autobind, createObject} from '../../utils/helper';
|
||||
import {Action} from '../../types';
|
||||
import Rating, {textPositionType} from '../../components/Rating';
|
||||
|
||||
/**
|
||||
@ -85,6 +86,13 @@ export default class RatingControl extends React.Component<RatingProps, any> {
|
||||
readOnly: false
|
||||
};
|
||||
|
||||
doAction(action: Action, data: object, throwErrors: boolean) {
|
||||
const {resetValue} = this.props;
|
||||
if (action.actionType && ['clear', 'reset'].includes(action.actionType)) {
|
||||
this.handleChange(resetValue ?? '');
|
||||
}
|
||||
}
|
||||
|
||||
async dispatchChangeEvent(eventName: string, eventData: any = {}) {
|
||||
const {dispatchEvent, data} = this.props;
|
||||
let rendererEvent = await dispatchEvent(
|
||||
@ -98,7 +106,7 @@ export default class RatingControl extends React.Component<RatingProps, any> {
|
||||
}
|
||||
|
||||
@autobind
|
||||
async handleChange(value: number) {
|
||||
async handleChange(value: any) {
|
||||
const {onChange} = this.props;
|
||||
|
||||
const prevented = await this.dispatchChangeEvent('change', value);
|
||||
|
Loading…
Reference in New Issue
Block a user