From 4c6bdfe1f3557e49a315c1564bcb6164c0bc7faa Mon Sep 17 00:00:00 2001 From: king <18310653075@163.com> Date: 星期五, 03 四月 2020 18:27:22 +0800 Subject: [PATCH] 2020-04-03 --- src/templates/comtableconfig/index.jsx | 354 +++++++++++++++++++++++++++++++++++++++++++++++++--------- 1 files changed, 295 insertions(+), 59 deletions(-) diff --git a/src/templates/comtableconfig/index.jsx b/src/templates/comtableconfig/index.jsx index 6058e1a..20b0da8 100644 --- a/src/templates/comtableconfig/index.jsx +++ b/src/templates/comtableconfig/index.jsx @@ -4,11 +4,12 @@ import { is, fromJS } from 'immutable' import { DndProvider } from 'react-dnd' import HTML5Backend from 'react-dnd-html5-backend' -import { Button, Card, Modal, Collapse, notification, Spin, Select, List, Icon, Empty, Switch, Tooltip } from 'antd' +import { Button, Card, Modal, Collapse, notification, Spin, Select, List, Icon, Empty, Switch, Tooltip, message } from 'antd' import moment from 'moment' import Api from '@/api' import Utils from '@/utils/utils.js' +import options from '@/store/options.js' import zhCN from '@/locales/zh-CN/comtable.js' import enUS from '@/locales/en-US/comtable.js' import { getSearchForm, getActionForm, getColumnForm } from '@/templates/zshare/formconfig' @@ -33,6 +34,7 @@ import TransferForm from '@/components/transferform' import SourceElement from '@/templates/zshare/dragelement/source' import CreateFunc from '@/templates/zshare/createfunc' +import CreateInterface from '@/templates/zshare/createinterface' import Source from './source' import './index.scss' @@ -77,7 +79,8 @@ optionLibs: null, // 鑷畾涔変笅鎷夐�夐」搴� thawBtnVisible: false, // 瑙e喕鎸夐挳寮圭獥 thawbtnlist: null, // 瑙e喕鎸夐挳鍒楄〃 - thawButtons: [] // 宸查�夋嫨瑕佽В鍐荤殑鎸夐挳 + thawButtons: [], // 宸查�夋嫨瑕佽В鍐荤殑鎸夐挳 + activeKey: '0' // 榛樿灞曞紑鍩烘湰淇℃伅 } /** @@ -165,6 +168,7 @@ this.setState({ config: _config, + activeKey: menu.activeKey || '0', optionLibs: optionLibs, originActions: _oriActions, originMenu: JSON.parse(JSON.stringify(menu)), @@ -462,13 +466,79 @@ */ handleColumn = (card) => { const { menu } = this.props - + if (card.type !== 'colspan') { - this.setState({ - modaltype: 'columns', - card: card, - formlist: getColumnForm(card, menu.roleList) + let menulist = menu.fstMenuList.map(item => { + return { + value: item.MenuID, + label: item.text, + isLeaf: false + } }) + + if ((card.type === 'text' || card.type === 'number') && card.linkmenu && card.linkmenu.length > 0) { + let _param = { + func: 'sPC_Get_FunMenu', + ParentID: card.linkmenu[0], + systemType: options.systemType, + debug: 'Y' + } + + this.setState({ + loading: true + }) + + Api.getSystemConfig(_param).then(result => { + if (result.status) { + menulist = menulist.map(item => { + if (item.value === card.linkmenu[0]) { + item.children = result.data.map(item => { + let submenu = { + value: item.ParentID, + label: item.MenuNameP, + children: item.FunMenu.map(cell => { + return { + value: cell.MenuID, + label: cell.MenuName, + MenuID: cell.MenuID, + MenuName: cell.MenuName, + MenuNo: cell.MenuNo, + Ot: cell.Ot, + PageParam: cell.PageParam, + LinkUrl: cell.LinkUrl + } + }) + } + + submenu.children = submenu.children.filter(cell => cell.MenuID !== menu.MenuID) + + return submenu + }) + } + return item + }) + } else { + notification.warning({ + top: 92, + message: result.message, + duration: 10 + }) + } + + this.setState({ + loading: false, + modaltype: 'columns', + card: card, + formlist: getColumnForm(card, menu.roleList, menulist) + }) + }) + } else { + this.setState({ + modaltype: 'columns', + card: card, + formlist: getColumnForm(card, menu.roleList, menulist) + }) + } } else { this.setState({ modaltype: 'colspan', @@ -629,13 +699,39 @@ }) } + let fieldrepet = false // 瀛楁閲嶅 + let labelrepet = false // 鎻愮ず鏂囧瓧閲嶅 + let _search = config.search.map(item => { + if (item.uuid !== res.uuid && item.field === res.field) { + fieldrepet = true + } else if (item.uuid !== res.uuid && item.field && item.label === res.label) { + labelrepet = true + } + if (item.uuid === res.uuid) { return res } else { return item } }) + + if (fieldrepet) { + notification.warning({ + top: 92, + message: '瀛楁宸插瓨鍦紒', + duration: 10 + }) + return + } else if (labelrepet) { + notification.warning({ + top: 92, + message: '鍚嶇О宸插瓨鍦紒', + duration: 10 + }) + return + } + _search = _search.filter(item => !item.origin) this.setState({ @@ -818,13 +914,39 @@ }) } else if (modaltype === 'columns' || modaltype === 'colspan') { this.columnFormRef.handleConfirm().then(res => { + let fieldrepet = false // 瀛楁閲嶅 + let labelrepet = false // 鎻愮ず鏂囧瓧閲嶅 + let _columns = config.columns.map(item => { + if (item.uuid !== res.uuid && item.field === res.field) { + fieldrepet = true + } else if (item.uuid !== res.uuid && item.field && item.label === res.label) { + labelrepet = true + } + if (item.uuid === res.uuid) { return res } else { return item } }) + + if (fieldrepet) { + notification.warning({ + top: 92, + message: '瀛楁宸插瓨鍦紒', + duration: 10 + }) + return + } else if (labelrepet) { + notification.warning({ + top: 92, + message: '鍚嶇О宸插瓨鍦紒', + duration: 10 + }) + return + } + _columns = _columns.filter(item => !item.origin) this.setState({ @@ -864,7 +986,7 @@ editModalCancel = () => { const { config, card, modaltype } = this.state - if (card.focus) { + if (card && card.focus) { let _config = null if (modaltype === 'search') { let _search = config.search.filter(item => item.uuid !== card.uuid) @@ -1047,10 +1169,10 @@ */ tableCreatFunc = () => { const { menu } = this.props - let config = JSON.parse(JSON.stringify(this.state.config)) + const { config } = this.state - this.settingRef.handleConfirm().then(res => { - const setting = res + this.settingRef.handleConfirm().then(setting => { + if (!(setting.interType === 'inner') || !setting.innerFunc) { notification.warning({ top: 92, @@ -1060,29 +1182,77 @@ return } - if (/[^\s]+\s+[^\s]+/ig.test(setting.dataresource) && config.setting.dataresource !== setting.dataresource) { - let param = { - func: 's_DataSrc_Save', - LText: setting.dataresource, - MenuID: menu.MenuID - } - - param.LText = Utils.formatOptions(param.LText) - param.timestamp = moment().format('YYYY-MM-DD HH:mm:ss') + '.000' - param.secretkey = Utils.encrypt(param.LText, param.timestamp) - - Api.getLocalConfig(param) - } - - let newLText = Utils.formatOptions(Utils.getTableFunc(setting, menu, config)) // 鍒涘缓瀛樺偍杩囩▼sql + let _config = {...config, setting: setting} + let newLText = Utils.formatOptions(Utils.getTableFunc(setting, menu, _config)) // 鍒涘缓瀛樺偍杩囩▼sql let DelText = Utils.formatOptions(Utils.dropfunc(setting.innerFunc)) // 鍒犻櫎瀛樺偍杩囩▼sql this.refs.tableCreatFunc.exec(setting.innerFunc, newLText, DelText).then(result => { if (result === 'success') { this.setState({ - config: {...config, setting: setting} + config: _config }) } + }) + }) + } + + /** + * @description 鍒涘缓鎸夐挳鎺ュ彛锛堝啓鍏ワ級 + */ + btnCreatInterface = () => { + const { menu } = this.props + const { config } = this.state + + this.menuformRef.handleConfirm().then(res => { + this.actionFormRef.handleConfirm().then(result => { + if (!['pop', 'exec', 'prompt'].includes(result) || result.funcType || result.intertype !== 'inner' || result.innerFunc ) { + notification.warning({ + top: 92, + message: '鎵撳紑鏂瑰紡涓� 寮圭獥锛堣〃鍗曪級銆佹彁绀烘鎴栫洿鎺ユ墽琛岋紝涓斾娇鐢ㄧ郴缁熷嚱鏁版椂锛屾墠鍙互鍒涘缓鎺ュ彛锛�', + duration: 10 + }) + return + } + + let _menu = { + type: 'main', + MenuID: menu.MenuID, + menuName: res.menuName, + menuNo: res.menuNo + } + + this.refs.btnCreatInterface.triggerInInterface(result, config, _menu) + }) + }) + } + + /** + * @description 鍒涘缓琛ㄦ牸鎺ュ彛锛堣鍑猴級 + */ + tableCreatInterface = () => { + const { menu } = this.props + const { config } = this.state + + this.menuformRef.handleConfirm().then(res => { + this.settingRef.handleConfirm().then(setting => { + if (setting.interType !== 'inner' || setting.innerFunc) { + notification.warning({ + top: 92, + message: '鎺ュ彛绫诲瀷涓�-鍐呴儴锛屼笖涓嶅瓨鍦ㄥ唴閮ㄥ嚱鏁版椂锛屾墠鍙互鍒涘缓鎺ュ彛锛�', + duration: 10 + }) + return + } + + let _config = {...config, setting: setting} + let _menu = { + type: 'main', + MenuID: menu.MenuID, + menuName: res.menuName, + menuNo: res.menuNo + } + + this.refs.tableCreatInterface.triggerOutInterface(_menu, _config) }) }) } @@ -1148,6 +1318,21 @@ profileVisible: true, card: element }) + } + + /** + * @description 鎸夐挳鍙屽嚮瑙﹀彂瀛愰厤缃� + */ + btnDoubleClick = (element) => { + if (!element.origin && (element.OpenType === 'pop' || element.OpenType === 'popview' || element.OpenType === 'blank' || element.OpenType === 'tab')) { + this.setSubConfig(element, 'button') + } else { + notification.warning({ + top: 92, + message: '姝ゆ寜閽棤瀛愰厤缃」锛�', + duration: 10 + }) + } } /** @@ -2243,7 +2428,7 @@ */ setSubConfig = (item, type) => { const { menu } = this.props - const { config, originMenu, optionLibs } = this.state + const { config, originMenu, optionLibs, activeKey } = this.state if (!originMenu.MenuID) { // menuID涓嶅瓨鍦ㄦ椂锛屼负鏂板缓鑿滃崟锛屾彁绀鸿彍鍗曞皻鏈繚瀛� notification.warning({ @@ -2294,6 +2479,9 @@ uuid = item.linkTab isbutton = false } + + // 淇濆瓨褰撳墠鎵撳紑椤电 + _originMenu.activeKey = activeKey let param = { optionLibs: optionLibs, @@ -2584,6 +2772,27 @@ }) } + copycolumn = () => { + const { config } = this.state + + let oInput = document.createElement('input') + let val = { + copyType: 'columns', + columns: config.columns + } + + oInput.value = window.btoa(window.encodeURIComponent(JSON.stringify(val))) + document.body.appendChild(oInput) + oInput.select() + document.execCommand('Copy') + oInput.className = 'oInput' + oInput.style.display = 'none' + + message.success('澶嶅埗鎴愬姛銆�') + + document.body.removeChild(oInput) + } + /** * @description 閫夋嫨涓嶄繚瀛樻椂锛屽鏈夊鍒舵寜閽紝鍒欏垹闄� */ @@ -2599,43 +2808,64 @@ } pasteSubmit = () => { + const { config } = this.state + this.pasteFormRef.handleConfirm().then(res => { - if (res.copyType !== 'action') { + if (res.copyType === 'action') { + this.setState({ + modaltype: '' + }, () => { + this.handleAction(res, 'copy') + }) + } else if (res.copyType === 'columns') { + if (config.columns && config.columns.length > 0) { + notification.warning({ + top: 92, + message: '鏄剧ず鍒楀凡瀛樺湪锛�', + duration: 10 + }) + return + } + + this.setState({ + modaltype: '', + config: {...config, columns: res.columns} + }) + } else { notification.warning({ top: 92, message: '閰嶇疆淇℃伅鏍煎紡閿欒锛�', duration: 10 }) - return } - - this.setState({ - modaltype: '' - }, () => { - this.handleAction(res, 'copy') - }) }) } render () { - const { modaltype } = this.state - const configAction = this.state.config.action.filter(_action => + const { modaltype, activeKey, config } = this.state + + const configAction = config.action.filter(_action => !_action.origin && (_action.OpenType === 'pop' || _action.OpenType === 'popview' || _action.OpenType === 'blank' || _action.OpenType === 'tab') ) let configTabs = [] - this.state.config.tabgroups.forEach(group => { - configTabs.push(...this.state.config[group]) + config.tabgroups.forEach(group => { + configTabs.push(...config[group]) }) + + let hasbtncrtinter = false + if (modaltype === 'actionEdit' && config.setting.interType === 'inner' && !config.setting.innerFunc && config.setting.dataresource) { + hasbtncrtinter = true + } return ( <div className="common-table-board"> <DndProvider backend={HTML5Backend}> {/* 宸ュ叿鏍� */} <div className="tools"> - <Collapse accordion defaultActiveKey="0" bordered={false}> + <Collapse accordion defaultActiveKey={activeKey} bordered={false} onChange={(key) => this.setState({activeKey: key})}> {/* 鍩烘湰淇℃伅 */} - <Panel header={this.state.dict['header.menu.basedata']} key="0" id="common-basedata"> + <Panel forceRender={true} header={this.state.dict['header.menu.basedata']} key="0" id="common-basedata"> {/* 鑿滃崟淇℃伅 */} <MenuForm dict={this.state.dict} @@ -2782,7 +3012,7 @@ </Tooltip> <DragElement type="search" - list={this.state.config.search} + list={config.search} handleList={this.handleList} handleMenu={this.handleSearch} deleteMenu={this.deleteElement} @@ -2798,13 +3028,14 @@ </div> <DragElement type="action" - list={this.state.config.action} - setting={this.state.config.setting} + list={config.action} + setting={config.setting} handleList={this.handleList} handleMenu={this.handleAction} copyElement={(val) => this.handleAction(val, 'copy')} deleteMenu={this.deleteElement} profileMenu={this.profileAction} + doubleClickCard={this.btnDoubleClick} placeholder={this.state.dict['header.form.action.placeholder']} /> </div> @@ -2813,12 +3044,13 @@ <Tooltip placement="bottomLeft" overlayClassName="middle" title="鍦ㄥ乏渚у伐鍏锋爮銆婃樉绀哄垪銆嬩腑锛岄�夋嫨瀵瑰簲绫诲瀷鐨勬樉绀哄垪鎷栬嚦姝ゅ娣诲姞锛涙垨鐐瑰嚮銆婃坊鍔犳樉绀哄垪銆嬫寜閽壒閲忔坊鍔狅紝閫夋嫨鎵归噺娣诲姞鏃讹紝闇�鎻愬墠閫夋嫨浣跨敤琛ㄣ�傛敞锛氭坊鍔犲悎骞跺垪鏃讹紝闇�璁剧疆鍙�夊垪銆�"> <Icon type="question-circle" /> </Tooltip> + {config.columns && config.columns.length > 0 ? <Icon className="column-copy" title="copy" type="copy" onClick={this.copycolumn} /> : null} <Switch checkedChildren="寮�" unCheckedChildren="鍏�" defaultChecked={this.state.showColumnName} onChange={this.onColumnNameChange} /> <DragElement type="columns" - list={this.state.config.columns} - setting={this.state.config.setting} - gridBtn={this.state.config.gridBtn} + list={config.columns} + setting={config.setting} + gridBtn={config.gridBtn} handleList={this.handleList} handleMenu={this.handleColumn} deleteMenu={this.deleteElement} @@ -2828,13 +3060,13 @@ /> </div> {/* 鏍囩缁� */} - {this.state.config.tabgroups.map((groupId, index) => { + {config.tabgroups.map((groupId, index) => { return ( <div key={index} className="tab-list"> {index === 0 ? <Tooltip placement="bottomLeft" overlayClassName="middle" title="鍦ㄥ乏渚у伐鍏锋爮銆婃爣绛鹃〉銆嬩腑锛岄�夋嫨瀵瑰簲绫诲瀷鐨勬爣绛鹃〉鎷栬嚦姝ゅ娣诲姞銆�"> <Icon type="question-circle" /> </Tooltip> : null} - {index !== (this.state.config.tabgroups.length - 1) ? + {index !== (config.tabgroups.length - 1) ? <Icon type="arrow-down" onClick={() => {this.handleGroup(index, 'down')}} /> : null } {index !== 0 ? <Icon type="arrow-up" onClick={() => {this.handleGroup(index, 'up')}} /> : null} @@ -2843,10 +3075,11 @@ <TabDragElement type="tabs" groupId={groupId} - list={this.state.config[groupId]} + list={config[groupId]} handleList={this.handleList} handleMenu={this.handleTab} deleteMenu={this.deleteElement} + doubleClickCard={(tab) => this.setSubConfig(tab, 'tab')} placeholder={this.state.dict['header.form.tab.placeholder']} /> </div>) @@ -2881,6 +3114,7 @@ maskClosable={false} onCancel={this.editModalCancel} footer={[ + hasbtncrtinter ? <CreateInterface key="interface" dict={this.state.dict} ref="btnCreatInterface" trigger={this.btnCreatInterface}/> : null, modaltype === 'actionEdit' ? <CreateFunc key="create" dict={this.state.dict} ref="btnCreatFunc" trigger={this.creatFunc}/> : null, <Button key="cancel" onClick={this.editModalCancel}>{this.state.dict['header.cancel']}</Button>, <Button key="confirm" type="primary" onClick={this.handleSubmit}>{this.state.dict['header.confirm']}</Button> @@ -2893,7 +3127,7 @@ tabs={this.state.tabviews} formlist={this.state.formlist} inputSubmit={this.handleSubmit} - setting={this.state.config.setting} + setting={config.setting} wrappedComponentRef={(inst) => this.actionFormRef = inst} /> </Modal> @@ -2910,6 +3144,7 @@ <ColumnForm dict={this.state.dict} card={this.state.card} + MenuID={this.props.menu.MenuID} inputSubmit={this.handleSubmit} formlist={this.state.formlist} wrappedComponentRef={(inst) => this.columnFormRef = inst} @@ -2929,7 +3164,7 @@ dict={this.state.dict} card={this.state.card} inputSubmit={this.handleSubmit} - columns={this.state.config.columns} + columns={config.columns} wrappedComponentRef={(inst) => this.columnFormRef = inst} /> </Modal> @@ -2946,7 +3181,7 @@ <GridBtnForm dict={this.state.dict} inputSubmit={this.handleSubmit} - card={this.state.config.gridBtn} + card={config.gridBtn} wrappedComponentRef={(inst) => this.gridBtnFormRef = inst} /> </Modal> @@ -3011,7 +3246,7 @@ <VerifyCard card={this.state.card} dict={this.state.dict} - columns={this.state.config.columns} + columns={config.columns} wrappedComponentRef={(inst) => this.verifyRef = inst} /> : null } @@ -3019,7 +3254,7 @@ <VerifyCardPrint card={this.state.card} dict={this.state.dict} - columns={this.state.config.columns} + columns={config.columns} wrappedComponentRef={(inst) => this.verifyRef = inst} /> : null } @@ -3027,7 +3262,7 @@ <VerifyCardExcelIn card={this.state.card} dict={this.state.dict} - columns={this.state.config.columns} + columns={config.columns} wrappedComponentRef={(inst) => this.verifyRef = inst} /> : null } @@ -3051,6 +3286,7 @@ }) }} footer={[ + <CreateInterface key="interface" dict={this.state.dict} ref="tableCreatInterface" trigger={this.tableCreatInterface}/>, <CreateFunc key="create" dict={this.state.dict} ref="tableCreatFunc" trigger={this.tableCreatFunc}/>, <Button key="cancel" onClick={() => { this.setState({ settingVisible: false }) }}>{this.state.dict['header.cancel']}</Button>, <Button key="confirm" type="primary" onClick={this.settingSave}>{this.state.dict['header.confirm']}</Button> @@ -3061,8 +3297,8 @@ dict={this.state.dict} menu={this.props.menu} inputSubmit={this.settingSave} - data={this.state.config.setting} - columns={this.state.config.columns} + data={config.setting} + columns={config.columns} usefulFields={this.props.permFuncField} wrappedComponentRef={(inst) => this.settingRef = inst} /> -- Gitblit v1.8.0