king
2023-03-11 642b103206a54923a460ee36550f275b22d6f09c
src/tabviews/zshare/actionList/normalbutton/index.jsx
@@ -13,6 +13,7 @@
import { updateForm } from '@/utils/utils-update.js'
import MKEmitter from '@/utils/events.js'
import MkIcon from '@/components/mk-icon'
import MkCounter from './mkcounter'
// import './index.scss'
const MutilForm = asyncSpinComponent(() => import('@/tabviews/zshare/mutilform'))
@@ -43,7 +44,8 @@
    disabled: false,
    hidden: false,
    autoMatic: false,
    check: false
    check: false,
    count: 0
  }
  moduleParams = null
@@ -59,7 +61,18 @@
    
    if (btn.OpenType === 'form') {
      let data = selectedData && selectedData[0] ? selectedData[0] : null
      this.setState({check: data && data[btn.field] === btn.openVal})
      if (btn.formType === 'counter') {
        let count = 0
        if (data && data[btn.field]) {
          count = +data[btn.field]
          if (isNaN(count)) {
            count = 0
          }
        }
        this.setState({count: count })
      } else {
        this.setState({check: data && data[btn.field] === btn.openVal})
      }
    } else if (btn.OpenType === 'formSubmit') {
      this.setState({
        selines: selectedData || []
@@ -95,7 +108,18 @@
    if (btn.OpenType === 'form') {
      let data = nextProps.selectedData && nextProps.selectedData[0] ? nextProps.selectedData[0] : null
      this.setState({check: data && data[btn.field] === btn.openVal})
      if (btn.formType === 'counter') {
        let count = 0
        if (data && data[btn.field]) {
          count = +data[btn.field]
          if (isNaN(count)) {
            count = 0
          }
        }
        this.setState({count: count })
      } else {
        this.setState({check: data && data[btn.field] === btn.openVal})
      }
    } else if (btn.OpenType === 'formSubmit') {
      this.setState({
        selines: nextProps.selectedData || []
@@ -352,29 +376,41 @@
        this.improveAction()
      })
    } else if (btn.OpenType === 'form') {
      this.setState({
        loading: true,
        check: !this.state.check
      }, () => {
        let type = 'text'
        let fieldlen = 50
        let value = this.state.check ? btn.openVal : btn.closeVal
        if (typeof(value) === 'number') {
          type = 'number'
          fieldlen = 0
        }
      if (btn.formType === 'counter') {
        let item = {
          type: type,
          type: 'number',
          readin: true,
          writein: true,
          fieldlen: fieldlen,
          fieldlen: btn.decimal || 0,
          key: btn.field,
          value: value
          value: this.state.count
        }
        this.execSubmit(data, () => { this.setState({loading: false})}, [item])
      })
        this.execSubmit(data, () => {}, [item])
      } else {
        this.setState({
          loading: true,
          check: !this.state.check
        }, () => {
          let type = 'text'
          let fieldlen = 50
          let value = this.state.check ? btn.openVal : btn.closeVal
          if (typeof(value) === 'number') {
            type = 'number'
            fieldlen = 0
          }
          let item = {
            type: type,
            readin: true,
            writein: true,
            fieldlen: fieldlen,
            key: btn.field,
            value: value
          }
          this.execSubmit(data, () => { this.setState({loading: false})}, [item])
        })
      }
    }
    if (window.GLOB.systemType === 'production') {
@@ -1944,11 +1980,13 @@
    }
    if ((res.ErrCode === 'S' || !res.ErrCode) || autoMatic) { // 执行成功
      notification.success({
        top: 92,
        message: res.message || '执行成功!',
        duration: btn.verify && btn.verify.stime ? btn.verify.stime : 2
      })
      if (btn.formType !== 'counter' || res.message) {
        notification.success({
          top: 92,
          message: res.message || '执行成功!',
          duration: btn.verify && btn.verify.stime ? btn.verify.stime : 2
        })
      }
    } else if (res.ErrCode === 'Y') { // 执行成功
      Modal.success({
        title: res.message || '执行成功!'
@@ -2382,7 +2420,7 @@
      MKEmitter.emit('popclose')
    } else if (btn.execError !== 'never') {
      MKEmitter.emit('refreshByButtonResult', btn.$menuId, btn.execError, btn, '', this.state.selines)
    } else if (btn.OpenType === 'form') {
    } else if (btn.OpenType === 'form' && btn.formType !== 'counter') {
      let data = this.props.selectedData && this.props.selectedData[0] ? this.props.selectedData[0] : null
      this.setState({check: data && data[btn.field] === btn.openVal})
    }
@@ -2760,15 +2798,22 @@
    }
  }
  changeCount = (count) => {
    this.setState({count}, () => {
      this.actionTrigger()
    })
  }
  render() {
    const { btn } = this.props
    const { loadingNumber, loadingTotal, loading, disabled, hidden, check } = this.state
    const { loadingNumber, loadingTotal, loading, disabled, hidden, check, count } = this.state
    if (hidden) return null
    if (btn.OpenType === 'form') {
      if (btn.formType === 'switch') { 
        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 === '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 {