| | |
| | | import React, {Component} from 'react' |
| | | import PropTypes from 'prop-types' |
| | | import moment from 'moment' |
| | | import { Button, Modal, notification, Spin, message } from 'antd' |
| | | import { Button, Modal, notification, message } from 'antd' |
| | | import Utils from '@/utils/utils.js' |
| | | import Api from '@/api' |
| | | import './index.scss' |
| | |
| | | |
| | | class MainAction extends Component { |
| | | static propTpyes = { |
| | | BData: PropTypes.any, // 主表数据 |
| | | type: PropTypes.string, // 判断当前为主表(main)、子表(sub)、子表标签(subtab) |
| | | MenuID: PropTypes.string, // 菜单ID |
| | | actions: PropTypes.array, // 按钮组 |
| | | logcolumns: PropTypes.array, // 日志中显示列 |
| | | logcolumns: PropTypes.array, // 显示列 |
| | | dict: PropTypes.object, // 字典项 |
| | | data: PropTypes.any, // 数据 |
| | | setting: PropTypes.any, // 页面通用设置 |
| | | triggerPopview: PropTypes.func // 弹窗标签页触发 |
| | | refreshdata: PropTypes.func, // 执行完成后数据刷新 |
| | | } |
| | | |
| | | state = { |
| | | visible: false, |
| | | formdata: null, |
| | | tabledata: null, |
| | | confirmLoading: false, |
| | | loadingUuid: '', |
| | | btnloading: false |
| | | loadingUuid: '' |
| | | } |
| | | |
| | | /** |
| | | * @description 触发按钮操作 |
| | | */ |
| | | actionTrigger = (item, record) => { |
| | | const { setting } = this.props |
| | | actionTrigger = (item) => { |
| | | const { data } = this.props |
| | | |
| | | let _this = this |
| | | let data = this.props.gettableselected() || [] |
| | | |
| | | if (item.Ot !== 'notRequired' && data.length === 0) { |
| | | // 需要选择行时,校验数据 |
| | | notification.warning({ |
| | | top: 92, |
| | | message: this.props.dict['main.action.confirm.selectline'], |
| | | duration: 10 |
| | | }) |
| | | return |
| | | } else if (item.Ot === 'requiredSgl' && data.length !== 1) { |
| | | // 需要选择单行时,校验数据 |
| | | notification.warning({ |
| | | top: 92, |
| | | message: this.props.dict['main.action.confirm.selectSingleLine'], |
| | | duration: 10 |
| | | }) |
| | | return |
| | | } else if (item.Ot !== 'notRequired' && !setting.primaryKey) { |
| | | // 需要选择行时,校验是否设置主键 |
| | | notification.warning({ |
| | | top: 92, |
| | | message: '未设置主键!', |
| | | duration: 10 |
| | | }) |
| | | return |
| | | } |
| | | |
| | | if (item.OpenType === 'prompt') { |
| | | confirm({ |
| | |
| | | this.setState({loadingUuid: item.uuid}) |
| | | this.execSubmit(item, data, () => { |
| | | this.setState({loadingUuid: ''}) |
| | | }) |
| | | } else if (item.OpenType === 'pop') { |
| | | this.setState({ |
| | | tabledata: data, |
| | | btnloading: true |
| | | }) |
| | | } else { |
| | | notification.warning({ |
| | | top: 92, |
| | | message: '完善中。。。', |
| | | duration: 10 |
| | | }) |
| | | } |
| | | } |
| | |
| | | } else if (res && res.ErrCode === '-1') { // 完成后不提示 |
| | | |
| | | } |
| | | |
| | | if (btn.OpenType === 'pop' && btn.setting && btn.setting.finish !== 'unclose') { |
| | | this.setState({ |
| | | visible: false |
| | | }) |
| | | } |
| | | |
| | | this.props.refreshdata(btn, 'success') |
| | | } |
| | |
| | | |
| | | |
| | | render() { |
| | | const { loadingUuid, btnloading } = this.state |
| | | const { loadingUuid } = this.state |
| | | |
| | | return ( |
| | | <div className="button-list toolbar-button"> |
| | | <div className="button-list formtab-button"> |
| | | {this.props.actions.map((item, index) => { |
| | | if (loadingUuid === item.uuid) { |
| | | return ( |
| | |
| | | ) |
| | | } |
| | | })} |
| | | <Button |
| | | className={'mk-btn'} |
| | | // icon={item.icon} |
| | | onClick={() => {this.actionTrigger()}} |
| | | >确定</Button> |
| | | <Button |
| | | className={'mk-btn'} |
| | | // icon={item.icon} |
| | | onClick={() => {this.actionTrigger()}} |
| | | >返回</Button> |
| | | {btnloading && <Spin size="large" />} |
| | | </div> |
| | | ) |
| | | } |