提交 ca6a992d authored 作者: 钟是志's avatar 钟是志

18689 就业-协议书违约管理-协议书违约查询-院系,自定义统计-聚合条件问题

删减部分代码. Array.splice 第二个参数的bug
上级 bf922ed1
const nameSpan = {
small: 9,
big: 7,
};
const nameSpan2 = {
small: 0,
big: 0,
};
const nameSpan3 = {
small: 3,
big: 2,
};
export {nameSpan, nameSpan3, nameSpan2};
import React from 'react'; import React from 'react';
import ReactDOM from 'react-dom'; import {Select, Modal, Table, Row, Col, Tag, Form, message, notification} from 'antd';
import {Select, Button, Modal, Input, Table, Row, Col, Tag, Form, message, notification} from 'antd';
import {connect} from 'dva'; import {connect} from 'dva';
import {getToken} from '../utils/token' import {getToken} from '../../utils/token'
import config from '@/webPublic/one_stop_public/config'; import config from '@/webPublic/one_stop_public/config';
import QueryItem from './QueryItem'; import QueryItem from '../QueryItem';
import OrderItem from './OrderItem'; import styles from '../Ability.css';
import styles from './Ability.css'; import FormdataWrapper from '../../utils/object-to-formdata-custom';
import FormdataWrapper from '../utils/object-to-formdata-custom'; import ButtonDiy from '../ButtonDiy/ButtonDiy';
import ButtonDiy from './ButtonDiy/ButtonDiy'; import {nameSpan,nameSpan3,nameSpan2} from './config';
const Option = Select.Option; const Option = Select.Option;
const nameSpan = {
small: 9,
big: 7,
};
const nameSpan2 = {
small: 0,
big: 0,
};
const nameSpan3 = {
small: 3,
big: 2,
};
var keyX = 1;
function swapArray(arr, index1, index2) {
arr[index1] = arr.splice(index2, 1, arr[index1])[0];
return arr;
}
const FormItem = Form.Item; const FormItem = Form.Item;
@connect(({cms, loading}) => ({ @connect(({cms, loading}) => ({
...@@ -49,7 +28,6 @@ export default class StatisticsInfo extends React.Component { ...@@ -49,7 +28,6 @@ export default class StatisticsInfo extends React.Component {
currentQueryKey: null, currentQueryKey: null,
currentGroupKey: null, currentGroupKey: null,
orderVisiable: false, orderVisiable: false,
groupVisiable: false,
currentOrderKey: null, currentOrderKey: null,
querys: [], querys: [],
orders: [], orders: [],
...@@ -79,28 +57,26 @@ export default class StatisticsInfo extends React.Component { ...@@ -79,28 +57,26 @@ export default class StatisticsInfo extends React.Component {
}; };
deleteQuery = (i) => { deleteQuery = (i) => {
const querys = this.state.querys; const querys = this.state.querys;
querys.splice(i); querys.splice(i, 1);
this.setState({querys}); this.setState({querys});
}; };
deleteOrder = (i) => { deleteOrder = (i) => {
const orders = this.state.orders; const orders = this.state.orders;
orders.splice(i); orders.splice(i, 1);
this.setState({orders}); this.setState({orders});
}; };
deleteGroup = (i) => { deleteGroup = (i) => {
const groups = this.state.groups; const groups = this.state.groups;
groups.splice(i); groups.splice(i, 1);
this.setState( this.setState(
{ {
groups groups: [...groups],
}, () => { }, () => {
this.finish(); this.finish();
}); });
}; };
open = () => { open = () => {
const {dispatch} = this.props; const {dispatch} = this.props;
dispatch({ dispatch({
type: 'DataObj/getExportInfo', type: 'DataObj/getExportInfo',
payload: { payload: {
...@@ -164,12 +140,6 @@ export default class StatisticsInfo extends React.Component { ...@@ -164,12 +140,6 @@ export default class StatisticsInfo extends React.Component {
this.setState({targetKeys}); this.setState({targetKeys});
}; };
addOrder = () => {
this.setState({orderVisiable: true});
};
okOrder = () => { okOrder = () => {
const orders = this.state.orders; const orders = this.state.orders;
orders.push(this.state.infos[this.state.currentOrderKey]); orders.push(this.state.infos[this.state.currentOrderKey]);
...@@ -192,11 +162,7 @@ export default class StatisticsInfo extends React.Component { ...@@ -192,11 +162,7 @@ export default class StatisticsInfo extends React.Component {
}); });
}; };
addGroup = () => {
this.setState({groupVisiable: true});
};
addQuery = () => { addQuery = () => {
this.setState({queryVisiable: true}); this.setState({queryVisiable: true});
...@@ -217,11 +183,11 @@ export default class StatisticsInfo extends React.Component { ...@@ -217,11 +183,11 @@ export default class StatisticsInfo extends React.Component {
const {x, y, z, infos, XxX, currentKey, groups} = this.state; const {x, y, z, infos, XxX, currentKey, groups} = this.state;
if (x == null) { if (x == null) {
message.error('请选择第一统计项'); message.warning('请选择第一统计项');
return; return;
} }
if (y == null) { if (y == null) {
message.error('请选择行数据'); message.warning('请选择行数据');
return; return;
} }
this.props.form.validateFields((err, fieldsValue) => { this.props.form.validateFields((err, fieldsValue) => {
...@@ -230,9 +196,7 @@ export default class StatisticsInfo extends React.Component { ...@@ -230,9 +196,7 @@ export default class StatisticsInfo extends React.Component {
const ggs = []; const ggs = [];
for (var key in fieldsValue) { for (var key in fieldsValue) {
var xx = key.indexOf("__") var xx = key.indexOf("__")
let kk = key.substr(xx + 2); let kk = key.substr(xx + 2);
qqs.push({ qqs.push({
notes: this.state.infos[kk].notes, notes: this.state.infos[kk].notes,
hql: this.state.infos[kk].hql, hql: this.state.infos[kk].hql,
...@@ -240,12 +204,10 @@ export default class StatisticsInfo extends React.Component { ...@@ -240,12 +204,10 @@ export default class StatisticsInfo extends React.Component {
x: fieldsValue[key].stringX, x: fieldsValue[key].stringX,
v: fieldsValue[key].string, v: fieldsValue[key].string,
}); });
} }
if (groups.length === 0) { if (groups.length === 0) {
message.error('请至少选择一个聚合条件'); message.warning('请至少选择一个聚合条件');
return; return;
} }
...@@ -254,7 +216,6 @@ export default class StatisticsInfo extends React.Component { ...@@ -254,7 +216,6 @@ export default class StatisticsInfo extends React.Component {
} }
const tx = infos[x] const tx = infos[x]
const ty = infos[y] const ty = infos[y]
var ttx; var ttx;
var tty; var tty;
var ttz; var ttz;
...@@ -295,7 +256,6 @@ export default class StatisticsInfo extends React.Component { ...@@ -295,7 +256,6 @@ export default class StatisticsInfo extends React.Component {
y: tty, y: tty,
z: ttz, z: ttz,
objId, objId,
xXx: XxX, xXx: XxX,
hql: currentKey && infos[currentKey] ? infos[currentKey].hql : null, hql: currentKey && infos[currentKey] ? infos[currentKey].hql : null,
querys: JSON.stringify(qqs), querys: JSON.stringify(qqs),
...@@ -304,17 +264,13 @@ export default class StatisticsInfo extends React.Component { ...@@ -304,17 +264,13 @@ export default class StatisticsInfo extends React.Component {
callback: (data) => { callback: (data) => {
this.setState({dataSource: data.dataSource, columns: data.columns}); this.setState({dataSource: data.dataSource, columns: data.columns});
}, },
}); });
}); });
}; };
downloadFile(url, params) { downloadFile(url, params) {
this.setState({exportLoading: true}); this.setState({exportLoading: true});
fetch(url, { fetch(url, {
method: 'POST', method: 'POST',
body: FormdataWrapper(params) body: FormdataWrapper(params)
...@@ -356,11 +312,11 @@ export default class StatisticsInfo extends React.Component { ...@@ -356,11 +312,11 @@ export default class StatisticsInfo extends React.Component {
const {x, y, z, infos, XxX, currentKey, groups} = this.state; const {x, y, z, infos, XxX, currentKey, groups} = this.state;
if (x == null) { if (x == null) {
message.error('请选择第一统计项'); message.warning('请选择第一统计项');
return; return;
} }
if (y == null) { if (y == null) {
message.error('请选择行数据'); message.warning('请选择行数据');
return; return;
} }
this.props.form.validateFields((err, fieldsValue) => { this.props.form.validateFields((err, fieldsValue) => {
...@@ -384,7 +340,7 @@ export default class StatisticsInfo extends React.Component { ...@@ -384,7 +340,7 @@ export default class StatisticsInfo extends React.Component {
} }
if (groups.length === 0) { if (groups.length === 0) {
message.error('请至少选择一个聚合条件'); message.warning('请至少选择一个聚合条件');
return; return;
} }
...@@ -503,13 +459,11 @@ export default class StatisticsInfo extends React.Component { ...@@ -503,13 +459,11 @@ export default class StatisticsInfo extends React.Component {
}; };
componentDidMount() { componentDidMount() {
// this.open(); this.open();
} }
pageConfig = (item = 0) => { pageConfig = (item = 0) => {
const { const {
visiable,
queryVisiable,
querys, querys,
groups, groups,
currentKey, currentKey,
...@@ -517,17 +471,13 @@ export default class StatisticsInfo extends React.Component { ...@@ -517,17 +471,13 @@ export default class StatisticsInfo extends React.Component {
infos, infos,
mockData, mockData,
mockXZData, mockXZData,
columns,
dataSource,
qs, qs,
os,
gs, gs,
x, x,
y, y,
z, z,
currentQueryKey, currentQueryKey,
currentGroupKey, currentGroupKey,
groupVisiable,
} = this.state; } = this.state;
let xxxs = []; let xxxs = [];
if (currentKey != null) { if (currentKey != null) {
...@@ -557,7 +507,6 @@ export default class StatisticsInfo extends React.Component { ...@@ -557,7 +507,6 @@ export default class StatisticsInfo extends React.Component {
} }
let optionGs = []; let optionGs = [];
for (let item of gs) { for (let item of gs) {
let add = true; let add = true;
for (let i = 0; i < groups.length; i++) { for (let i = 0; i < groups.length; i++) {
...@@ -780,8 +729,8 @@ export default class StatisticsInfo extends React.Component { ...@@ -780,8 +729,8 @@ export default class StatisticsInfo extends React.Component {
const {form, loading} = this.props; const {form, loading} = this.props;
const { const {
visiable, querys, groups, currentKey, XxX, exportLoading, visiable, querys, groups, exportLoading,
infos, mockData, columns, dataSource, qs, os, gs, x, y, z, currentQueryKey, currentGroupKey, groupVisiable, infos, columns, dataSource, x, y, z,
} = this.state; } = this.state;
const loadingxxx = loading || exportLoading; const loadingxxx = loading || exportLoading;
let columnsTemp = columns; let columnsTemp = columns;
...@@ -801,19 +750,7 @@ export default class StatisticsInfo extends React.Component { ...@@ -801,19 +750,7 @@ export default class StatisticsInfo extends React.Component {
columnsTemp[0].width = 200; columnsTemp[0].width = 200;
} }
} }
let xxxs = [];
if (currentKey != null) {
if (infos[currentKey].type === 'java.lang.Integer' ||
infos[currentKey].type === 'java.lang.Double' ||
infos[currentKey].type === 'java.lang.Long') {
xxxs = [{label: '数量', value: 'count'}, {label: '最大值', value: 'max'}, {
label: '最小值',
value: 'min',
}, {label: '平均值', value: 'avg'}, {label: '求和', value: 'sum'}];
} else {
xxxs = [{label: '数量', value: 'count'}];
}
}
return ( return (
<span> <span>
{/* 暂时屏蔽 */} {/* 暂时屏蔽 */}
...@@ -835,11 +772,11 @@ export default class StatisticsInfo extends React.Component { ...@@ -835,11 +772,11 @@ export default class StatisticsInfo extends React.Component {
onCancel={this.onCancle} onCancel={this.onCancle}
> >
{this.selectDom(0)} {this.selectDom(0)} {/*第一统计项*/}
{this.selectDom(1)} {this.selectDom(1)} {/*第二统计项*/}
{this.selectDom(2)} {this.selectDom(2)} {/*行数据*/}
{this.selectDom(3)} {this.selectDom(3)} {/*统计指标*/}
{this.selectDom(4)} {this.selectDom(4)} {/*查询条件*/}
<div style={{ <div style={{
textAlign: 'left', textAlign: 'left',
paddingLeft: '25px', paddingLeft: '25px',
...@@ -873,7 +810,7 @@ export default class StatisticsInfo extends React.Component { ...@@ -873,7 +810,7 @@ export default class StatisticsInfo extends React.Component {
deleteQuery={this.deleteQuery.bind(this, i)}/>)} deleteQuery={this.deleteQuery.bind(this, i)}/>)}
</FormItem>)} </FormItem>)}
</div> </div>
{this.selectDom(5)} {this.selectDom(5)} {/*聚合条件*/}
<Row style={{ <Row style={{
textAlign: 'left', textAlign: 'left',
paddingLeft: '80px', paddingLeft: '80px',
...@@ -882,7 +819,7 @@ export default class StatisticsInfo extends React.Component { ...@@ -882,7 +819,7 @@ export default class StatisticsInfo extends React.Component {
{groups.map((r, i) => {groups.map((r, i) =>
<Tag closable={true} <Tag closable={true}
key={i + r.field} key={i + r.field}
onChange={this.deleteGroup.bind(this, i)}> onClose={this.deleteGroup.bind(this, i)}>
{'按' + r.name + '聚合'} {'按' + r.name + '聚合'}
</Tag>, </Tag>,
)} )}
...@@ -895,15 +832,6 @@ export default class StatisticsInfo extends React.Component { ...@@ -895,15 +832,6 @@ export default class StatisticsInfo extends React.Component {
<ButtonDiy handleClick={this.export} <ButtonDiy handleClick={this.export}
name={'导出'} name={'导出'}
loading={loadingxxx}/> loading={loadingxxx}/>
{/* <Button type="primary"
onClick={this.finish}>
查询
</Button>
<Button type="primary"
onClick={this.finish}>
导出
</Button>
结果:*/}
</Col> </Col>
<Col span={24} <Col span={24}
style={{ style={{
...@@ -918,12 +846,6 @@ export default class StatisticsInfo extends React.Component { ...@@ -918,12 +846,6 @@ export default class StatisticsInfo extends React.Component {
columns={columnsTemp} columns={columnsTemp}
scroll={{x: 'max-content'}} scroll={{x: 'max-content'}}
pagination={false}/> pagination={false}/>
{/*{columns.length > 0 ?*/}
{/*<Table size="small"*/}
{/*bordered*/}
{/*dataSource={dataSource}*/}
{/*columns={columnsTemp}*/}
{/*pagination={false} /> : ''}*/}
</Col> </Col>
</Row> </Row>
</Modal> </Modal>
......
Markdown 格式
0%
您添加了 0 到此讨论。请谨慎行事。
请先完成此评论的编辑!
注册 或者 后发表评论