Commit 85c724c2 authored by baixian's avatar baixian

导出数据优化

parent 57dbae1d
...@@ -18,5 +18,5 @@ ...@@ -18,5 +18,5 @@
</head> </head>
<body> <body>
<div id="root"></div> <div id="root"></div>
<script type="text/javascript" src="https://cdn.img.shangjiadao.cn/qingxiao/biz/dist/main.3004e0.js"></script></body> <script type="text/javascript" src="https://cdn.img.shangjiadao.cn/qingxiao/biz/dist/main.8f5119.js"></script></body>
</html> </html>
\ No newline at end of file
...@@ -20,6 +20,7 @@ import * as classMgtAjax from '../services/classmgt'; ...@@ -20,6 +20,7 @@ import * as classMgtAjax from '../services/classmgt';
import * as uploader from '../services/uploader'; import * as uploader from '../services/uploader';
import { calendar } from '../utils/calendar'; import { calendar } from '../utils/calendar';
import * as commonAjax from '../services/common'; import * as commonAjax from '../services/common';
import * as memberListAjax from '../services/clockmember';
import exportExcel from '../utils/exportexcel'; import exportExcel from '../utils/exportexcel';
export default { export default {
namespace: 'createtheme', namespace: 'createtheme',
...@@ -2294,17 +2295,54 @@ export default { ...@@ -2294,17 +2295,54 @@ export default {
}, },
// 闯关学员导出 UnlockStudentExport // 闯关学员导出 UnlockStudentExport
* exportStudentExcel({ payload }, { call, put, select }) { * exportStudentExcel({ payload }, { call, put, select }) {
const { columns } = payload; const {
columns, subject_id, subject_type, checkpoint_id,
} = payload;
const { emigratedObj } = yield select(state => state.createtheme); const { emigratedObj } = yield select(state => state.createtheme);
const { sid } = yield select(state => state.webapp);
let newParams = '';
switch (subject_type) {
case 1:
newParams = {
subject_id,
subject_type,
school_id: sid,
extra: 'need_statistic',
};
break;
case 2:
newParams = {
subject_id,
subject_type,
school_id: sid,
extra: 'need_statistic',
};
break;
case 3:
newParams = {
subject_id,
subject_type,
school_id: sid,
checkpoint_id,
extra: 'need_statistic',
};
break;
default:
break;
}
const loading = message.loading('导出数据中...', 1); const loading = message.loading('导出数据中...', 1);
const data = yield call(themeAjax.UnlockStudentExport, { const data = yield call(memberListAjax.memberList, newParams);
mode_id: emigratedObj.id,
});
setTimeout(loading); setTimeout(loading);
if (data.code == 200) { if (data.code == 200) {
const list = (data.data && data.data.list) || []; const list = (data.data && data.data.list) || [];
if (list.length > 0) { if (list.length > 0) {
exportExcel(columns, list, '闯关打卡学员列表.xlsx', 'unlockStudent'); if (newParams.subject_type == 1) {
exportExcel(columns, list, '作业打卡学员列表.xlsx', 'jobClockStudent');
} else if (newParams.subject_type == 2) {
exportExcel(columns, list, '日历打卡学员列表.xlsx', 'unlockStudent');
} else if (newParams.subject_type == 3) {
exportExcel(columns, list, '闯关打卡学员列表.xlsx', 'unlockStudent');
}
} else { } else {
message.error('暂时没有数据可以导出!', 0.5); message.error('暂时没有数据可以导出!', 0.5);
} }
......
...@@ -12,7 +12,7 @@ import { ...@@ -12,7 +12,7 @@ import {
Divider, Divider,
Switch, Switch,
TimePicker, TimePicker,
Collapse, Tooltip,
DatePicker, DatePicker,
Select, Radio, InputNumber, Input, message, Table, Select, Radio, InputNumber, Input, message, Table,
} from 'antd'; } from 'antd';
...@@ -152,12 +152,15 @@ class SuccessStoreForm extends React.Component { ...@@ -152,12 +152,15 @@ class SuccessStoreForm extends React.Component {
}, },
}); });
} }
exportExcelStudent = (columns) => { exportExcelStudent = (columns, subject_id, checkpoint_id) => {
const { dispatch } = this.props; const { dispatch } = this.props;
dispatch({ dispatch({
type: 'createtheme/exportStudentExcel', type: 'createtheme/exportStudentExcel',
payload: { payload: {
columns, columns,
subject_id,
subject_type: 3,
checkpoint_id,
}, },
}); });
} }
...@@ -185,6 +188,63 @@ class SuccessStoreForm extends React.Component { ...@@ -185,6 +188,63 @@ class SuccessStoreForm extends React.Component {
previewQrcode, previewQrcode,
downloadTitle, downloadTitle,
} = this.props; } = this.props;
const exportColumns = [
{
title: '微信昵称',
dataIndex: 'wechat_user',
key: 'wechat_user',
},
{
title: '闯关数',
dataIndex: 'unlock_count',
key: 'unlock_count',
},
{
title: '被点评',
dataIndex: 'review_count',
key: 'review_count',
},
{
title: '点评分数',
dataIndex: 'review_score',
key: 'review_score',
},
{
title: '被点赞',
dataIndex: 'passive_like_count',
key: 'passive_like_count',
},
{
title: '精选数量',
dataIndex: 'place_top_at_count',
key: 'place_top_at_count',
},
{
title: '积分数',
dataIndex: 'integral_count',
key: 'integral_count',
},
{
title: '分享数',
dataIndex: 'share_count',
key: 'share_count',
},
{
title: '姓名',
dataIndex: 'name',
key: 'name',
},
{
title: '手机号',
dataIndex: 'mobile',
key: 'mobile',
},
{
title: '信息收集',
dataIndex: 'value',
key: 'value',
},
];
const columns = [ const columns = [
{ {
title: '关卡名称', title: '关卡名称',
...@@ -235,6 +295,8 @@ class SuccessStoreForm extends React.Component { ...@@ -235,6 +295,8 @@ class SuccessStoreForm extends React.Component {
render: (text, record, index) => { render: (text, record, index) => {
return ( return (
<div> <div>
<span className="hreflink" onClick={() => this.exportExcelStudent(exportColumns, emigratedObj.id, record.id)}>导出数据</span>
<Divider type="vertical" />
<span className="hreflink" onClick={() => this.edit(record)}>编辑</span> <span className="hreflink" onClick={() => this.edit(record)}>编辑</span>
<Divider type="vertical" /> <Divider type="vertical" />
<span className="hreflink" onClick={() => this.delete(record)}>删除</span> <span className="hreflink" onClick={() => this.delete(record)}>删除</span>
...@@ -243,79 +305,6 @@ class SuccessStoreForm extends React.Component { ...@@ -243,79 +305,6 @@ class SuccessStoreForm extends React.Component {
}, },
}, },
]; ];
const exportColumns = [
{
title: '微信昵称',
dataIndex: 'wechat_user',
key: 'wechat_user',
render: (text, record) => {
return (
<span>{ record.wechat_user && record.wechat_user.nickname ? record.wechat_user.nickname : '-' }</span>
);
},
},
{
title: '闯关数',
dataIndex: 'unlock_count',
key: 'unlock_count',
},
{
title: '被点评',
dataIndex: 'review_count',
key: 'review_count',
},
{
title: '点评分数',
dataIndex: 'review_score',
key: 'review_score',
},
{
title: '被点赞',
dataIndex: 'passive_like_count',
key: 'passive_like_count',
},
{
title: '精选数量',
dataIndex: 'place_top_at_count',
key: 'place_top_at_count',
},
{
title: '带来访客',
dataIndex: 'total_share_uv',
key: 'total_share_uv',
},
{
title: '姓名',
dataIndex: 'name',
key: 'name',
render: (text, record) => {
return (
<span>{ record.infoCollection && record.infoCollection.name ? record.infoCollection.name : '-' }</span>
);
},
},
{
title: '手机号',
dataIndex: 'mobile',
key: 'mobile',
render: (text, record) => {
return (
<span>{ record.infoCollection && record.infoCollection.mobile ? record.infoCollection.mobile : '-' }</span>
);
},
},
{
title: '信息收集',
dataIndex: 'value',
key: 'value',
render: (text, record) => {
return (
<span>{ record.subjectStudent && record.subjectStudent.content ? JSON.parse(record.subjectStudent.content).value : '-' }</span>
);
},
},
];
return ( return (
<div className={pageStyle.container}> <div className={pageStyle.container}>
<div className={pageStyle.head}> <div className={pageStyle.head}>
...@@ -327,7 +316,7 @@ class SuccessStoreForm extends React.Component { ...@@ -327,7 +316,7 @@ class SuccessStoreForm extends React.Component {
</div> </div>
</div> </div>
<div> <div>
<span className="hreflink" onClick={() => this.exportExcelStudent(exportColumns)}>导出数据</span> <span className="hreflink" onClick={() => this.exportExcelStudent(exportColumns, emigratedObj.id, 0)}><Tooltip title="导出全部关卡数据">导出数据</Tooltip></span>
<Divider type="vertical" /> <Divider type="vertical" />
<span className="hreflink" onClick={() => this.handleRemark(emigratedObj)}>点评作业</span> <span className="hreflink" onClick={() => this.handleRemark(emigratedObj)}>点评作业</span>
<Divider type="vertical" /> <Divider type="vertical" />
......
...@@ -251,6 +251,17 @@ class LiveClass extends React.Component { ...@@ -251,6 +251,17 @@ class LiveClass extends React.Component {
}, },
}); });
} }
exportExcelStudent = (columns, subject_id, subject_type) => {
const { dispatch } = this.props;
dispatch({
type: 'createtheme/exportStudentExcel',
payload: {
columns,
subject_id,
subject_type,
},
});
}
render() { render() {
const { const {
userPermission, userPermission,
...@@ -262,6 +273,115 @@ class LiveClass extends React.Component { ...@@ -262,6 +273,115 @@ class LiveClass extends React.Component {
downloadTitle, downloadTitle,
classList, classList,
} = this.props; } = this.props;
const exportJobColumns = [
{
title: '微信昵称',
dataIndex: 'wechat_user',
key: 'wechat_user',
},
{
title: '被点评',
dataIndex: 'review_count',
key: 'review_count',
},
{
title: '点评分数',
dataIndex: 'review_score',
key: 'review_score',
},
{
title: '被点赞',
dataIndex: 'passive_like_count',
key: 'passive_like_count',
},
{
title: '精选数量',
dataIndex: 'place_top_at_count',
key: 'place_top_at_count',
},
{
title: '积分数',
dataIndex: 'integral_count',
key: 'integral_count',
},
{
title: '分享数',
dataIndex: 'share_count',
key: 'share_count',
},
{
title: '姓名',
dataIndex: 'name',
key: 'name',
},
{
title: '手机号',
dataIndex: 'mobile',
key: 'mobile',
},
{
title: '信息收集',
dataIndex: 'value',
key: 'value',
},
];
const exportColumns = [
{
title: '微信昵称',
dataIndex: 'wechat_user',
key: 'wechat_user',
},
{
title: '打卡天数',
dataIndex: 'unlock_count',
key: 'unlock_count',
},
{
title: '被点评',
dataIndex: 'review_count',
key: 'review_count',
},
{
title: '点评分数',
dataIndex: 'review_score',
key: 'review_score',
},
{
title: '被点赞',
dataIndex: 'passive_like_count',
key: 'passive_like_count',
},
{
title: '精选数量',
dataIndex: 'place_top_at_count',
key: 'place_top_at_count',
},
{
title: '积分数',
dataIndex: 'integral_count',
key: 'integral_count',
},
{
title: '分享数',
dataIndex: 'share_count',
key: 'share_count',
},
{
title: '姓名',
dataIndex: 'name',
key: 'name',
},
{
title: '手机号',
dataIndex: 'mobile',
key: 'mobile',
},
{
title: '信息收集',
dataIndex: 'value',
key: 'value',
},
];
const columns = [ const columns = [
{ {
title: '打卡名称', title: '打卡名称',
...@@ -335,6 +455,10 @@ class LiveClass extends React.Component { ...@@ -335,6 +455,10 @@ class LiveClass extends React.Component {
<div className={pageStyle.tableoperatebox}> <div className={pageStyle.tableoperatebox}>
<span className="hreflink" onClick={() => this.editTheme(record)}>{record.subject_type == 3 ? '查看详情' : '编辑'}</span> <span className="hreflink" onClick={() => this.editTheme(record)}>{record.subject_type == 3 ? '查看详情' : '编辑'}</span>
<Divider type="vertical" /> <Divider type="vertical" />
{
record.subject_type != 3 &&
<span className="hreflink" onClick={() => this.exportExcelStudent(record.subject_type == 1 ? exportJobColumns : exportColumns, record.id, record.subject_type)}>导出数据<Divider type="vertical" /></span>
}
{ {
record.subject_type != 3 && record.subject_type != 3 &&
<span className="hreflink" onClick={() => this.copyClockMgt(record, 1)}>复制<Divider type="vertical" /></span> <span className="hreflink" onClick={() => this.copyClockMgt(record, 1)}>复制<Divider type="vertical" /></span>
......
...@@ -40,16 +40,34 @@ function exportExcel(headers, data, fileName = 'XXX.xlsx', type) { ...@@ -40,16 +40,34 @@ function exportExcel(headers, data, fileName = 'XXX.xlsx', type) {
// eslint-disable-next-line array-callback-return // eslint-disable-next-line array-callback-return
thisdata = data.map((item) => { thisdata = data.map((item) => {
return { return {
wechat_user: item.wechat_user && item.wechat_user.nickname ? item.wechat_user.nickname : '', wechat_user: item.school_student && item.school_student.nickname ? item.school_student.nickname : '',
unlock_count: item.unlock_count ? item.unlock_count : '-', unlock_count: item.max_clock_count ? item.max_clock_count : '-',
review_count: item.review_count, review_count: item.review_count,
review_score: Number(item.review_score) / 5, review_score: Number(item.review_score) / 5,
passive_like_count: item.passive_like_count, passive_like_count: item.like_count,
place_top_at_count: item.place_top_at_count, place_top_at_count: item.place_top_at_count,
total_share_uv: item.total_share_uv, integral_count: item.integral_count,
name: item.subjectStudent && item.subjectStudent.name ? item.subjectStudent.name : '', share_count: item.share_count,
mobile: item.subjectStudent && item.subjectStudent.mobile ? item.subjectStudent.mobile : '', name: item.name ? item.name : '',
value: item.subjectStudent && item.subjectStudent.content ? JSON.parse(item.subjectStudent.content).value : '', mobile: item.mobile ? item.mobile : '',
value: item.content && item.content ? JSON.parse(item.content).value : '',
};
});
break;
case 'jobClockStudent':
// eslint-disable-next-line array-callback-return
thisdata = data.map((item) => {
return {
wechat_user: item.school_student && item.school_student.nickname ? item.school_student.nickname : '',
review_count: item.review_count,
review_score: Number(item.review_score) / 5,
passive_like_count: item.like_count,
place_top_at_count: item.place_top_at_count,
integral_count: item.integral_count,
share_count: item.share_count,
name: item.name ? item.name : '',
mobile: item.mobile ? item.mobile : '',
value: item.content && item.content ? JSON.parse(item.content).value : '',
}; };
}); });
break; break;
......
...@@ -25,7 +25,7 @@ axios.interceptors.request.use((config) => { ...@@ -25,7 +25,7 @@ axios.interceptors.request.use((config) => {
return Promise.reject(error); return Promise.reject(error);
}); });
// axios.defaults.timeout = 30000; // axios.defaults.timeout = 30000;
axios.defaults.timeout = 30000; axios.defaults.timeout = 1000 * 60 * 2;
axios.defaults.retry = 1; axios.defaults.retry = 1;
axios.defaults.retryDelay = 3000; axios.defaults.retryDelay = 3000;
// Add a response interceptor // Add a response interceptor
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment