| | |
| | | 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')) |
| | |
| | | disabled: false, |
| | | hidden: false, |
| | | autoMatic: false, |
| | | check: false |
| | | check: false, |
| | | count: 0 |
| | | } |
| | | |
| | | moduleParams = null |
| | |
| | | |
| | | 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 || [] |
| | |
| | | |
| | | 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 || [] |
| | |
| | | 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') { |
| | |
| | | } |
| | | |
| | | 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 || '执行成功!' |
| | |
| | | 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}) |
| | | } |
| | |
| | | } |
| | | } |
| | | |
| | | 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 { |