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