Commit 85c724c2 authored by baixian's avatar baixian

导出数据优化

parent 57dbae1d
......@@ -18,5 +18,5 @@
</head>
<body>
<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>
\ No newline at end of file
......@@ -20,6 +20,7 @@ import * as classMgtAjax from '../services/classmgt';
import * as uploader from '../services/uploader';
import { calendar } from '../utils/calendar';
import * as commonAjax from '../services/common';
import * as memberListAjax from '../services/clockmember';
import exportExcel from '../utils/exportexcel';
export default {
namespace: 'createtheme',
......@@ -2294,17 +2295,54 @@ export default {
},
// 闯关学员导出 UnlockStudentExport
* 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 { 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 data = yield call(themeAjax.UnlockStudentExport, {
mode_id: emigratedObj.id,
});
const data = yield call(memberListAjax.memberList, newParams);
setTimeout(loading);
if (data.code == 200) {
const list = (data.data && data.data.list) || [];
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 {
message.error('暂时没有数据可以导出!', 0.5);
}
......
......@@ -12,7 +12,7 @@ import {
Divider,
Switch,
TimePicker,
Collapse,
Tooltip,
DatePicker,
Select, Radio, InputNumber, Input, message, Table,
} from 'antd';
......@@ -152,12 +152,15 @@ class SuccessStoreForm extends React.Component {
},
});
}
exportExcelStudent = (columns) => {
exportExcelStudent = (columns, subject_id, checkpoint_id) => {
const { dispatch } = this.props;
dispatch({
type: 'createtheme/exportStudentExcel',
payload: {
columns,
subject_id,
subject_type: 3,
checkpoint_id,
},
});
}
......@@ -185,6 +188,63 @@ class SuccessStoreForm extends React.Component {
previewQrcode,
downloadTitle,
} = 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 = [
{
title: '关卡名称',
......@@ -235,6 +295,8 @@ class SuccessStoreForm extends React.Component {
render: (text, record, index) => {
return (
<div>
<span className="hreflink" onClick={() => this.exportExcelStudent(exportColumns, emigratedObj.id, record.id)}>导出数据</span>
<Divider type="vertical" />
<span className="hreflink" onClick={() => this.edit(record)}>编辑</span>
<Divider type="vertical" />
<span className="hreflink" onClick={() => this.delete(record)}>删除</span>
......@@ -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 (
<div className={pageStyle.container}>
<div className={pageStyle.head}>
......@@ -327,7 +316,7 @@ class SuccessStoreForm extends React.Component {
</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" />
<span className="hreflink" onClick={() => this.handleRemark(emigratedObj)}>点评作业</span>
<Divider type="vertical" />
......
......@@ -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() {
const {
userPermission,
......@@ -262,6 +273,115 @@ class LiveClass extends React.Component {
downloadTitle,
classList,
} = 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 = [
{
title: '打卡名称',
......@@ -335,6 +455,10 @@ class LiveClass extends React.Component {
<div className={pageStyle.tableoperatebox}>
<span className="hreflink" onClick={() => this.editTheme(record)}>{record.subject_type == 3 ? '查看详情' : '编辑'}</span>
<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 &&
<span className="hreflink" onClick={() => this.copyClockMgt(record, 1)}>复制<Divider type="vertical" /></span>
......
......@@ -40,16 +40,34 @@ function exportExcel(headers, data, fileName = 'XXX.xlsx', type) {
// eslint-disable-next-line array-callback-return
thisdata = data.map((item) => {
return {
wechat_user: item.wechat_user && item.wechat_user.nickname ? item.wechat_user.nickname : '',
unlock_count: item.unlock_count ? item.unlock_count : '-',
wechat_user: item.school_student && item.school_student.nickname ? item.school_student.nickname : '',
unlock_count: item.max_clock_count ? item.max_clock_count : '-',
review_count: item.review_count,
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,
total_share_uv: item.total_share_uv,
name: item.subjectStudent && item.subjectStudent.name ? item.subjectStudent.name : '',
mobile: item.subjectStudent && item.subjectStudent.mobile ? item.subjectStudent.mobile : '',
value: item.subjectStudent && item.subjectStudent.content ? JSON.parse(item.subjectStudent.content).value : '',
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;
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;
......
......@@ -25,7 +25,7 @@ axios.interceptors.request.use((config) => {
return Promise.reject(error);
});
// axios.defaults.timeout = 30000;
axios.defaults.timeout = 30000;
axios.defaults.timeout = 1000 * 60 * 2;
axios.defaults.retry = 1;
axios.defaults.retryDelay = 3000;
// 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