From 0f6153ab337c4ecca5579a79b03f3ba5f831e0c4 Mon Sep 17 00:00:00 2001 From: king <18310653075@163.com> Date: 星期日, 18 九月 2022 02:03:48 +0800 Subject: [PATCH] 2022-09-18 --- src/menu/components/chart/antv-bar/chartcompile/index.jsx | 209 +++++++++++++++++++++++++++++++++++++++++++-------- 1 files changed, 175 insertions(+), 34 deletions(-) diff --git a/src/menu/components/chart/antv-bar/chartcompile/index.jsx b/src/menu/components/chart/antv-bar/chartcompile/index.jsx index 942c0cf..70b73e8 100644 --- a/src/menu/components/chart/antv-bar/chartcompile/index.jsx +++ b/src/menu/components/chart/antv-bar/chartcompile/index.jsx @@ -218,7 +218,7 @@ } }, { - title: '鏄剧ず', + title: '鏄剧ず锛堝��/%锛�', dataIndex: 'show', inputType: 'select', editable: true, @@ -262,20 +262,41 @@ } }) - if (config.plot.correction) { - delete config.plot.correction // 鏁版嵁淇锛堝凡寮冪敤锛� - config.plot.barSize = 35 + let plot = fromJS(config.plot).toJS() + + if (plot.correction) { + delete plot.correction // 鏁版嵁淇锛堝凡寮冪敤锛� + plot.barSize = 35 + } + + if (plot.datatype !== 'statistics') { + if (plot.colors) { + plot.colors = plot.colors.map(item => { + if (fieldName[item.type]) { + item.label = fieldName[item.type] + } + return item + }) + } + if (plot.customs) { + plot.customs = plot.customs.map(item => { + if (fieldName[item.type]) { + item.name = fieldName[item.type] + } + return item + }) + } } this.setState({ visible: true, view: 'normal', - ramp: config.plot.ramp || 'false', - datatype: config.plot.datatype || 'query', + ramp: plot.ramp || 'false', + datatype: plot.datatype || 'query', fieldName: fieldName, - plot: fromJS(config.plot).toJS(), - baseFormlist: getBaseForm(config.plot), - formlist: getOptionForm(config.plot, config.columns) + plot: plot, + baseFormlist: getBaseForm(plot, config.columns), + formlist: getOptionForm(plot, config.columns) }) } @@ -286,7 +307,7 @@ if (key === 'datatype') { this.setState({ datatype: val, - formlist: formlist.map(item => { + formlist: fromJS(formlist).toJS().map(item => { if (['Yaxis'].includes(item.key)) { item.hidden = val === 'statistics' } else if (['InfoType', 'InfoValue'].includes(item.key)) { @@ -295,6 +316,26 @@ return item }) }) + } else if (key === 'label') { + this.setState({formlist: fromJS(formlist).toJS().map(cell => { + if (!['labelColor', 'labelValue'].includes(cell.key)) return cell + + if (cell.key === 'labelColor') { + if (val !== 'true') { + cell.hidden = true + } else { + cell.hidden = false + } + } else { + if (val === 'false') { + cell.hidden = true + } else { + cell.hidden = false + } + } + + return cell + })}) } } @@ -477,17 +518,39 @@ if (!err) { let _plot = {...plot, ...values} - if (values.datatype === 'statistics' || values.datatype !== plot.datatype) { - _plot.enabled = 'false' - _plot.customs = [] - } else if (!values.Yaxis || !plot.Yaxis || !is(fromJS(values.Yaxis), fromJS(plot.Yaxis))) { - _plot.enabled = 'false' - _plot.customs = [] - _plot.colors = null - } - if (values.datatype !== plot.datatype) { _plot.colors = null + } + if (values.datatype === 'statistics') { + _plot.enabled = 'false' + _plot.customs = [] + delete _plot.Yaxis + } else if (!is(fromJS(values.Yaxis), fromJS(plot.Yaxis || []))) { + _plot.enabled = 'false' + _plot.colors = null + + let labels = {} + config.columns.forEach(col => { + labels[col.field] = col.label + }) + + let cus = {} + _plot.customs && _plot.customs.forEach(m => { + cus[m.type] = m + }) + _plot.customs = _plot.Yaxis.map((item, i) => { + if (cus[item]) return cus[item] + + return { + uuid: Utils.getuuid(), + type: item, + name: labels[item] || item, + axis: i === 0 ? 'true' : 'false', + label: 'false', + title: 'true', + shape: _plot.chartType === 'bar' && i === 0 ? ['bar', 'rect'] : ['line', 'smooth'] + } + }) } this.setState({ @@ -501,6 +564,40 @@ } else if (view === 'base') { this.baseRef.handleConfirm().then(res => { let _plot = {...plot, ...res} + + if (res.click === 'menu') { + delete _plot.menus + } else if (res.click === 'menus') { + delete _plot.menu + } else { + delete _plot.menus + delete _plot.menu + } + + delete _plot.MenuID + delete _plot.MenuName + delete _plot.MenuNo + delete _plot.tabType + + if (_plot.click === 'menu' && sessionStorage.getItem('appType') === '' && _plot.menu) { + let list = null + try { + list = JSON.parse(sessionStorage.getItem('thdMenuList')) || [] + } catch (e) { + list = [] + } + + let id = _plot.menu[_plot.menu.length - 1] + + list.forEach(item => { + if (item.MenuID === id) { + _plot.MenuID = id + _plot.MenuName = item.MenuName + _plot.MenuNo = item.MenuNo + _plot.tabType = item.type + } + }) + } this.setState({ plot: _plot, @@ -526,22 +623,29 @@ if (!err) { let _plot = {...plot, ...values} - if (values.datatype === 'statistics' || values.datatype !== plot.datatype) { - _plot.enabled = 'false' - _plot.customs = [] - } else if (!values.Yaxis || !plot.Yaxis || !is(fromJS(values.Yaxis), fromJS(plot.Yaxis))) { - _plot.enabled = 'false' - _plot.customs = [] - _plot.colors = null - } - let labels = {} config.columns.forEach(col => { labels[col.field] = col.label }) - if (values.datatype !== 'statistics' && (!_plot.customs || _plot.customs.length === 0)) { + if (values.datatype !== plot.datatype) { + _plot.colors = null + } + if (values.datatype === 'statistics') { + _plot.enabled = 'false' + _plot.customs = [] + delete _plot.Yaxis + } else if (!is(fromJS(values.Yaxis), fromJS(plot.Yaxis || []))) { + _plot.enabled = 'false' + _plot.colors = null + + let cus = {} + _plot.customs && _plot.customs.forEach(m => { + cus[m.type] = m + }) _plot.customs = _plot.Yaxis.map((item, i) => { + if (cus[item]) return cus[item] + return { uuid: Utils.getuuid(), type: item, @@ -553,7 +657,8 @@ } }) } - if (values.datatype !== plot.datatype || !_plot.colors) { + + if (!_plot.colors) { _plot.colors = [] if (_plot.datatype === 'query') { let limit = chartColors.length @@ -579,8 +684,44 @@ }) } else if (view === 'base') { this.baseRef.handleConfirm().then(res => { + let _plot = {...plot, ...res} + + if (res.click === 'menu') { + delete _plot.menus + } else if (res.click === 'menus') { + delete _plot.menu + } else { + delete _plot.menus + delete _plot.menu + } + + delete _plot.MenuID + delete _plot.MenuName + delete _plot.MenuNo + delete _plot.tabType + + if (_plot.click === 'menu' && sessionStorage.getItem('appType') === '' && _plot.menu) { + let list = null + try { + list = JSON.parse(sessionStorage.getItem('thdMenuList')) || [] + } catch (e) { + list = [] + } + + let id = _plot.menu[_plot.menu.length - 1] + + list.forEach(item => { + if (item.MenuID === id) { + _plot.MenuID = id + _plot.MenuName = item.MenuName + _plot.MenuNo = item.MenuNo + _plot.tabType = item.type + } + }) + } + this.setState({ - plot: {...plot, ...res}, + plot: _plot, view: tab }) }) @@ -635,15 +776,15 @@ <div className="line-chart-drawer-form"> <EditOutlined title="缂栬緫" onClick={this.showDrawer}/> <Modal - wrapClassName="popview-modal menu-chart-edit-modal" - title={config.type === 'bar' ? '鏌辩姸鍥剧紪杈�' : '鎶樼嚎鍥剧紪杈�'} + wrapClassName="mk-pop-modal" visible={visible} - width={950} + width={1000} maskClosable={false} onOk={this.onSubmit} onCancel={() => { this.setState({ visible: false }) }} destroyOnClose > + {config.name ? <div className="mk-com-name">{config.name} - 缂栬緫</div> : null} <Tabs activeKey={view} className="menu-chart-edit-box" onChange={this.changeTab}> <TabPane tab="缁勪欢璁剧疆" key="base"> <NormalForm dict={this.props.dict} formlist={baseFormlist} inputSubmit={this.onSubmit} wrappedComponentRef={(inst) => this.baseRef = inst}/> -- Gitblit v1.8.0