king
2019-11-28 213c70792e6af7f9ccef17d778c5f8806fbd513c
src/tabviews/commontable/mainAction/index.jsx
@@ -6,7 +6,7 @@
import Api from '@/api'
import './index.scss'
const { confirm } = Modal
// const { confirm } = Modal
class MainAction extends Component {
  static propTpyes = {
@@ -28,76 +28,77 @@
    this.props.refreshdata()
  }
  actionTrigger = (item) => {
    let _this = this
    // let _this = this
    let data = this.props.gettableselected() || []
    if (item.Ot === 'required' && data.length === 0) {
      // 需要选择行时,校验数据
      notification.warning({
        top: 92,
        message: this.props.dict['main.action.confirm.selectline']
      })
      return
    } else if (item.Ot === 'pop' && data.length !== 1) {
      if (data.length === 0) {
        // 需要选择行时,校验数据
        notification.warning({
          top: 92,
          message: this.props.dict['main.action.confirm.selectline']
        })
        return
      } else {
        // 需要选择单行时,校验数据
        notification.warning({
          top: 92,
          message: this.props.dict['main.action.confirm.selectSingleLine']
        })
        return
      }
    }
    console.log(data)
    // if (item.Ot === 'required' && data.length === 0) {
    //   // 需要选择行时,校验数据
    //   notification.warning({
    //     top: 92,
    //     message: this.props.dict['main.action.confirm.selectline']
    //   })
    //   return
    // } else if (item.Ot === 'pop' && data.length !== 1) {
    //   if (data.length === 0) {
    //     // 需要选择行时,校验数据
    //     notification.warning({
    //       top: 92,
    //       message: this.props.dict['main.action.confirm.selectline']
    //     })
    //     return
    //   } else {
    //     // 需要选择单行时,校验数据
    //     notification.warning({
    //       top: 92,
    //       message: this.props.dict['main.action.confirm.selectSingleLine']
    //     })
    //     return
    //   }
    // }
    if (item.Action === 'Prompt' || item.Action === 'Delete') {
      confirm({
        title: this.props.dict['main.action.confirm.tip'],
        onOk() {
          return Api.setActionSubmit({
            func: 'SetActionSubmitSuccess'
            // func: 'SetActionSubmitError'
          }).then((res) => {
            if (res.status) {
              notification.success({
                top: 92,
                message: _this.props.dict['main.action.confirm.success']
                // duration: 0
                // description:
              })
              _this.refreshdata()
            } else {
              notification.error({
                top: 92,
                message: res.message
              })
            }
          })
        },
        onCancel() {}
      })
    } else if (item.Action === 'Update') {
      Api.getModelFormData(item.MenuID).then(res => {
        if (res.status) {
          this.setState({
            formdata: res.data.map(input => {
              let validate = input.Validate && JSON.parse(input.Validate)
              input.DynOptions = JSON.parse(input.DynOptions)
              input.required = (validate && validate.required) || false
              return input
            }),
            visible: true,
            execAction: item,
            tabledata: data[0]
          })
        }
      })
    }
    // if (item.Action === 'Prompt' || item.Action === 'Delete') {
    //   confirm({
    //     title: this.props.dict['main.action.confirm.tip'],
    //     onOk() {
    //       return Api.setActionSubmit({
    //         func: 'SetActionSubmitSuccess'
    //         // func: 'SetActionSubmitError'
    //       }).then((res) => {
    //         if (res.status) {
    //           notification.success({
    //             top: 92,
    //             message: _this.props.dict['main.action.confirm.success']
    //             // duration: 0
    //             // description:
    //           })
    //           _this.refreshdata()
    //         } else {
    //           notification.error({
    //             top: 92,
    //             message: res.message
    //           })
    //         }
    //       })
    //     },
    //     onCancel() {}
    //   })
    // } else if (item.Action === 'Update') {
    //   Api.getModelFormData(item.MenuID).then(res => {
    //     if (res.status) {
    //       this.setState({
    //         formdata: res.data.map(input => {
    //           let validate = input.Validate && JSON.parse(input.Validate)
    //           input.DynOptions = JSON.parse(input.DynOptions)
    //           input.required = (validate && validate.required) || false
    //           return input
    //         }),
    //         visible: true,
    //         execAction: item,
    //         tabledata: data[0]
    //       })
    //     }
    //   })
    // }
  }
  getModels = () => {