Commit 4de4930c by zhangleyuan

Merge branch 'master' into feature/zhangleyuan/20210619/yongzong-optimize

parents dbbb5ea8 c380d5ba
...@@ -6,67 +6,67 @@ ...@@ -6,67 +6,67 @@
* @Description: 大班直播分享弹窗 * @Description: 大班直播分享弹窗
*/ */
import React from 'react' import React from 'react';
import { Modal, Button, message } from 'antd' import { Modal, Button, message } from 'antd';
import domtoimage from 'dom-to-image' import domtoimage from 'dom-to-image';
import qrcode from '@/libs/qrcode/qrcode.js' import qrcode from '@/libs/qrcode/qrcode.js';
import User from '@/common/js/user' import User from '@/common/js/user';
import $ from 'jquery' import $ from 'jquery';
import _ from 'underscore' import _ from 'underscore';
import CourseService from '@/domains/course-domain/CourseService' import CourseService from '@/domains/course-domain/CourseService';
import './ShareLiveModal.less' import './ShareLiveModal.less';
class ShareLiveModal extends React.Component { class ShareLiveModal extends React.Component {
constructor(props) { constructor(props) {
super(props) super(props);
this.state = { this.state = {
shareUrl: 'https://xiaomai5.com/liveShare?courseId=12', shareUrl: 'https://xiaomai5.com/liveShare?courseId=12',
} };
} }
componentDidMount() { componentDidMount() {
// 获取短链接 // 获取短链接
this.handleConvertShortUrl() this.handleConvertShortUrl();
} }
handleConvertShortUrl = () => { handleConvertShortUrl = () => {
const { longUrl } = this.props.data const { longUrl } = this.props.data;
// 发请求 // 发请求
CourseService.getQrcode({ CourseService.getQrcode({
urls: [longUrl], urls: [longUrl],
}).then((res) => { }).then((res) => {
const { result = [] } = res const { result = [] } = res;
this.setState( this.setState(
{ {
shareUrl: result[0].shortUrl, shareUrl: result[0].shortUrl,
}, },
() => { () => {
const qrcodeWrapDom = document.querySelector('#qrcodeWrap') const qrcodeWrapDom = document.querySelector('#qrcodeWrap');
const qrcodeNode = new qrcode({ const qrcodeNode = new qrcode({
text: this.state.shareUrl, text: this.state.shareUrl,
size: 98, size: 98,
}) });
qrcodeWrapDom.appendChild(qrcodeNode) qrcodeWrapDom.appendChild(qrcodeNode);
const qrcodeWrapDomDownload = document.querySelector('#qrcodeWrap-dowload') const qrcodeWrapDomDownload = document.querySelector('#qrcodeWrap-dowload');
const qrcodeNodeDownLoad = new qrcode({ const qrcodeNodeDownLoad = new qrcode({
text: this.state.shareUrl, text: this.state.shareUrl,
size: 196, size: 196,
}) });
qrcodeWrapDomDownload.appendChild(qrcodeNodeDownLoad) qrcodeWrapDomDownload.appendChild(qrcodeNodeDownLoad);
}
)
})
} }
);
});
};
componentWillUnmount() { componentWillUnmount() {
// 页面销毁之前清空定时器 // 页面销毁之前清空定时器
clearTimeout(this.timer) clearTimeout(this.timer);
} }
// 下载海报 // 下载海报
...@@ -79,31 +79,31 @@ class ShareLiveModal extends React.Component { ...@@ -79,31 +79,31 @@ class ShareLiveModal extends React.Component {
() => { () => {
this.setState({ time: new Date().valueOf() }, () => { this.setState({ time: new Date().valueOf() }, () => {
setTimeout(() => { setTimeout(() => {
let node = document.getElementById('poster-dowload') let node = document.getElementById('poster-dowload');
domtoimage.toPng(node).then((imgData) => { domtoimage.toPng(node).then((imgData) => {
console.log(imgData) console.log(imgData);
const download = document.createElement('a') const download = document.createElement('a');
const { courseName } = this.props.data const { courseName } = this.props.data;
$(download).attr('href', imgData).attr('download', `${courseName}.png`).get(0).click() $(download).attr('href', imgData).attr('download', `${courseName}.png`).get(0).click();
}) });
}, 1000) }, 1000);
}) });
}
)
} }
);
};
// 复制分享链接 // 复制分享链接
handleCopy = () => { handleCopy = () => {
const textContent = document.getElementById('shareUrl').innerText const textContent = document.getElementById('shareUrl').innerText;
window.copyText(textContent) window.copyText(textContent);
message.success('复制成功!') message.success('复制成功!');
} };
render() { render() {
const { courseDivision, data, type, title } = this.props const { courseDivision, data, type, title } = this.props;
const { courseName, scheduleVideoUrl, courseMediaVOS, coverUrl } = data const { courseName, scheduleVideoUrl, courseMediaVOS, coverUrl } = data;
const { shareUrl, showImg, time } = this.state const { shareUrl, showImg, time } = this.state;
// 判断是否是默认图, 默认图不需要在URL后面增加字符串 // 判断是否是默认图, 默认图不需要在URL后面增加字符串
let coverImgSrc = ''; let coverImgSrc = '';
switch (type) { switch (type) {
...@@ -111,15 +111,21 @@ class ShareLiveModal extends React.Component { ...@@ -111,15 +111,21 @@ class ShareLiveModal extends React.Component {
if (courseMediaVOS && courseMediaVOS.length > 0) { if (courseMediaVOS && courseMediaVOS.length > 0) {
data.courseMediaVOS.map((item, index) => { data.courseMediaVOS.map((item, index) => {
if (item.contentType === 'COVER') { if (item.contentType === 'COVER') {
coverImgSrc = item.mediaUrl coverImgSrc = item.mediaUrl;
} else {
coverImgSrc = 'https://image.xiaomaiketang.com/xm/Yip2YtFDwH.png';
} }
}) });
} else { } else {
coverImgSrc = 'https://image.xiaomaiketang.com/xm/Yip2YtFDwH.png'; coverImgSrc = 'https://image.xiaomaiketang.com/xm/Yip2YtFDwH.png';
} }
break; break;
case 'videoClass': // 视频课 case 'videoClass': // 视频课
coverImgSrc = coverUrl || (courseDivision === 'internal' ? `${scheduleVideoUrl}?x-oss-process=video/snapshot,t_0,m_fast&anystring=anystring` : 'https://image.xiaomaiketang.com/xm/mt3ZQRxGKB.png') coverImgSrc =
coverUrl ||
(courseDivision === 'internal'
? `${scheduleVideoUrl}?x-oss-process=video/snapshot,t_0,m_fast&anystring=anystring`
: 'https://image.xiaomaiketang.com/xm/mt3ZQRxGKB.png');
break; break;
case 'graphicsClass': // 图文课 case 'graphicsClass': // 图文课
coverImgSrc = coverUrl || 'https://image.xiaomaiketang.com/xm/wFnpZtp2yB.png'; coverImgSrc = coverUrl || 'https://image.xiaomaiketang.com/xm/wFnpZtp2yB.png';
...@@ -214,8 +220,8 @@ class ShareLiveModal extends React.Component { ...@@ -214,8 +220,8 @@ class ShareLiveModal extends React.Component {
</div> </div>
</div> </div>
</Modal> </Modal>
) );
} }
} }
export default ShareLiveModal export default ShareLiveModal;
import React from 'react'; import React from 'react';
import { withRouter } from "react-router-dom"; import { withRouter } from 'react-router-dom';
import {Table, Modal,Input,message} from 'antd'; import { Input } from 'antd';
import { PageControl } from "@/components"; import { PageControl, XMTable } from '@/components';
import PlanService from '@/domains/plan-domain/planService' import college from '@/common/lottie/college';
import PlanService from '@/domains/plan-domain/planService';
import User from '@/common/js/user'; import User from '@/common/js/user';
import Bus from '@/core/bus'; import Bus from '@/core/bus';
import './EmployeeShareData.less'; import './EmployeeShareData.less';
...@@ -10,103 +11,129 @@ import './EmployeeShareData.less'; ...@@ -10,103 +11,129 @@ import './EmployeeShareData.less';
const { Search } = Input; const { Search } = Input;
const UserRole = { const UserRole = {
Store_Manager: { Store_Manager: {
text: "学院管理员" text: '学院管理员',
}, },
Cloud_Manager: { Cloud_Manager: {
text:"管理员" text: '管理员',
}, },
Cloud_Operator: { Cloud_Operator: {
text:'运营师' text: '运营师',
}, },
Cloud_Lecture: { Cloud_Lecture: {
text:"讲师" text: '讲师',
}, },
}; };
class EmployeeShareData extends React.Component { class EmployeeShareData extends React.Component {
constructor(props) { constructor(props) {
super(props); super(props);
const id = getParameterByName("id"); const id = getParameterByName('id');
this.state = { this.state = {
id, id,
dataSource:[], dataSource: [],
size:10, size: 10,
query: { query: {
current: 1, current: 1,
}, },
totalCount:0, totalCount: 0,
} };
} }
componentDidMount(){ componentDidMount() {
this.handleFetchDataList(); this.handleFetchDataList();
} }
handleFetchDataList = ()=>{ handleFetchDataList = () => {
const { query ,size,id} = this.state; const { query, size, id } = this.state;
const params ={ const params = {
...query, ...query,
size, size,
planId:id, planId: id,
storeId:User.getStoreId(), storeId: User.getStoreId(),
} };
PlanService.getPlanUserRecordPage(params).then((res) => { PlanService.getPlanUserRecordPage(params).then((res) => {
const { result = {} } = res ; const { result = {} } = res;
const { records = [], total = 0 } = result; const { records = [], total = 0 } = result;
this.setState({ this.setState({
dataSource: records, dataSource: records,
totalCount: Number(total) totalCount: Number(total),
}); });
}); });
} };
onShowSizeChange = (current, size) => { onShowSizeChange = (current, size) => {
if (current == size) { if (current == size) {
return return;
} }
this.setState({ this.setState(
size {
},()=>{this.handleFetchDataList()}) size,
},
() => {
this.handleFetchDataList();
} }
handleChangeTable = (pagination, filters, sorter)=> { );
};
handleChangeTable = (pagination, filters, sorter) => {
const { columnKey, order } = sorter; const { columnKey, order } = sorter;
const { query } = this.state; const { query } = this.state;
let _columnKey; let _columnKey;
let _order; let _order;
if (columnKey === 'learnNum' && order === 'ascend') { _columnKey="LEARN_NUM"; _order = 'SORT_ASC'; } if (columnKey === 'learnNum' && order === 'ascend') {
if (columnKey === 'learnNum' && order === 'descend') { _columnKey="LEARN_NUM"; _order = 'SORT_DESC'; } _columnKey = 'LEARN_NUM';
_order = 'SORT_ASC';
}
if (columnKey === 'learnNum' && order === 'descend') {
_columnKey = 'LEARN_NUM';
_order = 'SORT_DESC';
}
if (columnKey === 'learnFinishNum' && order === 'ascend') { _columnKey="FINISH_NUM"; _order = 'SORT_ASC'; } if (columnKey === 'learnFinishNum' && order === 'ascend') {
if (columnKey === 'learnFinishNum' && order === 'descend') { _columnKey="FINISH_NUM"; _order = 'SORT_DESC'; } _columnKey = 'FINISH_NUM';
_order = 'SORT_ASC';
}
if (columnKey === 'learnFinishNum' && order === 'descend') {
_columnKey = 'FINISH_NUM';
_order = 'SORT_DESC';
}
if (columnKey === 'learnNoFinishNum' && order === 'ascend') { _columnKey="NOT_NUM"; _order = 'SORT_ASC'; } if (columnKey === 'learnNoFinishNum' && order === 'ascend') {
if (columnKey === 'learnNoFinishNum' && order === 'descend') { _columnKey="NOT_NUM"; _order = 'SORT_DESC'; } _columnKey = 'NOT_NUM';
_order = 'SORT_ASC';
}
if (columnKey === 'learnNoFinishNum' && order === 'descend') {
_columnKey = 'NOT_NUM';
_order = 'SORT_DESC';
}
const _query = { const _query = {
...query, ...query,
sortMap:{} sortMap: {},
}; };
_query.sortMap[_columnKey]=_order; _query.sortMap[_columnKey] = _order;
this.setState({ this.setState(
query:_query {
},()=>this.handleFetchDataList()) query: _query,
} },
handleChangNickname = (value)=>{ () => this.handleFetchDataList()
);
};
handleChangNickname = (value) => {
const isPhone = (value || '').match(/^\d+$/); const isPhone = (value || '').match(/^\d+$/);
const { query } = this.state; const { query } = this.state;
if(isPhone){ if (isPhone) {
query.userPhone = value; query.userPhone = value;
query.userName = null; query.userName = null;
}else{ } else {
query.userName = value; query.userName = value;
query.userPhone = null; query.userPhone = null;
} }
query.current = 1; query.current = 1;
this.setState({ this.setState({
query query,
}) });
} };
watchDataView = (record)=>{ watchDataView = (record) => {
Bus.trigger('watchDataView',record); Bus.trigger('watchDataView', record);
} };
// 请求表头 // 请求表头
parselumns = () => { parselumns = () => {
const columns = [ const columns = [
...@@ -115,24 +142,16 @@ class EmployeeShareData extends React.Component { ...@@ -115,24 +142,16 @@ class EmployeeShareData extends React.Component {
key: 'storeUserName', key: 'storeUserName',
dataIndex: 'storeUserName', dataIndex: 'storeUserName',
render: (val, record) => { render: (val, record) => {
return ( return <div>{val}</div>;
<div> },
{val}
</div>
)
}
}, },
{ {
title: '角色', title: '角色',
key: 'roleEnum', key: 'roleEnum',
dataIndex: 'roleEnum', dataIndex: 'roleEnum',
render: (val, record) => { render: (val, record) => {
return ( return <div>{UserRole[record.roleEnum].text}</div>;
<div> },
{UserRole[record.roleEnum].text}
</div>
)
}
}, },
//产品暂时性隐藏 //产品暂时性隐藏
// { // {
...@@ -151,28 +170,20 @@ class EmployeeShareData extends React.Component { ...@@ -151,28 +170,20 @@ class EmployeeShareData extends React.Component {
title: '最近分享成功时间', title: '最近分享成功时间',
key: 'recentlyForwardTime', key: 'recentlyForwardTime',
dataIndex: 'recentlyForwardTime', dataIndex: 'recentlyForwardTime',
width:240, width: 240,
render: (val, record) => { render: (val, record) => {
return ( return <div>{formatDate('YYYY-MM-DD H:i', val)}</div>;
<div> },
{formatDate('YYYY-MM-DD H:i', val)}
</div>
)
}
}, },
{ {
title: '学习人数', title: '学习人数',
key: 'learnNum', key: 'learnNum',
dataIndex: 'learnNum', dataIndex: 'learnNum',
width:110, width: 110,
sorter:true, sorter: true,
render: (val, record) => { render: (val, record) => {
return ( return <div className='learn-num'>{val}</div>;
<div className="learn-num"> },
{val}
</div>
)
}
}, },
// { // {
// title: '已学完', // title: '已学完',
...@@ -208,24 +219,39 @@ class EmployeeShareData extends React.Component { ...@@ -208,24 +219,39 @@ class EmployeeShareData extends React.Component {
dataIndex: 'operate', dataIndex: 'operate',
render: (val, record) => { render: (val, record) => {
return ( return (
<span className="operate-item" onClick={()=>this.watchDataView(record)}>数据详情</span> <span className='operate-item' onClick={() => this.watchDataView(record)}>
) 数据详情
} </span>
} );
},
},
]; ];
return columns; return columns;
} };
render() { render() {
const { dataSource,query,size,totalCount} = this.state; const { dataSource, query, size, totalCount } = this.state;
return ( return (
<div className="employee-share-data"> <div className='employee-share-data'>
<div className="search-container"> <div className='search-container'>
<Search placeholder="搜索员工姓名或手机号" onChange={(e) => { this.handleChangNickname(e.target.value)}} onSearch={ () => { this.handleFetchDataList()}} style={{ width: 200 }} enterButton={<span className="icon iconfont">&#xe832;</span>}/> <Search
placeholder='搜索员工姓名或手机号'
onChange={(e) => {
this.handleChangNickname(e.target.value);
}}
onSearch={() => {
this.handleFetchDataList();
}}
style={{ width: 200 }}
enterButton={<span className='icon iconfont'>&#xe832;</span>}
/>
</div> </div>
<div> <div>
<Table <XMTable
rowKey={record => record.id} renderEmpty={{
image: college,
description: '暂无数据',
}}
rowKey={(record) => record.id}
dataSource={dataSource} dataSource={dataSource}
columns={this.parselumns()} columns={this.parselumns()}
pagination={false} pagination={false}
...@@ -233,25 +259,30 @@ class EmployeeShareData extends React.Component { ...@@ -233,25 +259,30 @@ class EmployeeShareData extends React.Component {
showSorterTooltip={false} showSorterTooltip={false}
bordered bordered
/> />
{dataSource.length >0 && {dataSource.length > 0 && (
<div className="box-footer"> <div className='box-footer'>
<PageControl <PageControl
current={query.current - 1} current={query.current - 1}
pageSize={size} pageSize={size}
total={totalCount} total={totalCount}
toPage={(page) => { toPage={(page) => {
const _query = {...query, current: page + 1}; const _query = { ...query, current: page + 1 };
this.setState({ this.setState(
query:_query {
},()=>{ this.handleFetchDataList()}) query: _query,
},
() => {
this.handleFetchDataList();
}
);
}} }}
onShowSizeChange={this.onShowSizeChange} onShowSizeChange={this.onShowSizeChange}
/> />
</div> </div>
} )}
</div> </div>
</div> </div>
) );
} }
} }
......
import React from 'react' import React from 'react';
import { withRouter } from 'react-router-dom' import { withRouter } from 'react-router-dom';
import { Table, Modal, message, Tooltip } from 'antd' import { Modal, message, Tooltip } from 'antd';
import { PageControl } from '@/components' import { PageControl, XMTable } from '@/components';
import UserLearningDataFilter from './UserLearningDataFilter' import college from '@/common/lottie/college';
import PlanService from '@/domains/plan-domain/planService' import UserLearningDataFilter from './UserLearningDataFilter';
import UserLearnDetailModal from '../modal/UserLearnDetailModal' import PlanService from '@/domains/plan-domain/planService';
import UnbundEmployeeModal from '../modal/UnbundEmployeeModal' import UserLearnDetailModal from '../modal/UserLearnDetailModal';
import User from '@/common/js/user' import UnbundEmployeeModal from '../modal/UnbundEmployeeModal';
import './UserLearningData.less' import User from '@/common/js/user';
const { confirm } = Modal import './UserLearningData.less';
const { confirm } = Modal;
const LearnState = { const LearnState = {
UN_PLAY: { UN_PLAY: {
text: '未开始', text: '未开始',
...@@ -19,12 +20,12 @@ const LearnState = { ...@@ -19,12 +20,12 @@ const LearnState = {
FINISH: { FINISH: {
text: '已完成', text: '已完成',
}, },
} };
class UserLearningData extends React.Component { class UserLearningData extends React.Component {
constructor(props) { constructor(props) {
super(props) super(props);
const id = getParameterByName('id') const id = getParameterByName('id');
this.state = { this.state = {
id, id,
dataSource: [], dataSource: [],
...@@ -35,13 +36,13 @@ class UserLearningData extends React.Component { ...@@ -35,13 +36,13 @@ class UserLearningData extends React.Component {
totalCount: 0, totalCount: 0,
userLearnDetailModalSHow: false, userLearnDetailModalSHow: false,
unbundEmployeeModalVisible: false, unbundEmployeeModalVisible: false,
} };
} }
componentDidMount() { componentDidMount() {
this.handleFetchDataList() this.handleFetchDataList();
} }
handleFetchDataList = (_query) => { handleFetchDataList = (_query) => {
const { query, size, id } = this.state const { query, size, id } = this.state;
const params = { const params = {
...query, ...query,
..._query, ..._query,
...@@ -49,88 +50,88 @@ class UserLearningData extends React.Component { ...@@ -49,88 +50,88 @@ class UserLearningData extends React.Component {
planId: id, planId: id,
storeId: User.getStoreId(), storeId: User.getStoreId(),
storeUserId: User.getStoreUserId(), storeUserId: User.getStoreUserId(),
} };
this.setState({ query: params }) this.setState({ query: params });
PlanService.getPlanCustomerRecordPage(params).then((res) => { PlanService.getPlanCustomerRecordPage(params).then((res) => {
const { result = {} } = res const { result = {} } = res;
const { records = [], total = 0 } = result const { records = [], total = 0 } = result;
this.setState({ this.setState({
dataSource: records, dataSource: records,
totalCount: Number(total), totalCount: Number(total),
}) });
}) });
} };
onShowSizeChange = (current, size) => { onShowSizeChange = (current, size) => {
if (current == size) { if (current == size) {
return return;
} }
this.setState( this.setState(
{ {
size, size,
}, },
() => { () => {
this.handleFetchDataList() this.handleFetchDataList();
}
)
} }
);
};
handleChangeTable = (pagination, filters, sorter) => { handleChangeTable = (pagination, filters, sorter) => {
const { columnKey, order } = sorter const { columnKey, order } = sorter;
const { query } = this.state const { query } = this.state;
let _columnKey let _columnKey;
let _order let _order;
if (columnKey === 'latelyLearnTime' && order === 'ascend') { if (columnKey === 'latelyLearnTime' && order === 'ascend') {
_columnKey = 'LATE_LEARN_TIME' _columnKey = 'LATE_LEARN_TIME';
_order = 'SORT_ASC' _order = 'SORT_ASC';
} }
if (columnKey === 'latelyLearnTime' && order === 'descend') { if (columnKey === 'latelyLearnTime' && order === 'descend') {
_columnKey = 'LATE_LEARN_TIME' _columnKey = 'LATE_LEARN_TIME';
_order = 'SORT_DESC' _order = 'SORT_DESC';
} }
if (columnKey === 'startLearnTime' && order === 'ascend') { if (columnKey === 'startLearnTime' && order === 'ascend') {
_columnKey = 'START_LEARN_TIME' _columnKey = 'START_LEARN_TIME';
_order = 'SORT_ASC' _order = 'SORT_ASC';
} }
if (columnKey === 'startLearnTime' && order === 'descend') { if (columnKey === 'startLearnTime' && order === 'descend') {
_columnKey = 'START_LEARN_TIME' _columnKey = 'START_LEARN_TIME';
_order = 'SORT_DESC' _order = 'SORT_DESC';
} }
if (columnKey === 'learnNum' && order === 'ascend') { if (columnKey === 'learnNum' && order === 'ascend') {
_columnKey = 'LEARN_NUM' _columnKey = 'LEARN_NUM';
_order = 'SORT_ASC' _order = 'SORT_ASC';
} }
if (columnKey === 'learnNum' && order === 'descend') { if (columnKey === 'learnNum' && order === 'descend') {
_columnKey = 'LEARN_NUM' _columnKey = 'LEARN_NUM';
_order = 'SORT_DESC' _order = 'SORT_DESC';
} }
const _query = { const _query = {
...query, ...query,
sortMap: {}, sortMap: {},
} };
_query.sortMap[_columnKey] = _order _query.sortMap[_columnKey] = _order;
this.setState( this.setState(
{ {
query: _query, query: _query,
}, },
() => this.handleFetchDataList() () => this.handleFetchDataList()
) );
} };
watchDetail = (record) => { watchDetail = (record) => {
this.setState({ this.setState({
userLearnDetailModalSHow: true, userLearnDetailModalSHow: true,
storeCustomerId: record.storeCustomerId, storeCustomerId: record.storeCustomerId,
planId: record.planId, planId: record.planId,
}) });
} };
closeUserLearnDetailModal = () => { closeUserLearnDetailModal = () => {
this.setState({ this.setState({
userLearnDetailModalSHow: false, userLearnDetailModalSHow: false,
}) });
} };
UnbundEmployee = (record) => { UnbundEmployee = (record) => {
if (User.getUserRole() === 'CloudOperator') { if (User.getUserRole() === 'CloudOperator') {
return confirm({ return confirm({
...@@ -141,40 +142,40 @@ class UserLearningData extends React.Component { ...@@ -141,40 +142,40 @@ class UserLearningData extends React.Component {
okType: 'danger', okType: 'danger',
cancelText: '取消', cancelText: '取消',
onOk: () => { onOk: () => {
this.handleConfirmUnbundEmployee(record.storeCustomerId) this.handleConfirmUnbundEmployee(record.storeCustomerId);
}, },
}) });
} else { } else {
this.setState({ this.setState({
unbundEmployeeModalVisible: true, unbundEmployeeModalVisible: true,
storeCustomerId: record.storeCustomerId, storeCustomerId: record.storeCustomerId,
}) });
}
} }
};
handleConfirmUnbundEmployee = (storeCustomerId) => { handleConfirmUnbundEmployee = (storeCustomerId) => {
let removeUserIds = [] let removeUserIds = [];
removeUserIds.push(storeCustomerId) removeUserIds.push(storeCustomerId);
const params = { const params = {
planId: getParameterByName('id'), planId: getParameterByName('id'),
removeUserIds, removeUserIds,
storeCustomerId: storeCustomerId, storeCustomerId: storeCustomerId,
storeId: User.getStoreId(), storeId: User.getStoreId(),
storeUserId: User.getStoreUserId(), storeUserId: User.getStoreUserId(),
} };
PlanService.removePlanCustomer(params).then((res) => { PlanService.removePlanCustomer(params).then((res) => {
this.handleFetchDataList() this.handleFetchDataList();
message.success('解绑成功') message.success('解绑成功');
}) });
} };
handleCloseUnbundEmployeeModal = () => { handleCloseUnbundEmployeeModal = () => {
this.setState({ this.setState({
unbundEmployeeModalVisible: false, unbundEmployeeModalVisible: false,
}) });
} };
// 请求表头 // 请求表头
parselumns = () => { parselumns = () => {
let columns let columns;
if (User.getUserRole() === 'CloudManager' || User.getUserRole() === 'StoreManager') { if (User.getUserRole() === 'CloudManager' || User.getUserRole() === 'StoreManager') {
columns = [ columns = [
{ {
...@@ -182,7 +183,7 @@ class UserLearningData extends React.Component { ...@@ -182,7 +183,7 @@ class UserLearningData extends React.Component {
key: 'storeCustomerName', key: 'storeCustomerName',
dataIndex: 'storeCustomerName', dataIndex: 'storeCustomerName',
render: (val, record) => { render: (val, record) => {
return <div>{val}</div> return <div>{val}</div>;
}, },
}, },
{ {
...@@ -190,14 +191,20 @@ class UserLearningData extends React.Component { ...@@ -190,14 +191,20 @@ class UserLearningData extends React.Component {
key: 'learnState', key: 'learnState',
dataIndex: 'learnState', dataIndex: 'learnState',
render: (val, record) => { render: (val, record) => {
return <div>{LearnState[val].text}</div> return <div>{LearnState[val].text}</div>;
}, },
}, },
{ {
title: <span> title: (
<span>
<span>负责人</span> <span>负责人</span>
<Tooltip title="培训计划的分享者/跟进人"><i className="icon iconfont" style={{ marginLeft: '5px',cursor:'pointer',color:'#bfbfbf',fontSize:'14px',fontWeight:"400"}}>&#xe61d;</i></Tooltip> <Tooltip title='培训计划的分享者/跟进人'>
</span>, <i className='icon iconfont' style={{ marginLeft: '5px', cursor: 'pointer', color: '#bfbfbf', fontSize: '14px', fontWeight: '400' }}>
&#xe61d;
</i>
</Tooltip>
</span>
),
key: 'userNameList', key: 'userNameList',
dataIndex: 'userNameList', dataIndex: 'userNameList',
render: (val, record) => { render: (val, record) => {
...@@ -208,10 +215,10 @@ class UserLearningData extends React.Component { ...@@ -208,10 +215,10 @@ class UserLearningData extends React.Component {
<span> <span>
{item} {index < record.userNameList.length - 1 && <span></span>}{' '} {item} {index < record.userNameList.length - 1 && <span></span>}{' '}
</span> </span>
) );
})} })}
</div> </div>
) );
}, },
}, },
{ {
...@@ -221,7 +228,7 @@ class UserLearningData extends React.Component { ...@@ -221,7 +228,7 @@ class UserLearningData extends React.Component {
sorter: true, sorter: true,
width: 240, width: 240,
render: (val, record) => { render: (val, record) => {
return `${formatDate('YYYY-MM-DD H:i', parseInt(record.latelyLearnTime))}` return `${formatDate('YYYY-MM-DD H:i', parseInt(record.latelyLearnTime))}`;
}, },
}, },
{ {
...@@ -231,14 +238,20 @@ class UserLearningData extends React.Component { ...@@ -231,14 +238,20 @@ class UserLearningData extends React.Component {
width: 240, width: 240,
sorter: true, sorter: true,
render: (val, record) => { render: (val, record) => {
return <div>{formatDate('YYYY-MM-DD H:i', val)}</div> return <div>{formatDate('YYYY-MM-DD H:i', val)}</div>;
}, },
}, },
{ {
title: <span> title: (
<span>
<span>学习进度</span> <span>学习进度</span>
<Tooltip title="学员培训计划中达到“已完成”状态的课程数/总课程数"><i className="icon iconfont" style={{ marginLeft: '5px',cursor:'pointer',color:'#bfbfbf',fontSize:'14px', fontWeight:"400"}}>&#xe61d;</i></Tooltip> <Tooltip title='学员培训计划中达到“已完成”状态的课程数/总课程数'>
</span>, <i className='icon iconfont' style={{ marginLeft: '5px', cursor: 'pointer', color: '#bfbfbf', fontSize: '14px', fontWeight: '400' }}>
&#xe61d;
</i>
</Tooltip>
</span>
),
key: 'learnNum', key: 'learnNum',
dataIndex: 'learnNum', dataIndex: 'learnNum',
width: 130, width: 130,
...@@ -250,7 +263,7 @@ class UserLearningData extends React.Component { ...@@ -250,7 +263,7 @@ class UserLearningData extends React.Component {
<span>/</span> <span>/</span>
<span>{record.courseNum}</span> <span>{record.courseNum}</span>
</div> </div>
) );
}, },
}, },
{ {
...@@ -267,15 +280,15 @@ class UserLearningData extends React.Component { ...@@ -267,15 +280,15 @@ class UserLearningData extends React.Component {
<span <span
className='operate-item' className='operate-item'
onClick={() => { onClick={() => {
this.UnbundEmployee(record) this.UnbundEmployee(record);
}}> }}>
解绑 解绑
</span> </span>
</div> </div>
) );
}, },
}, },
] ];
} else { } else {
columns = [ columns = [
{ {
...@@ -283,7 +296,7 @@ class UserLearningData extends React.Component { ...@@ -283,7 +296,7 @@ class UserLearningData extends React.Component {
key: 'storeCustomerName', key: 'storeCustomerName',
dataIndex: 'storeCustomerName', dataIndex: 'storeCustomerName',
render: (val, record) => { render: (val, record) => {
return <div>{val}</div> return <div>{val}</div>;
}, },
}, },
{ {
...@@ -291,7 +304,7 @@ class UserLearningData extends React.Component { ...@@ -291,7 +304,7 @@ class UserLearningData extends React.Component {
key: 'learnState', key: 'learnState',
dataIndex: 'learnState', dataIndex: 'learnState',
render: (val, record) => { render: (val, record) => {
return <div>{LearnState[val].text}</div> return <div>{LearnState[val].text}</div>;
}, },
}, },
{ {
...@@ -300,7 +313,7 @@ class UserLearningData extends React.Component { ...@@ -300,7 +313,7 @@ class UserLearningData extends React.Component {
dataIndex: 'latelyLearnTime', dataIndex: 'latelyLearnTime',
sorter: true, sorter: true,
render: (val, record) => { render: (val, record) => {
return <div>{formatDate('YYYY-MM-DD H:i', val)}</div> return <div>{formatDate('YYYY-MM-DD H:i', val)}</div>;
}, },
}, },
{ {
...@@ -309,7 +322,7 @@ class UserLearningData extends React.Component { ...@@ -309,7 +322,7 @@ class UserLearningData extends React.Component {
dataIndex: 'startLearnTime', dataIndex: 'startLearnTime',
sorter: true, sorter: true,
render: (val, record) => { render: (val, record) => {
return <div>{formatDate('YYYY-MM-DD H:i', val)}</div> return <div>{formatDate('YYYY-MM-DD H:i', val)}</div>;
}, },
}, },
{ {
...@@ -333,7 +346,7 @@ class UserLearningData extends React.Component { ...@@ -333,7 +346,7 @@ class UserLearningData extends React.Component {
<span>/</span> <span>/</span>
<span>{record.courseNum}</span> <span>{record.courseNum}</span>
</div> </div>
) );
}, },
}, },
{ {
...@@ -350,28 +363,32 @@ class UserLearningData extends React.Component { ...@@ -350,28 +363,32 @@ class UserLearningData extends React.Component {
<span <span
className='operate-item' className='operate-item'
onClick={() => { onClick={() => {
this.UnbundEmployee(record) this.UnbundEmployee(record);
}}> }}>
解绑 解绑
</span> </span>
</div> </div>
) );
}, },
}, },
] ];
} }
return columns return columns;
} };
render() { render() {
const { dataSource, query, size, totalCount, userLearnDetailModalSHow, storeCustomerId, planId, unbundEmployeeModalVisible } = this.state const { dataSource, query, size, totalCount, userLearnDetailModalSHow, storeCustomerId, planId, unbundEmployeeModalVisible } = this.state;
return ( return (
<div className='user-learning-data'> <div className='user-learning-data'>
<div className='search-container'> <div className='search-container'>
<UserLearningDataFilter onChange={this.handleFetchDataList} /> <UserLearningDataFilter onChange={this.handleFetchDataList} />
</div> </div>
<div> <div>
<Table <XMTable
renderEmpty={{
image: college,
description: '暂无数据',
}}
rowKey={(record) => record.storeCustomerId} rowKey={(record) => record.storeCustomerId}
dataSource={dataSource} dataSource={dataSource}
columns={this.parselumns()} columns={this.parselumns()}
...@@ -388,15 +405,15 @@ class UserLearningData extends React.Component { ...@@ -388,15 +405,15 @@ class UserLearningData extends React.Component {
pageSize={size} pageSize={size}
total={totalCount} total={totalCount}
toPage={(page) => { toPage={(page) => {
const _query = { ...query, current: page + 1 } const _query = { ...query, current: page + 1 };
this.setState( this.setState(
{ {
query: _query, query: _query,
}, },
() => { () => {
this.handleFetchDataList() this.handleFetchDataList();
} }
) );
}} }}
onShowSizeChange={this.onShowSizeChange} onShowSizeChange={this.onShowSizeChange}
/> />
...@@ -412,14 +429,14 @@ class UserLearningData extends React.Component { ...@@ -412,14 +429,14 @@ class UserLearningData extends React.Component {
onClose={this.handleCloseUnbundEmployeeModal} onClose={this.handleCloseUnbundEmployeeModal}
storeCustomerId={storeCustomerId} storeCustomerId={storeCustomerId}
onConfirm={() => { onConfirm={() => {
this.handleFetchDataList() this.handleFetchDataList();
this.handleCloseUnbundEmployeeModal() this.handleCloseUnbundEmployeeModal();
}} }}
/> />
)} )}
</div> </div>
) );
} }
} }
export default withRouter(UserLearningData) export default withRouter(UserLearningData);
import React from "react" import React from 'react';
import _ from "underscore" import _ from 'underscore';
import { Table, Radio, Tabs, Modal, Input, message, Button, Tooltip } from "antd" import { Table, Radio, Tabs, Modal, Input, message, Button, Tooltip } from 'antd';
import { PageControl } from "@/components" import { PageControl, XMTable } from '@/components';
import college from '@/common/lottie/college';
import CourseService from "@/domains/course-domain/CourseService" import CourseService from '@/domains/course-domain/CourseService';
import User from "@/common/js/user" import User from '@/common/js/user';
import Service from "@/common/js/service" import Service from '@/common/js/service';
import dealTimeDuration from "../../course-manage/utils/dealTimeDuration" import dealTimeDuration from '../../course-manage/utils/dealTimeDuration';
import "./relatedCourseModal.less" import './relatedCourseModal.less';
const { Search } = Input const { Search } = Input;
const { TabPane } = Tabs const { TabPane } = Tabs;
const courseStateShow = { const courseStateShow = {
UN_START: { UN_START: {
code: 1, code: 1,
title: "待开课", title: '待开课',
color: "#FFB129", color: '#FFB129',
}, },
STARTING: { STARTING: {
code: 2, code: 2,
title: "上课中", title: '上课中',
color: "#238FFF" color: '#238FFF',
}, },
FINISH: { FINISH: {
code: 3, code: 3,
title: "已完成", title: '已完成',
color: "#3BBDAA" color: '#3BBDAA',
}, },
EXPIRED: { EXPIRED: {
code: 4, code: 4,
title: "未成功开课", title: '未成功开课',
color: "#999" color: '#999',
} },
} };
class SelectOperatorModal extends React.Component { class SelectOperatorModal extends React.Component {
constructor(props) { constructor(props) {
super(props) super(props);
this.state = { this.state = {
liveDataSource: [], liveDataSource: [],
liveSize: 10, liveSize: 10,
liveQuery: { liveQuery: {
current: 1 current: 1,
}, },
liveTotalCount: 0, liveTotalCount: 0,
selectLive: [], //弹窗内已选择的直播课程 selectLive: [], //弹窗内已选择的直播课程
currentCourseListData: [], currentCourseListData: [],
currentLiveCourseListData: [], //页面中已关联的直播课程 currentLiveCourseListData: [], //页面中已关联的直播课程
videoCourseDivision: "internal", videoCourseDivision: 'internal',
videoDataSource: { videoDataSource: {
external: [], external: [],
internal: [] internal: [],
}, },
videoSize: { videoSize: {
external: 10, external: 10,
internal: 10 internal: 10,
}, },
videoSearchName: { videoSearchName: {
external: "", external: '',
internal: "" internal: '',
}, },
videoSearchDefalt: "", videoSearchDefalt: '',
videoQuery: { videoQuery: {
external: { external: {
current: 1 current: 1,
}, },
internal: { internal: {
current: 1 current: 1,
} },
}, },
videoTotalCount: { videoTotalCount: {
external: 0, external: 0,
internal: 0 internal: 0,
}, },
selectVideo: { selectVideo: {
external: [], external: [],
internal: [] internal: [],
}, //弹窗内已选择的视频课程 }, //弹窗内已选择的视频课程
currentVideoCourseListData: { currentVideoCourseListData: {
external: [], external: [],
internal: [] internal: [],
}, //页面中已关联的视频课程 }, //页面中已关联的视频课程
pictureDataSource: [], pictureDataSource: [],
pictureSize: 10, pictureSize: 10,
pictureQuery: { pictureQuery: {
current: 1 current: 1,
}, },
pictureTotalCount: 0, pictureTotalCount: 0,
selectPicture: [], //弹窗内已选择的视频课程 selectPicture: [], //弹窗内已选择的视频课程
currentPictureCourseListData: [], //页面中已关联的视频课程 currentPictureCourseListData: [], //页面中已关联的视频课程
activeKey: "video", activeKey: 'video',
currentTaskCourseData: this.props.data[this.props.selectedTaskIndex].courseList || [] currentTaskCourseData: this.props.data[this.props.selectedTaskIndex].courseList || [],
} };
} }
componentDidMount() { componentDidMount() {
this.handleFetchLiveDataList() this.handleFetchLiveDataList();
this.handleFetchVideoDataList() this.handleFetchVideoDataList();
this.handleFetchPictureDataList() this.handleFetchPictureDataList();
} }
// 获取直播课列表 // 获取直播课列表
handleFetchLiveDataList = () => { handleFetchLiveDataList = () => {
const { liveQuery, liveSize } = this.state const { liveQuery, liveSize } = this.state;
const _data = [...this.props.data] const _data = [...this.props.data];
let currentLiveCourseListData = [] let currentLiveCourseListData = [];
_data.map((item) => { _data.map((item) => {
item.courseList.map((childItem, childIndex) => { item.courseList.map((childItem, childIndex) => {
if (childItem.courseType === "LIVE") { if (childItem.courseType === 'LIVE') {
currentLiveCourseListData.push(childItem.courseId) currentLiveCourseListData.push(childItem.courseId);
} }
return childItem return childItem;
}) });
return item return item;
}) });
const params = { const params = {
...liveQuery, ...liveQuery,
size: liveSize, size: liveSize,
excludeCourseIdList: currentLiveCourseListData excludeCourseIdList: currentLiveCourseListData,
} };
CourseService.getLiveCloudCourseBasePage(params).then((res) => { CourseService.getLiveCloudCourseBasePage(params).then((res) => {
const { result = {} } = res const { result = {} } = res;
const { records = [], total = 0 } = result const { records = [], total = 0 } = result;
this.setState({ this.setState({
liveDataSource: records, liveDataSource: records,
liveTotalCount: Number(total), liveTotalCount: Number(total),
currentLiveCourseListData currentLiveCourseListData,
}) });
}) });
} };
// 获取视频课列表 // 获取视频课列表
handleFetchVideoDataList = () => { handleFetchVideoDataList = () => {
const { videoQuery, videoSize, videoDataSource, videoTotalCount, videoCourseDivision } = this.state const { videoQuery, videoSize, videoDataSource, videoTotalCount, videoCourseDivision } = this.state;
const _data = [...this.props.data] const _data = [...this.props.data];
let currentVideoCourseListData = [] let currentVideoCourseListData = [];
_data.map((item, index) => { _data.map((item, index) => {
item.courseList.map((childItem, childIndex) => { item.courseList.map((childItem, childIndex) => {
if (childItem.courseType === "VOICE") { if (childItem.courseType === 'VOICE') {
currentVideoCourseListData.push(childItem.courseId) currentVideoCourseListData.push(childItem.courseId);
} }
return childItem return childItem;
}) });
return item return item;
}) });
const params = { const params = {
...videoQuery[videoCourseDivision], ...videoQuery[videoCourseDivision],
size: videoSize[videoCourseDivision], size: videoSize[videoCourseDivision],
courseDivision: videoCourseDivision === "internal" ? "INTERNAL" : "EXTERNAL", courseDivision: videoCourseDivision === 'internal' ? 'INTERNAL' : 'EXTERNAL',
excludeCourseIdList: currentVideoCourseListData excludeCourseIdList: currentVideoCourseListData,
} };
CourseService.videoScheduleBasePage(params).then((res) => { CourseService.videoScheduleBasePage(params).then((res) => {
const { result = {} } = res const { result = {} } = res;
console.log("result", result) console.log('result', result);
const { records = [], total = 0 } = result const { records = [], total = 0 } = result;
this.setState({ this.setState({
videoDataSource: { videoDataSource: {
...videoDataSource, ...videoDataSource,
[videoCourseDivision]: records [videoCourseDivision]: records,
}, },
videoTotalCount: { videoTotalCount: {
...videoTotalCount, ...videoTotalCount,
[videoCourseDivision]: Number(total) [videoCourseDivision]: Number(total),
}, },
currentVideoCourseListData currentVideoCourseListData,
}) });
}) });
} };
// 获取图文课列表 // 获取图文课列表
handleFetchPictureDataList = () => { handleFetchPictureDataList = () => {
const { pictureQuery, pictureSize } = this.state const { pictureQuery, pictureSize } = this.state;
const _data = [...this.props.data] const _data = [...this.props.data];
let currentPictureCourseListData = [] let currentPictureCourseListData = [];
_data.map((item, index) => { _data.map((item, index) => {
item.courseList.map((childItem, childIndex) => { item.courseList.map((childItem, childIndex) => {
if (childItem.courseType === "PICTURE") { if (childItem.courseType === 'PICTURE') {
currentPictureCourseListData.push(childItem.courseId) currentPictureCourseListData.push(childItem.courseId);
} }
return childItem return childItem;
}) });
return item return item;
}) });
const params = { const params = {
...pictureQuery, ...pictureQuery,
size: pictureSize, size: pictureSize,
courseType: "PICTURE", courseType: 'PICTURE',
storeId: User.getStoreId(), storeId: User.getStoreId(),
excludeCourseIdList: currentPictureCourseListData excludeCourseIdList: currentPictureCourseListData,
} };
Service.Hades("public/hades/mediaCoursePage", params).then((res) => { Service.Hades('public/hades/mediaCoursePage', params).then((res) => {
const { result = {} } = res const { result = {} } = res;
const { records = [], total = 0 } = result const { records = [], total = 0 } = result;
this.setState({ this.setState({
pictureDataSource: records, pictureDataSource: records,
pictureTotalCount: Number(total), pictureTotalCount: Number(total),
currentPictureCourseListData currentPictureCourseListData,
}) });
}) });
} };
handleChangVideoCourseName = (value) => { handleChangVideoCourseName = (value) => {
const { videoQuery, videoCourseDivision, videoSearchName } = this.state const { videoQuery, videoCourseDivision, videoSearchName } = this.state;
videoQuery[videoCourseDivision].courseName = value videoQuery[videoCourseDivision].courseName = value;
videoQuery[videoCourseDivision].current = 1 videoQuery[videoCourseDivision].current = 1;
this.setState({ this.setState({
...videoQuery, ...videoQuery,
videoSearchDefalt: value, videoSearchDefalt: value,
videoSearchName: { videoSearchName: {
...videoSearchName, ...videoSearchName,
[videoCourseDivision]: value [videoCourseDivision]: value,
} },
}) });
} };
handleChangLiveCourseName = (value) => { handleChangLiveCourseName = (value) => {
const { liveQuery } = this.state const { liveQuery } = this.state;
liveQuery.courseName = value liveQuery.courseName = value;
liveQuery.current = 1 liveQuery.current = 1;
this.setState({ this.setState({
liveQuery liveQuery,
}) });
} };
handleChangPictureCourseName = (value) => { handleChangPictureCourseName = (value) => {
const { pictureQuery } = this.state const { pictureQuery } = this.state;
pictureQuery.courseName = value pictureQuery.courseName = value;
pictureQuery.current = 1 pictureQuery.current = 1;
this.setState({ this.setState({
pictureQuery pictureQuery,
}) });
} };
onShowLiveSizeChange = (current, size) => { onShowLiveSizeChange = (current, size) => {
if (current === size) { if (current === size) {
return return;
} }
this.setState( this.setState(
{ {
liveSize: size liveSize: size,
}, },
() => { () => {
this.handleFetchLiveDataList() this.handleFetchLiveDataList();
}
)
} }
);
};
onShowVideoSizeChange = (current, size) => { onShowVideoSizeChange = (current, size) => {
if (current === size) { if (current === size) {
return return;
} }
this.setState( this.setState(
{ {
videoSize: size videoSize: size,
}, },
() => { () => {
this.handleFetchLiveDataList() this.handleFetchLiveDataList();
}
)
} }
);
};
onShowPictureSizeChange = (current, size) => { onShowPictureSizeChange = (current, size) => {
if (current === size) { if (current === size) {
return return;
} }
this.setState( this.setState(
{ {
pictureSize: size pictureSize: size,
}, },
() => { () => {
this.handleFetchPictureDataList() this.handleFetchPictureDataList();
}
)
} }
);
};
// 请求表头 // 请求表头
parseLiveColumns = () => { parseLiveColumns = () => {
const columns = [ const columns = [
{ {
title: <span><span>课程信息</span><Tooltip title="仅显示未关联课程,已关联课程不支持重复选择"><i className="icon iconfont" style={{ marginLeft: '5px',cursor:'pointer',color:'#bfbfbf',fontSize:'14px',fontWeight:"400" title: (
}}>&#xe61d;</i></Tooltip></span>, <span>
<span>课程信息</span>
<Tooltip title='仅显示未关联课程,已关联课程不支持重复选择'>
<i className='icon iconfont' style={{ marginLeft: '5px', cursor: 'pointer', color: '#bfbfbf', fontSize: '14px', fontWeight: '400' }}>
&#xe61d;
</i>
</Tooltip>
</span>
),
key: 'course', key: 'course',
dataIndex: 'course', dataIndex: 'course',
width:'40%', width: '40%',
render: (val, record) => { render: (val, record) => {
let hasCover = false let hasCover = false;
return ( return (
<div className='course-info'> <div className='course-info'>
{record.courseMediaVOS.map((item) => { {record.courseMediaVOS.map((item) => {
if (item.contentType === "COVER") { if (item.contentType === 'COVER') {
hasCover = true hasCover = true;
return <img className='course-cover' src={item.mediaUrl} alt='' /> return <img className='course-cover' src={item.mediaUrl} alt='' />;
} }
return null return null;
})} })}
<If condition={!hasCover}> <If condition={!hasCover}>
<img className='course-cover' src={"https://image.xiaomaiketang.com/xm/Yip2YtFDwH.png"} alt='' /> <img className='course-cover' src={'https://image.xiaomaiketang.com/xm/Yip2YtFDwH.png'} alt='' />
</If> </If>
<div> <div>
...@@ -316,35 +325,35 @@ class SelectOperatorModal extends React.Component { ...@@ -316,35 +325,35 @@ class SelectOperatorModal extends React.Component {
</span> </span>
</div> </div>
</div> </div>
) );
} },
}, },
{ {
title: "上课时间", title: '上课时间',
key: "courseTime", key: 'courseTime',
dataIndex: "courseTime", dataIndex: 'courseTime',
width: "40%", width: '40%',
render: (val, record) => { render: (val, record) => {
return ( return (
<div> <div>
<div>{formatDate("YYYY-MM-DD", record.startTime)}</div> <div>{formatDate('YYYY-MM-DD', record.startTime)}</div>
<div> <div>
{formatDate("H:i", record.startTime)}~{formatDate("H:i", record.endTime)} {formatDate('H:i', record.startTime)}~{formatDate('H:i', record.endTime)}
</div> </div>
</div> </div>
) );
} },
}, },
{ {
title: "学院展示", title: '学院展示',
key: "shelfState", key: 'shelfState',
dataIndex: "shelfState", dataIndex: 'shelfState',
width: "20%", width: '20%',
render: (val, record) => { render: (val, record) => {
return ( return (
<span> <span>
<Choose> <Choose>
<When condition={record.shelfState === "YES"}> <When condition={record.shelfState === 'YES'}>
<span>开启</span> <span>开启</span>
</When> </When>
<Otherwise> <Otherwise>
...@@ -352,24 +361,33 @@ class SelectOperatorModal extends React.Component { ...@@ -352,24 +361,33 @@ class SelectOperatorModal extends React.Component {
</Otherwise> </Otherwise>
</Choose> </Choose>
</span> </span>
) );
} },
} },
] ];
return columns return columns;
} };
// 请求表头 // 请求表头
parseVideoColumns = () => { parseVideoColumns = () => {
const { videoCourseDivision } = this.state const { videoCourseDivision } = this.state;
const columns = [ const columns = [
{ {
title: <span><span>课程信息</span><Tooltip title="仅显示未关联课程,已关联课程不支持重复选择"><i className="icon iconfont" style={{ marginLeft: '5px',cursor:'pointer',color:'#bfbfbf',fontSize:'14px',fontWeight:"400"}}>&#xe61d;</i></Tooltip></span>, title: (
<span>
<span>课程信息</span>
<Tooltip title='仅显示未关联课程,已关联课程不支持重复选择'>
<i className='icon iconfont' style={{ marginLeft: '5px', cursor: 'pointer', color: '#bfbfbf', fontSize: '14px', fontWeight: '400' }}>
&#xe61d;
</i>
</Tooltip>
</span>
),
key: 'course', key: 'course',
dataIndex: 'course', dataIndex: 'course',
width:'60%', width: '60%',
render: (val, record) => { render: (val, record) => {
const { coverUrl, scheduleVideoUrl } = record const { coverUrl, scheduleVideoUrl } = record;
return ( return (
<div className='course-info'> <div className='course-info'>
{/* 上传了封面的话就用上传的封面, 没有的话就取视频的第一帧 */} {/* 上传了封面的话就用上传的封面, 没有的话就取视频的第一帧 */}
...@@ -377,242 +395,251 @@ class SelectOperatorModal extends React.Component { ...@@ -377,242 +395,251 @@ class SelectOperatorModal extends React.Component {
className='course-cover' className='course-cover'
src={ src={
coverUrl || coverUrl ||
(videoCourseDivision === "internal" (videoCourseDivision === 'internal'
? `${scheduleVideoUrl}?x-oss-process=video/snapshot,t_0,m_fast` ? `${scheduleVideoUrl}?x-oss-process=video/snapshot,t_0,m_fast`
: "https://image.xiaomaiketang.com/xm/mt3ZQRxGKB.png") : 'https://image.xiaomaiketang.com/xm/mt3ZQRxGKB.png')
} }
alt='' alt=''
/> />
<div className='course-name'>{record.courseName}</div> <div className='course-name'>{record.courseName}</div>
</div> </div>
) );
} },
}, },
{ {
title: "课程时长", title: '课程时长',
key: "courseTime", key: 'courseTime',
dataIndex: "courseTime", dataIndex: 'courseTime',
width: "20%", width: '20%',
render: (val, record) => { render: (val, record) => {
return <span className='course-status'>{dealTimeDuration(record.videoDuration)}</span> return <span className='course-status'>{dealTimeDuration(record.videoDuration)}</span>;
} },
}, },
{ {
title: "学院展示", title: '学院展示',
key: "shelfState", key: 'shelfState',
dataIndex: "shelfState", dataIndex: 'shelfState',
width: "20%", width: '20%',
render: (val, record) => { render: (val, record) => {
return ( return (
<Choose> <Choose>
<When condition={record.shelfState === "YES"}> <When condition={record.shelfState === 'YES'}>
<span>开启</span> <span>开启</span>
</When> </When>
<Otherwise> <Otherwise>
<span>关闭</span> <span>关闭</span>
</Otherwise> </Otherwise>
</Choose> </Choose>
) );
} },
} },
] ];
return columns return columns;
} };
// 请求表头 // 请求表头
parsePictureColumns = () => { parsePictureColumns = () => {
const columns = [ const columns = [
{ {
title: <span><span>课程信息</span><Tooltip title="仅显示未关联课程,已关联课程不支持重复选择"><i className="icon iconfont" style={{ marginLeft: '5px',cursor:'pointer',color:'#bfbfbf',fontSize:'14px',fontWeight:"400"}}>&#xe61d;</i></Tooltip></span>, title: (
<span>
<span>课程信息</span>
<Tooltip title='仅显示未关联课程,已关联课程不支持重复选择'>
<i className='icon iconfont' style={{ marginLeft: '5px', cursor: 'pointer', color: '#bfbfbf', fontSize: '14px', fontWeight: '400' }}>
&#xe61d;
</i>
</Tooltip>
</span>
),
key: 'course', key: 'course',
dataIndex: 'course', dataIndex: 'course',
width:'55%', width: '55%',
render: (val, record) => { render: (val, record) => {
const { coverUrl } = record const { coverUrl } = record;
return ( return (
<div className='course-info'> <div className='course-info'>
<img className='course-cover' src={coverUrl || "https://image.xiaomaiketang.com/xm/wFnpZtp2yB.png"} alt='' /> <img className='course-cover' src={coverUrl || 'https://image.xiaomaiketang.com/xm/wFnpZtp2yB.png'} alt='' />
<div className='course-name'>{record.courseName}</div> <div className='course-name'>{record.courseName}</div>
</div> </div>
) );
} },
}, },
{ {
title: "更新时间", title: '更新时间',
key: "updated", key: 'updated',
dataIndex: "updated", dataIndex: 'updated',
width: "25%", width: '25%',
render: (val, record) => { render: (val, record) => {
return <span className='course-status'>{formatDate("YYYY-MM-DD", record.updated)}</span> return <span className='course-status'>{formatDate('YYYY-MM-DD', record.updated)}</span>;
} },
}, },
{ {
title: "学院展示", title: '学院展示',
key: "shelfState", key: 'shelfState',
dataIndex: "shelfState", dataIndex: 'shelfState',
width: "20%", width: '20%',
render: (val, record) => { render: (val, record) => {
return <span>{record.shelfState === "YES" ? "开启" : "关闭"}</span> return <span>{record.shelfState === 'YES' ? '开启' : '关闭'}</span>;
} },
} },
] ];
return columns return columns;
} };
selectLiveList = (record, selected) => { selectLiveList = (record, selected) => {
const { selectVideo, currentTaskCourseData, selectLive, selectPicture } = this.state const { selectVideo, currentTaskCourseData, selectLive, selectPicture } = this.state;
let _list = [] let _list = [];
if (selected || !_.find(selectLive, (item) => item.liveCourseId === record.liveCourseId)) { if (selected || !_.find(selectLive, (item) => item.liveCourseId === record.liveCourseId)) {
_list = _.uniq(selectLive.concat([record]), false, (item) => item.liveCourseId) _list = _.uniq(selectLive.concat([record]), false, (item) => item.liveCourseId);
} else { } else {
_list = _.reject(selectLive, (item) => item.liveCourseId === record.liveCourseId) _list = _.reject(selectLive, (item) => item.liveCourseId === record.liveCourseId);
} }
if (_list.length + currentTaskCourseData.length + selectVideo.length + selectPicture.length > 20) { if (_list.length + currentTaskCourseData.length + selectVideo.length + selectPicture.length > 20) {
message.warning("无法继续选择,一个任务最多关联20个课程") message.warning('无法继续选择,一个任务最多关联20个课程');
return return;
}
this.setState({ selectLive: _list })
} }
this.setState({ selectLive: _list });
};
selectVideoList = (record, selected) => { selectVideoList = (record, selected) => {
const { selectVideo, currentTaskCourseData, selectLive, selectPicture, videoCourseDivision } = this.state const { selectVideo, currentTaskCourseData, selectLive, selectPicture, videoCourseDivision } = this.state;
let { [videoCourseDivision]: selectList } = selectVideo let { [videoCourseDivision]: selectList } = selectVideo;
let _list = [] let _list = [];
if (selected || !_.find(selectList, (item) => item.id === record.id)) { if (selected || !_.find(selectList, (item) => item.id === record.id)) {
_list = _.uniq(selectList.concat([record]), false, (item) => item.id) _list = _.uniq(selectList.concat([record]), false, (item) => item.id);
} else { } else {
_list = _.reject(selectList, (item) => item.id === record.id) _list = _.reject(selectList, (item) => item.id === record.id);
} }
if (_list.length + currentTaskCourseData.length + selectLive.length + selectPicture.length > 20) { if (_list.length + currentTaskCourseData.length + selectLive.length + selectPicture.length > 20) {
message.warning("无法继续选择,一个任务最多关联20个课程") message.warning('无法继续选择,一个任务最多关联20个课程');
return return;
} }
this.setState({ this.setState({
selectVideo: { selectVideo: {
...selectVideo, ...selectVideo,
[videoCourseDivision]: _list [videoCourseDivision]: _list,
} },
}) });
} };
selectPictureList = (record, selected) => { selectPictureList = (record, selected) => {
const { selectVideo, currentTaskCourseData, selectLive, selectPicture } = this.state const { selectVideo, currentTaskCourseData, selectLive, selectPicture } = this.state;
let _list = [] let _list = [];
if (selected || !_.find(selectPicture, (item) => item.id === record.id)) { if (selected || !_.find(selectPicture, (item) => item.id === record.id)) {
_list = _.uniq(selectPicture.concat([record]), false, (item) => item.id) _list = _.uniq(selectPicture.concat([record]), false, (item) => item.id);
} else { } else {
_list = _.reject(selectPicture, (item) => item.id === record.id) _list = _.reject(selectPicture, (item) => item.id === record.id);
} }
if (_list.length + currentTaskCourseData.length + selectLive.length + selectVideo.length > 20) { if (_list.length + currentTaskCourseData.length + selectLive.length + selectVideo.length > 20) {
message.warning("无法继续选择,一个任务最多关联20个课程") message.warning('无法继续选择,一个任务最多关联20个课程');
return return;
}
this.setState({ selectPicture: _list })
} }
this.setState({ selectPicture: _list });
};
clearSelectCourse = () => { clearSelectCourse = () => {
this.setState({ this.setState({
selectLive: [], selectLive: [],
selectVideo: { selectVideo: {
internal: [], internal: [],
external: [] external: [],
}, },
selectPicture: [] selectPicture: [],
}) });
} };
handleSelectVideo = (selectVideo) => { handleSelectVideo = (selectVideo) => {
return selectVideo.map((item) => { return selectVideo.map((item) => {
let _item = {} let _item = {};
_item.courseId = item.id _item.courseId = item.id;
_item.courseType = "VOICE" _item.courseType = 'VOICE';
_item.courseName = item.courseName _item.courseName = item.courseName;
return _item return _item;
}) });
} };
handleSelectLive = (selectLive) => { handleSelectLive = (selectLive) => {
return selectLive.map((item, index) => { return selectLive.map((item, index) => {
let _item = {} let _item = {};
_item.courseId = item.liveCourseId _item.courseId = item.liveCourseId;
_item.courseType = "LIVE" _item.courseType = 'LIVE';
_item.courseName = item.courseName _item.courseName = item.courseName;
_item.courseState = item.courseState _item.courseState = item.courseState;
return _item return _item;
}) });
} };
videoCourseDivisionChange = (e) => { videoCourseDivisionChange = (e) => {
const { videoSearchName } = this.state const { videoSearchName } = this.state;
this.setState( this.setState(
{ {
videoCourseDivision: e.target.value, videoCourseDivision: e.target.value,
videoSearchDefalt: videoSearchName[e.target.value] videoSearchDefalt: videoSearchName[e.target.value],
}, },
() => { () => {
this.handleFetchVideoDataList() this.handleFetchVideoDataList();
}
)
} }
);
};
handleSelectPicture = (selectPicture) => { handleSelectPicture = (selectPicture) => {
return selectPicture.map((item, index) => { return selectPicture.map((item, index) => {
let _item = {} let _item = {};
_item.courseId = item.id _item.courseId = item.id;
_item.courseType = "PICTURE" _item.courseType = 'PICTURE';
_item.courseName = item.courseName _item.courseName = item.courseName;
return _item return _item;
}) });
} };
renderFooter = () => { renderFooter = () => {
const { activeKey } = this.state const { activeKey } = this.state;
let href = "" let href = '';
switch (activeKey) { switch (activeKey) {
case "live": case 'live':
href = ( href = (
<a <a
target='_blank' target='_blank'
rel='noopener noreferrer' rel='noopener noreferrer'
className='link-create-course' className='link-create-course'
href={window.location.origin + window.location.pathname + "#/create-live-course?type=add"} href={window.location.origin + window.location.pathname + '#/create-live-course?type=add'}
onClick={this.props.onClose}> onClick={this.props.onClose}>
没有找到需要的直播课?<span>去创建</span> 没有找到需要的直播课?<span>去创建</span>
</a> </a>
) );
break break;
case "video": case 'video':
href = ( href = (
<a <a
target='_blank' target='_blank'
rel='noopener noreferrer' rel='noopener noreferrer'
className='link-create-course' className='link-create-course'
href={window.location.origin + window.location.pathname + "#/create-video-course?type=add"} href={window.location.origin + window.location.pathname + '#/create-video-course?type=add'}
onClick={this.props.onClose}> onClick={this.props.onClose}>
没有找到需要的视频课?<span>去创建</span> 没有找到需要的视频课?<span>去创建</span>
</a> </a>
) );
break break;
case "picture": case 'picture':
href = ( href = (
<a <a
target='_blank' target='_blank'
rel='noopener noreferrer' rel='noopener noreferrer'
className='link-create-course' className='link-create-course'
href={window.location.origin + window.location.pathname + "#/create-graphics-course?type=add"} href={window.location.origin + window.location.pathname + '#/create-graphics-course?type=add'}
onClick={this.props.onClose}> onClick={this.props.onClose}>
没有找到需要的图文课?<span>去创建</span> 没有找到需要的图文课?<span>去创建</span>
</a> </a>
) );
break break;
default: default:
break break;
}
return href
} }
return href;
};
render() { render() {
const { visible } = this.props const { visible } = this.props;
const { const {
liveDataSource, liveDataSource,
liveSize, liveSize,
...@@ -632,8 +659,8 @@ class SelectOperatorModal extends React.Component { ...@@ -632,8 +659,8 @@ class SelectOperatorModal extends React.Component {
pictureQuery, pictureQuery,
pictureTotalCount, pictureTotalCount,
videoCourseDivision videoCourseDivision,
} = this.state } = this.state;
return ( return (
<Modal <Modal
title='关联课程' title='关联课程'
...@@ -649,7 +676,7 @@ class SelectOperatorModal extends React.Component { ...@@ -649,7 +676,7 @@ class SelectOperatorModal extends React.Component {
this.renderFooter(), this.renderFooter(),
<Button <Button
onClick={() => { onClick={() => {
this.props.onClose() this.props.onClose();
}}> }}>
取消 取消
</Button>, </Button>,
...@@ -660,18 +687,18 @@ class SelectOperatorModal extends React.Component { ...@@ -660,18 +687,18 @@ class SelectOperatorModal extends React.Component {
...this.handleSelectVideo(selectVideo.internal), ...this.handleSelectVideo(selectVideo.internal),
...this.handleSelectVideo(selectVideo.external), ...this.handleSelectVideo(selectVideo.external),
...this.handleSelectLive(selectLive), ...this.handleSelectLive(selectLive),
...this.handleSelectPicture(selectPicture) ...this.handleSelectPicture(selectPicture),
]) ])
}> }>
确定 确定
</Button> </Button>,
]}> ]}>
<div> <div>
<Tabs <Tabs
type='line' type='line'
defaultActiveKey='live' defaultActiveKey='live'
onChange={(activeKey) => { onChange={(activeKey) => {
this.setState({ activeKey: activeKey }) this.setState({ activeKey: activeKey });
}}> }}>
<TabPane tab='直播课' key='live'> <TabPane tab='直播课' key='live'>
<div className='search-container'> <div className='search-container'>
...@@ -680,10 +707,10 @@ class SelectOperatorModal extends React.Component { ...@@ -680,10 +707,10 @@ class SelectOperatorModal extends React.Component {
placeholder='搜索课程名称' placeholder='搜索课程名称'
style={{ width: 200 }} style={{ width: 200 }}
onChange={(e) => { onChange={(e) => {
this.handleChangLiveCourseName(e.target.value) this.handleChangLiveCourseName(e.target.value);
}} }}
onSearch={() => { onSearch={() => {
this.handleFetchLiveDataList() this.handleFetchLiveDataList();
}} }}
/> />
</div> </div>
...@@ -707,32 +734,36 @@ class SelectOperatorModal extends React.Component { ...@@ -707,32 +734,36 @@ class SelectOperatorModal extends React.Component {
</div> </div>
</div> </div>
<div> <div>
<Table <XMTable
renderEmpty={{
image: college,
description: '暂无数据',
}}
rowKey={(record) => record.liveCourseId} rowKey={(record) => record.liveCourseId}
dataSource={liveDataSource} dataSource={liveDataSource}
columns={this.parseLiveColumns()} columns={this.parseLiveColumns()}
pagination={false} pagination={false}
bordered bordered
rowSelection={{ rowSelection={{
type: "checkbox", type: 'checkbox',
selectedRowKeys: _.pluck(selectLive, "liveCourseId"), selectedRowKeys: _.pluck(selectLive, 'liveCourseId'),
onSelect: (record, selected) => { onSelect: (record, selected) => {
this.selectLiveList(record, selected) this.selectLiveList(record, selected);
}, },
onSelectAll: (selected, _selectedRows, changeRows) => { onSelectAll: (selected, _selectedRows, changeRows) => {
let _list = [] let _list = [];
if (selected) { if (selected) {
_list = _.uniq(selectLive.concat(changeRows), false, (item) => item.liveCourseId) _list = _.uniq(selectLive.concat(changeRows), false, (item) => item.liveCourseId);
} else { } else {
_list = _.reject(selectLive, (item) => _.find(changeRows, (data) => data.liveCourseId === item.liveCourseId)) _list = _.reject(selectLive, (item) => _.find(changeRows, (data) => data.liveCourseId === item.liveCourseId));
} }
if (_list.length + currentTaskCourseData.length + selectVideo.length + selectPicture.length > 20) { if (_list.length + currentTaskCourseData.length + selectVideo.length + selectPicture.length > 20) {
message.warning("无法继续选择,一个任务最多关联20个课程") message.warning('无法继续选择,一个任务最多关联20个课程');
const extraLength = _list.length + currentTaskCourseData.length + selectVideo.length + selectPicture.length - 20 const extraLength = _list.length + currentTaskCourseData.length + selectVideo.length + selectPicture.length - 20;
_list.splice(_list.length - extraLength, extraLength) _list.splice(_list.length - extraLength, extraLength);
}
this.setState({ selectLive: _list })
} }
this.setState({ selectLive: _list });
},
}} }}
/> />
{liveDataSource.length > 0 && ( {liveDataSource.length > 0 && (
...@@ -743,15 +774,15 @@ class SelectOperatorModal extends React.Component { ...@@ -743,15 +774,15 @@ class SelectOperatorModal extends React.Component {
size='small' size='small'
total={liveTotalCount} total={liveTotalCount}
toPage={(page) => { toPage={(page) => {
const _query = { ...liveQuery, current: page + 1 } const _query = { ...liveQuery, current: page + 1 };
this.setState( this.setState(
{ {
liveQuery: _query liveQuery: _query,
}, },
() => { () => {
this.handleFetchLiveDataList() this.handleFetchLiveDataList();
} }
) );
}} }}
onShowSizeChange={this.onShowLiveSizeChange} onShowSizeChange={this.onShowLiveSizeChange}
/> />
...@@ -772,10 +803,10 @@ class SelectOperatorModal extends React.Component { ...@@ -772,10 +803,10 @@ class SelectOperatorModal extends React.Component {
placeholder='搜索课程名称' placeholder='搜索课程名称'
style={{ width: 200 }} style={{ width: 200 }}
onChange={(e) => { onChange={(e) => {
this.handleChangVideoCourseName(e.target.value) this.handleChangVideoCourseName(e.target.value);
}} }}
onSearch={() => { onSearch={() => {
this.handleFetchVideoDataList() this.handleFetchVideoDataList();
}} }}
/> />
</div> </div>
...@@ -798,37 +829,41 @@ class SelectOperatorModal extends React.Component { ...@@ -798,37 +829,41 @@ class SelectOperatorModal extends React.Component {
</div> </div>
</div> </div>
<div> <div>
<Table <XMTable
renderEmpty={{
image: college,
description: '暂无数据',
}}
rowKey={(record) => record.id} rowKey={(record) => record.id}
dataSource={videoDataSource[videoCourseDivision]} dataSource={videoDataSource[videoCourseDivision]}
columns={this.parseVideoColumns()} columns={this.parseVideoColumns()}
pagination={false} pagination={false}
bordered bordered
rowSelection={{ rowSelection={{
type: "checkbox", type: 'checkbox',
selectedRowKeys: _.pluck(selectVideo[videoCourseDivision], "id"), selectedRowKeys: _.pluck(selectVideo[videoCourseDivision], 'id'),
onSelect: (record, selected) => { onSelect: (record, selected) => {
this.selectVideoList(record, selected) this.selectVideoList(record, selected);
}, },
onSelectAll: (selected, _selectedRows, changeRows) => { onSelectAll: (selected, _selectedRows, changeRows) => {
let _list = [] let _list = [];
if (selected) { if (selected) {
_list = _.uniq(selectVideo[videoCourseDivision].concat(changeRows), false, (item) => item.id) _list = _.uniq(selectVideo[videoCourseDivision].concat(changeRows), false, (item) => item.id);
} else { } else {
_list = _.reject(selectVideo[videoCourseDivision], (item) => _.find(changeRows, (data) => data.id === item.id)) _list = _.reject(selectVideo[videoCourseDivision], (item) => _.find(changeRows, (data) => data.id === item.id));
} }
if (_list.length + currentTaskCourseData.length + selectLive.length + selectPicture.length > 20) { if (_list.length + currentTaskCourseData.length + selectLive.length + selectPicture.length > 20) {
message.warning("无法继续选择,一个任务最多关联20个课程") message.warning('无法继续选择,一个任务最多关联20个课程');
const extraLength = _list.length + currentTaskCourseData.length + selectLive.length + selectPicture.length - 20 const extraLength = _list.length + currentTaskCourseData.length + selectLive.length + selectPicture.length - 20;
_list.splice(_list.length - extraLength, extraLength) _list.splice(_list.length - extraLength, extraLength);
} }
this.setState({ this.setState({
selectVideo: { selectVideo: {
...selectVideo, ...selectVideo,
[videoCourseDivision]: _list [videoCourseDivision]: _list,
} },
}) });
} },
}} }}
/> />
{videoDataSource[videoCourseDivision].length > 0 && ( {videoDataSource[videoCourseDivision].length > 0 && (
...@@ -839,19 +874,19 @@ class SelectOperatorModal extends React.Component { ...@@ -839,19 +874,19 @@ class SelectOperatorModal extends React.Component {
size='small' size='small'
total={videoTotalCount[videoCourseDivision]} total={videoTotalCount[videoCourseDivision]}
toPage={(page) => { toPage={(page) => {
const _query = { ...videoQuery[videoCourseDivision], current: page + 1 } const _query = { ...videoQuery[videoCourseDivision], current: page + 1 };
this.setState( this.setState(
{ {
videoQuery: { videoQuery: {
...videoQuery, ...videoQuery,
[videoCourseDivision]: _query [videoCourseDivision]: _query,
} },
}, },
() => { () => {
this.handleFetchVideoDataList() this.handleFetchVideoDataList();
} }
) );
}} }}
onShowSizeChange={this.onShowVideoSizeChange} onShowSizeChange={this.onShowVideoSizeChange}
/> />
...@@ -866,10 +901,10 @@ class SelectOperatorModal extends React.Component { ...@@ -866,10 +901,10 @@ class SelectOperatorModal extends React.Component {
placeholder='搜索课程名称' placeholder='搜索课程名称'
style={{ width: 200 }} style={{ width: 200 }}
onChange={(e) => { onChange={(e) => {
this.handleChangPictureCourseName(e.target.value) this.handleChangPictureCourseName(e.target.value);
}} }}
onSearch={() => { onSearch={() => {
this.handleFetchPictureDataList() this.handleFetchPictureDataList();
}} }}
/> />
</div> </div>
...@@ -893,32 +928,36 @@ class SelectOperatorModal extends React.Component { ...@@ -893,32 +928,36 @@ class SelectOperatorModal extends React.Component {
</div> </div>
</div> </div>
<div> <div>
<Table <XMTable
renderEmpty={{
image: college,
description: '暂无数据',
}}
rowKey={(record) => record.id} rowKey={(record) => record.id}
dataSource={pictureDataSource} dataSource={pictureDataSource}
columns={this.parsePictureColumns()} columns={this.parsePictureColumns()}
pagination={false} pagination={false}
bordered bordered
rowSelection={{ rowSelection={{
type: "checkbox", type: 'checkbox',
selectedRowKeys: _.pluck(selectPicture, "id"), selectedRowKeys: _.pluck(selectPicture, 'id'),
onSelect: (record, selected) => { onSelect: (record, selected) => {
this.selectPictureList(record, selected) this.selectPictureList(record, selected);
}, },
onSelectAll: (selected, _selectedRows, changeRows) => { onSelectAll: (selected, _selectedRows, changeRows) => {
let _list = [] let _list = [];
if (selected) { if (selected) {
_list = _.uniq(selectPicture.concat(changeRows), false, (item) => item.id) _list = _.uniq(selectPicture.concat(changeRows), false, (item) => item.id);
} else { } else {
_list = _.reject(selectPicture, (item) => _.find(changeRows, (data) => data.id === item.id)) _list = _.reject(selectPicture, (item) => _.find(changeRows, (data) => data.id === item.id));
} }
if (_list.length + currentTaskCourseData.length + selectVideo.length + selectLive.length > 20) { if (_list.length + currentTaskCourseData.length + selectVideo.length + selectLive.length > 20) {
message.warning("无法继续选择,一个任务最多关联20个课程") message.warning('无法继续选择,一个任务最多关联20个课程');
const extraLength = _list.length + currentTaskCourseData.length + selectVideo.length + selectLive.length - 20 const extraLength = _list.length + currentTaskCourseData.length + selectVideo.length + selectLive.length - 20;
_list.splice(_list.length - extraLength, extraLength) _list.splice(_list.length - extraLength, extraLength);
}
this.setState({ selectPicture: _list })
} }
this.setState({ selectPicture: _list });
},
}} }}
/> />
{pictureDataSource.length > 0 && ( {pictureDataSource.length > 0 && (
...@@ -929,15 +968,15 @@ class SelectOperatorModal extends React.Component { ...@@ -929,15 +968,15 @@ class SelectOperatorModal extends React.Component {
size='small' size='small'
total={pictureTotalCount} total={pictureTotalCount}
toPage={(page) => { toPage={(page) => {
const _query = { ...pictureQuery, current: page + 1 } const _query = { ...pictureQuery, current: page + 1 };
this.setState( this.setState(
{ {
pictureQuery: _query pictureQuery: _query,
}, },
() => { () => {
this.handleFetchPictureDataList() this.handleFetchPictureDataList();
} }
) );
}} }}
onShowSizeChange={this.onShowPictureSizeChange} onShowSizeChange={this.onShowPictureSizeChange}
/> />
...@@ -948,8 +987,8 @@ class SelectOperatorModal extends React.Component { ...@@ -948,8 +987,8 @@ class SelectOperatorModal extends React.Component {
</Tabs> </Tabs>
</div> </div>
</Modal> </Modal>
) );
} }
} }
export default SelectOperatorModal export default SelectOperatorModal;
import React, { useState, useRef, useEffect, useContext } from 'react' import React, { useState, useRef, useEffect, useContext } from 'react';
import Service from "@/common/js/service"; import Service from '@/common/js/service';
import { PageControl } from "@/components"; import { PageControl } from '@/components';
import { Input, Select, Tooltip, Button, Table } from 'antd'; import { Input, Select, Tooltip, Button, Table } from 'antd';
import User from "@/common/js/user"; import User from '@/common/js/user';
import moment from 'moment'; import moment from 'moment';
import './userData.less' import './userData.less';
const { Search } = Input; const { Search } = Input;
const { Option } = Select; const { Option } = Select;
interface sortType { interface sortType {
type: "ascend" | "descend" | null | undefined type: 'ascend' | 'descend' | null | undefined;
} }
function ExamData(props: any) { function ExamData(props: any) {
const sortStatus: sortType = { const sortStatus: sortType = {
type: undefined type: undefined,
} };
const examDataInit: any = {}; const examDataInit: any = {};
const queryInit: any = { current: 1, size: 10, order: 'SORT_ASC' }; const queryInit: any = { current: 1, size: 10, order: 'SORT_ASC' };
...@@ -28,165 +27,152 @@ function ExamData(props: any) { ...@@ -28,165 +27,152 @@ function ExamData(props: any) {
const [allData, setAllData] = useState(0); const [allData, setAllData] = useState(0);
const [order, setOrder] = useState(sortStatus.type); const [order, setOrder] = useState(sortStatus.type);
const questionTypeList = { const questionTypeList = {
SINGLE_CHOICE: "单选题", SINGLE_CHOICE: '单选题',
MULTI_CHOICE: "多选题", MULTI_CHOICE: '多选题',
JUDGE: "判断题", JUDGE: '判断题',
GAP_FILLING: "填空题", GAP_FILLING: '填空题',
INDEFINITE_CHOICE: "不定项选择题", INDEFINITE_CHOICE: '不定项选择题',
}; };
const userTypeEnum = { const userTypeEnum = {
WORK_WE_CHAT: '企业微信', WORK_WE_CHAT: '企业微信',
WE_CHAT: '微信' WE_CHAT: '微信',
} };
const userExamStateEnum = { const userExamStateEnum = {
EXAM: '进行中', EXAM: '进行中',
LACK_EXAM: '缺考', LACK_EXAM: '缺考',
FINISH_EXAM: '已考试' FINISH_EXAM: '已考试',
} };
const orderEnum = { const orderEnum = {
currentAccuracy: { currentAccuracy: {
ascend: 'ACCURACY_ASC', ascend: 'ACCURACY_ASC',
descend: 'ACCURACY_DESC' descend: 'ACCURACY_DESC',
}, },
};
}
const queryRef = useRef({}); const queryRef = useRef({});
useEffect(() => { useEffect(() => {
queryExamUserData(); queryExamUserData();
}, []) }, []);
useEffect(() => { useEffect(() => {
queryRef.current = query; queryRef.current = query;
queryExamUserDataList(); queryExamUserDataList();
}, [query]) }, [query]);
function queryExamUserData() { function queryExamUserData() {
Service.Hades('public/hades/queryExamQuestionData', { Service.Hades('public/hades/queryExamQuestionData', {
examId: props.examId, examId: props.examId,
tenantId: User.getStoreId(), tenantId: User.getStoreId(),
userId: User.getStoreUserId(), userId: User.getStoreUserId(),
source: 0 source: 0,
}).then((res) => { }).then((res) => {
setUserData(res.result) setUserData(res.result);
});
})
} }
function queryExamUserDataList() { function queryExamUserDataList() {
Service.Hades('public/hades/queryExamQuestionDataList', { Service.Hades('public/hades/queryExamQuestionDataList', {
...query, ...query,
examId: props.examId, examId: props.examId,
tenantId: User.getStoreId(), tenantId: User.getStoreId(),
userId: User.getStoreUserId(), userId: User.getStoreUserId(),
source: 0 source: 0,
}).then((res) => { }).then((res) => {
setList(res.result.records); setList(res.result.records);
setTotal(parseInt(res.result.total)) setTotal(parseInt(res.result.total));
if (!allData) { if (!allData) {
setAllData(parseInt(res.result.total)) setAllData(parseInt(res.result.total));
} }
}) });
} }
const columns = [ const columns = [
{ {
title: "序号", title: '序号',
dataIndex: "sort", dataIndex: 'sort',
width: 60, width: 60,
render: (text: any) => <span>{text + 1}</span>, render: (text: any, record: any, index: any) => <span>{index + 1}</span>,
}, },
{ {
title: "题目", title: '题目',
dataIndex: "questionStem", dataIndex: 'questionStem',
ellipsis: true, ellipsis: true,
width: 350, width: 350,
render: (val: any) => { render: (val: any) => {
var handleVal = val; var handleVal = val;
handleVal = handleVal.replace(/<(?!img|input).*?>/g, ""); handleVal = handleVal.replace(/<(?!img|input).*?>/g, '');
handleVal = handleVal.replace(/<\s?input[^>]*>/gi, "_、"); handleVal = handleVal.replace(/<\s?input[^>]*>/gi, '_、');
handleVal = handleVal.replace(/\&nbsp\;/gi, " "); handleVal = handleVal.replace(/\&nbsp\;/gi, ' ');
return ( return (
<Tooltip <Tooltip
overlayClassName="aid-tool-list" overlayClassName='aid-tool-list'
title={ title={<div style={{ maxWidth: 700, width: 'auto' }}>{handleVal}</div>}
<div style={{ maxWidth: 700, width: "auto" }}>{handleVal}</div> placement='topLeft'
} overlayStyle={{ maxWidth: 700 }}>
placement="topLeft"
overlayStyle={{ maxWidth: 700 }}
>
{handleVal} {handleVal}
</Tooltip> </Tooltip>
); );
}, },
}, },
{ {
title: "题型", title: '题型',
dataIndex: "questionType", dataIndex: 'questionType',
render: (text: any) => <span>{(questionTypeList as any)[text]}</span>, render: (text: any) => <span>{(questionTypeList as any)[text]}</span>,
filters: Object.keys(questionTypeList).map((key) => { filters: Object.keys(questionTypeList).map((key) => {
return { return {
text: (questionTypeList as any)[key], text: (questionTypeList as any)[key],
value: key value: key,
} };
}), }),
}, },
{ {
title: "本次正确率", title: '本次正确率',
dataIndex: "currentAccuracy", dataIndex: 'currentAccuracy',
sorter: true, sorter: true,
sortOrder: field === "currentAccuracy" ? order : sortStatus.type, sortOrder: field === 'currentAccuracy' ? order : sortStatus.type,
render: (text: any) => <span>{parseInt(text * 100 as any)}%</span>, render: (text: any) => <span>{parseInt((text * 100) as any)}%</span>,
}, },
{ {
title: <div>历史正确率 <Tooltip title: (
overlayClassName="tool-list" <div>
title='包含本次考试正确率' 历史正确率{' '}
placement="top" <Tooltip overlayClassName='tool-list' title='包含本次考试正确率' placement='top' overlayStyle={{ maxWidth: 700 }}>
overlayStyle={{ maxWidth: 700 }} {' '}
> <span style={{ color: 'rgba(191, 191, 191, 1)' }} className="icon iconfont">&#xe61d;</span> <span style={{ color: 'rgba(191, 191, 191, 1)' }} className='icon iconfont'>
&#xe61d;
</span>
</Tooltip> </Tooltip>
</div>, </div>
dataIndex: "totalAccuracy", ),
render: (text: any) => <span>{parseInt(text * 100 as any)}%</span>, dataIndex: 'totalAccuracy',
render: (text: any) => <span>{parseInt((text * 100) as any)}%</span>,
}, },
]; ];
function onChange(pagination: any, filters: any, sorter: any, extra: any) { function onChange(pagination: any, filters: any, sorter: any, extra: any) {
console.log(filters, sorter); console.log(filters, sorter);
setfield(sorter.field); setfield(sorter.field);
setOrder(sorter.order) setOrder(sorter.order);
console.log(sorter.field, sorter.order, (orderEnum as any)[sorter.field]) console.log(sorter.field, sorter.order, (orderEnum as any)[sorter.field]);
let _query: any = { ...queryRef.current }; let _query: any = { ...queryRef.current };
console.log(filters.questionType) console.log(filters.questionType);
if (filters.questionType) { if (filters.questionType) {
console.log(233232) console.log(233232);
_query.questionType = filters.questionType; _query.questionType = filters.questionType;
_query.current = 1; _query.current = 1;
} else { } else {
delete _query.questionType delete _query.questionType;
} }
_query.order = (orderEnum as any)[sorter.field][sorter.order] _query.order = (orderEnum as any)[sorter.field][sorter.order];
setQuery(_query) setQuery(_query);
} }
function download() { function download() {
Service.Hades('public/hades/exportExamData', { Service.Hades('public/hades/exportExamData', {
// ...query, // ...query,
...@@ -194,103 +180,102 @@ function ExamData(props: any) { ...@@ -194,103 +180,102 @@ function ExamData(props: any) {
exportDataType: 'EXAM_QUESTION_DATA', exportDataType: 'EXAM_QUESTION_DATA',
tenantId: User.getStoreId(), tenantId: User.getStoreId(),
userId: User.getStoreUserId(), userId: User.getStoreUserId(),
source: 0 source: 0,
}).then((res) => { }).then((res) => {
const dom = (document as any).getElementById("load-play-back-excel") const dom = (document as any).getElementById('load-play-back-excel');
dom.setAttribute('href', res.result); dom.setAttribute('href', res.result);
dom.click(); dom.click();
});
})
} }
return (
<div className='rr'>
return <div className="rr"> <a download id='load-play-back-excel' style={{ position: 'absolute', left: '-10000px' }}></a>
<a <div className='dataPanal'>
download {!!examData.singleChoiceCnt && (
id="load-play-back-excel" <div className='item'>
style={{ position: "absolute", left: "-10000px" }} <div className='num'>{Math.round((examData.singleChoiceAccuracy || 0) * 100)}%</div>
></a> <div className='percent'>正确率</div>
<div className="dataPanal"> <div className='subTitle'>
{ <div className='type'>
!!examData.singleChoiceCnt && <div className="item"> <span className='icon iconfont'>&#xe7fa;</span>单选题 <span>(共{examData.singleChoiceCnt}题)</span>
<div className="num">{Math.round((examData.singleChoiceAccuracy || 0) * 100)}%</div>
<div className="percent">正确率</div>
<div className="subTitle"><div className="type"><span className="icon iconfont">&#xe7fa;</span>单选题 <span>(共{examData.singleChoiceCnt}题)</span></div></div>
</div> </div>
}
{
!!examData.multiChoiceCnt && <div className="item">
<div className="num">{Math.round((examData.multiChoiceAccuracy || 0) * 100)}%</div>
<div className="percent">正确率</div>
<div className="subTitle"><div className="type"><span className="icon iconfont">&#xe7fb;</span>多选题<span>(共{examData.multiChoiceCnt}题)</span></div></div>
</div> </div>
}
{
!!examData.judgeCnt && <div className="item">
<div className="num">{Math.round((examData.judgeAccuracy || 0) * 100)}%</div>
<div className="percent">正确率</div>
<div className="subTitle"><div className="type"><span className="icon iconfont">&#xe7fc;</span>判断题<span>(共{examData.judgeCnt}题)</span></div></div>
</div> </div>
} )}
{!!examData.multiChoiceCnt && (
{ <div className='item'>
!!examData.gapFillingCnt && <div className="item"> <div className='num'>{Math.round((examData.multiChoiceAccuracy || 0) * 100)}%</div>
<div className="num">{Math.round((examData.gapFillingAccuracy || 0) * 100)}%</div> <div className='percent'>正确率</div>
<div className="percent">正确率</div> <div className='subTitle'>
<div className="subTitle"><div className="type"><span className="icon iconfont">&#xe7fd;</span>填空题<span>(共{examData.gapFillingCnt}题)</span></div></div> <div className='type'>
<span className='icon iconfont'>&#xe7fb;</span>多选题<span>(共{examData.multiChoiceCnt}题)</span>
</div> </div>
}
{
!!examData.indefiniteChoiceCnt && <div className="item">
<div className="num">{Math.round((examData.indefiniteChoiceAccuracy || 0) * 100)}%</div>
<div className="percent">正确率</div>
<div className="subTitle"><div className="type"><span className="icon iconfont">&#xe7fe;</span>不定项选择题 <span>(共{examData.indefiniteChoiceCnt}题)</span></div></div>
</div> </div>
}
</div> </div>
{ )}
!!allData && <Button style={{ marginBottom: 12, marginTop: 12 }} onClick={download} >导出</Button>
} {!!examData.judgeCnt && (
<div className='item'>
<div className='num'>{Math.round((examData.judgeAccuracy || 0) * 100)}%</div>
<div className="content"> <div className='percent'>正确率</div>
<Table <div className='subTitle'>
bordered <div className='type'>
size="small" <span className='icon iconfont'>&#xe7fc;</span>判断题<span>(共{examData.judgeCnt}题)</span>
columns={columns} </div>
dataSource={list} </div>
onChange={onChange} </div>
pagination={false} )}
> {!!examData.gapFillingCnt && (
</Table> <div className='item'>
{total > 0 && <div className='num'>{Math.round((examData.gapFillingAccuracy || 0) * 100)}%</div>
<div className='percent'>正确率</div>
<div className='subTitle'>
<div className='type'>
<span className='icon iconfont'>&#xe7fd;</span>填空题<span>(共{examData.gapFillingCnt}题)</span>
</div>
</div>
</div>
)}
{!!examData.indefiniteChoiceCnt && (
<div className='item'>
<div className='num'>{Math.round((examData.indefiniteChoiceAccuracy || 0) * 100)}%</div>
<div className='percent'>正确率</div>
<div className='subTitle'>
<div className='type'>
<span className='icon iconfont'>&#xe7fe;</span>不定项选择题 <span>(共{examData.indefiniteChoiceCnt}题)</span>
</div>
</div>
</div>
)}
</div>
{!!allData && (
<Button style={{ marginBottom: 12, marginTop: 12 }} onClick={download}>
导出
</Button>
)}
<div className='content'>
<Table bordered size='small' columns={columns} dataSource={list} onChange={onChange} pagination={false}></Table>
{total > 0 && (
<PageControl <PageControl
size="small" size='small'
current={query.current - 1} current={query.current - 1}
pageSize={query.size} pageSize={query.size}
total={total} total={total}
toPage={(page: any) => { toPage={(page: any) => {
console.log(page) console.log(page);
let _query: any = { ...queryRef.current }; let _query: any = { ...queryRef.current };
_query.current = page + 1; _query.current = page + 1;
setQuery(_query) setQuery(_query);
}} }}
/> />
} )}
</div> </div>
</div> </div>
);
} }
export default ExamData; export default ExamData;
/* /*
* @Author: yuananting * @Author: yuananting
* @Date: 2021-03-27 16:15:13 * @Date: 2021-03-27 16:15:13
* @LastEditors: yuananting * @LastEditors: fusanqiasng
* @LastEditTime: 2021-06-10 19:57:55 * @LastEditTime: 2021-07-01 16:30:38
* @Description: 助学工具-新建/复制/编辑试卷 * @Description: 助学工具-新建/复制/编辑试卷
* @Copyrigh: © 2020 杭州杰竞科技有限公司 版权所有 * @Copyrigh: © 2020 杭州杰竞科技有限公司 版权所有
*/ */
import React, { Component } from "react"; import React, { Component } from 'react';
import { import { Form, Button, Input, Table, InputNumber, ConfigProvider, Empty, Tooltip, message, Modal, Spin, Space, Radio } from 'antd';
Form, import { PlusOutlined } from '@ant-design/icons';
Button, import { XMTable } from '@/components';
Input, import ShowTips from '@/components/ShowTips';
Table, import Breadcrumbs from '@/components/Breadcrumbs';
InputNumber, import './OperatePaper.less';
ConfigProvider, import SelectQuestionModal from './modal/SelectQuestionModal';
Empty, import PaperPreviewModal from './modal/PreviewPaperModal';
Tooltip, import User from '@/common/js/user';
message, import AidToolService from '@/domains/aid-tool-domain/AidToolService';
Modal, import Bus from '@/core/bus';
Spin, import _ from 'underscore';
Space, import { Route, withRouter } from 'react-router-dom';
Radio,
} from "antd";
import { PlusOutlined } from "@ant-design/icons";
import { XMTable } from "@/components";
import ShowTips from "@/components/ShowTips";
import Breadcrumbs from "@/components/Breadcrumbs";
import "./OperatePaper.less";
import SelectQuestionModal from "./modal/SelectQuestionModal";
import PaperPreviewModal from "./modal/PreviewPaperModal";
import User from "@/common/js/user";
import AidToolService from "@/domains/aid-tool-domain/AidToolService";
import Bus from "@/core/bus";
import _ from "underscore";
import { Route, withRouter } from "react-router-dom";
import * as paperEmpty from '../../lottie/paperEmpty/data.json'; import * as paperEmpty from '../../lottie/paperEmpty/data.json';
import AddExam from "@/modules/teach-tool/examination-manager/AddExam"; import AddExam from '@/modules/teach-tool/examination-manager/AddExam';
const questionTypeEnum = { const questionTypeEnum = {
SINGLE_CHOICE: "单选题", SINGLE_CHOICE: '单选题',
MULTI_CHOICE: "多选题", MULTI_CHOICE: '多选题',
JUDGE: "判断题", JUDGE: '判断题',
GAP_FILLING: "填空题", GAP_FILLING: '填空题',
INDEFINITE_CHOICE: "不定项选择题", INDEFINITE_CHOICE: '不定项选择题',
}; };
class OperatePaper extends Component { class OperatePaper extends Component {
formRef = React.createRef(); formRef = React.createRef();
...@@ -50,7 +36,7 @@ class OperatePaper extends Component { ...@@ -50,7 +36,7 @@ class OperatePaper extends Component {
super(props); super(props);
this.state = { this.state = {
formData: { formData: {
categoryId: getParameterByName("categoryId"), // 分类ID categoryId: getParameterByName('categoryId'), // 分类ID
singleChoiceCnt: 0, // 单选题数量 singleChoiceCnt: 0, // 单选题数量
multiChoiceCnt: 0, // 多选题数量 multiChoiceCnt: 0, // 多选题数量
judgeCnt: 0, // 判断题数量 judgeCnt: 0, // 判断题数量
...@@ -75,34 +61,28 @@ class OperatePaper extends Component { ...@@ -75,34 +61,28 @@ class OperatePaper extends Component {
paperPreviewModal: null, paperPreviewModal: null,
quickSortModalVisible: false, // 快捷排序弹窗显隐 quickSortModalVisible: false, // 快捷排序弹窗显隐
selectQuestionList: [], selectQuestionList: [],
currentOperate: "", currentOperate: '',
currentNav: "", currentNav: '',
currentCategoryPapers: [], currentCategoryPapers: [],
loading: false, loading: false,
check: false, check: false,
sorterMethod: "addOrder", sorterMethod: 'addOrder',
sorterBy: [ sorterBy: ['SINGLE_CHOICE', 'MULTI_CHOICE', 'JUDGE', 'GAP_FILLING', 'INDEFINITE_CHOICE'],
"SINGLE_CHOICE",
"MULTI_CHOICE",
"JUDGE",
"GAP_FILLING",
"INDEFINITE_CHOICE",
],
sorterTypeList: [ sorterTypeList: [
{ {
typeKey: "SINGLE_CHOICE", typeKey: 'SINGLE_CHOICE',
}, },
{ {
typeKey: "MULTI_CHOICE", typeKey: 'MULTI_CHOICE',
}, },
{ {
typeKey: "JUDGE", typeKey: 'JUDGE',
}, },
{ {
typeKey: "GAP_FILLING", typeKey: 'GAP_FILLING',
}, },
{ {
typeKey: "INDEFINITE_CHOICE", typeKey: 'INDEFINITE_CHOICE',
}, },
], ],
}; };
...@@ -110,30 +90,26 @@ class OperatePaper extends Component { ...@@ -110,30 +90,26 @@ class OperatePaper extends Component {
componentDidMount() { componentDidMount() {
this.queryCurrentCategoryPapers(); this.queryCurrentCategoryPapers();
switch (getParameterByName("type")) { switch (getParameterByName('type')) {
case "new": case 'new':
this.setState({ currentOperate: "new", currentNav: "新建试卷" }); this.setState({ currentOperate: 'new', currentNav: '新建试卷' });
break; break;
case "edit": case 'edit':
this.setState({ currentOperate: "edit", currentNav: "编辑试卷" }, () => this.setState({ currentOperate: 'edit', currentNav: '编辑试卷' }, () => this.queryPaperDetail('edit'));
this.queryPaperDetail()
);
break; break;
case "copy": case 'copy':
this.setState({ currentOperate: "copy", currentNav: "复制试卷" }, () => this.setState({ currentOperate: 'copy', currentNav: '复制试卷' }, () => this.queryPaperDetail('copy'));
this.queryPaperDetail()
);
break; break;
} }
} }
// 获取当前分类下的所有试卷 // 获取当前分类下的所有试卷
queryCurrentCategoryPapers = () => { queryCurrentCategoryPapers = () => {
const categoryId = getParameterByName("categoryId"); const categoryId = getParameterByName('categoryId');
let params = { let params = {
current: 1, current: 1,
size: 9999, size: 9999,
categoryId: categoryId === "null" ? null : categoryId, categoryId: categoryId === 'null' ? null : categoryId,
paperName: null, // 试卷名称 paperName: null, // 试卷名称
source: 0, source: 0,
tenantId: User.getStoreId(), tenantId: User.getStoreId(),
...@@ -146,14 +122,15 @@ class OperatePaper extends Component { ...@@ -146,14 +122,15 @@ class OperatePaper extends Component {
}; };
// 编辑/复制试卷时获取相应试卷详情 // 编辑/复制试卷时获取相应试卷详情
queryPaperDetail = async () => { queryPaperDetail = async (flag) => {
this.setState({ loading: true }); this.setState({ loading: true });
const { currentOperate } = this.state; const { currentOperate } = this.state;
let query = { let query = {
paperId: getParameterByName("paperId"), paperId: getParameterByName('paperId'),
source: 0, source: 0,
userId: User.getStoreUserId(), userId: User.getStoreUserId(),
tenantId: User.getStoreId(), tenantId: User.getStoreId(),
flag: flag === 'copy',
}; };
const res = await AidToolService.queryPaperDetail(query); const res = await AidToolService.queryPaperDetail(query);
const { result } = res; const { result } = res;
...@@ -163,9 +140,8 @@ class OperatePaper extends Component { ...@@ -163,9 +140,8 @@ class OperatePaper extends Component {
selectQuestionList: questionList, selectQuestionList: questionList,
formData: { formData: {
...result, ...result,
paperId: getParameterByName("paperId"), paperId: getParameterByName('paperId'),
paperName: paperName: currentOperate === 'copy' ? paperName + '(复制)' : paperName,
currentOperate === "copy" ? paperName + "(复制)" : paperName,
}, },
loading: false, loading: false,
}, },
...@@ -188,26 +164,11 @@ class OperatePaper extends Component { ...@@ -188,26 +164,11 @@ class OperatePaper extends Component {
const _selectQuestionList = [...list]; const _selectQuestionList = [...list];
// 各类型题目汇总 // 各类型题目汇总
const singleQuestion = _.filter( const singleQuestion = _.filter(_selectQuestionList, (item) => item.questionType === 'SINGLE_CHOICE');
_selectQuestionList, const multiQuestion = _.filter(_selectQuestionList, (item) => item.questionType === 'MULTI_CHOICE');
(item) => item.questionType === "SINGLE_CHOICE" const judgeQuestion = _.filter(_selectQuestionList, (item) => item.questionType === 'JUDGE');
); const gapQuestion = _.filter(_selectQuestionList, (item) => item.questionType === 'GAP_FILLING');
const multiQuestion = _.filter( const indefiniteQuestion = _.filter(_selectQuestionList, (item) => item.questionType === 'INDEFINITE_CHOICE');
_selectQuestionList,
(item) => item.questionType === "MULTI_CHOICE"
);
const judgeQuestion = _.filter(
_selectQuestionList,
(item) => item.questionType === "JUDGE"
);
const gapQuestion = _.filter(
_selectQuestionList,
(item) => item.questionType === "GAP_FILLING"
);
const indefiniteQuestion = _.filter(
_selectQuestionList,
(item) => item.questionType === "INDEFINITE_CHOICE"
);
// 各类型题目总分值 // 各类型题目总分值
const singleChoiceScore = singleQuestion.reduce((prev, cur) => { const singleChoiceScore = singleQuestion.reduce((prev, cur) => {
...@@ -277,9 +238,7 @@ class OperatePaper extends Component { ...@@ -277,9 +238,7 @@ class OperatePaper extends Component {
const selectQuestionList = [...this.state.selectQuestionList]; const selectQuestionList = [...this.state.selectQuestionList];
const item = selectQuestionList.splice(index + moveLength, 1); const item = selectQuestionList.splice(index + moveLength, 1);
selectQuestionList.splice(index, 0, item[0]); selectQuestionList.splice(index, 0, item[0]);
this.setState({ selectQuestionList }, () => this.setState({ selectQuestionList }, () => this.setFormData(this.state.selectQuestionList));
this.setFormData(this.state.selectQuestionList)
);
}; };
// 移除已选题目 // 移除已选题目
...@@ -287,9 +246,7 @@ class OperatePaper extends Component { ...@@ -287,9 +246,7 @@ class OperatePaper extends Component {
const { selectQuestionList } = this.state; const { selectQuestionList } = this.state;
this.setState( this.setState(
{ {
selectQuestionList: [...selectQuestionList].filter( selectQuestionList: [...selectQuestionList].filter((item) => item.questionId !== delQuestionId),
(item) => item.questionId !== delQuestionId
),
}, },
() => this.setFormData(this.state.selectQuestionList) () => this.setFormData(this.state.selectQuestionList)
); );
...@@ -303,15 +260,12 @@ class OperatePaper extends Component { ...@@ -303,15 +260,12 @@ class OperatePaper extends Component {
if (result != null) { if (result != null) {
return result; return result;
} }
if (["new", "copy"].includes(currentOperate)) { if (['new', 'copy'].includes(currentOperate)) {
if (item.paperName === paperName) { if (item.paperName === paperName) {
result = item; result = item;
} }
} else if (currentOperate === "edit") { } else if (currentOperate === 'edit') {
if ( if (item.paperName === paperName && item.paperId !== getParameterByName('paperId')) {
item.paperName === paperName &&
item.paperId !== getParameterByName("paperId")
) {
result = item; result = item;
} }
} }
...@@ -321,15 +275,15 @@ class OperatePaper extends Component { ...@@ -321,15 +275,15 @@ class OperatePaper extends Component {
validatePaperName = (paperName) => { validatePaperName = (paperName) => {
if (this.state.check && !paperName) { if (this.state.check && !paperName) {
return "请输入试卷名称"; return '请输入试卷名称';
} }
if (this.checkExist(paperName)) { if (this.checkExist(paperName)) {
return "该试卷名称已存在"; return '该试卷名称已存在';
} }
if (paperName && paperName.length > 40) { if (paperName && paperName.length > 40) {
return "试卷名称最多40字"; return '试卷名称最多40字';
} }
}; };
...@@ -337,19 +291,14 @@ class OperatePaper extends Component { ...@@ -337,19 +291,14 @@ class OperatePaper extends Component {
savePaper = (saveType) => { savePaper = (saveType) => {
this.setState({ check: true }); this.setState({ check: true });
const { selectQuestionList, formData, currentOperate } = this.state; const { selectQuestionList, formData, currentOperate } = this.state;
const categoryId = getParameterByName("categoryId"); const categoryId = getParameterByName('categoryId');
const { match } = this.props; const { match } = this.props;
let questionList = []; let questionList = [];
if ( if (!formData.passRate || !formData.paperName || this.checkExist(formData.paperName) || (formData.paperName && formData.paperName.length > 40)) {
!formData.passRate ||
!formData.paperName ||
this.checkExist(formData.paperName) ||
(formData.paperName && formData.paperName.length > 40)
) {
return; return;
} }
if (selectQuestionList.length === 0) { if (selectQuestionList.length === 0) {
return message.warning("请选择题目"); return message.warning('请选择题目');
} }
selectQuestionList.forEach((item, index) => { selectQuestionList.forEach((item, index) => {
...@@ -370,29 +319,23 @@ class OperatePaper extends Component { ...@@ -370,29 +319,23 @@ class OperatePaper extends Component {
}, },
}, },
() => { () => {
if (["new", "copy"].includes(currentOperate)) { if (['new', 'copy'].includes(currentOperate)) {
AidToolService.createPaper(this.state.formData) AidToolService.createPaper(this.state.formData)
.then((res) => { .then((res) => {
if (res.success) { if (res.success) {
if (saveType === "saveToAddExam") { if (saveType === 'saveToAddExam') {
this.setState({formData:{ ...formData, paperId: res.result}},() => { this.setState({ formData: { ...formData, paperId: res.result } }, () => {
window.RCHistory.push({ window.RCHistory.push({
pathname: `${match.url}/exam-operate-page`, pathname: `${match.url}/exam-operate-page`,
}); });
}) });
} else { } else {
message.success( message.success(currentOperate === 'new' ? '新建成功' : '复制成功');
currentOperate === "new" ? "新建成功" : "复制成功"
);
window.RCHistory.push({ window.RCHistory.push({
pathname: `/paper-manage-index?categoryId=${categoryId}`, pathname: `/paper-manage-index?categoryId=${categoryId}`,
}); });
Bus.trigger( Bus.trigger('queryPaperPageList', categoryId, selectQuestionList.length);
"queryPaperPageList", Bus.trigger('queryCategoryTree', 'remain');
categoryId,
selectQuestionList.length
);
Bus.trigger("queryCategoryTree", "remain");
} }
} }
}) })
...@@ -400,34 +343,26 @@ class OperatePaper extends Component { ...@@ -400,34 +343,26 @@ class OperatePaper extends Component {
window.RCHistory.push({ window.RCHistory.push({
pathname: `/paper-manage-index?categoryId=${categoryId}`, pathname: `/paper-manage-index?categoryId=${categoryId}`,
}); });
Bus.trigger( Bus.trigger('queryPaperPageList', categoryId, selectQuestionList.length);
"queryPaperPageList", Bus.trigger('queryCategoryTree', 'remain');
categoryId,
selectQuestionList.length
);
Bus.trigger("queryCategoryTree", "remain");
}); });
} else if (currentOperate === "edit") { } else if (currentOperate === 'edit') {
AidToolService.editPaper({ AidToolService.editPaper({
...this.state.formData, ...this.state.formData,
paperId: getParameterByName("paperId"), paperId: getParameterByName('paperId'),
}) })
.then((res) => { .then((res) => {
if (res.success) { if (res.success) {
if (saveType === "saveToAddExam") { if (saveType === 'saveToAddExam') {
window.RCHistory.push({ window.RCHistory.push({
pathname: `${match.url}/exam-operate-page`, pathname: `${match.url}/exam-operate-page`,
}); });
} else { } else {
message.success("编辑成功"); message.success('编辑成功');
window.RCHistory.push({ window.RCHistory.push({
pathname: `/paper-manage-index?categoryId=${categoryId}`, pathname: `/paper-manage-index?categoryId=${categoryId}`,
}); });
Bus.trigger( Bus.trigger('queryPaperPageList', categoryId, selectQuestionList.length);
"queryPaperPageList",
categoryId,
selectQuestionList.length
);
} }
} }
}) })
...@@ -435,11 +370,7 @@ class OperatePaper extends Component { ...@@ -435,11 +370,7 @@ class OperatePaper extends Component {
window.RCHistory.push({ window.RCHistory.push({
pathname: `/paper-manage-index?categoryId=${categoryId}`, pathname: `/paper-manage-index?categoryId=${categoryId}`,
}); });
Bus.trigger( Bus.trigger('queryPaperPageList', categoryId, selectQuestionList.length);
"queryPaperPageList",
categoryId,
selectQuestionList.length
);
}); });
} }
} }
...@@ -451,7 +382,7 @@ class OperatePaper extends Component { ...@@ -451,7 +382,7 @@ class OperatePaper extends Component {
const { selectQuestionList, formData } = this.state; const { selectQuestionList, formData } = this.state;
const m = ( const m = (
<PaperPreviewModal <PaperPreviewModal
previewPage="paper-operate" previewPage='paper-operate'
paperInfo={{ ...formData, questionList: selectQuestionList }} paperInfo={{ ...formData, questionList: selectQuestionList }}
close={() => { close={() => {
this.setState({ this.setState({
...@@ -466,21 +397,17 @@ class OperatePaper extends Component { ...@@ -466,21 +397,17 @@ class OperatePaper extends Component {
// 取消/返回 // 取消/返回
handleGoBack = () => { handleGoBack = () => {
Modal.confirm({ Modal.confirm({
title: "确定要返回吗?", title: '确定要返回吗?',
content: "返回后,本次编辑的内容将不被保存", content: '返回后,本次编辑的内容将不被保存',
okText: "确认返回", okText: '确认返回',
cancelText: "留在本页", cancelText: '留在本页',
icon: ( icon: <span className='icon iconfont default-confirm-icon'>&#xe6f4;</span>,
<span className="icon iconfont default-confirm-icon">&#xe6f4;</span>
),
onOk: () => { onOk: () => {
window.RCHistory.push({ window.RCHistory.push({
pathname: `/paper-manage-index?categoryId=${getParameterByName( pathname: `/paper-manage-index?categoryId=${getParameterByName('categoryId')}`,
"categoryId"
)}`,
}); });
Bus.trigger("queryCategoryTree", "remain"); Bus.trigger('queryCategoryTree', 'remain');
Bus.trigger("queryPaperPageList", getParameterByName("categoryId"), 0); Bus.trigger('queryPaperPageList', getParameterByName('categoryId'), 0);
}, },
}); });
}; };
...@@ -490,39 +417,39 @@ class OperatePaper extends Component { ...@@ -490,39 +417,39 @@ class OperatePaper extends Component {
const { selectQuestionList } = this.state; const { selectQuestionList } = this.state;
const columns = [ const columns = [
{ {
title: "序号", title: '序号',
dataIndex: "index", dataIndex: 'index',
key: "index", key: 'index',
width: "10%", width: '10%',
render: (val, record, index) => { render: (val, record, index) => {
return <span>{index + 1}</span>; return <span>{index + 1}</span>;
}, },
}, },
{ {
title: "题型", title: '题型',
dataIndex: "questionType", dataIndex: 'questionType',
key: "questionType", key: 'questionType',
width: "12%", width: '12%',
filters: [ filters: [
{ {
text: "单选题", text: '单选题',
value: "SINGLE_CHOICE", value: 'SINGLE_CHOICE',
}, },
{ {
text: "多选题", text: '多选题',
value: "MULTI_CHOICE", value: 'MULTI_CHOICE',
}, },
{ {
text: "判断题", text: '判断题',
value: "JUDGE", value: 'JUDGE',
}, },
{ {
text: "填空题", text: '填空题',
value: "GAP_FILLING", value: 'GAP_FILLING',
}, },
{ {
text: "不定项选择题", text: '不定项选择题',
value: "INDEFINITE_CHOICE", value: 'INDEFINITE_CHOICE',
}, },
], ],
filterMultiple: true, filterMultiple: true,
...@@ -530,26 +457,23 @@ class OperatePaper extends Component { ...@@ -530,26 +457,23 @@ class OperatePaper extends Component {
render: (val) => questionTypeEnum[val], render: (val) => questionTypeEnum[val],
}, },
{ {
title: "题目", title: '题目',
dataIndex: "questionStem", dataIndex: 'questionStem',
key: "questionStem", key: 'questionStem',
ellipsis: { ellipsis: {
showTitle: false, showTitle: false,
}, },
render: (val) => { render: (val) => {
var handleVal = val; var handleVal = val;
handleVal = handleVal.replace(/<(?!img|input).*?>/g, ""); handleVal = handleVal.replace(/<(?!img|input).*?>/g, '');
handleVal = handleVal.replace(/<\s?input[^>]*>/gi, "_、"); handleVal = handleVal.replace(/<\s?input[^>]*>/gi, '_、');
handleVal = handleVal.replace(/\&nbsp\;/gi, " "); handleVal = handleVal.replace(/\&nbsp\;/gi, ' ');
return ( return (
<Tooltip <Tooltip
overlayClassName="aid-tool-list" overlayClassName='aid-tool-list'
title={ title={<div style={{ maxWidth: 700, width: 'auto' }}>{handleVal}</div>}
<div style={{ maxWidth: 700, width: "auto" }}>{handleVal}</div> placement='topLeft'
} overlayStyle={{ maxWidth: 700 }}>
placement="topLeft"
overlayStyle={{ maxWidth: 700 }}
>
{handleVal} {handleVal}
</Tooltip> </Tooltip>
); );
...@@ -558,20 +482,17 @@ class OperatePaper extends Component { ...@@ -558,20 +482,17 @@ class OperatePaper extends Component {
{ {
title: ( title: (
<span> <span>
分值{" "} 分值{' '}
<Tooltip title="多选题和填空题的漏选/半对得分不能高于题目本身分值"> <Tooltip title='多选题和填空题的漏选/半对得分不能高于题目本身分值'>
<span <span className='icon iconfont' style={{ color: '#BFBFBF', fontSize: 14, fontWeight: '400' }}>
className="icon iconfont"
style={{ color: "#BFBFBF", fontSize: 14, fontWeight: "400" }}
>
&#xe7c4; &#xe7c4;
</span> </span>
</Tooltip> </Tooltip>
</span> </span>
), ),
dataIndex: "score", dataIndex: 'score',
key: "score", key: 'score',
width: "12%", width: '12%',
render: (val, record, index) => { render: (val, record, index) => {
return ( return (
<InputNumber <InputNumber
...@@ -582,11 +503,7 @@ class OperatePaper extends Component { ...@@ -582,11 +503,7 @@ class OperatePaper extends Component {
const _selectQuestionList = [...selectQuestionList]; const _selectQuestionList = [...selectQuestionList];
this.setState( this.setState(
{ {
selectQuestionList: _selectQuestionList.map((item) => selectQuestionList: _selectQuestionList.map((item) => (item.questionId === record.questionId ? { ...item, score: value } : item)),
item.questionId === record.questionId
? { ...item, score: value }
: item
),
}, },
() => this.setFormData(this.state.selectQuestionList) () => this.setFormData(this.state.selectQuestionList)
); );
...@@ -596,20 +513,14 @@ class OperatePaper extends Component { ...@@ -596,20 +513,14 @@ class OperatePaper extends Component {
}, },
}, },
{ {
dataIndex: "portionScore", dataIndex: 'portionScore',
key: "portionScore", key: 'portionScore',
width: "18%", width: '18%',
render: (val, record, index) => { render: (val, record, index) => {
return ( return (
["MULTI_CHOICE", "GAP_FILLING", "INDEFINITE_CHOICE"].includes( ['MULTI_CHOICE', 'GAP_FILLING', 'INDEFINITE_CHOICE'].includes(record.questionType) && (
record.questionType
) && (
<div> <div>
{record.questionType === "GAP_FILLING" ? ( {record.questionType === 'GAP_FILLING' ? <span>半对得</span> : <span>漏选得</span>}{' '}
<span>半对得</span>
) : (
<span>漏选得</span>
)}{" "}
<InputNumber <InputNumber
min={0} min={0}
max={record.score - 1} max={record.score - 1}
...@@ -619,9 +530,7 @@ class OperatePaper extends Component { ...@@ -619,9 +530,7 @@ class OperatePaper extends Component {
this.setState( this.setState(
{ {
selectQuestionList: _selectQuestionList.map((item) => selectQuestionList: _selectQuestionList.map((item) =>
item.questionId === record.questionId item.questionId === record.questionId ? { ...item, portionScore: value } : item
? { ...item, portionScore: value }
: item
), ),
}, },
() => this.setFormData(this.state.selectQuestionList) () => this.setFormData(this.state.selectQuestionList)
...@@ -634,43 +543,34 @@ class OperatePaper extends Component { ...@@ -634,43 +543,34 @@ class OperatePaper extends Component {
}, },
}, },
{ {
title: "操作", title: '操作',
dataIndex: "operate", dataIndex: 'operate',
key: "operate", key: 'operate',
width: "16%", width: '16%',
render: (val, record, index) => { render: (val, record, index) => {
return ( return (
<div className="record-operate"> <div className='record-operate'>
<div <div
className={ className={index > 0 ? 'record-operate__item' : 'record-operate__ban'}
index > 0 ? "record-operate__item" : "record-operate__ban"
}
onClick={() => { onClick={() => {
this.handleMoveItem(index, -1); this.handleMoveItem(index, -1);
}} }}>
>
上移 上移
</div> </div>
<span className="record-operate__item split"> | </span> <span className='record-operate__item split'> | </span>
<div <div
className={ className={index < selectQuestionList.length - 1 ? 'record-operate__item' : 'record-operate__ban'}
index < selectQuestionList.length - 1
? "record-operate__item"
: "record-operate__ban"
}
onClick={() => { onClick={() => {
this.handleMoveItem(index, 1); this.handleMoveItem(index, 1);
}} }}>
>
下移 下移
</div> </div>
<span className="record-operate__item split"> | </span> <span className='record-operate__item split'> | </span>
<div <div
className="record-operate__item" className='record-operate__item'
onClick={() => { onClick={() => {
this.handleDelItem(record.questionId); this.handleDelItem(record.questionId);
}} }}>
>
移除 移除
</div> </div>
</div> </div>
...@@ -686,7 +586,7 @@ class OperatePaper extends Component { ...@@ -686,7 +586,7 @@ class OperatePaper extends Component {
const sorterTypeList = [...this.state.sorterTypeList]; const sorterTypeList = [...this.state.sorterTypeList];
const item = sorterTypeList.splice(index + moveLength, 1); const item = sorterTypeList.splice(index + moveLength, 1);
sorterTypeList.splice(index, 0, item[0]); sorterTypeList.splice(index, 0, item[0]);
const sorterBy = _.pluck(sorterTypeList, "typeKey"); const sorterBy = _.pluck(sorterTypeList, 'typeKey');
this.setState({ sorterTypeList, sorterBy }); this.setState({ sorterTypeList, sorterBy });
}; };
...@@ -694,13 +594,9 @@ class OperatePaper extends Component { ...@@ -694,13 +594,9 @@ class OperatePaper extends Component {
quickSorter = (list, sorterMethod, sorterBy) => { quickSorter = (list, sorterMethod, sorterBy) => {
this.setState({ this.setState({
selectQuestionList: selectQuestionList:
sorterMethod === "addOrder" sorterMethod === 'addOrder'
? list.sort((a, b) => a.sorterIndex - b.sorterIndex) ? list.sort((a, b) => a.sorterIndex - b.sorterIndex)
: list.sort( : list.sort((a, b) => sorterBy.indexOf(a.questionTypeEnum || a.questionType) - sorterBy.indexOf(b.questionTypeEnum || b.questionType)),
(a, b) =>
sorterBy.indexOf(a.questionTypeEnum || a.questionType) -
sorterBy.indexOf(b.questionTypeEnum || b.questionType)
),
}); });
}; };
...@@ -739,41 +635,39 @@ class OperatePaper extends Component { ...@@ -739,41 +635,39 @@ class OperatePaper extends Component {
const selectQuestionList = [...this.state.selectQuestionList]; const selectQuestionList = [...this.state.selectQuestionList];
const questionTypeEnum = { const questionTypeEnum = {
SINGLE_CHOICE: "【单选题】", SINGLE_CHOICE: '【单选题】',
MULTI_CHOICE: "【多选题】", MULTI_CHOICE: '【多选题】',
JUDGE: "【判断题】", JUDGE: '【判断题】',
GAP_FILLING: "【填空题】", GAP_FILLING: '【填空题】',
INDEFINITE_CHOICE: "【不定项选择题】", INDEFINITE_CHOICE: '【不定项选择题】',
}; };
const typeColumns = [ const typeColumns = [
{ {
title: "题型", title: '题型',
dataIndex: "typeKey", dataIndex: 'typeKey',
key: "typeKey", key: 'typeKey',
render: (text, record, index) => <span style={{color: '#333333'}}>{questionTypeEnum[text]}</span>, render: (text, record, index) => <span style={{ color: '#333333' }}>{questionTypeEnum[text]}</span>,
}, },
{ {
title: "操作", title: '操作',
key: "action", key: 'action',
align: 'right', align: 'right',
render: (text, record, index) => ( render: (text, record, index) => (
<Space size="middle"> <Space size='middle'>
<span <span
style={{color: index > 0 ? '#2966FF' : '#CCCCCC', cursor: 'pointer'}} style={{ color: index > 0 ? '#2966FF' : '#CCCCCC', cursor: 'pointer' }}
onClick={() => { onClick={() => {
index > 0 && this.handleMoveTypeSorter(index, -1); index > 0 && this.handleMoveTypeSorter(index, -1);
}} }}>
>
上移 上移
</span> </span>
<span style={{color: '#BFBFBF'}}> | </span> <span style={{ color: '#BFBFBF' }}> | </span>
<span <span
style={{color: index < 4 ? '#2966FF' : '#CCCCCC', cursor: 'pointer'}} style={{ color: index < 4 ? '#2966FF' : '#CCCCCC', cursor: 'pointer' }}
onClick={() => { onClick={() => {
index < 4 && this.handleMoveTypeSorter(index, 1); index < 4 && this.handleMoveTypeSorter(index, 1);
}} }}>
>
下移 下移
</span> </span>
</Space> </Space>
...@@ -782,32 +676,26 @@ class OperatePaper extends Component { ...@@ -782,32 +676,26 @@ class OperatePaper extends Component {
]; ];
return ( return (
<div> <div>
<div className="page operate-paper-page"> <div className='page operate-paper-page'>
<Breadcrumbs <Breadcrumbs navList={currentNav} goBack={() => this.handleGoBack()} />
navList={currentNav}
goBack={() => this.handleGoBack()}
/>
<Spin spinning={loading}> <Spin spinning={loading}>
<div className="box"> <div className='box'>
<div className="show-tips"> <div className='show-tips'>
<ShowTips message="请遵守国家相关规定,切勿上传低俗色情、暴力恐怖、谣言诈骗、侵权盗版等相关内容,小麦企学院保有依据国家规定及平台规则进行处理的权利" /> <ShowTips message='请遵守国家相关规定,切勿上传低俗色情、暴力恐怖、谣言诈骗、侵权盗版等相关内容,小麦企学院保有依据国家规定及平台规则进行处理的权利' />
</div> </div>
<Form ref={this.formRef} style={{ marginTop: 24 }}> <Form ref={this.formRef} style={{ marginTop: 24 }}>
<Form.Item <Form.Item
name="paperName" name='paperName'
label="试卷名称:" label='试卷名称:'
required required
validateStatus={ validateStatus={this.validatePaperName(paperName) ? 'error' : ''}
this.validatePaperName(paperName) ? "error" : "" help={this.validatePaperName(paperName)}>
}
help={this.validatePaperName(paperName)}
>
<Input <Input
value={paperName} value={paperName}
autoComplete="off" autoComplete='off'
maxLength={40} maxLength={40}
style={{ width: 300 }} style={{ width: 300 }}
placeholder="请输入试卷名称(40字以内)" placeholder='请输入试卷名称(40字以内)'
onChange={(e) => { onChange={(e) => {
this.setState({ this.setState({
formData: { formData: {
...@@ -820,12 +708,11 @@ class OperatePaper extends Component { ...@@ -820,12 +708,11 @@ class OperatePaper extends Component {
</Form.Item> </Form.Item>
<Form.Item <Form.Item
name="passRate" name='passRate'
label="及格线:" label='及格线:'
required required
validateStatus={check && !passRate ? "error" : ""} validateStatus={check && !passRate ? 'error' : ''}
help={check && !passRate && "请输入及格线"} help={check && !passRate && '请输入及格线'}>
>
<div> <div>
<InputNumber <InputNumber
min={1} min={1}
...@@ -842,9 +729,9 @@ class OperatePaper extends Component { ...@@ -842,9 +729,9 @@ class OperatePaper extends Component {
() => this.setFormData(selectQuestionList) () => this.setFormData(selectQuestionList)
); );
}} }}
/>{" "} />{' '}
% %
<span className="score-info"> <span className='score-info'>
总分({Number(totalScore) || 0})*及格线( 总分({Number(totalScore) || 0})*及格线(
{Number(passRate) || 0} {Number(passRate) || 0}
%)=及格分数( %)=及格分数(
...@@ -853,47 +740,33 @@ class OperatePaper extends Component { ...@@ -853,47 +740,33 @@ class OperatePaper extends Component {
</div> </div>
</Form.Item> </Form.Item>
<Space size={8}> <Space size={8}>
<Button <Button className='choose-btn' type='primary' icon={<PlusOutlined />} onClick={this.chooseQuestion}>
className="choose-btn"
type="primary"
icon={<PlusOutlined />}
onClick={this.chooseQuestion}
>
自选题目 自选题目
</Button> </Button>
<Button <Button
className="choose-btn" className='choose-btn'
onClick={() => { onClick={() => {
this.setState({ this.setState({
quickSortModalVisible: true, quickSortModalVisible: true,
}); });
}} }}>
>
快捷排序 快捷排序
</Button> </Button>
</Space> </Space>
{questionCnt > 0 && ( {questionCnt > 0 && (
<div <div className='paper-info-tip' style={{ margin: '0 auto 12px' }}>
className="paper-info-tip"
style={{ margin: "0 auto 12px" }}
>
总计<span>{totalScore}</span>分,共 总计<span>{totalScore}</span>分,共
<span>{questionCnt}</span> <span>{questionCnt}</span>
题。{" "} 题。 {singleChoiceCnt > 0 && `单选题${singleChoiceCnt}题,共${singleChoiceScore}分;`}
{singleChoiceCnt > 0 && {multiChoiceCnt > 0 && `多选题${multiChoiceCnt}题,共${multiChoiceScore}分;`}
`单选题${singleChoiceCnt}题,共${singleChoiceScore}分;`}
{multiChoiceCnt > 0 &&
`多选题${multiChoiceCnt}题,共${multiChoiceScore}分;`}
{judgeCnt > 0 && `判断题${judgeCnt}题,共${judgeScore}分,`} {judgeCnt > 0 && `判断题${judgeCnt}题,共${judgeScore}分,`}
{gapFillingCnt > 0 && {gapFillingCnt > 0 && `填空题${gapFillingCnt}题,共${gapFillingScore}分,`}
`填空题${gapFillingCnt}题,共${gapFillingScore}分,`} {indefiniteChoiceCnt > 0 && `不定项选择题${indefiniteChoiceCnt}题,共${indefiniteChoiceScore}分`}
{indefiniteChoiceCnt > 0 &&
`不定项选择题${indefiniteChoiceCnt}题,共${indefiniteChoiceScore}分`}
</div> </div>
)} )}
<XMTable <XMTable
className="table-style" className='table-style'
scroll={{ y: 350 }} scroll={{ y: 350 }}
columns={this.parseColumns()} columns={this.parseColumns()}
dataSource={selectQuestionList} dataSource={selectQuestionList}
...@@ -901,18 +774,16 @@ class OperatePaper extends Component { ...@@ -901,18 +774,16 @@ class OperatePaper extends Component {
onChange={this.sortByQuestionType} onChange={this.sortByQuestionType}
renderEmpty={{ renderEmpty={{
image: paperEmpty, image: paperEmpty,
description: <span style={{ display: 'block', paddingBottom: 24 }}>请在左上角添加题目</span> description: <span style={{ display: 'block', paddingBottom: 24 }}>请在左上角添加题目</span>,
}} }}
/> />
</Form> </Form>
</div> </div>
<div className="footer"> <div className='footer'>
<Button onClick={this.handleGoBack}>取消</Button> <Button onClick={this.handleGoBack}>取消</Button>
<Button onClick={this.previewPaper}>预览</Button> <Button onClick={this.previewPaper}>预览</Button>
<Button onClick={() => this.savePaper("saveToAddExam")}> <Button onClick={() => this.savePaper('saveToAddExam')}>保存并组织考试</Button>
保存并组织考试 <Button type='primary' onClick={() => this.savePaper()}>
</Button>
<Button type="primary" onClick={() => this.savePaper()}>
保存 保存
</Button> </Button>
</div> </div>
...@@ -921,8 +792,8 @@ class OperatePaper extends Component { ...@@ -921,8 +792,8 @@ class OperatePaper extends Component {
{paperPreviewModal} {paperPreviewModal}
<Modal <Modal
maskClosable={false} maskClosable={false}
className="type-order-modal" className='type-order-modal'
title="快捷排序" title='快捷排序'
width={560} width={560}
visible={quickSortModalVisible} visible={quickSortModalVisible}
onOk={() => { onOk={() => {
...@@ -935,23 +806,21 @@ class OperatePaper extends Component { ...@@ -935,23 +806,21 @@ class OperatePaper extends Component {
}} }}
onCancel={() => { onCancel={() => {
this.setState({ quickSortModalVisible: false }); this.setState({ quickSortModalVisible: false });
}} }}>
>
<Radio.Group <Radio.Group
onChange={(e) => onChange={(e) =>
this.setState({ this.setState({
sorterMethod: e.target.value, sorterMethod: e.target.value,
}) })
} }
value={sorterMethod} value={sorterMethod}>
> <Radio value={'addOrder'}>按添加顺序排序</Radio>
<Radio value={"addOrder"}>按添加顺序排序</Radio> <Radio value={'typeOrder'}>按题型排序</Radio>
<Radio value={"typeOrder"}>按题型排序</Radio>
</Radio.Group> </Radio.Group>
{sorterMethod === "typeOrder" && ( {sorterMethod === 'typeOrder' && (
<Table <Table
className="type-order-table" className='type-order-table'
style={{marginTop: '24px'}} style={{ marginTop: '24px' }}
showHeader={false} showHeader={false}
columns={typeColumns} columns={typeColumns}
dataSource={sorterTypeList} dataSource={sorterTypeList}
...@@ -964,16 +833,7 @@ class OperatePaper extends Component { ...@@ -964,16 +833,7 @@ class OperatePaper extends Component {
<Route <Route
path={`${match.url}/exam-operate-page`} path={`${match.url}/exam-operate-page`}
render={() => { render={() => {
return ( return <AddExam paperInfo={formData} type={currentOperate === 'edit' ? 'editPaperToAddExam' : 'newPaperToAddExam'} />;
<AddExam
paperInfo={formData}
type={
currentOperate === "edit"
? "editPaperToAddExam"
: "newPaperToAddExam"
}
/>
);
}} }}
/> />
</div> </div>
......
...@@ -6,6 +6,7 @@ ...@@ -6,6 +6,7 @@
} }
.table-style { .table-style {
border: 1px solid #f0f0f0 !important; border: 1px solid #f0f0f0 !important;
margin-bottom: 70px;
} }
.ant-tabs { .ant-tabs {
color: #666666; color: #666666;
......
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