From 84804b405cb88f659d055b16eb3bd00b813ccb4a Mon Sep 17 00:00:00 2001 From: king <18310653075@163.com> Date: 星期四, 10 十二月 2020 10:58:38 +0800 Subject: [PATCH] 2020-12-10 --- src/templates/zshare/editcomponent/index.jsx | 85 +++++++++++++++++++++++++----------------- 1 files changed, 50 insertions(+), 35 deletions(-) diff --git a/src/templates/zshare/editcomponent/index.jsx b/src/templates/zshare/editcomponent/index.jsx index eb57e52..a1eccb1 100644 --- a/src/templates/zshare/editcomponent/index.jsx +++ b/src/templates/zshare/editcomponent/index.jsx @@ -14,7 +14,7 @@ class editComponent extends Component { static propTpyes = { - type: PropTypes.string, + options: PropTypes.array, MenuID: PropTypes.any, config: PropTypes.object, thawButtons: PropTypes.any, @@ -43,21 +43,15 @@ * @description 瑙e喕鎸夐挳 */ handleThaw = () => { - const { config } = this.props + const { MenuID } = this.props this.setState({ thawVisible: true }) - let uuid = config.uuid - - if (this.props.type === 'maintable') { - uuid = this.props.MenuID - } - Api.getSystemConfig({ func: 'sPC_Get_FrozenMenu', - ParentID: uuid, + ParentID: MenuID, TYPE: 40 }).then(res => { if (res.status) { @@ -103,7 +97,7 @@ thawBtnSubmit = () => { const { thawButtons } = this.props const { thawbtnlist, dict } = this.state - let config = JSON.parse(JSON.stringify(this.props.config)) + let config = fromJS(this.props.config).toJS() // 涓夌骇鑿滃崟瑙i櫎鍐荤粨 if (this.refs.trawmenu.state.targetKeys.length === 0) { @@ -133,22 +127,28 @@ } pasteSubmit = () => { - const { config, type } = this.props + const { options } = this.props + let _config = fromJS(this.props.config).toJS() this.pasteFormRef.handleConfirm().then(res => { - if (['maintable', 'subtable'].includes(type) && res.copyType === 'action') { + if (res.copyType === 'action' && options.includes('action')) { res.uuid = Utils.getuuid() - + + _config.action = _config.action.filter(item => !item.origin) + _config.action.push(res) + this.setState({ pasteVisible: false }, () => { this.props.refresh({ type: 'paste', - content: res + config: _config }) }) - } else if (['maintable', 'subtable', 'calendar'].includes(type) && (res.copyType === 'search' || res.copyType === 'form')) { + } else if (options.includes('search') && (res.copyType === 'search' || res.copyType === 'form')) { res.uuid = Utils.getuuid() + _config.search = _config.search.filter(item => !item.origin) + let keys = _config.search.map(item => item.field.toLowerCase()) // search锛� text select multiselect link date dateweek datemonth daterange group // form锛� text number select multiselect link switch checkbox radio checkcard @@ -166,23 +166,40 @@ } res.copyType = 'search' + _config.search.push(res) + + if (res.field && keys.includes(res.field.toLowerCase())) { + notification.warning({ + top: 92, + message: '鎼滅储瀛楁宸插瓨鍦紒', + duration: 5 + }) + return + } + this.setState({ pasteVisible: false }, () => { this.props.refresh({ type: 'paste', - content: res + config: _config }) }) - } else if (['maintable', 'subtable'].includes(type) && res.copyType === 'columns') { - let _columns = config.columns.filter(col => !col.origin) - if (_columns.length > 0) { - notification.warning({ - top: 92, - message: '鏄剧ず鍒楀凡瀛樺湪锛�', - duration: 5 + } else if (options.includes('columns') && res.copyType === 'columns') { + _config.columns = _config.columns.filter(col => !col.origin) + let keys = _config.columns.map(item => item.field ? item.field.toLowerCase() : '') + + if (_config.columns.length === 0) { + _config.columns = res.columns + } else { + res.columns.forEach(col => { + if (!col.field) return + let _key = col.field.toLowerCase() + if (!keys.includes(_key)) { + keys.push(_key) + _config.columns.push(col) + } }) - return } this.setState({ @@ -190,14 +207,12 @@ }, () => { this.props.refresh({ type: 'paste', - content: res + config: _config }) }) - } else if (['form'].includes(type) && (res.copyType === 'form' || res.copyType === 'search')) { - let _config = fromJS(config).toJS() + } else if (options.includes('form') && (res.copyType === 'form' || res.copyType === 'search')) { let fields = [] let labels = [] - res.uuid = Utils.getuuid() // search锛� text select multiselect link date dateweek datemonth daterange group @@ -213,7 +228,7 @@ if (_config.groups.length > 0) { _config.groups.forEach(group => { group.sublist.forEach(item => { - fields.push(item.field) + fields.push(item.field.toLowerCase()) labels.push(item.label) }) if (group.default) { @@ -222,13 +237,13 @@ }) } else { _config.fields.forEach(item => { - fields.push(item.field) + fields.push(item.field.toLowerCase()) labels.push(item.label) }) _config.fields.push(res) } - if (fields.includes(res.field)) { + if (fields.includes(res.field.toLowerCase())) { notification.warning({ top: 92, message: '瀛楁宸插瓨鍦紒', @@ -249,7 +264,7 @@ }, () => { this.props.refresh({ type: 'paste', - content: _config, + config: _config, newform: res }) }) @@ -276,12 +291,12 @@ } render() { - const { type } = this.props + const { MenuID } = this.props const { dict } = this.state 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', 'calendar'].includes(type) ? <Menu.Item key="paste"><Icon type="snippets" />{dict['header.form.paste']}</Menu.Item> : null} + {MenuID ? <Menu.Item key="thaw"><Icon type="unlock" />{dict['header.form.thawbutton']}</Menu.Item> : null} + <Menu.Item key="paste"><Icon type="snippets" />{dict['header.form.paste']}</Menu.Item> {/* <Menu.Item key="replace"><Icon type="retweet" />鏇挎崲</Menu.Item> */} </Menu> ) -- Gitblit v1.8.0