Commit dada4189 by guomingpang
parents 70fdad21 88dbb461
...@@ -155,7 +155,7 @@ class ChooseMembersModal extends React.Component { ...@@ -155,7 +155,7 @@ class ChooseMembersModal extends React.Component {
let rightsList = []; // 保存新加进去的成员 let rightsList = []; // 保存新加进去的成员
selectUserList.map((item) => { selectUserList.map((item) => {
rightsList.push({ rightsList.push({
rights: "LOOK_DOWNLOAD", rights: "LOOK",
userId: item.userId userId: item.userId
}) })
return rightsList return rightsList
......
...@@ -19,7 +19,7 @@ class ManagingMembersModal extends React.Component { ...@@ -19,7 +19,7 @@ class ManagingMembersModal extends React.Component {
addManagingMember: false, // 是否点击了添加成员 addManagingMember: false, // 是否点击了添加成员
storeId :User.getStoreId() , // 学院Id storeId :User.getStoreId() , // 学院Id
iconRotateList: [], iconRotateList: [],
userAuthority : ['可编辑', '可查看/下载', '仅可查看', '', '创建者', '学院管理员'] , // 空 代表删除 userAuthority : ['可编辑', '可下载', '可查看', '', '创建者', '学院管理员'] , // 空 代表删除
} }
} }
componentDidMount() { componentDidMount() {
...@@ -64,7 +64,7 @@ class ManagingMembersModal extends React.Component { ...@@ -64,7 +64,7 @@ class ManagingMembersModal extends React.Component {
// 修改成员权限 // 修改成员权限
updateFileUserAuthority = (params, newRights = 1) => { updateFileUserAuthority = (params, newRights = 1) => {
const rightList = ['EDIT', 'LOOK_DOWNLOAD', '']; const rightList = ['EDIT', 'LOOK_DOWNLOAD', 'LOOK'];
let { iconRotateList } = this.state; let { iconRotateList } = this.state;
let _params = params; let _params = params;
_params.rights = rightList[newRights]; _params.rights = rightList[newRights];
...@@ -173,10 +173,10 @@ class ManagingMembersModal extends React.Component { ...@@ -173,10 +173,10 @@ class ManagingMembersModal extends React.Component {
<span className='menu-bottom'>下载、复制</span> <span className='menu-bottom'>下载、复制</span>
</div> </div>
</Menu.Item> </Menu.Item>
{/* <Menu.Item key="LOOK" > <Menu.Item key="LOOK" >
<div onClick={() => this.updateFileUserAuthority(params, 2)}>仅可查看</div> <div onClick={() => this.updateFileUserAuthority(params, 2)}>{userAuthority[2]}</div>
<span className='menu-bottom'>{userAuthority[2]}</span> <span className='menu-bottom'>查看</span>
</Menu.Item> */} </Menu.Item>
<Menu.Divider key='LINE'/> <Menu.Divider key='LINE'/>
<Menu.Item key="REMOVE" > <Menu.Item key="REMOVE" >
<div className='remove' onClick={() => this.removeUser(params, userAuthority[3])}>移除</div> <div className='remove' onClick={() => this.removeUser(params, userAuthority[3])}>移除</div>
...@@ -247,6 +247,8 @@ class ManagingMembersModal extends React.Component { ...@@ -247,6 +247,8 @@ class ManagingMembersModal extends React.Component {
num = 1; num = 1;
} else if (record.rights === "EDIT") { } else if (record.rights === "EDIT") {
num = 0; num = 0;
}else if(record.rights=="LOOK"){
num = 2;
} }
} }
return ( return (
......
...@@ -2,89 +2,89 @@ ...@@ -2,89 +2,89 @@
* @Author: yuananting * @Author: yuananting
* @Date: 2021-03-03 15:13:12 * @Date: 2021-03-03 15:13:12
* @LastEditors: fusanqiasng * @LastEditors: fusanqiasng
* @LastEditTime: 2021-05-25 10:07:03 * @LastEditTime: 2021-06-15 17:54:04
* @Description: 助学工具接口 * @Description: 助学工具接口
* @Copyrigh: © 2020 杭州杰竞科技有限公司 版权所有 * @Copyrigh: © 2020 杭州杰竞科技有限公司 版权所有
*/ */
import Service from '@/common/js/service' import Service from '@/common/js/service';
export function queryExternalCategoryTree(params: object) { export function queryExternalCategoryTree(params: object) {
return Service.Hades('public/externalHades/queryCategoryTree', params) return Service.Hades('public/externalHades/queryCategoryTree', params);
} }
export function queryCategoryTree(params: object) { export function queryCategoryTree(params: object) {
return Service.Hades('public/hades/queryCategoryTree', params) return Service.Hades('public/hades/queryCategoryTree', params);
} }
export function addCategory(params: object) { export function addCategory(params: object) {
return Service.Hades('public/hades/addCategory', params) return Service.Hades('public/hades/addCategory', params);
} }
export function delCategory(params: object) { export function delCategory(params: object) {
return Service.Hades('public/hades/delCategory', params) return Service.Hades('public/hades/delCategory', params);
} }
export function editCategory(params: object) { export function editCategory(params: object) {
return Service.Hades('public/hades/editCategory', params) return Service.Hades('public/hades/editCategory', params);
} }
export function editCategoryTree(params: object) { export function moveCategoryTree(params: object) {
return Service.Hades('public/hades/editCategoryTree', params) return Service.Hades('public/hades/editCategoryTree', params);
} }
export function queryQuestionPageList(params: object) { export function queryQuestionPageList(params: object) {
return Service.Hades('public/hades/queryQuestionPageList', params) return Service.Hades('public/hades/queryQuestionPageList', params);
} }
export function addQuestion(params: object) { export function addQuestion(params: object) {
return Service.Hades('public/hades/addQuestion', params) return Service.Hades('public/hades/addQuestion', params);
} }
export function deleteQuestion(params: object) { export function deleteQuestion(params: object) {
return Service.Hades('public/hades/deleteQuestion', params) return Service.Hades('public/hades/deleteQuestion', params);
} }
export function queryQuestionDetails(params: object) { export function queryQuestionDetails(params: object) {
return Service.Hades('public/hades/queryQuestionDetails', params) return Service.Hades('public/hades/queryQuestionDetails', params);
} }
export function editQuestion(params: object) { export function editQuestion(params: object) {
return Service.Hades('public/hades/editQuestion', params) return Service.Hades('public/hades/editQuestion', params);
} }
export function batchImport(params: object) { export function batchImport(params: object) {
return Service.Hades('public/hades/batchImport', params) return Service.Hades('public/hades/batchImport', params);
} }
export function createPaper(params: object) { export function createPaper(params: object) {
return Service.Hades('public/hades/createPaper', params) return Service.Hades('public/hades/createPaper', params);
} }
export function queryPaperPageList(params: object) { export function queryPaperPageList(params: object) {
return Service.Hades('public/hades/queryPaperPageList', params) return Service.Hades('public/hades/queryPaperPageList', params);
} }
export function deletePaper(params: object) { export function deletePaper(params: object) {
return Service.Hades('public/hades/deletePaper', params) return Service.Hades('public/hades/deletePaper', params);
} }
export function queryPaperDetail(params: object) { export function queryPaperDetail(params: object) {
return Service.Hades('public/hades/queryPaperDetail', params) return Service.Hades('public/hades/queryPaperDetail', params);
} }
export function viewPaper(params: object) { export function viewPaper(params: object) {
return Service.Hades('public/hades/viewPaper', params) return Service.Hades('public/hades/viewPaper', params);
} }
export function editPaper(params: object) { export function editPaper(params: object) {
return Service.Hades('public/hades/editPaper', params) return Service.Hades('public/hades/editPaper', params);
} }
export function batchQueryQuestionDetails(params: object) { export function batchQueryQuestionDetails(params: object) {
return Service.Hades('public/hades/batchQueryQuestionDetails', params) return Service.Hades('public/hades/batchQueryQuestionDetails', params);
} }
export function queryQuestionPageListWithContent(params: object) { export function queryQuestionPageListWithContent(params: object) {
return Service.Hades('public/hades/queryQuestionPageListWithContent', params) return Service.Hades('public/hades/queryQuestionPageListWithContent', params);
} }
...@@ -2,7 +2,7 @@ ...@@ -2,7 +2,7 @@
* @Author: yuananting * @Author: yuananting
* @Date: 2021-03-11 11:34:37 * @Date: 2021-03-11 11:34:37
* @LastEditors: fusanqiasng * @LastEditors: fusanqiasng
* @LastEditTime: 2021-05-24 23:44:39 * @LastEditTime: 2021-06-15 11:25:18
* @Description: 助学工具接口 * @Description: 助学工具接口
* @Copyrigh: © 2020 杭州杰竞科技有限公司 版权所有 * @Copyrigh: © 2020 杭州杰竞科技有限公司 版权所有
*/ */
...@@ -12,7 +12,7 @@ import { ...@@ -12,7 +12,7 @@ import {
addCategory, addCategory,
delCategory, delCategory,
editCategory, editCategory,
editCategoryTree, moveCategoryTree,
addQuestion, addQuestion,
queryQuestionPageList, queryQuestionPageList,
deleteQuestion, deleteQuestion,
...@@ -26,8 +26,8 @@ import { ...@@ -26,8 +26,8 @@ import {
viewPaper, viewPaper,
editPaper, editPaper,
batchQueryQuestionDetails, batchQueryQuestionDetails,
queryQuestionPageListWithContent queryQuestionPageListWithContent,
} from '@/data-source/aidTool/request-apis' } from '@/data-source/aidTool/request-apis';
export default class AidToolService { export default class AidToolService {
/** /**
* 查询运营端分类书 * 查询运营端分类书
...@@ -35,101 +35,101 @@ export default class AidToolService { ...@@ -35,101 +35,101 @@ export default class AidToolService {
* @returns * @returns
*/ */
static queryExternalCategoryTree(parmas: any) { static queryExternalCategoryTree(parmas: any) {
return queryExternalCategoryTree(parmas) return queryExternalCategoryTree(parmas);
} }
// 获取题目分类树 // 获取题目分类树
static queryCategoryTree(params: any) { static queryCategoryTree(params: any) {
return queryCategoryTree(params) return queryCategoryTree(params);
} }
// 新增题目分类 // 新增题目分类
static addCategory(params: any) { static addCategory(params: any) {
return addCategory(params) return addCategory(params);
} }
// 删除分类 // 删除分类
static delCategory(params: any) { static delCategory(params: any) {
return delCategory(params) return delCategory(params);
} }
// 编辑分类 // 编辑分类
static editCategory(params: any) { static editCategory(params: any) {
return editCategory(params) return editCategory(params);
} }
// 编辑分类树(拖拽) // 拖拽移动分类树
static editCategoryTree(params: any) { static moveCategoryTree(params: any) {
return editCategoryTree(params) return moveCategoryTree(params);
} }
// 查询题目列表 // 查询题目列表
static queryQuestionPageList(params: any) { static queryQuestionPageList(params: any) {
return queryQuestionPageList(params) return queryQuestionPageList(params);
} }
// 添加题目 // 添加题目
static addQuestion(params: any) { static addQuestion(params: any) {
return addQuestion(params) return addQuestion(params);
} }
// 删除题目 // 删除题目
static deleteQuestion(params: any) { static deleteQuestion(params: any) {
return deleteQuestion(params) return deleteQuestion(params);
} }
// 预览题目 // 预览题目
static queryQuestionDetails(params: any) { static queryQuestionDetails(params: any) {
return queryQuestionDetails(params) return queryQuestionDetails(params);
} }
// 编辑题目 // 编辑题目
static editQuestion(params: any) { static editQuestion(params: any) {
return editQuestion(params) return editQuestion(params);
} }
// 批量导入 // 批量导入
static batchImport(params: any) { static batchImport(params: any) {
return batchImport(params) return batchImport(params);
} }
// 创建试卷 // 创建试卷
static createPaper(params: any) { static createPaper(params: any) {
return createPaper(params) return createPaper(params);
} }
// 查询试卷列表 // 查询试卷列表
static queryPaperPageList(params: any) { static queryPaperPageList(params: any) {
return queryPaperPageList(params) return queryPaperPageList(params);
} }
// 删除试卷 // 删除试卷
static deletePaper(params: any) { static deletePaper(params: any) {
return deletePaper(params) return deletePaper(params);
} }
// 编辑前查询试卷信息 // 编辑前查询试卷信息
static queryPaperDetail(params: any) { static queryPaperDetail(params: any) {
return queryPaperDetail(params) return queryPaperDetail(params);
} }
// 预览试卷 // 预览试卷
static viewPaper(params: any) { static viewPaper(params: any) {
return viewPaper(params) return viewPaper(params);
} }
// 编辑试卷 // 编辑试卷
static editPaper(params: any) { static editPaper(params: any) {
return editPaper(params) return editPaper(params);
} }
// 操作试卷-预览查询多题目信息 // 操作试卷-预览查询多题目信息
static batchQueryQuestionDetails(params: any) { static batchQueryQuestionDetails(params: any) {
return batchQueryQuestionDetails(params) return batchQueryQuestionDetails(params);
} }
// 操作试卷-选择题目列表带题目详情 // 操作试卷-选择题目列表带题目详情
static queryQuestionPageListWithContent(params: any) { static queryQuestionPageListWithContent(params: any) {
return queryQuestionPageListWithContent(params) return queryQuestionPageListWithContent(params);
} }
} }
/* /*
* @Author: 陈剑宇 * @Author: 陈剑宇
* @Date: 2020-05-07 14:43:01 * @Date: 2020-05-07 14:43:01
* @LastEditTime: 2021-05-28 15:20:40 * @LastEditTime: 2021-06-11 16:44:17
* @LastEditors: fusanqiasng * @LastEditors: Please set LastEditors
* @Description: * @Description:
* @FilePath: /wheat-web-demo/src/domains/basic-domain/constants.ts * @FilePath: /wheat-web-demo/src/domains/basic-domain/constants.ts
*/ */
......
/* /*
* @Author: 吴文洁 * @Author: 吴文洁
* @Date: 2020-08-20 09:21:40 * @Date: 2020-08-20 09:21:40
* @LastEditors: zhangleyuan * @LastEditors: Please set LastEditors
* @LastEditTime: 2021-02-20 17:08:58 * @LastEditTime: 2021-06-11 15:17:56
* @Description: * @Description:
* @Copyright: 杭州杰竞科技有限公司 版权所有 * @Copyright: 杭州杰竞科技有限公司 版权所有
*/ */
......
/* /*
* @Author: 吴文洁 * @Author: 吴文洁
* @Date: 2020-08-05 10:12:45 * @Date: 2020-08-05 10:12:45
* @LastEditors: yuananting * @LastEditors: Please set LastEditors
* @LastEditTime: 2021-06-02 15:05:54 * @LastEditTime: 2021-06-15 11:22:25
* @Description: 视频课-列表模块 * @Description: 视频课-列表模块
* @Copyright: 杭州杰竞科技有限公司 版权所有 * @Copyright: 杭州杰竞科技有限公司 版权所有
*/ */
......
...@@ -52,6 +52,13 @@ class ShareLiveModal extends React.Component { ...@@ -52,6 +52,13 @@ class ShareLiveModal extends React.Component {
size: 98, size: 98,
}) })
qrcodeWrapDom.appendChild(qrcodeNode) qrcodeWrapDom.appendChild(qrcodeNode)
const qrcodeWrapDomDownload = document.querySelector('#qrcodeWrap-dowload')
const qrcodeNodeDownLoad = new qrcode({
text: this.state.shareUrl,
size: 196,
})
qrcodeWrapDomDownload.appendChild(qrcodeNodeDownLoad)
} }
) )
}) })
...@@ -72,13 +79,12 @@ class ShareLiveModal extends React.Component { ...@@ -72,13 +79,12 @@ class ShareLiveModal extends React.Component {
() => { () => {
this.setState({ time: new Date().valueOf() }, () => { this.setState({ time: new Date().valueOf() }, () => {
setTimeout(() => { setTimeout(() => {
let node = document.getElementById('poster') 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()
// this.props.close()
}) })
}, 1000) }, 1000)
}) })
...@@ -158,6 +164,29 @@ class ShareLiveModal extends React.Component { ...@@ -158,6 +164,29 @@ class ShareLiveModal extends React.Component {
<div className='qrcode-wrap__right' id='qrcodeWrap'></div> <div className='qrcode-wrap__right' id='qrcodeWrap'></div>
</div> </div>
</div> </div>
<div id='poster-dowload'>
<div className='store-name'>
<span className='text'>{User.getStoreName()}</span>
</div>
<div className='course-name-title'>{type === 'videoClass' ? `${courseName}开课啦` : `邀请你观看直播:`}</div>
{type === 'liveClass' && <div class='live-couse-name'>{courseName}</div>}
<Choose>
<When condition={showImg}>
<img crossOrigin='*' src={coverImgSrc + `?=${time}`} className='course-cover' alt='' />
</When>
<Otherwise>
<img src={coverImgSrc + `?=${time}`} className='course-cover' alt='' />
</Otherwise>
</Choose>
<div className='qrcode-wrap'>
<div className='qrcode-wrap__left'>
<div className='text'>长按识别二维码进入观看</div>
<img className='finger' src='https://image.xiaomaiketang.com/xm/thpkWDwJsC.png' alt='' />
</div>
<div className='qrcode-wrap__right' id='qrcodeWrap-dowload'></div>
</div>
</div>
</div> </div>
<div className='right'> <div className='right'>
<div className='share-poster right__item'> <div className='share-poster right__item'>
......
.share-live-modal { .share-live-modal {
.ant-modal-body { .ant-modal-body {
display: flex; display: flex;
#poster{ height:510px !important;
background: #FFF; overflow: hidden !important;
margin:0;
padding: 20px;
}
.left { .left {
width: 303px; width: 303px;
margin: 0 32px 0 16px; margin: 0 32px 0 16px;
box-shadow:0px 2px 10px 0px rgba(0,0,0,0.05); box-shadow:0px 2px 10px 0px rgba(0,0,0,0.05);
border-radius: 12px; border-radius: 12px;
#poster{
background: #FFF;
margin:0;
padding: 20px;
margin-bottom:140px;
.course-name-title { .course-name-title {
font-size: 14px; font-size: 14px;
color: #333; color: #333;
...@@ -83,6 +84,82 @@ ...@@ -83,6 +84,82 @@
} }
} }
} }
#poster-dowload{
background: #FFF;
margin:0;
padding: 40px;
width:606px;
.course-name-title {
font-size: 28px;
color: #333;
line-height: 40px;
margin-bottom: 8px;
}
.live-couse-name{
font-size:32px;
color:#333333;
font-weight: 600;
}
.course-name {
color: #333;
font-size: 32px;
font-weight: 600;
line-height: 40px;
}
.course-cover {
width: 526px;
height: 286px;
border-radius: 6px;
margin-top: 16px;
}
.qrcode-wrap {
padding: 0 32px;
display: flex;
align-items: center;
margin: 48px 0 32px 0;
&__left {
width: 196px;
text-align: center;
margin-right: 44px;
.text {
line-height: 40px;
}
.finger {
width: 80px;
height: 80px;
margin-top: 16px;
}
}
&__right {
width: 220px;
height: 220px;
padding: 12px
}
}
.store-name {
// padding: 8px 16px;
display: flex;
align-items: center;
margin-bottom: 16px;
.text {
font-size: 24px;
color: #999;
font-size: 28px;
line-height: 40px;
text-overflow: ellipsis;
overflow: hidden;
white-space: nowrap;
width: 100%;
}
}
}
}
.right { .right {
.title { .title {
......
/* /*
* @Author: 吴文洁 * @Author: 吴文洁
* @Date: 2020-08-05 10:12:45 * @Date: 2020-08-05 10:12:45
* @LastEditors: yuananting * @LastEditors: Please set LastEditors
* @LastEditTime: 2021-06-02 16:15:55 * @LastEditTime: 2021-06-11 16:44:42
* @Description: 视频课-列表模块 * @Description: 视频课-列表模块
* @Copyright: 杭州杰竞科技有限公司 版权所有 * @Copyright: 杭州杰竞科技有限公司 版权所有
*/ */
......
...@@ -2,17 +2,17 @@ ...@@ -2,17 +2,17 @@
* @Description: * @Description:
* @Author: zangsuyun * @Author: zangsuyun
* @Date: 2021-03-19 18:05:23 * @Date: 2021-03-19 18:05:23
* @LastEditors: wufan * @LastEditors: fusanqiasng
* @LastEditTime: 2021-05-30 16:48:46 * @LastEditTime: 2021-06-15 11:20:24
* @Copyright: © 2020 杭州杰竞科技有限公司 版权所有 * @Copyright: © 2020 杭州杰竞科技有限公司 版权所有
*/ */
import React, { Component } from "react"; import React, { Component } from 'react';
import { Input, Button, Tree } from "antd"; import { Input, Button, Tree } from 'antd';
import "./Classification.less"; import './Classification.less';
import User from "@/common/js/user"; import User from '@/common/js/user';
import KnowledgeAPI from "@/data-source/knowledge/request-api"; import KnowledgeAPI from '@/data-source/knowledge/request-api';
import Bus from "@/core/bus"; import Bus from '@/core/bus';
const { Search } = Input; const { Search } = Input;
const { DirectoryTree } = Tree; const { DirectoryTree } = Tree;
...@@ -21,7 +21,7 @@ class Classification extends Component { ...@@ -21,7 +21,7 @@ class Classification extends Component {
constructor(props) { constructor(props) {
super(props); super(props);
this.state = { this.state = {
selectedKeys: props.selectedKeys ? [props.selectedKeys] : ["0"], selectedKeys: props.selectedKeys ? [props.selectedKeys] : ['0'],
searchValue: null, searchValue: null,
NewEditQuestionBankCategory: null, //新增或编辑分类模态框 NewEditQuestionBankCategory: null, //新增或编辑分类模态框
ImportCourseCategory: null, // 引用课程分类模态框 ImportCourseCategory: null, // 引用课程分类模态框
...@@ -32,11 +32,11 @@ class Classification extends Component { ...@@ -32,11 +32,11 @@ class Classification extends Component {
componentDidMount() { componentDidMount() {
this.queryCategoryTree(); this.queryCategoryTree();
Bus.bind('knowledgeCategoryTree', this.queryCategoryTree) Bus.bind('knowledgeCategoryTree', this.queryCategoryTree);
} }
componentWillUnmount() { componentWillUnmount() {
Bus.unbind('knowledgeCategoryTree', this.queryCategoryTree) Bus.unbind('knowledgeCategoryTree', this.queryCategoryTree);
} }
shouldComponentUpdate = (nextProps, nextState) => { shouldComponentUpdate = (nextProps, nextState) => {
...@@ -79,7 +79,7 @@ class Classification extends Component { ...@@ -79,7 +79,7 @@ class Classification extends Component {
}; };
KnowledgeAPI.getCategoryTree(query).then((res) => { KnowledgeAPI.getCategoryTree(query).then((res) => {
const { categoryList = [], noCategoryCnt = 0 } = res.result; const { categoryList = [], noCategoryCnt = 0 } = res.result;
let str = "未分类"; let str = '未分类';
if (categoryName) { if (categoryName) {
this.setState({ autoExpandParent: true }); this.setState({ autoExpandParent: true });
if (str.indexOf(categoryName) < 0) { if (str.indexOf(categoryName) < 0) {
...@@ -93,8 +93,8 @@ class Classification extends Component { ...@@ -93,8 +93,8 @@ class Classification extends Component {
this.setState({ expandedKeys: nodeId }); this.setState({ expandedKeys: nodeId });
} else { } else {
const defaultNode = { const defaultNode = {
id: "0", id: '0',
categoryName: "未分类", categoryName: '未分类',
categoryCount: noCategoryCnt, categoryCount: noCategoryCnt,
}; };
categoryList.unshift(defaultNode); categoryList.unshift(defaultNode);
...@@ -110,8 +110,8 @@ class Classification extends Component { ...@@ -110,8 +110,8 @@ class Classification extends Component {
} else { } else {
this.setState({ autoExpandParent: false }); this.setState({ autoExpandParent: false });
const defaultNode = { const defaultNode = {
id: "0", id: '0',
categoryName: "未分类", categoryName: '未分类',
categoryCount: noCategoryCnt, categoryCount: noCategoryCnt,
}; };
categoryList.unshift(defaultNode); categoryList.unshift(defaultNode);
...@@ -140,39 +140,35 @@ class Classification extends Component { ...@@ -140,39 +140,35 @@ class Classification extends Component {
item.title = item.title =
!value || (value && item.categoryName.indexOf(value) > -1) ? ( !value || (value && item.categoryName.indexOf(value) > -1) ? (
<span> <span>
{item.categoryName}{item.categoryCount} {item.categoryName}
{item.categoryCount > 0 && <span>{item.categoryCount}</span>}
</span> </span>
) : ( ) : (
<span style={{ opacity: 0.5 }}> <span style={{ opacity: 0.5 }}>
{item.categoryName}{item.categoryCount} {item.categoryName}
{item.categoryCount > 0 && <span>{item.categoryCount}</span>}
</span> </span>
); );
item.icon = item.icon =
item.categoryName === "未分类" ? ( item.categoryName === '未分类' ? (
<img <img
style={{ style={{
width: "24px", width: '24px',
height: "24px", height: '24px',
opacity: opacity: !value || (value && item.categoryName.indexOf(value) > -1) ? 1 : 0.5,
!value || (value && item.categoryName.indexOf(value) > -1)
? 1
: 0.5,
}} }}
src="https://image.xiaomaiketang.com/xm/defaultCategory.png" src='https://image.xiaomaiketang.com/xm/defaultCategory.png'
alt="" alt=''
/> />
) : ( ) : (
<img <img
style={{ style={{
width: "24px", width: '24px',
height: "24px", height: '24px',
opacity: opacity: !value || (value && item.categoryName.indexOf(value) > -1) ? 1 : 0.5,
!value || (value && item.categoryName.indexOf(value) > -1)
? 1
: 0.5,
}} }}
src="https://image.xiaomaiketang.com/xm/hasCategory.png" src='https://image.xiaomaiketang.com/xm/hasCategory.png'
alt="" alt=''
/> />
); );
if (item.sonCategoryList) { if (item.sonCategoryList) {
...@@ -186,36 +182,30 @@ class Classification extends Component { ...@@ -186,36 +182,30 @@ class Classification extends Component {
}; };
render() { render() {
const { const { treeData, expandedKeys, selectedKeys, autoExpandParent } = this.state;
treeData,
expandedKeys,
selectedKeys,
autoExpandParent,
} = this.state;
return ( return (
<div className="question-bank-sider"> <div className='question-bank-sider'>
<div className="sider-title">知识分类</div> <div className='sider-title'>知识分类</div>
<Search <Search
className="sider-search" className='sider-search'
placeholder="搜索名称分类" placeholder='搜索名称分类'
onSearch={(value) => { onSearch={(value) => {
this.queryCategoryTree(value); this.queryCategoryTree(value);
}} }}
enterButton={<span className="icon iconfont">&#xe832;</span>} enterButton={<span className='icon iconfont'>&#xe832;</span>}
style={{width: 230}} style={{ width: 230 }}
/> />
<div className="sider-btn"> <div className='sider-btn'>
<Button <Button
onClick={() => { onClick={() => {
window.RCHistory.push({ window.RCHistory.push({
pathname: "/course-category-manage?from=knowledge", pathname: '/course-category-manage?from=knowledge',
}); });
}} }}>
>
分类管理 分类管理
</Button> </Button>
</div> </div>
<div className="sider-tree"> <div className='sider-tree'>
<DirectoryTree <DirectoryTree
expandedKeys={expandedKeys} expandedKeys={expandedKeys}
autoExpandParent={autoExpandParent} autoExpandParent={autoExpandParent}
......
...@@ -2,8 +2,8 @@ ...@@ -2,8 +2,8 @@
* @Description: * @Description:
* @Author: zangsuyun * @Author: zangsuyun
* @Date: 2021-03-12 14:49:40 * @Date: 2021-03-12 14:49:40
* @LastEditors: wufan * @LastEditors: Please set LastEditors
* @LastEditTime: 2021-05-30 20:37:42 * @LastEditTime: 2021-06-11 16:44:59
* @Copyright: © 2020 杭州杰竞科技有限公司 版权所有 * @Copyright: © 2020 杭州杰竞科技有限公司 版权所有
*/ */
......
...@@ -2,8 +2,8 @@ ...@@ -2,8 +2,8 @@
* @Description: * @Description:
* @Author: zangsuyun * @Author: zangsuyun
* @Date: 2021-03-13 09:54:26 * @Date: 2021-03-13 09:54:26
* @LastEditors: yuananting * @LastEditors: fusanqiasng
* @LastEditTime: 2021-06-07 18:28:31 * @LastEditTime: 2021-06-15 17:19:12
* @Copyright: © 2020 杭州杰竞科技有限公司 版权所有 * @Copyright: © 2020 杭州杰竞科技有限公司 版权所有
*/ */
......
...@@ -317,7 +317,7 @@ function PlanList(props) { ...@@ -317,7 +317,7 @@ function PlanList(props) {
scroll={{ x: 1400 }} scroll={{ x: 1400 }}
className='plan-list-table' className='plan-list-table'
renderEmpty={{ renderEmpty={{
description: <span style={{ display: 'block', paddingBottom: 24 }}>还没有试卷</span> description: <span style={{ display: 'block', paddingBottom: 24 }}>暂无数据</span>
}} }}
/> />
<div className='box-footer'> <div className='box-footer'>
......
...@@ -51,6 +51,13 @@ class ShareLiveModal extends React.Component { ...@@ -51,6 +51,13 @@ class ShareLiveModal extends React.Component {
size: 98, size: 98,
}) })
qrcodeWrapDom.appendChild(qrcodeNode) qrcodeWrapDom.appendChild(qrcodeNode)
const qrcodeWrapDomDownload = document.querySelector('#qrcodeWrap-dowload')
const qrcodeNodeDownLoad = new qrcode({
text: this.state.shareUrl,
size: 196,
})
qrcodeWrapDomDownload.appendChild(qrcodeNodeDownLoad)
} }
) )
}) })
...@@ -70,9 +77,8 @@ class ShareLiveModal extends React.Component { ...@@ -70,9 +77,8 @@ class ShareLiveModal extends React.Component {
}, },
() => { () => {
this.setState({ time: new Date().valueOf() }, () => { this.setState({ time: new Date().valueOf() }, () => {
let node = document.getElementById('poster') let node = document.getElementById('poster-dowload')
domtoimage.toPng(node).then((imgData) => { domtoimage.toPng(node).then((imgData) => {
console.log(imgData)
const download = document.createElement('a') const download = document.createElement('a')
const { planName } = this.props.data const { planName } = this.props.data
$(download).attr('href', imgData).attr('download', `${planName}.png`).get(0).click() $(download).attr('href', imgData).attr('download', `${planName}.png`).get(0).click()
...@@ -112,7 +118,7 @@ class ShareLiveModal extends React.Component { ...@@ -112,7 +118,7 @@ class ShareLiveModal extends React.Component {
<div className='course-name-title'>邀请你参与培训:</div> <div className='course-name-title'>邀请你参与培训:</div>
<div class='live-couse-name'>{planName}</div> <div className='live-couse-name'>{planName}</div>
<Choose> <Choose>
<When condition={showImg}> <When condition={showImg}>
<img crossOrigin='*' src={coverUrl + `?=${time}`} className='course-cover' alt='' /> <img crossOrigin='*' src={coverUrl + `?=${time}`} className='course-cover' alt='' />
...@@ -130,6 +136,31 @@ class ShareLiveModal extends React.Component { ...@@ -130,6 +136,31 @@ class ShareLiveModal extends React.Component {
<div className='qrcode-wrap__right' id='qrcodeWrap'></div> <div className='qrcode-wrap__right' id='qrcodeWrap'></div>
</div> </div>
</div> </div>
<div id='poster-dowload'>
<div className='store-name'>
<span className='text'>{User.getStoreName()}</span>
</div>
<div className='course-name-title'>邀请你参与培训:</div>
<div className='live-couse-name'>{planName}</div>
<Choose>
<When condition={showImg}>
<img crossOrigin='*' src={coverUrl + `?=${time}`} className='course-cover' alt='' />
</When>
<Otherwise>
<img src={coverUrl + `?=${time}`} className='course-cover' alt='' />
</Otherwise>
</Choose>
<div className='qrcode-wrap'>
<div className='qrcode-wrap__left'>
<div className='text'>长按识别二维码进入观看</div>
<img className='finger' src='https://image.xiaomaiketang.com/xm/thpkWDwJsC.png' alt='' />
</div>
<div className='qrcode-wrap__right' id='qrcodeWrap-dowload'></div>
</div>
</div>
</div> </div>
<div className='right'> <div className='right'>
<div className='share-poster right__item'> <div className='share-poster right__item'>
......
.share-live-modal { .share-live-modal {
.ant-modal-body { .ant-modal-body {
display: flex; display: flex;
#poster{ height:510px !important;
background: #FFF; overflow: hidden !important;
margin:0;
padding: 20px;
}
.left { .left {
width: 303px; width: 303px;
margin: 0 32px 0 16px; margin: 0 32px 0 16px;
box-shadow:0px 2px 10px 0px rgba(0,0,0,0.05); box-shadow:0px 2px 10px 0px rgba(0,0,0,0.05);
border-radius: 12px; border-radius: 12px;
#poster{
background: #FFF;
margin:0;
padding: 20px;
margin-bottom:140px;
.course-name-title { .course-name-title {
font-size: 14px; font-size: 14px;
color: #333; color: #333;
...@@ -83,6 +84,83 @@ ...@@ -83,6 +84,83 @@
} }
} }
} }
#poster-dowload{
background: #FFF;
margin:0;
padding: 40px;
width:606px;
.course-name-title {
font-size: 28px;
color: #333;
line-height: 40px;
margin-bottom: 8px;
}
.live-couse-name{
font-size:32px;
color:#333333;
font-weight: 600;
}
.course-name {
color: #333;
font-size: 32px;
font-weight: 600;
line-height: 40px;
}
.course-cover {
width: 526px;
height: 286px;
border-radius: 6px;
margin-top: 16px;
}
.qrcode-wrap {
padding: 0 32px;
display: flex;
align-items: center;
margin: 48px 0 32px 0;
&__left {
width: 196px;
text-align: center;
margin-right: 44px;
.text {
line-height: 40px;
}
.finger {
width: 80px;
height: 80px;
margin-top: 16px;
}
}
&__right {
width: 220px;
height: 220px;
padding: 12px
}
}
.store-name {
// padding: 8px 16px;
display: flex;
align-items: center;
margin-bottom: 16px;
.text {
font-size: 12px;
color: #999;
font-size: 28px;
line-height: 40px;
text-overflow: ellipsis;
overflow: hidden;
white-space: nowrap;
width: 100%;
}
}
}
}
.right { .right {
.title { .title {
......
...@@ -22,13 +22,15 @@ import UploadProgressModal from '@/bu-components/UploadProgressModal'; ...@@ -22,13 +22,15 @@ import UploadProgressModal from '@/bu-components/UploadProgressModal';
import SelectPrepareFileModal from '@/bu-components/SelectPrepareFileModal'; import SelectPrepareFileModal from '@/bu-components/SelectPrepareFileModal';
import CopyFileModal from '@/bu-components/CopyFileModal'; import CopyFileModal from '@/bu-components/CopyFileModal';
import ManagingMembersModal from '@/bu-components/ManagingMembersModal'; import ManagingMembersModal from '@/bu-components/ManagingMembersModal';
import PreviewFileModal from '../modal/PreviewFileModal'
import ScanFileModal from '../modal/ScanFileModal'; import ScanFileModal from '../modal/ScanFileModal';
import CreateFolderModal from '../modal/CreateFolderModal'; import CreateFolderModal from '../modal/CreateFolderModal';
import User from '@/common/js/user'; import User from '@/common/js/user';
import axios from 'axios';
const appId = "yozoqvpO2Hvz8346";
const DEL_FOLDER_URL_MAP = { const DEL_FOLDER_URL_MAP = {
'MYSELF': 'public/hadesStore/delFolder', 'MYSELF': 'public/hadesStore/delFolder',
'COMMON': 'public/hadesStore/delFolder' 'COMMON': 'public/hadesStore/delFolder'
...@@ -53,7 +55,10 @@ class FolderList extends React.Component { ...@@ -53,7 +55,10 @@ class FolderList extends React.Component {
showCopyFileModal: false, // 复制文件弹窗 showCopyFileModal: false, // 复制文件弹窗
showManagingModal: false, // 管理文件查看编辑权限 showManagingModal: false, // 管理文件查看编辑权限
nonCompliantFileList: [], // 不符合上限的文件列表 nonCompliantFileList: [], // 不符合上限的文件列表
parentRights: '' // 继承父级文件夹权限 parentRights: '', // 继承父级文件夹权限
showPreviewModal:false, //是否显示loading
previewing:false, //是否正在预览
previewStatus:'UPLOAD' //预览文件的生成状态
} }
} }
...@@ -96,10 +101,123 @@ class FolderList extends React.Component { ...@@ -96,10 +101,123 @@ class FolderList extends React.Component {
break; break;
} }
} }
handleYZPreviewDataDot =(folderFormat) => {
switch (folderFormat) {
case 'PDF':
window.WEBTRACING('resource_disk_yz_file_preview_pdf', '资料云盘_点击永中预览_pdf');
break;
case 'WORD':
case 'DOCX':
case 'DOC':
window.WEBTRACING('resource_disk_yz_file_preview_word', '资料云盘_点击永中预览_word');
break;
case 'EXCEL':
window.WEBTRACING('resource_disk_yz_file_preview_excel', '资料云盘_点击永中预览_excel');
break;
case 'PPT':
case 'PPTX':
window.WEBTRACING('resource_disk_yz_file_preview_ppt', '资料云盘_点击永中预览_ppt');
break;
default:
break;
}
}
getYoZoSign = (data,type,folderName)=>{
return new Promise((resolve) => {
let uploadParams;
if(type==="UPLOAD"){
uploadParams ={
fileUrl:data,
instId:window.currentUserInstInfo.instId,
yoZoTypeEnum:'UPLOAD'
}
}else{
uploadParams ={
fileVersionId:data,
instId:window.currentUserInstInfo.instId,
yoZoTypeEnum:'VIEW',
htmlTitle:folderName
}
}
Service.Apollo('public/apollo/getYoZoSign', uploadParams).then(res => {
const { result = [] } = res;
resolve(result)
});
})
}
saveYoZoFileVersionId = (fileVersionId,folderId)=>{
const params ={
fileVersionId,
folderId,
instId: window.currentUserInstInfo.instId,
}
Service.Apollo('public/apollo/saveYoZoFileVersionId', params).then(res => {
});
}
// 预览文件 // 预览文件
handleScanFile = (folder) => { handleScanFile = async (folder) => {
const { folderFormat, folderSize, ossUrl } = folder; const { folderFormat, folderSize, ossUrl,rights,fileVersionId,id,folderName} = folder;
const {currentRootDisk } = this.props;
//如果是公共文件且只有查看的权限的用户的预览对接的三方是永中
const that = this;
if(currentRootDisk.disk==="COMMON" && rights==="LOOK"){
switch (folderFormat) {
case 'PDF':
case 'WORD':
case 'DOCX':
case 'DOC':
case 'EXCEL':
case 'PPT':
case 'PPTX':
that.handleYZPreviewDataDot(folderFormat);
if(!fileVersionId){
this.setState({
previewing:true,
showPreviewModal:true,
previewStatus:'UPLOAD'
},async ()=>{
const uploadSign = await that.getYoZoSign(ossUrl,"UPLOAD");
axios.post(`https://dmc.yozocloud.cn/api/file/http?fileUrl=${ossUrl}&appId=${appId}&sign=${uploadSign}`)
.then(async function (response){
that.saveYoZoFileVersionId(response.data.data.fileVersionId,id);
const { previewing } = that.state;
if(previewing){
const previewSign = await that.getYoZoSign(response.data.data.fileVersionId,"VIEW",folderName);
const url = `https://eic.yozocloud.cn/api/view/file?fileVersionId=${response.data.data.fileVersionId}&appId=${appId}&sign=${previewSign}&htmlTitle=${folderName}`
that.setState({
previewStatus:'UPLOAD_SUCCESS',
url
})
}
})
})
}else{
const previewSign = await that.getYoZoSign(fileVersionId,"VIEW",folderName);
const url = `http://eic.yozocloud.cn/api/view/file?fileVersionId=${fileVersionId}&appId=${appId}&sign=${previewSign}&htmlTitle=${folderName}`
const a = document.createElement('a');
document.body.appendChild(a);
a.setAttribute('href', url);
a.setAttribute('target', '_blank');
a.click();
document.body.removeChild(a)
}
break;
default:
const scanFileModal = (
<ScanFileModal
fileType={folderFormat}
item={folder}
close={() => {
this.setState({ scanFileModal: null });
}}
/>
);
this.setState({ scanFileModal });
break;
}
}else{
switch (folderFormat) { switch (folderFormat) {
case 'PDF': case 'PDF':
window.open(ossUrl, "_blank"); window.open(ossUrl, "_blank");
...@@ -127,20 +245,20 @@ class FolderList extends React.Component { ...@@ -127,20 +245,20 @@ class FolderList extends React.Component {
}); });
break; break;
} }
if (folderFormat === 'EXCEL') { // if (folderFormat === 'EXCEL') {
Modal.confirm({ // Modal.confirm({
title: '抱歉,不能在线预览', // title: '抱歉,不能在线预览',
content: ' 该文件类型不支持在线预览,请下载后再查看', // content: ' 该文件类型不支持在线预览,请下载后再查看',
// icon: <Icon type="question-circle" theme="filled" style={{ color: '#FF8534' }}></Icon>, // // icon: <Icon type="question-circle" theme="filled" style={{ color: '#FF8534' }}></Icon>,
okText: "下载", // okText: "下载",
onOk: () => { // onOk: () => {
const a = document.createElement('a'); // const a = document.createElement('a');
a.href = ossUrl; // a.href = ossUrl;
a.click(); // a.click();
} // }
}); // });
break; // break;
} // }
const prefixUrl = "https://view.officeapps.live.com/op/view.aspx?src="; const prefixUrl = "https://view.officeapps.live.com/op/view.aspx?src=";
const scanUrl = `${prefixUrl}${encodeURIComponent(ossUrl)}` const scanUrl = `${prefixUrl}${encodeURIComponent(ossUrl)}`
window.open(scanUrl, "_blank"); window.open(scanUrl, "_blank");
...@@ -156,11 +274,17 @@ class FolderList extends React.Component { ...@@ -156,11 +274,17 @@ class FolderList extends React.Component {
this.setState({ scanFileModal }); this.setState({ scanFileModal });
break; break;
} }
}
// 预览文件埋点 // 预览文件埋点
this.handleDataDot(folderFormat); this.handleDataDot(folderFormat);
} }
cancelPreview = ()=>{
this.setState({
previewing:false,
showPreviewModal:false,
previewStatus:'UPLOAD'
})
}
// 选择文件夹 // 选择文件夹
handleSelectFolder = (folder) => { handleSelectFolder = (folder) => {
const { folderPathList, showResultPage, currentRootDisk } = this.props; const { folderPathList, showResultPage, currentRootDisk } = this.props;
...@@ -277,8 +401,8 @@ class FolderList extends React.Component { ...@@ -277,8 +401,8 @@ class FolderList extends React.Component {
title: '操作', title: '操作',
key: 'operate', key: 'operate',
render: (value, record) => { render: (value, record) => {
if (!(currentRootDisk.disk === 'COMMON' && (folderPathList.length === 1 || record.folderType === 'FOLDER')) || if ((!(currentRootDisk.disk === 'COMMON' && (folderPathList.length === 1 || record.folderType === 'FOLDER')) ||
hasManagementAuthority) { hasManagementAuthority) && !(record.rights==="LOOK") ){
return ( return (
<Dropdown overlay={this.renderMenu(record)} trigger={['hover']}> <Dropdown overlay={this.renderMenu(record)} trigger={['hover']}>
<span className="icon iconfont">&#xe62c;</span> <span className="icon iconfont">&#xe62c;</span>
...@@ -609,14 +733,13 @@ class FolderList extends React.Component { ...@@ -609,14 +733,13 @@ class FolderList extends React.Component {
<Menu.Divider key="administration-bottom"/> <Menu.Divider key="administration-bottom"/>
] ]
} }
{ {(folderType === 'FILE' && (rights === "LOOK_DOWNLOAD" || rights === 'EDIT') ) &&
folderType === 'FILE' &&
<Menu.Item key="download"> <Menu.Item key="download">
<span onClick={() => { this.handleDownload(record) }}>下载</span> <span onClick={() => { this.handleDownload(record) }}>下载</span>
</Menu.Item> </Menu.Item>
} }
{ {(rights === "LOOK_DOWNLOAD" || rights === 'EDIT') &&
currentRootDisk.disk === 'COMMON' &&
<Menu.Item key="copy"> <Menu.Item key="copy">
<span onClick={() => this.handleShowCopyFileModal(record)}>复制到</span> <span onClick={() => this.handleShowCopyFileModal(record)}>复制到</span>
</Menu.Item> </Menu.Item>
...@@ -647,7 +770,8 @@ class FolderList extends React.Component { ...@@ -647,7 +770,8 @@ class FolderList extends React.Component {
const { const {
currentFolder, currentFile, renameModalData, showSelectFileModal, currentFolder, currentFile, renameModalData, showSelectFileModal,
showUploadModal, localFileList, showCopyFileModal, showManagingModal showUploadModal, localFileList, showCopyFileModal, showManagingModal,
showPreviewModal, previewStatus,url
} = this.state; } = this.state;
const { const {
selectedFileIds, folderList, showResultPage, selectedFileIds, folderList, showResultPage,
...@@ -790,7 +914,9 @@ class FolderList extends React.Component { ...@@ -790,7 +914,9 @@ class FolderList extends React.Component {
}} }}
/> />
} }
{ showPreviewModal &&
<PreviewFileModal onCancel={()=>this.cancelPreview()} previewStatus={previewStatus} url={url}/>
}
{ this.state.scanFileModal } { this.state.scanFileModal }
{ this.state.chargeModal } { this.state.chargeModal }
</div> </div>
......
import React from 'react';
import "./PreviewFileModal.less";
import { Spin } from 'antd'
class PreviewFileModal extends React.Component {
constructor(props) {
super(props);
this.state = {};
}
cancelPreView = ()=>{
this.props.onCancel();
}
toPreView = (url)=>{
const a = document.createElement('a');
document.body.appendChild(a);
a.setAttribute('href', url);
a.setAttribute('target', '_blank');
a.click();
document.body.removeChild(a);
this.props.onCancel();
}
render() {
const { previewStatus,url} = this.props
return (
<div className="preview-modal">
<div className="preview-modal-content">
<div className="load-img-box">
{previewStatus === "UPLOAD" &&
<Spin size="large"/>
}
{previewStatus === "UPLOAD_SUCCESS" &&
<img className="load-img" src="https://image.xiaomaiketang.com/xm/jJRK3bTEdc.png"></img>
}
</div>
<div className="load-text-box">
{previewStatus === "UPLOAD" &&
<div className="load-text-box-title">预览生成中</div>
}
{previewStatus === "UPLOAD_SUCCESS" &&
<div className="load-text-box-title">预览生成成功</div>
}
</div>
<div className="operate">
<span className="btn cancel-preview-btn" onClick={()=>this.cancelPreView()}>取消预览</span>
{previewStatus === "UPLOAD" &&
<span className="btn to-preview-btn__disabled to-preview-btn">去查看</span>
}
{previewStatus === "UPLOAD_SUCCESS" &&
<span className="btn to-preview-btn" onClick={()=>this.toPreView(url)}>去查看</span>
}
</div>
</div>
</div>
);
}
}
export default PreviewFileModal;
.preview-modal{
position: fixed;
top: 0;
right: 0;
bottom: 0;
left: 0;
z-index: 102;
height: 100%;
background: rgba(0, 0, 0, 0.7);
.preview-modal-content{
position:absolute;
left:calc(50% - 133px);
top:calc(50% - 87px);
color:#FFF;
text-align:center;
width:266px;
height:174px;
.ant-spin-dot-item{
background-color: #FFF;
}
.load-img-box{
.load-img{
width:44px;
height:44px;
}
}
.load-text-box{
margin-top:23px;
font-size:16px;
color:#FFF;
.load-text-box-title{
margin-bottom:8px;
}
}
.operate{
margin-top:24px;
.btn {
padding:5px 12px;
border:1px solid #E8E8E8;
border-radius:2px;
}
.cancel-preview-btn{
margin-right:8px;
}
.to-preview-btn__disabled{
border:1px solid #E8E8E8;
opacity: 0.4;
}
}
}
}
\ No newline at end of file
...@@ -11,6 +11,7 @@ import { Radio, Button, Dropdown, Modal, Tooltip, message } from "antd"; ...@@ -11,6 +11,7 @@ import { Radio, Button, Dropdown, Modal, Tooltip, message } from "antd";
import { LIVE_SHARE } from "@/domains/course-domain/constants"; import { LIVE_SHARE } from "@/domains/course-domain/constants";
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 StoreService from "@/domains/store-domain/storeService";
import BaseService from "@/domains/basic-domain/baseService"; import BaseService from "@/domains/basic-domain/baseService";
import { XMContext } from "@/store/context"; import { XMContext } from "@/store/context";
import logoImg from "@/common/images/logo.png"; import logoImg from "@/common/images/logo.png";
...@@ -18,6 +19,7 @@ import CourseService from "@/domains/course-domain/CourseService"; ...@@ -18,6 +19,7 @@ import CourseService from "@/domains/course-domain/CourseService";
import qrcode from "@/libs/qrcode/qrcode.js"; import qrcode from "@/libs/qrcode/qrcode.js";
import Bus from '@/core/tbus'; import Bus from '@/core/tbus';
import ClickOutside from '../../components/ClickOutside'; import ClickOutside from '../../components/ClickOutside';
import _ from "underscore";
const baseImg = "https://image.xiaomaiketang.com/xm/rJeQaZxtc7.png"; const baseImg = "https://image.xiaomaiketang.com/xm/rJeQaZxtc7.png";
const { confirm } = Modal; const { confirm } = Modal;
...@@ -33,6 +35,7 @@ function Header(props) { ...@@ -33,6 +35,7 @@ function Header(props) {
const [list, setList] = useState([]); const [list, setList] = useState([]);
const [openDropdown, setOpenDropdown] = useState(false); const [openDropdown, setOpenDropdown] = useState(false);
const [instScroll, setInstScroll] = useState(false); const [instScroll, setInstScroll] = useState(false);
const [topLeftLogo, setTopLeftLogo] = useState("https://image.xiaomaiketang.com/xm/WEsMPAYxAs.png")
const ctx = useContext(XMContext); const ctx = useContext(XMContext);
const htmlUrl = `${LIVE_SHARE}store/index?id=${User.getStoreId()}&userId=${User.getUserId()}&from=work_weixin`; const htmlUrl = `${LIVE_SHARE}store/index?id=${User.getStoreId()}&userId=${User.getUserId()}&from=work_weixin`;
const storeUserId = User.getStoreUserId(); const storeUserId = User.getStoreUserId();
...@@ -47,6 +50,7 @@ function Header(props) { ...@@ -47,6 +50,7 @@ function Header(props) {
setStoreName(value); setStoreName(value);
}); });
getStoreList(); getStoreList();
getTopLeftLogo()
}, []); }, []);
useEffect(() => { useEffect(() => {
...@@ -77,6 +81,15 @@ function Header(props) { ...@@ -77,6 +81,15 @@ function Header(props) {
}); });
} }
function getTopLeftLogo() {
if (User.getToken()) {
StoreService.getStoreDetail({storeId:User.getStoreId()})
.then(res=> {
setTopLeftLogo(res.result.logo)
})
}
}
function getStoreList() { function getStoreList() {
if (!enterpriseId) return null; if (!enterpriseId) return null;
const params = { const params = {
...@@ -219,7 +232,7 @@ function Header(props) { ...@@ -219,7 +232,7 @@ function Header(props) {
<div id="top-container" className="top-container"> <div id="top-container" className="top-container">
<div className="top top-nav"> <div className="top top-nav">
<div> <div>
<img src='https://image.xiaomaiketang.com/xm/WEsMPAYxAs.png' className="logo" alt="" /> <img src={topLeftLogo} className="logo" alt="" />
</div> </div>
<div className="message-help"> <div className="message-help">
{list.length ? ( {list.length ? (
......
/* /*
* @Author: yuananting * @Author: yuananting
* @Date: 2021-02-23 18:28:50 * @Date: 2021-02-23 18:28:50
* @LastEditors: yuananting * @LastEditors: fusanqiasng
* @LastEditTime: 2021-06-02 14:25:06 * @LastEditTime: 2021-06-15 17:55:03
* @Description: 助学工具-课程分类 * @Description: 助学工具-课程分类
* @Copyrigh: © 2020 杭州杰竞科技有限公司 版权所有 * @Copyrigh: © 2020 杭州杰竞科技有限公司 版权所有
*/ */
import React, { Component } from 'react' import React, { Component } from 'react';
import Breadcrumbs from '@/components/Breadcrumbs' import Breadcrumbs from '@/components/Breadcrumbs';
import './CourseCategoryManage.less' import './CourseCategoryManage.less';
import OpearteCourseCategoryModal from '../modal/OpearteCourseCategoryModal' import OpearteCourseCategoryModal from '../modal/OpearteCourseCategoryModal';
import AidToolService from '@/domains/aid-tool-domain/AidToolService' import AidToolService from '@/domains/aid-tool-domain/AidToolService';
import User from '@/common/js/user' import User from '@/common/js/user';
import { Tree, Input, Space, Button, Menu, Dropdown, message, Modal } from 'antd' import { Tree, Input, Space, Button, Menu, Dropdown, message, Modal } from 'antd';
import ShowTips from '@/components/ShowTips' import ShowTips from '@/components/ShowTips';
const { DirectoryTree } = Tree const { DirectoryTree } = Tree;
const { Search } = Input const { Search } = Input;
const { confirm } = Modal const { confirm } = Modal;
class CourseCategoryManage extends Component { class CourseCategoryManage extends Component {
constructor(props) { constructor(props) {
super(props) super(props);
this.state = { this.state = {
operateCourseCategoryModal: null, //新增或编辑分类模态框 operateCourseCategoryModal: null, //新增或编辑分类模态框
treeData: [], treeData: [],
originTreeData: [], originTreeData: [],
treeMap: {}, treeMap: {},
selectedKeys: ['null'], selectedKeys: ['null'],
autoExpandParent: true autoExpandParent: true,
} };
} }
componentDidMount() { componentDidMount() {
this.queryCategoryTree('init') this.queryCategoryTree('init');
} }
getWholeTree = () => { getWholeTree = () => {
...@@ -40,112 +40,112 @@ class CourseCategoryManage extends Component { ...@@ -40,112 +40,112 @@ class CourseCategoryManage extends Component {
count: false, count: false,
source: 0, source: 0,
userId: User.getStoreUserId(), userId: User.getStoreUserId(),
tenantId: User.getStoreId() tenantId: User.getStoreId(),
} };
AidToolService.queryCategoryTree(query).then((res) => { AidToolService.queryCategoryTree(query).then((res) => {
const { categoryList = [] } = res.result const { categoryList = [] } = res.result;
this.setState({ originTreeData: categoryList }, () => { this.setState({ originTreeData: categoryList }, () => {
let map = {} let map = {};
let topItem = [] let topItem = [];
categoryList.forEach((item) => { categoryList.forEach((item) => {
topItem.push(item) topItem.push(item);
}) });
this.setState({ this.setState({
treeMap: Object.assign(this.getTreeMap(categoryList, map), { treeMap: Object.assign(this.getTreeMap(categoryList, map), {
0: { 0: {
sonCategoryList: topItem sonCategoryList: topItem,
} },
}) }),
}) });
}) });
}) });
} };
// 查询分类树 // 查询分类树
queryCategoryTree = (operateType, categoryName) => { queryCategoryTree = (operateType, categoryName) => {
this.getWholeTree() this.getWholeTree();
this.setState({ categoryName }) this.setState({ categoryName });
let query = { let query = {
bizType: 'QUESTION', bizType: 'QUESTION',
count: false, count: false,
source: 0, source: 0,
categoryName, categoryName,
userId: User.getStoreUserId(), userId: User.getStoreUserId(),
tenantId: User.getStoreId() tenantId: User.getStoreId(),
} };
AidToolService.queryCategoryTree(query).then((res) => { AidToolService.queryCategoryTree(query).then((res) => {
const { categoryList = [] } = res.result const { categoryList = [] } = res.result;
let str = '未分类' let str = '未分类';
if (categoryName) { if (categoryName) {
this.setState({ autoExpandParent: true }) this.setState({ autoExpandParent: true });
if (str.indexOf(categoryName) < 0) { if (str.indexOf(categoryName) < 0) {
this.setState({ this.setState({
treeData: this.renderTreeNodes(categoryList, categoryName) treeData: this.renderTreeNodes(categoryList, categoryName),
}) });
let nodeId = [] let nodeId = [];
Object.keys(this.state.treeMap).forEach((item) => { Object.keys(this.state.treeMap).forEach((item) => {
nodeId.push(item) nodeId.push(item);
}) });
this.setState({ expandedKeys: nodeId }) this.setState({ expandedKeys: nodeId });
} else { } else {
const defaultNode = { const defaultNode = {
id: 'null', id: 'null',
categoryName: '未分类', categoryName: '未分类',
categoryCount: 0, categoryCount: 0,
parentId: '0', parentId: '0',
categoryLevel: 0 categoryLevel: 0,
} };
categoryList.unshift(defaultNode) categoryList.unshift(defaultNode);
this.setState({ this.setState({
treeData: this.renderTreeNodes(categoryList, categoryName) treeData: this.renderTreeNodes(categoryList, categoryName),
}) });
let nodeId = [] let nodeId = [];
Object.keys(this.state.treeMap).forEach((item) => { Object.keys(this.state.treeMap).forEach((item) => {
nodeId.push(item) nodeId.push(item);
}) });
if (operateType === 'init') { if (operateType === 'init') {
this.setState({ expandedKeys: nodeId }) this.setState({ expandedKeys: nodeId });
} }
} }
} else { } else {
this.setState({ autoExpandParent: false }) this.setState({ autoExpandParent: false });
const defaultNode = { const defaultNode = {
id: 'null', id: 'null',
categoryName: '未分类', categoryName: '未分类',
categoryCount: 0, categoryCount: 0,
parentId: '0', parentId: '0',
categoryLevel: 0 categoryLevel: 0,
} };
categoryList.unshift(defaultNode) categoryList.unshift(defaultNode);
this.setState({ treeData: this.renderTreeNodes(categoryList, categoryName) }) this.setState({ treeData: this.renderTreeNodes(categoryList, categoryName) });
if (operateType === 'init') { if (operateType === 'init') {
this.setState({ expandedKeys: [] }) this.setState({ expandedKeys: [] });
} }
} }
}) });
} };
// 树节点渲染-内容处理 // 树节点渲染-内容处理
renderTreeNodes = (data, value) => { renderTreeNodes = (data, value) => {
let newTreeData = data.map((item) => { let newTreeData = data.map((item) => {
item.title = item.categoryName item.title = item.categoryName;
item.key = item.id item.key = item.id;
item.title = ( item.title = (
<div <div
style={{ style={{
opacity: !value || (value && item.categoryName.indexOf(value) > -1) ? 1 : 0.5 opacity: !value || (value && item.categoryName.indexOf(value) > -1) ? 1 : 0.5,
}} }}
className='node-title-div' className='node-title-div'
onMouseOver={(e) => { onMouseOver={(e) => {
let mouseNodeOpts = e.currentTarget.getElementsByTagName('div')[0] let mouseNodeOpts = e.currentTarget.getElementsByTagName('div')[0];
if (mouseNodeOpts) { if (mouseNodeOpts) {
mouseNodeOpts.style.visibility = 'visible' mouseNodeOpts.style.visibility = 'visible';
} }
}} }}
onMouseOut={(e) => { onMouseOut={(e) => {
let mouseNodeOpts = e.currentTarget.getElementsByTagName('div')[0] let mouseNodeOpts = e.currentTarget.getElementsByTagName('div')[0];
if (mouseNodeOpts) { if (mouseNodeOpts) {
mouseNodeOpts.style.visibility = 'hidden' mouseNodeOpts.style.visibility = 'hidden';
} }
}}> }}>
<span>{item.categoryName}</span> <span>{item.categoryName}</span>
...@@ -158,9 +158,9 @@ class CourseCategoryManage extends Component { ...@@ -158,9 +158,9 @@ class CourseCategoryManage extends Component {
(item.categoryLevel === 0 && originTreeData.length >= 29) || (item.categoryLevel === 0 && originTreeData.length >= 29) ||
(item.categoryLevel > 0 && this.getRelatedNodes(item.parentId).length >= 30) (item.categoryLevel > 0 && this.getRelatedNodes(item.parentId).length >= 30)
) { ) {
return message.info('最多只能添加30个分类') return message.info('最多只能添加30个分类');
} }
this.newEditCourseCategory('newEqualLevelCategory', 'equal', 'new', item) this.newEditCourseCategory('newEqualLevelCategory', 'equal', 'new', item);
}}> }}>
<span className='icon iconfont' style={{ color: '#BFBFBF' }}> <span className='icon iconfont' style={{ color: '#BFBFBF' }}>
&#xe7f5;{' '} &#xe7f5;{' '}
...@@ -171,10 +171,10 @@ class CourseCategoryManage extends Component { ...@@ -171,10 +171,10 @@ class CourseCategoryManage extends Component {
<span <span
onClick={() => { onClick={() => {
if (this.getRelatedNodes(item.id) && this.getRelatedNodes(item.id).length >= 30) { if (this.getRelatedNodes(item.id) && this.getRelatedNodes(item.id).length >= 30) {
message.info('最多只能添加30个子分类') message.info('最多只能添加30个子分类');
return return;
} }
this.newEditCourseCategory('newChildLevelCategory', 'child', 'new', item) this.newEditCourseCategory('newChildLevelCategory', 'child', 'new', item);
}}> }}>
<span className='icon iconfont' style={{ color: '#BFBFBF' }}> <span className='icon iconfont' style={{ color: '#BFBFBF' }}>
&#xe7f8;{' '} &#xe7f8;{' '}
...@@ -193,14 +193,14 @@ class CourseCategoryManage extends Component { ...@@ -193,14 +193,14 @@ class CourseCategoryManage extends Component {
</Space> </Space>
)} )}
</div> </div>
) );
item.icon = item.icon =
item.categoryName === '未分类' ? ( item.categoryName === '未分类' ? (
<img <img
style={{ style={{
width: '24px', width: '24px',
height: '24px', height: '24px',
opacity: !value || (value && item.categoryName.indexOf(value) > -1) ? 1 : 0.5 opacity: !value || (value && item.categoryName.indexOf(value) > -1) ? 1 : 0.5,
}} }}
src='https://image.xiaomaiketang.com/xm/defaultCategory.png' src='https://image.xiaomaiketang.com/xm/defaultCategory.png'
alt='' alt=''
...@@ -210,54 +210,54 @@ class CourseCategoryManage extends Component { ...@@ -210,54 +210,54 @@ class CourseCategoryManage extends Component {
style={{ style={{
width: '24px', width: '24px',
height: '24px', height: '24px',
opacity: !value || (value && item.categoryName.indexOf(value) > -1) ? 1 : 0.5 opacity: !value || (value && item.categoryName.indexOf(value) > -1) ? 1 : 0.5,
}} }}
src='https://image.xiaomaiketang.com/xm/hasCategory.png' src='https://image.xiaomaiketang.com/xm/hasCategory.png'
alt='' alt=''
/> />
) );
if (item.sonCategoryList) { if (item.sonCategoryList) {
item.children = this.renderTreeNodes(item.sonCategoryList, value) item.children = this.renderTreeNodes(item.sonCategoryList, value);
}
return item
})
return newTreeData
} }
return item;
});
return newTreeData;
};
// 树结构平铺 // 树结构平铺
getTreeMap = (data, map) => { getTreeMap = (data, map) => {
data.forEach((item) => { data.forEach((item) => {
map[item.id] = item map[item.id] = item;
if (item.sonCategoryList && item.sonCategoryList.length > 0) { if (item.sonCategoryList && item.sonCategoryList.length > 0) {
this.getTreeMap(item.sonCategoryList, map) this.getTreeMap(item.sonCategoryList, map);
} }
}) });
return map return map;
} };
// 新增或编辑分类 // 新增或编辑分类
newEditCourseCategory = (categoryType, addLevelType, type, node) => { newEditCourseCategory = (categoryType, addLevelType, type, node) => {
let title = '' let title = '';
let label = '' let label = '';
switch (categoryType) { switch (categoryType) {
case 'newEqualLevelCategory': case 'newEqualLevelCategory':
title = '新增分类' title = '新增分类';
label = '分类名称' label = '分类名称';
break break;
case 'newChildLevelCategory': case 'newChildLevelCategory':
title = '新增子分类' title = '新增子分类';
label = '子分类名称' label = '子分类名称';
break break;
case 'editEqualLevelCategory': case 'editEqualLevelCategory':
title = '编辑分类' title = '编辑分类';
label = '分类名称' label = '分类名称';
break break;
case 'editChildLevelCategory': case 'editChildLevelCategory':
title = '编辑子分类' title = '编辑子分类';
label = '子分类名称' label = '子分类名称';
break break;
} }
const m = ( const m = (
<OpearteCourseCategoryModal <OpearteCourseCategoryModal
...@@ -267,15 +267,15 @@ class CourseCategoryManage extends Component { ...@@ -267,15 +267,15 @@ class CourseCategoryManage extends Component {
title={title} title={title}
label={label} label={label}
close={() => { close={() => {
this.queryCategoryTree('remain', this.state.categoryName) this.queryCategoryTree('remain', this.state.categoryName);
this.setState({ this.setState({
operateCourseCategoryModal: null operateCourseCategoryModal: null,
}) });
}} }}
/> />
) );
this.setState({ operateCourseCategoryModal: m }) this.setState({ operateCourseCategoryModal: m });
} };
// 删除分类 // 删除分类
delCategory = (item) => { delCategory = (item) => {
...@@ -291,17 +291,17 @@ class CourseCategoryManage extends Component { ...@@ -291,17 +291,17 @@ class CourseCategoryManage extends Component {
categoryId: item.id, categoryId: item.id,
source: 0, source: 0,
tenantId: User.getStoreId(), tenantId: User.getStoreId(),
userId: User.getStoreUserId() userId: User.getStoreUserId(),
} };
AidToolService.delCategory(params).then((res) => { AidToolService.delCategory(params).then((res) => {
if (res.success) { if (res.success) {
message.success('删除分类成功') message.success('删除分类成功');
this.queryCategoryTree('remain', this.state.categoryName) this.queryCategoryTree('remain', this.state.categoryName);
}
})
}
})
} }
});
},
});
};
// 更多操作-【重命名 删除】 // 更多操作-【重命名 删除】
initDropMenu = (item) => { initDropMenu = (item) => {
...@@ -310,8 +310,8 @@ class CourseCategoryManage extends Component { ...@@ -310,8 +310,8 @@ class CourseCategoryManage extends Component {
<Menu.Item key='0'> <Menu.Item key='0'>
<span <span
onClick={() => { onClick={() => {
let categoryType = item.categoryLevel === 0 ? 'editEqualLevelCategory' : 'editChildLevelCategory' let categoryType = item.categoryLevel === 0 ? 'editEqualLevelCategory' : 'editChildLevelCategory';
this.newEditCourseCategory(categoryType, 'equal', 'edit', item) this.newEditCourseCategory(categoryType, 'equal', 'edit', item);
}}> }}>
重命名 重命名
</span> </span>
...@@ -319,49 +319,47 @@ class CourseCategoryManage extends Component { ...@@ -319,49 +319,47 @@ class CourseCategoryManage extends Component {
<Menu.Item key='1'> <Menu.Item key='1'>
<span <span
onClick={() => { onClick={() => {
this.delCategory(item) this.delCategory(item);
}}> }}>
删除 删除
</span> </span>
</Menu.Item> </Menu.Item>
</Menu> </Menu>
) );
} };
// 获取相关节点 // 获取相关节点
getRelatedNodes = (parentId) => { getRelatedNodes = (parentId) => {
return this.state.treeMap[parentId] ? this.state.treeMap[parentId].sonCategoryList : [] return this.state.treeMap[parentId] ? this.state.treeMap[parentId].sonCategoryList : [];
} };
// 获取拖拽目标父节点层级 // 获取拖拽目标父节点层级
getParentDragNodesLevel = (dragNode) => { getParentDragNodesLevel = (dragNode) => {
if (!dragNode) { if (!dragNode) {
return [] return [];
} }
let dragNodes = [] let dragNodes = [];
dragNodes.push(dragNode.id) dragNodes.push(dragNode.id);
if (dragNode.parentId !== "0") { if (dragNode.parentId !== '0') {
dragNodes = dragNodes.concat( dragNodes = dragNodes.concat(this.getParentDragNodesLevel(this.state.treeMap[dragNode.parentId]));
this.getParentDragNodesLevel(this.state.treeMap[dragNode.parentId])
);
}
return dragNodes
} }
return dragNodes;
};
// 获取拖拽节点层级 // 获取拖拽节点层级
getDragNodesLevel = (dragNode) => { getDragNodesLevel = (dragNode) => {
let dragNodes = [] let dragNodes = [];
if (dragNode.sonCategoryList && dragNode.sonCategoryList.length > 0) { if (dragNode.sonCategoryList && dragNode.sonCategoryList.length > 0) {
dragNode.sonCategoryList.forEach((item) => { dragNode.sonCategoryList.forEach((item) => {
dragNodes.push(item.categoryLevel) dragNodes.push(item.categoryLevel);
if (item.sonCategoryList && item.sonCategoryList.length > 0) { if (item.sonCategoryList && item.sonCategoryList.length > 0) {
dragNodes = dragNodes.concat(this.getDragNodesLevel(item)) dragNodes = dragNodes.concat(this.getDragNodesLevel(item));
} }
}) });
}
return [...new Set(dragNodes)]
} }
return [...new Set(dragNodes)];
};
// 拖拽 // 拖拽
onDrop = (info) => { onDrop = (info) => {
...@@ -370,148 +368,181 @@ class CourseCategoryManage extends Component { ...@@ -370,148 +368,181 @@ class CourseCategoryManage extends Component {
// 不允许其他节点拖拽到未分类之前 // 不允许其他节点拖拽到未分类之前
if ( if (
this.state.categoryName || this.state.categoryName ||
(info.node.categoryName === "未分类" && info.dropPosition === 0) || (info.node.categoryName === '未分类' && info.dropPosition === 0) ||
(info.node.categoryName === "未分类" && (info.node.categoryName === '未分类' && info.dropToGap && info.dropPosition === -1)
info.dropToGap &&
info.dropPosition === -1)
) { ) {
return; return;
} }
// 未分类不可以拖拽 // 未分类不可以拖拽
if ( if (info.dragNode.categoryName === '未分类' && info.dragNode.categoryLevel === 0) return message.info('“未分类”为默认分类暂不支持移动');
info.dragNode.categoryName === "未分类" &&
info.dragNode.categoryLevel === 0
)
return message.info("“未分类”为默认分类暂不支持移动");
let targetParentId = info.dropToGap ? info.node.parentId : info.node.id let targetParentId = info.dropToGap ? info.node.parentId : info.node.id;
let relatedNodes = this.getRelatedNodes(targetParentId) let relatedNodes = this.getRelatedNodes(targetParentId);
if (!((info.dropToGap && info.node.parentId === info.dragNode.parentId) || (!info.dropToGap && info.node.id === info.dragNode.parentId))) { if (!((info.dropToGap && info.node.parentId === info.dragNode.parentId) || (!info.dropToGap && info.node.id === info.dragNode.parentId))) {
if (this.state.treeMap[targetParentId].categoryLevel === 4) { if (this.state.treeMap[targetParentId].categoryLevel >= 4) {
return message.info('最多支持5级分类') return message.info('最多支持5级分类');
} else { } else {
let nodesArr = this.getDragNodesLevel(this.state.treeMap[info.dragNode.id]) let nodesArr = this.getDragNodesLevel(this.state.treeMap[info.dragNode.id]);
let parentArr = this.getParentDragNodesLevel(this.state.treeMap[targetParentId]) let parentArr = this.getParentDragNodesLevel(this.state.treeMap[targetParentId]);
if (nodesArr.length + parentArr.length > 4) { if (nodesArr.length + parentArr.length > 4) {
return message.info("最多支持5级分类"); return message.info('最多支持5级分类');
} }
} }
if (relatedNodes && relatedNodes.length >= 30) { if (relatedNodes && relatedNodes.length >= 30) {
return message.info('最多只能添加30个分类') return message.info('最多只能添加30个分类');
} }
} }
const dropKey = info.node.key const dropKey = info.node.key;
const dragKey = info.dragNode.key const dragKey = info.dragNode.key;
const dropPos = info.node.pos.split('-') const dropPos = info.node.pos.split('-');
const dropPosition = info.dropPosition - Number(dropPos[dropPos.length - 1]) const dropPosition = info.dropPosition - Number(dropPos[dropPos.length - 1]);
const loop = (data, key, callback) => { const loop = (data, key, callback) => {
for (let i = 0; i < data.length; i++) { for (let i = 0; i < data.length; i++) {
if (data[i].key === key) { if (data[i].key === key) {
return callback(data[i], i, data) return callback(data[i], i, data);
} }
if (data[i].sonCategoryList) { if (data[i].sonCategoryList) {
loop(data[i].sonCategoryList, key, callback) loop(data[i].sonCategoryList, key, callback);
}
} }
} }
const data = [...this.state.treeData] };
const data = [...this.state.treeData];
let getSuf = function (name, originCategoryName, sufIndex) { let getSuf = function (name, originCategoryName, sufIndex) {
if (relatedNodes && relatedNodes.length > 0) { if (relatedNodes && relatedNodes.length > 0) {
let sameNameNodes = [] let sameNameNodes = [];
relatedNodes.forEach((item) => { relatedNodes.forEach((item) => {
if (item.id === info.dragNode.id) return true if (item.id === info.dragNode.id) return true;
if (item.categoryName === name) { if (item.categoryName === name) {
sameNameNodes.push(item) sameNameNodes.push(item);
} }
}) });
if (sameNameNodes.length > 0) { if (sameNameNodes.length > 0) {
sufIndex++ sufIndex++;
return getSuf(originCategoryName + `(${sufIndex})`, originCategoryName, sufIndex) return getSuf(originCategoryName + `(${sufIndex})`, originCategoryName, sufIndex);
} }
} }
return sufIndex return sufIndex;
} };
let dragObj let dragObj;
loop(data, dragKey, (item, index, arr) => { loop(data, dragKey, (item, index, arr) => {
arr.splice(index, 1) arr.splice(index, 1);
item.parentId = targetParentId item.parentId = targetParentId;
if (item.originCategoryName) { if (item.originCategoryName) {
item.categoryName = item.originCategoryName item.categoryName = item.originCategoryName;
} else { } else {
item.originCategoryName = item.categoryName item.originCategoryName = item.categoryName;
} }
info.dragNode.categoryName = item.originCategoryName info.dragNode.categoryName = item.originCategoryName;
let sufIndex = getSuf(info.dragNode.categoryName, item.originCategoryName, 0) let sufIndex = getSuf(info.dragNode.categoryName, item.originCategoryName, 0);
item.categoryName = item.categoryName + (sufIndex ? `(${sufIndex})` : '') item.categoryName = item.categoryName + (sufIndex ? `(${sufIndex})` : '');
item.categoryName = item.originCategoryName + (sufIndex ? `(${sufIndex})` : '') item.categoryName = item.originCategoryName + (sufIndex ? `(${sufIndex})` : '');
dragObj = item dragObj = item;
}) });
if (!info.dropToGap) { if (!info.dropToGap) {
loop(data, dropKey, (item) => { loop(data, dropKey, (item) => {
item.sonCategoryList = item.sonCategoryList || [] item.sonCategoryList = item.sonCategoryList || [];
item.sonCategoryList.unshift(dragObj) item.sonCategoryList.unshift(dragObj);
}) });
} else if ((info.node.props.sonCategoryList || []).length > 0 && info.node.props.expanded && dropPosition === 1) { } else if ((info.node.props.sonCategoryList || []).length > 0 && info.node.props.expanded && dropPosition === 1) {
loop(data, dropKey, (item) => { loop(data, dropKey, (item) => {
item.sonCategoryList = item.children || [] item.sonCategoryList = item.children || [];
item.sonCategoryList.unshift(dragObj) item.sonCategoryList.unshift(dragObj);
}) });
} else { } else {
let ar let ar;
let i let i;
loop(data, dropKey, (item, index, arr) => { loop(data, dropKey, (item, index, arr) => {
ar = arr ar = arr;
i = index i = index;
}) });
if (dropPosition === -1) { if (dropPosition === -1) {
ar.splice(i, 0, dragObj) ar.splice(i, 0, dragObj);
} else { } else {
ar.splice(i + 1, 0, dragObj) ar.splice(i + 1, 0, dragObj);
} }
} }
data.shift() data.shift();
let newTreeData = this.renderTreeNodes(this.handleLoop(data, 0)) let newTreeData = this.renderTreeNodes(this.handleLoop(data, 0));
this.setState({ treeData: newTreeData }) this.setState({ treeData: newTreeData });
let firstParentNode = {
categoryCount: 0,
categoryLevel: 0,
categoryName: '',
id: 0,
parentId: 0,
parentName: '',
rootId: 0,
sonCategoryList: [...newTreeData],
sort: 0,
source: 0,
tenantId: User.getStoreId(),
userId: User.getStoreUserId(),
};
let movedCategory = this.movedNodeFind(newTreeData, info.dragNode.id);
let parentCategory = movedCategory.parentId === '0' ? firstParentNode : this.movedNodeFind(newTreeData, targetParentId);
// let params = {
// movedCategory,
// parentCategory,
// source: 0,
// tenantId: User.getStoreId(),
// userId: User.getStoreUserId(),
// };
let params = { let params = {
categoryList: newTreeData, categoryList: newTreeData,
movedCategory,
parentCategory,
source: 0, source: 0,
tenantId: User.getStoreId(), tenantId: User.getStoreId(),
userId: User.getStoreUserId() userId: User.getStoreUserId(),
};
AidToolService.moveCategoryTree(params).then((res) => {
this.queryCategoryTree('remain');
});
};
// 获取移动节点信息
movedNodeFind(categoryList, movedId) {
for (const item of categoryList) {
if (item.id === movedId) return item;
if (item.sonCategoryList && item.sonCategoryList.length > 0) {
const node = this.movedNodeFind(item.sonCategoryList, movedId);
if (node) return node;
}
} }
AidToolService.editCategoryTree(params).then((res) => { return null;
this.queryCategoryTree('remain')
})
} }
handleLoop = (data, level) => { handleLoop = (data, level) => {
data.map((item, index) => { data.map((item, index) => {
item.sort = index item.sort = index;
item.categoryLevel = level item.categoryLevel = level;
if (item.sonCategoryList) { if (item.sonCategoryList) {
item.children = this.handleLoop(item.sonCategoryList, level + 1) item.children = this.handleLoop(item.sonCategoryList, level + 1);
item.sonCategoryList = this.handleLoop(item.sonCategoryList, level + 1) item.sonCategoryList = this.handleLoop(item.sonCategoryList, level + 1);
}
return item
})
return data
} }
return item;
});
return data;
};
// 树状展开事件 // 树状展开事件
onExpand = (expandedKeys) => { onExpand = (expandedKeys) => {
this.setState({ expandedKeys }) this.setState({ expandedKeys });
} };
// 树状选中事件 // 树状选中事件
onSelect = (selectedKeys) => { onSelect = (selectedKeys) => {
this.setState({ selectedKeys }) this.setState({ selectedKeys });
} };
render() { render() {
const { treeData, originTreeData, expandedKeys, selectedKeys, autoExpandParent, operateCourseCategoryModal } = this.state const { treeData, originTreeData, expandedKeys, selectedKeys, autoExpandParent, operateCourseCategoryModal } = this.state;
return ( return (
<div className='page course-category-manage'> <div className='page course-category-manage'>
{['aid', 'knowledge'].includes(getParameterByName('from')) ? ( {['aid', 'knowledge'].includes(getParameterByName('from')) ? (
...@@ -534,10 +565,10 @@ class CourseCategoryManage extends Component { ...@@ -534,10 +565,10 @@ class CourseCategoryManage extends Component {
type='primary' type='primary'
onClick={() => { onClick={() => {
if (originTreeData.length >= 29) { if (originTreeData.length >= 29) {
message.info('最多只能添加30个分类') message.info('最多只能添加30个分类');
return return;
} }
this.newEditCourseCategory('newEqualLevelCategory', 'equal', 'new') this.newEditCourseCategory('newEqualLevelCategory', 'equal', 'new');
}}> }}>
新增一级分类 新增一级分类
</Button> </Button>
...@@ -559,8 +590,8 @@ class CourseCategoryManage extends Component { ...@@ -559,8 +590,8 @@ class CourseCategoryManage extends Component {
</div> </div>
{operateCourseCategoryModal} {operateCourseCategoryModal}
</div> </div>
) );
} }
} }
export default CourseCategoryManage export default CourseCategoryManage;
/* /*
* @Author: yuananting * @Author: yuananting
* @Date: 2021-02-22 10:59:43 * @Date: 2021-02-22 10:59:43
* @LastEditors: yuananting * @LastEditors: fusanqiasng
* @LastEditTime: 2021-04-13 13:55:37 * @LastEditTime: 2021-06-15 11:20:48
* @Description: 助学工具-侧边课程分类树 * @Description: 助学工具-侧边课程分类树
* @Copyrigh: © 2020 杭州杰竞科技有限公司 版权所有 * @Copyrigh: © 2020 杭州杰竞科技有限公司 版权所有
*/ */
import React, { Component } from "react"; import React, { Component } from 'react';
import { Input, Button, Tree } from "antd"; import { Input, Button, Tree } from 'antd';
import "./CourseCategorySiderTree.less"; import './CourseCategorySiderTree.less';
import User from "@/common/js/user"; import User from '@/common/js/user';
import AidToolService from "@/domains/aid-tool-domain/AidToolService"; import AidToolService from '@/domains/aid-tool-domain/AidToolService';
import Bus from "@/core/bus"; import Bus from '@/core/bus';
const { Search } = Input; const { Search } = Input;
const { DirectoryTree } = Tree; const { DirectoryTree } = Tree;
...@@ -20,31 +20,25 @@ class CourseCategorySiderTree extends Component { ...@@ -20,31 +20,25 @@ class CourseCategorySiderTree extends Component {
constructor(props) { constructor(props) {
super(props); super(props);
this.state = { this.state = {
selectedKeys: ["QUESTION_INDEX", "PAPER_INDEX"].includes(props.fromModule) selectedKeys: ['QUESTION_INDEX', 'PAPER_INDEX'].includes(props.fromModule) ? [getParameterByName('categoryId') || 'null'] : ['null'],
? [getParameterByName("categoryId") || "null"]
: ["null"],
treeData: props.treeData || [], treeData: props.treeData || [],
autoExpandParent: false, autoExpandParent: false,
}; };
} }
componentDidMount() { componentDidMount() {
this.queryCategoryTree("init"); this.queryCategoryTree('init');
Bus.bind("queryCategoryTree", this.queryCategoryTree); Bus.bind('queryCategoryTree', this.queryCategoryTree);
} }
componentWillUnmount() { componentWillUnmount() {
Bus.unbind("queryCategoryTree", this.queryCategoryTree); Bus.unbind('queryCategoryTree', this.queryCategoryTree);
} }
// 查询分类树 // 查询分类树
queryCategoryTree = (type = "init", categoryName) => { queryCategoryTree = (type = 'init', categoryName) => {
let query = { let query = {
bizType: ["QUESTION_INDEX", "QUESTION_MODAL"].includes( bizType: ['QUESTION_INDEX', 'QUESTION_MODAL'].includes(this.props.fromModule) ? 'QUESTION' : 'PAPER',
this.props.fromModule
)
? "QUESTION"
: "PAPER",
categoryName, categoryName,
count: true, count: true,
source: 0, source: 0,
...@@ -53,7 +47,7 @@ class CourseCategorySiderTree extends Component { ...@@ -53,7 +47,7 @@ class CourseCategorySiderTree extends Component {
}; };
AidToolService.queryCategoryTree(query).then((res) => { AidToolService.queryCategoryTree(query).then((res) => {
const { categoryList = [], noCategoryCnt = 0 } = res.result; const { categoryList = [], noCategoryCnt = 0 } = res.result;
let str = "未分类"; let str = '未分类';
if (categoryName) { if (categoryName) {
this.setState({ autoExpandParent: true }); this.setState({ autoExpandParent: true });
if (str.indexOf(categoryName) < 0) { if (str.indexOf(categoryName) < 0) {
...@@ -64,15 +58,15 @@ class CourseCategorySiderTree extends Component { ...@@ -64,15 +58,15 @@ class CourseCategorySiderTree extends Component {
Object.keys(this.state.treeMap).forEach((item) => { Object.keys(this.state.treeMap).forEach((item) => {
nodeId.push(item); nodeId.push(item);
}); });
if (type === "init") { if (type === 'init') {
this.setState({ expandedKeys: nodeId }); this.setState({ expandedKeys: nodeId });
} }
} else { } else {
const defaultNode = { const defaultNode = {
id: "null", id: 'null',
categoryName: "未分类", categoryName: '未分类',
categoryCount: noCategoryCnt, categoryCount: noCategoryCnt,
parentId: "0", parentId: '0',
categoryLevel: 0, categoryLevel: 0,
}; };
categoryList.unshift(defaultNode); categoryList.unshift(defaultNode);
...@@ -83,24 +77,24 @@ class CourseCategorySiderTree extends Component { ...@@ -83,24 +77,24 @@ class CourseCategorySiderTree extends Component {
Object.keys(this.state.treeMap).forEach((item) => { Object.keys(this.state.treeMap).forEach((item) => {
nodeId.push(item); nodeId.push(item);
}); });
if (type === "init") { if (type === 'init') {
this.setState({ expandedKeys: nodeId }); this.setState({ expandedKeys: nodeId });
} }
} }
} else { } else {
this.setState({ autoExpandParent: false }); this.setState({ autoExpandParent: false });
const defaultNode = { const defaultNode = {
id: "null", id: 'null',
categoryName: "未分类", categoryName: '未分类',
categoryCount: noCategoryCnt, categoryCount: noCategoryCnt,
parentId: "0", parentId: '0',
categoryLevel: 0, categoryLevel: 0,
}; };
categoryList.unshift(defaultNode); categoryList.unshift(defaultNode);
this.setState({ this.setState({
treeData: this.renderTreeNodes(categoryList, categoryName), treeData: this.renderTreeNodes(categoryList, categoryName),
}); });
if (type === "init") { if (type === 'init') {
this.setState({ expandedKeys: [] }); this.setState({ expandedKeys: [] });
} }
} }
...@@ -126,12 +120,12 @@ class CourseCategorySiderTree extends Component { ...@@ -126,12 +120,12 @@ class CourseCategorySiderTree extends Component {
// 树状选中事件 // 树状选中事件
onSelect = (selectedKeys) => { onSelect = (selectedKeys) => {
this.setState({ selectedKeys }, () => { this.setState({ selectedKeys }, () => {
if (this.props.fromModule === "QUESTION_INDEX") { if (this.props.fromModule === 'QUESTION_INDEX') {
Bus.trigger("queryQuestionPageList", selectedKeys[0]); Bus.trigger('queryQuestionPageList', selectedKeys[0]);
} else if (this.props.fromModule === "QUESTION_MODAL") { } else if (this.props.fromModule === 'QUESTION_MODAL') {
Bus.trigger("queryQuestionPageListWithContent", selectedKeys[0]); Bus.trigger('queryQuestionPageListWithContent', selectedKeys[0]);
} else { } else {
Bus.trigger("queryPaperPageList", selectedKeys[0], 0); Bus.trigger('queryPaperPageList', selectedKeys[0], 0);
} }
}); });
}; };
...@@ -144,39 +138,35 @@ class CourseCategorySiderTree extends Component { ...@@ -144,39 +138,35 @@ class CourseCategorySiderTree extends Component {
item.title = item.title =
!value || (value && item.categoryName.indexOf(value) > -1) ? ( !value || (value && item.categoryName.indexOf(value) > -1) ? (
<span> <span>
{item.categoryName}{item.categoryCount} {item.categoryName}
{item.categoryCount > 0 && <span>{item.categoryCount}</span>}
</span> </span>
) : ( ) : (
<span style={{ opacity: 0.5 }}> <span style={{ opacity: 0.5 }}>
{item.categoryName}{item.categoryCount} {item.categoryName}
{item.categoryCount > 0 && <span>{item.categoryCount}</span>}
</span> </span>
); );
item.icon = item.icon =
item.categoryName === "未分类" ? ( item.categoryName === '未分类' ? (
<img <img
style={{ style={{
width: "24px", width: '24px',
height: "24px", height: '24px',
opacity: opacity: !value || (value && item.categoryName.indexOf(value) > -1) ? 1 : 0.5,
!value || (value && item.categoryName.indexOf(value) > -1)
? 1
: 0.5,
}} }}
src="https://image.xiaomaiketang.com/xm/defaultCategory.png" src='https://image.xiaomaiketang.com/xm/defaultCategory.png'
alt="" alt=''
/> />
) : ( ) : (
<img <img
style={{ style={{
width: "24px", width: '24px',
height: "24px", height: '24px',
opacity: opacity: !value || (value && item.categoryName.indexOf(value) > -1) ? 1 : 0.5,
!value || (value && item.categoryName.indexOf(value) > -1)
? 1
: 0.5,
}} }}
src="https://image.xiaomaiketang.com/xm/hasCategory.png" src='https://image.xiaomaiketang.com/xm/hasCategory.png'
alt="" alt=''
/> />
); );
if (item.sonCategoryList) { if (item.sonCategoryList) {
...@@ -190,46 +180,34 @@ class CourseCategorySiderTree extends Component { ...@@ -190,46 +180,34 @@ class CourseCategorySiderTree extends Component {
}; };
render() { render() {
const { const { treeData, expandedKeys, selectedKeys, autoExpandParent } = this.state;
treeData,
expandedKeys,
selectedKeys,
autoExpandParent,
} = this.state;
return ( return (
<div className="category-tree-sider"> <div className='category-tree-sider'>
{["QUESTION_INDEX", "PAPER_INDEX"].includes(this.props.fromModule) && ( {['QUESTION_INDEX', 'PAPER_INDEX'].includes(this.props.fromModule) && (
<div className="sider-title"> <div className='sider-title'>{this.props.fromModule === 'QUESTION_INDEX' ? '题目分类' : '试卷分类'}</div>
{this.props.fromModule === "QUESTION_INDEX"
? "题目分类"
: "试卷分类"}
</div>
)} )}
<Search <Search
className="sider-search" className='sider-search'
placeholder="搜索名称分类" placeholder='搜索名称分类'
onSearch={(value) => { onSearch={(value) => {
this.queryCategoryTree("init", value); this.queryCategoryTree('init', value);
}} }}
enterButton={<span className="icon iconfont">&#xe832;</span>} enterButton={<span className='icon iconfont'>&#xe832;</span>}
/> />
{["QUESTION_INDEX", "PAPER_INDEX"].includes(this.props.fromModule) && {['QUESTION_INDEX', 'PAPER_INDEX'].includes(this.props.fromModule) && User.getUserRole() !== 'CloudLecturer' && this.props.type !== 'modal-select' && (
User.getUserRole() !== "CloudLecturer" && <div className='sider-btn'>
this.props.type !== "modal-select" && (
<div className="sider-btn">
<Button <Button
onClick={() => { onClick={() => {
window.RCHistory.push({ window.RCHistory.push({
pathname: "/course-category-manage?from=aid", pathname: '/course-category-manage?from=aid',
}); });
}} }}>
>
分类管理 分类管理
</Button> </Button>
</div> </div>
)} )}
<div className="sider-tree"> <div className='sider-tree'>
<DirectoryTree <DirectoryTree
expandedKeys={expandedKeys} expandedKeys={expandedKeys}
autoExpandParent={autoExpandParent} autoExpandParent={autoExpandParent}
......
...@@ -184,7 +184,7 @@ function DataAnalysic(props: any) { ...@@ -184,7 +184,7 @@ function DataAnalysic(props: any) {
onClick={() => { onClick={() => {
checkAnswerDetail(record); checkAnswerDetail(record);
}}> }}>
答题详情 答题详情
</div> </div>
</When> </When>
<Otherwise>-</Otherwise> <Otherwise>-</Otherwise>
......
/* /*
* @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 11:13:36 * @LastEditTime: 2021-06-15 17:20:48
* @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 { 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';
import _ from "underscore";
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());
this.queryPaperDetail()
);
break; break;
case "copy": case 'copy':
this.setState({ currentOperate: "copy", currentNav: "复制试卷" }, () => this.setState({ currentOperate: 'copy', currentNav: '复制试卷' }, () => this.queryPaperDetail());
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(),
...@@ -150,7 +126,7 @@ class OperatePaper extends Component { ...@@ -150,7 +126,7 @@ class OperatePaper extends Component {
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(),
...@@ -163,9 +139,8 @@ class OperatePaper extends Component { ...@@ -163,9 +139,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 +163,11 @@ class OperatePaper extends Component { ...@@ -188,26 +163,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 +237,7 @@ class OperatePaper extends Component { ...@@ -277,9 +237,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 +245,7 @@ class OperatePaper extends Component { ...@@ -287,9 +245,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 +259,12 @@ class OperatePaper extends Component { ...@@ -303,15 +259,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 +274,15 @@ class OperatePaper extends Component { ...@@ -321,15 +274,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 +290,14 @@ class OperatePaper extends Component { ...@@ -337,19 +290,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 +318,23 @@ class OperatePaper extends Component { ...@@ -370,29 +318,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 +342,26 @@ class OperatePaper extends Component { ...@@ -400,34 +342,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 +369,7 @@ class OperatePaper extends Component { ...@@ -435,11 +369,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 +381,7 @@ class OperatePaper extends Component { ...@@ -451,7 +381,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 +396,17 @@ class OperatePaper extends Component { ...@@ -466,21 +396,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 +416,39 @@ class OperatePaper extends Component { ...@@ -490,39 +416,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 +456,23 @@ class OperatePaper extends Component { ...@@ -530,26 +456,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,22 +481,23 @@ class OperatePaper extends Component { ...@@ -558,22 +481,23 @@ class OperatePaper extends Component {
{ {
title: ( title: (
<span> <span>
分值{" "} 分值{' '}
<Tooltip title="多选题和填空题的漏选/半对得分不能高于题目本身分值"> <Tooltip title='多选题和填空题的漏选/半对得分不能高于题目本身分值'>
<span <span
className="icon iconfont" className='icon iconfont'
style={{ style={{
color: "#BFBFBF", fontSize: 14, fontWeight: "400" 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
...@@ -584,11 +508,7 @@ class OperatePaper extends Component { ...@@ -584,11 +508,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)
); );
...@@ -598,20 +518,14 @@ class OperatePaper extends Component { ...@@ -598,20 +518,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}
...@@ -621,9 +535,7 @@ class OperatePaper extends Component { ...@@ -621,9 +535,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)
...@@ -636,43 +548,34 @@ class OperatePaper extends Component { ...@@ -636,43 +548,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>
...@@ -688,7 +591,7 @@ class OperatePaper extends Component { ...@@ -688,7 +591,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 });
}; };
...@@ -696,13 +599,9 @@ class OperatePaper extends Component { ...@@ -696,13 +599,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)
),
}); });
}; };
...@@ -738,75 +637,70 @@ class OperatePaper extends Component { ...@@ -738,75 +637,70 @@ class OperatePaper extends Component {
totalScore, totalScore,
} = formData; } = formData;
const { match } = this.props; const { match } = this.props;
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>
), ),
}, },
]; ];
return ( return (
<div> <div>
<div className="page operate-paper-page"> <div className='page operate-paper-page'>
<Breadcrumbs navList={currentNav} goBack={() => this.handleGoBack()} /> <Breadcrumbs 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, marginBottom: '85px' }}> <Form ref={this.formRef} style={{ marginTop: 24, marginBottom: '85px' }}>
<Form.Item <Form.Item
name="paperName" name='paperName'
label="试卷名称:" label='试卷名称:'
required required
validateStatus={this.validatePaperName(paperName) ? "error" : ""} validateStatus={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: {
...@@ -819,12 +713,11 @@ class OperatePaper extends Component { ...@@ -819,12 +713,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}
...@@ -841,9 +734,9 @@ class OperatePaper extends Component { ...@@ -841,9 +734,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}
%)=及格分数( %)=及格分数(
...@@ -851,67 +744,50 @@ class OperatePaper extends Component { ...@@ -851,67 +744,50 @@ class OperatePaper extends Component {
</span> </span>
</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}
pagination={false} pagination={false}
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>
...@@ -920,8 +796,8 @@ class OperatePaper extends Component { ...@@ -920,8 +796,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={() => {
...@@ -934,27 +810,26 @@ class OperatePaper extends Component { ...@@ -934,27 +810,26 @@ 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}
pagination={false} pagination={false}
bordered={false}
/> />
)} )}
</Modal> </Modal>
...@@ -962,16 +837,7 @@ class OperatePaper extends Component { ...@@ -962,16 +837,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>
......
...@@ -277,7 +277,7 @@ class PreviewPaperModal extends Component { ...@@ -277,7 +277,7 @@ class PreviewPaperModal extends Component {
/> />
</div> </div>
} }
description={<span style={{ display: 'block', paddingBottom: 24 }}>暂无内容</span>} description={<span style={{ display: 'block', paddingBottom: 24, marginTop: 50 }}>暂无内容</span>}
></Empty> ></Empty>
); );
}; };
......
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