From 48a18736c461ad730bd264b0ac7b40b68a0e33a1 Mon Sep 17 00:00:00 2001 From: king <18310653075@163.com> Date: 星期日, 28 六月 2020 20:30:20 +0800 Subject: [PATCH] 2020-06-28 --- src/templates/sharecomponent/columncomponent/index.jsx | 51 +++++++++++++++++++++++++++++++-------------------- 1 files changed, 31 insertions(+), 20 deletions(-) diff --git a/src/templates/sharecomponent/columncomponent/index.jsx b/src/templates/sharecomponent/columncomponent/index.jsx index 4a514cc..47ac705 100644 --- a/src/templates/sharecomponent/columncomponent/index.jsx +++ b/src/templates/sharecomponent/columncomponent/index.jsx @@ -28,9 +28,9 @@ } state = { - dict: (!localStorage.getItem('lang') || localStorage.getItem('lang') === 'zh-CN') ? zhCN : enUS, + dict: localStorage.getItem('lang') !== 'en-US' ? zhCN : enUS, columnlist: null, // 鏄剧ず鍒� - loading: false, // 鏌ヨ鏄剧ず鍒楀叧鑱旇彍鍗� + loading: false, // 鏌ヨ鏄剧ず鍒楄仈鍔ㄨ彍鍗� showField: false, // 鏄剧ず鍒楀瓧娈� modaltype: '', // 妯℃�佹鎺у埗 card: null // 缂栬緫涓厓绱� @@ -49,18 +49,22 @@ * @description 鐩戝惉鍒版樉绀哄垪澶嶅埗鏃讹紝瑙﹀彂鏄剧ず鍒楃紪杈� */ UNSAFE_componentWillReceiveProps (nextProps) { + const { config } = this.props const { columnlist } = this.state if ( nextProps.pasteContent && - columnlist.length === 0 && nextProps.pasteContent.columns && nextProps.pasteContent.copyType === 'columns' && nextProps.pasteContent.columns.length > 0 ) { - this.setState({columnlist: nextProps.pasteContent.columns}) - } else if (!is(fromJS(nextProps.config.columns), fromJS(this.props.config.columns)) && !is(fromJS(nextProps.config.columns), fromJS(columnlist))) { - this.setState({columnlist: nextProps.config.columns}) + if (columnlist.filter(col => !col.origin).length === 0) { + this.setState({columnlist: nextProps.pasteContent.columns}, () => { + this.props.updatecolumn({...config, columns: nextProps.pasteContent.columns}) + }) + } + } else if (!is(fromJS(nextProps.config.columns), fromJS(config.columns)) && !is(fromJS(nextProps.config.columns), fromJS(columnlist))) { + this.setState({columnlist: fromJS(nextProps.config.columns).toJS()}) } } @@ -74,8 +78,9 @@ this.setState({columnlist: list}) this.handleColumn(card) } else { - this.setState({columnlist: list}) - this.props.updatecolumn({...config, columns: list}) + this.setState({columnlist: list}, ()=> { + this.props.updatecolumn({...config, columns: list}) + }) } } @@ -98,7 +103,7 @@ let _param = { func: 'sPC_Get_FunMenu', ParentID: card.linkmenu[0], - systemType: options.systemType, + systemType: options.sysType, debug: 'Y' } @@ -280,8 +285,9 @@ card: null, columnlist: _columnlist, modaltype: '' + }, ()=> { + this.props.updatecolumn({...config, columns: _columnlist}) }) - this.props.updatecolumn({...config, columns: _columnlist}) }) } else if (modaltype === 'gridbtn') { this.gridBtnFormRef.handleConfirm().then(res => { @@ -305,7 +311,7 @@ confirm({ content: dict['model.confirm'] + dict['model.delete'] + ` - ${card.label} 锛焋, okText: dict['model.confirm'], - cancelText: this.state.dict['header.cancel'], + cancelText: this.state.dict['model.cancel'], onOk() { let _columnlist = fromJS(_this.state.columnlist).toJS() @@ -330,8 +336,9 @@ _this.setState({ columnlist: _columnlist + }, ()=> { + _this.props.updatecolumn({...config, columns: _columnlist}) }) - _this.props.updatecolumn({...config, columns: _columnlist}) }, onCancel() {} }) @@ -417,9 +424,13 @@ card: null, columnlist: _columnlist, modaltype: '' + }, ()=> { + this.props.updatecolumn({...config, columns: _columnlist}) }) - this.props.updatecolumn({...config, columns: _columnlist}) - + } + + shouldComponentUpdate (nextProps, nextState) { + return !is(fromJS(this.props), fromJS(nextProps)) || !is(fromJS(this.state), fromJS(nextState)) } /** @@ -443,7 +454,7 @@ {columnlist && columnlist.length > 0 ? <Icon className="column-copy" title="copy" type="copy" onClick={this.copycolumn} /> : null } - <Switch checkedChildren="寮�" unCheckedChildren="鍏�" defaultChecked={this.state.showField} onChange={this.onFieldChange} /> + <Switch checkedChildren={dict['model.switch.open']} unCheckedChildren={dict['model.switch.close']} defaultChecked={this.state.showField} onChange={this.onFieldChange} /> <DragElement list={columnlist} setting={config.setting} @@ -460,7 +471,7 @@ <Modal title={dict['header.modal.column.edit']} visible={modaltype === 'columns'} - width={750} + width={800} maskClosable={false} onOk={this.handleSubmit} onCancel={this.editModalCancel} @@ -477,9 +488,9 @@ </Modal> {/* 鍚堝苟鍒楃紪杈� */} <Modal - title={dict['header.modal.colspan.edit']} + title={dict['model.modal.colspan'] + '-' + dict['model.edit']} visible={modaltype === 'colspan'} - width={750} + width={800} maskClosable={false} onOk={this.handleSubmit} onCancel={this.editModalCancel} @@ -497,7 +508,7 @@ <Modal title={dict['header.modal.gridbtn.edit']} visible={modaltype === 'gridbtn'} - width={700} + width={800} maskClosable={false} onOk={this.handleSubmit} onCancel={this.editModalCancel} @@ -518,7 +529,7 @@ width={'75vw'} maskClosable={false} style={{minWidth: '900px', maxWidth: '1200px'}} - okText={dict['header.submit']} + okText={dict['model.submit']} onOk={this.markSubmit} onCancel={() => { this.setState({ modaltype: '' }) }} destroyOnClose -- Gitblit v1.8.0