From 6c66c9c2a6d0f7e7ccc65d4d9e478f1acb74d87e Mon Sep 17 00:00:00 2001 From: king <18310653075@163.com> Date: 星期五, 20 八月 2021 12:12:48 +0800 Subject: [PATCH] 2021-08-20 --- src/tabviews/zshare/actionList/excelInbutton/index.jsx | 70 ++++++++++++++++++++++++++++++---- 1 files changed, 61 insertions(+), 9 deletions(-) diff --git a/src/tabviews/zshare/actionList/excelInbutton/index.jsx b/src/tabviews/zshare/actionList/excelInbutton/index.jsx index 1312e0d..e943949 100644 --- a/src/tabviews/zshare/actionList/excelInbutton/index.jsx +++ b/src/tabviews/zshare/actionList/excelInbutton/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 } from 'antd' +import { Button, Modal, notification, message, Icon } from 'antd' import ExcelIn from './excelin' import Utils, { getExcelInSql } from '@/utils/utils.js' @@ -28,7 +28,23 @@ state = { dict: sessionStorage.getItem('lang') !== 'en-US' ? zhCN : enUS, loading: false, + disabled: false, primaryId: '', + } + + UNSAFE_componentWillMount () { + const { btn, selectedData } = this.props + let disabled = false + + if (btn.controlField && selectedData && selectedData.length > 0) { // 琛ㄦ牸涓寜閽殣钘忔帶鍒� + selectedData.forEach(item => { + let s = item[btn.controlField] + '' + if (s === btn.controlVal || (btn.controlVal && btn.controlVal.split(',').includes(s))) { + disabled = true + } + }) + this.setState({disabled}) + } } shouldComponentUpdate (nextProps, nextState) { @@ -40,6 +56,24 @@ if (position === 'toolbar') { MKEmitter.addListener('triggerBtnId', this.actionTrigger) + } + } + + UNSAFE_componentWillReceiveProps (nextProps) { + const { btn, selectedData } = this.props + + if (btn.controlField && !is(fromJS(nextProps.selectedData || []), fromJS(selectedData || []))) { + let disabled = false + + if (nextProps.selectedData && nextProps.selectedData.length > 0) { // 琛ㄦ牸涓寜閽殣钘忔帶鍒� + nextProps.selectedData.forEach(item => { + let s = item[btn.controlField] + '' + if (s === btn.controlVal || (btn.controlVal && btn.controlVal.split(',').includes(s))) { + disabled = true + } + }) + } + this.setState({disabled}) } } @@ -74,7 +108,7 @@ if ((triggerId && btn.uuid !== triggerId) || loading) return - if (Tab && Tab.supMenu && !BID) { + if (((Tab && Tab.supMenu) || setting.supModule) && !BID) { notification.warning({ top: 92, message: '闇�瑕佷笂绾т富閿�硷紒', @@ -103,7 +137,7 @@ } let primaryId = '' // 瀵煎叆鏃惰Id - if (btn.Ot === 'requiredSgl') { + if (btn.Ot === 'requiredSgl' && setting.primaryKey) { primaryId = data[0][setting.primaryKey] || '' } @@ -194,7 +228,7 @@ /** * @description Excel 瀵煎叆 */ - getexceldata = (data, errors, sheetName) => { + getexceldata = (data, errors, sheetName, errDetail) => { const { btn } = this.props if (errors) { @@ -213,7 +247,7 @@ } else if (errors === 'headerError') { notification.warning({ top: 92, - message: '宸ヤ綔琛ㄣ��' + sheetName + '銆嬭〃澶磋缃敊璇紝璇锋鏌ヨ〃澶翠腑鐨勫悕绉板強椤哄簭锛屼笌鎸夐挳Excel鍒椾俊鎭槸鍚︿竴鑷达紒', + message: `宸ヤ綔琛ㄣ��${sheetName}銆嬭〃澶撮敊璇紝${errDetail}`, duration: 5 }) } @@ -408,28 +442,46 @@ render() { const { btn, show } = this.props - const { loading } = this.state + const { loading, disabled } = this.state if (show === 'actionList') { return <div style={{display: 'inline-block'}} onClick={(e) => e.stopPropagation()}> <Button icon={btn.icon} loading={loading} + disabled={disabled} className={'mk-btn mk-' + btn.class} onClick={() => {this.actionTrigger()}} >{btn.label}</Button> <ExcelIn btn={btn} triggerExcelIn={() => this.updateStatus('start')} returndata={this.getexceldata} ref="excelIn" /> </div> } else { // icon銆乼ext銆� all 鍗$墖 + let label = '' + let icon = '' + + if (show === 'button') { + label = btn.label + icon = btn.icon || '' + } else if (show === 'link') { + label = <span>{btn.label}{btn.icon ? <Icon style={{marginLeft: '8px'}} type={btn.icon}/> : ''}</span> + icon = '' + } else if (show === 'icon') { + icon = btn.icon || 'upload' + // } else if (show === 'text') { + } else { + label = btn.label + } + return <div style={{display: 'inline-block'}} onClick={(e) => e.stopPropagation()}> <Button type="link" title={show === 'icon' ? btn.label : ''} loading={loading} - style={btn.btnstyle} - icon={show === 'text' ? '' : (show === 'icon' ? (btn.icon || 'upload') : (btn.icon || ''))} + disabled={disabled} + style={btn.style} + icon={icon} onClick={() => {this.actionTrigger()}} - >{show === 'icon' ? '' : btn.label}</Button> + >{label}</Button> <ExcelIn btn={btn} triggerExcelIn={() => this.updateStatus('start')} returndata={this.getexceldata} ref="excelIn" /> </div> } -- Gitblit v1.8.0