From f895e8af9e6a393f71fec0dc26fdf1b9b6616cb4 Mon Sep 17 00:00:00 2001 From: king <18310653075@163.com> Date: 星期五, 11 十二月 2020 18:53:04 +0800 Subject: [PATCH] 2020-12-11 --- src/templates/zshare/modalform/index.jsx | 47 + src/templates/zshare/editTable/index.jsx | 26 src/templates/zshare/modalform/fieldtable/index.jsx | 275 ++----------- src/templates/zshare/modalform/fieldtable/index.scss | 41 -- src/tabviews/zshare/actionList/popupbutton/index.jsx | 3 src/templates/formtabconfig/index.jsx | 14 src/menu/actioncomponent/dragaction/index.jsx | 14 src/menu/components/card/cardcellcomponent/dragaction/action.jsx | 16 src/menu/components/card/cardcellcomponent/dragaction/index.jsx | 8 src/menu/actioncomponent/index.jsx | 83 ++++ src/tabviews/zshare/actionList/excelInbutton/index.jsx | 1 src/tabviews/zshare/actionList/exceloutbutton/index.jsx | 1 src/menu/components/table/normal-table/index.scss | 10 src/templates/modalconfig/index.jsx | 18 src/tabviews/zshare/actionList/index.jsx | 14 src/tabviews/custom/components/share/normalTable/index.jsx | 8 src/tabviews/custom/index.scss | 3 src/tabviews/zshare/actionList/newpagebutton/index.jsx | 1 src/menu/components/table/normal-table/columns/index.scss | 5 src/components/barcode/index.scss | 2 src/tabviews/zshare/actionList/normalbutton/index.jsx | 4 src/templates/sharecomponent/actioncomponent/verifyexcelin/index.jsx | 15 src/templates/zshare/editTable/index.scss | 8 src/tabviews/zshare/actionList/changeuserbutton/index.jsx | 1 src/views/menudesign/index.jsx | 82 +++- src/tabviews/zshare/actionList/tabbutton/index.jsx | 1 src/menu/components/card/cardcellcomponent/index.jsx | 39 + src/templates/zshare/formconfig.jsx | 34 + src/templates/zshare/modalform/datatable/index.jsx | 140 ++++-- src/menu/actioncomponent/dragaction/card.jsx | 17 src/templates/zshare/verifycard/index.jsx | 53 ++ src/tabviews/zshare/actionList/printbutton/index.jsx | 1 src/tabviews/zshare/mutilform/index.jsx | 93 +++- src/tabviews/custom/index.jsx | 4 src/menu/modalconfig/index.jsx | 22 src/templates/zshare/modalform/datatable/index.scss | 10 src/menu/components/table/normal-table/index.jsx | 16 src/menu/components/table/normal-table/columns/index.jsx | 18 38 files changed, 653 insertions(+), 495 deletions(-) diff --git a/src/components/barcode/index.scss b/src/components/barcode/index.scss index b0f66e1..b7ec350 100644 --- a/src/components/barcode/index.scss +++ b/src/components/barcode/index.scss @@ -1,7 +1,7 @@ .barcode-box { + display: inline-block; overflow-y: hidden; height: 100%; - float: left; svg { vertical-align: top; } diff --git a/src/menu/actioncomponent/dragaction/card.jsx b/src/menu/actioncomponent/dragaction/card.jsx index e2c1131..88df555 100644 --- a/src/menu/actioncomponent/dragaction/card.jsx +++ b/src/menu/actioncomponent/dragaction/card.jsx @@ -3,7 +3,7 @@ import { Icon, Button, Popover } from 'antd' import './index.scss' -const Card = ({ id, card, moveCard, findCard, editCard, delCard, copyCard, profileCard, doubleClickCard }) => { +const Card = ({ id, card, moveCard, findCard, editCard, delCard, copyCard, changeStyle, profileCard, doubleClickCard }) => { const originalIndex = findCard(id).index const [{ isDragging }, drag] = useDrag({ item: { type: 'action', id, originalIndex }, @@ -41,8 +41,8 @@ btnElement = ( <Button type="link" - className={'mk-icon mk-' + card.class} icon={card.icon} + style={card.btnstyle} onDoubleClick={() => doubleClickCard(id)} >{card.icon ? '' : card.label}</Button> ) @@ -50,15 +50,15 @@ btnElement = ( <Button type="link" - className={'mk-link mk-' + card.class} + style={card.btnstyle} onDoubleClick={() => doubleClickCard(id)} >{card.label}{card.icon ? <Icon type={card.icon}/> : null}</Button> ) } else { btnElement = ( <Button - className={'mk-btn mk-' + card.class} icon={card.icon} + style={card.btnstyle} onDoubleClick={() => doubleClickCard(id)} > {card.label} @@ -69,10 +69,11 @@ return ( <Popover overlayClassName="mk-popover-control-wrap" mouseLeaveDelay={0.2} mouseEnterDelay={0.2} content={ <div className="mk-popover-control"> - <Icon className="edit" title="edit" type="edit" onClick={() => editCard(id)} /> - <Icon className="copy" title="copy" type="copy" onClick={() => copyCard(id)} /> - <Icon className="close" title="close" type="close" onClick={() => delCard(id)} /> - {hasProfile ? <Icon className="profile" title="setting" type="profile" onClick={() => profileCard(id)} /> : null} + <Icon className="edit" title="缂栬緫" type="edit" onClick={() => editCard(id)} /> + <Icon className="copy" title="澶嶅埗" type="copy" onClick={() => copyCard(id)} /> + <Icon className="close" title="鍒犻櫎" type="close" onClick={() => delCard(id)} /> + <Icon className="style" title="璋冩暣鏍峰紡" onClick={() => changeStyle(id)} type="font-colors" /> + {hasProfile ? <Icon className="profile" title="楠岃瘉" type="profile" onClick={() => profileCard(id)} /> : null} </div> } trigger="hover"> <div className="page-card" style={{ opacity: opacity}}> diff --git a/src/menu/actioncomponent/dragaction/index.jsx b/src/menu/actioncomponent/dragaction/index.jsx index 8024806..08044d4 100644 --- a/src/menu/actioncomponent/dragaction/index.jsx +++ b/src/menu/actioncomponent/dragaction/index.jsx @@ -7,7 +7,7 @@ import Card from './card' import './index.scss' -const Container = ({list, handleList, handleMenu, deleteMenu, profileMenu, doubleClickCard }) => { +const Container = ({list, handleList, handleMenu, deleteMenu, profileMenu, changeBtnStyle, dropButton, doubleClickCard }) => { const [cards, setCards] = useState(list) const moveCard = (id, atIndex) => { const { card, index } = findCard(id) @@ -40,6 +40,11 @@ const profileCard = id => { const { card } = findCard(id) profileMenu(card) + } + + const changeStyle = id => { + const { card } = findCard(id) + changeBtnStyle(card) } const delCard = id => { @@ -86,7 +91,11 @@ const [, drop] = useDrop({ accept: 'action', - drop() {} + drop(item) { + const { index } = findCard(item.id) + if (index > -1) return + dropButton(item.id) + } }) return ( @@ -101,6 +110,7 @@ editCard={editCard} delCard={delCard} findCard={findCard} + changeStyle={changeStyle} profileCard={profileCard} doubleClickCard={doubleClickBtn} /> diff --git a/src/menu/actioncomponent/index.jsx b/src/menu/actioncomponent/index.jsx index aab64b2..0075307 100644 --- a/src/menu/actioncomponent/index.jsx +++ b/src/menu/actioncomponent/index.jsx @@ -50,6 +50,7 @@ componentDidMount () { MKEmitter.addListener('addButton', this.addButton) + MKEmitter.addListener('submitStyle', this.getStyle) } /** @@ -75,6 +76,41 @@ return } MKEmitter.removeListener('addButton', this.addButton) + MKEmitter.removeListener('submitStyle', this.getStyle) + } + + getStyle = (comIds, style) => { + const { config } = this.props + const { card, actionlist } = this.state + + if (comIds.length !== 2 || comIds[0] !== config.uuid) return + + let _card = fromJS(card).toJS() + _card.btnstyle = style + + let _actionlist = actionlist.map(cell => { + if (cell.uuid === _card.uuid) return _card + return cell + }) + + this.setState({ + actionlist: _actionlist + }, () => { + this.props.updateaction({...config, action: _actionlist}) + }) + } + + changeBtnStyle = (element) => { + const { config } = this.props + + let _style = element.btnstyle ? fromJS(element.btnstyle).toJS() : {} + let options = ['font', 'border', 'background'] + + this.setState({ + card: element + }) + + MKEmitter.emit('changeStyle', [config.uuid, element.uuid], options, _style) } addButton = (cardId, element) => { @@ -225,8 +261,9 @@ */ handleSubmit = () => { const { config } = this.props + let color = { primary: '#1890ff', yellow: '#c49f47', orange: 'orange', danger: '#ff4d4f', green: '#26C281', dgreen: '#32c5d2', purple: '#8E44AD', cyan: '#13c2c2', gray: '#666666' } let _actionlist = fromJS(this.state.actionlist).toJS() - + this.actionFormRef.handleConfirm().then(btn => { _actionlist = _actionlist.filter(item => !item.origin || item.uuid === btn.uuid) @@ -237,6 +274,17 @@ } if (item.uuid === btn.uuid) { + btn.btnstyle = item.btnstyle || {} + + if (btn.class !== item.class || btn.show !== item.show || !btn.btnstyle.color) { + if (btn.show === 'link' || btn.show === 'icon') { + btn.btnstyle.color = color[btn.class] + btn.btnstyle.background = 'transparent' + } else { + btn.btnstyle.color = '#ffffff' + btn.btnstyle.background = color[btn.class] + } + } return btn } else { return item @@ -417,18 +465,49 @@ } } + dropButton = (id) => { + let config = fromJS(this.props.config).toJS() + + let btn = null + if (config.subtype === 'normaltable') { + config.cols.forEach(col => { + if (col.type !== 'action') return + + col.elements = col.elements.filter(item => { + if (item.uuid === id) { + btn = item + } + return item.uuid !== id + }) + }) + } + + if (!btn) return + + btn.Ot = 'requiredSgl' + config.action.push(btn) + + this.setState({ + actionlist: config.action + }, () => { + this.props.updateaction(config) + }) + } + render() { const { config } = this.props const { actionlist, visible, card, dict, profVisible } = this.state return ( - <div className={'model-menu-action-list length' + actionlist.length}> + <div className={'model-menu-action-list'}> <DragElement list={actionlist} handleList={this.handleList} + dropButton={this.dropButton} handleMenu={this.handleAction} deleteMenu={this.deleteElement} profileMenu={this.profileAction} + changeBtnStyle={this.changeBtnStyle} doubleClickCard={this.btnDoubleClick} /> {/* 缂栬緫鎸夐挳锛氬鍒躲�佺紪杈� */} diff --git a/src/menu/components/card/cardcellcomponent/dragaction/action.jsx b/src/menu/components/card/cardcellcomponent/dragaction/action.jsx index 3a4dcf0..a4bed7a 100644 --- a/src/menu/components/card/cardcellcomponent/dragaction/action.jsx +++ b/src/menu/components/card/cardcellcomponent/dragaction/action.jsx @@ -42,21 +42,11 @@ let btnElement = null if (card.show === 'icon') { - btnElement = (card.icon ? <Button className={'mk-link mk-' + card.class} style={card.btnstyle} type="link"><Icon type={card.icon}/></Button> : null) + btnElement = (<Button style={card.btnstyle} type="link"><Icon type={card.icon}/></Button>) } else if (card.show === 'link') { - btnElement = ( - <Button className={'mk-link mk-' + card.class} style={card.btnstyle} type="link">{card.label}{card.icon ? <Icon type={card.icon}/> : null}</Button> - ) + btnElement = (<Button style={card.btnstyle} type="link">{card.label}{card.icon ? <Icon type={card.icon}/> : null}</Button>) } else { - btnElement = ( - <Button - className={'mk-btn mk-' + card.class} - icon={card.icon} - style={card.btnstyle} - > - {card.label} - </Button> - ) + btnElement = (<Button icon={card.icon} style={card.btnstyle}> {card.label} </Button>) } return ( diff --git a/src/menu/components/card/cardcellcomponent/dragaction/index.jsx b/src/menu/components/card/cardcellcomponent/dragaction/index.jsx index 49267a8..119bcd2 100644 --- a/src/menu/components/card/cardcellcomponent/dragaction/index.jsx +++ b/src/menu/components/card/cardcellcomponent/dragaction/index.jsx @@ -8,7 +8,7 @@ import Action from './action' import './index.scss' -const Container = ({list, handleList, handleMenu, deleteMenu, profileAction, handleStyle, handleSubConfig }) => { +const Container = ({list, handleList, handleMenu, deleteMenu, profileAction, handleStyle, dropButton, handleSubConfig }) => { const [cards, setCards] = useState(list) const moveCard = (id, atIndex) => { const { card, index } = findCard(id) @@ -91,7 +91,11 @@ const [, drop] = useDrop({ accept: 'action', - drop() {} + drop(item) { + const { index } = findCard(item.id) + if (index > -1) return + dropButton(item.id) + } }) return ( diff --git a/src/menu/components/card/cardcellcomponent/index.jsx b/src/menu/components/card/cardcellcomponent/index.jsx index ed96872..76e3bd6 100644 --- a/src/menu/components/card/cardcellcomponent/index.jsx +++ b/src/menu/components/card/cardcellcomponent/index.jsx @@ -65,6 +65,7 @@ } UNSAFE_componentWillReceiveProps(nextProps) { + const { cards } = this.props if (this.props.side !== nextProps.side) { this.setState({ elements: fromJS(nextProps.elements).toJS() @@ -72,6 +73,10 @@ } else if (nextProps.elements.length === 0 && this.state.elements.length > 0) { this.setState({ elements: [] + }) + } else if (cards.subtype === 'normaltable' && this.state.elements.length > nextProps.elements.length) { // 琛ㄦ牸涓寜閽Щ鍑� + this.setState({ + elements: fromJS(nextProps.elements).toJS() }) } } @@ -416,12 +421,26 @@ */ handleActionSubmit = () => { const { elements } = this.state + let color = { primary: '#1890ff', yellow: '#c49f47', orange: 'orange', danger: '#ff4d4f', green: '#26C281', dgreen: '#32c5d2', purple: '#8E44AD', cyan: '#13c2c2', gray: '#666666' } this.actionFormRef.handleConfirm().then(res => { let _elements = elements.map(cell => { if (cell.uuid === res.uuid) { res = {...cell, ...res} delete res.focus + let btnstyle = {} + + if (res.class !== cell.class || res.show !== cell.show || !res.btnstyle) { + if (res.show === 'link' || res.show === 'icon') { + btnstyle.color = color[res.class] + btnstyle.backgroundColor = 'transparent' + } else { + btnstyle.color = '#ffffff' + btnstyle.backgroundColor = color[res.class] + } + } + res.btnstyle = {...res.btnstyle, ...btnstyle} + return res } return cell @@ -541,6 +560,25 @@ }) } + dropButton = (id) => { + const { cards } = this.props + let index = cards.action.findIndex(item => item.uuid === id) + + if (index === -1) return + + let btn = cards.action[index] + btn.eleType = 'button' + + let _elements = [...this.state.elements, btn] + let _action = cards.action.filter(item => item.uuid !== id) + + this.setState({ + elements: _elements + }, () => { + this.props.updateElement(_elements, _action) + }) + } + render() { const { cards } = this.props const { elements, visible, actvisible, profVisible, card, dict } = this.state @@ -552,6 +590,7 @@ handleList={this.handleList} handleMenu={this.handleElement} handleStyle={this.handleStyle} + dropButton={this.dropButton} profileAction={this.profileAction} handleSubConfig={this.handleSubConfig} deleteMenu={this.deleteElement} diff --git a/src/menu/components/table/normal-table/columns/index.jsx b/src/menu/components/table/normal-table/columns/index.jsx index 6a09532..b2c1597 100644 --- a/src/menu/components/table/normal-table/columns/index.jsx +++ b/src/menu/components/table/normal-table/columns/index.jsx @@ -119,9 +119,9 @@ ) class EditableCell extends Component { - updateCard = (vals) => { + updateCard = (vals, action) => { const { column } = this.props - this.props.upComponent({...column, elements: vals}) + this.props.upComponent({...column, elements: vals}, action) } shouldComponentUpdate (nextProps, nextState) { @@ -131,6 +131,7 @@ return !is(fromJS(column), fromJS(nextProps.column)) || !is(fromJS(config.columns), fromJS(nextProps.config.columns)) || + !is(fromJS(config.action), fromJS(nextProps.config.action)) || !is(fromJS(config.search), fromJS(nextProps.config.search)) } @@ -145,7 +146,7 @@ ) } else if (column && column.type === 'action') { return ( - <td style={{padding: '0 5px', textAlign: column.Align, minWidth: column.Width || 100}} className={className}> + <td style={{padding: '0 5px', textAlign: column.Align, minWidth: column.Width || 100}} className={'action-column ' + className}> <CardCellComponent cards={config} cardCell={column} elements={column.elements} updateElement={this.updateCard}/> </td> ) @@ -208,6 +209,7 @@ return !is(fromJS(this.state), fromJS(nextState)) || !is(fromJS(config.wrap), fromJS(nextProps.config.wrap)) || !is(fromJS(config.search), fromJS(nextProps.config.search)) || + !is(fromJS(config.action), fromJS(nextProps.config.action)) || config.setting.laypage !== nextProps.config.setting.laypage } @@ -223,7 +225,7 @@ }) } - updateCol = (col) => { + updateCol = (col, action) => { let _columns = fromJS(this.state.columns).toJS() if (col.isSub) { @@ -250,7 +252,11 @@ this.setState({ columns: _columns, }, () => { - this.props.updatecolumn({...this.props.config, cols: _columns}) + if (action) { + this.props.updatecolumn({...this.props.config, cols: _columns, action}) + } else { + this.props.updatecolumn({...this.props.config, cols: _columns}) + } }) } @@ -392,7 +398,7 @@ cell: EditableCell } } - + const columns = this.state.columns.map((col, index) => { return { title: col.label, diff --git a/src/menu/components/table/normal-table/columns/index.scss b/src/menu/components/table/normal-table/columns/index.scss index 558cccb..3a23c29 100644 --- a/src/menu/components/table/normal-table/columns/index.scss +++ b/src/menu/components/table/normal-table/columns/index.scss @@ -15,6 +15,11 @@ font-size: 12px; } } + .action-column { + .card-detail-row:empty { + min-height: 40px; + } + } tr:hover td { background: #ffffff!important; } diff --git a/src/menu/components/table/normal-table/index.jsx b/src/menu/components/table/normal-table/index.jsx index d460388..d29236f 100644 --- a/src/menu/components/table/normal-table/index.jsx +++ b/src/menu/components/table/normal-table/index.jsx @@ -160,22 +160,6 @@ this.props.updateConfig(_card) } - addCard = () => { - let card = fromJS(this.state.card).toJS() - - // let newcard = { - // uuid: Utils.getuuid(), - // setting: { width: 6, type: 'simple'}, - // style: { - // paddingTop: '5px', paddingBottom: '5px', paddingLeft: '15px', paddingRight: '15px', - // }, - // elements: [] - // } - - this.setState({card}) - this.props.updateConfig(card) - } - addColumns = () => { let card = fromJS(this.state.card).toJS() diff --git a/src/menu/components/table/normal-table/index.scss b/src/menu/components/table/normal-table/index.scss index dd6694d..93caec9 100644 --- a/src/menu/components/table/normal-table/index.scss +++ b/src/menu/components/table/normal-table/index.scss @@ -31,12 +31,16 @@ padding: 5px; background: rgba(255, 255, 255, 0.55); } + .model-table-search-list.length0 + .model-menu-action-list { + min-height: 60px; + } .model-menu-action-list { line-height: 40px; padding: 10px 0px; - } - .model-menu-action-list.length0 { - display: none; + min-height: 50px; + >.ant-row { + min-height: 30px; + } } .card-add-button { text-align: right; diff --git a/src/menu/modalconfig/index.jsx b/src/menu/modalconfig/index.jsx index 878cb09..32e9b5f 100644 --- a/src/menu/modalconfig/index.jsx +++ b/src/menu/modalconfig/index.jsx @@ -179,10 +179,10 @@ */ handleForm = (_card) => { const { componentConfig } = this.props - let card = fromJS(_card).toJS() - const { config } = this.state + let card = fromJS(_card).toJS() let _inputfields = [] + let _tabfields = [] let _linkableFields = [] let _linksupFields = [{ value: '', @@ -193,21 +193,20 @@ // 璁剧疆涓嬫媺鑿滃崟鍙叧鑱斿瓧娈�(涓婄骇涓庝笅绾�) if (config.groups.length > 0) { config.groups.forEach(group => { - let sublist = group.sublist.filter(item => item.type === 'text' || item.type === 'number') - _inputfields = [..._inputfields, ...sublist] - - let suplist = group.sublist.filter(item => item.type === 'select' || item.type === 'link') - _formfields = [..._formfields, ...suplist] + _formfields = [..._formfields, ...group.sublist] }) } else { - _inputfields = config.fields.filter(item => item.type === 'text' || item.type === 'number') - - _formfields = config.fields.filter(item => item.type === 'select' || item.type === 'link') + _formfields = config.fields } + + _inputfields = _formfields.filter(item => item.type === 'text' || item.type === 'number') + _tabfields = _formfields.filter(item => card.field !== item.field && ['text', 'number', 'select', 'link'].includes(item.type)) + _tabfields.unshift({field: '', text: '鍘熻〃鍗�'}) let uniq = new Map() uniq.set(card.field, true) _formfields.forEach(item => { + if (item.type !== 'select' && item.type !== 'link' && item.type !== 'radio') return if (item.field && !uniq.has(item.field)) { uniq.set(item.field, true) @@ -232,7 +231,6 @@ }) } }) - if (card.linkSubField && card.linkSubField.length > 0) { let fields = _inputfields.map(item => item.field) @@ -242,7 +240,7 @@ this.setState({ visible: true, card: card, - formlist: getModalForm(card, _inputfields, _linkableFields, _linksupFields, !!this.props.editTab) + formlist: getModalForm(card, _inputfields, _tabfields, _linkableFields, _linksupFields, !!this.props.editTab) }) } diff --git a/src/tabviews/custom/components/share/normalTable/index.jsx b/src/tabviews/custom/components/share/normalTable/index.jsx index 584b7c0..e203f3d 100644 --- a/src/tabviews/custom/components/share/normalTable/index.jsx +++ b/src/tabviews/custom/components/share/normalTable/index.jsx @@ -344,7 +344,13 @@ {content && _href ? <a href={_href} target="_blank" rel="noopener noreferrer">{content}</a> : null } </div> ) - } else if (col.type === 'custom' || col.type === 'action') { + } else if (col.type === 'custom') { + style.padding = '0px' + resProps.children = ( + <CardCellComponent data={record} cards={config} elements={col.elements} updateStatus={this.props.updateStatus}/> + ) + } else if (col.type === 'action') { + style.padding = '0px 5px' resProps.children = ( <CardCellComponent data={record} cards={config} elements={col.elements} updateStatus={this.props.updateStatus}/> ) diff --git a/src/tabviews/custom/index.jsx b/src/tabviews/custom/index.jsx index d74da96..7297557 100644 --- a/src/tabviews/custom/index.jsx +++ b/src/tabviews/custom/index.jsx @@ -273,12 +273,14 @@ card.elements = card.elements.filter(cell => { if (cell.eleType === 'button') { cell.logLabel = item.name + '-' + cell.label + cell.Ot = 'requiredSgl' } return cell.eleType !== 'button' || permAction[cell.uuid] }) card.backElements = card.backElements.filter(cell => { if (cell.eleType === 'button') { cell.logLabel = item.name + '-' + cell.label + cell.Ot = 'requiredSgl' } return cell.eleType !== 'button' || permAction[cell.uuid] }) @@ -288,6 +290,7 @@ card.elements = card.elements.filter(cell => { if (cell.eleType === 'button') { cell.logLabel = item.name + '-' + cell.label + cell.Ot = 'requiredSgl' } return cell.eleType !== 'button' || permAction[cell.uuid] }) @@ -297,6 +300,7 @@ if (col.type !== 'action') return col.elements = col.elements.filter(cell => { cell.logLabel = item.name + '-' + cell.label + cell.Ot = 'requiredSgl' return permAction[cell.uuid] }) }) diff --git a/src/tabviews/custom/index.scss b/src/tabviews/custom/index.scss index 6164b26..b8b53a5 100644 --- a/src/tabviews/custom/index.scss +++ b/src/tabviews/custom/index.scss @@ -40,5 +40,8 @@ width: 40px; height: 40px; } + .ant-btn-link:hover { + opacity: 0.8; + } } diff --git a/src/tabviews/zshare/actionList/changeuserbutton/index.jsx b/src/tabviews/zshare/actionList/changeuserbutton/index.jsx index 596f327..3abb379 100644 --- a/src/tabviews/zshare/actionList/changeuserbutton/index.jsx +++ b/src/tabviews/zshare/actionList/changeuserbutton/index.jsx @@ -165,6 +165,7 @@ <Button type="link" loading={loading} + style={btn.btnstyle} icon={show === 'text' ? '' : (btn.icon || '')} onClick={(e) => {e.stopPropagation(); this.actionTrigger()}} >{show === 'icon' && btn.icon ? '' : btn.label}</Button> diff --git a/src/tabviews/zshare/actionList/excelInbutton/index.jsx b/src/tabviews/zshare/actionList/excelInbutton/index.jsx index fe50dda..de8e379 100644 --- a/src/tabviews/zshare/actionList/excelInbutton/index.jsx +++ b/src/tabviews/zshare/actionList/excelInbutton/index.jsx @@ -410,6 +410,7 @@ <Button type="link" loading={loading} + style={btn.btnstyle} icon={show === 'text' ? '' : (show === 'icon' ? (btn.icon || 'upload') : (btn.icon || ''))} onClick={() => {this.actionTrigger()}} >{show === 'icon' ? '' : btn.label}</Button> diff --git a/src/tabviews/zshare/actionList/exceloutbutton/index.jsx b/src/tabviews/zshare/actionList/exceloutbutton/index.jsx index 194cd79..0aa6370 100644 --- a/src/tabviews/zshare/actionList/exceloutbutton/index.jsx +++ b/src/tabviews/zshare/actionList/exceloutbutton/index.jsx @@ -734,6 +734,7 @@ <Button type="link" loading={loading} + style={btn.btnstyle} icon={show === 'text' ? '' : (show === 'icon' ? (btn.icon || 'download') : (btn.icon || ''))} onClick={(e) => {e.stopPropagation(); this.actionTrigger()}} >{show === 'icon' ? '' : btn.label}</Button> diff --git a/src/tabviews/zshare/actionList/index.jsx b/src/tabviews/zshare/actionList/index.jsx index 34b7479..8e81116 100644 --- a/src/tabviews/zshare/actionList/index.jsx +++ b/src/tabviews/zshare/actionList/index.jsx @@ -56,7 +56,7 @@ return ( <NormalButton key={item.uuid} - show="actionList" + show={item.show || 'actionList'} BID={BID} Tab={Tab} btn={item} @@ -72,7 +72,7 @@ return ( <ExcelInButton key={item.uuid} - show="actionList" + show={item.show || 'actionList'} BID={BID} Tab={Tab} btn={item} @@ -85,7 +85,7 @@ return ( <ExcelOutButton key={item.uuid} - show="actionList" + show={item.show || 'actionList'} BID={BID} Tab={Tab} btn={item} @@ -98,7 +98,7 @@ return ( <PopupButton key={item.uuid} - show="actionList" + show={item.show || 'actionList'} BID={BID} Tab={Tab} btn={item} @@ -112,7 +112,7 @@ return ( <TabButton key={item.uuid} - show="actionList" + show={item.show || 'actionList'} btn={item} MenuID={MenuID} setting={setting} @@ -136,7 +136,7 @@ return ( <ChangeUserButton key={item.uuid} - show="actionList" + show={item.show || 'actionList'} BID={BID} btn={item} setting={setting} @@ -148,7 +148,7 @@ return ( <PrintButton key={item.uuid} - show="actionList" + show={item.show || 'actionList'} BID={BID} Tab={Tab} btn={item} diff --git a/src/tabviews/zshare/actionList/newpagebutton/index.jsx b/src/tabviews/zshare/actionList/newpagebutton/index.jsx index 685d8c9..af5cc5c 100644 --- a/src/tabviews/zshare/actionList/newpagebutton/index.jsx +++ b/src/tabviews/zshare/actionList/newpagebutton/index.jsx @@ -161,6 +161,7 @@ return ( <Button type="link" + style={btn.btnstyle} icon={show === 'text' ? '' : (btn.icon || '')} onClick={(e) => {e.stopPropagation(); this.actionTrigger()}} >{show === 'icon' && btn.icon ? '' : btn.label}</Button> diff --git a/src/tabviews/zshare/actionList/normalbutton/index.jsx b/src/tabviews/zshare/actionList/normalbutton/index.jsx index 0458bcb..0482cee 100644 --- a/src/tabviews/zshare/actionList/normalbutton/index.jsx +++ b/src/tabviews/zshare/actionList/normalbutton/index.jsx @@ -1172,7 +1172,7 @@ const { btn, show, style } = this.props const { loadingNumber, loading } = this.state - if (show === 'actionList' || show === 'button') { + if (show === 'actionList') { return <div style={{display: 'inline-block'}} onClick={(e) => e.stopPropagation()}> <Button style={style} @@ -1198,8 +1198,8 @@ return <div style={{display: 'inline-block'}} onClick={(e) => e.stopPropagation()}> <Button type="link" - style={style} loading={loading} + style={btn.btnstyle || style} icon={show === 'text' ? '' : (btn.icon || '')} onClick={() => {this.actionTrigger()}} >{show === 'icon' && btn.icon ? '' : btn.label}</Button> diff --git a/src/tabviews/zshare/actionList/popupbutton/index.jsx b/src/tabviews/zshare/actionList/popupbutton/index.jsx index cc2f838..a82689f 100644 --- a/src/tabviews/zshare/actionList/popupbutton/index.jsx +++ b/src/tabviews/zshare/actionList/popupbutton/index.jsx @@ -145,9 +145,10 @@ onClick={() => {this.actionTrigger()}} loading={loading} >{btn.label}</Button> : null} - {['icon', 'text', 'all'].includes(show) ? <Button + {show !== 'actionList' ? <Button type="link" loading={loading} + style={btn.btnstyle} icon={show === 'text' ? '' : (btn.icon || '')} onClick={() => {this.actionTrigger()}} >{show === 'icon' && btn.icon ? '' : btn.label}</Button> : null} diff --git a/src/tabviews/zshare/actionList/printbutton/index.jsx b/src/tabviews/zshare/actionList/printbutton/index.jsx index fbaec64..df11de2 100644 --- a/src/tabviews/zshare/actionList/printbutton/index.jsx +++ b/src/tabviews/zshare/actionList/printbutton/index.jsx @@ -1281,6 +1281,7 @@ <Button type="link" loading={loading} + style={btn.btnstyle} icon={show === 'text' ? '' : (btn.icon || '')} onClick={() => {this.actionTrigger()}} >{show === 'icon' && btn.icon ? '' : btn.label}</Button> diff --git a/src/tabviews/zshare/actionList/tabbutton/index.jsx b/src/tabviews/zshare/actionList/tabbutton/index.jsx index 9861fe6..ce60d09 100644 --- a/src/tabviews/zshare/actionList/tabbutton/index.jsx +++ b/src/tabviews/zshare/actionList/tabbutton/index.jsx @@ -167,6 +167,7 @@ return ( <Button type="link" + style={btn.btnstyle} icon={show === 'text' ? '' : (btn.icon || '')} onClick={(e) => {e.stopPropagation(); this.actionTrigger()}} >{show === 'icon' && btn.icon ? '' : btn.label}</Button> diff --git a/src/tabviews/zshare/mutilform/index.jsx b/src/tabviews/zshare/mutilform/index.jsx index aeaf147..ee8a26d 100644 --- a/src/tabviews/zshare/mutilform/index.jsx +++ b/src/tabviews/zshare/mutilform/index.jsx @@ -130,7 +130,8 @@ item.options.unshift({ key: Utils.getuuid(), Value: '', - Text: item.emptyText || '绌�' + Text: item.emptyText || '绌�', + ParentID: '' }) } @@ -245,7 +246,7 @@ item.supInitVal = data[item.linkField] } - item.options = item.oriOptions.filter(option => option.ParentID === item.supInitVal) + item.options = item.oriOptions.filter(option => option.ParentID === item.supInitVal || option.Value === '') } return item }) @@ -261,17 +262,7 @@ formlist: formlist }, () => { if (action.setting && action.setting.focus) { - try { - let _form = document.getElementById('main-form-box') - let _item = _form.getElementsByTagName('input') - _item = [..._item] - _item.forEach(input => { - if (!input || input.id !== action.setting.focus) return - input.select() - }) - } catch { - console.warn('focus error锛�') - } + this.selectInput(action.setting.focus, 'init') } // 鐢ㄦ潵鏇存柊state锛岄槻姝㈠彈鎺ц〃鍗曞垵濮嬫椂涓嶆樉绀� this.setState({ @@ -279,6 +270,28 @@ }) this.improveActionForm(deForms) }) + } + + selectInput = (selectId, type) => { + try { + let _form = document.getElementById('main-form-box') + let _inputs = _form.getElementsByTagName('input') + _inputs = [..._inputs] + _inputs.forEach(input => { + if (!input || input.id !== selectId) return + + if (input.className === 'ant-select-search__field' && type !== 'init') { + let div = document.getElementById(input.id) + div && div.click && div.click() + } else if (input.select) { + input.select() + } else if (input.focus) { + input.focus() + } + }) + } catch { + console.warn('focus error锛�') + } } /** @@ -438,7 +451,7 @@ this.setState({ formlist: _formlist.map(item => { if (item.type === 'link') { - item.options = item.oriOptions.filter(option => option.ParentID === item.supInitVal) + item.options = item.oriOptions.filter(option => option.ParentID === item.supInitVal || option.Value === '') } else if (['select', 'multiselect', 'radio', 'checkbox', 'checkcard'].includes(item.type)) { item.options = item.oriOptions } @@ -531,7 +544,7 @@ this.setState({ formlist: _formlist.map(item => { if (item.type === 'link') { - item.options = item.oriOptions.filter(option => option.ParentID === item.supInitVal) + item.options = item.oriOptions.filter(option => option.ParentID === item.supInitVal || option.Value === '') } else if (['select', 'multiselect', 'radio', 'checkbox', 'checkcard'].includes(item.type)) { item.options = item.oriOptions } @@ -549,7 +562,7 @@ formlist = formlist.map(item => { if (item.type === 'link' && item.linkField === supfield.field) { - item.options = item.oriOptions.filter(option => option.ParentID === supfield.initval) + item.options = item.oriOptions.filter(option => option.ParentID === supfield.initval || option.Value === '') item.initval = item.options[0] ? item.options[0].Value : '' if (this.props.form.getFieldValue(item.field) !== undefined) { @@ -572,13 +585,13 @@ selectChange = (_field, value) => { const { record } = this.state let formlist = fromJS(this.state.formlist).toJS() - let subfields = [] let fieldsvalue = {} let _record = {} + formlist = formlist.map(item => { if (item.type === 'link' && item.linkField === _field.field) { - item.options = item.oriOptions.filter(option => option.ParentID === value) + item.options = item.oriOptions.filter(option => option.ParentID === value || option.Value === '') item.initval = item.options[0] ? item.options[0].Value : '' if (this.props.form.getFieldValue(item.field) !== undefined) { @@ -631,6 +644,16 @@ this.setState(_param) } + + this.setState({}, () => { + if (!_field.enter || _field.enter === 'false') return + + if (_field.enter === 'tab') { + this.selectInput(_field.tabField) + } else if (_field.enter === 'sub') { + this.handleSubmit() + } + }) } handleConfirmPassword = (rule, value, callback, item) => { @@ -643,8 +666,30 @@ callback(item.label + '鏈�澶у�间负 ' + item.max) } } - callback() + } + + handleChange = (e, item) => { + let val = e.target.value + + if (item.enter === 'false') return + if (!val || !/\n/ig.test(val)) return + if (item.enter === 'tab') { + this.selectInput(item.tabField) + } else { + this.handleSubmit(e) + this.selectInput(item.tabField || item.field) + } + } + + handleInputSubmit = (e, item) => { + if (item.enter === 'false') return + if (item.enter === 'tab') { + this.selectInput(item.tabField) + } else { + this.handleSubmit(e) + this.selectInput(item.tabField || item.field) + } } getFields() { @@ -737,7 +782,7 @@ }, ..._rules ] - })(<Input placeholder="" autoComplete="off" disabled={item.readonly === 'true'} onPressEnter={this.handleSubmit} />)} + })(<Input placeholder="" autoComplete="off" disabled={item.readonly === 'true'} onChange={(e) => this.handleChange(e, item)} onPressEnter={(e) => this.handleInputSubmit(e, item)} />)} </Form.Item> </Col> ) @@ -766,8 +811,8 @@ ] })( precision === null ? - <InputNumber disabled={item.readonly === 'true'} onPressEnter={this.handleSubmit} /> : - <InputNumber precision={precision} disabled={item.readonly === 'true'} onPressEnter={this.handleSubmit} /> + <InputNumber disabled={item.readonly === 'true'} onPressEnter={(e) => this.handleInputSubmit(e, item)} /> : + <InputNumber precision={precision} disabled={item.readonly === 'true'} onPressEnter={(e) => this.handleInputSubmit(e, item)} /> )} </Form.Item> </Col> @@ -915,7 +960,7 @@ showSearch allowClear={true} filterOption={(input, option) => option.props.children.toLowerCase().indexOf(input.toLowerCase()) >= 0} - onChange={(value) => {this.selectChange(item, value)}} + onSelect={(value) => {this.selectChange(item, value)}} disabled={item.readonly === 'true'} > {item.options.map(option => @@ -1285,7 +1330,7 @@ } handleSubmit = (e) => { - e.preventDefault() + e && e.preventDefault() this.props.inputSubmit() } diff --git a/src/templates/formtabconfig/index.jsx b/src/templates/formtabconfig/index.jsx index 6ccf8df..ef2cbd8 100644 --- a/src/templates/formtabconfig/index.jsx +++ b/src/templates/formtabconfig/index.jsx @@ -426,6 +426,7 @@ const { menu } = this.props const { config } = this.state let _inputfields = [] + let _tabfields = [] let _linkableFields = [] let _linksupFields = [{ value: '', @@ -435,12 +436,12 @@ // 璁剧疆涓嬫媺鑿滃崟鍙叧鑱斿瓧娈� config.groups.forEach(group => { - let sublist = group.sublist.filter(item => item.type === 'text' || item.type === 'number') - _inputfields = [..._inputfields, ...sublist] - - let suplist = group.sublist.filter(item => item.type === 'select' || item.type === 'link') - _formfields = [..._formfields, ...suplist] + _formfields = [..._formfields, ...group.sublist] }) + + _inputfields = _formfields.filter(item => item.type === 'text' || item.type === 'number') + _tabfields = _formfields.filter(item => card.field !== item.field && ['text', 'number', 'select', 'link'].includes(item.type)) + _tabfields.unshift({field: '', text: '鍘熻〃鍗�'}) if (card.linkSubField && card.linkSubField.length > 0) { let fields = _inputfields.map(item => item.field) @@ -451,6 +452,7 @@ uniq.set(card.field, true) _formfields.forEach(item => { + if (item.type !== 'select' && item.type !== 'link') return if (item.field && !uniq.has(item.field)) { uniq.set(item.field, true) @@ -481,7 +483,7 @@ this.setState({ modaltype: 'search', card: card, - formlist: getModalForm(card, _inputfields, _linkableFields, _linksupFields, false).map(item => { + formlist: getModalForm(card, _inputfields, _tabfields, _linkableFields, _linksupFields, false).map(item => { if (item.key === 'type') { item.options = item.options.filter(option => !['switch', 'checkbox', 'radio', 'checkcard', 'hint'].includes(option.value)) } diff --git a/src/templates/modalconfig/index.jsx b/src/templates/modalconfig/index.jsx index 10f9a33..5bb6f03 100644 --- a/src/templates/modalconfig/index.jsx +++ b/src/templates/modalconfig/index.jsx @@ -259,6 +259,7 @@ let card = fromJS(_card).toJS() const { config } = this.state let _inputfields = [] + let _tabfields = [] let _linkableFields = [] let _linksupFields = [{ value: '', @@ -269,21 +270,20 @@ // 璁剧疆涓嬫媺鑿滃崟鍙叧鑱斿瓧娈�(涓婄骇涓庝笅绾�) if (config.groups.length > 0) { config.groups.forEach(group => { - let sublist = group.sublist.filter(item => item.type === 'text' || item.type === 'number') - _inputfields = [..._inputfields, ...sublist] - - let suplist = group.sublist.filter(item => item.type === 'select' || item.type === 'link' || item.type === 'radio') - _formfields = [..._formfields, ...suplist] + _formfields = [..._formfields, ...group.sublist] }) } else { - _inputfields = config.fields.filter(item => item.type === 'text' || item.type === 'number') - - _formfields = config.fields.filter(item => item.type === 'select' || item.type === 'link' || item.type === 'radio') + _formfields = config.fields } + + _inputfields = _formfields.filter(item => item.type === 'text' || item.type === 'number') + _tabfields = _formfields.filter(item => card.field !== item.field && ['text', 'number', 'select', 'link'].includes(item.type)) + _tabfields.unshift({field: '', text: '鍘熻〃鍗�'}) let uniq = new Map() uniq.set(card.field, true) _formfields.forEach(item => { + if (item.type !== 'select' && item.type !== 'link' && item.type !== 'radio') return if (item.field && !uniq.has(item.field)) { uniq.set(item.field, true) @@ -341,7 +341,7 @@ this.setState({ visible: true, card: card, - formlist: getModalForm(card, _inputfields, _linkableFields, _linksupFields, !!this.props.editTab) + formlist: getModalForm(card, _inputfields, _tabfields, _linkableFields, _linksupFields, !!this.props.editTab) }) } diff --git a/src/templates/sharecomponent/actioncomponent/verifyexcelin/index.jsx b/src/templates/sharecomponent/actioncomponent/verifyexcelin/index.jsx index ea18718..91870f9 100644 --- a/src/templates/sharecomponent/actioncomponent/verifyexcelin/index.jsx +++ b/src/templates/sharecomponent/actioncomponent/verifyexcelin/index.jsx @@ -170,9 +170,18 @@ title: 'SQL', dataIndex: 'sql', width: '60%', - render: (text) => ( - <Paragraph copyable ellipsis={{ rows: 5, expandable: true }}>{text}</Paragraph> - ) + render: (text) => { + let title = text.match(/^\s*\/\*.+\*\//) + title = title && title[0] ? title[0] : '' + text = title ? text.replace(title, '') : text + + return ( + <div> + {title ? <span style={{color: '#a50'}}>{title}</span> : null} + <Paragraph copyable ellipsis={{ rows: 4, expandable: true }}>{text}</Paragraph> + </div> + ) + } }, { title: '鎵ц浣嶇疆', diff --git a/src/templates/zshare/editTable/index.jsx b/src/templates/zshare/editTable/index.jsx index 4a250b5..c863a45 100644 --- a/src/templates/zshare/editTable/index.jsx +++ b/src/templates/zshare/editTable/index.jsx @@ -16,11 +16,10 @@ class BodyRow extends React.Component { render() { - const { isOver, connectDragSource, connectDropTarget, moveRow, ...restProps } = this.props - const style = { ...restProps.style, cursor: 'move' } + const { isOver, moveAble, connectDragSource, connectDropTarget, moveRow, ...restProps } = this.props let { className } = restProps - if (isOver) { + if (isOver && moveAble) { if (restProps.index > dragingIndex) { className += ' drop-over-downward' } @@ -29,9 +28,13 @@ } } - return connectDragSource( - connectDropTarget(<tr {...restProps} className={className} style={style} />), - ) + if (moveAble) { + return connectDragSource( + connectDropTarget(<tr {...restProps} className={className} style={{ ...restProps.style, cursor: 'move' }} />), + ) + } else { + return (<tr {...restProps} className={className} style={restProps.style} />) + } } } @@ -103,7 +106,7 @@ </Radio.Group> ) } else { - return <Input onPressEnter={() => this.getValue(form)} /> + return <Input onPressEnter={() => this.getValue(form)}/> } } @@ -174,7 +177,7 @@ const { editingKey } = this.state const editable = this.isEditing(record) return editable ? ( - <span style={{textAlign: 'center', display: 'block'}}> + <div style={{textAlign: 'center', minWidth: '110px'}}> <EditableContext.Consumer> {form => ( <span onClick={() => this.save(form, record.uuid)} style={{ marginRight: 8 , color: '#1890ff', cursor: 'pointer'}}> @@ -183,9 +186,9 @@ )} </EditableContext.Consumer> <span style={{ color: '#1890ff', cursor: 'pointer'}} onClick={() => this.cancel(record.uuid)}>{eTDict['model.cancel']}</span> - </span> + </div> ) : ( - <div className={'edit-operation-btn' + (editingKey !== '' ? ' disabled' : '')}> + <div className={'edit-operation-btn' + (editingKey !== '' ? ' disabled' : '')} style={{minWidth: '110px'}}> {!actions || actions.includes('edit') ? <span className="primary" onClick={() => {editingKey === '' && this.edit(record.uuid)}}><Icon type="edit" /></span> : null} {(!actions || actions.includes('del')) && editingKey === '' ? <Popconfirm overlayClassName="popover-confirm" @@ -380,7 +383,7 @@ return ( <EditableContext.Provider value={this.props.form}> - <div className={'modal-edit-table ' + (this.state.editingKey ? 'editing' : '')}> + <div className="modal-edit-table"> <DndProvider> <Table bordered @@ -392,6 +395,7 @@ pagination={false} onRow={(record, index) => ({ index, + moveAble: !this.state.editingKey, moveRow: this.moveRow, })} /> diff --git a/src/templates/zshare/editTable/index.scss b/src/templates/zshare/editTable/index.scss index 4d73446..b35ee08 100644 --- a/src/templates/zshare/editTable/index.scss +++ b/src/templates/zshare/editTable/index.scss @@ -58,13 +58,6 @@ .ant-empty { margin: 0; } -} -.modal-edit-table.editing { - .editable-row { - cursor: default!important; - } -} -.modal-edit-table:not(.editing) { tr.drop-over-downward td { border-bottom: 2px dashed #1890ff; } @@ -72,3 +65,4 @@ border-top: 2px dashed #1890ff; } } + diff --git a/src/templates/zshare/formconfig.jsx b/src/templates/zshare/formconfig.jsx index 2af3c33..cc26757 100644 --- a/src/templates/zshare/formconfig.jsx +++ b/src/templates/zshare/formconfig.jsx @@ -1814,11 +1814,12 @@ * @description 鑾峰彇琛ㄥ崟閰嶇疆淇℃伅 * @param {*} card // 琛ㄥ崟瀵硅薄 * @param {*} inputfields // 鍙叧鑱旇〃鍗� + * @param {*} tabfields // 鍙垏鎹㈣〃鍗� * @param {*} linkableFields // 鍙叧鑱旇〃鍗� * @param {*} linksupFields // 涓婄骇琛ㄥ崟 * @param {*} subtable // 鏄惁涓哄瓙琛ㄨ〃鍗� */ -export function getModalForm (card, inputfields, linkableFields, linksupFields, subtable = false) { +export function getModalForm (card, inputfields = [], tabfields = [], linkableFields, linksupFields, subtable = false) { let roleList = sessionStorage.getItem('sysRoles') if (roleList) { try { @@ -2356,8 +2357,8 @@ { type: 'text', key: 'tooltip', - label: '琛ㄥ崟娉ㄩ噴', - tooltip: '榧犳爣鎮诞浜庢彁绀烘枃瀛椾笂鏂规椂锛屾樉绀烘敞閲娿��', + label: '鎮诞鎻愮ず', + tooltip: '榧犳爣鎮诞浜庢彁绀烘枃瀛椾笂鏂规椂锛屾樉绀烘彁绀轰俊鎭��', initVal: card.tooltip || '', required: false }, @@ -2365,11 +2366,36 @@ type: 'text', key: 'emptyText', label: '绌哄�兼枃鏈�', - tooltip: '绌哄�肩殑鎻愮ず鏂囨湰锛岄粯璁や负銆婄┖銆嬨��', + tooltip: '绌哄�肩殑鎻愮ず鏂囨湰锛岄�夋嫨璁剧疆绌哄�兼椂鏈夋晥锛岄粯璁ゅ�间负銆婄┖銆嬨��', initVal: card.emptyText || '', required: false }, { + type: 'radio', + key: 'enter', + label: '鍥炶溅浜嬩欢', + initVal: (card.type === 'text' || card.type === 'number') ? (card.enter || 'sub') : (card.enter || 'false'), + tooltip: '鐐瑰嚮Enter閿紝鎴栨枃鏈被琛ㄥ崟杈撳叆鍥炶溅绗︺��', + options: [{ + value: 'sub', + text: '鎻愪氦' + }, { + value: 'tab', + text: '鍒囨崲' + }, { + value: 'false', + text: '鏃犲姩浣�' + }] + }, + { + type: 'select', + key: 'tabField', + label: '鍒囨崲瀛楁', + initVal: card.tabField || '', + options: tabfields, + required: false + }, + { type: 'multiselect', key: 'blacklist', label: Formdict['header.form.blacklist'], diff --git a/src/templates/zshare/modalform/datatable/index.jsx b/src/templates/zshare/modalform/datatable/index.jsx index d05be5e..50e0cc6 100644 --- a/src/templates/zshare/modalform/datatable/index.jsx +++ b/src/templates/zshare/modalform/datatable/index.jsx @@ -1,6 +1,7 @@ import React, { Component } from 'react' import PropTypes from 'prop-types' import { is, fromJS } from 'immutable' +import { DndProvider, DragSource, DropTarget } from 'react-dnd' import { Table, Input, Popconfirm, Form, Icon, notification } from 'antd' import Utils from '@/utils/utils.js' @@ -8,6 +9,64 @@ import './index.scss' const EditableContext = React.createContext() +let dragingIndex = -1 + +class BodyRow extends React.Component { + render() { + const { isOver, moveAble, connectDragSource, connectDropTarget, moveRow, ...restProps } = this.props + let { className } = restProps + + if (isOver && moveAble) { + if (restProps.index > dragingIndex) { + className += ' drop-over-downward' + } + if (restProps.index < dragingIndex) { + className += ' drop-over-upward' + } + } + + if (moveAble) { + return connectDragSource( + connectDropTarget(<tr {...restProps} className={className} style={{...restProps.style, cursor: 'move'}} />), + ) + } else { + return (<tr {...restProps} className={className} style={restProps.style} />) + } + } +} + +const rowSource = { + beginDrag(props) { + dragingIndex = props.index + return { + index: props.index, + } + } +} + +const rowTarget = { + drop(props, monitor) { + const dragIndex = monitor.getItem().index + const hoverIndex = props.index + + if (dragIndex === hoverIndex) { + return + } + + props.moveRow(dragIndex, hoverIndex) + + monitor.getItem().index = hoverIndex + }, +} + +const DragableBodyRow = DropTarget('row', rowTarget, (connect, monitor) => ({ + connectDropTarget: connect.dropTarget(), + isOver: monitor.isOver(), +}))( + DragSource('row', rowSource, connect => ({ + connectDragSource: connect.dragSource(), + }))(BodyRow), +) class EditableCell extends Component { getInput = (form) => { @@ -161,8 +220,9 @@ }) columns.push({ - title: 'operation', + title: '鎿嶄綔', dataIndex: 'operation', + align: 'center', width: '18%', render: (text, record) => { const { editingKey } = this.state @@ -181,8 +241,6 @@ ) : ( <div className={'operation-btn' + (editingKey !== '' ? ' disabled' : '')}> <span className="primary" onClick={() => {editingKey === '' && this.edit(record.key)}}><Icon type="edit" /></span> - <span className="primary" onClick={() => {editingKey === '' && this.handleUpDown(record.key, 'up')}}><Icon type="arrow-up" /></span> - <span className="danger" onClick={() => {editingKey === '' && this.handleUpDown(record.key, 'down')}}><Icon type="arrow-down" /></span> {editingKey === '' ? <Popconfirm overlayClassName="popover-confirm" title={this.props.dict['model.query.delete']} @@ -219,27 +277,6 @@ handleDelete = (key) => { const { data } = this.state let _data = data.filter(item => key !== item.key) - - this.setState({ - data: _data - }, () => { - this.props.onChange(_data) - }) - } - - handleUpDown = (key, direction) => { - let _data = fromJS(this.state.data).toJS() - const index = _data.findIndex(item => key === item.key) - - if ((index === 0 && direction === 'up') || (index === _data.length - 1 && direction === 'down')) { - return - } - - if (direction === 'up') { - _data.splice(index - 1, 0, ..._data.splice(index, 1)) - } else { - _data.splice(index + 1, 0, ..._data.splice(index, 1)) - } this.setState({ data: _data @@ -286,14 +323,7 @@ handleAdd = () => { const { fields, type } = this.props - if (this.state.editingKey) { - notification.warning({ - top: 92, - message: '璇蜂繚瀛樼紪杈戜腑鐨勫厓绱狅紒', - duration: 5 - }) - return - } else if (this.state.data.length >= 20) { + if (this.state.data.length >= 20) { notification.warning({ top: 92, message: '鏈�澶氬彲娣诲姞20椤癸紒', @@ -314,7 +344,7 @@ let data = [...this.state.data, item] - this.setState({ data }, () => { + this.setState({ data, editingKey: '' }, () => { this.props.onChange(data) }) } @@ -323,11 +353,27 @@ this.setState({ editingKey: key }) } + moveRow = (dragIndex, hoverIndex) => { + const { editingKey } = this.state + let _data = fromJS(this.state.data).toJS() + + if (editingKey) return + + _data.splice(hoverIndex, 0, ..._data.splice(dragIndex, 1)) + + this.setState({ + data: _data + }, () => { + this.props.onChange(_data) + }) + } + render() { const components = { body: { - cell: EditableCell, - }, + row: DragableBodyRow, + cell: EditableCell + } } const columns = this.state.columns.map(col => { @@ -358,14 +404,22 @@ <EditableContext.Provider value={this.props.form}> <div className="modal-card-data-table"> {addable ? <Icon className="add-row" type="plus" onClick={this.handleAdd} /> : null} - <Table - components={components} - bordered - dataSource={this.state.data} - columns={columns} - rowClassName="editable-row" - pagination={false} - /> + <DndProvider> + <Table + components={components} + bordered + rowKey="key" + dataSource={this.state.data} + columns={columns} + rowClassName="editable-row" + onRow={(record, index) => ({ + index, + moveAble: !this.state.editingKey, + moveRow: this.moveRow, + })} + pagination={false} + /> + </DndProvider> </div> </EditableContext.Provider> ) diff --git a/src/templates/zshare/modalform/datatable/index.scss b/src/templates/zshare/modalform/datatable/index.scss index 212b7ce..e80b7bf 100644 --- a/src/templates/zshare/modalform/datatable/index.scss +++ b/src/templates/zshare/modalform/datatable/index.scss @@ -35,8 +35,10 @@ } } .operation-btn { + font-size: 16px; + text-align: center; span { - margin-right: 7px; + margin-right: 15px; cursor: pointer; } .primary { @@ -57,4 +59,10 @@ color: rgba(0, 0, 0, .25); } } + tr.drop-over-downward td { + border-bottom: 2px dashed #1890ff; + } + tr.drop-over-upward td { + border-top: 2px dashed #1890ff; + } } diff --git a/src/templates/zshare/modalform/fieldtable/index.jsx b/src/templates/zshare/modalform/fieldtable/index.jsx index 58ada4f..16a2b09 100644 --- a/src/templates/zshare/modalform/fieldtable/index.jsx +++ b/src/templates/zshare/modalform/fieldtable/index.jsx @@ -1,72 +1,12 @@ import React, { Component } from 'react' import PropTypes from 'prop-types' -import { fromJS } from 'immutable' -import { Table, Input, InputNumber, Popconfirm, Form, Icon, notification, Select } from 'antd' +import { Icon, notification } from 'antd' -import ColorSketch from '@/mob/colorsketch' +import asyncComponent from '@/utils/asyncComponent' import Utils from '@/utils/utils.js' import './index.scss' -const EditableContext = React.createContext() - -class EditableCell extends Component { - getInput = (form) => { - const { inputType } = this.props - if (inputType === 'number') { - return <InputNumber min={12} max={50} precision={0} onPressEnter={() => this.getValue(form)} /> - } else if (inputType === 'color') { - return <ColorSketch /> - } else if (inputType === 'select') { - return <Select> - <Select.Option key="left" value="left"> left </Select.Option> - <Select.Option key="center" value="center"> center </Select.Option> - <Select.Option key="right" value="right"> right </Select.Option> - <Select.Option key="justify" value="justify"> justify </Select.Option> - </Select> - } else { - return <Input onPressEnter={() => this.getValue(form)} /> - } - } - - getValue = (form) => { - const { record } = this.props - form.validateFields((error, row) => { - if (error) { - return - } - this.props.onSave({...record, ...row}) - }) - } - - renderCell = (form) => { - const { getFieldDecorator } = form - const { editing, dataIndex, title, record, children, className } = this.props - - return ( - <td className={className}> - {editing ? ( - <Form.Item style={{ margin: 0 }}> - {getFieldDecorator(dataIndex, { - rules: [ - { - required: true, - message: `Please Input ${title}!`, - }, - ], - initialValue: record[dataIndex], - })(this.getInput(form))} - </Form.Item> - ) : ( - children - )} - </td> - ) - } - - render() { - return <EditableContext.Consumer>{this.renderCell}</EditableContext.Consumer> - } -} +const EditTable = asyncComponent(() => import('@/templates/zshare/editTable')) class EdiFieldsTable extends Component { static propTpyes = { @@ -75,28 +15,32 @@ } UNSAFE_componentWillMount () { - let data = this.props['data-__meta'].initialValue + let data = this.props['data-__meta'].initialValue || [] this.setState({ - data: data + data: data.map(item => { + item.uuid = item.uuid || item.key + return item + }) }) } state = { data: [], - editingKey: '', columns: [ { title: '瀛楁鍚�', dataIndex: 'field', inputType: 'input', editable: true, + width: '20%', }, { title: '瀛椾綋棰滆壊', dataIndex: 'color', inputType: 'color', editable: true, + width: '20%', render: (text, record) => { return <span style={{color: text}}>绀轰緥</span> } @@ -105,142 +49,42 @@ title: '瀛椾綋澶у皬', dataIndex: 'fontSize', inputType: 'number', + min: 12, + max: 50, editable: true, + width: '20%', }, { title: '瀵归綈鏂瑰紡', dataIndex: 'align', inputType: 'select', editable: true, - }, - { - title: 'operation', - dataIndex: 'operation', - width: '18%', - render: (text, record) => { - const { editingKey } = this.state - const editable = this.isEditing(record) - return editable ? ( - <span> - <EditableContext.Consumer> - {form => ( - <span onClick={() => this.save(form, record.key)} style={{ marginRight: 8 , color: '#1890ff', cursor: 'pointer'}}> - 淇濆瓨 - </span> - )} - </EditableContext.Consumer> - <span style={{ color: '#1890ff', cursor: 'pointer'}} onClick={() => this.cancel(record.key)}>鍙栨秷</span> - </span> - ) : ( - <div className={'operation-btn' + (editingKey !== '' ? ' disabled' : '')}> - <span className="primary" onClick={() => {editingKey === '' && this.edit(record.key)}}><Icon type="edit" /></span> - <span className="primary" onClick={() => {editingKey === '' && this.handleUpDown(record.key, 'up')}}><Icon type="arrow-up" /></span> - <span className="danger" onClick={() => {editingKey === '' && this.handleUpDown(record.key, 'down')}}><Icon type="arrow-down" /></span> - {editingKey === '' ? <Popconfirm - overlayClassName="popover-confirm" - title={this.props.dict['model.query.delete']} - onConfirm={() => this.handleDelete(record.key) - }> - <span className="danger"><Icon type="delete" /></span> - </Popconfirm> : null} - {editingKey !== '' ? <span className="danger"><Icon type="delete" /></span> : null} - </div> - ) - }, - }, + width: '20%', + options: [ + {value: 'left', text: 'left'}, + {value: 'center', text: 'center'}, + {value: 'right', text: 'right'}, + {value: 'justify', text: 'justify'} + ] + } ] } - isEditing = record => record.key === this.state.editingKey - - cancel = () => { - this.setState({ editingKey: '' }) - } - - onSave = (record) => { - const newData = [...this.state.data] - const index = newData.findIndex(item => record.key === item.key) - if (index > -1) { - newData.splice(index, 1, record) - this.setState({ data: newData, editingKey: '' }, () => { - this.props.onChange(newData) - }) - } - } - - handleDelete = (key) => { - const { data } = this.state - let _data = data.filter(item => key !== item.key) - - this.setState({ - data: _data - }, () => { - this.props.onChange(_data) - }) - } - - handleUpDown = (key, direction) => { - let _data = fromJS(this.state.data).toJS() - const index = _data.findIndex(item => key === item.key) - - if ((index === 0 && direction === 'up') || (index === _data.length - 1 && direction === 'down')) { - return - } - - if (direction === 'up') { - _data.splice(index - 1, 0, ..._data.splice(index, 1)) - } else { - _data.splice(index + 1, 0, ..._data.splice(index, 1)) - } - - this.setState({ - data: _data - }, () => { - this.props.onChange(_data) - }) - } - - save(form, key) { - form.validateFields((error, row) => { - if (error) { - return; - } - const newData = [...this.state.data] - const index = newData.findIndex(item => key === item.key) - if (index > -1) { - const item = newData[index] - newData.splice(index, 1, { - ...item, - ...row, - }) - this.setState({ data: newData, editingKey: '' }, () => { - this.props.onChange(newData) - }) - } else { - newData.push(row); - this.setState({ data: newData, editingKey: '' }, () => { - this.props.onChange(newData) - }) - } - }) - } - handleAdd = () => { - if (this.state.editingKey) { - notification.warning({ - top: 92, - message: '璇蜂繚瀛樼紪杈戜腑鐨勫厓绱狅紒', - duration: 5 - }) - return - } - + let _index = this.state.data.length + 1 let item = { key: Utils.getuuid(), - field: `field${this.state.data.length + 1}`, + field: `field${_index}`, color: 'rgba(0, 0, 0, 0.85)', align: 'left', fontSize: 14, + } + + item.uuid = item.key + + while (this.state.data.filter(cell => cell.field === item.field).length > 0) { + _index++ + item.field = `field${_index}` } let data = [...this.state.data, item] @@ -250,50 +94,33 @@ }) } - edit(key) { - this.setState({ editingKey: key }) + changeData = (data) => { + let fields = data.map(cell => cell.field) + fields = Array.from(new Set(fields)) + if (data.length > 1 && data.length > fields.length) { + notification.warning({ + top: 92, + message: '瀛楁鍚嶄笉鍙噸澶嶏紒', + duration: 5 + }) + return + } + Array.from(new Set(fields)) + this.setState({ data }, () => { + this.props.onChange(data) + }) } render() { - const components = { - body: { - cell: EditableCell, - }, - } - - const columns = this.state.columns.map(col => { - if (!col.editable) { - return col - } - return { - ...col, - onCell: record => ({ - record, - inputType: col.inputType, - dataIndex: col.dataIndex, - title: col.title, - editing: this.isEditing(record), - onSave: this.onSave, - }), - } - }) + const { data, columns } = this.state return ( - <EditableContext.Provider value={this.props.form}> - <div className="modal-card-field-table"> - {this.state.data.length < 3 ? <Icon className="add-row" type="plus" onClick={this.handleAdd} /> : null} - <Table - components={components} - bordered - dataSource={this.state.data} - columns={columns} - rowClassName="editable-row" - pagination={false} - /> - </div> - </EditableContext.Provider> + <div className="modal-card-field-table"> + {data.length < 3 ? <Icon className="add-row" type="plus" onClick={this.handleAdd} /> : null} + <EditTable data={data} columns={columns} onChange={this.changeData}/> + </div> ) } } -export default Form.create()(EdiFieldsTable) \ No newline at end of file +export default EdiFieldsTable \ No newline at end of file diff --git a/src/templates/zshare/modalform/fieldtable/index.scss b/src/templates/zshare/modalform/fieldtable/index.scss index bf190f5..6e9832a 100644 --- a/src/templates/zshare/modalform/fieldtable/index.scss +++ b/src/templates/zshare/modalform/fieldtable/index.scss @@ -8,47 +8,6 @@ font-size: 18px; color: #26C281; } - .editable-row { - .ant-form-explain { - position: absolute; - font-size: 12px; - margin-top: -4px; - } - .color-sketch-block { - width: 200px; - position: relative; - top: 8px; - } - .ant-select { - width: 80px; - } - > td { - padding: 16px 10px; - } - } - .operation-btn { - span { - margin-right: 10px; - cursor: pointer; - } - .primary { - color: #1890ff; - } - .danger { - color: #ff4d4f; - } - } - .operation-btn.disabled { - span { - cursor: default; - } - .primary { - color: rgba(0, 0, 0, .25); - } - .danger { - color: rgba(0, 0, 0, .25); - } - } .ant-empty { margin: 0; } diff --git a/src/templates/zshare/modalform/index.jsx b/src/templates/zshare/modalform/index.jsx index 58d33b1..eb7b333 100644 --- a/src/templates/zshare/modalform/index.jsx +++ b/src/templates/zshare/modalform/index.jsx @@ -14,14 +14,14 @@ const { TextArea } = Input const modalTypeOptions = { - text: ['initval', 'readonly', 'required', 'hidden', 'readin', 'fieldlength', 'regular', 'interception', 'entireLine', 'tooltip'], - number: ['initval', 'readonly', 'hidden', 'decimal', 'min', 'max', 'readin', 'entireLine', 'tooltip'], - select: ['initval', 'readonly', 'required', 'hidden', 'readin', 'resourceType', 'setAll', 'linkSubField', 'entireLine', 'tooltip', 'emptyText'], + text: ['initval', 'readonly', 'required', 'hidden', 'readin', 'fieldlength', 'regular', 'interception', 'entireLine', 'tooltip', 'enter'], + number: ['initval', 'readonly', 'hidden', 'decimal', 'min', 'max', 'readin', 'entireLine', 'tooltip', 'enter'], + select: ['initval', 'readonly', 'required', 'hidden', 'readin', 'resourceType', 'setAll', 'linkSubField', 'entireLine', 'tooltip', 'emptyText', 'enter'], checkbox: ['initval', 'readonly', 'required', 'hidden', 'readin', 'resourceType', 'entireLine', 'tooltip'], radio: ['initval', 'readonly', 'required', 'hidden', 'readin', 'resourceType', 'linkSubField', 'entireLine', 'tooltip', 'setAll', 'emptyText'], checkcard: ['initval', 'readonly', 'required', 'hidden', 'readin', 'resourceType', 'linkSubField', 'fieldlength', 'display', 'tooltip', 'width', 'multiple'], multiselect: ['initval', 'readonly', 'required', 'hidden', 'readin', 'resourceType', 'fieldlength', 'entireLine', 'tooltip'], - link: ['initval', 'readonly', 'required', 'hidden', 'readin', 'resourceType', 'setAll', 'linkField', 'entireLine', 'tooltip', 'emptyText'], + link: ['initval', 'readonly', 'required', 'hidden', 'readin', 'resourceType', 'setAll', 'linkField', 'entireLine', 'tooltip', 'emptyText', 'enter'], fileupload: ['readonly', 'required', 'readin', 'fieldlength', 'maxfile', 'fileType', 'entireLine', 'tooltip'], switch: ['initval', 'openVal', 'closeVal', 'readonly', 'hidden', 'readin', 'entireLine', 'tooltip'], date: ['initval', 'readonly', 'required', 'hidden', 'readin', 'entireLine', 'tooltip'], @@ -47,6 +47,7 @@ resourceType: null, supField: '', display: 'text', + enter: '', cFields: [], formlist: null, linkSubFields: null @@ -59,6 +60,7 @@ let resourceType = '' let supField = '' let display = '' + let enter = '' let cFields = [] let linkSubFields = [] @@ -67,6 +69,8 @@ type = cell.initVal } else if (cell.key === 'display') { display = cell.initVal + } else if (cell.key === 'enter') { + enter = cell.initVal } else if (cell.key === 'fields') { cFields = cell.initVal } else if (cell.key === 'resourceType') { @@ -86,9 +90,10 @@ } }) - let _options = this.getOptions(type, resourceType, supField, display) + let _options = this.getOptions(type, resourceType, supField, display, enter) this.setState({ + enter: enter, openType: type, supField: supField, display: display, @@ -136,7 +141,7 @@ } } - getOptions = (type, resourceType, supField, display) => { + getOptions = (type, resourceType, supField, display, enter) => { let _options = ['label', 'field', 'type', 'blacklist', 'writein', ...fromJS(modalTypeOptions[type]).toJS()] if (type === 'hint') { @@ -163,6 +168,12 @@ } } + if (type === 'text' || type === 'number' || type === 'select' || type === 'link') { + if (enter === 'tab' || enter === 'sub') { + _options.push('tabField') + } + } + if (type !== 'funcvar' && type !== 'linkMain') { if (supField) { _options.push('supField', 'supvalue') @@ -176,7 +187,7 @@ openTypeChange = (key, value) => { if (key === 'type') { - let _options = this.getOptions(value, this.state.resourceType, this.state.supField, this.state.display) + let _options = this.getOptions(value, this.state.resourceType, this.state.supField, this.state.display, this.state.enter) let fieldValue = {} this.setState({ @@ -222,6 +233,8 @@ if (form.show) { fieldValue.resourceType = form.initVal } + } else if (form.key === 'enter') { + form.initVal = this.state.enter } else if (form.key === 'linkSubField') { form.initVal = this.state.linkSubFields.map(_field => _field.field) @@ -282,7 +295,7 @@ const { openType } = this.state let value = e.target.value if (key === 'resourceType') { - let _options = this.getOptions(openType, value, this.state.supField, this.state.display) + let _options = this.getOptions(openType, value, this.state.supField, this.state.display, this.state.enter) this.setState({ resourceType: value, @@ -292,10 +305,20 @@ }) }) } else if (key === 'display') { - let _options = this.getOptions(openType, this.state.resourceType, this.state.supField, value) + let _options = this.getOptions(openType, this.state.resourceType, this.state.supField, value, this.state.enter) this.setState({ display: value, + formlist: this.state.formlist.map(form => { + form.show = _options.includes(form.key) + return form + }) + }) + } else if (key === 'enter') { + let _options = this.getOptions(openType, this.state.resourceType, this.state.supField, this.state.display, value) + + this.setState({ + enter: value, formlist: this.state.formlist.map(form => { form.show = _options.includes(form.key) return form @@ -488,9 +511,9 @@ onChange={(value) => {this.openTypeChange(item.key, value)}} getPopupContainer={() => document.getElementById('modal-fields-form-box')} > - {item.options.map(option => - <Select.Option id={option.value} title={option.text} key={option.value} value={option.value}> - {item.key === 'icon' && <Icon type={option.text} />} {option.text} + {item.options.map((option, i) => + <Select.Option key={`${i}`} value={option.value || option.field}> + {item.key === 'icon' && <Icon type={option.text} />} {option.text || option.label} </Select.Option> )} </Select> diff --git a/src/templates/zshare/verifycard/index.jsx b/src/templates/zshare/verifycard/index.jsx index 1745fd7..40fcbbb 100644 --- a/src/templates/zshare/verifycard/index.jsx +++ b/src/templates/zshare/verifycard/index.jsx @@ -44,6 +44,7 @@ systemScripts: [], columnsFields: [], unionFields: [], + uniqueFields: [], // 鍞竴鎬ч獙璇侊紝琛ㄥ崟瀛楁 uniqueColumns: [ { title: '鍚嶇О', @@ -220,9 +221,18 @@ title: 'SQL', dataIndex: 'sql', width: '45%', - render: (text) => ( - <Paragraph copyable ellipsis={{ rows: 5, expandable: true }}>{text}</Paragraph> - ) + render: (text) => { + let title = text.match(/^\s*\/\*.+\*\//) + title = title && title[0] ? title[0] : '' + text = title ? text.replace(title, '') : text + + return ( + <div> + {title ? <span style={{color: '#a50'}}>{title}</span> : null} + <Paragraph copyable ellipsis={{ rows: 4, expandable: true }}>{text}</Paragraph> + </div> + ) + } }, { title: '缁撴灉澶勭悊', @@ -283,9 +293,18 @@ title: 'SQL', dataIndex: 'sql', width: '60%', - render: (text) => ( - <Paragraph copyable ellipsis={{ rows: 5, expandable: true }}>{text}</Paragraph> - ) + render: (text) => { + let title = text.match(/^\s*\/\*.+\*\//) + title = title && title[0] ? title[0] : '' + text = title ? text.replace(title, '') : text + + return ( + <div> + {title ? <span style={{color: '#a50'}}>{title}</span> : null} + <Paragraph copyable ellipsis={{ rows: 4, expandable: true }}>{text}</Paragraph> + </div> + ) + } }, { title: '鎵ц浣嶇疆', @@ -580,6 +599,12 @@ } }) + let uniqueFields = fromJS(_fields).toJS() + + if (!hasBid) { // 鍞竴鎬ч獙璇佹坊鍔燘ID + uniqueFields.unshift({ uuid: 'BID', field: 'BID', label: 'BID', type: 'text' }) + } + if (!hasBid && (card.sqlType === 'insert' || card.sqlType === 'insertOrUpdate')) { // 琛ㄥ崟涓鍔燘ID _fields.unshift({ uuid: 'BID', field: 'BID', label: 'BID', type: 'text' }) fieldArr.push('bid') @@ -599,14 +624,17 @@ } let unionFields = fromJS(_fields).toJS() + let formArr = _fields.map(_f => _f.field.toLowerCase()) if (hasColumn) { columns.forEach(_f => { + if (_f.field && !formArr.includes(_f.field.toLowerCase())) { + formArr.push(_f.field.toLowerCase()) + unionFields.push(_f) + } if (!_f.field || fieldArr.includes(_f.field.toLowerCase())) return fieldArr.push(_f.field.toLowerCase()) - - unionFields.push(_f) _usefulfields.push(_f.field) if (_f.datatype) { // 鑷畾涔夊瓧娈� @@ -799,7 +827,7 @@ usefulfields: _usefulfields.join(', '), uniqueColumns: this.state.uniqueColumns.map(col => { if (col.dataIndex === 'field') { - col.options = _fields + col.options = uniqueFields } return col }), @@ -809,7 +837,8 @@ } return col }), - unionFields + unionFields, + uniqueFields }) }) } @@ -1304,7 +1333,7 @@ render() { const { card } = this.props - const { verify, fields, uniqueColumns, unionFields, onceUniqueColumns, columnsFields, contrastColumns, customColumns, orderColumns, scriptsColumns, orderModular, orderModularDetail, voucher, voucherDetail, notes } = this.state + const { verify, fields, uniqueFields, uniqueColumns, unionFields, onceUniqueColumns, columnsFields, contrastColumns, customColumns, orderColumns, scriptsColumns, orderModular, orderModularDetail, voucher, voucherDetail, notes } = this.state const formItemLayout = { labelCol: { xs: { span: 24 }, @@ -1492,7 +1521,7 @@ } key="2"> <UniqueForm btn={card} - fields={card.Ot !== 'requiredOnce' ? fields : columnsFields} + fields={card.Ot !== 'requiredOnce' ? uniqueFields : columnsFields} dict={this.props.dict} uniqueChange={this.uniqueChange} /> diff --git a/src/views/menudesign/index.jsx b/src/views/menudesign/index.jsx index 4d27f54..3c0331d 100644 --- a/src/views/menudesign/index.jsx +++ b/src/views/menudesign/index.jsx @@ -221,6 +221,18 @@ buttons.push(`select '${btn.uuid}' as menuid, '${item.name + '-' + btn.label}' as menuname, '${_sort * 10}' as Sort`) _sort++ }) + } else if (item.type === 'table' && item.subtype === 'normaltable') { + item.action && item.action.forEach(btn => { + buttons.push(`select '${btn.uuid}' as menuid, '${item.name + '-' + btn.label}' as menuname, '${_sort * 10}' as Sort`) + _sort++ + }) + item.cols && item.cols.forEach(col => { + if (col.type !== 'action') return + col.elements.forEach(btn => { + buttons.push(`select '${btn.uuid}' as menuid, '${item.name + '-' + btn.label}' as menuname, '${_sort * 10}' as Sort`) + _sort++ + }) + }) } }) } @@ -300,7 +312,6 @@ if (config.MenuType !== 'billPrint') { btnParam.LText = this.getMenuMessage() - btnParam.LText = btnParam.LText.join(' union all ') btnParam.LText = Utils.formatOptions(btnParam.LText) btnParam.timestamp = moment().format('YYYY-MM-DD HH:mm:ss') @@ -358,29 +369,56 @@ }).then(res => { if (!res) return - Api.getSystemConfig(param).then(response => { - if (response.status) { - this.setState({ - oriConfig: fromJS(_config).toJS(), - openEdition: response.open_edition || '', - menuloading: false - }) - notification.success({ - top: 92, - message: '淇濆瓨鎴愬姛', - duration: 2 - }) + return Api.getSystemConfig(param) + }).then(res => { + if (!res) return + + if (res.status) { + this.setState({ + oriConfig: fromJS(_config).toJS(), + openEdition: res.open_edition || '' + }) + + if (btnParam.LText) { + return Api.getSystemConfig(btnParam) } else { - this.setState({ - menuloading: false - }) - notification.warning({ - top: 92, - message: response.message, - duration: 5 - }) + return { + status: true + } } - }) + } else { + this.setState({ + menuloading: false + }) + notification.warning({ + top: 92, + message: res.message, + duration: 5 + }) + return false + } + }).then(res => { + if (!res) return + + if (res.status) { + this.setState({ + menuloading: false + }) + notification.success({ + top: 92, + message: '淇濆瓨鎴愬姛', + duration: 2 + }) + } else { + this.setState({ + menuloading: false + }) + notification.warning({ + top: 92, + message: res.message, + duration: 5 + }) + } }) }) } -- Gitblit v1.8.0