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

19571 学籍管理-学生管理-自定义统计,统计导出问题

上级 34fcd152
import React from 'react' import React from 'react';
import { Select,Input,InputNumber,Button,DatePicker } from 'antd'; import { Select, Input, InputNumber, Button, DatePicker } from 'antd';
import { connect } from 'dva'; import { connect } from 'dva';
import moment from 'moment'; import moment from 'moment';
import ButtonDiy from '@/baseComponent/ButtonDiy'; import ButtonDiy from '@/baseComponent/ButtonDiy';
const Option = Select.Option; const Option = Select.Option;
export default class QueryItem extends React.Component { export default class QueryItem extends React.Component {
constructor(props) { constructor(props) {
super(props); super(props);
const value = props.value || {}; const value = props.value || {};
this.state = { this.state = {
stringX:value.stringX, stringX: value.stringX, // 等于 不等于 那个下拉框的值
string:value.string, string: value.string, // 搜索值
disabled:value.disabled||false disabled: value.disabled || false,
}; };
} }
componentWillReceiveProps(nextProps) { componentWillReceiveProps(nextProps) {
// Should be a controlled component. // Should be a controlled component.
if ('value' in nextProps) { if ('value' in nextProps && nextProps.value) {
const value = nextProps.value; const value = nextProps.value;
this.setState(value); this.setState({
} stringX: value.stringX, // 等于 不等于 那个下拉框的值
} string: value.string, // 搜索值
disabled: value.disabled || false,
triggerChange = (changedValue) => { });
// Should provide an event to pass value to Form. }
const onChange = this.props.onChange; }
if (onChange) {
onChange(Object.assign({}, this.state, changedValue)); triggerChange = (changedValue) => {
} // Should provide an event to pass value to Form.
}; const onChange = this.props.onChange;
if (onChange) {
changeNumber=(e)=>{ const newValue = Object.assign({}, this.state, changedValue);
onChange(newValue);
if (!('value' in this.props)) { }
this.setState({ string:e}); };
}
this.triggerChange({ string:e}); changeNumber = (e) => {
}; if (!('value' in this.props)) {
changeStringX=(e)=>{ this.setState({ string: e });
var disabled = false }
this.triggerChange({ string: e });
if(e=="IS NOT NULL"||e=="IS NULL"){ };
disabled=true; changeStringX = (e) => {
var disabled = false;
}
if (!('value' in this.props)) { if (e == 'IS NOT NULL' || e == 'IS NULL') {
this.setState({ stringX:e ,disabled}); disabled = true;
} }
if (!('value' in this.props)) {
this.triggerChange({ stringX:e ,disabled}); this.setState({ stringX: e, disabled });
}; }
changeString=(e)=>{
this.triggerChange({ stringX: e, disabled });
if (!('value' in this.props)) { };
this.setState({ string:e.target.value }); changeString = (e) => {
} if (!('value' in this.props)) {
this.triggerChange({ string:e.target.value }); this.setState({ string: e.target.value });
}; }
changeDate=(date)=>{ this.triggerChange({ string: e.target.value });
//console.log(date) };
if (!('value' in this.props)) { changeDate = (date) => {
this.setState({ string:date.valueOf() }); if (!('value' in this.props)) {
} this.setState({ string: date.valueOf() });
this.triggerChange({ string:date.valueOf() }); }
}; this.triggerChange({ string: date.valueOf() });
render() { };
const{obj} = this.props;
const {string,stringX,disabled} =this.state; render() {
if(obj.options && obj.options.length>0){ const { obj } = this.props;
return(<div> <Select onChange={this.changeStringX} const { string, stringX, disabled } = this.state;
value={stringX||"="} if (obj.options && obj.options.length > 0) {
style={{width:100, paddingRight: 12}}> return (
<Option value="=">等于</Option> <div>
<Option value="<>">不等于</Option> <Select
<Option value="IS NOT NULL">不为空</Option> onChange={this.changeStringX}
<Option value="IS NULL">为空</Option> value={stringX || '='}
</Select> style={{ width: 100, paddingRight: 12 }}>
{disabled?"": <span style={{paddingRight: 12}}> <Option value="=">等于</Option>
<Select onChange={this.changeNumber} <Option value="<>">不等于</Option>
value={string} <Option value="IS NOT NULL">不为空</Option>
style={{width:200}}> <Option value="IS NULL">为空</Option>
{obj.options.map((r)=><Option key={r.v} value={r.v}>{r.l}</Option>)} </Select>
{disabled ? (
</Select> ''
</span>} ) : (
<ButtonDiy className='defaultRed' <span style={{ paddingRight: 12 }}>
name="删除" <Select onChange={this.changeNumber}
handleClick={this.props.deleteQuery}/> value={string}
</div>) style={{ width: 200 }}
} >
if(obj.type === "java.lang.String"){ {obj.options.map((r) => (
return ( <Option key={r.v} value={r.v}>
<div> {r.l}
<Select onChange={this.changeStringX} </Option>
value={stringX||"="} ))}
style={{width:100, paddingRight: 12 }}> </Select>
<Option value="=">等于</Option> </span>
<Option value="!=">不等于</Option> )}
<Option value="like"></Option> <ButtonDiy className="defaultRed" name="删除" handleClick={this.props.deleteQuery} />
<Option value="IS NOT NULL">不为空</Option> </div>
<Option value="IS NULL">为空</Option> );
</Select> }
{disabled?"": <span style={{paddingRight: 12}}> if (obj.type === 'java.lang.String') {
<Input onChange={this.changeString} return (
placeholder="请输入" <div>
value={string} <Select
style={{width:200,}} onChange={this.changeStringX}
/> value={stringX || '='}
</span>} style={{ width: 100, paddingRight: 12 }}>
<ButtonDiy className='defaultRed' <Option value="=">等于</Option>
name="删除" <Option value="!=">不等于</Option>
handleClick={this.props.deleteQuery}/> <Option value="like"></Option>
</div>) <Option value="IS NOT NULL">不为空</Option>
<Option value="IS NULL">为空</Option>
}else if(obj.type === "java.lang.Integer"|| </Select>
obj.type === "java.lang.Double" || {disabled ? (
obj.type === "java.lang.Long"){ ''
return ( <div> <Select onChange={this.changeStringX} ) : (
value={stringX||"="} <span style={{ paddingRight: 12 }}>
style={{width:100, paddingRight: 12}}> <Input
<Option value="=">等于</Option> onChange={this.changeString}
<Option value="<>">不等于</Option> placeholder="请输入"
<Option value=">">大于</Option> value={string}
<Option value=">=">大于等于</Option> style={{ width: 200 }}
<Option value="<">小于</Option> />
<Option value="<=">小于等于</Option> </span>
<Option value="IS NOT NULL">不为空</Option> )}
<Option value="IS NULL">为空</Option> <ButtonDiy className="defaultRed" name="删除" handleClick={this.props.deleteQuery} />
</Select> </div>
{disabled?"": <span style={{paddingRight: 12}}> );
<InputNumber onChange={this.changeNumber} } else if (
placeholder="请输入" obj.type === 'java.lang.Integer' ||
value={string} obj.type === 'java.lang.Double' ||
style={{width:200}} obj.type === 'java.lang.Long'
/> ) {
</span>} return (
<ButtonDiy className='defaultRed' <div>
style={{marginLeft: 12}} <Select
name="删除" onChange={this.changeStringX}
handleClick={this.props.deleteQuery}/> value={stringX || '='}
</div>) style={{ width: 100, paddingRight: 12 }}>
}else if(obj.type === "java.lang.Boolean"){ <Option value="=">等于</Option>
return ( <div> <Option value="<>">不等于</Option>
<Select onChange={this.changeStringX} <Option value=">">大于</Option>
value={stringX||"="} <Option value=">=">大于等于</Option>
style={{width:100, paddingRight: 12}}> <Option value="<">小于</Option>
<Option value="="> <Option value="<=">小于等于</Option>
等于 <Option value="IS NOT NULL">不为空</Option>
</Option> <Option value="IS NULL">为空</Option>
</Select> </Select>
{disabled?"": <span style={{paddingRight: 12}}> {disabled ? (
<Select onChange={this.changeNumber} ''
value={string} ) : (
style={{width:200}} <span style={{ paddingRight: 12 }}>
> <InputNumber
<Option value={true}> onChange={this.changeNumber}
placeholder="请输入"
</Option> value={string}
<Option value={false}> style={{ width: 200 }}
/>
</Option> </span>
</Select> )}
</span>} <ButtonDiy
<ButtonDiy className='defaultRed' className="defaultRed"
style={{marginLeft: 12}} style={{ marginLeft: 12 }}
name="删除" name="删除"
handleClick={this.props.deleteQuery}/> handleClick={this.props.deleteQuery}
</div>) />
}else if(obj.type === "java.util.Date"){ </div>
return(<div> );
<Select onChange={this.changeStringX} } else if (obj.type === 'java.lang.Boolean') {
value={stringX||"="} return (
style={{width:100, paddingRight: 12}}> <div>
<Option value="=">等于</Option> <Select
<Option value="<>">不等于</Option> onChange={this.changeStringX}
<Option value=">">大于</Option> value={stringX || '='}
<Option value=">=">大于等于</Option> style={{ width: 100, paddingRight: 12 }}>
<Option value="<">小于</Option> <Option value="=">等于</Option>
<Option value="<=">小于等于</Option> </Select>
<Option value="IS NOT NULL">不为空</Option> {disabled ? (
<Option value="IS NULL">为空</Option> ''
</Select> ) : (
{disabled?"": <span style={{paddingRight: 12}}> <span style={{ paddingRight: 12 }}>
<DatePicker onChange={this.changeDate} <Select onChange={this.changeNumber} value={string} style={{ width: 200 }}>
showTime <Option value={true}></Option>
format="YYYY-MM-DD HH:mm:ss" <Option value={false}></Option>
allowClear={false} </Select>
style={{width:200}} </span>
value={string?moment(string):null} )}
/> <ButtonDiy
</span>} className="defaultRed"
<ButtonDiy className='defaultRed' style={{ marginLeft: 12 }}
style={{marginLeft: 12}} name="删除"
name="删除" handleClick={this.props.deleteQuery}
handleClick={this.props.deleteQuery}/> />
</div>) </div>
);
}else{ } else if (obj.type === 'java.util.Date') {
return (<span>暂无法处理</span>) return (
} <div>
<Select
onChange={this.changeStringX}
} value={stringX || '='}
style={{ width: 100, paddingRight: 12 }}>
<Option value="=">等于</Option>
<Option value="<>">不等于</Option>
<Option value=">">大于</Option>
<Option value=">=">大于等于</Option>
<Option value="<">小于</Option>
<Option value="<=">小于等于</Option>
<Option value="IS NOT NULL">不为空</Option>
<Option value="IS NULL">为空</Option>
</Select>
{disabled ? (
''
) : (
<span style={{ paddingRight: 12 }}>
<DatePicker
onChange={this.changeDate}
showTime
format="YYYY-MM-DD HH:mm:ss"
allowClear={false}
style={{ width: 200 }}
value={string ? moment(string) : null}
/>
</span>
)}
<ButtonDiy
className="defaultRed"
style={{ marginLeft: 12 }}
name="删除"
handleClick={this.props.deleteQuery}
/>
</div>
);
} else {
return <span>暂无法处理</span>;
}
}
} }
/**
* 钟是志
* 2021年5月25日 10:56:50
* 学工 学生管理 自定义统计 功能 通用版
*
* */
import React, { Fragment } from 'react'; import React, { Fragment } from 'react';
import { Select, Button, Divider, Table, Row, Col, Tag, Alert, Form, message } from 'antd'; import { Select, Button, Divider, Table, Row, Col, Tag, Alert, Form, message } from 'antd';
import { connect } from 'dva'; import { connect } from 'dva';
...@@ -27,6 +33,14 @@ const nameSpan3 = { ...@@ -27,6 +33,14 @@ const nameSpan3 = {
}; };
var keyX = 1; var keyX = 1;
function getLableNameByValue(
options = [],
searchKey = ''){
const findItem = options.find((x) => {
return x.field === searchKey;
});
return findItem.name;
}
const FormItem = Form.Item; const FormItem = Form.Item;
@connect(({ cms, ExportFile, loading }) => ({ @connect(({ cms, ExportFile, loading }) => ({
...@@ -306,6 +320,7 @@ export default class StatisticsInfo extends React.Component { ...@@ -306,6 +320,7 @@ export default class StatisticsInfo extends React.Component {
finish = () => { finish = () => {
const { dispatch, beanName, daoClass } = this.props; const { dispatch, beanName, daoClass } = this.props;
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.info('请选择横轴'); message.info('请选择横轴');
return; return;
...@@ -330,8 +345,6 @@ export default class StatisticsInfo extends React.Component { ...@@ -330,8 +345,6 @@ 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) {
...@@ -349,7 +362,7 @@ export default class StatisticsInfo extends React.Component { ...@@ -349,7 +362,7 @@ export default class StatisticsInfo extends React.Component {
var tty; var tty;
var ttz; var ttz;
if (tx.notes) { if (tx.notes) {
if (tx.notes.indexOf('com.') == -1) { if (tx.notes.indexOf('com.') === -1) {
ttx = infos[x].hql.replace('.id', '.dictName'); ttx = infos[x].hql.replace('.id', '.dictName');
} else { } else {
ttx = infos[x].hql; ttx = infos[x].hql;
...@@ -358,7 +371,7 @@ export default class StatisticsInfo extends React.Component { ...@@ -358,7 +371,7 @@ export default class StatisticsInfo extends React.Component {
ttx = infos[x].hql; ttx = infos[x].hql;
} }
if (ty.notes) { if (ty.notes) {
if (ty.notes.indexOf('com.') == -1) { if (ty.notes.indexOf('com.') === -1) {
tty = infos[y].hql.replace('.id', '.dictName'); tty = infos[y].hql.replace('.id', '.dictName');
} else { } else {
tty = infos[y].hql; tty = infos[y].hql;
...@@ -369,7 +382,7 @@ export default class StatisticsInfo extends React.Component { ...@@ -369,7 +382,7 @@ export default class StatisticsInfo extends React.Component {
if (z != null) { if (z != null) {
const tz = infos[z]; const tz = infos[z];
if (tz && tz.notes) { if (tz && tz.notes) {
if (tz.notes.indexOf('com.') == -1) { if (tz.notes.indexOf('com.') === -1) {
ttz = infos[z].hql.replace('.id', '.dictName'); ttz = infos[z].hql.replace('.id', '.dictName');
} else { } else {
ttz = infos[z].hql; ttz = infos[z].hql;
...@@ -447,9 +460,10 @@ export default class StatisticsInfo extends React.Component { ...@@ -447,9 +460,10 @@ export default class StatisticsInfo extends React.Component {
} }
export = () => { export = () => {
const { dispatch, beanName, daoClass } = this.props; const { beanName, daoClass } = this.props;
const { x, y, z, infos, XxX, currentKey, groups } = this.state; const { x, y, z, infos, XxX, currentKey, groups, qs } = this.state;
console.log(this.state, '----state---');
console.log(this.props, '----props---');
if (x == null) { if (x == null) {
message.info('请选择第一统计项'); message.info('请选择第一统计项');
return; return;
...@@ -493,7 +507,7 @@ export default class StatisticsInfo extends React.Component { ...@@ -493,7 +507,7 @@ export default class StatisticsInfo extends React.Component {
var tty; var tty;
var ttz; var ttz;
if (tx.notes) { if (tx.notes) {
if (tx.notes.indexOf('com.') == -1) { if (tx.notes.indexOf('com.') === -1) {
ttx = infos[x].hql.replace('.id', '.dictName'); ttx = infos[x].hql.replace('.id', '.dictName');
} else { } else {
ttx = infos[x].hql; ttx = infos[x].hql;
...@@ -502,7 +516,7 @@ export default class StatisticsInfo extends React.Component { ...@@ -502,7 +516,7 @@ export default class StatisticsInfo extends React.Component {
ttx = infos[x].hql; ttx = infos[x].hql;
} }
if (ty.notes) { if (ty.notes) {
if (ty.notes.indexOf('com.') == -1) { if (ty.notes.indexOf('com.') === -1) {
tty = infos[y].hql.replace('.id', '.dictName'); tty = infos[y].hql.replace('.id', '.dictName');
} else { } else {
tty = infos[y].hql; tty = infos[y].hql;
...@@ -513,7 +527,7 @@ export default class StatisticsInfo extends React.Component { ...@@ -513,7 +527,7 @@ export default class StatisticsInfo extends React.Component {
if (z != null) { if (z != null) {
const tz = infos[z]; const tz = infos[z];
if (tz && tz.notes) { if (tz && tz.notes) {
if (tz.notes.indexOf('com.') == -1) { if (tz.notes.indexOf('com.') === -1) {
ttz = infos[z].hql.replace('.id', '.dictName'); ttz = infos[z].hql.replace('.id', '.dictName');
} else { } else {
ttz = infos[z].hql; ttz = infos[z].hql;
...@@ -526,6 +540,9 @@ export default class StatisticsInfo extends React.Component { ...@@ -526,6 +540,9 @@ export default class StatisticsInfo extends React.Component {
x: ttx, x: ttx,
y: tty, y: tty,
z: ttz, z: ttz,
xname: getLableNameByValue(qs, x),
yname: getLableNameByValue(qs, y),
zname: getLableNameByValue(qs, z),
beanName, beanName,
daoClass, daoClass,
xXx: XxX, xXx: XxX,
...@@ -533,7 +550,6 @@ export default class StatisticsInfo extends React.Component { ...@@ -533,7 +550,6 @@ export default class StatisticsInfo extends React.Component {
hql: currentKey && infos[currentKey] ? infos[currentKey].hql : null, hql: currentKey && infos[currentKey] ? infos[currentKey].hql : null,
querys: JSON.stringify(qqs), querys: JSON.stringify(qqs),
groups: JSON.stringify(ggs), groups: JSON.stringify(ggs),
}; };
let downloadUrl = config.httpServer + '/CmsApi/exportStatistics?'; let downloadUrl = config.httpServer + '/CmsApi/exportStatistics?';
const token = getToken() != null && getToken() != 'null' ? getToken() : '0000'; const token = getToken() != null && getToken() != 'null' ? getToken() : '0000';
...@@ -807,6 +823,8 @@ export default class StatisticsInfo extends React.Component { ...@@ -807,6 +823,8 @@ export default class StatisticsInfo extends React.Component {
> >
<Select style={{ width: '100%' }} <Select style={{ width: '100%' }}
onChange={selectConfigItem.onChange} onChange={selectConfigItem.onChange}
showSearch={true}
optionFilterProp={'children'}
value={selectConfigItem.value}> value={selectConfigItem.value}>
{selectConfigItem.options.map((r) => { {selectConfigItem.options.map((r) => {
return <Option key={r[selectConfigItem.optionKey]} return <Option key={r[selectConfigItem.optionKey]}
...@@ -853,7 +871,6 @@ export default class StatisticsInfo extends React.Component { ...@@ -853,7 +871,6 @@ export default class StatisticsInfo extends React.Component {
render() { render() {
const { form, loading, isShow } = this.props; const { form, loading, isShow } = this.props;
const { const {
querys, groups, currentKey, exportLoading, querys, groups, currentKey, exportLoading,
infos, columns, dataSource, x, y, z, infos, columns, dataSource, x, y, z,
...@@ -877,25 +894,13 @@ export default class StatisticsInfo extends React.Component { ...@@ -877,25 +894,13 @@ 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' }];
}
}
if (!isShow) { if (!isShow) {
return <span><ButtonDiy name='自定义统计' return <span><ButtonDiy name='自定义统计'
type='default' type='default'
className='defaultBlue' className='defaultBlue'
handleClick={() => this.props.setShow(true)}/></span>; handleClick={() => this.props.setShow(true)}/></span>;
} }
return ( return (
<div style={{ <div style={{
backgroundColor: '#fff', backgroundColor: '#fff',
...@@ -916,10 +921,7 @@ export default class StatisticsInfo extends React.Component { ...@@ -916,10 +921,7 @@ export default class StatisticsInfo extends React.Component {
type="warning"/> type="warning"/>
<Row> <Row>
<Col span={24}> <Col span={24}>
{ <div style={{display: showSearchItem ? 'block' : 'none'}}>
showSearchItem ?
<Fragment>
{this.selectDom(0)} {this.selectDom(0)}
{this.selectDom(1)} {this.selectDom(1)}
{this.selectDom(2)} {this.selectDom(2)}
...@@ -928,7 +930,7 @@ export default class StatisticsInfo extends React.Component { ...@@ -928,7 +930,7 @@ export default class StatisticsInfo extends React.Component {
<div style={{ textAlign: 'left', paddingLeft: '25px' }}> <div style={{ textAlign: 'left', paddingLeft: '25px' }}>
{querys.map((r, i) => {querys.map((r, i) =>
<FormItem key={r.field} <FormItem key={r.field}
labelCol={{ labelCol={{ // 查询条件
xl: nameSpan3.small, xl: nameSpan3.small,
xxl: nameSpan3.big, xxl: nameSpan3.big,
}} }}
...@@ -937,8 +939,10 @@ export default class StatisticsInfo extends React.Component { ...@@ -937,8 +939,10 @@ export default class StatisticsInfo extends React.Component {
xxl: 24 - nameSpan3.big, xxl: 24 - nameSpan3.big,
}} }}
label={r.name}> label={r.name}>
{form.getFieldDecorator(i + 'q__' + r.field, { {form.getFieldDecorator(i + 'q__' + r.field,
initialValue: { stringX: '=' }, rules: [{ {
initialValue: { stringX: '=' },
rules: [{
validator: (rule, value, callback) => { validator: (rule, value, callback) => {
var errors = []; var errors = [];
if (value == null) { if (value == null) {
...@@ -970,9 +974,8 @@ export default class StatisticsInfo extends React.Component { ...@@ -970,9 +974,8 @@ export default class StatisticsInfo extends React.Component {
</Tag>, </Tag>,
)} )}
</Row> </Row>
</Fragment> </div>
: null
}
<Row style={{ paddingTop: '20px' }}> <Row style={{ paddingTop: '20px' }}>
<Col span={24} style={{ textAlign: 'left' }}> <Col span={24} style={{ textAlign: 'left' }}>
<ButtonDiy handleClick={this.finish} <ButtonDiy handleClick={this.finish}
......
Markdown 格式
0%
您添加了 0 到此讨论。请谨慎行事。
请先完成此评论的编辑!
注册 或者 后发表评论