king
2022-08-02 8d66ff34fae5b048a6b7923cc75d34f13a08be9d
src/tabviews/zshare/actionList/funcMegvii/index.jsx
@@ -1,8 +1,7 @@
import React, {Component} from 'react'
import PropTypes from 'prop-types'
import { withRouter } from 'react-router'
import { is, fromJS } from 'immutable'
import { Button, Modal, notification, message } from 'antd'
import { Button, Modal, notification, message, Progress } from 'antd'
import CryptoJS from 'crypto-js'
import moment from 'moment'
@@ -26,6 +25,7 @@
    loading: false,
    disabled: false,
    loadingNumber: '',
    loadingTotal: '',
    hidden: false,
    IpList: [],
    lines: [],
@@ -98,12 +98,7 @@
    const { loading, disabled } = this.state
    if (loading || disabled) return
    if (triggerId) {
      if (btn.uuid !== triggerId) return
      if (this.props.lineId && record && record[0] && this.props.lineId !== record[0].$$key) {
        return
      }
    }
    if (triggerId && btn.uuid !== triggerId) return
    if (((Tab && Tab.supMenu) || setting.supModule) && !BID) {
      notification.warning({
@@ -112,10 +107,8 @@
        duration: 5
      })
      return
    } else if (type === 'linkbtn' && selectedData && selectedData.length === 1) {
      if (record[0].$Index !== selectedData[0].$Index) {
        return
      }
    } else if (type === 'linkbtn' && !btn.$toolbtn && !is(fromJS(selectedData || []), fromJS(record))) {
      return
    }
    let data = record || selectedData || []
@@ -135,7 +128,6 @@
      loading: true,
      lines: data
    })
    this.getIpList()
  }
@@ -195,6 +187,7 @@
  }
  loginDevice = () => {
    const { btn } = this.props
    const { lines, selectIp } = this.state
    // 上报接口设置:工程模式-场景模式-开放接口设置-数据上报设置-数据上报服务器地址(开启服务器二次鉴权)
@@ -244,6 +237,12 @@
          }
        })
        if (data.length > 1 && btn.progress === 'progressbar') {
          this.setState({
            loadingTotal: data.length
          })
        }
        this.addUser(ip, data, result.session_id)
      })
    }, err => {
@@ -255,7 +254,7 @@
    let data = datas.shift()
    this.setState({
      loadingNumber: datas.length || ''
      loadingNumber: datas.length
    })
    let error = ''
@@ -332,7 +331,8 @@
    this.setState({
      loading: false,
      loadingNumber: ''
      loadingNumber: '',
      loadingTotal: ''
    })
    
    // if (btn.execSuccess !== 'never') {
@@ -415,7 +415,8 @@
    
    this.setState({
      loading: false,
      loadingNumber: ''
      loadingNumber: '',
      loadingTotal: ''
    })
    // if (btn.execError !== 'never') {
@@ -490,57 +491,56 @@
  }
  render() {
    const { btn, show } = this.props
    const { loading, disabled, hidden, loadingNumber } = this.state
    const { btn } = this.props
    const { loading, disabled, hidden, loadingNumber, loadingTotal } = this.state
    if (hidden) return null
    if (show === 'actionList') {
      return (
        <>
          <Button
            icon={btn.icon}
            loading={loading}
            disabled={disabled}
            title={disabled ? (btn.reason || '') : ''}
            className={'mk-btn mk-' + btn.class}
            onClick={(e) => {e.stopPropagation(); this.actionTrigger()}}
          >{(loadingNumber ? `(${loadingNumber})` : '') + btn.label}</Button>
          {this.getModels()}
        </>
      )
    } else { // icon、text、 all 卡片
      let label = ''
      let icon = ''
    let label = ''
    let icon = ''
    let type = 'link'
    let className = ''
      if (show === 'button') {
        label = btn.label
        icon = btn.icon || ''
      } else if (show === 'link') {
        label = <span>{btn.label}{btn.icon ? <MkIcon style={{marginLeft: '8px'}} type={btn.icon}/> : ''}</span>
        icon = ''
      } else if (show === 'icon') {
        icon = btn.icon || ''
      } else {
        label = btn.label
      }
      return (
        <>
          <Button
            type="link"
            title={disabled ? (btn.reason || '') : (show === 'icon' ? btn.label : '')}
            loading={loading}
            disabled={disabled}
            style={btn.style}
            icon={icon}
            onClick={(e) => {e.stopPropagation(); this.actionTrigger()}}
          >{label}</Button>
          {this.getModels()}
        </>
      )
    if (btn.show === 'button') {
      label = btn.label
      icon = btn.icon || ''
    } else if (btn.show === 'link') {
      label = <span>{btn.label}{btn.icon ? <MkIcon style={{marginLeft: '8px'}} type={btn.icon}/> : ''}</span>
      icon = ''
    } else if (btn.show === 'icon') {
      icon = btn.icon || ''
    } else if (!btn.$toolbtn) {
      icon = btn.icon || ''
      label = btn.label
      className = 'mk-btn mk-' + btn.class
    } else {
      type = ''
      icon = btn.icon || ''
      label = btn.label
      className = 'mk-btn mk-' + btn.class
    }
    if (loadingNumber && !loadingTotal && btn.$toolbtn && (!btn.show || btn.show === 'button')) {
      label = (loadingNumber && !loadingTotal ? `(${loadingNumber})` : '') + btn.label
    }
    return (
      <>
        <Button
          type={type}
          title={disabled ? (btn.reason || '') : (btn.show === 'icon' ? btn.label : '')}
          loading={loading}
          disabled={disabled}
          style={btn.style}
          icon={icon}
          className={className}
          onClick={(e) => {e.stopPropagation(); this.actionTrigger()}}
        >{label}</Button>
        {this.getModels()}
        {loadingTotal ? <Progress className="mk-button-progress" percent={(loadingTotal - loadingNumber) / loadingTotal * 100} size="small" showInfo={false} /> : null}
      </>
    )
  }
}
export default withRouter(FuncButton)
export default FuncButton