From 37a134bd23ec4b227a0e010b08a1a89c2bbaaa0d Mon Sep 17 00:00:00 2001 From: king <18310653075@163.com> Date: 星期二, 03 十一月 2020 17:10:14 +0800 Subject: [PATCH] 2020-11-03 --- src/tabviews/custom/components/chart/antv-bar-line/index.jsx | 5 src/tabviews/verupmanage/subtabtable/index.jsx | 3 src/tabviews/custom/components/tabs/antv-tabs/index.jsx | 9 src/tabviews/zshare/normalTable/index.jsx | 2 src/mob/mobshell/index.jsx | 28 src/tabviews/zshare/chartcomponent/index.jsx | 5 src/templates/sharecomponent/searchcomponent/dragsearch/card.jsx | 16 src/tabviews/calendar/index.jsx | 3 src/tabviews/zshare/actionList/excelInbutton/index.jsx | 5 src/templates/treepageconfig/index.jsx | 17 src/tabviews/zshare/actionList/exceloutbutton/index.jsx | 11 src/templates/zshare/editcomponent/index.jsx | 94 +- src/tabviews/custom/components/search/main-search/index.scss | 38 + src/templates/formtabconfig/dragelement/index.jsx | 23 src/menu/components/tabs/tabcomponents/index.jsx | 4 src/templates/modalconfig/index.jsx | 12 src/templates/sharecomponent/columncomponent/dragcolumn/index.jsx | 25 src/tabviews/zshare/actionList/index.jsx | 6 src/tabviews/iframe/index.jsx | 5 src/templates/modalconfig/dragelement/index.jsx | 3 src/tabviews/subtable/index.jsx | 12 src/templates/formtabconfig/dragelement/card.jsx | 16 src/tabviews/subtabtable/index.jsx | 14 src/templates/sharecomponent/tabscomponent/tabdragelement/card.jsx | 14 src/tabviews/commontable/index.jsx | 16 src/tabviews/zshare/actionList/normalbutton/index.jsx | 11 src/templates/modalconfig/dragelement/card.jsx | 8 src/mob/mobshell/card.jsx | 16 src/templates/sharecomponent/actioncomponent/dragaction/card.jsx | 16 src/tabviews/custom/components/card/data-card/index.jsx | 5 src/menu/components/search/main-search/dragsearch/index.jsx | 1 src/tabviews/custom/components/card/prop-card/index.jsx | 5 src/tabviews/custom/components/search/main-search/index.jsx | 792 +++++++++++++++++++++++++++++ src/tabviews/custom/components/share/tabtransfer/index.jsx | 75 ++ src/menu/datasource/verifycard/settingform/index.jsx | 28 src/templates/sharecomponent/columncomponent/dragcolumn/card.jsx | 8 src/templates/calendarconfig/index.jsx | 4 src/tabviews/custom/components/chart/antv-pie/index.jsx | 5 src/templates/sharecomponent/searchcomponent/dragsearch/index.jsx | 26 src/menu/components/search/main-search/index.jsx | 72 +- src/tabviews/custom/index.jsx | 43 - src/tabviews/scriptmanage/index.jsx | 3 src/templates/sharecomponent/actioncomponent/dragaction/index.jsx | 24 src/templates/sharecomponent/tabscomponent/tabdragelement/index.jsx | 22 src/tabviews/verupmanage/index.jsx | 3 src/menu/menushell/index.jsx | 3 src/tabviews/zshare/cardcomponent/index.jsx | 12 47 files changed, 1,216 insertions(+), 352 deletions(-) diff --git a/src/menu/components/search/main-search/dragsearch/index.jsx b/src/menu/components/search/main-search/dragsearch/index.jsx index 231dae1..178a530 100644 --- a/src/menu/components/search/main-search/dragsearch/index.jsx +++ b/src/menu/components/search/main-search/dragsearch/index.jsx @@ -67,7 +67,6 @@ } const { index: overIndex } = findCard(id) - const _cards = update(cards, { $splice: [[overIndex + 1, 0, copycard]] }) handleList(_cards, copycard) diff --git a/src/menu/components/search/main-search/index.jsx b/src/menu/components/search/main-search/index.jsx index 8fd76f9..7a700dc 100644 --- a/src/menu/components/search/main-search/index.jsx +++ b/src/menu/components/search/main-search/index.jsx @@ -130,15 +130,16 @@ /** * @description 鎼滅储鏉′欢椤哄簭璋冩暣锛屾垨鎷栨嫿娣诲姞 */ - handleList = (list, card) => { - const { config } = this.props + handleList = (list, newcell) => { + const { card } = this.state + let _card = {...card, search: list} - if (card) { - this.setState({searchlist: list}) - this.handleSearch(card) + if (newcell) { + this.setState({card: _card}) + this.handleSearch(newcell) } else { - this.setState({searchlist: list}, ()=> { - this.props.updatesearch({...config, search: list}) + this.setState({card: _card}, ()=> { + this.props.updateConfig(_card) }) } } @@ -170,21 +171,19 @@ * @description 鍙栨秷淇濆瓨锛屽鏋滃厓绱犱负鏂版坊鍏冪礌锛屽垯浠庡簭鍒椾腑鍒犻櫎 */ editModalCancel = () => { - const { card } = this.state + const { card, editcard } = this.state - if (card.focus) { - let searchlist = fromJS(this.state.searchlist).toJS() - - searchlist = searchlist.filter(item => item.uuid !== card.uuid) + if (editcard.focus) { + card.search = card.search.filter(item => item.uuid !== editcard.uuid) this.setState({ - card: null, - searchlist: searchlist, + card: card, + editcard: null, visible: false }) } else { this.setState({ - card: null, + editcard: null, visible: false }) } @@ -192,22 +191,17 @@ /** * @description 鎼滅储淇敼鍚庢彁浜や繚瀛� - * 1銆佸幓闄ょ郴缁熼粯璁ゆ悳绱㈡潯浠� - * 2銆佸瓧娈靛強鎻愮ず鏂囧瓧閲嶅鏍¢獙 - * 3銆佹洿鏂颁笅鎷夎彍鍗曞彲閫夐泦鍚� - * 4銆佷笅鎷夎彍鍗曟暟鎹簮璇硶楠岃瘉 + * 1銆佸瓧娈靛強鎻愮ず鏂囧瓧閲嶅鏍¢獙 + * 2銆佷笅鎷夎彍鍗曟暟鎹簮璇硶楠岃瘉 */ handleSubmit = () => { - const { config } = this.props - let _searchlist = fromJS(this.state.searchlist).toJS() + let card = fromJS(this.state.card).toJS() this.searchFormRef.handleConfirm().then(res => { let fieldrepet = false // 瀛楁閲嶅 let labelrepet = false // 鎻愮ず鏂囧瓧閲嶅 - _searchlist = _searchlist.filter(item => !item.origin || item.uuid === res.uuid) // 鍘婚櫎绯荤粺椤� - - _searchlist = _searchlist.map(item => { // 鏁版嵁鏇存柊鍙婇噸澶嶆娴� + card.search = card.search.map(item => { // 鏁版嵁鏇存柊鍙婇噸澶嶆娴� if (item.uuid !== res.uuid && res.field && item.field) { let itemFields = [] if (item.type === 'text') { @@ -259,7 +253,7 @@ return } - if ((res.type === 'select' || res.type === 'multiselect' || res.type === 'link') && res.resourceType === '1' && /\s/.test(res.dataSource)) { + if (['select', 'multiselect', 'link'].includes(res.type) && res.resourceType === '1' && /\s/.test(res.dataSource)) { this.setState({ sqlVerifing: true }) @@ -282,11 +276,11 @@ Api.getLocalConfig(param).then(result => { if (result.status) { this.setState({ + card: card, sqlVerifing: false, - searchlist: _searchlist, visible: false }, ()=> { - this.props.updatesearch({...config, search: _searchlist}) + this.props.updateConfig(card) }) } else { this.setState({sqlVerifing: false}) @@ -298,10 +292,10 @@ }) } else { this.setState({ - searchlist: _searchlist, + card: card, visible: false }, ()=> { - this.props.updatesearch({...config, search: _searchlist}) + this.props.updateConfig(card) }) } }) @@ -310,22 +304,20 @@ /** * @description 鎼滅储鏉′欢鍒犻櫎 */ - deleteElement = (card) => { - const { config } = this.props + deleteElement = (cell) => { const { dict } = this.state let _this = this confirm({ - content: dict['model.confirm'] + dict['model.delete'] + ` - ${card.label} 锛焋, + content: dict['model.confirm'] + dict['model.delete'] + ` - ${cell.label} 锛焋, onOk() { - let _searchlist = fromJS(_this.state.searchlist).toJS() - - _searchlist = _searchlist.filter(item => item.uuid !== card.uuid) + let _card = fromJS(_this.state.card).toJS() + _card.search = _card.search.filter(item => item.uuid !== cell.uuid) _this.setState({ - searchlist: _searchlist + card: _card }, () => { - _this.props.updatesearch({...config, search: _searchlist}) + _this.props.updateConfig(_card) }) }, onCancel() {} @@ -346,7 +338,9 @@ } card.search.push(item) - this.setState({card}) + this.setState({card}, () => { + this.handleSearch(item) + }) } render() { @@ -384,7 +378,7 @@ > <SearchForm dict={dict} - card={this.state.card} + card={this.state.editcard} formlist={this.state.formlist} inputSubmit={this.handleSubmit} wrappedComponentRef={(inst) => this.searchFormRef = inst} diff --git a/src/menu/components/tabs/tabcomponents/index.jsx b/src/menu/components/tabs/tabcomponents/index.jsx index 2608e82..e0f397d 100644 --- a/src/menu/components/tabs/tabcomponents/index.jsx +++ b/src/menu/components/tabs/tabcomponents/index.jsx @@ -88,6 +88,7 @@ line: '鎶樼嚎鍥�', tabs: '鏍囩缁�', pie: '楗煎浘', + search: '鎼滅储', card: '鍗$墖' } let i = 1 @@ -113,10 +114,11 @@ isNew: true // 鏂版坊鍔犳爣蹇楋紝鐢ㄤ簬鍒濆鍖� } - let targetId = '0' + let targetId = '' if (item.dropTargetId) { targetId = item.dropTargetId + delete item.dropTargetId } else if (cards.length > 0) { targetId = cards[cards.length - 1].uuid } diff --git a/src/menu/datasource/verifycard/settingform/index.jsx b/src/menu/datasource/verifycard/settingform/index.jsx index ab33160..de9225c 100644 --- a/src/menu/datasource/verifycard/settingform/index.jsx +++ b/src/menu/datasource/verifycard/settingform/index.jsx @@ -20,7 +20,8 @@ state = { interType: this.props.setting.interType || 'system', - modules: [] + modules: [], + useMSearch: this.props.setting.useMSearch || 'false' } UNSAFE_componentWillMount () { @@ -173,7 +174,7 @@ render() { const { setting, menu, columns, config } = this.props const { getFieldDecorator } = this.props.form - const { interType, modules } = this.state + const { interType, modules, useMSearch } = this.state const formItemLayout = { labelCol: { @@ -415,21 +416,38 @@ </Col> : null} <Col span={8}> <Form.Item label={ - <Tooltip placement="topLeft" title={'浣跨敤涓绘悳绱㈡潯浠讹紙瀛樺湪鏃讹級锛屼富鎼滅储鏉′欢涓庣粍浠剁殑鎼滅储鏉′欢浼氫竴鍚岀敤浣滄暟鎹繃婊わ紙缁勪欢鐨勬悳绱㈡潯浠朵紭鍏堬級銆�'}> + <Tooltip placement="topLeft" title={'浼樺厛浣跨敤鍚岀骇鐨勬悳绱㈡潯浠剁粍浠讹紝鍚岀骇鎼滅储涓嶅瓨鍦ㄦ椂锛屼緷娆″悜涓婇�夊彇锛屼笌褰撳墠缁勪欢鐨勬悳绱㈡潯浠朵竴鍚岀敤浣滄暟鎹繃婊わ紙褰撳墠缁勪欢鐨勬悳绱㈡潯浠朵紭鍏堬級銆�'}> <Icon type="question-circle" /> - 涓绘悳绱� + 澶栧眰鎼滅储 </Tooltip> }> {getFieldDecorator('useMSearch', { initialValue: setting.useMSearch || 'false' })( - <Radio.Group> + <Radio.Group onChange={(e) => this.setState({useMSearch: e.target.value})}> <Radio value="true">浣跨敤</Radio> <Radio value="false">涓嶄娇鐢�</Radio> </Radio.Group> )} </Form.Item> </Col> + {useMSearch === 'true' ? <Col span={8}> + <Form.Item label={ + <Tooltip placement="topLeft" title={'澶栧眰鎼滅储鏉′欢鏀瑰彉鏃讹紝鏄惁鍒锋柊褰撳墠缁勪欢鏁版嵁銆�'}> + <Icon type="question-circle" /> + 鍚屾鍒锋柊 + </Tooltip> + }> + {getFieldDecorator('syncRefresh', { + initialValue: setting.syncRefresh || 'true' + })( + <Radio.Group> + <Radio value="true">鏄�</Radio> + <Radio value="false">鍚�</Radio> + </Radio.Group> + )} + </Form.Item> + </Col> : null} <Col span={8}> <Form.Item label="鍒濆鍖栨暟鎹�"> {getFieldDecorator('onload', { diff --git a/src/menu/menushell/index.jsx b/src/menu/menushell/index.jsx index 2c12f56..2656df8 100644 --- a/src/menu/menushell/index.jsx +++ b/src/menu/menushell/index.jsx @@ -104,10 +104,11 @@ isNew: true // 鏂版坊鍔犳爣蹇楋紝鐢ㄤ簬鍒濆鍖� } - let targetId = '0' + let targetId = '' if (item.dropTargetId) { targetId = item.dropTargetId + delete item.dropTargetId } else if (cards.length > 0) { targetId = cards[cards.length - 1].uuid } diff --git a/src/mob/mobshell/card.jsx b/src/mob/mobshell/card.jsx index 27c3338..5b7a510 100644 --- a/src/mob/mobshell/card.jsx +++ b/src/mob/mobshell/card.jsx @@ -9,7 +9,7 @@ const MobLogin1 = asyncComponent(() => import('@/mob/components/login/mob-login-1')) const MobLogin2 = asyncComponent(() => import('@/mob/components/login/mob-login-2')) -const Card = ({ id, card, moveCard, findCard, editId, editCard, delCard, hasDrop, doubleClickCard, updateConfig }) => { +const Card = ({ id, card, moveCard, findCard, editId, editCard, delCard, doubleClickCard, updateConfig }) => { const originalIndex = findCard(id).index const [{ isDragging }, drag] = useDrag({ item: { type: 'mob', id, originalIndex }, @@ -21,17 +21,15 @@ accept: 'mob', canDrop: () => true, drop: (item) => { - if (!item.hasOwnProperty('originalIndex')) { - hasDrop(card) - } - }, - hover({ id: draggedId }) { - if (!draggedId) return - if (draggedId !== id) { + const { id: draggedId, originalIndex } = item + + if (originalIndex === undefined) { + item.dropTargetId = id + } else if (draggedId && draggedId !== id) { const { index: overIndex } = findCard(id) moveCard(draggedId, overIndex) } - }, + } }) let style = { opacity: 1} diff --git a/src/mob/mobshell/index.jsx b/src/mob/mobshell/index.jsx index f293e7b..d803eb8 100644 --- a/src/mob/mobshell/index.jsx +++ b/src/mob/mobshell/index.jsx @@ -9,8 +9,6 @@ import './index.scss' const Container = ({config, editId, handleList, editCard, deleteCard, doubleClickCard }) => { - let target = null - const [cards, setCards] = useState(config.components) const moveCard = (id, atIndex) => { const { card, index } = findCard(id) @@ -28,10 +26,6 @@ card, index: cards.indexOf(card), } - } - - const hasDrop = (item) => { - target = item } const updateConfig = (element) => { @@ -55,21 +49,20 @@ type: item.componentType, subtype: item.subtype, } - - let targetId = cards.length > 0 ? cards[cards.length - 1].uuid : 0 - if (target) { - targetId = target.uuid + + let targetId = '' + + if (item.dropTargetId) { + targetId = item.dropTargetId + delete item.dropTargetId + } else if (cards.length > 0) { + targetId = cards[cards.length - 1].uuid } - const { index: overIndex } = findCard(`${targetId}`) - let targetIndex = overIndex - - targetIndex++ - - const _cards = update(cards, { $splice: [[targetIndex, 0, newcard]] }) + const { index: overIndex } = findCard(`${targetId}`) // cards涓虹┖鏃� overIndex 涓� -1 + const _cards = update(cards, { $splice: [[overIndex + 1, 0, newcard]] }) handleList({...config, components: _cards}) - target = null } }) @@ -85,7 +78,6 @@ editCard={editCard} delCard={deleteCard} findCard={findCard} - hasDrop={hasDrop} updateConfig={updateConfig} doubleClickCard={doubleClickCard} /> diff --git a/src/tabviews/calendar/index.jsx b/src/tabviews/calendar/index.jsx index 9bd3ce9..ab6760a 100644 --- a/src/tabviews/calendar/index.jsx +++ b/src/tabviews/calendar/index.jsx @@ -324,7 +324,8 @@ obj_name: 'data', arr_field: arr_field, custom_script: setting.customScript, - default_sql: setting.execute || 'true' + default_sql: setting.execute || 'true', + menuname: this.props.MenuName || '' } let _dataresource = setting.dataresource diff --git a/src/tabviews/commontable/index.jsx b/src/tabviews/commontable/index.jsx index dc44e40..10b5d2e 100644 --- a/src/tabviews/commontable/index.jsx +++ b/src/tabviews/commontable/index.jsx @@ -517,6 +517,10 @@ let _orderBy = orderBy || setting.order let param = UtilsDM.getQueryDataParams(setting, arr_field, search, _orderBy, pageIndex, pageSize, BID, this.props.menuType, this.props.dataManager) + if (param.func === 'sPC_Get_TableData') { + param.menuname = this.props.MenuName || '' + } + let result = await Api.genericInterface(param) if (result.status) { this.setState({ @@ -555,6 +559,10 @@ let _orderBy = orderBy || setting.order let param = UtilsDM.getStatQueryDataParams(setting, statFields, search, _orderBy, BID, this.props.menuType, this.props.dataManager) + + if (param.func === 'sPC_Get_TableData') { + param.menuname = this.props.MenuName || '' + } Api.genericInterface(param).then(res => { if (res.status) { @@ -858,7 +866,7 @@ } render() { - const { menuType } = this.props + const { menuType, MenuName } = this.props const { BID, setting, searchlist, pageSize, actions, columns, loadingview, viewlost, pickup, config, userConfig, tabActive, chartId, search, selectedData } = this.state return ( @@ -893,6 +901,7 @@ BID={BID} setting={setting} actions={actions} + MenuName={MenuName} dict={this.state.dict} MenuID={this.props.MenuID} selectedData={selectedData} @@ -906,9 +915,9 @@ {this.props.menuType !== 'HS' ? <SettingComponent config={config} columns={columns} + MenuName={MenuName} dict={this.state.dict} MenuID={this.props.MenuID} - MenuName={this.props.MenuName} permAction={this.props.permAction} permRoles={this.props.permRoles} userConfig={this.state.userConfig} @@ -924,6 +933,7 @@ config={config} setting={setting} columns={columns} + MenuName={MenuName} pageSize={pageSize} dict={this.state.dict} data={this.state.data} @@ -948,6 +958,7 @@ BID={BID} plot={item} config={config} + MenuName={MenuName} tableId="mainTable" data={this.state.data} MenuID={this.props.MenuID} @@ -967,6 +978,7 @@ BID={BID} plot={item} config={config} + MenuName={MenuName} data={this.state.data} getexceloutparam={this.getexceloutparam} loading={this.state.loading} diff --git a/src/tabviews/custom/components/card/data-card/index.jsx b/src/tabviews/custom/components/card/data-card/index.jsx index 1907ab5..9c52d9c 100644 --- a/src/tabviews/custom/components/card/data-card/index.jsx +++ b/src/tabviews/custom/components/card/data-card/index.jsx @@ -5,8 +5,6 @@ import Api from '@/api' import UtilsDM from '@/utils/utils-datamanage.js' -import zhCN from '@/locales/zh-CN/main.js' -import enUS from '@/locales/en-US/main.js' import preImg from '@/assets/img/prev.png' import nextImg from '@/assets/img/next.png' import MKEmitter from '@/utils/events.js' @@ -20,13 +18,12 @@ BID: PropTypes.any, // 鐖剁骇Id data: PropTypes.array, // 缁熶竴鏌ヨ鏁版嵁 config: PropTypes.object, // 缁勪欢閰嶇疆淇℃伅 - mainSearch: PropTypes.any, // 鍏ㄥ眬鎼滅储鏉′欢 + mainSearch: PropTypes.any, // 澶栧眰鎼滅储鏉′欢 menuType: PropTypes.any, // 鑿滃崟绫诲瀷 dataManager: PropTypes.any, // 鏁版嵁鏉冮檺 } state = { - dict: localStorage.getItem('lang') !== 'en-US' ? zhCN : enUS, // 瀛楀吀 config: null, // 鍥捐〃閰嶇疆淇℃伅 pageIndex: 1, activeKey: '', // 閫変腑鍗� diff --git a/src/tabviews/custom/components/card/prop-card/index.jsx b/src/tabviews/custom/components/card/prop-card/index.jsx index fb0cb33..bb6fef1 100644 --- a/src/tabviews/custom/components/card/prop-card/index.jsx +++ b/src/tabviews/custom/components/card/prop-card/index.jsx @@ -6,8 +6,6 @@ import asyncComponent from '@/utils/asyncComponent' import Api from '@/api' import UtilsDM from '@/utils/utils-datamanage.js' -import zhCN from '@/locales/zh-CN/main.js' -import enUS from '@/locales/en-US/main.js' import MKEmitter from '@/utils/events.js' import './index.scss' @@ -18,13 +16,12 @@ BID: PropTypes.any, // 鐖剁骇Id data: PropTypes.array, // 缁熶竴鏌ヨ鏁版嵁 config: PropTypes.object, // 缁勪欢閰嶇疆淇℃伅 - mainSearch: PropTypes.any, // 鍏ㄥ眬鎼滅储鏉′欢 + mainSearch: PropTypes.any, // 澶栧眰鎼滅储鏉′欢 menuType: PropTypes.any, // 鑿滃崟绫诲瀷 dataManager: PropTypes.any, // 鏁版嵁鏉冮檺 } state = { - dict: localStorage.getItem('lang') !== 'en-US' ? zhCN : enUS, // 瀛楀吀 config: null, // 鍥捐〃閰嶇疆淇℃伅 loading: true, // 鏁版嵁鍔犺浇鐘舵�� activeKey: '', // 閫変腑鏁版嵁 diff --git a/src/tabviews/custom/components/chart/antv-bar-line/index.jsx b/src/tabviews/custom/components/chart/antv-bar-line/index.jsx index a007a29..0d993cd 100644 --- a/src/tabviews/custom/components/chart/antv-bar-line/index.jsx +++ b/src/tabviews/custom/components/chart/antv-bar-line/index.jsx @@ -10,8 +10,6 @@ import Api from '@/api' import Utils from '@/utils/utils.js' import UtilsDM from '@/utils/utils-datamanage.js' -import zhCN from '@/locales/zh-CN/main.js' -import enUS from '@/locales/en-US/main.js' import './index.scss' const ExcelOutButton = asyncComponent(() => import('@/tabviews/zshare/actionList/exceloutbutton')) @@ -22,13 +20,12 @@ BID: PropTypes.any, // 鐖剁骇Id data: PropTypes.array, // 缁熶竴鏌ヨ鏁版嵁 config: PropTypes.object, // 缁勪欢閰嶇疆淇℃伅 - mainSearch: PropTypes.any, // 鍏ㄥ眬鎼滅储鏉′欢 + mainSearch: PropTypes.any, // 澶栧眰鎼滅储鏉′欢 menuType: PropTypes.any, // 鑿滃崟绫诲瀷 dataManager: PropTypes.any, // 鏁版嵁鏉冮檺 } state = { - dict: localStorage.getItem('lang') !== 'en-US' ? zhCN : enUS, // 瀛楀吀 config: null, // 鍥捐〃閰嶇疆淇℃伅 empty: true, // 鍥捐〃鏁版嵁涓虹┖ loading: false, // 鏁版嵁鍔犺浇鐘舵�� diff --git a/src/tabviews/custom/components/chart/antv-pie/index.jsx b/src/tabviews/custom/components/chart/antv-pie/index.jsx index ca47081..abe2143 100644 --- a/src/tabviews/custom/components/chart/antv-pie/index.jsx +++ b/src/tabviews/custom/components/chart/antv-pie/index.jsx @@ -9,8 +9,6 @@ import Api from '@/api' import Utils from '@/utils/utils.js' import UtilsDM from '@/utils/utils-datamanage.js' -import zhCN from '@/locales/zh-CN/main.js' -import enUS from '@/locales/en-US/main.js' import './index.scss' class LineChart extends Component { @@ -18,13 +16,12 @@ BID: PropTypes.any, // 鐖剁骇Id data: PropTypes.array, // 缁熶竴鏌ヨ鏁版嵁 config: PropTypes.object, // 缁勪欢閰嶇疆淇℃伅 - mainSearch: PropTypes.any, // 鍏ㄥ眬鎼滅储鏉′欢 + mainSearch: PropTypes.any, // 澶栧眰鎼滅储鏉′欢 menuType: PropTypes.any, // 鑿滃崟绫诲瀷 dataManager: PropTypes.any, // 鏁版嵁鏉冮檺 } state = { - dict: localStorage.getItem('lang') !== 'en-US' ? zhCN : enUS, // 瀛楀吀 config: null, // 鍥捐〃閰嶇疆淇℃伅 empty: true, // 鍥捐〃鏁版嵁涓虹┖ loading: false, // 鏁版嵁鍔犺浇鐘舵�� diff --git a/src/tabviews/custom/components/search/main-search/index.jsx b/src/tabviews/custom/components/search/main-search/index.jsx new file mode 100644 index 0000000..1aad4c6 --- /dev/null +++ b/src/tabviews/custom/components/search/main-search/index.jsx @@ -0,0 +1,792 @@ +import React, {Component} from 'react' +import PropTypes from 'prop-types' +import { fromJS } from 'immutable' +import { Form, Row, Col, Input, Button, Select, DatePicker, notification } from 'antd' +import moment from 'moment' + +import Api from '@/api' +import options from '@/store/options.js' +import DateGroup from '@/tabviews/zshare/dategroup' +import Utils from '@/utils/utils.js' +import zhCN from '@/locales/zh-CN/main.js' +import enUS from '@/locales/en-US/main.js' +import './index.scss' + +const { MonthPicker, WeekPicker, RangePicker } = DatePicker + +class MainSearch extends Component { + static propTpyes = { + BID: PropTypes.any, // 鐖剁骇Id + config: PropTypes.object, // 缁勪欢閰嶇疆淇℃伅 + mainSearch: PropTypes.any, // 澶栧眰鎼滅储鏉′欢 + menuType: PropTypes.any, // 鑿滃崟绫诲瀷 + dataManager: PropTypes.any, // 鏁版嵁鏉冮檺 + refreshdata: PropTypes.func // 鍒锋柊鏁版嵁 + } + + state = { + dict: sessionStorage.getItem('lang') !== 'en-US' ? zhCN : enUS, + match: null, // 鎼滅储鏉′欢鍖归厤瑙勫垯 + style: null, // 鎼滅储鏉′欢绫诲瀷 + label: null, // 鎻愮ず鏂囧瓧 + required: null, // 鏄惁蹇呭~ + searchlist: null, // 鎼滅储椤� + groups: null, // 缁勫悎鎼滅储椤� + formId: Utils.getuuid() // 鎼滅储琛ㄥ崟Id + } + + UNSAFE_componentWillMount () { + let searchlist = fromJS(this.props.config.search).toJS() + let match = {} + let label = {} + let style = {} + let required = {} + let _list = [] + let fieldMap = new Map() + let mainItems = [] // 浜戠鎴栧崟鐐规暟鎹� + let localItems = [] // 鏈湴鏁版嵁 + let deForms = [] // 娴嬭瘯绯荤粺锛屽崟涓姹� + + searchlist.forEach(item => { + if (fieldMap.has(item.field)) { + item.field = item.field + '@tail@' + } + fieldMap.set(item.field, true) + + match[item.field] = item.match + label[item.field] = item.label + style[item.field] = item.type + required[item.field] = item.required === 'true' + + if (['select', 'link', 'multiselect'].includes(item.type)) { + if (item.setAll === 'true' && item.type !== 'multiselect') { + item.options.unshift({ + key: Utils.getuuid(), + Value: '', + Text: this.state.dict['main.all'] + }) + } + + // 鏁版嵁婧愭煡璇㈣鍙� + if (item.resourceType === '1' && item.dataSource) { + let _option = Utils.getSelectQueryOptions(item) + + if (this.props.dataManager) { // 鏁版嵁鏉冮檺 + _option.sql = _option.sql.replace(/\$@/ig, '/*') + _option.sql = _option.sql.replace(/@\$/ig, '*/') + } else { + _option.sql = _option.sql.replace(/@\$|\$@/ig, '') + } + + // 娴嬭瘯绯荤粺鍗曚釜璇锋眰 + if (this.props.menuType !== 'HS' && options.sysType === 'local' && !window.GLOB.systemType) { + deForms.push({ + ...item, + arr_field: _option.field, + data_sql: Utils.formatOptions(_option.sql) + }) + } else { // 鍚堝苟璇锋眰锛屽尯鍒嗘湰鍦板強绯荤粺 + // 澶栬仈鏁版嵁搴撴浛鎹� + if (window.GLOB.externalDatabase !== null) { + _option.sql = _option.sql.replace(/@db@/ig, `[${window.GLOB.externalDatabase}]..`) + } + if (item.database === 'sso') { + mainItems.push(`select '${item.field}' as obj_name,'${_option.field}' as arr_field,'${window.btoa(window.encodeURIComponent(_option.sql))}' as LText`) + } else { + localItems.push(`select '${item.field}' as obj_name,'${_option.field}' as arr_field,'${window.btoa(window.encodeURIComponent(_option.sql))}' as LText`) + } + } + } + item.oriOptions = fromJS(item.options).toJS() + } + + _list.push(item) + }) + + let _groups = [] + _list = _list.map(item => { + if (item.type === 'link') { + let supItem = _list.filter(form => form.field === item.linkField)[0] + + if (!supItem) { + notification.warning({ + top: 92, + message: '鏈煡璇㈠埌鎼滅储鏉′欢銆�' + item.label + '銆嬪叧鑱斿瓧娈碉紒', + duration: 5 + }) + item.supInitVal = '' + } else { + item.supInitVal = supItem.initval + item.options = item.oriOptions.filter(option => option.ParentID === supItem.initval) + } + } else if (item.type === 'group' && item.Hide !== 'true') { + _groups.push(fromJS(item).toJS()) + } + + return item + }) + + this.setState({ + match: match, + label: label, + style: style, + required: required, + searchlist: _list, + groups: _groups + }, () => { + if (this.props.menuType !== 'HS' && options.sysType === 'local' && !window.GLOB.systemType) { + this.improveSimpleSearch(deForms) + } else { + this.improveSearch(mainItems, localItems) + } + }) + } + + // 鏌ヨ涓嬫媺鑿滃崟 + improveSearch = (mainItems, localItems) => { + const { menuType, BID } = this.props + let deffers = [] + + if (menuType !== 'HS' && window.GLOB.systemType !== 'production') { + localItems = [...localItems, ...mainItems] + mainItems = [] + } + + // 鏈湴璇锋眰 + let param = { + func: 'sPC_Get_SelectedList', + LText: localItems.join(' union all '), + obj_name: '', + arr_field: '', + table_type: 'Y' + } + + if (BID) { + param.BID = BID + } + + if (param.LText) { + 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 (menuType === 'HS') { // 浜戠鏁版嵁楠岃瘉 + param.open_key = Utils.encryptOpenKey(param.secretkey, param.timestamp) + } + + deffers.push( + new Promise(resolve => { + Api.getSystemCacheConfig(param).then(res => { + if (!res.status) { + notification.warning({ + top: 92, + message: res.message, + duration: 5 + }) + } + resolve(res) + }) + }) + ) + } + + // 绯荤粺璇锋眰 + let mainparam = { + func: 'sPC_Get_SelectedList', + LText: mainItems.join(' union all '), + obj_name: '', + arr_field: '', + table_type: 'Y' + } + + if (BID) { + mainparam.BID = BID + } + + if (mainparam.LText) { + mainparam.LText = Utils.formatOptions(mainparam.LText) + mainparam.timestamp = moment().format('YYYY-MM-DD HH:mm:ss') + mainparam.secretkey = Utils.encrypt(mainparam.LText, mainparam.timestamp) + + if (menuType === 'HS') { // 浜戠鏁版嵁楠岃瘉 + mainparam.open_key = Utils.encryptOpenKey(mainparam.secretkey, mainparam.timestamp) + if (options.cloudServiceApi) { + mainparam.rduri = options.cloudServiceApi + mainparam.userid = sessionStorage.getItem('CloudUserID') || '' + mainparam.LoginUID = sessionStorage.getItem('CloudLoginUID') || '' + } + } else if (window.GLOB.mainSystemApi) { + mainparam.rduri = window.GLOB.mainSystemApi + } + + deffers.push( + new Promise(resolve => { + Api.getSystemCacheConfig(mainparam).then(res => { + if (!res.status) { + notification.warning({ + top: 92, + message: res.message, + duration: 5 + }) + } + resolve(res) + }) + }) + ) + } + + Promise.all(deffers).then(response => { + let result = {...response[0], ...(response[1] || {})} + + delete result.ErrCode + delete result.ErrMesg + delete result.message + delete result.status + + let _searchlist = this.state.searchlist.map(item => { + if (['select', 'link', 'multiselect'].includes(item.type) && result[item.field] && result[item.field].length > 0) { + let options = result[item.field].map(cell => { + let _item = { + key: Utils.getuuid(), + Value: cell[item.valueField], + Text: cell[item.valueText] + } + + if (item.type === 'link') { + _item.ParentID = cell[item.linkField] + } + + return _item + }) + + item.oriOptions = [...item.oriOptions, ...options] + } + return item + }) + + this.setState({ + searchlist: _searchlist.map(item => { + if (item.type === 'link') { + if (item.supInitVal) { + item.options = item.oriOptions.filter(option => option.ParentID === item.supInitVal) + } else { + item.options = item.oriOptions + } + } else if (item.type === 'select' || item.type === 'multiselect') { + item.options = item.oriOptions + } + + return item + }) + }) + }) + } + + // 娴嬭瘯绯荤粺鍗曚釜璇锋眰涓嬫媺閫夐」 + improveSimpleSearch = (deForms) => { + if (deForms.length === 0) return + + let deffers = deForms.map(item => { + let param = { + func: 'sPC_Get_SelectedList', + LText: item.data_sql, + obj_name: item.field, + arr_field: item.arr_field + } + + if (this.props.BID) { + param.BID = this.props.BID + } + + param.timestamp = moment().format('YYYY-MM-DD HH:mm:ss') + param.secretkey = Utils.encrypt(param.LText, param.timestamp) + + return ( + new Promise(resolve => { + Api.getSystemCacheConfig(param).then(res => { + if (!res.status) { + notification.warning({ + top: 92, + message: res.message, + duration: 5 + }) + } + resolve(res) + }) + }) + ) + }) + + Promise.all(deffers).then(response => { + let result = {} + + response.forEach(res => { + result = {...result, ...res} + }) + + delete result.ErrCode + delete result.ErrMesg + delete result.message + delete result.status + + let _searchlist = this.state.searchlist.map(item => { + if (['select', 'link', 'multiselect'].includes(item.type) && result[item.field] && result[item.field].length > 0) { + let options = result[item.field].map(cell => { + let _item = { + key: Utils.getuuid(), + Value: cell[item.valueField], + Text: cell[item.valueText] + } + + if (item.type === 'link') { + _item.ParentID = cell[item.linkField] + } + + return _item + }) + + item.oriOptions = [...item.oriOptions, ...options] + } + return item + }) + + this.setState({ + searchlist: _searchlist.map(item => { + if (item.type === 'link') { + if (item.supInitVal) { + item.options = item.oriOptions.filter(option => option.ParentID === item.supInitVal) + } else { + item.options = item.oriOptions + } + } else if (item.type === 'select' || item.type === 'multiselect') { + item.options = item.oriOptions + } + + return item + }) + }) + }) + } + + resetform = (formlist, supfields, index, fieldsvalue) => { + index++ + let subfields = [] + + supfields.forEach(supfield => { + formlist = formlist.map(item => { + if (item.type === 'link' && item.linkField === supfield.field) { + item.options = item.oriOptions.filter(option => option.ParentID === supfield.initval) + item.initval = item.options[0] ? item.options[0].Value : '' + + if (this.props.form.getFieldValue(item.field) !== undefined) { + fieldsvalue[item.field] = item.initval + } + + subfields.push(item) + } + return item + }) + }) + + if (subfields.length === 0 || index > 6) { + return formlist + } else { + return this.resetform(formlist, subfields, index, fieldsvalue) + } + } + + selectChange = (_field, value) => { + let formlist = fromJS(this.state.searchlist).toJS() + + let subfields = [] + let fieldsvalue = {} + formlist = formlist.map(item => { + if (item.type === 'link' && item.linkField === _field.field) { + item.options = item.oriOptions.filter(option => option.ParentID === value) + item.initval = item.options[0] ? item.options[0].Value : '' + + if (this.props.form.getFieldValue(item.field) !== undefined) { + fieldsvalue[item.field] = item.initval + } + + subfields.push(item) + } + return item + }) + + if (subfields.length === 0) { + this.searchChange() + return + } + + formlist = this.resetform(formlist, subfields, 0, fieldsvalue) + + if (Object.keys(fieldsvalue).length > 0) { + this.props.form.setFieldsValue(fieldsvalue) + } + + this.setState({ + searchlist: formlist + }, () => { + this.searchChange() + }) + } + + getFields() { + const { getFieldDecorator } = this.props.form + const fields = [] + + this.state.searchlist.forEach((item, index) => { + if (item.Hide === 'true') return + + if (item.type === 'text') { // 鏂囨湰鎼滅储 + fields.push( + <Col span={item.ratio || 6} key={index}> + <Form.Item label={item.label}> + {getFieldDecorator(item.field, { + initialValue: item.initval, + rules: [ + { + required: item.required === 'true', + message: this.state.dict['form.required.input'] + item.label + '!' + } + ] + })(<Input placeholder="" autoComplete="off" />)} + </Form.Item> + </Col> + ) + } else if (item.type === 'select') { // 涓嬫媺鎼滅储 + fields.push( + <Col span={item.ratio || 6} key={index}> + <Form.Item label={item.label}> + {getFieldDecorator(item.field, { + initialValue: item.initval, + rules: [ + { + required: item.required === 'true', + message: this.state.dict['form.required.select'] + item.label + '!' + } + ] + })( + <Select + showSearch + onChange={(value) => {this.selectChange(item, value)}} + filterOption={(input, option) => option.props.children.toLowerCase().indexOf(input.toLowerCase()) >= 0} + getPopupContainer={() => document.getElementById(this.state.formId)} + > + {item.options.map((option, i) => + <Select.Option id={`${i}`} title={option.Text} key={`${i}`} value={option.Value}>{option.Text}</Select.Option> + )} + </Select> + )} + </Form.Item> + </Col> + ) + } else if (item.type === 'multiselect') { // 涓嬫媺澶氶�� + let _initval = item.initval ? item.initval.split(',').filter(Boolean) : [] + fields.push( + <Col span={item.ratio || 6} key={index}> + <Form.Item label={item.label}> + {getFieldDecorator(item.field, { + initialValue: _initval, + rules: [ + { + required: item.required === 'true', + message: this.state.dict['form.required.select'] + item.label + '!' + } + ] + })( + <Select + showSearch + mode="multiple" + onChange={this.searchChange} + filterOption={(input, option) => option.props.children.toLowerCase().indexOf(input.toLowerCase()) >= 0} + getPopupContainer={() => document.getElementById(this.state.formId)} + > + {item.options.map((option, i) => + <Select.Option id={`${i}`} title={option.Text} key={`${i}`} value={option.Value}>{option.Text}</Select.Option> + )} + </Select> + )} + </Form.Item> + </Col> + ) + } else if (item.type === 'date') { // 鏃堕棿鎼滅储 + fields.push( + <Col span={item.ratio || 6} key={index}> + <Form.Item label={item.label}> + {getFieldDecorator(item.field, { + initialValue: item.initval ? moment().subtract(item.initval, 'days') : null, + rules: [ + { + required: item.required === 'true', + message: this.state.dict['form.required.select'] + item.label + '!' + } + ] + })( + <DatePicker onChange={this.searchChange} getCalendarContainer={() => document.getElementById(this.state.formId)} /> + )} + </Form.Item> + </Col> + ) + } else if (item.type === 'datemonth') { + fields.push( + <Col span={item.ratio || 6} key={index}> + <Form.Item label={item.label}> + {getFieldDecorator(item.field, { + initialValue: item.initval ? moment().subtract(item.initval, 'month') : null, + rules: [ + { + required: item.required === 'true', + message: this.state.dict['form.required.select'] + item.label + '!' + } + ] + })( + <MonthPicker onChange={this.searchChange} getCalendarContainer={() => document.getElementById(this.state.formId)} /> + )} + </Form.Item> + </Col> + ) + } else if (item.type === 'dateweek') { + fields.push( + <Col span={item.ratio || 6} key={index}> + <Form.Item label={item.label}> + {getFieldDecorator(item.field, { + initialValue: item.initval ? moment().subtract(item.initval * 7, 'days') : null, + rules: [ + { + required: item.required === 'true', + message: this.state.dict['form.required.select'] + item.label + '!' + } + ] + })( + <WeekPicker onChange={this.searchChange} getCalendarContainer={() => document.getElementById(this.state.formId)} /> + )} + </Form.Item> + </Col> + ) + } else if (item.type === 'daterange') { + let _defaultValue = [null, null] + + if (item.initval) { + try { + let _initval = JSON.parse(item.initval) + _defaultValue = [moment().subtract(_initval[0], 'days'), moment().subtract(_initval[1], 'days')] + } catch { + _defaultValue = [null, null] + } + } + + fields.push( + <Col className="daterange" span={item.ratio || 6} key={index}> + <Form.Item label={item.label}> + {getFieldDecorator(item.field, + { + initialValue: _defaultValue, + rules: [ + { + required: item.required === 'true', + message: this.state.dict['form.required.select'] + item.label + '!' + } + ] + })( + <RangePicker + placeholder={['寮�濮嬫棩鏈�', '缁撴潫鏃ユ湡']} + renderExtraFooter={() => 'extra footer'} + onChange={this.searchChange} + getCalendarContainer={() => document.getElementById(this.state.formId)} + /> + )} + </Form.Item> + </Col> + ) + } else if (item.type === 'group') { + fields.push( + <Col span={item.ratio || 6} key={index}> + <Form.Item label={item.label} className={item.required === 'true' ? 'group-required' : ''}> + <DateGroup ref={item.uuid} position={index} card={item} onGroupChange={this.searchChange} /> + </Form.Item> + </Col> + ) + } + }) + + fields.push( + <Col span={6} style={{ whiteSpace: 'nowrap' }} key="actions"> + <Form.Item label={' '} colon={false} style={{ minHeight: '40px' }}> + <Button type="primary" htmlType="submit"> + {this.state.dict['main.search']} + </Button> + <Button style={{ marginLeft: 8 }} onClick={this.handleReset}> + {this.state.dict['main.reset']} + </Button> + </Form.Item> + </Col> + ) + + return fields + } + + addHideFieldValue = (values) => { + const { searchlist } = this.state + let hideValue = {} + searchlist.forEach(item => { + if (item.Hide === 'true') { + let value = '' + + if (item.type === 'multiselect') { // 涓嬫媺澶氶�� + value = item.initval ? item.initval.split(',').filter(Boolean) : [] + } else if (item.type === 'date') { // 鏃堕棿鎼滅储 + value = item.initval ? moment().subtract(item.initval, 'days') : '' + } else if (item.type === 'datemonth') { + value = item.initval ? moment().subtract(item.initval, 'month') : '' + } else if (item.type === 'dateweek') { + value = item.initval ? moment().subtract(item.initval * 7, 'days') : '' + } else if (item.type === 'daterange') { + if (item.initval) { + try { + let _initval = JSON.parse(item.initval) + value = [moment().subtract(_initval[0], 'days'), moment().subtract(_initval[1], 'days')] + } catch { + value = '' + } + } + } else if (item.type !== 'group') { + value = item.initval + } + + hideValue[item.field] = value + } + }) + + return {...hideValue, ...values} + } + + handleSearch = (e) => { + // 鍥炶溅鎴栫偣鍑绘悳绱� + e.preventDefault() + this.props.form.validateFields((err, values) => { + if (!err) { + values = this.addHideFieldValue(values) + let searches = this.getFieldsValues(values) + this.props.refreshdata(searches) + } + }) + } + + searchChange = () => { + this.setState({}, () => { + this.props.form.validateFields((err, values) => { + if (!err) { + values = this.addHideFieldValue(values) + let searches = this.getFieldsValues(values) + this.props.refreshdata(searches) + } + }) + }) + } + + /** + * @description 鎼滅储鏉′欢閲嶇疆 + */ + handleReset = () => { + const { groups } = this.state + + if (groups.length > 0) { + groups.forEach(item => { + this.refs[item.uuid].reset() + }) + } + + let searchlist = this.state.searchlist.map(item => { + item.initval = item.oriInitval + return item + }) + + this.setState({searchlist}, () => { + this.props.form.resetFields() + this.props.form.validateFields((err, values) => { + if (!err) { + // 寮傛鑾峰彇鏇存柊鍚庣殑鏃堕棿缁� + this.setState({}, () => { + values = this.addHideFieldValue(values) + let searches = this.getFieldsValues(values) + this.props.refreshdata(searches) + }) + } + }) + }) + } + + getFieldsValues = (values) => { + const { groups } = this.state + // 鑾峰彇鎼滅储鏉′欢鍊� + let search = [] + Object.keys(values).forEach(key => { + let _value = '' + if (this.state.style[key] === 'daterange') { + if (values[key].length > 0 && values[key][0] && values[key][1]) { + _value = [moment(values[key][0]).format('YYYY-MM-DD'), moment(values[key][1]).format('YYYY-MM-DD')] + } + } else if (this.state.style[key] === 'dateweek') { + if (values[key]) { + _value = [moment(values[key]).startOf('week').format('YYYY-MM-DD'), moment(values[key]).endOf('week').format('YYYY-MM-DD')] + } + } else if (this.state.style[key] === 'date') { + if (values[key]) { + _value = moment(values[key]).format('YYYY-MM-DD') + } + } else if (this.state.style[key] === 'datemonth') { + if (values[key]) { + _value = moment(values[key]).format('YYYY-MM') + } + } else if (this.state.style[key] === 'multiselect') { + _value = values[key] || [] + + } else { + _value = (values[key] || values[key] === 0) ? values[key] : '' + + _value = _value.replace(/(^\s*|\s*$)/ig, '') + } + + search.push({ + type: this.state.style[key], + key: key.replace(/@tail@$/, ''), + value: _value, + label: this.state.label[key], + match: this.state.match[key], + required: this.state.required[key] + }) + }) + + if (groups.length > 0) { + groups.forEach(item => { + let items = this.refs[item.uuid].getSearchItems() + search.push(...items) + }) + } + + return search + } + + render() { + const formItemLayout = { + labelCol: { + xs: { span: 24 }, + sm: { span: 8 } + }, + wrapperCol: { + xs: { span: 24 }, + sm: { span: 16 } + } + } + + return ( + <Form {...formItemLayout} className="custom-main-search" id={this.state.formId} onSubmit={this.handleSearch}> + <Row gutter={24}>{this.getFields()}</Row> + </Form> + ) + } +} + +export default Form.create()(MainSearch) \ No newline at end of file diff --git a/src/tabviews/custom/components/search/main-search/index.scss b/src/tabviews/custom/components/search/main-search/index.scss new file mode 100644 index 0000000..4b220df --- /dev/null +++ b/src/tabviews/custom/components/search/main-search/index.scss @@ -0,0 +1,38 @@ +.custom-main-search { + .ant-form-item { + display: flex; + margin-bottom: 0px; + min-height: 60px; + .ant-form-explain { + white-space: nowrap; + } + } + .ant-form-item-control-wrapper { + flex: 1; + width: calc(100% - 100px); + } + .ant-form-item-label { + text-overflow: ellipsis; + } + .daterange .ant-calendar-picker-input { + padding: 4px 20px 4px 5px; + font-size: 13px; + } + .ant-select-dropdown { + z-index: 10 !important; + } + .ant-calendar-picker-container { + z-index: 10 !important; + } + .group-required { + label::before { + display: inline-block; + margin-right: 4px; + color: #f5222d; + font-size: 14px; + font-family: SimSun, sans-serif; + line-height: 1; + content: '*'; + } + } +} \ No newline at end of file diff --git a/src/tabviews/custom/components/share/tabtransfer/index.jsx b/src/tabviews/custom/components/share/tabtransfer/index.jsx index 9bddc70..0238c31 100644 --- a/src/tabviews/custom/components/share/tabtransfer/index.jsx +++ b/src/tabviews/custom/components/share/tabtransfer/index.jsx @@ -1,17 +1,20 @@ import React, {Component} from 'react' import PropTypes from 'prop-types' -// import { fromJS } from 'immutable' +import { connect } from 'react-redux' +import { is, fromJS } from 'immutable' import { Row, Col, Empty } from 'antd' import asyncSpinComponent from '@/utils/asyncSpinComponent' +import Utils from '@/utils/utils.js' import './index.scss' // 閫氱敤缁勪欢 const AntvBarAndLine = asyncSpinComponent(() => import('@/tabviews/custom/components/chart/antv-bar-line')) +const MainSearch = asyncSpinComponent(() => import('@/tabviews/custom/components/search/main-search')) const AntvPie = asyncSpinComponent(() => import('@/tabviews/custom/components/chart/antv-pie')) const AntvTabs = asyncSpinComponent(() => import('@/tabviews/custom/components/tabs/antv-tabs')) -class MainSearch extends Component { +class TabTransfer extends Component { static propTpyes = { BID: PropTypes.any, // 鐖剁骇Id config: PropTypes.object, // 缁勪欢閰嶇疆淇℃伅 @@ -20,14 +23,57 @@ dataManager: PropTypes.any, // 鏁版嵁鏉冮檺 } - state = {} + state = { + mainSearch: [], + self: false + } UNSAFE_componentWillMount () { + const { config, mainSearch } = this.props + // 鑾峰彇涓绘悳绱㈡潯浠� + let _mainSearch = [] + let self = false + config.components.forEach(component => { + if (component.type === 'search') { + self = true + component.search = component.search.map(item => { + item.oriInitval = item.initval + if (!item.blacklist || item.blacklist.length === 0) return item + + let _black = item.blacklist.filter(v => { + return this.props.permRoles.indexOf(v) !== -1 + }) + + if (_black.length > 0) { + item.Hide = 'true' + } + + return item + }) + + _mainSearch = Utils.initMainSearch(component.search) + } + }) + + this.setState({mainSearch: self ? _mainSearch : fromJS(mainSearch).toJS(), self}) + } + + UNSAFE_componentWillReceiveProps(nextProps) { + const { self } = this.state + + if (!self && !is(fromJS(this.props.mainSearch), fromJS(nextProps.mainSearch))) { + this.setState({mainSearch: fromJS(nextProps.mainSearch).toJS()}) + } + } + + resetSearch = (search) => { + this.setState({mainSearch: search}) } getComponents = () => { - const { menuType, dataManager, BID, mainSearch, config } = this.props + const { menuType, dataManager, BID, config } = this.props + const { mainSearch } = this.state if (!config || !config.components || config.components.length === 0) return (<Empty description={false} />) @@ -42,6 +88,12 @@ return ( <Col span={item.width} key={item.uuid}> <AntvPie config={item} BID={BID} mainSearch={mainSearch} menuType={menuType} dataManager={dataManager} /> + </Col> + ) + } else if (item.type === 'search') { + return ( + <Col span={item.width} key={item.uuid}> + <MainSearch config={item} BID={BID} mainSearch={mainSearch} menuType={menuType} dataManager={dataManager} refreshdata={this.resetSearch} /> </Col> ) } else if (item.type === 'tabs') { @@ -63,4 +115,17 @@ } } -export default MainSearch \ No newline at end of file +const mapStateToProps = (state) => { + return { + menuType: state.editLevel, + permAction: state.permAction, + permRoles: state.permRoles, + dataManager: state.dataManager + } +} + +const mapDispatchToProps = () => { + return {} +} + +export default connect(mapStateToProps, mapDispatchToProps)(TabTransfer) \ No newline at end of file diff --git a/src/tabviews/custom/components/tabs/antv-tabs/index.jsx b/src/tabviews/custom/components/tabs/antv-tabs/index.jsx index 839ca01..1f89c25 100644 --- a/src/tabviews/custom/components/tabs/antv-tabs/index.jsx +++ b/src/tabviews/custom/components/tabs/antv-tabs/index.jsx @@ -5,8 +5,6 @@ import asyncComponent from '@/utils/asyncComponent' -import zhCN from '@/locales/zh-CN/model.js' -import enUS from '@/locales/en-US/model.js' import './index.scss' const TabTransfer = asyncComponent(() => import('../../share/tabtransfer')) @@ -17,13 +15,12 @@ static propTpyes = { BID: PropTypes.any, // 鐖剁骇Id config: PropTypes.object, // 缁勪欢閰嶇疆淇℃伅 - mainSearch: PropTypes.any, // 鍏ㄥ眬鎼滅储鏉′欢 + mainSearch: PropTypes.any, // 澶栧眰鎼滅储鏉′欢 menuType: PropTypes.any, // 鑿滃崟绫诲瀷 dataManager: PropTypes.any, // 鏁版嵁鏉冮檺 } state = { - dict: localStorage.getItem('lang') !== 'en-US' ? zhCN : enUS, tabs: null } @@ -50,7 +47,7 @@ } render() { - const { BID, mainSearch, menuType, dataManager } = this.props + const { BID, mainSearch } = this.props const { tabs } = this.state return ( @@ -58,7 +55,7 @@ <Tabs defaultActiveKey="1" tabPosition={tabs.setting.position} type={tabs.setting.tabStyle}> {tabs.subtabs.map(tab => ( <TabPane tab={<span>{tab.icon ? <Icon type={tab.icon} /> : null}{tab.label}</span>} key={tab.uuid}> - <TabTransfer config={tab} BID={BID} mainSearch={mainSearch} menuType={menuType} dataManager={dataManager}/> + <TabTransfer config={tab} BID={BID} mainSearch={mainSearch}/> </TabPane> ))} </Tabs> diff --git a/src/tabviews/custom/index.jsx b/src/tabviews/custom/index.jsx index cd29a77..a3a5325 100644 --- a/src/tabviews/custom/index.jsx +++ b/src/tabviews/custom/index.jsx @@ -1,6 +1,6 @@ import React, {Component} from 'react' import PropTypes from 'prop-types' -import {connect} from 'react-redux' +import { connect } from 'react-redux' import { is, fromJS } from 'immutable' import { notification, Spin, Row, Col, Button, message } from 'antd' import moment from 'moment' @@ -22,6 +22,7 @@ const AntvTabs = asyncSpinComponent(() => import('./components/tabs/antv-tabs')) const DataCard = asyncSpinComponent(() => import('./components/card/data-card')) const PropCard = asyncSpinComponent(() => import('./components/card/prop-card')) +const MainSearch = asyncSpinComponent(() => import('./components/search/main-search')) class CustomPage extends Component { static propTpyes = { @@ -365,27 +366,6 @@ }) } - /** - * @description 鎼滅储鏉′欢鏀瑰彉鏃讹紝閲嶇疆琛ㄦ牸鏁版嵁 - * 鍚湁鍒濆涓嶅姞杞界殑椤甸潰锛屼慨鏀硅缃� - */ - refreshbysearch = (searches) => { - this.setState({ - mainSearch: searches - }) - } - - - /** - * @description 椤甸潰鍒锋柊锛岄噸鏂拌幏鍙栭厤缃� - */ - reloadview = () => { - this.setState({ loadingview: true, viewlost: false, lostmsg: '', data: null, loading: false, search: '' - }, () => { - this.loadconfig() - }) - } - handleviewconfig = (e) => { e.stopPropagation() @@ -413,12 +393,7 @@ } UNSAFE_componentWillReceiveProps(nextProps) { - if (nextProps.refreshTab && nextProps.refreshTab.MenuID === this.props.MenuID) { - if (nextProps.refreshTab.position === 'view') { - this.reloadview() - } - this.props.refreshTabView('') - } + } shouldComponentUpdate (nextProps, nextState) { @@ -432,6 +407,10 @@ this.setState = () => { return } + } + + resetSearch = (search) => { + this.setState({mainSearch: search}) } getComponents = () => { @@ -453,10 +432,16 @@ <AntvPie config={item} data={data} BID={BID} mainSearch={mainSearch} menuType={menuType} dataManager={dataManager} /> </Col> ) + } else if (item.type === 'search') { + return ( + <Col span={item.width} key={item.uuid}> + <MainSearch config={item} data={data} BID={BID} mainSearch={mainSearch} menuType={menuType} dataManager={dataManager} refreshdata={this.resetSearch} /> + </Col> + ) } else if (item.type === 'tabs') { return ( <Col span={item.width} key={item.uuid}> - <AntvTabs config={item} BID={BID} mainSearch={mainSearch} menuType={menuType} dataManager={dataManager} /> + <AntvTabs config={item} BID={BID} mainSearch={mainSearch} /> </Col> ) } else if (item.type === 'card') { diff --git a/src/tabviews/iframe/index.jsx b/src/tabviews/iframe/index.jsx index d82dfe1..11b6299 100644 --- a/src/tabviews/iframe/index.jsx +++ b/src/tabviews/iframe/index.jsx @@ -9,10 +9,7 @@ render () { return ( - <iframe - title={this.props.title} - src={this.props.url} - /> + <iframe title={this.props.title} src={this.props.url} /> ) } } diff --git a/src/tabviews/scriptmanage/index.jsx b/src/tabviews/scriptmanage/index.jsx index a76aebb..3b8541d 100644 --- a/src/tabviews/scriptmanage/index.jsx +++ b/src/tabviews/scriptmanage/index.jsx @@ -166,7 +166,8 @@ let param = { func: 'sPC_Get_TableData', obj_name: 'data', - arr_field: arr_field + arr_field: arr_field, + menuname: this.props.MenuName || '' } let _orderBy = orderBy || setting.order diff --git a/src/tabviews/subtable/index.jsx b/src/tabviews/subtable/index.jsx index cba767a..5df98ae 100644 --- a/src/tabviews/subtable/index.jsx +++ b/src/tabviews/subtable/index.jsx @@ -435,6 +435,10 @@ this.handleTableId() + if (param.func === 'sPC_Get_TableData') { + param.menuname = this.props.Tab.label || '' + } + let result = await Api.genericInterface(param) if (result.status) { this.setState({ @@ -493,6 +497,10 @@ let _orderBy = orderBy || setting.order let param = UtilsDM.getStatQueryDataParams(setting, statFields, searches, _orderBy, _BID, this.props.menuType, this.props.dataManager) + if (param.func === 'sPC_Get_TableData') { + param.menuname = this.props.Tab.label || '' + } + Api.genericInterface(param).then(res => { if (res.status) { let _data = res.data[0] @@ -719,6 +727,7 @@ BData={this.props.BData} MenuID={this.props.MenuID} selectedData={selectedData} + MenuName={this.props.Tab.label} logcolumns={this.state.logcolumns} refreshdata={this.refreshbyaction} ContainerId={this.props.ContainerId} @@ -743,6 +752,7 @@ total={this.state.total} MenuID={this.props.MenuID} loading={this.state.loading} + MenuName={this.props.Tab.label} refreshdata={this.refreshbytable} logcolumns={this.state.logcolumns} statFValue={this.state.statFValue} @@ -767,6 +777,7 @@ MenuID={this.props.MenuID} loading={this.state.loading} tableId={this.props.Tab.uuid} + MenuName={this.props.Tab.label} logcolumns={this.state.logcolumns} refreshdata={this.refreshbyaction} handleTableId={this.handleTableId} @@ -783,6 +794,7 @@ BID={this.props.BID} Tab={this.props.Tab} data={this.state.data} + MenuName={this.props.Tab.label} getexceloutparam={this.getexceloutparam} loading={this.state.loading} /> diff --git a/src/tabviews/subtabtable/index.jsx b/src/tabviews/subtabtable/index.jsx index d6a86cf..7602306 100644 --- a/src/tabviews/subtabtable/index.jsx +++ b/src/tabviews/subtabtable/index.jsx @@ -349,6 +349,10 @@ let _orderBy = orderBy || setting.order let param = UtilsDM.getQueryDataParams(setting, arr_field, searches, _orderBy, pageIndex, pageSize, BID, this.props.menuType, this.props.dataManager) + if (param.func === 'sPC_Get_TableData') { + param.menuname = this.props.Tab.label || '' + } + let result = await Api.genericInterface(param) if (result.status) { this.setState({ @@ -393,6 +397,10 @@ let _orderBy = orderBy || setting.order let param = UtilsDM.getStatQueryDataParams(setting, statFields, searches, _orderBy, BID, this.props.menuType, this.props.dataManager) + if (param.func === 'sPC_Get_TableData') { + param.menuname = this.props.Tab.label || '' + } + Api.genericInterface(param).then(res => { if (res.status) { let _data = res.data[0] @@ -592,6 +600,7 @@ BData={this.props.BData} selectedData={selectedData} MenuID={this.props.SupMenuID} + MenuName={this.props.Tab.label} logcolumns={this.state.logcolumns} refreshdata={this.refreshbyaction} getexceloutparam={this.getexceloutparam} @@ -610,6 +619,7 @@ total={this.state.total} MenuID={this.props.MenuID} loading={this.state.loading} + MenuName={this.props.Tab.label} refreshdata={this.refreshbytable} logcolumns={this.state.logcolumns} statFValue={this.state.statFValue} @@ -627,9 +637,10 @@ plot={item} config={config} BID={this.props.BID} - BData={this.props.BData} data={this.state.data} + BData={this.props.BData} loading={this.state.loading} + MenuName={this.props.Tab.label} logcolumns={this.state.logcolumns} refreshdata={this.refreshbyaction} handleTableId={() => {}} @@ -644,6 +655,7 @@ config={config} data={this.state.data} loading={this.state.loading} + MenuName={this.props.Tab.label} /> </Col> ) diff --git a/src/tabviews/verupmanage/index.jsx b/src/tabviews/verupmanage/index.jsx index 0fbb0c8..5e4ca30 100644 --- a/src/tabviews/verupmanage/index.jsx +++ b/src/tabviews/verupmanage/index.jsx @@ -224,7 +224,8 @@ let param = { func: 'sPC_Get_TableData', obj_name: 'data', - arr_field: arr_field + arr_field: arr_field, + menuname: this.props.MenuName || '' } let _orderBy = orderBy || setting.order diff --git a/src/tabviews/verupmanage/subtabtable/index.jsx b/src/tabviews/verupmanage/subtabtable/index.jsx index c87c785..cb714a6 100644 --- a/src/tabviews/verupmanage/subtabtable/index.jsx +++ b/src/tabviews/verupmanage/subtabtable/index.jsx @@ -248,7 +248,8 @@ func: 'sPC_Get_TableData', obj_name: 'data', arr_field: arr_field, - BID: BID + BID: BID, + menuname: this.props.Tab.label || '' } let _orderBy = orderBy || setting.order diff --git a/src/tabviews/zshare/actionList/excelInbutton/index.jsx b/src/tabviews/zshare/actionList/excelInbutton/index.jsx index 17a718a..1d59ff2 100644 --- a/src/tabviews/zshare/actionList/excelInbutton/index.jsx +++ b/src/tabviews/zshare/actionList/excelInbutton/index.jsx @@ -18,6 +18,7 @@ static propTpyes = { show: PropTypes.any, // 鏄剧ず鏍峰紡 BID: PropTypes.string, // 涓昏〃ID + MenuName: PropTypes.any, // 鑿滃崟鍚嶇О selectedData: PropTypes.any, // 瀛愯〃涓�夋嫨鏁版嵁 Tab: PropTypes.any, // 濡傛灉褰撳墠鍏冪礌涓烘爣绛炬椂锛宼ab涓烘爣绛句俊鎭� btn: PropTypes.object, // 鎸夐挳 @@ -188,7 +189,7 @@ * @description Excel 瀵煎叆 */ getexceldata = (data, errors, sheetName) => { - const { btn } = this.props + const { btn, MenuName } = this.props if (errors) { if (errors === 'notexit') { @@ -275,6 +276,8 @@ param.open_key = Utils.encryptOpenKey(param.secretkey, param.timestamp) } + param.menuname = `${MenuName ? MenuName + '-' : ''}${btn.label}` + Api.genericInterface(param).then((res) => { if (res.status) { this.execSuccess(res) diff --git a/src/tabviews/zshare/actionList/exceloutbutton/index.jsx b/src/tabviews/zshare/actionList/exceloutbutton/index.jsx index fc82316..030e799 100644 --- a/src/tabviews/zshare/actionList/exceloutbutton/index.jsx +++ b/src/tabviews/zshare/actionList/exceloutbutton/index.jsx @@ -18,6 +18,7 @@ static propTpyes = { BID: PropTypes.string, // 涓昏〃ID show: PropTypes.any, // 鏄剧ず鏍峰紡 + MenuName: PropTypes.any, // 鑿滃崟鍚嶇О Tab: PropTypes.any, // 濡傛灉褰撳墠鍏冪礌涓烘爣绛炬椂锛宼ab涓烘爣绛句俊鎭� btn: PropTypes.object, // 鎸夐挳 setting: PropTypes.any, // 椤甸潰閫氱敤璁剧疆 @@ -440,7 +441,7 @@ * @description 鎵ц鑷畾涔夎剼鏈� */ execCustomScript = () => { - const { btn } = this.props + const { btn, MenuName } = this.props const { search } = this.state let script = btn.verify.script @@ -464,7 +465,8 @@ }) let param = { - func: 'sPC_TableData_InUpDe' + func: 'sPC_TableData_InUpDe', + menuname: `${MenuName ? MenuName + '-' : ''}${btn.label}` } if (this.props.BID) { @@ -527,7 +529,7 @@ * @description 鑾峰彇榛樿瀛樺偍杩囩▼璇锋眰鍙傛暟 */ getExcelDefaultParam = (arr_field, orderBy, search, pagination = false, pageIndex = 1, pageSize = 100) => { - const { setting } = this.props + const { setting, MenuName, btn } = this.props let _search = Utils.joinMainSearchkey(search) @@ -538,7 +540,8 @@ obj_name: 'data', arr_field: arr_field, custom_script: setting.customScript, - default_sql: setting.default || 'true' + default_sql: setting.default || 'true', + menuname: `${MenuName ? MenuName + '-' : ''}${btn.label}` } // 鏁版嵁绠$悊鏉冮檺 diff --git a/src/tabviews/zshare/actionList/index.jsx b/src/tabviews/zshare/actionList/index.jsx index 67f6200..3d00fe4 100644 --- a/src/tabviews/zshare/actionList/index.jsx +++ b/src/tabviews/zshare/actionList/index.jsx @@ -21,6 +21,7 @@ static propTpyes = { BID: PropTypes.any, // 涓昏〃ID BData: PropTypes.any, // 涓昏〃鏁版嵁 + MenuName: PropTypes.any, // 鑿滃崟鍚嶇О selectedData: PropTypes.any, // 瀛愯〃涓�夋嫨鏁版嵁 Tab: PropTypes.any, // 濡傛灉褰撳墠鍏冪礌涓烘爣绛炬椂锛宼ab涓烘爣绛句俊鎭� MenuID: PropTypes.string, // 鑿滃崟ID @@ -49,7 +50,7 @@ } getButtonList = (actions) => { - const { BID, BData, MenuID, Tab, logcolumns, setting, ContainerId, selectedData, getexceloutparam } = this.props + const { BID, BData, MenuID, Tab, logcolumns, setting, ContainerId, selectedData, getexceloutparam, MenuName } = this.props return actions.map(item => { if (['exec', 'prompt', 'pop'].includes(item.OpenType)) { @@ -62,6 +63,7 @@ btn={item} BData={BData} setting={setting} + MenuName={MenuName} columns={logcolumns} ContainerId={ContainerId} selectedData={selectedData} @@ -77,6 +79,7 @@ Tab={Tab} btn={item} setting={setting} + MenuName={MenuName} selectedData={selectedData} updateStatus={this.updateStatus} /> @@ -90,6 +93,7 @@ Tab={Tab} btn={item} setting={setting} + MenuName={MenuName} getexceloutparam={getexceloutparam} updateStatus={this.updateStatus} /> diff --git a/src/tabviews/zshare/actionList/normalbutton/index.jsx b/src/tabviews/zshare/actionList/normalbutton/index.jsx index f8cce80..6a8abe7 100644 --- a/src/tabviews/zshare/actionList/normalbutton/index.jsx +++ b/src/tabviews/zshare/actionList/normalbutton/index.jsx @@ -22,6 +22,7 @@ show: PropTypes.any, // 鎸夐挳鏄剧ず鏍峰紡鎺у埗 BID: PropTypes.string, // 涓昏〃ID BData: PropTypes.any, // 涓昏〃鏁版嵁 + MenuName: PropTypes.any, // 鑿滃崟鍚嶇О style: PropTypes.any, // 鎸夐挳鏍峰紡 selectedData: PropTypes.any, // 瀛愯〃涓�夋嫨鏁版嵁 Tab: PropTypes.any, // 濡傛灉褰撳墠鍏冪礌涓烘爣绛炬椂锛宼ab涓烘爣绛句俊鎭� @@ -190,7 +191,7 @@ * @description 鎸夐挳鎻愪氦鎵ц */ execSubmit = (data, _resolve, formdata) => { - const { setting, columns, btn } = this.props + const { setting, columns, btn, MenuName } = this.props if (btn.intertype === 'inner' || btn.intertype === 'system') { // 鎵ц鏂瑰紡涓哄琛屾嫾鎺ワ紝涓旀墦寮�鏂瑰紡涓鸿〃鍗曟椂锛屼細杞负寰幆鍙戦�佽姹� // 鎵撳紑鏂瑰紡涓烘ā鎬佹锛屼娇鐢ㄥ唴閮ㄥ嚱鏁版坊鍔�(鏈夋壒閲忔坊鍔犲満鏅紝宸插幓闄�) @@ -309,6 +310,10 @@ param.timestamp = moment().format('YYYY-MM-DD HH:mm:ss') param.secretkey = Utils.encrypt(param.LTextOut, param.timestamp) param.open_key = Utils.encryptOpenKey(param.secretkey, param.timestamp) + } + + if (param.func === 'sPC_TableData_InUpDe') { + param.menuname = `${MenuName ? MenuName + '-' : ''}${btn.label}` } Api.genericInterface(param).then((res) => { @@ -437,6 +442,10 @@ param.open_key = Utils.encryptOpenKey(param.secretkey, param.timestamp) } + if (param.func === 'sPC_TableData_InUpDe') { + param.menuname = `${MenuName ? MenuName + '-' : ''}${btn.label}` + } + return param }) diff --git a/src/tabviews/zshare/cardcomponent/index.jsx b/src/tabviews/zshare/cardcomponent/index.jsx index a5ca725..d3283a3 100644 --- a/src/tabviews/zshare/cardcomponent/index.jsx +++ b/src/tabviews/zshare/cardcomponent/index.jsx @@ -22,6 +22,7 @@ type: PropTypes.any, // 鍗$墖绫诲瀷锛屾坊鍔犳寜閽负 insert BID: PropTypes.any, // 涓昏〃ID BData: PropTypes.any, // 涓昏〃鏁版嵁 + MenuName: PropTypes.any, // 鑿滃崟鍚嶇О Tab: PropTypes.any, // 濡傛灉褰撳墠鍏冪礌涓烘爣绛炬椂锛宼ab涓烘爣绛句俊鎭� MenuID: PropTypes.string, // 鑿滃崟ID setting: PropTypes.object, // 椤甸潰璁惧畾 @@ -129,7 +130,7 @@ * @description 鑾峰彇鎸夐挳鍏冪礌 */ getActionList = (actions, show) => { - const { BID, BData, Tab, setting, logcolumns, ContainerId, data, MenuID } = this.props + const { BID, BData, Tab, setting, logcolumns, ContainerId, data, MenuID, MenuName } = this.props return actions.map(item => { if (['exec', 'prompt', 'pop'].includes(item.OpenType)) { @@ -142,6 +143,7 @@ show={show} BData={BData} setting={setting} + MenuName={MenuName} columns={logcolumns} selectedData={[data]} ContainerId={ContainerId} @@ -505,6 +507,7 @@ show={'plus' + plusSize} BData={this.props.BData} setting={this.props.setting} + MenuName={this.props.MenuName} columns={this.props.logcolumns} selectedData={[]} ContainerId={this.props.ContainerId} @@ -523,6 +526,7 @@ BData: PropTypes.any, // 涓昏〃鏁版嵁 Tab: PropTypes.any, // 濡傛灉褰撳墠鍏冪礌涓烘爣绛炬椂锛宼ab涓烘爣绛句俊鎭� MenuID: PropTypes.string, // 鑿滃崟ID + MenuName: PropTypes.any, // 鑿滃崟鍚嶇О config: PropTypes.object, // 椤甸潰閰嶇疆淇℃伅 logcolumns: PropTypes.array, // 鏄剧ず鍒� ContainerId: PropTypes.any, // tab椤甸潰ID锛岀敤浜庡脊绐楁帶鍒� @@ -758,7 +762,7 @@ } render() { - const { plot, data, loading, BID, BData, Tab, MenuID, config, logcolumns, ContainerId } = this.props + const { plot, data, loading, BID, BData, Tab, MenuID, config, logcolumns, ContainerId, MenuName } = this.props const { card, colMap, selectKey, actionList } = this.state return ( @@ -781,6 +785,7 @@ Tab={Tab} btn={action} show="icon" + MenuName={MenuName} setting={config.setting} updateStatus={() => {}} /> @@ -793,6 +798,7 @@ Tab={Tab} btn={action} show="icon" + MenuName={MenuName} setting={config.setting} getexceloutparam={this.props.getexceloutparam} updateStatus={() => {}} @@ -814,6 +820,7 @@ BData={BData} MenuID={MenuID} colMap={colMap} + MenuName={MenuName} selectKey={selectKey} logcolumns={logcolumns} setting={config.setting} @@ -833,6 +840,7 @@ data={{key: 'insert'}} BData={BData} MenuID={MenuID} + MenuName={MenuName} setting={config.setting} ContainerId={ContainerId} switchCard={() => {}} diff --git a/src/tabviews/zshare/chartcomponent/index.jsx b/src/tabviews/zshare/chartcomponent/index.jsx index 85ec585..4edb9b1 100644 --- a/src/tabviews/zshare/chartcomponent/index.jsx +++ b/src/tabviews/zshare/chartcomponent/index.jsx @@ -18,6 +18,7 @@ static propTpyes = { BID: PropTypes.any, // 鐖剁骇Id Tab: PropTypes.any, // 鏍囩淇℃伅 + MenuName: PropTypes.any, // 鑿滃崟鍚嶇О plot: PropTypes.object, // 鍥炬爣璁剧疆淇℃伅 data: PropTypes.array, // 鍥捐〃浼犲叆鏁版嵁 loading: PropTypes.bool, // 鏁版嵁鍔犺浇涓� @@ -1075,7 +1076,7 @@ } render() { - const { plot, loading, config, BID, Tab } = this.props + const { plot, loading, config, BID, Tab, MenuName } = this.props const { empty, chartFields, selectFields, actions } = this.state return ( @@ -1109,6 +1110,7 @@ Tab={Tab} btn={item} show="icon" + MenuName={MenuName} setting={config.setting} getexceloutparam={this.props.getexceloutparam} updateStatus={() => {}} @@ -1122,6 +1124,7 @@ Tab={Tab} btn={item} show="icon" + MenuName={MenuName} setting={config.setting} updateStatus={() => {}} /> diff --git a/src/tabviews/zshare/normalTable/index.jsx b/src/tabviews/zshare/normalTable/index.jsx index 25ffd9d..a8e4994 100644 --- a/src/tabviews/zshare/normalTable/index.jsx +++ b/src/tabviews/zshare/normalTable/index.jsx @@ -28,6 +28,7 @@ tableId: PropTypes.string, // 鍒楄〃Id statFValue: PropTypes.any, // 鍚堣瀛楁鏁版嵁 pageSize: PropTypes.any, // 姣忛〉鏁版嵁 + MenuName: PropTypes.any, // 鑿滃崟鍚嶇О dict: PropTypes.object, // 瀛楀吀椤� config: PropTypes.object, // 椤甸潰閰嶇疆 MenuID: PropTypes.string, // 鑿滃崟Id @@ -602,6 +603,7 @@ selectedData={[record]} BData={this.props.BData} setting={this.props.setting} + MenuName={this.props.MenuName} columns={this.props.logcolumns} ContainerId={this.props.ContainerId} updateStatus={this.props.refreshbyaction} diff --git a/src/templates/calendarconfig/index.jsx b/src/templates/calendarconfig/index.jsx index d37142f..d0ebf5a 100644 --- a/src/templates/calendarconfig/index.jsx +++ b/src/templates/calendarconfig/index.jsx @@ -16,7 +16,7 @@ import SearchComponent from '@/templates/sharecomponent/searchcomponent' import MenuForm from '@/templates/comtableconfig/menuform' -// import EditComponent from '@/templates/zshare/editcomponent' +import EditComponent from '@/templates/zshare/editcomponent' import SourceElement from '@/templates/zshare/dragsource' import Source from './source' import './index.scss' @@ -785,7 +785,7 @@ </div> } bordered={false} extra={ <div> - {/* <EditComponent dict={this.state.dict} type="subtable" config={this.state.config} refresh={this.updateConfig}/> */} + <EditComponent dict={this.state.dict} type="calendar" config={this.state.config} refresh={this.updateConfig}/> <Switch className="big" checkedChildren="鍚�" unCheckedChildren="鍋�" checked={this.state.config.enabled} onChange={this.onEnabledChange} /> <Button type="primary" onClick={this.submitConfig} loading={this.state.menuloading}>{this.state.dict['model.save']}</Button> <Button onClick={this.cancelConfig}>{this.state.dict['model.back']}</Button> diff --git a/src/templates/formtabconfig/dragelement/card.jsx b/src/templates/formtabconfig/dragelement/card.jsx index 5141b81..4e326df 100644 --- a/src/templates/formtabconfig/dragelement/card.jsx +++ b/src/templates/formtabconfig/dragelement/card.jsx @@ -8,7 +8,7 @@ const { MonthPicker } = DatePicker const { TextArea } = Input -const Card = ({ id, type, cols, card, moveCard, findCard, editCard, delCard, profileCard, hasDrop, copyCard }) => { +const Card = ({ id, type, cols, card, moveCard, findCard, editCard, delCard, profileCard, copyCard }) => { const originalIndex = findCard(id).index const [{ isDragging }, drag] = useDrag({ item: { type: ItemTypes[type], id, originalIndex }, @@ -20,17 +20,15 @@ accept: ItemTypes[type], canDrop: () => true, drop: (item) => { - if (!item.hasOwnProperty('originalIndex')) { - hasDrop(card) - } - }, - hover({ id: draggedId }) { - if (!draggedId) return - if (draggedId !== id) { + const { id: draggedId, originalIndex } = item + + if (originalIndex === undefined) { + item.dropTargetId = id + } else if (draggedId && draggedId !== id) { const { index: overIndex } = findCard(id) moveCard(draggedId, overIndex) } - }, + } }) const opacity = isDragging ? 0 : 1 diff --git a/src/templates/formtabconfig/dragelement/index.jsx b/src/templates/formtabconfig/dragelement/index.jsx index b57b6b2..caf0924 100644 --- a/src/templates/formtabconfig/dragelement/index.jsx +++ b/src/templates/formtabconfig/dragelement/index.jsx @@ -9,7 +9,6 @@ import './index.scss' const Container = ({list, type, groupId, setting, placeholder, handleList, handleMenu, deleteMenu, profileMenu }) => { - let target = null const [cards, setCards] = useState(list) const moveCard = (id, atIndex) => { const { card, index } = findCard(id) @@ -81,10 +80,6 @@ deleteMenu({card: card, type: type}) } - const hasDrop = (item) => { - target = item - } - const [, drop] = useDrop({ accept: ItemTypes[type], drop(item) { @@ -141,19 +136,19 @@ newcard.verify = null } - let targetId = cards.length > 0 ? cards[cards.length - 1].uuid : 0 - if (target) { - targetId = target.uuid + let targetId = '' + + if (item.dropTargetId) { + targetId = item.dropTargetId + delete item.dropTargetId + } else if (cards.length > 0) { + targetId = cards[cards.length - 1].uuid } const { index: overIndex } = findCard(`${targetId}`) - let targetIndex = overIndex + const _cards = update(cards, { $splice: [[overIndex + 1, 0, newcard]] }) - targetIndex++ - - const _cards = update(cards, { $splice: [[targetIndex, 0, newcard]] }) handleList(type, _cards, newcard, groupId) - target = null } }) @@ -172,7 +167,6 @@ delCard={delCard} profileCard={profileCard} findCard={findCard} - hasDrop={hasDrop} /> ))} {type === 'search' && cards.map(card => ( @@ -188,7 +182,6 @@ delCard={delCard} copyCard={copyCard} findCard={findCard} - hasDrop={hasDrop} /> </Col> ))} diff --git a/src/templates/modalconfig/dragelement/card.jsx b/src/templates/modalconfig/dragelement/card.jsx index 4f481bf..d162322 100644 --- a/src/templates/modalconfig/dragelement/card.jsx +++ b/src/templates/modalconfig/dragelement/card.jsx @@ -25,11 +25,9 @@ if (originalIndex === undefined) { item.dropTargetId = id - } else if (draggedId) { - if (draggedId !== id) { - const { index: overIndex } = findCard(id) - moveCard(draggedId, overIndex) - } + } else if (draggedId && draggedId !== id) { + const { index: overIndex } = findCard(id) + moveCard(draggedId, overIndex) } } }) diff --git a/src/templates/modalconfig/dragelement/index.jsx b/src/templates/modalconfig/dragelement/index.jsx index 20ddba6..eb60daf 100644 --- a/src/templates/modalconfig/dragelement/index.jsx +++ b/src/templates/modalconfig/dragelement/index.jsx @@ -99,10 +99,11 @@ newcard.required = 'true' newcard.focus = true - let targetId = '0' + let targetId = '' if (item.dropTargetId) { targetId = item.dropTargetId + delete item.dropTargetId } else if (cards.length > 0) { targetId = cards[cards.length - 1].uuid } diff --git a/src/templates/modalconfig/index.jsx b/src/templates/modalconfig/index.jsx index 759e390..a6f6da3 100644 --- a/src/templates/modalconfig/index.jsx +++ b/src/templates/modalconfig/index.jsx @@ -352,7 +352,7 @@ * 3銆佽缃紪杈戝弬鏁伴」-formlist */ handleForm = (_card) => { - const {menu, tabConfig, subTabConfig} = this.props + const { menu, tabConfig, subTabConfig } = this.props let card = JSON.parse(JSON.stringify(_card)) const { config } = this.state let _inputfields = [] @@ -797,14 +797,8 @@ setAll: 'false', options: [], dataSource: '', - linkField: '', - valueField: '', - valueText: '', - orderBy: '', orderType: 'asc', decimal: 0, - min: '', - max: '', readonly: 'false', required: 'true' } @@ -844,10 +838,6 @@ setAll: 'false', options: [], dataSource: '', - linkField: '', - valueField: '', - valueText: '', - orderBy: '', orderType: 'asc', readonly: 'false', required: 'true' diff --git a/src/templates/sharecomponent/actioncomponent/dragaction/card.jsx b/src/templates/sharecomponent/actioncomponent/dragaction/card.jsx index 04fcc96..7f983f0 100644 --- a/src/templates/sharecomponent/actioncomponent/dragaction/card.jsx +++ b/src/templates/sharecomponent/actioncomponent/dragaction/card.jsx @@ -3,7 +3,7 @@ import { Icon, Button, Popover } from 'antd' import './index.scss' -const Card = ({ id, card, moveCard, findCard, editCard, delCard, copyCard, profileCard, hasDrop, doubleClickCard }) => { +const Card = ({ id, card, moveCard, findCard, editCard, delCard, copyCard, profileCard, doubleClickCard }) => { const originalIndex = findCard(id).index const [{ isDragging }, drag] = useDrag({ item: { type: 'action', id, originalIndex }, @@ -15,17 +15,15 @@ accept: 'action', canDrop: () => true, drop: (item) => { - if (!item.hasOwnProperty('originalIndex')) { - hasDrop(card) - } - }, - hover({ id: draggedId }) { - if (!draggedId) return - if (draggedId !== id) { + const { id: draggedId, originalIndex } = item + + if (originalIndex === undefined) { + item.dropTargetId = id + } else if (draggedId && draggedId !== id) { const { index: overIndex } = findCard(id) moveCard(draggedId, overIndex) } - }, + } }) const opacity = isDragging ? 0 : 1 diff --git a/src/templates/sharecomponent/actioncomponent/dragaction/index.jsx b/src/templates/sharecomponent/actioncomponent/dragaction/index.jsx index e5edf64..5e1da18 100644 --- a/src/templates/sharecomponent/actioncomponent/dragaction/index.jsx +++ b/src/templates/sharecomponent/actioncomponent/dragaction/index.jsx @@ -7,8 +7,6 @@ import './index.scss' const Container = ({list, setting, placeholder, handleList, handleMenu, deleteMenu, profileMenu, doubleClickCard }) => { - let target = null - const [cards, setCards] = useState(list) const moveCard = (id, atIndex) => { const { card, index } = findCard(id) @@ -90,10 +88,6 @@ handleList(_cards, copycard) } - const hasDrop = (item) => { - target = item - } - const [, drop] = useDrop({ accept: 'action', drop(item) { @@ -136,20 +130,19 @@ newcard.class = 'dgreen' } - let targetId = cards.length > 0 ? cards[cards.length - 1].uuid : 0 - if (target) { - targetId = target.uuid + let targetId = '' + + if (item.dropTargetId) { + targetId = item.dropTargetId + delete item.dropTargetId + } else if (cards.length > 0) { + targetId = cards[cards.length - 1].uuid } const { index: overIndex } = findCard(`${targetId}`) - let targetIndex = overIndex - - targetIndex++ - - const _cards = update(cards, { $splice: [[targetIndex, 0, newcard]] }) + const _cards = update(cards, { $splice: [[overIndex + 1, 0, newcard]] }) handleList(_cards, newcard) - target = null } }) @@ -165,7 +158,6 @@ editCard={editCard} delCard={delCard} findCard={findCard} - hasDrop={hasDrop} profileCard={profileCard} doubleClickCard={doubleClickBtn} /> diff --git a/src/templates/sharecomponent/columncomponent/dragcolumn/card.jsx b/src/templates/sharecomponent/columncomponent/dragcolumn/card.jsx index d480eab..f98d56e 100644 --- a/src/templates/sharecomponent/columncomponent/dragcolumn/card.jsx +++ b/src/templates/sharecomponent/columncomponent/dragcolumn/card.jsx @@ -3,7 +3,7 @@ import { Icon, Popover } from 'antd' import './index.scss' -const Card = ({ id, card, showfield, moveCard, findCard, editCard, delCard, markCard, hasDrop }) => { +const Card = ({ id, card, showfield, moveCard, findCard, editCard, delCard, markCard }) => { const originalIndex = findCard(id).index const [{ isDragging }, drag] = useDrag({ item: { type: 'columns', id, originalIndex }, @@ -14,9 +14,11 @@ const [, drop] = useDrop({ accept: 'columns', canDrop: () => true, - drop: ({ id: draggedId, originalIndex }) => { + drop: (item) => { + const { id: draggedId, originalIndex } = item + if (originalIndex === undefined) { - hasDrop(card) + item.dropTargetId = id } else if (draggedId && draggedId !== id) { const { index: overIndex } = findCard(id) moveCard(draggedId, overIndex) diff --git a/src/templates/sharecomponent/columncomponent/dragcolumn/index.jsx b/src/templates/sharecomponent/columncomponent/dragcolumn/index.jsx index 9969166..1fa8a7c 100644 --- a/src/templates/sharecomponent/columncomponent/dragcolumn/index.jsx +++ b/src/templates/sharecomponent/columncomponent/dragcolumn/index.jsx @@ -8,8 +8,6 @@ import './index.scss' const Container = ({list, setting, gridBtn, showfield, placeholder, handleList, handleMenu, handleGridBtn, deleteMenu, markMenu }) => { - let target = null - const [cards, setCards] = useState(list) const moveCard = (id, atIndex) => { const { card, index } = findCard(id) @@ -31,7 +29,6 @@ const editCard = id => { const { card } = findCard(id) - delete card.focus // 鍏煎鏃╂湡鐨勫悎骞跺垪 handleMenu(card) @@ -46,10 +43,6 @@ const markCard = id => { const { card } = findCard(id) markMenu(card) - } - - const hasDrop = (item) => { - target = item } const [, drop] = useDrop({ @@ -78,20 +71,19 @@ newcard.order = 'vertical' } - let targetId = cards.length > 0 ? cards[cards.length - 1].uuid : 0 - if (target) { - targetId = target.uuid + let targetId = '' + + if (item.dropTargetId) { + targetId = item.dropTargetId + delete item.dropTargetId + } else if (cards.length > 0) { + targetId = cards[cards.length - 1].uuid } const { index: overIndex } = findCard(`${targetId}`) - let targetIndex = overIndex - - targetIndex++ - - const _cards = update(cards, { $splice: [[targetIndex, 0, newcard]] }) + const _cards = update(cards, { $splice: [[overIndex + 1, 0, newcard]] }) handleList(_cards, newcard) - target = null } }) @@ -149,7 +141,6 @@ delCard={delCard} markCard={markCard} findCard={findCard} - hasDrop={hasDrop} /> ))} {i === (columns.length - 1) && gridBtn && gridBtn.display ? diff --git a/src/templates/sharecomponent/searchcomponent/dragsearch/card.jsx b/src/templates/sharecomponent/searchcomponent/dragsearch/card.jsx index 3fb2a8b..ddd5807 100644 --- a/src/templates/sharecomponent/searchcomponent/dragsearch/card.jsx +++ b/src/templates/sharecomponent/searchcomponent/dragsearch/card.jsx @@ -8,7 +8,7 @@ const { MonthPicker, WeekPicker, RangePicker } = DatePicker -const Card = ({ id, card, moveCard, copyCard, findCard, editCard, delCard, hasDrop }) => { +const Card = ({ id, card, moveCard, copyCard, findCard, editCard, delCard }) => { const originalIndex = findCard(id).index const [{ isDragging }, drag] = useDrag({ item: { type: 'search', id, originalIndex }, @@ -20,17 +20,15 @@ accept: 'search', canDrop: () => true, drop: (item) => { - if (!item.hasOwnProperty('originalIndex')) { - hasDrop(card) - } - }, - hover({ id: draggedId }) { - if (!draggedId) return - if (draggedId !== id) { + const { id: draggedId, originalIndex } = item + + if (originalIndex === undefined) { + item.dropTargetId = id + } else if (draggedId && draggedId !== id) { const { index: overIndex } = findCard(id) moveCard(draggedId, overIndex) } - }, + } }) const opacity = isDragging ? 0 : 1 diff --git a/src/templates/sharecomponent/searchcomponent/dragsearch/index.jsx b/src/templates/sharecomponent/searchcomponent/dragsearch/index.jsx index 3d546f6..9c3a55b 100644 --- a/src/templates/sharecomponent/searchcomponent/dragsearch/index.jsx +++ b/src/templates/sharecomponent/searchcomponent/dragsearch/index.jsx @@ -8,8 +8,6 @@ import './index.scss' const Container = ({list, placeholder, handleList, handleMenu, deleteMenu }) => { - let target = null - const [cards, setCards] = useState(list) const moveCard = (id, atIndex) => { const { card, index } = findCard(id) @@ -75,10 +73,6 @@ handleList(_cards, copycard) } - const hasDrop = (item) => { - target = item - } - const [, drop] = useDrop({ accept: 'search', drop(item) { @@ -112,21 +106,20 @@ } newcard.match = _match - - let targetId = cards.length > 0 ? cards[cards.length - 1].uuid : 0 - if (target) { - targetId = target.uuid + + let targetId = '' + + if (item.dropTargetId) { + targetId = item.dropTargetId + delete item.dropTargetId + } else if (cards.length > 0) { + targetId = cards[cards.length - 1].uuid } const { index: overIndex } = findCard(`${targetId}`) - let targetIndex = overIndex - - targetIndex++ - - const _cards = update(cards, { $splice: [[targetIndex, 0, newcard]] }) + const _cards = update(cards, { $splice: [[overIndex + 1, 0, newcard]] }) handleList(_cards, newcard) - target = null } }) @@ -142,7 +135,6 @@ editCard={editCard} delCard={delCard} findCard={findCard} - hasDrop={hasDrop} /> </Col> ))} diff --git a/src/templates/sharecomponent/tabscomponent/tabdragelement/card.jsx b/src/templates/sharecomponent/tabscomponent/tabdragelement/card.jsx index 83b9a27..dd3bb58 100644 --- a/src/templates/sharecomponent/tabscomponent/tabdragelement/card.jsx +++ b/src/templates/sharecomponent/tabscomponent/tabdragelement/card.jsx @@ -3,7 +3,7 @@ import { Icon, Popover } from 'antd' import './index.scss' -const Card = ({ id, card, moveCard, findCard, doubleClickCard, editCard, delCard, hasDrop }) => { +const Card = ({ id, card, moveCard, findCard, doubleClickCard, editCard, delCard }) => { const originalIndex = findCard(id).index const [{ isDragging }, drag] = useDrag({ item: { type: 'tabs', id, originalIndex }, @@ -15,13 +15,11 @@ accept: 'tabs', canDrop: () => true, drop: (item) => { - if (!item.hasOwnProperty('originalIndex')) { - hasDrop(card) - } - }, - hover({ id: draggedId }) { - if (!draggedId) return - if (draggedId !== id) { + const { id: draggedId, originalIndex } = item + + if (originalIndex === undefined) { + item.dropTargetId = id + } else if (draggedId && draggedId !== id) { const { index: overIndex } = findCard(id) moveCard(draggedId, overIndex) } diff --git a/src/templates/sharecomponent/tabscomponent/tabdragelement/index.jsx b/src/templates/sharecomponent/tabscomponent/tabdragelement/index.jsx index ad89ed3..9d819d5 100644 --- a/src/templates/sharecomponent/tabscomponent/tabdragelement/index.jsx +++ b/src/templates/sharecomponent/tabscomponent/tabdragelement/index.jsx @@ -10,7 +10,6 @@ const { TabPane } = Tabs const Container = ({list, placeholder, handleList, handleMenu, deleteMenu, doubleClickCard }) => { - let target = null const [cards, setCards] = useState(list) const moveCard = (id, atIndex) => { const { card, index } = findCard(id) @@ -33,10 +32,6 @@ } } - const hasDrop = (item) => { - target = item - } - const [, drop] = useDrop({ accept: 'tabs', drop(item) { @@ -54,19 +49,19 @@ newcard.supMenu = 'mainTable' newcard.focus = true - let targetId = cards.length > 0 ? cards[cards.length - 1].uuid : 0 - if (target) { - targetId = target.uuid + let targetId = '' + + if (item.dropTargetId) { + targetId = item.dropTargetId + delete item.dropTargetId + } else if (cards.length > 0) { + targetId = cards[cards.length - 1].uuid } const { index: overIndex } = findCard(`${targetId}`) - let targetIndex = overIndex + const _cards = update(cards, { $splice: [[overIndex + 1, 0, newcard]] }) - targetIndex++ - - const _cards = update(cards, { $splice: [[targetIndex, 0, newcard]] }) handleList(_cards, newcard) - target = null } }) @@ -98,7 +93,6 @@ findCard={findCard} editCard={editCard} delCard={delCard} - hasDrop={hasDrop} doubleClickCard={doubleClickBab} /> } key={`${index}`}> diff --git a/src/templates/treepageconfig/index.jsx b/src/templates/treepageconfig/index.jsx index 1fd9e94..991ad20 100644 --- a/src/templates/treepageconfig/index.jsx +++ b/src/templates/treepageconfig/index.jsx @@ -15,7 +15,6 @@ import asyncComponent from '@/utils/asyncComponent' import MenuForm from '@/templates/comtableconfig/menuform' -import EditComponent from '@/templates/zshare/editcomponent' import SourceElement from '@/templates/zshare/dragsource' import Source from './source' import './index.scss' @@ -706,21 +705,6 @@ } /** - * @description 缂栬緫鍔熻兘瀹屾垚鏇存柊锛屽寘鎷В鍐绘寜閽�佺矘璐淬�佹浛鎹㈢瓑 - */ - editConfig = (res) => { - if (res.type === 'paste') { - this.setState({ - pasteContent: res.content - }, () => { - this.setState({ - pasteContent: null - }) - }) - } - } - - /** * @description 鏇存柊鏍囩閰嶇疆淇℃伅 */ updatetabs = (config, delcards) => { @@ -804,7 +788,6 @@ </div> } bordered={false} extra={ <div> - <EditComponent dict={this.state.dict} type="TreePage" config={this.state.config} MenuID={this.props.menu.MenuID} refresh={this.editConfig}/> <Switch className="big" checkedChildren="鍚�" unCheckedChildren="鍋�" checked={this.state.config.enabled} onChange={this.onEnabledChange} /> <Button type="primary" onClick={this.submitConfig} loading={this.state.menuloading}>{this.state.dict['model.save']}</Button> <Button onClick={this.cancelConfig}>{this.state.dict['model.back']}</Button> diff --git a/src/templates/zshare/editcomponent/index.jsx b/src/templates/zshare/editcomponent/index.jsx index adb6bd8..8d4083f 100644 --- a/src/templates/zshare/editcomponent/index.jsx +++ b/src/templates/zshare/editcomponent/index.jsx @@ -4,6 +4,7 @@ import { Menu, Dropdown, Icon, Modal, Spin, notification } from 'antd' import Api from '@/api' +import Utils from '@/utils/utils.js' import PasteForm from '@/templates/zshare/pasteform' import ReplaceForm from '@/templates/zshare/replaceform' import TransferForm from '@/templates/zshare/basetransferform' @@ -136,14 +137,8 @@ this.pasteFormRef.handleConfirm().then(res => { if (['maintable', 'subtable'].includes(type) && res.copyType === 'action') { - if (this.props.type === 'subtable' && !['pop', 'prompt', 'exec', 'excelIn', 'excelOut', 'popview'].includes(res.OpenType)) { - notification.warning({ - top: 92, - message: '涓嶆敮鎸佹鎵撳紑鏂瑰紡锛�', - duration: 5 - }) - return - } + res.uuid = Utils.getuuid() + this.setState({ pasteVisible: false }, () => { @@ -152,7 +147,24 @@ content: res }) }) - } else if (['maintable', 'subtable'].includes(type) && res.copyType === 'search') { + } else if (['maintable', 'subtable', 'calendar'].includes(type) && (res.copyType === 'search' || res.copyType === 'form')) { + res.uuid = Utils.getuuid() + + // search锛� text select multiselect link date dateweek datemonth daterange group + // form锛� text number select multiselect link switch checkbox radio checkcard + // fileupload date datemonth datetime textarea hint color funcvar + if (res.copyType === 'form') { + if (['number', 'switch', 'textarea', 'checkcard', 'fileupload', 'hint', 'color', 'funcvar'].includes(res.type)) { + res.type = 'text' + } else if (res.type === 'radio') { + res.type = 'select' + } else if (res.type === 'checkbox') { + res.type = 'multiselect' + } else if (res.type === 'datetime') { + res.type = 'date' + } + } + this.setState({ pasteVisible: false }, () => { @@ -180,68 +192,54 @@ content: res }) }) - } else if (['form'].includes(type) && res.copyType === 'form') { - if (res.type === 'linkMain') { - notification.warning({ - top: 92, - message: '涓嶆敮鎸佹琛ㄥ崟绫诲瀷锛�', - duration: 10 - }) - return - } - + } else if (['form'].includes(type) && (res.copyType === 'form' || res.copyType === 'search')) { let _config = fromJS(config).toJS() - let fieldrepet = false - let labelrepet = false + let fields = [] + let labels = [] + + res.uuid = Utils.getuuid() + + // search锛� text select multiselect link date dateweek datemonth daterange group + // form锛� text number select multiselect link switch checkbox radio checkcard + // fileupload date datemonth datetime textarea hint color funcvar + if (res.copyType === 'search') { + if (res.type === 'dateweek' || res.type === 'daterange' || res.type === 'group') { + res.type = 'date' + } + } if (_config.groups.length > 0) { _config.groups.forEach(group => { group.sublist.forEach(item => { - if (item.uuid === res.uuid) { - fieldrepet = true - } else if (item.field === res.field) { - fieldrepet = true - } else if (item.label === res.label) { - labelrepet = true - } + fields.push(item.field) + labels.push(item.label) }) + if (group.default) { + group.sublist.push(res) + } }) } else { _config.fields.forEach(item => { - if (item.uuid === res.uuid) { - fieldrepet = true - } else if (item.field === res.field) { - fieldrepet = true - } else if (item.label === res.label) { - labelrepet = true - } + fields.push(item.field) + labels.push(item.label) }) + _config.fields.push(res) } - if (fieldrepet) { + if (fields.includes(res.field)) { notification.warning({ top: 92, message: '瀛楁宸插瓨鍦紒', duration: 10 }) return - } else if (labelrepet) { + } else if (labels.includes(res.label)) { notification.warning({ top: 92, message: '鍚嶇О宸插瓨鍦紒', duration: 10 }) return - } - - if (_config.groups.length > 0) { - _config.groups.forEach(group => { - if (group.default) { - group.sublist.push(res) - } - }) - } else { - _config.fields.push(res) } this.setState({ @@ -280,7 +278,7 @@ const menu = ( <Menu onClick={this.handleMenuClick}> {['maintable', 'subtable'].includes(type) ? <Menu.Item key="thaw"><Icon type="unlock" />{dict['header.form.thawbutton']}</Menu.Item> : null} - {['maintable', 'subtable', 'form'].includes(type) ? <Menu.Item key="paste"><Icon type="snippets" />{dict['header.form.paste']}</Menu.Item> : null} + {['maintable', 'subtable', 'form', 'calendar'].includes(type) ? <Menu.Item key="paste"><Icon type="snippets" />{dict['header.form.paste']}</Menu.Item> : null} {/* <Menu.Item key="replace"><Icon type="retweet" />鏇挎崲</Menu.Item> */} </Menu> ) -- Gitblit v1.8.0