From bd1dfc9e6c9b9f8076ca2783ce598e0936b4c664 Mon Sep 17 00:00:00 2001 From: king <18310653075@163.com> Date: 星期三, 22 十二月 2021 14:36:03 +0800 Subject: [PATCH] 2021-12-22 --- src/tabviews/zshare/actionList/normalbutton/index.jsx | 101 ++++++++++++++++++++++++++++++++------------------ 1 files changed, 65 insertions(+), 36 deletions(-) diff --git a/src/tabviews/zshare/actionList/normalbutton/index.jsx b/src/tabviews/zshare/actionList/normalbutton/index.jsx index b811fe8..ba6f77f 100644 --- a/src/tabviews/zshare/actionList/normalbutton/index.jsx +++ b/src/tabviews/zshare/actionList/normalbutton/index.jsx @@ -3,7 +3,7 @@ import moment from 'moment' import {connect} from 'react-redux' import { is, fromJS } from 'immutable' -import { Button, Modal, notification, message, Drawer, Icon } from 'antd' +import { Button, Modal, notification, message, Drawer } from 'antd' import Api from '@/api' import Utils, { getSysDefaultSql } from '@/utils/utils.js' @@ -13,6 +13,7 @@ import asyncSpinComponent from '@/utils/asyncSpinComponent' import { updateForm } from '@/utils/utils-update.js' import MKEmitter from '@/utils/events.js' +import MkIcon from '@/components/mk-icon' // import './index.scss' const MutilForm = asyncSpinComponent(() => import('@/tabviews/zshare/mutilform')) @@ -37,12 +38,13 @@ dict: sessionStorage.getItem('lang') !== 'en-US' ? zhCN : enUS, visible: false, formdata: null, - tabledata: null, + selines: null, confirmLoading: false, btnconfig: null, loading: false, loadingNumber: '', disabled: false, + hidden: false, checkParam: null, autoMatic: false } @@ -60,7 +62,7 @@ disabled = true } }) - this.setState({disabled}) + this.setState({disabled, hidden: disabled && btn.control === 'hidden'}) } } @@ -96,7 +98,7 @@ } }) } - this.setState({disabled}) + this.setState({disabled, hidden: disabled && btn.control === 'hidden'}) } } @@ -125,7 +127,7 @@ this.setState({ loading: true }) - this.execSubmit(this.state.tabledata, () => {}, res.form) + this.execSubmit(this.state.selines, () => {}, res.form) } resetModuleParam = (menuId, btnId, param) => { @@ -244,10 +246,11 @@ return } + this.setState({ + selines: data + }) + if (btn.OpenType === 'formSubmit') { - this.setState({ - tabledata: data - }) MKEmitter.emit('mkFormSubmit', btn.uuid) return } else if (btn.OpenType === 'prompt') { @@ -274,7 +277,6 @@ this.setState({ loading: true, - tabledata: data, btnconfig: modal }, () => { this.improveAction() @@ -1412,8 +1414,10 @@ if (btn.execSuccess === 'closetab') { MKEmitter.emit('closeTabView', btn.$MenuID) + } else if (btn.execSuccess === 'closepoptab') { + MKEmitter.emit('popclose') } else if (btn.execSuccess !== 'never') { - MKEmitter.emit('refreshByButtonResult', btn.$menuId, btn.execSuccess, btn, id) + MKEmitter.emit('refreshByButtonResult', btn.$menuId, btn.execSuccess, btn, id, this.state.selines) } if (btn.refreshTab && btn.refreshTab.length > 0) { @@ -1627,7 +1631,7 @@ visible: false }) if (btn.execError !== 'never') { - MKEmitter.emit('refreshByButtonResult', btn.$menuId, btn.execError, btn) + MKEmitter.emit('refreshByButtonResult', btn.$menuId, btn.execError, btn, '', this.state.selines) } } }) @@ -1644,8 +1648,10 @@ MKEmitter.emit('mkFC', 'focus', btnconfig.setting.errFocus) } - if (btn.execError !== 'never') { - MKEmitter.emit('refreshByButtonResult', btn.$menuId, btn.execError, btn) + if (btn.execError === 'closepoptab') { + MKEmitter.emit('popclose') + } else if (btn.execError !== 'never') { + MKEmitter.emit('refreshByButtonResult', btn.$menuId, btn.execError, btn, '', this.state.selines) } } @@ -1691,7 +1697,7 @@ const { btnconfig, autoMatic } = this.state if (btnconfig) { - if (!autoMatic && btnconfig.setting.display === 'prompt') { // 濡傛灉琛ㄥ崟浠ユ槸鍚︽灞曠ず + if (!autoMatic && (btnconfig.setting.display === 'prompt' || btnconfig.setting.display === 'exec')) { // 濡傛灉琛ㄥ崟浠ユ槸鍚︽灞曠ず this.modelconfirm() } else { this.setState({ @@ -1735,7 +1741,7 @@ this.setState({ btnconfig: _LongParam }, () => { - if (!autoMatic && _LongParam.setting.display === 'prompt') { // 濡傛灉琛ㄥ崟浠ユ槸鍚︽灞曠ず + if (!autoMatic && (_LongParam.setting.display === 'prompt' || _LongParam.setting.display === 'exec')) { // 濡傛灉琛ㄥ崟浠ユ槸鍚︽灞曠ず this.modelconfirm() } else { this.setState({ @@ -1756,7 +1762,7 @@ this.formRef.handleConfirm().then(res => { this.setState({ confirmLoading: true }) - this.execSubmit(this.state.tabledata, () => { this.setState({ confirmLoading: false }) }, res) + this.execSubmit(this.state.selines, () => { this.setState({ confirmLoading: false }) }, res) }) } @@ -1773,7 +1779,7 @@ modelconfirm = () => { const { BData } = this.props - const { btnconfig, tabledata } = this.state + const { btnconfig, selines } = this.state let _this = this let result = [] @@ -1788,8 +1794,8 @@ if (item.type === 'linkMain' && BData && BData.hasOwnProperty(item.field)) { _initval = BData[item.field] - } else if (_readin && tabledata[0] && tabledata[0].hasOwnProperty(item.field)) { - _initval = tabledata[0][item.field] + } else if (_readin && selines[0] && selines[0].hasOwnProperty(item.field)) { + _initval = selines[0][item.field] } else if (item.type === 'date' && _initval) { _initval = moment().subtract(_initval, 'days').format('YYYY-MM-DD') } else if (item.type === 'datemonth' && _initval) { @@ -1813,6 +1819,24 @@ if (['date', 'datemonth', 'datetime'].includes(_type) && item.declareType === 'nvarchar(50)') { _type = 'text' + } else if (item.type === 'rate') { + item.rateCount = item.rateCount || 5 + let allowHalf = item.allowHalf === 'true' + + if (allowHalf) { + _initval = parseFloat(_initval) + if (_initval % 0.5 !== 0) { + _initval = parseInt(_initval) + } + } else { + _initval = parseInt(_initval) + } + + if (isNaN(_initval) || _initval < 0) { + _initval = 0 + } else if (_initval > item.rateCount) { + _initval = item.rateCount + } } result.push({ @@ -1826,17 +1850,21 @@ }) }) - confirm({ - title: this.state.dict['main.action.confirm.tip'], - onOk() { - return new Promise(resolve => { - _this.execSubmit(tabledata, resolve, result) - }) - }, - onCancel() { - _this.setState({ loading: false }) - } - }) + if (btnconfig.setting.display === 'exec') { + this.execSubmit(selines, () => {}, result) + } else { + confirm({ + title: this.state.dict['main.action.confirm.tip'], + onOk() { + return new Promise(resolve => { + _this.execSubmit(selines, resolve, result) + }) + }, + onCancel() { + _this.setState({ loading: false }) + } + }) + } } /** @@ -1876,11 +1904,11 @@ menuType={this.props.menuType} action={btnconfig} inputSubmit={this.handleOk} - data={this.state.tabledata[0]} + data={this.state.selines[0]} BData={BData} wrappedComponentRef={(inst) => this.formRef = inst} /> - <div style={{ position: 'absolute', zIndex: 1, right: 0, bottom: 0, width: '100%', borderTop: '1px solid #e9e9e9', padding: '10px 16px', background: '#fff', textAlign: 'right'}}> + <div className="ant-drawer-footer" style={{ position: 'absolute', zIndex: 1, right: 0, bottom: 0, width: '100%', borderTop: '1px solid #e9e9e9', padding: '10px 16px', background: '#fff', textAlign: 'right'}}> <Button onClick={this.handleCancel} style={{ marginRight: 8 }}> {btnconfig.setting.formType !== 'check' ? '鍙栨秷' : '鍏抽棴'} </Button> @@ -1919,7 +1947,7 @@ menuType={this.props.menuType} action={btnconfig} inputSubmit={this.handleOk} - data={this.state.tabledata[0]} + data={this.state.selines[0]} BData={BData} wrappedComponentRef={(inst) => this.formRef = inst} /> @@ -1930,7 +1958,9 @@ render() { const { btn, show, style } = this.props - const { loadingNumber, loading, disabled } = this.state + const { loadingNumber, loading, disabled, hidden } = this.state + + if (hidden) return null if (show === 'actionList') { return <div style={{display: 'inline-block'}} onClick={(e) => e.stopPropagation()}> @@ -1963,11 +1993,10 @@ label = btn.label icon = btn.icon || '' } else if (show === 'link') { - label = <span>{btn.label}{btn.icon ? <Icon style={{marginLeft: '8px'}} type={btn.icon}/> : ''}</span> + label = <span>{btn.label}{btn.icon ? <MkIcon style={{marginLeft: '8px'}} type={btn.icon}/> : ''}</span> icon = '' } else if (show === 'icon') { icon = btn.icon || '' - // } else if (show === 'text') { } else { label = btn.label } -- Gitblit v1.8.0