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 | 321 +++++++++++++++++++++++++++++++++++++++++------------ 1 files changed, 249 insertions(+), 72 deletions(-) diff --git a/src/templates/comtableconfig/index.jsx b/src/templates/comtableconfig/index.jsx index 1b241b7..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' @@ -465,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', @@ -632,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({ @@ -821,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({ @@ -867,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) @@ -1063,20 +1182,6 @@ 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 _config = {...config, setting: setting} let newLText = Utils.formatOptions(Utils.getTableFunc(setting, menu, _config)) // 鍒涘缓瀛樺偍杩囩▼sql let DelText = Utils.formatOptions(Utils.dropfunc(setting.innerFunc)) // 鍒犻櫎瀛樺偍杩囩▼sql @@ -1092,7 +1197,37 @@ } /** - * @description 鍒涘缓琛ㄦ牸鎺ュ彛 + * @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 @@ -1100,20 +1235,6 @@ this.menuformRef.handleConfirm().then(res => { this.settingRef.handleConfirm().then(setting => { - 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) - } - if (setting.interType !== 'inner' || setting.innerFunc) { notification.warning({ top: 92, @@ -1131,13 +1252,7 @@ menuNo: res.menuNo } - this.refs.tableCreatInterface.exec(_menu, _config).then(result => { - if (result === 'success') { - this.setState({ - config: _config - }) - } - }) + this.refs.tableCreatInterface.triggerOutInterface(_menu, _config) }) }) } @@ -1203,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 + }) + } } /** @@ -2642,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 閫夋嫨涓嶄繚瀛樻椂锛屽鏈夊鍒舵寜閽紝鍒欏垹闄� */ @@ -2657,34 +2808,55 @@ } 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, activeKey } = 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"> @@ -2840,7 +3012,7 @@ </Tooltip> <DragElement type="search" - list={this.state.config.search} + list={config.search} handleList={this.handleList} handleMenu={this.handleSearch} deleteMenu={this.deleteElement} @@ -2856,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> @@ -2871,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} @@ -2886,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} @@ -2901,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>) @@ -2939,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> @@ -2951,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> @@ -2968,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} @@ -2987,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> @@ -3004,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> @@ -3069,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 } @@ -3077,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 } @@ -3085,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 } @@ -3120,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