From 7b01bec1609710729a868093ad69484ebea82d80 Mon Sep 17 00:00:00 2001 From: king <18310653075@163.com> Date: 星期二, 20 十月 2020 10:16:26 +0800 Subject: [PATCH] 2020-10-20 --- src/templates/modalconfig/index.jsx | 112 +++++++++++--------------------------------------------- 1 files changed, 22 insertions(+), 90 deletions(-) diff --git a/src/templates/modalconfig/index.jsx b/src/templates/modalconfig/index.jsx index 53313ee..151df90 100644 --- a/src/templates/modalconfig/index.jsx +++ b/src/templates/modalconfig/index.jsx @@ -49,7 +49,6 @@ dict: CommonDict, // 瀛楀吀 config: null, // 椤甸潰閰嶇疆锛屽寘鎷ā鏉跨被鍨嬨�佹ā鎬佹璁剧疆銆佹坊鍔犺〃鍚嶃�佽〃鍗曞垪琛� visible: false, // 琛ㄥ崟缂栬緫妯℃�佹锛屾樉绀烘帶鍒� - modalType: null, // 琛ㄥ崟缂栬緫绫诲瀷锛岀紪杈戞垨澶嶅埗 tableVisible: false, // 鏁版嵁琛ㄥ瓧娈靛垪琛ㄦā鎬佹锛屾樉绀烘帶鍒� tableColumns: [], // 琛ㄦ牸瀛楁鍚嶅垪琛� fields: null, // 琛ㄥ崟锛屽彲閫夊瓧娈碉紙鍘婚噸鍚庯級 @@ -352,32 +351,9 @@ * 2銆佷繚瀛樼紪杈戦」-card * 3銆佽缃紪杈戝弬鏁伴」-formlist */ - handleForm = (_card, type) => { + handleForm = (_card) => { const {menu, tabConfig, subTabConfig} = this.props let card = JSON.parse(JSON.stringify(_card)) - - if (type === 'copy') { - card.originUuid = card.uuid - card.uuid = Utils.getuuid() - card.focus = true - - // 澶嶅埗鍒板壀鍒囨澘 - let oInput = document.createElement('input') - let val = JSON.parse(JSON.stringify(card)) - val.copyType = 'form' - val.uuid = Utils.getuuid() - - delete val.originUuid - - 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' - document.body.removeChild(oInput) - } - const { config } = this.state let _inputfields = [] let _linkableFields = [] @@ -472,7 +448,6 @@ this.setState({ visible: true, - modalType: type, card: card, formlist: getModalForm(card, _inputfields, _linkableFields, _linksupFields, !!this.props.editTab, roleList) }) @@ -485,70 +460,14 @@ * 3銆侀�氳繃loading鍒锋柊 */ handleSubmit = () => { - const { card, modalType } = this.state - this.formRef.handleConfirm().then(res => { let _config = JSON.parse(JSON.stringify(this.state.config)) let fieldrepet = false // 瀛楁閲嶅 let labelrepet = false // 鎻愮ず鏂囧瓧閲嶅 - if (modalType === 'copy' && card.originUuid) { - if (_config.groups.length > 0) { - _config.groups = _config.groups.map(group => { - let _index = null - group.sublist.forEach((item, index) => { - if (item.uuid === card.originUuid) { - _index = index - } - - if (item.uuid !== res.uuid && item.field === res.field) { - fieldrepet = true - } else if (item.uuid !== res.uuid && item.label === res.label) { - labelrepet = true - } - }) - - if (_index !== null) { - group.sublist.splice(_index + 1, 0, res) - } - - return group - }) - } else { - let _index = null - _config.fields.forEach((item, index) => { - if (item.uuid === card.originUuid) { - _index = index - } - - if (item.uuid !== res.uuid && item.field === res.field) { - fieldrepet = true - } else if (item.uuid !== res.uuid && item.label === res.label) { - labelrepet = true - } - }) - - _config.fields.splice(_index + 1, 0, res) - } - } else { - if (_config.groups.length > 0) { - _config.groups.forEach(group => { - group.sublist = group.sublist.map(item => { - if (item.uuid !== res.uuid && item.field === res.field) { - fieldrepet = true - } else if (item.uuid !== res.uuid && item.label === res.label) { - labelrepet = true - } - - if (item.uuid === res.uuid) { - return res - } else { - return item - } - }) - }) - } else { - _config.fields = _config.fields.map(item => { + if (_config.groups.length > 0) { + _config.groups.forEach(group => { + group.sublist = group.sublist.map(item => { if (item.uuid !== res.uuid && item.field === res.field) { fieldrepet = true } else if (item.uuid !== res.uuid && item.label === res.label) { @@ -561,7 +480,21 @@ return item } }) - } + }) + } else { + _config.fields = _config.fields.map(item => { + if (item.uuid !== res.uuid && item.field === res.field) { + fieldrepet = true + } else if (item.uuid !== res.uuid && item.label === res.label) { + labelrepet = true + } + + if (item.uuid === res.uuid) { + return res + } else { + return item + } + }) } if (fieldrepet) { @@ -607,7 +540,6 @@ this.setState({ sqlVerifing: false, config: _config, - modalType: null, card: null, visible: false }) @@ -622,7 +554,6 @@ } else { this.setState({ config: _config, - modalType: null, card: null, visible: false }) @@ -1299,9 +1230,10 @@ </div> </DndProvider> <Modal - title={this.state.modalType !== 'copy' ? this.state.dict['model.edit'] : this.state.dict['header.modal.form.copy']} + title={this.state.dict['model.edit']} visible={this.state.visible} - width={800} + width={850} + maskClosable={false} onCancel={this.editModalCancel} onOk={this.handleSubmit} confirmLoading={this.state.sqlVerifing} -- Gitblit v1.8.0