From ff4295358a99b2d35265a5fed445e4407cf6ed9a Mon Sep 17 00:00:00 2001 From: king <18310653075@163.com> Date: 星期一, 18 五月 2020 14:48:10 +0800 Subject: [PATCH] 2020-05-18 --- src/index.js | 2 src/templates/sharecomponent/columncomponent/index.jsx | 17 ++- src/templates/sharecomponent/actioncomponent/index.jsx | 30 ++++--- src/templates/sharecomponent/settingcomponent/settingform/index.jsx | 12 +- src/components/sidemenu/index.jsx | 6 src/templates/formtabconfig/index.jsx | 4 src/templates/sharecomponent/cardcomponent/index.jsx | 67 ++++++++-------- src/templates/comtableconfig/index.jsx | 3 src/templates/sharecomponent/tabscomponent/index.jsx | 37 ++++++-- src/templates/sharecomponent/chartgroupcomponent/chartform/index.jsx | 14 ++- src/templates/sharecomponent/cardcomponent/dragdetail/index.jsx | 15 ++- src/templates/sharecomponent/searchcomponent/index.jsx | 13 ++- 12 files changed, 129 insertions(+), 91 deletions(-) diff --git a/src/components/sidemenu/index.jsx b/src/components/sidemenu/index.jsx index 7e146c3..23b2740 100644 --- a/src/components/sidemenu/index.jsx +++ b/src/components/sidemenu/index.jsx @@ -30,7 +30,7 @@ state = { dict: (!localStorage.getItem('lang') || localStorage.getItem('lang') === 'zh-CN') ? zhCN : enUS, mainMenuList: null, // 涓�绾ц彍鍗曪紝缂栬緫璋冩暣涓婄骇鑿滃崟鏃惰幏鍙� - subMenulist: null, // 浜岀骇鑿滃崟 + subMenulist: [], // 浜岀骇鑿滃崟 editMenu: null, // 缂栬緫涓夌骇鑿滃崟鏃惰缃� rootSubmenuKeys: null, createThirdMenu: false, @@ -41,7 +41,7 @@ async loadsubmenu (menu) { if (!menu || !menu.MenuID) { // 娌℃湁涓昏彍鍗曟椂锛屾竻绌轰笅绾ц彍鍗� this.setState({ - subMenulist: null, + subMenulist: [], rootSubmenuKeys: [], openKeys: [], editMenu: null @@ -61,7 +61,7 @@ if (result.data.length === 0) { // 鏌ヨ鑿滃崟涓虹┖ this.setState({ - subMenulist: null, + subMenulist: [], rootSubmenuKeys: [], openKeys: [] }) diff --git a/src/index.js b/src/index.js index bc93d9d..3dc43e3 100644 --- a/src/index.js +++ b/src/index.js @@ -95,7 +95,7 @@ if (process.env.NODE_ENV === 'production') { // 鐢ㄤ簬鏍¢獙鏄惁瀛樺湪寮�鍙戞潈闄� window.GLOB.linkurl = window.location.href.split('#')[0] } else { - window.GLOB.linkurl = 'http://qingqiumarket.cn/MKWMS/Index.html' + window.GLOB.linkurl = '' } diff --git a/src/templates/comtableconfig/index.jsx b/src/templates/comtableconfig/index.jsx index 489dc0a..f729761 100644 --- a/src/templates/comtableconfig/index.jsx +++ b/src/templates/comtableconfig/index.jsx @@ -82,7 +82,7 @@ if (!_LongParam) { _config = fromJS(Source.baseConfig).toJS() if (!menu.isSubtable) { // 涓嶆槸閫夋嫨涓诲瓙琛ㄦ椂锛岄殣钘忔爣绛鹃〉 - _config.tabs = [] + _config.tabgroups = [{ uuid: 'tabs', sublist: [] }] } _config.isAdd = true } else { @@ -105,7 +105,6 @@ } // 閰嶇疆榛樿鍊硷紝鍏煎 - _config.tabs = _config.tabs || [] _config.Template = 'CommonTable' _config.easyCode = _config.easyCode || '' diff --git a/src/templates/formtabconfig/index.jsx b/src/templates/formtabconfig/index.jsx index 4635da4..5fa3915 100644 --- a/src/templates/formtabconfig/index.jsx +++ b/src/templates/formtabconfig/index.jsx @@ -905,9 +905,7 @@ if (config.groups[0] && config.groups[0].sublist[0] && config.groups[0].sublist[0].origin) { config.groups[0].sublist = config.groups[0].sublist.filter(item => !item.origin) } - if (config.tabs[0] && config.tabs[0].origin) { - config.tabs = config.tabs.filter(item => !item.origin) - } + config.tabgroups[0].sublist = config.tabgroups[0].sublist.filter(item => !item.origin) } let btnNames = config.action.map(item => item.label) diff --git a/src/templates/sharecomponent/actioncomponent/index.jsx b/src/templates/sharecomponent/actioncomponent/index.jsx index 7f03402..45f5777 100644 --- a/src/templates/sharecomponent/actioncomponent/index.jsx +++ b/src/templates/sharecomponent/actioncomponent/index.jsx @@ -1,6 +1,6 @@ import React, {Component} from 'react' import PropTypes from 'prop-types' -import { fromJS } from 'immutable' +import { is, fromJS } from 'immutable' import { Icon, Tooltip, Modal, notification, Button } from 'antd' import moment from 'moment' @@ -63,6 +63,8 @@ if (nextProps.pasteContent && nextProps.pasteContent.copyType === 'action') { this.setState({actionlist: [...actionlist, nextProps.pasteContent]}) this.handleAction(nextProps.pasteContent) + } else if (!is(fromJS(nextProps.config.action), fromJS(this.props.config.action)) && !is(fromJS(nextProps.config.action), fromJS(actionlist))) { + this.setState({actionlist: fromJS(nextProps.config.action).toJS()}) } } @@ -76,8 +78,9 @@ this.setState({actionlist: list}) this.handleAction(card) } else { - this.setState({actionlist: list}) - this.props.updateaction({...config, action: list}) + this.setState({actionlist: list}, () => { + this.props.updateaction({...config, action: list}) + }) } } @@ -349,9 +352,9 @@ actionlist: _actionlist, copying: false, visible: false + }, () => { + this.props.updateaction({...config, action: _actionlist, gridBtn: _gridBtn}, copyActionId) }) - - this.props.updateaction({...config, action: _actionlist, gridBtn: _gridBtn}, copyActionId) }) }) } @@ -549,10 +552,6 @@ _actionlist = _actionlist.filter(item => item.uuid !== card.uuid) - _this.setState({ - actionlist: _actionlist - }) - let _hasGridbtn = _actionlist.filter(act => act.position === 'grid').length > 0 let _gridBtn = config.gridBtn ? fromJS(config.gridBtn).toJS() : null @@ -577,7 +576,11 @@ card: card } - _this.props.updateaction({...config, action: _actionlist, gridBtn: _gridBtn}, '', delcard) + _this.setState({ + actionlist: _actionlist + }, () => { + _this.props.updateaction({...config, action: _actionlist, gridBtn: _gridBtn}, '', delcard) + }) }, onCancel() {} }) @@ -616,8 +619,9 @@ this.setState({ actionlist: _actionlist, profVisible: false + }, () => { + this.props.updateaction({...config, action: _actionlist}) }) - this.props.updateaction({...config, action: _actionlist}) }) } @@ -785,9 +789,9 @@ this.setState({ actionlist: _actionlist + }, () => { + this.props.updateaction({...config, action: _actionlist, gridBtn: _gridBtn}) }) - - this.props.updateaction({...config, action: _actionlist, gridBtn: _gridBtn}) }) }) }) diff --git a/src/templates/sharecomponent/cardcomponent/dragdetail/index.jsx b/src/templates/sharecomponent/cardcomponent/dragdetail/index.jsx index e6bc7fc..ce0e89e 100644 --- a/src/templates/sharecomponent/cardcomponent/dragdetail/index.jsx +++ b/src/templates/sharecomponent/cardcomponent/dragdetail/index.jsx @@ -5,8 +5,8 @@ import Card from './card' import './index.scss' -const Container = ({list, handleList, handleMenu, deleteMenu }) => { - const [cards, setCards] = useState(list) +const Container = ({cardObj, handleList, handleMenu, deleteMenu }) => { + const [cards, setCards] = useState(cardObj.details) const moveCard = (id, atIndex) => { const { card, index } = findCard(id) const _cards = update(cards, { $splice: [[index, 1], [atIndex, 0, card]] }) @@ -14,8 +14,8 @@ handleList(_cards) } - if (!is(fromJS(cards), fromJS(list))) { - setCards(list) + if (!is(fromJS(cards), fromJS(cardObj.details))) { + setCards(cardObj.details) } const findCard = id => { @@ -30,8 +30,13 @@ accept: 'detail' }) + let marginLeft = 0 + if (cardObj.subelement.includes('avatar')) { + marginLeft = 48 + } + return ( - <div ref={drop} className="ant-card-meta-detail" style={{marginLeft: 48}}> + <div ref={drop} className="ant-card-meta-detail" style={{marginLeft: marginLeft}}> {cards.map(card => ( <Card key={card.uuid} diff --git a/src/templates/sharecomponent/cardcomponent/index.jsx b/src/templates/sharecomponent/cardcomponent/index.jsx index eddefc1..69c5ddb 100644 --- a/src/templates/sharecomponent/cardcomponent/index.jsx +++ b/src/templates/sharecomponent/cardcomponent/index.jsx @@ -142,6 +142,10 @@ render() { const { card } = this.props const { dict, visible, cardcell } = this.state + let _width = '100%' + if (card.actions.length > 0) { + _width = Math.floor((100 / card.actions.length) * 10000) / 10000 + '%' + } return ( <div className="line-card-edit-box"> @@ -150,47 +154,46 @@ className={'ant-card ant-card-bordered chart-card' + (card.widthType === 'ratio' ? ' ant-col ant-col-' + card.cardWidth : '')} style={card.widthType === 'absolute' ? { width: card.cardWidth } : null} > - <div className="ant-card-head"> - <div className="ant-card-head-wrapper"> - <div className="ant-card-head-title">Card Title</div> - <div className="ant-card-extra"> - <span>Action</span> + {card.subelement.includes('header') ? + <div className="ant-card-head"> + <Icon className="edit" title="Edit" type="edit" onClick={this.editHeader} /> + <div className="ant-card-head-wrapper"> + <div className="ant-card-head-title">{card.header.title.content}</div> + <div className="ant-card-extra"> + <span>Action</span> + </div> </div> - </div> - </div> - <div className="ant-card-body"> + </div> : null + } + {card.subelement.includes('content') ? <div className="ant-card-body"> <div className="ant-card-meta"> <Icon type="plus" onClick={() => this.editdetail()} /> - {card.cardType === 'card2' ? <div className="ant-card-meta-avatar"> - <span className="ant-avatar ant-avatar-circle ant-avatar-image" style={{width: 32, height: 32}}> - <img src="https://zos.alipayobjects.com/rmsportal/ODTLcjxAfvqbxHnVXCYX.png" alt=""/> - </span> - </div> : null } + {card.subelement.includes('avatar') ? + <div className="ant-card-meta-avatar"> + <Icon className="edit" title="Edit" type="edit" onClick={this.editAvatar} /> + <span className="ant-avatar ant-avatar-circle ant-avatar-image" style={{width: 32, height: 32}}> + <img src={card.avatar.content || 'https://zos.alipayobjects.com/rmsportal/ODTLcjxAfvqbxHnVXCYX.png'} alt=""/> + </span> + </div> : null + } <DragDetail - list={card.details} + cardObj={card} handleList={this.handleList} handleMenu={this.editdetail} deleteMenu={this.deletedetail} /> </div> - </div> - {card.cardType === 'card2' ? <ul className="ant-card-actions"> - <li style={{width: '33.3333%'}}> - <span> - <Icon type="setting"/> - </span> - </li> - <li style={{width: '33.3333%'}}> - <span> - <Icon type="edit"/> - </span> - </li> - <li style={{width: '33.3333%'}}> - <span> - <Icon type="edit"/> - </span> - </li> - </ul> : null} + </div> : null} + {card.subelement.includes('actions') ? + <ul className="ant-card-actions"> + <Icon className="edit" title="Edit" type="edit" onClick={this.editAction} /> + {card.actions.map(item => (<li style={{width: _width}}> + <span> + <Icon type={item.icon || 'dash'}/> + </span> + </li>))} + </ul> : null + } </div> {/* 鏄剧ず鍒楃紪杈� */} <Modal diff --git a/src/templates/sharecomponent/chartgroupcomponent/chartform/index.jsx b/src/templates/sharecomponent/chartgroupcomponent/chartform/index.jsx index 1b0edb1..e8a9eb5 100644 --- a/src/templates/sharecomponent/chartgroupcomponent/chartform/index.jsx +++ b/src/templates/sharecomponent/chartgroupcomponent/chartform/index.jsx @@ -111,17 +111,17 @@ { uuid: 'card1', url: card1, - type: 'card1' + subelement: ['content'] }, { uuid: 'card2', url: card2, - type: 'card2' + subelement: ['content', 'avatar'] }, { uuid: 'card3', url: card3, - type: 'card3' + subelement: ['content', 'avatar', 'header', 'actions'] } ] } @@ -417,7 +417,7 @@ result.Yaxis = result.Yaxis[0] || '' } } else if (result.chartType === 'card') { - result.cardType = selectlegend.type + result.subelement = selectlegend.subelement if (!result.details) { result.details = [ @@ -425,7 +425,11 @@ {bold: 'false', uuid: 'carddescription', content: 'Card content', datatype: 'static', align: 'left'} ] result.actions = [] - result.title = '' + result.header = { + title: {content: 'Card title', datatype: 'static'}, + actions: [] + } + result.avatar = {content: 'https://zos.alipayobjects.com/rmsportal/ODTLcjxAfvqbxHnVXCYX.png', datatype: 'static', width: 32, height: 32} } } diff --git a/src/templates/sharecomponent/columncomponent/index.jsx b/src/templates/sharecomponent/columncomponent/index.jsx index 4a514cc..0d7d14d 100644 --- a/src/templates/sharecomponent/columncomponent/index.jsx +++ b/src/templates/sharecomponent/columncomponent/index.jsx @@ -60,7 +60,7 @@ ) { this.setState({columnlist: nextProps.pasteContent.columns}) } else if (!is(fromJS(nextProps.config.columns), fromJS(this.props.config.columns)) && !is(fromJS(nextProps.config.columns), fromJS(columnlist))) { - this.setState({columnlist: nextProps.config.columns}) + this.setState({columnlist: fromJS(nextProps.config.columns).toJS()}) } } @@ -74,8 +74,9 @@ this.setState({columnlist: list}) this.handleColumn(card) } else { - this.setState({columnlist: list}) - this.props.updatecolumn({...config, columns: list}) + this.setState({columnlist: list}, ()=> { + this.props.updatecolumn({...config, columns: list}) + }) } } @@ -280,8 +281,9 @@ card: null, columnlist: _columnlist, modaltype: '' + }, ()=> { + this.props.updatecolumn({...config, columns: _columnlist}) }) - this.props.updatecolumn({...config, columns: _columnlist}) }) } else if (modaltype === 'gridbtn') { this.gridBtnFormRef.handleConfirm().then(res => { @@ -330,8 +332,9 @@ _this.setState({ columnlist: _columnlist + }, ()=> { + _this.props.updatecolumn({...config, columns: _columnlist}) }) - _this.props.updatecolumn({...config, columns: _columnlist}) }, onCancel() {} }) @@ -417,9 +420,9 @@ card: null, columnlist: _columnlist, modaltype: '' + }, ()=> { + this.props.updatecolumn({...config, columns: _columnlist}) }) - this.props.updatecolumn({...config, columns: _columnlist}) - } /** diff --git a/src/templates/sharecomponent/searchcomponent/index.jsx b/src/templates/sharecomponent/searchcomponent/index.jsx index c929ec3..9068bf8 100644 --- a/src/templates/sharecomponent/searchcomponent/index.jsx +++ b/src/templates/sharecomponent/searchcomponent/index.jsx @@ -53,7 +53,7 @@ this.setState({searchlist: [...searchlist, nextProps.pasteContent]}) this.handleSearch(nextProps.pasteContent) } else if (!is(fromJS(nextProps.config.search), fromJS(this.props.config.search)) && !is(fromJS(nextProps.config.search), fromJS(searchlist))) { - this.setState({searchlist: nextProps.config.search}) + this.setState({searchlist: fromJS(nextProps.config.search).toJS()}) } } @@ -67,8 +67,9 @@ this.setState({searchlist: list}) this.handleSearch(card) } else { - this.setState({searchlist: list}) - this.props.updatesearch({...config, search: list}) + this.setState({searchlist: list}, ()=> { + this.props.updatesearch({...config, search: list}) + }) } } @@ -212,8 +213,9 @@ sqlVerifing: false, searchlist: _searchlist, visible: false + }, ()=> { + this.props.updatesearch({...config, search: _searchlist}, optionLibs) }) - this.props.updatesearch({...config, search: _searchlist}, optionLibs) } else { this.setState({sqlVerifing: false}) @@ -226,8 +228,9 @@ this.setState({ searchlist: _searchlist, visible: false + }, ()=> { + this.props.updatesearch({...config, search: _searchlist}, optionLibs) }) - this.props.updatesearch({...config, search: _searchlist}, optionLibs) } }) } diff --git a/src/templates/sharecomponent/settingcomponent/settingform/index.jsx b/src/templates/sharecomponent/settingcomponent/settingform/index.jsx index 2f565dc..8e794e9 100644 --- a/src/templates/sharecomponent/settingcomponent/settingform/index.jsx +++ b/src/templates/sharecomponent/settingcomponent/settingform/index.jsx @@ -350,12 +350,14 @@ }) } - // 鏁版嵁婧愬鐞� - if (/\s/.test(_dataresource)) { - _dataresource = '(' + _dataresource + ') tb' - } + // 鏁版嵁婧愬鐞�, 瀛樺湪鏄剧ず鍒楁椂 + if (arr_field) { + if (/\s/.test(_dataresource)) { + _dataresource = '(' + _dataresource + ') tb' + } - _dataresource = `select ${_setting.laypage !== 'false' ? 'top 10' : ''} ${arr_field} from (select ${arr_field} ,ROW_NUMBER() over(order by ${_setting.order}) as rows from ${_dataresource}) tmptable ${_setting.laypage !== 'false' ? 'where rows > 0' : ''} order by tmptable.rows` + _dataresource = `select ${_setting.laypage !== 'false' ? 'top 10' : ''} ${arr_field} from (select ${arr_field} ,ROW_NUMBER() over(order by ${_setting.order}) as rows from ${_dataresource}) tmptable ${_setting.laypage !== 'false' ? 'where rows > 0' : ''} order by tmptable.rows` + } if (_setting.queryType === 'statistics') { regoptions.forEach(item => { diff --git a/src/templates/sharecomponent/tabscomponent/index.jsx b/src/templates/sharecomponent/tabscomponent/index.jsx index 7238978..5749ffe 100644 --- a/src/templates/sharecomponent/tabscomponent/index.jsx +++ b/src/templates/sharecomponent/tabscomponent/index.jsx @@ -1,6 +1,6 @@ import React, {Component} from 'react' import PropTypes from 'prop-types' -import { fromJS } from 'immutable' +import { is, fromJS } from 'immutable' import { Icon, Tooltip, Modal, notification } from 'antd' import Utils from '@/utils/utils.js' @@ -43,6 +43,17 @@ } /** + * @description 鏍囩缁勫彉鍖栨椂锛屾洿鏂版爣绛� + */ + UNSAFE_componentWillReceiveProps (nextProps) { + const { tabgroups } = this.state + + if (!is(fromJS(nextProps.config.tabgroups), fromJS(this.props.config.tabgroups)) && !is(fromJS(nextProps.config.tabgroups), fromJS(tabgroups))) { + this.setState({tabgroups: fromJS(nextProps.config.tabgroups).toJS()}) + } + } + + /** * @description 鍏冪礌娣诲姞鎴栨嫋鍔ㄦ椂椤哄簭鍙樺寲 */ handleList = (list, card, groupId) => { @@ -62,8 +73,9 @@ this.setState({tabgroups: _tabgroups}) this.handleTab(card, _group) } else { - this.setState({tabgroups: _tabgroups}) - this.props.updatetabs({...config, tabgroups: _tabgroups}) + this.setState({tabgroups: _tabgroups}, () => { + this.props.updatetabs({...config, tabgroups: _tabgroups}) + }) } } @@ -169,8 +181,9 @@ group: null, tabgroups: tabgroups, visible: false + }, () => { + this.props.updatetabs({...config, tabgroups: tabgroups}) }) - this.props.updatetabs({...config, tabgroups: tabgroups}) }) } @@ -196,8 +209,9 @@ _this.setState({ tabgroups: tabgroups + }, () => { + _this.props.updatetabs({...config, tabgroups: tabgroups}, [card]) }) - _this.props.updatetabs({...config, tabgroups: tabgroups}, [card]) }, onCancel() {} }) @@ -229,8 +243,9 @@ _this.setState({ tabgroups: _tabgroups + }, () => { + _this.props.updatetabs({...config, tabgroups: _tabgroups}) }) - _this.props.updatetabs({...config, tabgroups: _tabgroups}) }, onCancel() {} }) @@ -249,13 +264,13 @@ okText: this.state.dict['model.confirm'], cancelText: this.state.dict['header.cancel'], onOk() { - _tabgroups = _tabgroups.filter(_group => _group.uuid !== group.uuid) _this.setState({ tabgroups: _tabgroups + }, () => { + _this.props.updatetabs({...config, tabgroups: _tabgroups}, group.sublist) }) - _this.props.updatetabs({...config, tabgroups: _tabgroups}, group.sublist) }, onCancel() {} }) @@ -276,8 +291,9 @@ this.setState({ tabgroups: _tabgroups + }, () => { + this.props.updatetabs({...config, tabgroups: _tabgroups}) }) - this.props.updatetabs({...config, tabgroups: _tabgroups}) notification.success({ top: 92, @@ -308,8 +324,9 @@ group: null, tabgroups: _tabgroups, visible: false + }, () => { + this.props.updatetabs({...config, tabgroups: _tabgroups}) }) - this.props.updatetabs({...config, tabgroups: _tabgroups}) } else { this.setState({ card: null, -- Gitblit v1.8.0