From e9640ccdc9fe57f91919e3f51462c780e44fadb0 Mon Sep 17 00:00:00 2001 From: king <18310653075@163.com> Date: 星期三, 23 十二月 2020 13:14:20 +0800 Subject: [PATCH] 2020-12-23 --- src/menu/components/chart/antv-bar/chartcompile/index.jsx | 7 src/menu/components/table/normal-table/columns/editColumn/formconfig.jsx | 7 src/menu/components/table/normal-table/wrapsetting/index.jsx | 4 src/menu/components/chart/antv-pie/chartcompile/formconfig.jsx | 5 src/menu/components/card/cardcomponent/settingform/index.jsx | 9 src/menu/components/card/table-card/index.jsx | 3 src/menu/components/share/actioncomponent/dragaction/card.jsx | 5 src/menu/components/card/cardcellcomponent/dragaction/action.jsx | 14 src/menu/components/card/cardcellcomponent/dragaction/index.jsx | 4 src/templates/comtableconfig/index.jsx | 509 +++++------ src/menu/components/share/searchcomponent/dragsearch/card.jsx | 1 src/menu/components/card/cardcellcomponent/dragaction/card.jsx | 14 src/menu/components/chart/antv-bar/index.jsx | 14 src/menu/components/table/normal-table/columns/editColumn/index.jsx | 11 src/menu/popview/controller.jsx | 70 + src/tabviews/custom/components/share/normalTable/index.jsx | 86 - src/menu/components/card/data-card/wrapsetting/index.jsx | 4 src/views/menudesign/index.jsx | 63 + src/menu/components/chart/antv-bar/chartcompile/formconfig.jsx | 7 src/menu/components/card/cardcellcomponent/index.jsx | 4 src/menu/components/chart/antv-pie/chartcompile/index.jsx | 5 src/menu/datasource/verifycard/settingform/index.jsx | 24 src/menu/components/search/main-search/dragsearch/card.jsx | 12 src/menu/components/card/cardcomponent/index.jsx | 12 src/templates/subtableconfig/index.jsx | 427 ++++------ src/menu/components/card/data-card/index.jsx | 10 src/menu/components/share/actioncomponent/index.jsx | 9 src/menu/components/chart/antv-pie/index.jsx | 8 src/menu/popview/index.scss | 303 +++++++ src/tabviews/custom/index.jsx | 46 src/menu/components/card/data-card/wrapsetting/settingform/index.jsx | 13 src/menu/components/table/normal-table/wrapsetting/settingform/index.jsx | 7 src/menu/components/card/prop-card/index.jsx | 1 src/menu/components/table/normal-table/index.jsx | 10 src/menu/components/table/normal-table/columns/index.jsx | 144 +-- src/menu/popview/index.jsx | 523 +++++++++++++ 36 files changed, 1,572 insertions(+), 823 deletions(-) diff --git a/src/menu/components/card/cardcellcomponent/dragaction/action.jsx b/src/menu/components/card/cardcellcomponent/dragaction/action.jsx index a4bed7a..7bdc28b 100644 --- a/src/menu/components/card/cardcellcomponent/dragaction/action.jsx +++ b/src/menu/components/card/cardcellcomponent/dragaction/action.jsx @@ -3,7 +3,7 @@ import { Icon, Popover, Button } from 'antd' import './index.scss' -const Card = ({ id, cardIds, card, moveCard, findCard, editCard, delCard, profileCard, changeStyle, doubleClickCard }) => { +const Card = ({ id, card, moveCard, findCard, editCard, delCard, profileCard, changeStyle, doubleClickCard }) => { const originalIndex = findCard(id).index const [{ isDragging }, drag] = useDrag({ item: { type: 'action', id, originalIndex }, @@ -15,13 +15,13 @@ accept: 'action', canDrop: () => true, drop({ id: draggedId }) { - if (!draggedId) return - if (!cardIds.includes(draggedId)) return + if (!draggedId || draggedId === id) return - if (draggedId !== id) { - const { index: overIndex } = findCard(id) - moveCard(draggedId, overIndex) - } + const { index: originIndex } = findCard(draggedId) + if (originIndex === -1) return + + const { index: overIndex } = findCard(id) + moveCard(draggedId, overIndex) }, }) diff --git a/src/menu/components/card/cardcellcomponent/dragaction/card.jsx b/src/menu/components/card/cardcellcomponent/dragaction/card.jsx index 1950e40..bff2d66 100644 --- a/src/menu/components/card/cardcellcomponent/dragaction/card.jsx +++ b/src/menu/components/card/cardcellcomponent/dragaction/card.jsx @@ -17,7 +17,7 @@ const QrCode = asyncComponent(() => import('@/components/qrcode')) const MarkColumn = asyncIconComponent(() => import('@/menu/components/table/normal-table/columns/markcolumn')) -const Card = ({ id, cardIds, fields, card, moveCard, findCard, editCard, delCard, copyCard, changeStyle, updateMarks }) => { +const Card = ({ id, fields, card, moveCard, findCard, editCard, delCard, copyCard, changeStyle, updateMarks }) => { const originalIndex = findCard(id).index const [{ isDragging }, drag] = useDrag({ item: { type: 'action', id, originalIndex }, @@ -29,13 +29,13 @@ accept: 'action', canDrop: () => true, drop({ id: draggedId }) { - if (!draggedId) return - if (!cardIds.includes(draggedId)) return + if (!draggedId || draggedId === id) return - if (draggedId !== id) { - const { index: overIndex } = findCard(id) - moveCard(draggedId, overIndex) - } + const { index: originIndex } = findCard(draggedId) + if (originIndex === -1) return + + const { index: overIndex } = findCard(id) + moveCard(draggedId, overIndex) }, }) diff --git a/src/menu/components/card/cardcellcomponent/dragaction/index.jsx b/src/menu/components/card/cardcellcomponent/dragaction/index.jsx index f6b4da6..3c2561c 100644 --- a/src/menu/components/card/cardcellcomponent/dragaction/index.jsx +++ b/src/menu/components/card/cardcellcomponent/dragaction/index.jsx @@ -87,8 +87,6 @@ deleteMenu(card) } - let cardIds = cards.map(card => card.uuid) - const [, drop] = useDrop({ accept: 'action', drop(item) { @@ -106,7 +104,6 @@ <Action id={card.uuid} key={card.uuid} - cardIds={cardIds} card={card} moveCard={moveCard} editCard={editCard} @@ -122,7 +119,6 @@ <Card id={card.uuid} key={card.uuid} - cardIds={cardIds} card={card} fields={fields} moveCard={moveCard} diff --git a/src/menu/components/card/cardcellcomponent/index.jsx b/src/menu/components/card/cardcellcomponent/index.jsx index d7aea51..953b4fa 100644 --- a/src/menu/components/card/cardcellcomponent/index.jsx +++ b/src/menu/components/card/cardcellcomponent/index.jsx @@ -467,6 +467,10 @@ onOk() { let _elements = elements.filter(item => item.uuid !== card.uuid) + if (card.eleType === 'button') { + MKEmitter.emit('delButtons', [card.uuid]) + } + _this.setState({ elements: _elements }, () => { diff --git a/src/menu/components/card/cardcomponent/index.jsx b/src/menu/components/card/cardcomponent/index.jsx index f99c712..891d87f 100644 --- a/src/menu/components/card/cardcomponent/index.jsx +++ b/src/menu/components/card/cardcomponent/index.jsx @@ -17,7 +17,6 @@ class CardBoxComponent extends Component { static propTpyes = { offset: PropTypes.any, // 鍋忕Щ閲� - MenuType: PropTypes.any, // 鑿滃崟绫诲瀷 cards: PropTypes.object, // 鍗$墖琛岄厤缃俊鎭� card: PropTypes.object, // 鍗$墖閰嶇疆淇℃伅 deleteElement: PropTypes.func, // 鍗$墖鍒犻櫎 @@ -51,9 +50,9 @@ } shouldComponentUpdate (nextProps, nextState) { - const { cards, MenuType } = this.props + const { cards } = this.props - return !is(fromJS(cards), fromJS(nextProps.cards)) || !is(fromJS(this.state), fromJS(nextState)) || MenuType !== nextProps.MenuType + return !is(fromJS(cards), fromJS(nextProps.cards)) || !is(fromJS(this.state), fromJS(nextState)) } /** @@ -205,7 +204,7 @@ } render() { - const { cards, MenuType, offset } = this.props + const { cards, offset } = this.props const { card, elements, side, settingVisible, dict } = this.state let _style = {...card.style} @@ -226,11 +225,11 @@ <Popover overlayClassName="mk-popover-control-wrap" mouseLeaveDelay={0.2} mouseEnterDelay={0.2} content={ <div className="mk-popover-control"> <Icon className="plus" title="娣诲姞鍏冪礌" onClick={this.addElement} type="plus" /> - {MenuType !== 'billPrint' ? <Icon className="plus" title="娣诲姞鎸夐挳" onClick={this.addButton} type="plus-square" /> : null} + <Icon className="plus" title="娣诲姞鎸夐挳" onClick={this.addButton} type="plus-square" /> <Icon className="edit" type="edit" onClick={() => this.setState({settingVisible: true})} /> <Icon className="style" title="璋冩暣鏍峰紡" onClick={this.changeStyle} type="font-colors" /> {cards.subtype === 'propcard' ? <Icon className="close" title="鍒犻櫎鍗$墖" type="delete" onClick={() => this.props.deleteElement(card)} /> : null} - {MenuType !== 'billPrint' && card.setting.type === 'multi' ? <Switch size="small" onClick={this.changeSide} defaultChecked /> : null} + {card.setting.type === 'multi' ? <Switch size="small" onClick={this.changeSide} defaultChecked /> : null} </div> } trigger="hover"> <Icon type="tool" /> @@ -251,7 +250,6 @@ <SettingForm dict={dict} cards={cards} - MenuType={MenuType} setting={card.setting} inputSubmit={this.settingSubmit} wrappedComponentRef={(inst) => this.settingRef = inst} diff --git a/src/menu/components/card/cardcomponent/settingform/index.jsx b/src/menu/components/card/cardcomponent/settingform/index.jsx index 6899fb0..6e52747 100644 --- a/src/menu/components/card/cardcomponent/settingform/index.jsx +++ b/src/menu/components/card/cardcomponent/settingform/index.jsx @@ -6,7 +6,6 @@ class SettingForm extends Component { static propTpyes = { - MenuType: PropTypes.any, // 鑿滃崟绫诲瀷 dict: PropTypes.object, // 瀛楀吀椤� cards: PropTypes.object, // 鍗$墖闆� setting: PropTypes.object, // 鏁版嵁婧愰厤缃� @@ -39,7 +38,7 @@ } render() { - const { setting, cards, MenuType } = this.props + const { setting, cards } = this.props const { getFieldDecorator } = this.props.form const formItemLayout = { @@ -75,7 +74,7 @@ })(<InputNumber min={1} max={24} precision={0} onPressEnter={this.handleSubmit}/>)} </Form.Item> </Col> - {MenuType !== 'billPrint' ? <Col span={12}> + <Col span={12}> <Form.Item label={ <Tooltip placement="topLeft" title="閫夋嫨澶嶅紡鍗℃椂锛屽彲閰嶇疆榧犳爣鎮诞鏃剁殑鏄剧ず淇℃伅銆�"> <Icon type="question-circle" /> @@ -91,8 +90,8 @@ </Radio.Group> )} </Form.Item> - </Col> : null} - {MenuType !== 'billPrint' && this.state.type === 'multi' ? <Col span={12}> + </Col> + {this.state.type === 'multi' ? <Col span={12}> <Form.Item label={ <Tooltip placement="topLeft" title="澶嶅紡鍗$墖榧犳爣鎮诞淇℃伅鐨勫姩鐢绘晥鏋溿��"> <Icon type="question-circle" /> diff --git a/src/menu/components/card/data-card/index.jsx b/src/menu/components/card/data-card/index.jsx index 7b76158..57b3102 100644 --- a/src/menu/components/card/data-card/index.jsx +++ b/src/menu/components/card/data-card/index.jsx @@ -89,6 +89,7 @@ columns: [], scripts: [], action: [], + btnlog: [], subcards: subcards } this.setState({ @@ -287,7 +288,6 @@ } render() { - const { menu } = this.props const { card } = this.state let offset = 0 @@ -307,9 +307,9 @@ <NormalHeader defaultshow="hidden" config={card} updateComponent={this.updateComponent}/> <Popover overlayClassName="mk-popover-control-wrap" mouseLeaveDelay={0.2} mouseEnterDelay={0.2} content={ <div className="mk-popover-control"> - {menu && menu.MenuType !== 'billPrint' ? <Icon className="plus" title="娣诲姞鎼滅储" onClick={this.addSearch} type="plus-circle" /> : null} - {menu && menu.MenuType !== 'billPrint' ? <Icon className="plus" title="娣诲姞鎸夐挳" onClick={this.addButton} type="plus-square" /> : null} - {menu ? <WrapComponent MenuType={menu.MenuType} config={card} updateConfig={this.updateComponent} /> : null} + <Icon className="plus" title="娣诲姞鎼滅储" onClick={this.addSearch} type="plus-circle" /> + <Icon className="plus" title="娣诲姞鎸夐挳" onClick={this.addButton} type="plus-square" /> + <WrapComponent config={card} updateConfig={this.updateComponent} /> <Icon className="style" title="璋冩暣鏍峰紡" onClick={this.changeStyle} type="font-colors" /> <Icon className="close" title="鍒犻櫎缁勪欢" type="delete" onClick={() => this.props.deletecomponent(card.uuid)} /> <SettingComponent config={card} updateConfig={this.updateComponent} /> @@ -318,7 +318,7 @@ <Icon type="tool" /> </Popover> <ActionComponent config={card} setSubConfig={this.setSubConfig} updateaction={this.updateComponent}/> - {card.subcards.map((subcard, index) => (<CardComponent key={subcard.uuid} offset={!index ? offset : 0} MenuType={menu ? menu.MenuType : ''} cards={card} card={subcard} updateElement={this.updateCard} deleteElement={this.deleteCard}/>))} + {card.subcards.map((subcard, index) => (<CardComponent key={subcard.uuid} offset={!index ? offset : 0} cards={card} card={subcard} updateElement={this.updateCard} deleteElement={this.deleteCard}/>))} <div style={{clear: 'both'}}></div> {card.wrap.pagestyle !== 'switch' && card.setting.laypage === 'true' ? <Pagination total={85} size="small" showTotal={total => `鍏� ${total} 鏉} pageSize={20} defaultCurrent={1}/> : null} </div> diff --git a/src/menu/components/card/data-card/wrapsetting/index.jsx b/src/menu/components/card/data-card/wrapsetting/index.jsx index 3f448f5..b55aef2 100644 --- a/src/menu/components/card/data-card/wrapsetting/index.jsx +++ b/src/menu/components/card/data-card/wrapsetting/index.jsx @@ -11,7 +11,6 @@ class DataSource extends Component { static propTpyes = { config: PropTypes.any, - MenuType: PropTypes.any, updateConfig: PropTypes.func } @@ -51,7 +50,7 @@ } render () { - const { config, MenuType } = this.props + const { config } = this.props const { visible, dict, wrap } = this.state return ( @@ -72,7 +71,6 @@ dict={dict} wrap={wrap} config={config} - MenuType={MenuType} inputSubmit={this.verifySubmit} wrappedComponentRef={(inst) => this.verifyRef = inst} /> diff --git a/src/menu/components/card/data-card/wrapsetting/settingform/index.jsx b/src/menu/components/card/data-card/wrapsetting/settingform/index.jsx index f1690da..035ceab 100644 --- a/src/menu/components/card/data-card/wrapsetting/settingform/index.jsx +++ b/src/menu/components/card/data-card/wrapsetting/settingform/index.jsx @@ -6,7 +6,6 @@ class SettingForm extends Component { static propTpyes = { - MenuType: PropTypes.any, // 鑿滃崟绫诲瀷 dict: PropTypes.object, // 瀛楀吀椤� config: PropTypes.object, // 鍗$墖琛屼俊鎭� wrap: PropTypes.object, // 鏁版嵁婧愰厤缃� @@ -54,7 +53,7 @@ } render() { - const { wrap, config, MenuType } = this.props + const { wrap, config } = this.props const { getFieldDecorator } = this.props.form const { roleList } = this.state @@ -133,7 +132,7 @@ )} </Form.Item> </Col> : null} - {MenuType !== 'billPrint' && config.subtype === 'datacard' ? <Col span={12}> + {config.subtype === 'datacard' ? <Col span={12}> <Form.Item label={ <Tooltip placement="topLeft" title="鏁版嵁婧愪腑閫夋嫨鍒嗛〉鏃舵湁鏁堛��"> <Icon type="question-circle" /> @@ -150,7 +149,7 @@ )} </Form.Item> </Col> : null} - {MenuType !== 'billPrint' && config.subtype !== 'tablecard' ? <Col span={12}> + {config.subtype !== 'tablecard' ? <Col span={12}> <Form.Item label="鍗$墖灞炴��"> {getFieldDecorator('cardType', { initialValue: wrap.cardType || '' @@ -222,7 +221,7 @@ })(<InputNumber min={100} max={2000} precision={0} onPressEnter={this.handleSubmit} />)} </Form.Item> </Col> : null} - {MenuType === 'billPrint' && config.subtype === 'propcard' ? <Col span={12}> + {config.subtype === 'propcard' ? <Col span={12}> <Form.Item label={ <Tooltip placement="topLeft" title="閫夋嫨绫诲瀷涓恒�婇〉鐪�/椤佃剼銆嬫椂锛屾墦鍗扮殑姣忛〉閲岄兘浼氬甫鏈夎缁勪欢銆�"> <Icon type="question-circle" /> @@ -239,7 +238,7 @@ )} </Form.Item> </Col> : null} - {MenuType !== 'billPrint' ? <Col span={12}> + <Col span={12}> <Form.Item label="榛戝悕鍗�"> {getFieldDecorator('blacklist', { initialValue: wrap.blacklist || [] @@ -255,7 +254,7 @@ </Select> )} </Form.Item> - </Col> : null} + </Col> </Row> </Form> </div> diff --git a/src/menu/components/card/prop-card/index.jsx b/src/menu/components/card/prop-card/index.jsx index 0c69a7f..5462bb8 100644 --- a/src/menu/components/card/prop-card/index.jsx +++ b/src/menu/components/card/prop-card/index.jsx @@ -88,6 +88,7 @@ columns: [], scripts: [], subcards: subcards, + btnlog: [], } this.setState({ card: _card diff --git a/src/menu/components/card/table-card/index.jsx b/src/menu/components/card/table-card/index.jsx index cb727ce..6f572c1 100644 --- a/src/menu/components/card/table-card/index.jsx +++ b/src/menu/components/card/table-card/index.jsx @@ -80,7 +80,8 @@ headerStyle: { fontSize: '16px', borderBottomWidth: '1px', borderBottomColor: '#e8e8e8' }, columns: [], scripts: [], - subcards: subcards + subcards: subcards, + btnlog: [], } this.setState({ diff --git a/src/menu/components/chart/antv-bar/chartcompile/formconfig.jsx b/src/menu/components/chart/antv-bar/chartcompile/formconfig.jsx index 3b709ed..3a2ded3 100644 --- a/src/menu/components/chart/antv-bar/chartcompile/formconfig.jsx +++ b/src/menu/components/chart/antv-bar/chartcompile/formconfig.jsx @@ -6,9 +6,8 @@ /** * @description 鑾峰彇鍥捐〃瑙嗗浘閰嶇疆琛ㄥ崟 * @param {object} card // 鍥捐〃瀵硅薄 - * @param {Array} MenuType // 鑿滃崟绫诲瀷 */ -export function getBaseForm (card, MenuType) { +export function getBaseForm (card) { let menulist = sessionStorage.getItem('fstMenuList') if (menulist) { try { @@ -75,7 +74,6 @@ initVal: card.blacklist || [], multi: true, required: false, - forbid: MenuType === 'billPrint', options: roleList }, { @@ -85,7 +83,6 @@ initVal: card.linkmenu || [], tooltip: '鍦ㄤ娇鐢ㄦ煴褰㈠浘涓旀湭鍚敤鑷畾涔夎缃椂鏈夋晥銆�', required: false, - forbid: MenuType === 'billPrint', options: menulist } ] @@ -96,7 +93,7 @@ * @param {object} card // 鍥捐〃瀵硅薄 * @param {Array} columns // 鏄剧ず鍒� */ -export function getOptionForm (card, columns, MenuType) { +export function getOptionForm (card, columns) { let shapes = [] if (card.chartType === 'line') { diff --git a/src/menu/components/chart/antv-bar/chartcompile/index.jsx b/src/menu/components/chart/antv-bar/chartcompile/index.jsx index c91f174..97c1471 100644 --- a/src/menu/components/chart/antv-bar/chartcompile/index.jsx +++ b/src/menu/components/chart/antv-bar/chartcompile/index.jsx @@ -16,7 +16,6 @@ class LineChartDrawerForm extends Component { static propTpyes = { - MenuType: PropTypes.any, dict: PropTypes.object, plot: PropTypes.object, config: PropTypes.object, @@ -147,7 +146,7 @@ } showDrawer = () => { - const { config, MenuType } = this.props + const { config } = this.props let fieldName = {} config.columns.forEach(col => { @@ -167,8 +166,8 @@ datatype: config.plot.datatype || 'query', fieldName: fieldName, plot: fromJS(config.plot).toJS(), - baseFormlist: getBaseForm(config.plot, MenuType), - formlist: getOptionForm(config.plot, config.columns, MenuType) + baseFormlist: getBaseForm(config.plot), + formlist: getOptionForm(config.plot, config.columns) }) } diff --git a/src/menu/components/chart/antv-bar/index.jsx b/src/menu/components/chart/antv-bar/index.jsx index 84c616b..04946db 100644 --- a/src/menu/components/chart/antv-bar/index.jsx +++ b/src/menu/components/chart/antv-bar/index.jsx @@ -84,7 +84,8 @@ scripts: [], search: [], action: [], - plot: _plot + plot: _plot, + btnlog: [], } this.setState({ card: _card @@ -823,7 +824,6 @@ } render() { - const { menu } = this.props const { card } = this.state return ( @@ -831,9 +831,9 @@ <NormalHeader config={card} updateComponent={this.updateComponent}/> <Popover overlayClassName="mk-popover-control-wrap" mouseLeaveDelay={0.2} mouseEnterDelay={0.2} content={ <div className="mk-popover-control"> - {menu && menu.MenuType !== 'billPrint' ? <Icon className="plus" title="娣诲姞鎼滅储" onClick={this.addSearch} type="plus-circle" /> : null} - {menu && menu.MenuType !== 'billPrint' ? <Icon className="plus" title="娣诲姞鎸夐挳" onClick={this.addButton} type="plus-square" /> : null} - {menu ? <ChartCompileForm config={card} MenuType={menu.MenuType} dict={this.state.dict} plotchange={this.updateComponent}/> : null} + <Icon className="plus" title="娣诲姞鎼滅储" onClick={this.addSearch} type="plus-circle" /> + <Icon className="plus" title="娣诲姞鎸夐挳" onClick={this.addButton} type="plus-square" /> + <ChartCompileForm config={card} dict={this.state.dict} plotchange={this.updateComponent}/> <Icon className="style" title="璋冩暣鏍峰紡" onClick={this.changeStyle} type="font-colors" /> <Icon className="close" title="delete" type="delete" onClick={() => this.props.deletecomponent(card.uuid)} /> <SettingComponent config={card} updateConfig={this.updateComponent}/> @@ -841,11 +841,11 @@ } trigger="hover"> <Icon type="tool" /> </Popover> - {menu && menu.MenuType !== 'billPrint' ? <ActionComponent + <ActionComponent type="chart" config={card} updateaction={this.updateComponent} - /> : null} + /> <div className="canvas" id={card.uuid}></div> </div> ) diff --git a/src/menu/components/chart/antv-pie/chartcompile/formconfig.jsx b/src/menu/components/chart/antv-pie/chartcompile/formconfig.jsx index 8a248f0..7a79ef7 100644 --- a/src/menu/components/chart/antv-pie/chartcompile/formconfig.jsx +++ b/src/menu/components/chart/antv-pie/chartcompile/formconfig.jsx @@ -6,9 +6,8 @@ /** * @description 鑾峰彇鍥捐〃瑙嗗浘閰嶇疆琛ㄥ崟 * @param {object} card // 鍥捐〃瀵硅薄 - * @param {Array} MenuType // 鑿滃崟绫诲瀷 */ -export function getBaseForm (card, MenuType) { +export function getBaseForm (card) { let menulist = sessionStorage.getItem('fstMenuList') if (menulist) { try { @@ -75,7 +74,6 @@ initVal: card.blacklist || [], multi: true, required: false, - forbid: MenuType === 'billPrint', options: roleList }, { @@ -85,7 +83,6 @@ initVal: card.linkmenu || [], tooltip: '鍙屽嚮楗煎浘锛屼細鎵撳紑鍏宠仈鐨勮彍鍗曘��', required: false, - forbid: MenuType === 'billPrint', options: menulist } ] diff --git a/src/menu/components/chart/antv-pie/chartcompile/index.jsx b/src/menu/components/chart/antv-pie/chartcompile/index.jsx index 9a48a8a..ad68d31 100644 --- a/src/menu/components/chart/antv-pie/chartcompile/index.jsx +++ b/src/menu/components/chart/antv-pie/chartcompile/index.jsx @@ -16,7 +16,6 @@ class LineChartDrawerForm extends Component { static propTpyes = { - MenuType: PropTypes.any, dict: PropTypes.object, plot: PropTypes.object, config: PropTypes.object, @@ -51,13 +50,13 @@ } showDrawer = () => { - const { config, MenuType } = this.props + const { config } = this.props this.setState({ visible: true, view: 'normal', plot: fromJS(config.plot).toJS(), - baseFormlist: getBaseForm(config.plot, MenuType), + baseFormlist: getBaseForm(config.plot), formlist: getOptionForm(config.plot, config.columns) }) } diff --git a/src/menu/components/chart/antv-pie/index.jsx b/src/menu/components/chart/antv-pie/index.jsx index c210c31..11dd20f 100644 --- a/src/menu/components/chart/antv-pie/index.jsx +++ b/src/menu/components/chart/antv-pie/index.jsx @@ -71,7 +71,8 @@ scripts: [], search: [], action: [], - plot: _plot + plot: _plot, + btnlog: [], } this.props.updateConfig(_card) this.setState({ @@ -395,7 +396,6 @@ } render() { - const { menu } = this.props const { card } = this.state return ( @@ -403,8 +403,8 @@ <NormalHeader config={card} updateComponent={this.updateComponent}/> <Popover overlayClassName="mk-popover-control-wrap" mouseLeaveDelay={0.2} mouseEnterDelay={0.2} content={ <div className="mk-popover-control"> - {menu && menu.MenuType !== 'billPrint' ? <Icon className="plus" title="娣诲姞鎼滅储" onClick={this.addSearch} type="plus-circle" /> : null} - {menu ? <ChartCompileForm config={card} MenuType={menu.MenuType} dict={this.state.dict} plotchange={this.updateComponent}/> : null} + <Icon className="plus" title="娣诲姞鎼滅储" onClick={this.addSearch} type="plus-circle" /> + <ChartCompileForm config={card} dict={this.state.dict} plotchange={this.updateComponent}/> <Icon className="style" title="璋冩暣鏍峰紡" onClick={this.changeStyle} type="font-colors" /> <Icon className="close" title="delete" type="delete" onClick={() => this.props.deletecomponent(card.uuid)} /> <SettingComponent config={card} updateConfig={this.updateComponent}/> diff --git a/src/menu/components/search/main-search/dragsearch/card.jsx b/src/menu/components/search/main-search/dragsearch/card.jsx index 2b56c5b..47a7283 100644 --- a/src/menu/components/search/main-search/dragsearch/card.jsx +++ b/src/menu/components/search/main-search/dragsearch/card.jsx @@ -20,14 +20,12 @@ accept: 'search', canDrop: () => true, drop: ({ id: draggedId }) => { - if (!draggedId) return - if (draggedId !== id) { - const { index: originIndex } = findCard(draggedId) - if (originIndex === -1) return + if (!draggedId || draggedId === id) return + const { index: originIndex } = findCard(draggedId) + if (originIndex === -1) return - const { index: overIndex } = findCard(id) - moveCard(draggedId, overIndex) - } + const { index: overIndex } = findCard(id) + moveCard(draggedId, overIndex) }, }) const opacity = isDragging ? 0 : 1 diff --git a/src/menu/components/share/actioncomponent/dragaction/card.jsx b/src/menu/components/share/actioncomponent/dragaction/card.jsx index 88df555..8bdf734 100644 --- a/src/menu/components/share/actioncomponent/dragaction/card.jsx +++ b/src/menu/components/share/actioncomponent/dragaction/card.jsx @@ -14,11 +14,10 @@ const [, drop] = useDrop({ accept: 'action', canDrop: () => true, - drop: () => {}, - hover({ id: draggedId }) { + drop: ({ id: draggedId }) => { if (!draggedId || draggedId === id) return - const { index: originIndex } = findCard(id) + const { index: originIndex } = findCard(draggedId) if (originIndex === -1) return const { index: overIndex } = findCard(id) diff --git a/src/menu/components/share/actioncomponent/index.jsx b/src/menu/components/share/actioncomponent/index.jsx index c2c6d8d..1363c41 100644 --- a/src/menu/components/share/actioncomponent/index.jsx +++ b/src/menu/components/share/actioncomponent/index.jsx @@ -323,14 +323,9 @@ _actionlist = _actionlist.filter(item => item.uuid !== card.uuid) - let delButtons = sessionStorage.getItem('delButtons') - try { - delButtons = JSON.parse(delButtons) - delButtons.push(card.uuid) - } catch { - delButtons = [card.uuid] + if (!card.origin) { + MKEmitter.emit('delButtons', [card.uuid]) } - sessionStorage.setItem('delButtons', JSON.stringify(delButtons)) _this.setState({ actionlist: _actionlist diff --git a/src/menu/components/share/searchcomponent/dragsearch/card.jsx b/src/menu/components/share/searchcomponent/dragsearch/card.jsx index 6d7e365..a23d8e5 100644 --- a/src/menu/components/share/searchcomponent/dragsearch/card.jsx +++ b/src/menu/components/share/searchcomponent/dragsearch/card.jsx @@ -23,7 +23,6 @@ if (!draggedId || draggedId === id) return const { index: originIndex } = findCard(draggedId) - if (originIndex === -1) return const { index: overIndex } = findCard(id) diff --git a/src/menu/components/table/normal-table/columns/editColumn/formconfig.jsx b/src/menu/components/table/normal-table/columns/editColumn/formconfig.jsx index 1ab32f6..4126c3c 100644 --- a/src/menu/components/table/normal-table/columns/editColumn/formconfig.jsx +++ b/src/menu/components/table/normal-table/columns/editColumn/formconfig.jsx @@ -38,13 +38,13 @@ }, { value: 'custom', text: '鑷畾涔夊垪' + }, { + value: 'colspan', + text: '鍚堝苟鍒�' }] if (!card.isSub) { options.push({ - value: 'colspan', - text: '鍚堝苟鍒�' - }, { value: 'action', text: '鎿嶄綔' }) @@ -126,6 +126,7 @@ label: Formdict['model.sort'], initVal: card.IsSort || 'true', required: true, + forbidden: card.isSub, options: [{ value: 'true', text: Formdict['model.true'] diff --git a/src/menu/components/table/normal-table/columns/editColumn/index.jsx b/src/menu/components/table/normal-table/columns/editColumn/index.jsx index d3f4fcd..6725e03 100644 --- a/src/menu/components/table/normal-table/columns/editColumn/index.jsx +++ b/src/menu/components/table/normal-table/columns/editColumn/index.jsx @@ -107,6 +107,13 @@ }) } else if (key === 'field') { this.props.form.setFieldsValue({label: option.props.children}) + if (this.state.type === 'number') { + let decimal = 0 + if (/Decimal/ig.test(option.props.datatype)) { + decimal = +option.props.datatype.replace(/Decimal\(18,/ig, '').replace(')', '') + } + this.props.form.setFieldsValue({decimal}) + } } else if (key === 'format' && value === 'percent') { this.props.form.setFieldsValue({postfix: '%'}) } @@ -140,7 +147,7 @@ if (!formlist) return null formlist.forEach((item, index) => { - if (item.hidden) return + if (item.hidden || item.forbidden) return if (item.type === 'text') { // 鏂囨湰鎼滅储 let rules = [] @@ -213,7 +220,7 @@ getPopupContainer={() => document.getElementById('columnwinter')} > {item.options.map((option, index) => - <Select.Option key={`${option.value || option.field}${index}`} value={option.value || option.field}> + <Select.Option key={`${option.value || option.field}${index}`} datatype={option.datatype || ''} value={option.value || option.field}> {option.text || option.label} </Select.Option> )} diff --git a/src/menu/components/table/normal-table/columns/index.jsx b/src/menu/components/table/normal-table/columns/index.jsx index 093fb0d..5041887 100644 --- a/src/menu/components/table/normal-table/columns/index.jsx +++ b/src/menu/components/table/normal-table/columns/index.jsx @@ -41,7 +41,9 @@ return !is(fromJS(this.props.column), fromJS(nextProps.column)) || !is(fromJS(this.props.fields), fromJS(nextProps.fields)) || - this.props.index !== nextProps.index + this.props.index !== nextProps.index || + this.props.rowSpan !== nextProps.rowSpan || + this.props.colSpan !== nextProps.colSpan } render() { @@ -66,10 +68,10 @@ ) } else if (column) { return ( - <th {...restProps}> + <th {...restProps} key={column.uuid}> <Popover overlayClassName="mk-popover-control-wrap" mouseLeaveDelay={0.2} mouseEnterDelay={0.2} content={ <div className="mk-popover-control"> - {column && column.type === 'custom' ? + {column && ['custom', 'colspan'].includes(column.type) ? <Icon className="plus" title="娣诲姞" type="plus" onClick={() => this.props.addElement(column)} /> : null } <Icon className="edit" title="缂栬緫" type="edit" onClick={() => this.props.editColumn(column)} /> @@ -153,7 +155,7 @@ return ( <td style={{...style, minWidth: column.Width || 100}} className={className}> {column.field} - {column.marks && column.marks.length > 0 ? <Icon className="profile" type="ant-design"/> : null} + {column.marks && column.marks.length ? <Icon className="profile" type="ant-design"/> : null} </td> ) } else { @@ -175,6 +177,7 @@ state = { dict: localStorage.getItem('lang') !== 'en-US' ? zhCN : enUS, data: [{uuid: Utils.getuuid()}], + refresh: false, // 寮哄埗鍒锋柊 columns: [], fields: [], lineMarks: [] @@ -225,29 +228,21 @@ }) } + loopCol = (columns, col) => { + return columns.map(column => { + if (column.type === 'colspan') { + column.subcols = this.loopCol(column.subcols, col) + } + if (column.uuid === col.uuid) { + return col + } + return column + }) + } + updateCol = (col, action) => { let _columns = fromJS(this.state.columns).toJS() - - if (col.isSub) { - _columns = _columns.map(column => { - if (column.type === 'colspan') { - column.subcols = column.subcols.map(item => { - if (item.uuid === col.uuid) { - return col - } - return item - }) - } - return column - }) - } else { - _columns = _columns.map(column => { - if (column.uuid === col.uuid) { - return col - } - return column - }) - } + _columns = this.loopCol(_columns, col) this.setState({ columns: _columns, @@ -333,20 +328,18 @@ this.setState({card: null}) } + loopDelCol = (columns, col) => { + return columns.filter(column => { + if (column.type === 'colspan') { + column.subcols = this.loopDelCol(column.subcols, col) + } + return column.uuid !== col.uuid + }) + } + deleteCol = (col) => { let _columns = fromJS(this.state.columns).toJS() - - if (col.isSub) { - _columns = _columns.map(column => { - if (column.type !== 'colspan') return column - if (column.subcols && column.subcols.length > 0) { - column.subcols = column.subcols.filter(item => item.uuid !== col.uuid) - } - return column - }) - } else { - _columns = _columns.filter(column => column.uuid !== col.uuid) - } + _columns = this.loopDelCol(_columns, col) this.setState({ columns: _columns @@ -387,6 +380,35 @@ document.body.removeChild(oInput) } + handlecolumns = (columns, fields, config, isSub) => { + return columns.map((col, index) => { + return { + title: col.label, + dataIndex: col.uuid, + align: col.Align, + sorter: !isSub && col.IsSort === 'true', + onCell: () => ({ + column: col, + width: col.Width, + config: config, + upComponent: this.updateCol + }), + onHeaderCell: () => ({ + index: isSub ? undefined : index, + column: col, + fields: fields, + align: col.Align, + moveCol: this.moveCol, + updateCol: this.updateCol, + addElement: this.addElement, + editColumn: this.editColumn, + deleteCol: this.deleteCol, + }), + children: col.subcols && col.subcols.length ? this.handlecolumns(col.subcols, fields, config, true) : null, + } + }) + } + render() { const { config } = this.props const { fields, card, lineMarks, dict } = this.state @@ -399,51 +421,7 @@ } } - const columns = this.state.columns.map((col, index) => { - return { - title: col.label, - dataIndex: col.field, - align: col.Align, - sorter: col.IsSort === 'true', - onCell: () => ({ - column: col, - width: col.Width, - config: config, - upComponent: this.updateCol - }), - children: col.subcols && col.subcols.length > 0 ? col.subcols.map(cell => ({ - align: col.Align, - title: cell.label, - key: cell.uuid, - onCell: () => ({ - column: cell, - width: cell.Width, - config: config, - upComponent: this.updateCol - }), - onHeaderCell: () => ({ - column: cell, - fields: fields, - align: cell.Align, - updateCol: this.updateCol, - addElement: this.addElement, - editColumn: this.editColumn, - deleteCol: this.deleteCol, - }) - })) : null, - onHeaderCell: () => ({ - index, - column: col, - fields: fields, - align: col.Align, - moveCol: this.moveCol, - updateCol: this.updateCol, - addElement: this.addElement, - editColumn: this.editColumn, - deleteCol: this.deleteCol, - }) - } - }) + const columns = this.handlecolumns(this.state.columns, fields, config) return ( <div className={`normal-table-columns ${config.setting.laypage} ${config.wrap.tableType}`}> @@ -454,12 +432,12 @@ <DndProvider> <Table rowKey="uuid" + rowClassName="editable-row" bordered={config.wrap.bordered !== 'false'} components={components} dataSource={this.state.data} rowSelection={config.wrap.tableType ? { type: 'radio' } : null} columns={columns} - rowClassName="editable-row" pagination={{ current: 1, pageSize: 10, diff --git a/src/menu/components/table/normal-table/index.jsx b/src/menu/components/table/normal-table/index.jsx index 0a90b78..d6c9c0c 100644 --- a/src/menu/components/table/normal-table/index.jsx +++ b/src/menu/components/table/normal-table/index.jsx @@ -73,7 +73,8 @@ { origin: true, uuid: Utils.getuuid(), Align: 'left', label: 'label2', field: '', Hide: 'false', IsSort: 'true', type: 'text', Width: 120 }, { origin: true, uuid: Utils.getuuid(), Align: 'left', label: 'label3', field: '', Hide: 'false', IsSort: 'true', type: 'text', Width: 120 }, ], - scripts: [] + scripts: [], + btnlog: [], } this.setState({ @@ -266,7 +267,6 @@ } render() { - const { menu } = this.props const { card } = this.state return ( @@ -275,9 +275,9 @@ <Popover overlayClassName="mk-popover-control-wrap" mouseLeaveDelay={0.2} mouseEnterDelay={0.2} content={ <div className="mk-popover-control"> <Icon className="plus" title="娣诲姞鍒�" onClick={this.addColumns} type="plus" /> - {menu && menu.MenuType !== 'billPrint' ? <Icon className="plus" title="娣诲姞鎼滅储" onClick={this.addSearch} type="plus-circle" /> : null} - {menu && menu.MenuType !== 'billPrint' ? <Icon className="plus" title="娣诲姞鎸夐挳" onClick={this.addButton} type="plus-square" /> : null} - {menu ? <WrapComponent config={card} MenuType={menu.MenuType} updateConfig={this.updateComponent} /> : null} + <Icon className="plus" title="娣诲姞鎼滅储" onClick={this.addSearch} type="plus-circle" /> + <Icon className="plus" title="娣诲姞鎸夐挳" onClick={this.addButton} type="plus-square" /> + <WrapComponent config={card} updateConfig={this.updateComponent} /> <Icon className="style" title="璋冩暣鏍峰紡" onClick={this.changeStyle} type="font-colors" /> <Icon className="close" title="鍒犻櫎缁勪欢" type="delete" onClick={() => this.props.deletecomponent(card.uuid)} /> <SettingComponent config={card} updateConfig={this.updateComponent} /> diff --git a/src/menu/components/table/normal-table/wrapsetting/index.jsx b/src/menu/components/table/normal-table/wrapsetting/index.jsx index be4a8c4..4a1fbd1 100644 --- a/src/menu/components/table/normal-table/wrapsetting/index.jsx +++ b/src/menu/components/table/normal-table/wrapsetting/index.jsx @@ -11,7 +11,6 @@ class DataSource extends Component { static propTpyes = { config: PropTypes.any, - MenuType: PropTypes.any, updateConfig: PropTypes.func } @@ -51,7 +50,7 @@ } render () { - const { config, MenuType } = this.props + const { config } = this.props const { visible, dict, wrap } = this.state return ( @@ -72,7 +71,6 @@ dict={dict} wrap={wrap} config={config} - MenuType={MenuType} inputSubmit={this.verifySubmit} wrappedComponentRef={(inst) => this.verifyRef = inst} /> diff --git a/src/menu/components/table/normal-table/wrapsetting/settingform/index.jsx b/src/menu/components/table/normal-table/wrapsetting/settingform/index.jsx index 35ec31f..88719bc 100644 --- a/src/menu/components/table/normal-table/wrapsetting/settingform/index.jsx +++ b/src/menu/components/table/normal-table/wrapsetting/settingform/index.jsx @@ -6,7 +6,6 @@ class SettingForm extends Component { static propTpyes = { - MenuType: PropTypes.any, // 鑿滃崟绫诲瀷 dict: PropTypes.object, // 瀛楀吀椤� config: PropTypes.object, // 鍗$墖琛屼俊鎭� wrap: PropTypes.object, // 鏁版嵁婧愰厤缃� @@ -54,7 +53,7 @@ } render() { - const { wrap, MenuType, config } = this.props + const { wrap, config } = this.props const { getFieldDecorator } = this.props.form const { roleList } = this.state @@ -159,7 +158,7 @@ )} </Form.Item> </Col> - {MenuType !== 'billPrint' ? <Col span={12}> + <Col span={12}> <Form.Item label="榛戝悕鍗�"> {getFieldDecorator('blacklist', { initialValue: wrap.blacklist || [] @@ -175,7 +174,7 @@ </Select> )} </Form.Item> - </Col> : null} + </Col> </Row> </Form> </div> diff --git a/src/menu/datasource/verifycard/settingform/index.jsx b/src/menu/datasource/verifycard/settingform/index.jsx index 3cfed31..3a761bb 100644 --- a/src/menu/datasource/verifycard/settingform/index.jsx +++ b/src/menu/datasource/verifycard/settingform/index.jsx @@ -190,7 +190,7 @@ } render() { - const { setting, menu, columns, config } = this.props + const { setting, columns, config } = this.props const { getFieldDecorator } = this.props.form const { interType, modules, useMSearch, laypage, supModule, usefulFields } = this.state @@ -386,7 +386,7 @@ </Radio.Group>)} </Form.Item> </Col> : null} - {menu.MenuType !== 'billPrint' ? <Col span={8}> + <Col span={8}> <Form.Item label={ <Tooltip placement="topLeft" title={'璇ョ粍浠跺鏋滃彈鍏朵粬缁勪欢鎺у埗锛岃閫夐」鐩稿簲鐨勭粍浠讹紝娌℃湁鏃堕�夆�滄棤鈥濄��'}> <Icon type="question-circle" /> @@ -405,8 +405,8 @@ <Cascader options={modules} onChange={this.changeSupModule} expandTrigger="hover" placeholder="" /> )} </Form.Item> - </Col> : null} - {menu.MenuType !== 'billPrint' && config.pageable ? <Col span={8}> + </Col> + {config.pageable ? <Col span={8}> <Form.Item label="鍒嗛〉"> {getFieldDecorator('laypage', { initialValue: setting.laypage || 'true' @@ -418,7 +418,7 @@ )} </Form.Item> </Col> : null} - {menu.MenuType !== 'billPrint' && config.pageable && laypage !== 'false' ? <Col span={8}> + {config.pageable && laypage !== 'false' ? <Col span={8}> <Form.Item label={ <Tooltip placement="topLeft" title="閫夋嫨鍒嗛〉鏃舵湁鏁堛��"> <Icon type="question-circle" /> @@ -436,8 +436,8 @@ })(<InputNumber min={1} max={500} precision={0} />)} </Form.Item> </Col> : null} - {/* 1銆佷笉鍒嗛〉涓斾笉瀛樺湪涓婄骇妯″潡 2銆佹墦鍗版椂 */} - {((!config.pageable || (config.pageable && laypage === 'false')) && (!supModule || supModule.length === 0 || supModule[0] === 'empty')) || menu.MenuType === 'billPrint' ? <Col span={8}> + {/* 1銆佷笉鍒嗛〉涓斾笉瀛樺湪涓婄骇妯″潡 */} + {(!config.pageable || (config.pageable && laypage === 'false')) && (!supModule || supModule.length === 0 || supModule[0] === 'empty') ? <Col span={8}> <Form.Item label={ <Tooltip placement="topLeft" title={'鍒濆鍖栧姞杞芥椂锛屾槸鍚︿笌鍏朵粬缁勪欢涓�鍚屽姞杞芥暟鎹紝娉細浠呭湪浣跨敤绯荤粺鍑芥暟锛屼笖鍒濆鍖栧姞杞芥暟鎹椂鏈夋晥锛屽垎椤佃姹傛椂鏃犳晥銆�'}> <Icon type="question-circle" /> @@ -454,7 +454,7 @@ )} </Form.Item> </Col> : null} - {menu.MenuType !== 'billPrint' ? <Col span={8}> + <Col span={8}> <Form.Item label={ <Tooltip placement="topLeft" title={'浼樺厛浣跨敤鍚岀骇鐨勬悳绱㈡潯浠剁粍浠讹紝鍚岀骇鎼滅储涓嶅瓨鍦ㄦ椂锛屼緷娆″悜涓婇�夊彇锛屼笌褰撳墠缁勪欢鐨勬悳绱㈡潯浠朵竴鍚岀敤浣滄暟鎹繃婊わ紙褰撳墠缁勪欢鐨勬悳绱㈡潯浠朵紭鍏堬級銆�'}> <Icon type="question-circle" /> @@ -470,8 +470,8 @@ </Radio.Group> )} </Form.Item> - </Col> : null} - {menu.MenuType !== 'billPrint' && useMSearch === 'true' ? <Col span={8}> + </Col> + {useMSearch === 'true' ? <Col span={8}> <Form.Item label={ <Tooltip placement="topLeft" title={'澶栧眰鎼滅储鏉′欢鏀瑰彉鏃讹紝鏄惁鍒锋柊褰撳墠缁勪欢鏁版嵁銆�'}> <Icon type="question-circle" /> @@ -488,7 +488,7 @@ )} </Form.Item> </Col> : null} - {menu.MenuType !== 'billPrint' ? <Col span={8}> + <Col span={8}> <Form.Item label="鍒濆鍖栨暟鎹�"> {getFieldDecorator('onload', { initialValue: setting.onload || 'true' @@ -499,7 +499,7 @@ </Radio.Group> )} </Form.Item> - </Col> : null} + </Col> </Row> </Form> </div> diff --git a/src/menu/popview/controller.jsx b/src/menu/popview/controller.jsx new file mode 100644 index 0000000..1029431 --- /dev/null +++ b/src/menu/popview/controller.jsx @@ -0,0 +1,70 @@ +import React, {Component} from 'react' +import { is, fromJS } from 'immutable' + +import MKEmitter from '@/utils/events.js' +import PopConfig from '@/menu/popview' + +class PopviewController extends Component { + state = { + btn: null, + config: null, + visible: false + } + + shouldComponentUpdate (nextProps, nextState) { + return !is(fromJS(this.state), fromJS(nextState)) + } + + componentDidMount () { + MKEmitter.addListener('changePopview', this.initConfig) + } + + /** + * @description 缁勪欢閿�姣侊紝娓呴櫎state鏇存柊锛屾竻闄ゅ揩鎹烽敭璁剧疆 + */ + componentWillUnmount () { + this.setState = () => { + return + } + MKEmitter.removeListener('changePopview', this.initConfig) + } + + initConfig = (config, btn) => { + this.setState({ + visible: true, + config: fromJS(config).toJS(), + btn: fromJS(btn).toJS() + }) + } + + handleBack = () => { + this.setState({ + visible: false, + config: null, + btn: null + }) + } + + handleSave = (modal) => { + const { config, btn } = this.state + MKEmitter.emit('submitModal', config, btn, modal) + + this.setState({ + visible: false, + config: null, + btn: null + }) + } + + render () { + const { config, btn, visible } = this.state + + if (!visible) return null + + return ( + <PopConfig btn={btn} componentConfig={config} handleBack={this.handleBack} handleSave={this.handleSave}/> + ) + } +} + +export default PopviewController \ No newline at end of file diff --git a/src/menu/popview/index.jsx b/src/menu/popview/index.jsx new file mode 100644 index 0000000..471b71a --- /dev/null +++ b/src/menu/popview/index.jsx @@ -0,0 +1,523 @@ +import React, { Component } from 'react' +import PropTypes from 'prop-types' +import { connect } from 'react-redux' +import { DndProvider } from 'react-dnd' +import { is, fromJS } from 'immutable' +import moment from 'moment' +import HTML5Backend from 'react-dnd-html5-backend' +import { notification, Modal, Collapse, Card, Switch, Button } from 'antd' + +import Api from '@/api' +import Utils from '@/utils/utils.js' +import zhCN from '@/locales/zh-CN/mob.js' +import enUS from '@/locales/en-US/mob.js' +import asyncComponent from '@/utils/asyncComponent' +import { modifyCustomMenu } from '@/store/action' + +import './index.scss' + +const { Panel } = Collapse +const { confirm } = Modal + +const Header = asyncComponent(() => import('@/menu/header')) +const SourceWrap = asyncComponent(() => import('@/menu/modelsource')) +const MenuShell = asyncComponent(() => import('@/menu/menushell')) +const BgController = asyncComponent(() => import('@/menu/bgcontroller')) +const PaddingController = asyncComponent(() => import('@/menu/padcontroller')) +const StyleController = asyncComponent(() => import('@/menu/stylecontroller')) +const ModalController = asyncComponent(() => import('@/menu/modalconfig/controller')) +const TableComponent = asyncComponent(() => import('@/templates/sharecomponent/tablecomponent')) + +sessionStorage.setItem('isEditState', 'true') + +class MenuDesign extends Component { + static propTpyes = { + btn: PropTypes.object, + handleSave: PropTypes.func, + handleBack: PropTypes.func + } + + state = { + dict: localStorage.getItem('lang') !== 'en-US' ? zhCN : enUS, + MenuType: '', + MenuId: '', + MenuNo: '', + tableFields: [], + delButtons: [], + activeKey: 'basedata', + menuloading: false, + oriConfig: null, + openEdition: '', + config: null, + } + + UNSAFE_componentWillMount() { + const { btn } = this.props + + this.setState({ + MenuId: btn.uuid, + }, () => { + this.getMenuParam() + }) + } + + shouldComponentUpdate (nextProps, nextState) { + return !is(fromJS(this.state), fromJS(nextState)) + } + + /** + * @description 缁勪欢閿�姣侊紝娓呴櫎state鏇存柊 + */ + componentWillUnmount () { + this.setState = () => { + return + } + } + + closeView = () => { + const { oriConfig, config } = this.state + + if (!config) { + window.close() + return + } + + let _config = fromJS(config).toJS() + delete _config.tableFields + + if (!is(fromJS(oriConfig), fromJS(_config))) { + confirm({ + title: '閰嶇疆宸蹭慨鏀癸紝鏀惧純淇濆瓨鍚楋紵', + content: '', + onOk() { + window.close() + }, + onCancel() {} + }) + } else { + window.close() + } + } + + getMenuParam = () => { + const { MenuId, MenuType } = this.state + + let param = { + func: 'sPC_Get_LongParam', + MenuID: MenuId + } + + Api.getSystemConfig(param).then(result => { + if (result.status) { + let config = null + + try { + config = JSON.parse(window.decodeURIComponent(window.atob(result.LongParam))) + } catch (e) { + console.warn('Parse Failure') + config = null + } + + if (!config) { + config = { + version: 1.0, + uuid: MenuId, + MenuID: MenuId, + Template: 'CustomPage', + enabled: false, + tables: [], + components: [], + style: { + backgroundColor: '#ffffff', backgroundImage: '', + paddingTop: '16px', paddingBottom: '80px', paddingLeft: '16px', paddingRight: '16px' + }, + MenuType: MenuType + } + } else { + config.uuid = MenuId + config.MenuID = MenuId + config.MenuType = config.MenuType || MenuType + } + + this.setState({ + oriConfig: config, + config: fromJS(config).toJS(), + openEdition: result.open_edition || '', + }) + + this.getRoleFields() + } else { + notification.warning({ + top: 92, + message: result.message, + duration: 5 + }) + } + }) + } + + getMenuMessage = () => { + const { config } = this.state + let buttons = [] + let _sort = 1 + + let traversal = (components) => { + components.forEach(item => { + if (item.type === 'tabs') { + item.subtabs.forEach(tab => { + traversal(tab.components) + }) + } else if (item.type === 'card' || (item.type === 'table' && item.subtype === 'tablecard')) { + 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.subcards.forEach(card => { + card.elements && card.elements.forEach(cell => { + if (cell.eleType !== 'button') return + + buttons.push(`select '${cell.uuid}' as menuid, '${item.name + '-' + cell.label}' as menuname, '${_sort * 10}' as Sort`) + _sort++ + }) + card.backElements && card.backElements.forEach(cell => { + if (cell.eleType !== 'button') return + + buttons.push(`select '${cell.uuid}' as menuid, '${item.name + '-' + cell.label}' as menuname, '${_sort * 10}' as Sort`) + _sort++ + }) + }) + } else if (item.type === 'line' || item.type === 'bar') { + item.action && item.action.forEach(btn => { + 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 => { + if (btn.origin) return + 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++ + }) + }) + } + }) + } + + traversal(config.components) + + return buttons + } + + filterConfig = (components) => { + return components.map(item => { + if (item.type === 'tabs') { + item.subtabs.forEach(tab => { + tab.components = this.filterConfig(tab.components) + }) + } else if (item.type === 'table' && item.subtype === 'normaltable') { + item.search = item.search.filter(a => !a.origin) + item.action = item.action.filter(a => !a.origin) + item.cols = item.cols.filter(a => !a.origin) + } + return item + }) + } + + submitConfig = () => { + const { openEdition } = this.state + let config = fromJS(this.state.config).toJS() + + if (config.cacheUseful === 'true' && !config.cacheTime) { + notification.warning({ + top: 92, + message: '璇峰畬鍠勮彍鍗曞熀鏈俊鎭紒', + duration: 5 + }) + return + } + + config.components = this.filterConfig(config.components) + + if (config.enabled && this.verifyConfig()) { + config.enabled = false + } + + let _config = fromJS(config).toJS() + delete _config.tableFields + + let param = { + func: 'sPC_TrdMenu_AddUpt', + FstID: _config.fstMenuId || '', + SndID: _config.parentId, + ParentID: _config.parentId, + MenuID: _config.uuid, + MenuNo: _config.MenuNo || '', + EasyCode: _config.easyCode || '', + Template: 'CustomPage', + MenuName: _config.MenuName || '', + PageParam: JSON.stringify({Template: 'CustomPage', OpenType: 'newtab'}), + LongParam: window.btoa(window.encodeURIComponent(JSON.stringify(_config))), + LText: '', + LTexttb: '' + } + + param.LText = Utils.formatOptions(param.LText) + param.timestamp = moment().format('YYYY-MM-DD HH:mm:ss') + param.secretkey = Utils.encrypt(param.LText, param.timestamp) + + if (openEdition) { // 鐗堟湰绠$悊 + param.open_edition = openEdition + } + + let btnParam = { // 娣诲姞鑿滃崟鎸夐挳 + func: 'sPC_Button_AddUpt', + Type: 40, // 娣诲姞鑿滃崟涓嬬殑鎸夐挳type涓�40锛屾寜閽笅鐨勬寜閽畉ype涓�60 + ParentID: _config.uuid, + MenuNo: _config.MenuNo, + Template: 'CustomPage', + PageParam: '', + LongParam: '', + LText: [] + } + + 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') + btnParam.secretkey = Utils.encrypt(btnParam.LText, btnParam.timestamp) + + this.setState({ + menuloading: true + }, () => { + new Promise(resolve => { + resolve(true) + }).then(res => { + if (!res) return + + 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 { + 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, + config: {...config, components: []} + }, () => { + this.setState({ + config: {...this.state.config, components: this.state.oriConfig.components} + }) + }) + notification.success({ + top: 92, + message: '淇濆瓨鎴愬姛', + duration: 2 + }) + } else { + this.setState({ + menuloading: false + }) + notification.warning({ + top: 92, + message: res.message, + duration: 5 + }) + } + }) + }) + } + + getRoleFields = () => { + Api.getSystemConfig({func: 'sPC_Get_Roles_sModular'}).then(res => { + if (res.status) { + let _permFuncField = [] + let _sysRoles = [] + + if (res.Roles && res.Roles.length > 0) { + _sysRoles = res.Roles.map(role => { + return { + uuid: Utils.getuuid(), + value: role.RoleID, + text: role.RoleName + } + }) + } + + if (res.sModular && res.sModular.length > 0) { + res.sModular.forEach(field => { + if (field.ModularNo) { + _permFuncField.push(field.ModularNo) + } + }) + _permFuncField = _permFuncField.sort() + } + + sessionStorage.setItem('sysRoles', JSON.stringify(_sysRoles)) + sessionStorage.setItem('permFuncField', JSON.stringify(_permFuncField)) + } + }) + } + + onEnabledChange = () => { + const { config } = this.state + + if (!config.enabled && this.verifyConfig(true)) { + return + } + + this.setState({ + config: {...config, enabled: !config.enabled} + }) + } + + verifyConfig = (show) => { + const { config } = this.state + let error = '' + + config.components.forEach(item => { + if (error) return + if (item.subtype === 'propcard' && item.wrap.datatype === 'static') return + + if (item.setting) { + if (item.setting.interType === 'system' && item.setting.execute !== 'false' && !item.setting.dataresource) { + error = `缁勪欢銆�${item.name}銆嬫湭璁剧疆鏁版嵁婧愶紒` + } else if (item.setting.interType === 'system' && item.setting.execute === 'false' && item.scripts.length === 0) { + error = `缁勪欢銆�${item.name}銆嬫湭璁剧疆鏁版嵁婧愶紒` + } else if (item.setting.interType && !item.setting.primaryKey) { + error = `缁勪欢銆�${item.name}銆嬫湭璁剧疆涓婚敭锛乣 + } + } + if (item.type === 'bar' || item.type === 'line' || item.type === 'pie') { + if (!item.plot.Xaxis) { + error = `缁勪欢銆�${item.name}銆嬪浘琛ㄥ瓧娈靛皻鏈缃紒` + } + } + }) + + if (show && error) { + notification.warning({ + top: 92, + message: error, + duration: 5 + }) + } + + return error + } + + // 鏇存柊閰嶇疆淇℃伅 + updateConfig = (config) => { + this.setState({ + config: config + }) + + this.props.modifyCustomMenu(config) + } + + /** + * @description 鏇存柊甯哥敤琛ㄤ俊鎭紝蹇嵎娣诲姞鍚庢洿鏂伴厤缃俊鎭� + */ + updatetable = (config, fields) => { + const { tableFields } = this.state + + config.tableFields = fields ? fields : tableFields + + this.setState({ + tableFields: fields ? fields : tableFields, + config + }) + + this.props.modifyCustomMenu(config) + } + + render () { + const { activeKey, MenuType, dict, config, menuloading } = this.state + + return ( + <div className="pc-menu-view" id="view"> + <Header /> + <DndProvider backend={HTML5Backend}> + <div className="menu-body"> + <div className="menu-setting"> + <Collapse accordion activeKey={activeKey} bordered={false} onChange={(key) => this.setState({activeKey: key})}> + {/* 鍩烘湰淇℃伅 */} + <Panel header={dict['mob.basemsg']} key="basedata"> + {/* 琛ㄥ悕娣诲姞 */} + {config ? <TableComponent config={config} updatetable={this.updatetable}/> : null} + </Panel> + {/* 缁勪欢娣诲姞 */} + <Panel header={dict['mob.component']} key="component"> + <SourceWrap MenuType={MenuType} /> + </Panel> + <Panel header={'鑳屾櫙'} key="background"> + {config ? <BgController config={config} updateConfig={this.updateConfig} /> : null} + </Panel> + <Panel header={'鍐呰竟璺�'} key="padding"> + {config ? <PaddingController config={config} updateConfig={this.updateConfig} /> : null} + </Panel> + </Collapse> + </div> + <div className={'menu-view ' + (menuloading ? 'saving' : '')}> + <Card title={ + <div> {config && config.MenuName} </div> + } bordered={false} extra={ + <div> + {config ? <Switch className="big" checkedChildren={dict['mob.enable']} unCheckedChildren={dict['mob.disable']} checked={config.enabled} onChange={this.onEnabledChange} /> : null} + <Button type="primary" onClick={this.submitConfig} loading={menuloading}>{dict['mob.save']}</Button> + <Button type="default" onClick={this.closeView}>{dict['mob.return']}</Button> + </div> + } style={{ width: '100%' }}> + {config && config.components ? <MenuShell menu={config} handleList={this.updateConfig} /> : null} + </Card> + </div> + </div> + </DndProvider> + <StyleController /> + <ModalController /> + </div> + ) + } +} + +const mapStateToProps = () => { + return {} +} + +const mapDispatchToProps = (dispatch) => { + return { + modifyCustomMenu: (customMenu) => dispatch(modifyCustomMenu(customMenu)) + } +} + +export default connect(mapStateToProps, mapDispatchToProps)(MenuDesign) \ No newline at end of file diff --git a/src/menu/popview/index.scss b/src/menu/popview/index.scss new file mode 100644 index 0000000..7dcf66e --- /dev/null +++ b/src/menu/popview/index.scss @@ -0,0 +1,303 @@ +.modal-form-board { + position: fixed; + z-index: 1070; + padding-top: 48px; + top: 0px; + left: 0px; + right: 0px; + bottom: 0px; + background: rgba(0, 0, 0, 0.35); + display: flex; + .tools { + flex: 1; + background: #ffffff; + border-right: 1px solid #d9d9d9; + height: 100%; + overflow-y: auto; + padding-bottom: 30px; + .ant-collapse-borderless { + background-color: #ffffff; + } + .ant-collapse-item { + border: 0; + } + .ant-input-search { + margin-top: 10px; + } + .ant-collapse-item.ant-collapse-item-active { + border-bottom: 1px solid #d9d9d9; + } + .ant-collapse .ant-collapse-header { + padding: 11px 16px 10px 40px; + border-bottom: 1px solid #d9d9d9; + background: #1890ff; + color: #ffffff; + } + .ant-collapse-content-box { + .ant-form-item { + margin-bottom: 10px; + .ant-form-item-label { + text-align: left; + height: 25px; + line-height: 25px; + } + } + .ant-btn { + margin-bottom: 10px; + } + } + .search-element { + padding-top: 10px; + li { + padding: 0px 16px 10px; + div { + cursor: move; + } + } + } + .tables { + .ant-select-selection-selected-value { + opacity: 0.4!important; + } + } + .ant-list { + margin-top: 20px; + .ant-list-item { + display: -webkit-box; + padding-right: 20px; + position: relative; + padding-left: 5px; + overflow: hidden; + text-overflow: ellipsis; + -webkit-line-clamp: 2; + -webkit-box-orient: vertical; + width: 100%; + .anticon { + position: absolute; + top: 0px; + right: 0px; + padding: 3px 3px 10px 10px; + cursor: pointer; + } + .bottom-mask { + position: absolute; + width: 100%; + height: 8px; + bottom: 0; + left: 0; + background: #ffffff; + border-radius: 8px; + } + } + } + } + .tools::-webkit-scrollbar { + width: 4px; + } + .tools::-webkit-scrollbar-thumb { + border-radius: 5px; + box-shadow: inset 0 0 5px rgba(0, 0, 0, 0.08); + background: rgba(0, 0, 0, 0.08); + } + .tools::-webkit-scrollbar-track { + box-shadow: inset 0 0 5px rgba(0, 0, 0, 0.05); + border-radius: 3px; + border: 1px solid rgba(0, 0, 0, 0.07); + background: rgba(0, 0, 0, 0); + } + .setting { + position: relative; + width: calc(100vw - 235px); + height: 100%; + overflow-y: hidden; + background: #ffffff; + .ant-card-head { + min-height: 44px; + } + .ant-card-head-title { + padding: 5px 0; + color: #1890ff; + } + .ant-card-extra { + padding: 5px 0; + button { + margin-left: 20px; + } + } + .ant-card-body { + position: relative; + padding: 0; + .ant-modal-content { + max-width: 95%; + margin: 0 auto; + margin-top: 30px; + .ant-modal-header { + position: relative; + z-index: 10; + background: transparent; + min-height: 50px; + } + .ant-modal-close { + opacity: 0.3; + } + .ant-modal-footer { + position: relative; + button { + opacity: 0.3; + } + } + .action-mask { + position: absolute; + top: 0px; + left: 0px; + right: 0px; + bottom: 0px; + } + } + .modal-form { + padding: 0px 24px; + min-height: 87px; + .group-title { + position: relative; + min-height: 22px; + margin-bottom: 10px; + padding-top: 10px; + border-bottom: 1px solid #e8e8e8; + + span { + padding: 0 5px 5px; + } + } + > .ant-row { + min-height: 120px; + } + .ant-row .ant-col-6 { + padding: 0 12px!important; + } + .ant-row.ant-form-item .ant-col { + padding: 0; + } + .textarea2, .textarea4 { + padding-left: 7px; + } + .page-card { + position: relative; + background: #ffffff; + border-radius: 2px; + margin-bottom: 15px; + .ant-form-item { + cursor: move; + display: flex; + margin-bottom: 0px; + .ant-form-item-label { + overflow: visible; + position: relative; + height: 40px; + label { + width: 100%; + cursor: move; + overflow: hidden; + display: inline-block; + text-overflow: ellipsis; + white-space: nowrap; + } + } + .ant-form-item-control-wrapper { + position: relative; + .ant-select { + width: 100%; + margin-top: 4px; + } + .ant-calendar-picker { + width: 100%; + margin-top: 4px; + } + .ant-input-number { + width: 100%; + margin-top: 4px; + } + } + .ant-form-item-control-wrapper::after { + content: ''; + position: absolute; + top: 0; + left: 0; + right: 0; + bottom: 0; + opacity: 0; + z-index: 1; + } + .ant-col-cuslabel { + width: 10.5%; + } + .ant-col-cuswrap { + width: 89.5%; + } + } + } + .ant-calendar-picker { + min-width: 100px!important; + } + } + > .anticon-setting { + position: absolute; + font-size: 16px; + right: 5px; + top: 5px; + padding: 10px; + cursor: pointer; + } + .paste-Icon { + position: absolute; + font-size: 16px; + right: 15px; + top: 65px; + } + } + } + .setting { + overflow-y: auto; + } + .setting::-webkit-scrollbar { + width: 7px; + } + .setting::-webkit-scrollbar-thumb { + border-radius: 5px; + box-shadow: inset 0 0 5px rgba(0, 0, 0, 0.13); + background: rgba(0, 0, 0, 0.13); + } + .setting::-webkit-scrollbar-track { + box-shadow: inset 0 0 5px rgba(0, 0, 0, 0.05); + border-radius: 3px; + border: 1px solid rgba(0, 0, 0, 0.07); + background: rgba(0, 0, 0, 0); + } +} + +.modal-fields { + .ant-modal { + top: 50px; + padding-bottom: 5px; + .ant-modal-body { + max-height: calc(100vh - 190px); + overflow-y: auto; + .ant-empty { + margin: 15vh 8px; + } + } + .ant-modal-body::-webkit-scrollbar { + width: 7px; + } + .ant-modal-body::-webkit-scrollbar-thumb { + border-radius: 5px; + box-shadow: inset 0 0 5px rgba(0, 0, 0, 0.13); + background: rgba(0, 0, 0, 0.13); + } + .ant-modal-body::-webkit-scrollbar-track { + box-shadow: inset 0 0 5px rgba(0, 0, 0, 0.05); + border-radius: 3px; + border: 1px solid rgba(0, 0, 0, 0.07); + background: rgba(0, 0, 0, 0); + } + } +} \ No newline at end of file diff --git a/src/tabviews/custom/components/share/normalTable/index.jsx b/src/tabviews/custom/components/share/normalTable/index.jsx index b227d1d..e377073 100644 --- a/src/tabviews/custom/components/share/normalTable/index.jsx +++ b/src/tabviews/custom/components/share/normalTable/index.jsx @@ -391,9 +391,7 @@ } UNSAFE_componentWillMount () { - const { menuType, memberLevel, setting, fields } = this.props - let columns = fromJS(this.props.columns).toJS() - let _columns = [] + const { menuType, memberLevel, setting, fields, columns } = this.props let radio = 5 // 铏氬寲姣斾緥 let _format = false // 鏄惁铏氬寲澶勭悊 let rowspans = [] @@ -408,70 +406,46 @@ } } - columns.forEach(item => { - if (item.hidden === true || item.Hide === 'true') return - let cell = null - - if (item.type === 'colspan') { - cell = {title: item.label, children: []} - - item.subcols.forEach(col => { - if (col.rowspan === 'true') { - rowspans.push(col.field) + let getColumns = (cols) => { + return cols.map(item => { + let cell = null + + if (item.type === 'colspan') { + cell = { title: item.label, align: item.Align } + cell.children = getColumns(item.subcols) + } else { + if (item.rowspan === 'true') { + rowspans.push(item.field) } if (_format && !Math.floor(Math.random() * radio)) { - col.blur = true + item.blur = true } - - if (col.marks && col.marks.length === 0) { - col.marks = '' + + if (item.marks && item.marks.length === 0) { + item.marks = '' } - - cell.children.push({ - align: col.Align, - title: col.label, - dataIndex: col.field || col.uuid, - key: col.uuid, - width: col.Width || 120, + + cell = { + align: item.Align, + dataIndex: item.uuid, + title: item.label, + sorter: item.field && item.IsSort === 'true', + width: item.Width || 120, onCell: record => ({ record, - col, - config: col.type === 'custom' ? {setting, columns: fields} : null, + col: item, + config: item.type === 'custom' || item.type === 'action' ? {setting, columns: fields} : null, triggerLink: this.triggerLink, updateStatus: this.updateStatus }) - }) - }) - } else { - if (item.rowspan === 'true') { - rowspans.push(item.field) + } } - if (_format && !Math.floor(Math.random() * radio)) { - item.blur = true - } + + return cell + }) + } - if (item.marks && item.marks.length === 0) { - item.marks = '' - } - - cell = { - align: item.Align, - dataIndex: item.field || item.uuid, - title: item.label, - sorter: item.field && item.IsSort === 'true', - width: item.Width || 120, - onCell: record => ({ - record, - col: item, - config: item.type === 'custom' || item.type === 'action' ? {setting, columns: fields} : null, - triggerLink: this.triggerLink, - updateStatus: this.updateStatus - }) - } - } - - _columns.push(cell) - }) + let _columns = getColumns(columns) if (rowspans.length === 0) { rowspans = null diff --git a/src/tabviews/custom/index.jsx b/src/tabviews/custom/index.jsx index 04b727a..89ed828 100644 --- a/src/tabviews/custom/index.jsx +++ b/src/tabviews/custom/index.jsx @@ -234,21 +234,7 @@ }) } if (item.type === 'table' && item.subtype === 'normaltable') { - item.cols = item.cols.map(col => { - if (!col.blacklist || col.blacklist.length === 0) return col - if (col.blacklist.filter(v => roleId.indexOf(v) > -1).length > 0) { - col.Hide = 'true' - } - - if (col.Hide !== 'true' && col.linkmenu && col.linkmenu.length > 0) { - let menu_id = col.linkmenu.slice(-1)[0] - col.linkThdMenu = permMenus.filter(m => m.MenuID === menu_id)[0] || '' - } else { - col.linkThdMenu = '' - } - - return col - }) + item.cols = this.getCols(item.cols, roleId, permMenus) } // 鏉冮檺杩囨护 @@ -301,13 +287,14 @@ }) }) } else if (item.type === 'table' && item.subtype === 'normaltable') { - item.cols.forEach(col => { - if (col.type !== 'action') return + item.cols = item.cols.filter(col => { + if (col.type !== 'action') return true col.elements = col.elements.filter(cell => { cell.logLabel = item.name + '-' + cell.label cell.Ot = 'requiredSgl' return permAction[cell.uuid] }) + return col.elements.length !== 0 }) } } else { @@ -338,6 +325,31 @@ }) } + getCols = (cols, roleId, permMenus) => { + return cols.filter(col => { + if (col.blacklist && col.blacklist.filter(v => roleId.indexOf(v) > -1).length > 0) { + return false + } else if (col.Hide === 'true') { + return false + } + if (col.type === 'colspan') { + col.subcols = this.getCols(col.subcols || [], roleId, permMenus) + if (col.subcols.length === 0) { + return false + } + } + + if (col.linkmenu && col.linkmenu.length > 0) { + let menu_id = col.linkmenu.slice(-1)[0] + col.linkThdMenu = permMenus.filter(m => m.MenuID === menu_id)[0] || '' + } else { + col.linkThdMenu = '' + } + + return true + }) + } + // 鏍煎紡鍖栭粯璁よ缃� formatSetting = (components, params, mainSearch, inherit) => { return components.map(component => { diff --git a/src/templates/comtableconfig/index.jsx b/src/templates/comtableconfig/index.jsx index e23bbbf..a6d10ff 100644 --- a/src/templates/comtableconfig/index.jsx +++ b/src/templates/comtableconfig/index.jsx @@ -202,13 +202,11 @@ }) } - getFuncNames = (data, funcNames, tableNames) => { + getFuncNames = (data) => { + let funcNames = [] + let tableNames = [] + data.forEach(item => { - // if (item.subfuncs) { - // this.getFuncNames(item.subfuncs, funcNames, tableNames) - // return - // } - if (item.tableName) { tableNames.push(item.tableName) } @@ -220,6 +218,8 @@ funcNames.push({func: item.callbackFunc, label: item.label || ''}) } }) + + tableNames = Array.from(new Set(tableNames)) return { func: funcNames, @@ -354,297 +354,252 @@ }) } - new Promise(resolve => { - // let deffers = [] - // _config.funcs.forEach(item => { - // if (item.type === 'tab') { - // let deffer = new Promise(resolve => { - // Api.getSystemConfig({ - // func: 'sPC_Get_LongParam', - // MenuID: item.linkTab - // }).then(result => { - // if (result.status && result.LongParam) { - // let _LongParam = '' + // 淇濆瓨鏃跺垹闄ら厤缃被鍨嬶紝system 銆乽ser + delete _config.type + delete _config.isAdd + + let _LongParam = '' + + try { + _LongParam = window.btoa(window.encodeURIComponent(JSON.stringify(_config))) + } catch (e) { + notification.warning({ + top: 92, + message: '缂栬瘧閿欒', + duration: 5 + }) + this.setState({ + menucloseloading: false, + menuloading: false + }) + return + } + + let _sort = 0 + let btntabs = [] + + let btnParam = { // 娣诲姞鑿滃崟鎸夐挳 + func: 'sPC_Button_AddUpt', + Type: 40, // 娣诲姞鑿滃崟涓嬬殑鎸夐挳type涓�40锛屾寜閽笅鐨勬寜閽畉ype涓�60 + ParentID: menu.MenuID, + MenuNo: _config.MenuNo, + Template: _config.Template || '', + PageParam: '', + LongParam: '', + LText: [] + } + + _config.action.forEach(item => { + _sort++ + if (item.OpenType === 'popview') { + btntabs.push({ + uuid: item.uuid, + linkTab: item.linkTab, + label: item.label, + sort: _sort + }) + } - // if (result.LongParam) { - // try { - // _LongParam = JSON.parse(window.decodeURIComponent(window.atob(result.LongParam))) - // } catch (e) { - // console.warn('Parse Failure') - // _LongParam = '' - // } - // } + btnParam.LText.push(`select '${item.uuid}' as menuid, '${item.label}' as menuname, '${_sort * 10}' as Sort`) + }) + + btnParam.LText = btnParam.LText.join(' union all ') + btnParam.LText = Utils.formatOptions(btnParam.LText) + btnParam.timestamp = moment().format('YYYY-MM-DD HH:mm:ss') + btnParam.secretkey = Utils.encrypt(btnParam.LText, btnParam.timestamp) - // if (_LongParam) { - // item.menuNo = _LongParam.tabNo || '' - // item.subfuncs = _LongParam.funcs || [] - // } - // } - // resolve() - // }) - // }) + let tabParam = { // 娣诲姞鑿滃崟tab椤� + func: 'sPC_sMenusTab_AddUpt', + MenuID: menu.MenuID + } - // deffers.push(deffer) - // } - // }) + let _LText = [] - // if (deffers.length === 0) { - // resolve() - // } else { - // Promise.all(deffers).then(() => { - // resolve() - // }) - // } - resolve() - }).then(() => { - // 淇濆瓨鏃跺垹闄ら厤缃被鍨嬶紝system 銆乽ser - delete _config.type - delete _config.isAdd - - let _LongParam = '' - - try { - _LongParam = window.btoa(window.encodeURIComponent(JSON.stringify(_config))) - } catch (e) { - notification.warning({ - top: 92, - message: '缂栬瘧閿欒', - duration: 5 - }) - this.setState({ - menucloseloading: false, - menuloading: false - }) - return - } - - let _sort = 0 - let btntabs = [] - - let btnParam = { // 娣诲姞鑿滃崟鎸夐挳 - func: 'sPC_Button_AddUpt', - Type: 40, // 娣诲姞鑿滃崟涓嬬殑鎸夐挳type涓�40锛屾寜閽笅鐨勬寜閽畉ype涓�60 - ParentID: menu.MenuID, - MenuNo: _config.MenuNo, - Template: _config.Template || '', - PageParam: '', - LongParam: '', - LText: [] - } - - _config.action.forEach(item => { + btntabs.forEach(item => { + _LText.push(`select '${item.uuid}' as MenuID ,'${item.linkTab}' as Tabid,'${item.label}' as TabName ,'${item.sort * 10}' as Sort`) + }) + _config.tabgroups.forEach(group => { + group.sublist.forEach(item => { _sort++ - if (item.OpenType === 'popview') { - btntabs.push({ - uuid: item.uuid, - linkTab: item.linkTab, - label: item.label, - sort: _sort + _LText.push(`select '${menu.MenuID}' as MenuID ,'${item.linkTab}' as Tabid,'${item.label}' as TabName ,'${_sort * 10}' as Sort`) + }) + }) + + _LText = _LText.join(' union all ') + + // 娓呯┖鑿滃崟涓嬪叧鑱旂殑鏍囩 + if (!_LText) { + _LText = `select '${menu.MenuID}' as MenuID ,'' as Tabid,'' as TabName ,'0' as Sort` + } + + tabParam.LText = Utils.formatOptions(_LText) + tabParam.timestamp = moment().format('YYYY-MM-DD HH:mm:ss') + tabParam.secretkey = Utils.encrypt(tabParam.LText, tabParam.timestamp) + + let _vals = this.getFuncNames(_config.funcs) + + let param = { + func: 'sPC_TrdMenu_AddUpt', + FstID: _config.fstMenuId, + SndID: _config.ParentId, + ParentID: _config.ParentId, + MenuID: menu.MenuID, + MenuNo: _config.MenuNo, + EasyCode: _config.easyCode || '', + Template: _config.Template || '', + MenuName: _config.MenuName, + PageParam: JSON.stringify({...menu.PageParam, Template: _config.Template, OpenType: _config.OpenType}), + LongParam: _LongParam, + LText: _vals.func.map(item => `select '${menu.MenuID}' as MenuID,'${item.func}' as ProcName,'${item.label}' as MenuName`), + LTexttb: _vals.table.map(item => `select '${menu.MenuID}' as MenuID,'${item}' as tbName`) + } + + if (menu.menuSort) { // 鑿滃崟鏂板缓鏃惰缃帓搴� + param.Sort = menu.menuSort + } + + param.LText = param.LText.join(' union all ') + param.LText = Utils.formatOptions(param.LText) + param.LTexttb = param.LTexttb.join(' union all ') + param.LTexttb = Utils.formatOptions(param.LTexttb) + param.timestamp = moment().format('YYYY-MM-DD HH:mm:ss') + param.secretkey = Utils.encrypt(param.LText, param.timestamp) + + if (openEdition) { // 鐗堟湰绠$悊 + param.open_edition = openEdition + } + + // 鏈夋寜閽垨鏍囩鍒犻櫎鏃讹紝鍏堣繘琛屽垹闄ゆ搷浣� + // 鍒犻櫎鎴愬姛鍚庯紝淇濆瓨椤甸潰閰嶇疆 + new Promise(resolve => { + if (delActions.length > 0) { + let deffers = delActions.map(item => { + let _param = { + func: 'sPC_MainMenu_Del', + MenuID: item.card ? item.card.uuid : item.uuid + } + + if (item.type === 'action') { + let _ParentParam = null + + try { + _ParentParam = window.btoa(window.encodeURIComponent(JSON.stringify(item.card))) + } catch (e) { + console.warn('Stringify Failure') + _ParentParam = null + } + + if (_ParentParam) { // 鍒犻櫎鎸夐挳鏃讹紝淇濆瓨鎸夐挳閰嶇疆淇℃伅锛岀敤浜庢仮澶嶆寜閽� + _param.ParentParam = _ParentParam + } + } + + return new Promise(resolve => { + Api.getSystemConfig(_param).then(response => { + resolve(response) + }) }) - } - - btnParam.LText.push(`select '${item.uuid}' as menuid, '${item.label}' as menuname, '${_sort * 10}' as Sort`) - }) - - btnParam.LText = btnParam.LText.join(' union all ') - btnParam.LText = Utils.formatOptions(btnParam.LText) - btnParam.timestamp = moment().format('YYYY-MM-DD HH:mm:ss') - btnParam.secretkey = Utils.encrypt(btnParam.LText, btnParam.timestamp) - - let tabParam = { // 娣诲姞鑿滃崟tab椤� - func: 'sPC_sMenusTab_AddUpt', - MenuID: menu.MenuID - } - - let _LText = [] - - btntabs.forEach(item => { - _LText.push(`select '${item.uuid}' as MenuID ,'${item.linkTab}' as Tabid,'${item.label}' as TabName ,'${item.sort * 10}' as Sort`) - }) - _config.tabgroups.forEach(group => { - group.sublist.forEach(item => { - _sort++ - _LText.push(`select '${menu.MenuID}' as MenuID ,'${item.linkTab}' as Tabid,'${item.label}' as TabName ,'${_sort * 10}' as Sort`) }) - }) - - _LText = _LText.join(' union all ') - - // 娓呯┖鑿滃崟涓嬪叧鑱旂殑鏍囩 - if (!_LText) { - _LText = `select '${menu.MenuID}' as MenuID ,'' as Tabid,'' as TabName ,'0' as Sort` - } - - tabParam.LText = Utils.formatOptions(_LText) - tabParam.timestamp = moment().format('YYYY-MM-DD HH:mm:ss') - tabParam.secretkey = Utils.encrypt(tabParam.LText, tabParam.timestamp) - - let _vals = this.getFuncNames(_config.funcs, [], []) - let _tables = Array.from(new Set(_vals.table)) - - let param = { - func: 'sPC_TrdMenu_AddUpt', - FstID: _config.fstMenuId, - SndID: _config.ParentId, - ParentID: _config.ParentId, - MenuID: menu.MenuID, - MenuNo: _config.MenuNo, - EasyCode: _config.easyCode || '', - Template: _config.Template || '', - MenuName: _config.MenuName, - PageParam: JSON.stringify({...menu.PageParam, Template: _config.Template, OpenType: _config.OpenType}), - LongParam: _LongParam, - LText: _vals.func.map(item => `select '${menu.MenuID}' as MenuID,'${item.func}' as ProcName,'${item.label}' as MenuName`), - LTexttb: _tables.map(item => `select '${menu.MenuID}' as MenuID,'${item}' as tbName`) - } - - if (menu.menuSort) { // 鑿滃崟鏂板缓鏃惰缃帓搴� - param.Sort = menu.menuSort - } - - param.LText = param.LText.join(' union all ') - param.LText = Utils.formatOptions(param.LText) - param.LTexttb = param.LTexttb.join(' union all ') - param.LTexttb = Utils.formatOptions(param.LTexttb) - param.timestamp = moment().format('YYYY-MM-DD HH:mm:ss') - param.secretkey = Utils.encrypt(param.LText, param.timestamp) - - if (openEdition) { // 鐗堟湰绠$悊 - param.open_edition = openEdition - } - - // 鏈夋寜閽垨鏍囩鍒犻櫎鏃讹紝鍏堣繘琛屽垹闄ゆ搷浣� - // 鍒犻櫎鎴愬姛鍚庯紝淇濆瓨椤甸潰閰嶇疆 - new Promise(resolve => { - if (delActions.length > 0) { - let deffers = delActions.map(item => { - let _param = { - func: 'sPC_MainMenu_Del', - MenuID: item.card ? item.card.uuid : item.uuid - } - - if (item.type === 'action') { - let _ParentParam = null - - try { - _ParentParam = window.btoa(window.encodeURIComponent(JSON.stringify(item.card))) - } catch (e) { - console.warn('Stringify Failure') - _ParentParam = null - } - - if (_ParentParam) { // 鍒犻櫎鎸夐挳鏃讹紝淇濆瓨鎸夐挳閰嶇疆淇℃伅锛岀敤浜庢仮澶嶆寜閽� - _param.ParentParam = _ParentParam - } - } - - return new Promise(resolve => { - Api.getSystemConfig(_param).then(response => { - resolve(response) - }) - }) - }) - Promise.all(deffers).then(result => { - let error = null - result.forEach(response => { - if (!response.status) { - error = response - } - }) - - if (error) { - this.setState({ - menuloading: false, - menucloseloading: false - }) - notification.warning({ - top: 92, - message: error.message, - duration: 5 - }) - resolve(false) - } else { - this.setState({ - delActions: [] - }) - resolve(true) + Promise.all(deffers).then(result => { + let error = null + result.forEach(response => { + if (!response.status) { + error = response } }) - } else if (delActions.length === 0) { - resolve(true) - } - }).then(resp => { - if (resp === false) return - if (thawButtons.length > 0) { - let defers = thawButtons.map(item => { - return new Promise((resolve) => { - Api.getSystemConfig({ - func: 'sPC_MainMenu_ReDel', - MenuID: item - }).then(res => { - if (res.status) { - resolve('') - } else { - resolve(res.message) - } - }) - }) - }) - - return Promise.all(defers) - } else { - return true - } - }).then(res => { - if (res === true || res === false) return res - - let msg = res.filter(Boolean)[0] - if (msg) { - notification.warning({ - top: 92, - message: msg, - duration: 5 - }) - return false - } else { - this.setState({ - thawButtons: [] - }) - return true - } - }).then(resp => { - if (resp === false) return - let localParam = fromJS(param).toJS() - Api.getSystemConfig(param).then(response => { - if (response.status) { - this.setState({ - config: _config, - openEdition: response.open_edition || '', - originMenu: fromJS(_config).toJS() - }) - - localParam.func = 'sPC_TrdMenu_AddUpt_For_Local' - delete localParam.LongParam - delete localParam.PageParam - delete localParam.Template - delete localParam.Sort - delete localParam.EasyCode - delete localParam.open_edition - - this.submitAction(btnParam, tabParam, localParam) - } else { + if (error) { this.setState({ menuloading: false, menucloseloading: false }) notification.warning({ top: 92, - message: response.message, + message: error.message, duration: 5 }) + resolve(false) + } else { + this.setState({ + delActions: [] + }) + resolve(true) } }) + } else if (delActions.length === 0) { + resolve(true) + } + }).then(resp => { + if (resp === false) return + + if (thawButtons.length > 0) { + let defers = thawButtons.map(item => { + return new Promise((resolve) => { + Api.getSystemConfig({ + func: 'sPC_MainMenu_ReDel', + MenuID: item + }).then(res => { + if (res.status) { + resolve('') + } else { + resolve(res.message) + } + }) + }) + }) + + return Promise.all(defers) + } else { + return true + } + }).then(res => { + if (res === true || res === false) return res + + let msg = res.filter(Boolean)[0] + if (msg) { + notification.warning({ + top: 92, + message: msg, + duration: 5 + }) + return false + } else { + this.setState({ + thawButtons: [] + }) + return true + } + }).then(resp => { + if (resp === false) return + let localParam = fromJS(param).toJS() + Api.getSystemConfig(param).then(response => { + if (response.status) { + this.setState({ + config: _config, + openEdition: response.open_edition || '', + originMenu: fromJS(_config).toJS() + }) + + localParam.func = 'sPC_TrdMenu_AddUpt_For_Local' + delete localParam.LongParam + delete localParam.PageParam + delete localParam.Template + delete localParam.Sort + delete localParam.EasyCode + delete localParam.open_edition + + this.submitAction(btnParam, tabParam, localParam) + } else { + this.setState({ + menuloading: false, + menucloseloading: false + }) + notification.warning({ + top: 92, + message: response.message, + duration: 5 + }) + } }) }) } diff --git a/src/templates/subtableconfig/index.jsx b/src/templates/subtableconfig/index.jsx index 131aabb..3acb99e 100644 --- a/src/templates/subtableconfig/index.jsx +++ b/src/templates/subtableconfig/index.jsx @@ -275,50 +275,6 @@ _config.enabled = false } - // _config.funcs = [] - - // _config.funcs.push({ - // type: 'view', - // subtype: 'view', - // uuid: _config.uuid, - // intertype: _config.setting.interType || 'system', - // interface: _config.setting.interface || '', - // tableName: _config.setting.tableName || '', - // innerFunc: _config.setting.innerFunc || '', - // outerFunc: _config.setting.outerFunc || '' - // }) - - // _config.action.forEach(item => { - // let tablename = item.OpenType === 'excelIn' ? (item.sheet || '') : (item.sql || '') - - // if (item.OpenType === 'excelOut' && item.intertype === 'system') { - // tablename = _config.setting.tableName || '' - // } - - // if (item.OpenType === 'popview') { - // _config.funcs.push({ - // type: 'tab', - // subtype: 'btn', - // uuid: item.uuid, - // label: item.label, - // linkTab: item.linkTab - // }) - // } else { - // _config.funcs.push({ - // type: 'button', - // subtype: 'btn', - // uuid: item.uuid, - // label: item.label, - // tableName: tablename, - // intertype: item.intertype, - // interface: item.interface || '', - // innerFunc: item.innerFunc || '', - // outerFunc: item.outerFunc || '', - // callbackFunc: item.callbackFunc || '' - // }) - // } - // }) - if (this.state.closeVisible) { // 鏄剧ず鍏抽棴瀵硅瘽妗嗘椂锛屾ā鎬佹涓繚瀛樻寜閽紝鏄剧ず淇濆瓨涓姸鎬� this.setState({ menucloseloading: true @@ -329,251 +285,206 @@ }) } - new Promise(resolve => { - // let deffers = [] - // _config.funcs.forEach(item => { - // if (item.type === 'tab') { - // let deffer = new Promise(resolve => { - // Api.getSystemConfig({ - // func: 'sPC_Get_LongParam', - // MenuID: item.linkTab - // }).then(result => { - // if (result.status && result.LongParam) { - // let _LongParam = '' - - // if (result.LongParam) { - // try { - // _LongParam = JSON.parse(window.decodeURIComponent(window.atob(result.LongParam))) - // } catch (e) { - // console.warn('Parse Failure') - // _LongParam = '' - // } - // } - - // if (_LongParam) { - // item.menuNo = _LongParam.tabNo - // item.subfuncs = _LongParam.funcs || [] - // } - // } - // resolve() - // }) - // }) + // 淇濆瓨鏃跺垹闄ら厤缃被鍨嬶紝system 銆乽ser + delete _config.type + delete _config.isAdd - // deffers.push(deffer) - // } - // }) + let _LongParam = '' - // if (deffers.length === 0) { - // resolve() - // } else { - // Promise.all(deffers).then(() => { - // resolve() - // }) - // } - resolve() - }).then(() => { - // 淇濆瓨鏃跺垹闄ら厤缃被鍨嬶紝system 銆乽ser - delete _config.type - delete _config.isAdd - - let _LongParam = '' - - try { - _LongParam = window.btoa(window.encodeURIComponent(JSON.stringify(_config))) - } catch (e) { - notification.warning({ - top: 92, - message: '缂栬瘧閿欒', - duration: 5 - }) - - this.setState({ - menucloseloading: false, - menuloading: false - }) - return - } - - let btnParam = { - func: 'sPC_Button_AddUpt', - Type: 40, - ParentID: _config.uuid, - MenuNo: _config.tabNo, - Template: 'SubTable', - PageParam: '', - LongParam: '', - LText: [] - } - - let btntabs = [] - - _config.action.forEach((item, index) => { - if (item.OpenType === 'popview') { - btntabs.push(`select '${item.uuid}' as MenuID ,'${item.linkTab}' as Tabid,'${item.label}' as TabName ,'${(index + 1) * 10}' as Sort`) - } - btnParam.LText.push(`select '${item.uuid}' as menuid, '${item.label}' as menuname, '${(index + 1) * 10}' as Sort`) + try { + _LongParam = window.btoa(window.encodeURIComponent(JSON.stringify(_config))) + } catch (e) { + notification.warning({ + top: 92, + message: '缂栬瘧閿欒', + duration: 5 }) - btnParam.LText = btnParam.LText.join(' union all ') - btnParam.LText = Utils.formatOptions(btnParam.LText) - btnParam.timestamp = moment().format('YYYY-MM-DD HH:mm:ss') - btnParam.secretkey = Utils.encrypt(btnParam.LText, btnParam.timestamp) + this.setState({ + menucloseloading: false, + menuloading: false + }) + return + } - let tabParam = { // 娣诲姞鏍囩鎸夐挳tab椤� - func: 'sPC_sMenusTab_AddUpt', - MenuID: _config.uuid, - LText: btntabs.join(' union all ') + let btnParam = { + func: 'sPC_Button_AddUpt', + Type: 40, + ParentID: _config.uuid, + MenuNo: _config.tabNo, + Template: 'SubTable', + PageParam: '', + LongParam: '', + LText: [] + } + + let btntabs = [] + + _config.action.forEach((item, index) => { + if (item.OpenType === 'popview') { + btntabs.push(`select '${item.uuid}' as MenuID ,'${item.linkTab}' as Tabid,'${item.label}' as TabName ,'${(index + 1) * 10}' as Sort`) } + btnParam.LText.push(`select '${item.uuid}' as menuid, '${item.label}' as menuname, '${(index + 1) * 10}' as Sort`) + }) - tabParam.LText = Utils.formatOptions(tabParam.LText) - tabParam.timestamp = moment().format('YYYY-MM-DD HH:mm:ss') - tabParam.secretkey = Utils.encrypt(tabParam.LText, tabParam.timestamp) + btnParam.LText = btnParam.LText.join(' union all ') + btnParam.LText = Utils.formatOptions(btnParam.LText) + btnParam.timestamp = moment().format('YYYY-MM-DD HH:mm:ss') + btnParam.secretkey = Utils.encrypt(btnParam.LText, btnParam.timestamp) - let param = { - func: 'sPC_Tab_AddUpt', - MenuID: _config.uuid, - MenuNo: _config.tabNo, - Template: 'SubTable', - MenuName: _config.tabName, - Remark: _config.Remark, - Sort: 0, - PageParam: JSON.stringify({Template: 'SubTable'}), - LongParam: _LongParam - } + let tabParam = { // 娣诲姞鏍囩鎸夐挳tab椤� + func: 'sPC_sMenusTab_AddUpt', + MenuID: _config.uuid, + LText: btntabs.join(' union all ') + } - if (openEdition) { - param.open_edition = openEdition - } + tabParam.LText = Utils.formatOptions(tabParam.LText) + tabParam.timestamp = moment().format('YYYY-MM-DD HH:mm:ss') + tabParam.secretkey = Utils.encrypt(tabParam.LText, tabParam.timestamp) - // 鏈夋寜閽垨鏍囩鍒犻櫎鏃讹紝鍏堣繘琛屽垹闄ゆ搷浣� - // 鍒犻櫎鎴愬姛鍚庯紝淇濆瓨椤甸潰閰嶇疆 - new Promise(resolve => { - if (delActions.length > 0) { - let deffers = delActions.map(item => { - let _param = { - func: 'sPC_MainMenu_Del', - MenuID: item.card.uuid - } + let param = { + func: 'sPC_Tab_AddUpt', + MenuID: _config.uuid, + MenuNo: _config.tabNo, + Template: 'SubTable', + MenuName: _config.tabName, + Remark: _config.Remark, + Sort: 0, + PageParam: JSON.stringify({Template: 'SubTable'}), + LongParam: _LongParam + } - let _ParentParam = null + if (openEdition) { + param.open_edition = openEdition + } - try { - _ParentParam = window.btoa(window.encodeURIComponent(JSON.stringify(item.card))) - } catch (e) { - console.warn('Stringify Failure') - _ParentParam = null - } + // 鏈夋寜閽垨鏍囩鍒犻櫎鏃讹紝鍏堣繘琛屽垹闄ゆ搷浣� + // 鍒犻櫎鎴愬姛鍚庯紝淇濆瓨椤甸潰閰嶇疆 + new Promise(resolve => { + if (delActions.length > 0) { + let deffers = delActions.map(item => { + let _param = { + func: 'sPC_MainMenu_Del', + MenuID: item.card.uuid + } - if (_ParentParam) { // 鍒犻櫎鎸夐挳鏃讹紝淇濆瓨鎸夐挳閰嶇疆淇℃伅锛岀敤浜庢仮澶嶆寜閽� - _param.ParentParam = _ParentParam - } + let _ParentParam = null - return new Promise(resolve => { - Api.getSystemConfig(_param).then(response => { - resolve(response) - }) + try { + _ParentParam = window.btoa(window.encodeURIComponent(JSON.stringify(item.card))) + } catch (e) { + console.warn('Stringify Failure') + _ParentParam = null + } + + if (_ParentParam) { // 鍒犻櫎鎸夐挳鏃讹紝淇濆瓨鎸夐挳閰嶇疆淇℃伅锛岀敤浜庢仮澶嶆寜閽� + _param.ParentParam = _ParentParam + } + + return new Promise(resolve => { + Api.getSystemConfig(_param).then(response => { + resolve(response) }) }) - Promise.all(deffers).then(result => { - let error = null - result.forEach(response => { - if (!response.status) { - error = response - } - }) - - if (error) { - this.setState({ - menuloading: false, - menucloseloading: false - }) - notification.warning({ - top: 92, - message: error.message, - duration: 5 - }) - resolve(false) - } else { - this.setState({ - delActions: [] - }) - resolve(true) + }) + Promise.all(deffers).then(result => { + let error = null + result.forEach(response => { + if (!response.status) { + error = response } }) - } else if (delActions.length === 0) { - resolve(true) - } - }).then(resp => { - if (resp === false) return - if (thawButtons.length > 0) { - let defers = thawButtons.map(item => { - return new Promise((resolve) => { - Api.getSystemConfig({ - func: 'sPC_MainMenu_ReDel', - MenuID: item - }).then(res => { - if (res.status) { - resolve('') - } else { - resolve(res.message) - } - }) - }) - }) - - return Promise.all(defers) - } else { - return true - } - }).then(res => { - if (res === true || res === false) return res - - let msg = res.filter(Boolean)[0] - if (msg) { - notification.warning({ - top: 92, - message: msg, - duration: 5 - }) - return false - } else { - this.setState({ - thawButtons: [] - }) - return true - } - }).then(resp => { - if (resp === false) return - - Api.getSystemConfig(param).then(response => { - if (response.status) { - this.setState({ - openEdition: response.open_edition || '', - config: _config, - originConfig: fromJS(_config).toJS() - }, () => { - this.setState({ - menuloading: false, - menucloseloading: false - }) - this.submitAction(btnParam, tabParam) - }) - } else { + if (error) { this.setState({ menuloading: false, menucloseloading: false }) notification.warning({ top: 92, - message: response.message, + message: error.message, duration: 5 }) + resolve(false) + } else { + this.setState({ + delActions: [] + }) + resolve(true) } }) + } else if (delActions.length === 0) { + resolve(true) + } + }).then(resp => { + if (resp === false) return + + if (thawButtons.length > 0) { + let defers = thawButtons.map(item => { + return new Promise((resolve) => { + Api.getSystemConfig({ + func: 'sPC_MainMenu_ReDel', + MenuID: item + }).then(res => { + if (res.status) { + resolve('') + } else { + resolve(res.message) + } + }) + }) + }) + + return Promise.all(defers) + } else { + return true + } + }).then(res => { + if (res === true || res === false) return res + + let msg = res.filter(Boolean)[0] + if (msg) { + notification.warning({ + top: 92, + message: msg, + duration: 5 + }) + return false + } else { + this.setState({ + thawButtons: [] + }) + return true + } + }).then(resp => { + if (resp === false) return + + Api.getSystemConfig(param).then(response => { + if (response.status) { + this.setState({ + openEdition: response.open_edition || '', + config: _config, + originConfig: fromJS(_config).toJS() + }, () => { + this.setState({ + menuloading: false, + menucloseloading: false + }) + this.submitAction(btnParam, tabParam) + }) + } else { + this.setState({ + menuloading: false, + menucloseloading: false + }) + notification.warning({ + top: 92, + message: response.message, + duration: 5 + }) + } }) }) - } /** diff --git a/src/views/menudesign/index.jsx b/src/views/menudesign/index.jsx index 54c8363..2dfb63e 100644 --- a/src/views/menudesign/index.jsx +++ b/src/views/menudesign/index.jsx @@ -13,6 +13,7 @@ import enUS from '@/locales/en-US/mob.js' import antdEnUS from 'antd/es/locale/en_US' import antdZhCN from 'antd/es/locale/zh_CN' +import MKEmitter from '@/utils/events.js' import asyncComponent from '@/utils/asyncComponent' import { modifyCustomMenu } from '@/store/action' @@ -32,10 +33,10 @@ const PaddingController = asyncComponent(() => import('@/menu/padcontroller')) const StyleController = asyncComponent(() => import('@/menu/stylecontroller')) const ModalController = asyncComponent(() => import('@/menu/modalconfig/controller')) +const PopviewController = asyncComponent(() => import('@/menu/popview/controller')) const TableComponent = asyncComponent(() => import('@/templates/sharecomponent/tablecomponent')) sessionStorage.setItem('isEditState', 'true') -sessionStorage.setItem('delButtons', JSON.stringify([])) class MenuDesign extends Component { state = { @@ -46,6 +47,7 @@ MenuName: '', MenuNo: '', tableFields: [], + delButtons: [], activeKey: 'basedata', menuloading: false, oriConfig: null, @@ -79,6 +81,10 @@ return !is(fromJS(this.state), fromJS(nextState)) } + componentDidMount () { + MKEmitter.addListener('delButtons', this.delButtons) + } + /** * @description 缁勪欢閿�姣侊紝娓呴櫎state鏇存柊 */ @@ -86,6 +92,11 @@ this.setState = () => { return } + MKEmitter.removeListener('delButtons', this.delButtons) + } + + delButtons = (items) => { + this.setState({delButtons: [...this.state.delButtons, ...items]}) } closeView = () => { @@ -149,7 +160,6 @@ backgroundColor: '#ffffff', backgroundImage: '', paddingTop: '16px', paddingBottom: '80px', paddingLeft: '16px', paddingRight: '16px' }, - MenuType: MenuType } if (MenuType === 'billPrint') { config.style.paddingTop = '50px' @@ -160,7 +170,6 @@ } else { config.uuid = MenuId config.MenuID = MenuId - config.MenuType = config.MenuType || MenuType } if (MenuType === 'billPrint') { @@ -263,24 +272,24 @@ } submitConfig = () => { - const { openEdition } = this.state + const { openEdition, MenuType, delButtons } = this.state let config = fromJS(this.state.config).toJS() - if (config.MenuType === 'billPrint' && (!config.firstCount || !config.everyPCount)) { + if (MenuType === 'billPrint' && (!config.firstCount || !config.everyPCount)) { notification.warning({ top: 92, message: '璇峰畬鍠勫熀鏈俊鎭紒', duration: 5 }) return - } else if (config.MenuType === 'home' && (config.cacheUseful === 'true' && !config.cacheTime)) { + } else if (MenuType === 'home' && (config.cacheUseful === 'true' && !config.cacheTime)) { notification.warning({ top: 92, message: '璇峰畬鍠勮彍鍗曞熀鏈俊鎭紒', duration: 5 }) return - } else if (config.MenuType === 'custom' && (!config.MenuName || !config.MenuNo || !config.fstMenuId || !config.parentId || (config.cacheUseful === 'true' && !config.cacheTime))) { + } else if (MenuType === 'custom' && (!config.MenuName || !config.MenuNo || !config.fstMenuId || !config.parentId || (config.cacheUseful === 'true' && !config.cacheTime))) { notification.warning({ top: 92, message: '璇峰畬鍠勮彍鍗曞熀鏈俊鎭紒', @@ -333,7 +342,7 @@ LText: [] } - if (config.MenuType !== 'billPrint') { + if (MenuType !== 'billPrint') { btnParam.LText = this.getMenuMessage() btnParam.LText = btnParam.LText.join(' union all ') btnParam.LText = Utils.formatOptions(btnParam.LText) @@ -347,7 +356,7 @@ menuloading: true }, () => { new Promise(resolve => { - if (config.MenuType === 'billPrint') { + if (MenuType === 'billPrint') { html2canvas(document.getElementById('menu-shell-inner')).then(canvas => { let img = canvas.toDataURL('image/png') // 鑾峰彇鐢熸垚鐨勫浘鐗� Api.fileuploadbase64(img, 'cloud').then(result => { @@ -392,7 +401,36 @@ }).then(res => { if (!res) return - return Api.getSystemConfig(param) + if (delButtons.length === 0) { + return { + status: true + } + } else { + let _param = { + func: 'sPC_MainMenu_Del', + MenuID: delButtons.join(',') + } + return Api.getSystemConfig(_param) + } + }).then(res => { + if (!res) return + + if (res.status) { + this.setState({ + delButtons: [] + }) + return Api.getSystemConfig(param) + } else { + this.setState({ + menuloading: false + }) + notification.warning({ + top: 92, + message: res.message, + duration: 5 + }) + return false + } }).then(res => { if (!res) return @@ -495,7 +533,7 @@ } verifyConfig = (show) => { - const { config } = this.state + const { config, MenuType } = this.state let error = '' config.components.forEach(item => { @@ -507,7 +545,7 @@ error = `缁勪欢銆�${item.name}銆嬫湭璁剧疆鏁版嵁婧愶紒` } else if (item.setting.interType === 'system' && item.setting.execute === 'false' && item.scripts.length === 0) { error = `缁勪欢銆�${item.name}銆嬫湭璁剧疆鏁版嵁婧愶紒` - } else if (item.setting.interType && !item.setting.primaryKey && config.MenuType !== 'billPrint') { + } else if (item.setting.interType && !item.setting.primaryKey && MenuType !== 'billPrint') { error = `缁勪欢銆�${item.name}銆嬫湭璁剧疆涓婚敭锛乣 } } @@ -619,6 +657,7 @@ </DndProvider> <StyleController /> <ModalController /> + <PopviewController /> </div> </ConfigProvider> ) -- Gitblit v1.8.0