From b3547d1c531e479021219fda5df153a11b9b52a3 Mon Sep 17 00:00:00 2001 From: king <18310653075@163.com> Date: 星期一, 31 八月 2020 17:28:09 +0800 Subject: [PATCH] 2020-08-31 --- src/templates/sharecomponent/columncomponent/index.jsx | 132 ++++++++++++++++++++++++++++++++++++++------ 1 files changed, 114 insertions(+), 18 deletions(-) diff --git a/src/templates/sharecomponent/columncomponent/index.jsx b/src/templates/sharecomponent/columncomponent/index.jsx index 0d7d14d..30538c5 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,17 +49,21 @@ * @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))) { + 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()}) } } @@ -99,7 +103,7 @@ let _param = { func: 'sPC_Get_FunMenu', ParentID: card.linkmenu[0], - systemType: options.systemType, + systemType: options.sysType, debug: 'Y' } @@ -189,8 +193,8 @@ */ editModalCancel = () => { const { card } = this.state - - if (card.focus) { + + if (card && card.focus) { let _columnlist = fromJS(this.state.columnlist).toJS() _columnlist = _columnlist.filter(item => item.uuid !== card.uuid) @@ -266,12 +270,57 @@ if (column.marks && column.marks.filter(mark => mark.field === card.field || mark.contrastField === card.field).length > 0) { refers.push(column.label) } + if (column.type === 'colspan') { + let _length = column.sublist.length + column.sublist = column.sublist.filter(cell => cell !== card.uuid) + + if (column.sublist.length < _length) { + let subfield = [] // 鍚堝苟鍒楀瓧娈� + _columnlist.forEach(col => { + if (col.field && column.sublist.includes(col.uuid)) { + subfield.push(col.field) + } + }) + column.subfield = subfield.join(', ') + } + } }) if (refers.length > 0) { notification.warning({ top: 92, - message: '鏄剧ず鍒椼��' + refers.join('銆�') + '銆嬫爣璁颁腑鍚湁璇ュ瓧娈碉紝姝ゆ淇敼浼氬鑷存爣璁板け鏁堬紝璇蜂慨鏀广��' + refers.join('銆�') + '銆嬫爣璁拌缃紒', + message: '鏄剧ず鍒椼��' + refers.join('銆�') + '銆嬫爣璁颁腑鍚湁璇ュ瓧娈碉紝姝ゆ淇敼浼氬鑷存爣璁板け鏁堬紝璇蜂慨鏀圭浉搴旂殑鏍囪璁剧疆锛�', + duration: 5 + }) + } + + let chartRefers = [] + config.charts && config.charts.forEach((chart, index) => { + if (chart.chartType === 'card') { + if (chart.avatar && chart.avatar.field === card.field) { + chartRefers.push(chart.title || (index + 1)) + } else if (chart.header && chart.header.datatype === 'dynamic' && chart.header.field === card.field) { + chartRefers.push(chart.title || (index + 1)) + } else if (chart.details && chart.details.length > 0 && chart.details.filter(item => item.datatype === 'dynamic' && item.field === card.field).length > 0) { + chartRefers.push(chart.title || (index + 1)) + } + } else if (['bar', 'line', 'pie'].includes(chart.chartType)) { + if (chart.Xaxis === card.field) { + chartRefers.push(chart.title || (index + 1)) + } else if (Array.isArray(chart.Yaxis)) { + if (chart.Yaxis.includes(card.field)) { + chartRefers.push(chart.title || (index + 1)) + } + } else if (chart.Yaxis === card.field) { + chartRefers.push(chart.title || (index + 1)) + } + } + }) + + if (chartRefers.length > 0) { + notification.warning({ + top: 92, + message: '鍥捐〃銆�' + chartRefers.join('銆�') + '銆嬩腑鍚湁璇ュ瓧娈碉紝姝ゆ淇敼浼氬鑷村浘琛ㄦ樉绀哄紓甯革紝璇蜂慨鏀圭浉搴旂殑鍥捐〃璁剧疆锛�', duration: 5 }) } @@ -306,8 +355,6 @@ confirm({ content: dict['model.confirm'] + dict['model.delete'] + ` - ${card.label} 锛焋, - okText: dict['model.confirm'], - cancelText: this.state.dict['header.cancel'], onOk() { let _columnlist = fromJS(_this.state.columnlist).toJS() @@ -319,12 +366,57 @@ if (column.marks && column.marks.filter(mark => mark.field === card.field || mark.contrastField === card.field).length > 0) { refers.push(column.label) } + if (column.type === 'colspan') { + let _length = column.sublist.length + column.sublist = column.sublist.filter(cell => cell !== card.uuid) + + if (column.sublist.length < _length) { + let subfield = [] // 鍚堝苟鍒楀瓧娈� + _columnlist.forEach(col => { + if (col.field && column.sublist.includes(col.uuid)) { + subfield.push(col.field) + } + }) + column.subfield = subfield.join(', ') + } + } }) if (refers.length > 0) { notification.warning({ top: 92, - message: '鏄剧ず鍒椼��' + refers.join('銆�') + '銆嬫爣璁颁腑鍚湁璇ュ瓧娈碉紝鍒犻櫎浼氬鑷存爣璁板け鏁堬紝璇蜂慨鏀广��' + refers.join('銆�') + '銆嬫爣璁拌缃紒', + message: '鏄剧ず鍒椼��' + refers.join('銆�') + '銆嬫爣璁颁腑鍚湁璇ュ瓧娈碉紝鍒犻櫎浼氬鑷存爣璁板け鏁堬紝璇蜂慨鏀圭浉搴旂殑鏍囪璁剧疆锛�', + duration: 5 + }) + } + + let chartRefers = [] + config.charts && config.charts.forEach((chart, index) => { + if (chart.chartType === 'card') { + if (chart.avatar && chart.avatar.field === card.field) { + chartRefers.push(chart.title || (index + 1)) + } else if (chart.header && chart.header.datatype === 'dynamic' && chart.header.field === card.field) { + chartRefers.push(chart.title || (index + 1)) + } else if (chart.details && chart.details.length > 0 && chart.details.filter(item => item.datatype === 'dynamic' && item.field === card.field).length > 0) { + chartRefers.push(chart.title || (index + 1)) + } + } else if (['bar', 'line', 'pie'].includes(chart.chartType)) { + if (chart.Xaxis === card.field) { + chartRefers.push(chart.title || (index + 1)) + } else if (Array.isArray(chart.Yaxis)) { + if (chart.Yaxis.includes(card.field)) { + chartRefers.push(chart.title || (index + 1)) + } + } else if (chart.Yaxis === card.field) { + chartRefers.push(chart.title || (index + 1)) + } + } + }) + + if (chartRefers.length > 0) { + notification.warning({ + top: 92, + message: '鍥捐〃銆�' + chartRefers.join('銆�') + '銆嬩腑鍚湁璇ュ瓧娈碉紝鍒犻櫎浼氬鑷村浘琛ㄦ樉绀哄紓甯革紝璇蜂慨鏀圭浉搴旂殑鍥捐〃璁剧疆锛�', duration: 5 }) } @@ -425,6 +517,10 @@ }) } + shouldComponentUpdate (nextProps, nextState) { + return !is(fromJS(this.props), fromJS(nextProps)) || !is(fromJS(this.state), fromJS(nextState)) + } + /** * @description 缁勪欢閿�姣侊紝娓呴櫎state鏇存柊 */ @@ -446,7 +542,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} @@ -463,7 +559,7 @@ <Modal title={dict['header.modal.column.edit']} visible={modaltype === 'columns'} - width={750} + width={800} maskClosable={false} onOk={this.handleSubmit} onCancel={this.editModalCancel} @@ -480,9 +576,9 @@ </Modal> {/* 鍚堝苟鍒楃紪杈� */} <Modal - title={dict['header.modal.colspan.edit']} + title={dict['model.form.colspan'] + '-' + dict['model.edit']} visible={modaltype === 'colspan'} - width={750} + width={800} maskClosable={false} onOk={this.handleSubmit} onCancel={this.editModalCancel} @@ -500,7 +596,7 @@ <Modal title={dict['header.modal.gridbtn.edit']} visible={modaltype === 'gridbtn'} - width={700} + width={800} maskClosable={false} onOk={this.handleSubmit} onCancel={this.editModalCancel} @@ -521,7 +617,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