| | |
| | | import React, {Component} from 'react' |
| | | import PropTypes from 'prop-types' |
| | | import moment from 'moment' |
| | | import { Button, Affix, Modal, notification, Spin } from 'antd' |
| | | import { Button, Affix, Modal, notification, Spin, message } from 'antd' |
| | | import MutilForm from '@/tabviews/tableshare/mutilform' |
| | | import Utils from '@/utils/utils.js' |
| | | import Api from '@/api' |
| | |
| | | configMap: {} |
| | | } |
| | | |
| | | UNSAFE_componentWillMount() { |
| | | console.log(this.props.type) |
| | | } |
| | | |
| | | refreshdata = (item, type) => { |
| | | this.props.refreshdata(item, type) |
| | | } |
| | | |
| | | /** |
| | | * @description 触发按钮操作 |
| | | */ |
| | | actionTrigger = (item, record) => { |
| | | const { setting } = this.props |
| | | |
| | |
| | | |
| | | Api.genericInterface(param).then((res) => { |
| | | if (res.status) { |
| | | this.execSuccess(btn) |
| | | this.execSuccess(btn, res) |
| | | } else { |
| | | this.execError(res, btn) |
| | | } |
| | |
| | | let errorMsg = '' |
| | | result.forEach(res => { |
| | | if (res.status) { |
| | | |
| | | errorMsg = res |
| | | } else { |
| | | iserror = true |
| | | errorMsg = res.message |
| | | errorMsg = res |
| | | } |
| | | }) |
| | | if (!iserror) { |
| | | this.execSuccess(btn) |
| | | this.execSuccess(btn, errorMsg) |
| | | } else { |
| | | notification.error({ |
| | | top: 92, |
| | | message: errorMsg, |
| | | duration: 15 |
| | | }) |
| | | this.refreshdata(btn, 'error') |
| | | this.execError(errorMsg, btn) |
| | | } |
| | | _resolve() |
| | | }) |
| | |
| | | response.func = btn.callbackFunc |
| | | return Api.genericInterface(response) |
| | | } else { |
| | | this.execSuccess(btn) |
| | | this.execSuccess(btn, response) |
| | | _resolve() |
| | | } |
| | | } else { |
| | |
| | | if (!res) return |
| | | |
| | | if (res.status) { |
| | | this.execSuccess(btn) |
| | | this.execSuccess(btn, res) |
| | | } else { |
| | | this.execError(res, btn) |
| | | } |
| | |
| | | result.forEach(res => { |
| | | if (!res.status) { |
| | | iserror = true |
| | | errorMsg = res.message |
| | | errorMsg = res |
| | | } else { |
| | | errorMsg = res |
| | | } |
| | | }) |
| | | if (iserror) { |
| | | notification.error({ |
| | | top: 92, |
| | | message: errorMsg, |
| | | duration: 15 |
| | | }) |
| | | this.refreshdata(btn, 'error') |
| | | this.execError(errorMsg, btn) |
| | | _resolve() |
| | | return |
| | | } |
| | |
| | | return Promise.all(deffers) |
| | | } else { |
| | | _resolve() |
| | | this.execSuccess(btn) |
| | | this.execSuccess(btn, errorMsg) |
| | | } |
| | | }).then(result => { |
| | | if (!result) return |
| | |
| | | result.forEach(res => { |
| | | if (!res.status) { |
| | | iserror = true |
| | | errorMsg = res.message |
| | | errorMsg = res |
| | | } else { |
| | | errorMsg = res |
| | | } |
| | | }) |
| | | if (iserror) { |
| | | notification.error({ |
| | | top: 92, |
| | | message: errorMsg, |
| | | duration: 15 |
| | | }) |
| | | this.refreshdata(btn, 'error') |
| | | this.execError(errorMsg, btn) |
| | | return |
| | | } else { |
| | | this.execSuccess(btn) |
| | | this.execSuccess(btn, errorMsg) |
| | | } |
| | | _resolve() |
| | | }) |
| | |
| | | } |
| | | } |
| | | |
| | | execSuccess = (btn) => { |
| | | /** |
| | | * @description 操作成功后处理 |
| | | * 1、excel导出,成功后取消导出按钮加载中状态 |
| | | * 2、状态码为 S 时,显示成功信息后系统默认信息 |
| | | * 3、状态码为 -1 时,不显示任何信息 |
| | | * 4、模态框执行成功后是否关闭 |
| | | * 5、通知主列表刷新 |
| | | */ |
| | | execSuccess = (btn, res) => { |
| | | if (btn.OpenType === 'excelOut') { |
| | | this.setState({ |
| | | loadingUuid: '' |
| | | }) |
| | | } else { |
| | | } else if (res && res.ErrCode === 'S') { |
| | | notification.success({ |
| | | top: 92, |
| | | message: this.props.dict['main.action.confirm.success'], |
| | | message: res.ErrMesg || this.props.dict['main.action.confirm.success'], |
| | | duration: 2 |
| | | }) |
| | | } else if (res && res.ErrCode === '-1') { |
| | | |
| | | } |
| | | |
| | | if (btn.OpenType === 'pop' && btn.setting && btn.setting.finish !== 'unclose') { |
| | |
| | | this.refreshdata(btn, 'success') |
| | | } |
| | | |
| | | /** |
| | | * @description 操作失败后处理 |
| | | * 1、状态码为 E、N、F、NM 时,显示相应提示信息 |
| | | * 2、excel导出,失败后取消导出按钮加载中状态 |
| | | * 3、通知主列表刷新 |
| | | */ |
| | | execError = (res, btn) => { |
| | | if (!res.ErrCode || res.ErrCode === 'E') { |
| | | if (res.ErrCode === 'E') { |
| | | Modal.error({ |
| | | title: res.message || res.ErrMesg, |
| | | }) |
| | | } else if (res.ErrCode === 'N') { |
| | | notification.error({ |
| | | top: 92, |
| | | message: res.message || res.ErrMesg, |
| | | duration: 15 |
| | | duration: btn.errorTime || 15 |
| | | }) |
| | | } else if (res.ErrCode === 'E') { |
| | | Modal.error({ |
| | | title: res.message || res.ErrMesg |
| | | } else if (res.ErrCode === 'F') { |
| | | notification.error({ |
| | | className: 'notification-custom-error', |
| | | top: 92, |
| | | message: res.message || res.ErrMesg, |
| | | duration: btn.errorTime || 15 |
| | | }) |
| | | } else if (res.ErrCode === 'NM') { |
| | | message.error(res.message || res.ErrMesg) |
| | | } |
| | | |
| | | if (btn.OpenType === 'excelOut') { |
| | |
| | | this.refreshdata(btn, 'error') |
| | | } |
| | | |
| | | /** |
| | | * @description 按钮配置信息错误提示 |
| | | */ |
| | | actionSettingError = () => { |
| | | notification.warning({ |
| | | top: 92, |
| | |
| | | }) |
| | | } |
| | | |
| | | /** |
| | | * @description 获取按钮配置信息 |
| | | */ |
| | | improveAction = (action) => { |
| | | const { configMap, execAction } = this.state |
| | | |
| | |
| | | } |
| | | } |
| | | |
| | | /** |
| | | * @description 获取下拉表单选项信息 |
| | | */ |
| | | improveActionForm = () => { |
| | | const { configMap, execAction } = this.state |
| | | let subfields = [] |
| | |
| | | }) |
| | | } |
| | | |
| | | /** |
| | | * @description 模态框(表单),确认 |
| | | */ |
| | | handleOk = () => { |
| | | this.formRef.handleConfirm().then(res => { |
| | | this.setState({ |
| | |
| | | }, () => {}) |
| | | } |
| | | |
| | | /** |
| | | * @description 模态框(表单),取消 |
| | | */ |
| | | handleCancel = () => { |
| | | this.setState({ |
| | | visible: false |
| | | }) |
| | | } |
| | | |
| | | /** |
| | | * @description 显示模态框 |
| | | */ |
| | | getModels = () => { |
| | | const { execAction } = this.state |
| | | |