king
2025-05-23 24842b40de5cd60700bf69dfd38a0332f5431e36
src/tabviews/zshare/actionList/funcMegvii/index.jsx
@@ -7,7 +7,7 @@
import NApi from '@/api'
import Utils from '@/utils/utils.js'
import Api from '@/api/w4k.js'
import Api from '@/api/direct.js'
import MKEmitter from '@/utils/events.js'
import MkIcon from '@/components/mk-icon'
@@ -34,20 +34,11 @@
  }
  UNSAFE_componentWillMount () {
    const { btn, selectedData } = this.props
    let disabled = false
    const { btn, selectedData, BData, disabled } = this.props
    if (btn.controlField && selectedData && selectedData.length > 0) { // 表格中按钮隐藏控制
      selectedData.forEach(item => {
        let s = item[btn.controlField] !== undefined ? item[btn.controlField] + '' : ''
        if (btn.controlVals.includes(s)) {
          disabled = true
        }
      })
      this.setState({hidden: disabled && btn.control === 'hidden'})
    }
    if (this.props.disabled || disabled) {
    if (btn.controlField) {
      this.setStatus(btn, selectedData || [], BData, disabled)
    } else if (disabled) {
      this.setState({disabled: true})
    }
  }
@@ -57,25 +48,12 @@
  }
  UNSAFE_componentWillReceiveProps (nextProps) {
    const { btn, selectedData } = this.props
    const { btn } = this.props
    let disabled = false
    if (btn.controlField && !is(fromJS(nextProps.selectedData || []), fromJS(selectedData || []))) {
      if (nextProps.selectedData && nextProps.selectedData.length > 0) { // 表格中按钮隐藏控制
        nextProps.selectedData.forEach(item => {
          let s = item[btn.controlField] !== undefined ? item[btn.controlField] + '' : ''
          if (btn.controlVals.includes(s)) {
            disabled = true
          }
        })
      }
      this.setState({hidden: disabled && btn.control === 'hidden'})
    }
    if (nextProps.disabled || disabled) {
      this.setState({disabled: true})
    if (btn.controlField) {
      this.setStatus(btn, nextProps.selectedData || [], nextProps.BData, nextProps.disabled)
    } else {
      this.setState({disabled: false})
      this.setState({disabled: nextProps.disabled === true})
    }
  }
@@ -90,61 +68,95 @@
    MKEmitter.removeListener('triggerBtnId', this.actionTrigger)
  }
  setStatus = (btn, data, BData, disprop) => {
    let disabled = false
    let hidden = false
    if (btn.control !== 'parent') {
      if (data.length > 0) {
        data.forEach(item => {
          let s = item[btn.controlField] !== undefined ? item[btn.controlField] + '' : ''
          if (btn.controlVals.includes(s)) {
            disabled = true
          }
        })
      } else if (btn.controlVals.includes('')) {
        disabled = true
      }
    } else {
      if (!BData || !BData.hasOwnProperty(btn.controlField)) {
        hidden = true
      } else {
        let s = BData[btn.controlField] + ''
        if (btn.controlVals.includes(s)) {
          hidden = true
        }
      }
    }
    if (disabled && btn.control === 'hidden') {
      hidden = true
    }
    if (disprop) {
      disabled = true
    }
    this.setState({hidden, disabled})
  }
  /**
   * @description 触发按钮操作
   */
  actionTrigger = (triggerId, record, type) => {
    const { BID, btn, selectedData, setting } = this.props
  actionTrigger = (triggerId, record, type, lid) => {
    const { BID, btn, selectedData, setting, LID } = this.props
    const { loading, disabled } = this.state
    if (loading || disabled) return
    if (triggerId && btn.uuid !== triggerId) return
    if (type === 'linkbtn' && !btn.$toolbtn && LID !== lid) return
    let data = record || selectedData || []
    // let data = fromJS(mockdata.data).toJS()
    if (setting.supModule && !BID) {
      notification.warning({
        top: 92,
        message: '需要上级主键值!',
        message: setting.supModTip || '需要上级主键值!',
        duration: 5
      })
      return
    } else if (type === 'linkbtn' && !btn.$toolbtn && !is(fromJS(selectedData || []), fromJS(record))) {
      return
    }
    let data = record || selectedData || []
    // let data = fromJS(mockdata.data).toJS()
    if (data.length === 0) {
    } else if (data.length === 0) {
      // 需要选择行时,校验数据
      notification.warning({
        top: 92,
        message: '请选择行!',
        duration: 5
      })
      return
    } else {
      this.setState({
        loading: true,
        lines: data
      })
      this.getIpList()
    }
    this.setState({
      loading: true,
      lines: data
    })
    this.getIpList()
  }
  getIpList = () => {
    let _scriptSql = `select ID,data_code,data_name,Remark,face_ip,face_uname,face_pwd from bd_data where typecharone='face_device'  and deleted=0`
    _scriptSql = Utils.formatOptions(_scriptSql)
    let _sParam = {
      func: 'sPC_Get_SelectedList',
      LText: _scriptSql,
      obj_name: 'data',
      arr_field: 'ID,data_code,data_name,Remark,face_ip,face_uname,face_pwd'
    }
    if (window.GLOB.execType === 'x') {
      _sParam.exec_type = 'x'
    }
    
    _sParam.LText = Utils.formatOptions(_scriptSql, _sParam.exec_type)
    _sParam.timestamp = moment().format('YYYY-MM-DD HH:mm:ss')
    _sParam.secretkey = Utils.encrypt(_sParam.LText, _sParam.timestamp)
    _sParam.secretkey = Utils.encrypt(window.GLOB.execType === 'x' ? '' : _sParam.LText, _sParam.timestamp)
    
    NApi.getSystemCacheConfig(_sParam).then(res => {
      if (res.status) {
@@ -194,7 +206,7 @@
    // let ip = 'http://localhost:3001'
    let ip = selectIp.face_ip
    Api.login(ip, selectIp.face_uname, selectIp.face_pwd).then(result => {
    Api.w4kLogin(ip, selectIp.face_uname, selectIp.face_pwd).then(result => {
      if (result.errors) {
        this.execPreError(result)
        return
@@ -202,7 +214,7 @@
      document.cookie = 'sessionID=' + result.session_id
      Api.queryUsers(ip).then(res => {
      Api.w4kQueryUsers(ip).then(res => {
        if (res.errors) {
          this.execPreError(res)
          return
@@ -277,7 +289,7 @@
    }
    if (error) {
      this.execError({ErrCode: 'E', ErrMesg: error})
      this.execError({ErrCode: 'E', message: error})
      return
    }
@@ -289,7 +301,7 @@
      data.id_number = CryptoJS.enc.Base64.stringify(encrypted.ciphertext)
    }
    Api.addUsers(ip, data).then(res => {
    Api.w4kAddUsers(ip, data).then(res => {
      if (res.errors) {
        this.execPreError(res, data)
        return
@@ -297,7 +309,7 @@
      if (datas.length > 0) {
        this.addUser(ip, datas, sessionId)
      } else {
        this.execSuccess({ErrCode: 'S', ErrMesg: '执行成功。'})
        this.execSuccess({ErrCode: 'S', message: '执行成功。'})
      }
    }, (err) => {
      this.execPreError(err, data)
@@ -312,18 +324,18 @@
   * 4、模态框执行成功后是否关闭
   * 5、通知主列表刷新
   */
  execSuccess = (res) => {
  execSuccess = (res = {}) => {
    const { btn } = this.props
    if (res && (res.ErrCode === 'S' || !res.ErrCode)) { // 执行成功
    if (res.ErrCode === 'S' || !res.ErrCode) { // 执行成功
      notification.success({
        top: 92,
        message: res.ErrMesg || '执行成功',
        message: res.message || '执行成功',
        duration: btn.verify && btn.verify.stime ? btn.verify.stime : 2
      })
    } else if (res && res.ErrCode === 'Y') { // 执行成功
      Modal.success({
        title: res.ErrMesg || '执行成功'
        title: res.message || '执行成功'
      })
    } else if (res && res.ErrCode === '-1') { // 完成后不提示
@@ -394,23 +406,23 @@
    if (res.ErrCode === 'E') {
      Modal.error({
        title: res.message || res.ErrMesg,
        title: res.message || '执行失败!',
      })
    } else if (res.ErrCode === 'N') {
      notification.error({
        top: 92,
        message: res.message || res.ErrMesg,
        message: res.message || '执行失败!',
        duration: btn.verify && btn.verify.ntime ? btn.verify.ntime : 10
      })
    } else if (res.ErrCode === 'F') {
      notification.error({
        className: 'notification-custom-error',
        top: 92,
        message: res.message || res.ErrMesg,
        message: res.message || '执行失败!',
        duration: btn.verify && btn.verify.ftime ? btn.verify.ftime : 10
      })
    } else if (res.ErrCode === 'NM') {
      message.error(res.message || res.ErrMesg)
      message.error(res.message || '执行失败!')
    }
    
    this.setState({
@@ -497,43 +509,26 @@
    if (hidden) return null
    let label = ''
    let icon = ''
    let type = 'link'
    let className = ''
    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 = ''
    if (btn.show === 'link') {
      label = <span>{btn.label}{btn.icon ? <MkIcon style={{marginLeft: '8px'}} type={btn.icon} /> : ''}</span>
    } else if (btn.show === 'icon') {
      icon = btn.icon || ''
    } else if (!btn.$toolbtn) {
      icon = btn.icon || ''
      label = btn.label
      className = 'mk-btn mk-' + btn.class
      label = !loading ? <MkIcon type={btn.icon} /> : null
    } else if (btn.$toolbtn) {
      label = <span>{!loading && btn.icon ? <MkIcon style={{marginRight: '8px'}} type={btn.icon} /> : ''}{loadingNumber && !loadingTotal ? `(${loadingNumber})` : ''}{btn.label}</span>
    } 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
      label = <span>{!loading && btn.icon ? <MkIcon style={{marginRight: '8px'}} type={btn.icon} /> : ''}{btn.label}</span>
    }
    return (
      <>
        <Button
          type={type}
          type="link"
          title={disabled ? (btn.reason || '') : (btn.show === 'icon' ? btn.label : '')}
          loading={loading}
          disabled={disabled}
          style={btn.style}
          icon={icon}
          className={className}
          className={btn.hover || ''}
          onClick={(e) => {e.stopPropagation(); this.actionTrigger()}}
        >{label}</Button>
        {this.getModels()}