king
2023-06-22 79e4981aa6cc9354276fc54cdf6d14eb08ab7fee
src/tabviews/zshare/actionList/normalbutton/index.jsx
@@ -1,6 +1,7 @@
import React, {Component} from 'react'
import PropTypes from 'prop-types'
import moment from 'moment'
import qs from 'qs'
import { is, fromJS } from 'immutable'
import { Button, Modal, notification, message, Drawer, Switch, Checkbox, Progress } from 'antd'
@@ -61,7 +62,7 @@
    
    if (btn.OpenType === 'form') {
      let data = selectedData && selectedData[0] ? selectedData[0] : null
      if (btn.formType === 'counter') {
      if (btn.formType === 'counter' || btn.formType === 'count_line') {
        let count = 0
        if (data && data[btn.field]) {
          count = +data[btn.field]
@@ -108,7 +109,7 @@
    if (btn.OpenType === 'form') {
      let data = nextProps.selectedData && nextProps.selectedData[0] ? nextProps.selectedData[0] : null
      if (btn.formType === 'counter') {
      if (btn.formType === 'counter' || btn.formType === 'count_line') {
        let count = 0
        if (data && data[btn.field]) {
          count = +data[btn.field]
@@ -329,6 +330,9 @@
        return
      }
    } else if (!['inner', 'outer', 'system', 'custom'].includes(btn.intertype)) {
      if (btn.OpenType === 'form' && btn.formType === 'count_line') {
        return
      }
      // 接口类型错误
      notification.warning({
        top: 92,
@@ -744,8 +748,10 @@
    let _params = []
    if ( btn.Ot === 'notRequired' || btn.Ot === 'requiredSgl' || btn.Ot === 'requiredOnce' ) {
      let param = {
        func: btn.innerFunc || ''
      let param = {}
      if (btn.innerFunc) {
        param.func = btn.innerFunc
      }
      if (this.props.BID) {
@@ -758,9 +764,7 @@
        let ids = data.map(d => { return d[setting.primaryKey] || ''})
        ids = ids.filter(Boolean)
        primaryId = ids.join(',')
      }
      if (setting.primaryKey) {
        param[setting.primaryKey] = primaryId // 设置主键参数
      }
@@ -1269,7 +1273,46 @@
      param[key] = result[key]
    })
    Api.directRequest(url, btn.method, param, btn.cross).then(res => {
    let _params = {
      url: url,
      method: btn.method || 'post'
    }
    if (btn.cross === 'true') {
      if (JSON.stringify(param) !== '{}') {
        if (btn.stringify === 'qs') {
          _params.data = qs.stringify(param)
        } else if (btn.stringify === 'JSON') {
          _params.data = param
        } else {
          _params.data = JSON.stringify(param)
        }
      }
    } else {
      let _url = url
      if (JSON.stringify(param) !== '{}') {
        if (_params.method === 'get') {
          let keys = Object.keys(param).map(key => `${key}=${param[key]}`)
          _url = _url + '?' + keys.join('&')
        } else if (_params.method === 'post') {
          if (btn.stringify === 'qs') {
            _params.data = qs.stringify(param)
          } else if (btn.stringify === 'JSON') {
            _params.data = param
          } else {
            _params.data = JSON.stringify(param)
          }
        }
      }
      _url = _url.replace(/&/ig, '%26')
      _params.url = '/trans/redirect?rd=' + _url + '&method=' + _params.method
      _params.method = 'post'
    }
    Api.directRequest(_params).then(res => {
      if (typeof(res) !== 'object') {
        let error = '未知的返回结果!'
@@ -2050,7 +2093,17 @@
      MKEmitter.emit('refreshDebugTable')
    }
    
    btn.syncComponentId && MKEmitter.emit('reloadData', btn.syncComponentId)
    if (btn.syncComponentId) {
      if (btn.syncComponentId === 'multiComponent') {
        btn.syncComponentIds.forEach((id, i) => {
          setTimeout(() => {
            MKEmitter.emit('reloadData', id)
          }, 20 * i)
        })
      } else {
        MKEmitter.emit('reloadData', btn.syncComponentId)
      }
    }
    if (tabId) {
      MKEmitter.emit('reloadMenuView', tabId, 'table')
@@ -2212,7 +2265,7 @@
        if (!res.oa_access_token) return
  
        params.forEach(n => {
          Api.wxNginxRequest(`${domain2}cgi-bin/message/template/send?access_token=${res.oa_access_token}`, 'post', n).then(re => {
          Api.wxNginxRequest(`${domain2}cgi-bin/message/template/send?access_token=${res.oa_access_token}`, 'post', JSON.stringify(n)).then(re => {
            if (verify.wxNoteCallback === 'true') {
              let msg = re.errmsg || ''
@@ -2869,6 +2922,37 @@
    })
  }
  changeLineCount = (count) => {
    const { btn, selectedData } = this.props
    const { disabled } = this.state
    if (disabled) return
    let data = selectedData || []
    if (data.length === 0) {
      // 需要选择行时,校验数据
      notification.warning({
        top: 92,
        message: this.state.dict['main.action.confirm.selectline'],
        duration: 5
      })
      return
    } else if (data.length !== 1) {
      // 需要选择单行时,校验数据
      notification.warning({
        top: 92,
        message: this.state.dict['main.action.confirm.selectSingleLine'],
        duration: 5
      })
      return
    }
    this.setState({count}, () => {
      MKEmitter.emit('refreshLineData', btn.$menuId, btn, data[0].$$uuid, count)
    })
  }
  render() {
    const { btn } = this.props
    const { loadingNumber, loadingTotal, loading, disabled, hidden, check, count } = this.state
@@ -2879,6 +2963,8 @@
        return <Switch loading={loading} checked={check} disabled={disabled || loading} title={disabled ? (btn.reason || '') : ''} onChange={(val,e) => {e.stopPropagation();this.actionTrigger()}} style={btn.style} className={btn.size === 'large' ? 'ant-switch-large' : ''} size={btn.size} checkedChildren={btn.openText || ''} unCheckedChildren={btn.closeText || ''}/>
      } else if (btn.formType === 'counter') {
        return <MkCounter count={count} disabled={disabled} btn={btn} onChange={this.changeCount}/>
      } else if (btn.formType === 'count_line') {
        return <MkCounter count={count} disabled={disabled} btn={btn} onChange={this.changeLineCount}/>
      } else if (btn.formType === 'radio') {
        return <Checkbox className={btn.checkType || ''} disabled={disabled || loading} title={disabled ? (btn.reason || '') : ''} checked={check} onChange={(e) => {e.stopPropagation();this.actionTrigger()}} style={btn.style}></Checkbox>
      } else {