From 9a82bce9cf0ed4a51c1b0b0669eaa38cedbace07 Mon Sep 17 00:00:00 2001 From: king <18310653075@163.com> Date: 星期四, 16 七月 2020 16:35:58 +0800 Subject: [PATCH] 2020-07-16 --- src/templates/sharecomponent/chartgroupcomponent/index.jsx | 62 ++++++++++++++++++++++++++++--- 1 files changed, 56 insertions(+), 6 deletions(-) diff --git a/src/templates/sharecomponent/chartgroupcomponent/index.jsx b/src/templates/sharecomponent/chartgroupcomponent/index.jsx index 1ed99b7..8650363 100644 --- a/src/templates/sharecomponent/chartgroupcomponent/index.jsx +++ b/src/templates/sharecomponent/chartgroupcomponent/index.jsx @@ -14,7 +14,6 @@ const { confirm } = Modal -// **鎮茶鑰呭線寰�姝g‘锛屼箰瑙傝�呭線寰�鎴愬姛 class ChartGroupComponent extends Component { static propTpyes = { config: PropTypes.object, // 鑿滃崟閰嶇疆淇℃伅 @@ -23,7 +22,7 @@ } state = { - dict: (!localStorage.getItem('lang') || localStorage.getItem('lang') === 'zh-CN') ? zhCN : enUS, + dict: localStorage.getItem('lang') !== 'en-US' ? zhCN : enUS, chartlist: null, // 鍥捐〃闆� card: null, // 缂栬緫涓厓绱� formlist: null, // 琛ㄥ崟淇℃伅 @@ -78,6 +77,8 @@ * @description 娣诲姞鎴栦慨鏀瑰浘琛� */ handleChart = (item) => { + const { config } = this.props + let _type = 'editChart' if (!item) { _type = 'addChart' @@ -88,14 +89,59 @@ chartType: 'line', icon: 'line-chart', Hide: 'false', - blacklist: [] + blacklist: [], + correction: 7 } + } + + let _columns = [{ + uuid: 'x', + value: '', + text: '绌�', + background: '' + }] + config.columns.forEach(col => { + if (!['text', 'number'].includes(col.type)) return + if (!col.marks) return + + let _marks = col.marks.filter(_mark => _mark.signType === 'card') + + if (_marks.length === 0) return + + _columns.push({ + uuid: col.uuid, + value: col.field, + text: col.label, + background: _marks[0].color ? _marks[0].color[1] : '' + }) + }) + + if (item.chartType === 'card') { // 妫�楠屽凡娣诲姞鑳屾櫙鏄惁淇敼 + if (item.bgfield) { + let _column = _columns.filter(col => col.value === item.bgfield)[0] + if (_column) { + item.background = _column.background + } else { + item.bgfield = '' + item.background = '' + } + } else { + item.background = '' + } + } + + let actions = config.action.filter(item => item.OpenType === 'excelOut' || (item.OpenType === 'excelIn' && item.Ot === 'notRequired')) + actions = actions.map(cell => ({value: cell.uuid, text: cell.label})) + + if (item.actions && item.actions.length > 0) { + let keys = actions.map(cell => cell.value) + item.actions = item.actions.filter(cell => keys.includes(cell)) } this.setState({ card: item, modaltype: _type, - formlist: getChartViewForm(item, this.props.sysRoles) + formlist: getChartViewForm(item, this.props.sysRoles, _columns, actions) }) } @@ -159,7 +205,7 @@ confirm({ content: dict['model.confirm'] + dict['model.delete'] + ` ${plot.title} 锛焋, okText: dict['model.confirm'], - cancelText: dict['header.cancel'], + cancelText: dict['model.cancel'], onOk() { let _chartlist = fromJS(_this.state.chartlist).toJS() let _chartview = _this.state.chartview @@ -188,6 +234,10 @@ }) this.props.updatechartgroup(config, id) + } + + shouldComponentUpdate (nextProps, nextState) { + return !is(fromJS(this.props), fromJS(nextProps)) || !is(fromJS(this.state), fromJS(nextState)) } /** @@ -220,7 +270,7 @@ <Modal title={modaltype === 'addChart' ? '鍥捐〃-娣诲姞' : '鍥炬爣-缂栬緫'} visible={modaltype === 'addChart' || modaltype === 'editChart'} - width={750} + width={800} maskClosable={false} onOk={this.submitChart} onCancel={this.editModalCancel} -- Gitblit v1.8.0