From cb9ade2afd2a367ad767bc605ab7086c695dd010 Mon Sep 17 00:00:00 2001 From: king <18310653075@163.com> Date: 星期五, 09 十二月 2022 15:53:32 +0800 Subject: [PATCH] 2022-12-09 --- src/menu/components/chart/antv-bar/chartcompile/index.jsx | 222 +++++++++++++++++++++++++++++++++++++++++++++---------- 1 files changed, 181 insertions(+), 41 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..7feda4a 100644 --- a/src/menu/components/chart/antv-bar/chartcompile/index.jsx +++ b/src/menu/components/chart/antv-bar/chartcompile/index.jsx @@ -17,7 +17,6 @@ class LineChartDrawerForm extends Component { static propTpyes = { - dict: PropTypes.object, plot: PropTypes.object, config: PropTypes.object, plotchange: PropTypes.func @@ -218,7 +217,7 @@ } }, { - title: '鏄剧ず', + title: '鏄剧ず锛堝��/%锛�', dataIndex: 'show', inputType: 'select', editable: true, @@ -262,20 +261,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 +306,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 +315,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 + })}) } } @@ -324,7 +364,7 @@ rules: [ { required: !!item.required, - message: this.props.dict['form.required.input'] + item.label + '!' + message: '璇疯緭鍏�' + item.label + '!' } ] })(<Input placeholder="" autoComplete="off" disabled={item.readonly} onPressEnter={this.onSubmit}/>)} @@ -345,7 +385,7 @@ rules: [ { required: !!item.required, - message: this.props.dict['form.required.input'] + item.label + '!' + message: '璇疯緭鍏�' + item.label + '!' } ] })(<InputNumber min={item.min} max={item.max} precision={item.decimal} onPressEnter={this.onSubmit}/>)} @@ -366,7 +406,7 @@ rules: [ { required: !!item.required, - message: this.props.dict['form.required.select'] + item.label + '!' + message: '璇烽�夋嫨' + item.label + '!' } ] })( @@ -395,7 +435,7 @@ rules: [ { required: !!item.required, - message: this.props.dict['form.required.select'] + item.label + '!' + message: '璇烽�夋嫨' + item.label + '!' } ] })( @@ -477,17 +517,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 +563,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 +622,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 +656,8 @@ } }) } - if (values.datatype !== plot.datatype || !_plot.colors) { + + if (!_plot.colors) { _plot.colors = [] if (_plot.datatype === 'query') { let limit = chartColors.length @@ -579,8 +683,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,18 +775,18 @@ <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}/> + <NormalForm formlist={baseFormlist} inputSubmit={this.onSubmit} wrappedComponentRef={(inst) => this.baseRef = inst}/> </TabPane> <TabPane tab="鍥捐〃璁剧疆" key="normal"> <Form {...formItemLayout}> @@ -675,7 +815,7 @@ </Form.Item> </Form> </Col> : null} - {datatype === 'statistics' ? <Button className="color-add mk-green" onClick={this.addColor}>{this.props.dict['model.add']}</Button> : null} + {datatype === 'statistics' ? <Button className="color-add mk-green" onClick={this.addColor}>娣诲姞</Button> : null} {datatype === 'statistics' ? <EditTable actions={['edit', 'move', 'del']} data={plot.colors || []} columns={ramp ==='true' ? rampStatColorColumns : statColorColumns} onChange={this.changeColor}/> : null} {datatype !== 'statistics' ? <EditTable actions={['edit']} data={plot.colors || []} columns={ramp ==='true' ? rampColorColumns : colorColumns} onChange={this.changeColor}/> : null} </div> -- Gitblit v1.8.0