king
2019-12-26 e47f5f999cb20283ad99c00c5e771d44501cf3c9
src/tabviews/tableshare/actionList/index.jsx
@@ -1,7 +1,7 @@
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'
@@ -30,14 +30,13 @@
    configMap: {}
  }
  UNSAFE_componentWillMount() {
    console.log(this.props.type)
  }
  refreshdata = (item, type) => {
    this.props.refreshdata(item, type)
  }
  
  /**
   * @description 触发按钮操作
   */
  actionTrigger = (item, record) => {
    const { setting } = this.props
@@ -181,7 +180,7 @@
        Api.genericInterface(param).then((res) => {
          if (res.status) {
            this.execSuccess(btn)
            this.execSuccess(btn, res)
          } else {
            this.execError(res, btn)
          }
@@ -236,21 +235,16 @@
          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()
        })
@@ -333,7 +327,7 @@
              response.func = btn.callbackFunc
              return Api.genericInterface(response)
            } else {
              this.execSuccess(btn)
              this.execSuccess(btn, response)
              _resolve()
            }
          } else {
@@ -344,7 +338,7 @@
          if (!res) return
  
          if (res.status) {
            this.execSuccess(btn)
            this.execSuccess(btn, res)
          } else {
            this.execError(res, btn)
          }
@@ -429,16 +423,13 @@
          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
          }
@@ -461,7 +452,7 @@
            return Promise.all(deffers)
          } else {
            _resolve()
            this.execSuccess(btn)
            this.execSuccess(btn, errorMsg)
          }
        }).then(result => {
          if (!result) return
@@ -471,19 +462,16 @@
          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()
        })
@@ -501,17 +489,27 @@
    }
  }
  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') {
@@ -522,17 +520,32 @@
    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') {
@@ -544,6 +557,9 @@
    this.refreshdata(btn, 'error')
  }
  /**
   * @description 按钮配置信息错误提示
   */
  actionSettingError = () => {
    notification.warning({
      top: 92,
@@ -552,6 +568,9 @@
    })
  }
  /**
   * @description 获取按钮配置信息
   */
  improveAction = (action) => {
    const { configMap, execAction } = this.state
@@ -613,6 +632,9 @@
    }
  }
  /**
   * @description 获取下拉表单选项信息
   */
  improveActionForm = () => {
    const { configMap, execAction } = this.state
    let subfields = []
@@ -710,6 +732,9 @@
    })
  }
  /**
   * @description 模态框(表单),确认
   */
  handleOk = () => {
    this.formRef.handleConfirm().then(res => {
      this.setState({
@@ -723,12 +748,18 @@
    }, () => {})
  }
  /**
   * @description 模态框(表单),取消
   */
  handleCancel = () => {
    this.setState({
      visible: false
    })
  }
  /**
   * @description 显示模态框
   */
  getModels = () => {
    const { execAction } = this.state