From cec9290f6cd8e3e7e881f4d38d43de307645a08a Mon Sep 17 00:00:00 2001 From: king <18310653075@163.com> Date: 星期一, 23 九月 2019 09:29:48 +0800 Subject: [PATCH] 2019-09-23update --- src/components/mainAction/index.jsx | 66 ++++++++++++++++++++++++-------- 1 files changed, 49 insertions(+), 17 deletions(-) diff --git a/src/components/mainAction/index.jsx b/src/components/mainAction/index.jsx index 12149a1..95df621 100644 --- a/src/components/mainAction/index.jsx +++ b/src/components/mainAction/index.jsx @@ -1,13 +1,16 @@ import React, {Component} from 'react' import PropTypes from 'prop-types' // import { is, fromJS } from 'immutable' -import { Button, Affix } from 'antd' +import { Button, Affix, Modal } from 'antd' import './index.scss' + +const { confirm } = Modal class MainAction extends Component { static propTpyes = { actions: PropTypes.array, // 鎼滅储鏉′欢鍒楄〃 - dict: PropTypes.object // 瀛楀吀椤� + dict: PropTypes.object, // 瀛楀吀椤� + fixed: PropTypes.any } state = { @@ -15,7 +18,20 @@ } actionTrigger = (item) => { - console.log(item) + if (item.Action === 'Prompt' || item.Action === 'Delete') { + confirm({ + title: this.props.dict['main.action.confirm.tip'], + // content: 'Some descriptions', + onOk() { + return new Promise((resolve, reject) => { + setTimeout(Math.random() > 0.5 ? resolve : reject, 1000) + }).catch(() => console.log('Oops errors!')) + }, + onCancel() { + console.log('Cancel') + } + }) + } } UNSAFE_componentWillMount () { @@ -28,21 +44,37 @@ // } render() { + if (this.props.fixed) { // 鎸夐挳鏄惁鍥哄畾鍦ㄥご閮� + return ( + <Affix offsetTop={48}> + <div className="button-list"> + {this.props.actions.map((item, index) => { + return ( + <Button + className={'mk-btn ' + item.CssClass} + icon={item.Icon} + key={'action' + index} + onClick={() => {this.actionTrigger(item)}} + >{item.MenuName}</Button> + ) + })} + </div> + </Affix> + ) + } return ( - <Affix offsetTop={48}> - <div className="button-list"> - {this.props.actions.map((item, index) => { - return ( - <Button - className={'mk-btn ' + item.CssClass} - icon={item.Icon} - key={'action' + index} - onClick={() => {this.actionTrigger(item)}} - >{item.MenuName}</Button> - ) - })} - </div> - </Affix> + <div className="button-list"> + {this.props.actions.map((item, index) => { + return ( + <Button + className={'mk-btn ' + item.CssClass} + icon={item.Icon} + key={'action' + index} + onClick={() => {this.actionTrigger(item)}} + >{item.MenuName}</Button> + ) + })} + </div> ) } } -- Gitblit v1.8.0