Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
X
xiaomai-cloud-class-web
Overview
Overview
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
xiaomai-cloud-class
xiaomai-cloud-class-web
Commits
bb4a363c
Commit
bb4a363c
authored
Apr 13, 2021
by
yuananting
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
fix及格线统一整数
parent
ab61605c
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
111 additions
and
120 deletions
+111
-120
src/modules/teach-tool/paper-manage/OperatePaper.jsx
+111
-120
No files found.
src/modules/teach-tool/paper-manage/OperatePaper.jsx
View file @
bb4a363c
...
...
@@ -2,7 +2,7 @@
* @Author: yuananting
* @Date: 2021-03-27 16:15:13
* @LastEditors: yuananting
* @LastEditTime: 2021-04-13
15:12:49
* @LastEditTime: 2021-04-13
21:28:33
* @Description: 助学工具-新建/复制/编辑试卷
* @Copyrigh: © 2020 杭州杰竞科技有限公司 版权所有
*/
...
...
@@ -71,6 +71,7 @@ class OperatePaper extends Component {
currentNav
:
""
,
currentCategoryPapers
:
[],
loading
:
false
,
check
:
false
,
};
}
...
...
@@ -293,53 +294,54 @@ class OperatePaper extends Component {
return
result
;
};
validatePaperName
=
(
paperName
)
=>
{
if
(
this
.
state
.
check
&&
!
paperName
)
{
return
"请输入试卷名称"
;
}
if
(
this
.
checkExist
(
paperName
))
{
return
"该试卷名称已存在"
;
}
};
// 保存试卷
savePaper
=
async
()
=>
{
try
{
await
this
.
formRef
.
current
.
validateFields
();
const
{
selectQuestionList
,
formData
,
currentOperate
}
=
this
.
state
;
const
categoryId
=
getParameterByName
(
"categoryId"
);
let
questionList
=
[];
if
(
selectQuestionList
.
length
===
0
)
{
return
message
.
warning
(
"请选择题目"
);
}
selectQuestionList
.
forEach
((
item
,
index
)
=>
{
questionList
.
push
({
categoryId
:
item
.
categoryId
,
portionScore
:
item
.
portionScore
||
0
,
questionId
:
item
.
questionId
,
questionType
:
item
.
questionType
,
score
:
item
.
score
||
2
,
sort
:
index
,
});
this
.
setState
({
check
:
true
});
const
{
selectQuestionList
,
formData
,
currentOperate
}
=
this
.
state
;
const
categoryId
=
getParameterByName
(
"categoryId"
);
let
questionList
=
[];
if
(
!
formData
.
passRate
||
!
formData
.
paperName
)
{
return
;
}
if
(
selectQuestionList
.
length
===
0
)
{
return
message
.
warning
(
"请选择题目"
);
}
selectQuestionList
.
forEach
((
item
,
index
)
=>
{
questionList
.
push
({
categoryId
:
item
.
categoryId
,
portionScore
:
item
.
portionScore
||
0
,
questionId
:
item
.
questionId
,
questionType
:
item
.
questionType
,
score
:
item
.
score
||
2
,
sort
:
index
,
});
this
.
setState
(
{
formData
:
{
...
formData
,
questionList
,
}
,
});
this
.
setState
(
{
formData
:
{
...
formData
,
questionList
,
},
()
=>
{
if
([
"new"
,
"copy"
].
includes
(
currentOperate
))
{
AidToolService
.
createPaper
(
this
.
state
.
formData
)
.
then
((
res
)
=>
{
if
(
res
.
success
)
{
message
.
success
(
currentOperate
===
"new"
?
"新建成功"
:
"复制成功"
);
window
.
RCHistory
.
push
({
pathname
:
`/paper-manage-index?categoryId=
${
categoryId
}
`
,
});
Bus
.
trigger
(
"queryPaperPageList"
,
categoryId
,
selectQuestionList
.
length
);
Bus
.
trigger
(
"queryCategoryTree"
,
"remain"
);
}
})
.
catch
((
e
)
=>
{
},
()
=>
{
if
([
"new"
,
"copy"
].
includes
(
currentOperate
))
{
AidToolService
.
createPaper
(
this
.
state
.
formData
)
.
then
((
res
)
=>
{
if
(
res
.
success
)
{
message
.
success
(
currentOperate
===
"new"
?
"新建成功"
:
"复制成功"
);
window
.
RCHistory
.
push
({
pathname
:
`/paper-manage-index?categoryId=
${
categoryId
}
`
,
});
...
...
@@ -349,27 +351,27 @@ class OperatePaper extends Component {
selectQuestionList
.
length
);
Bus
.
trigger
(
"queryCategoryTree"
,
"remain"
);
});
}
else
if
(
currentOperate
===
"edit"
)
{
AidToolService
.
editPaper
({
...
this
.
state
.
formData
,
paperId
:
getParameterByName
(
"paperId"
),
}
})
.
then
((
res
)
=>
{
if
(
res
.
success
)
{
message
.
success
(
"编辑成功"
);
window
.
RCHistory
.
push
({
pathname
:
`/paper-manage-index?categoryId=
${
categoryId
}
`
,
});
Bus
.
trigger
(
"queryPaperPageList"
,
categoryId
,
selectQuestionList
.
length
);
Bus
.
trigger
(
"queryCategoryTree"
,
"remain"
);
}
})
.
catch
((
e
)
=>
{
.
catch
((
e
)
=>
{
window
.
RCHistory
.
push
({
pathname
:
`/paper-manage-index?categoryId=
${
categoryId
}
`
,
});
Bus
.
trigger
(
"queryPaperPageList"
,
categoryId
,
selectQuestionList
.
length
);
Bus
.
trigger
(
"queryCategoryTree"
,
"remain"
);
});
}
else
if
(
currentOperate
===
"edit"
)
{
AidToolService
.
editPaper
({
...
this
.
state
.
formData
,
paperId
:
getParameterByName
(
"paperId"
),
})
.
then
((
res
)
=>
{
if
(
res
.
success
)
{
message
.
success
(
"编辑成功"
);
window
.
RCHistory
.
push
({
pathname
:
`/paper-manage-index?categoryId=
${
categoryId
}
`
,
});
...
...
@@ -379,13 +381,22 @@ class OperatePaper extends Component {
selectQuestionList
.
length
);
Bus
.
trigger
(
"queryCategoryTree"
,
"remain"
);
}
})
.
catch
((
e
)
=>
{
window
.
RCHistory
.
push
({
pathname
:
`/paper-manage-index?categoryId=
${
categoryId
}
`
,
});
}
Bus
.
trigger
(
"queryPaperPageList"
,
categoryId
,
selectQuestionList
.
length
);
Bus
.
trigger
(
"queryCategoryTree"
,
"remain"
);
});
}
);
}
catch
(
e
)
{
console
.
log
(
e
);
}
}
);
};
// 预览试卷
...
...
@@ -621,6 +632,7 @@ class OperatePaper extends Component {
currentNav
,
formData
,
loading
,
check
,
}
=
this
.
state
;
const
{
singleChoiceCnt
,
...
...
@@ -639,7 +651,6 @@ class OperatePaper extends Component {
questionCnt
,
totalScore
,
}
=
formData
;
const
_that
=
this
;
return
(
<
div
className=
"page operate-paper-page"
>
...
...
@@ -654,21 +665,10 @@ class OperatePaper extends Component {
name=
"paperName"
label=
"试卷名称:"
required
rules=
{
[
{
required
:
true
,
message
:
"请输入试卷名称"
,
},
({
getFieldValue
})
=>
({
validator
(
_
,
value
)
{
if
(
_that
.
checkExist
(
value
))
{
return
Promise
.
reject
(
"该试卷名称已存在"
);
}
else
{
return
Promise
.
resolve
();
}
},
}),
]
}
validateStatus=
{
this
.
validatePaperName
(
paperName
)
?
"error"
:
""
}
help=
{
this
.
validatePaperName
(
paperName
)
}
>
<
Input
value=
{
paperName
}
...
...
@@ -687,45 +687,36 @@ class OperatePaper extends Component {
/>
</
Form
.
Item
>
<
Form
.
Item
label=
"及格线:"
required
>
<
Form
.
Item
name=
"passRate"
label=
"及格线:"
required
validateStatus=
{
check
&&
!
passRate
?
"error"
:
""
}
help=
{
check
&&
!
passRate
&&
"请输入及格线"
}
>
<
div
>
<
Form
.
Item
noStyle
initialValue=
{
60
}
name=
"passRate"
rules=
{
[
({
getFieldValue
})
=>
({
validator
(
_
,
value
)
{
if
(
!
value
)
{
return
Promise
.
reject
(
"请输入及格线"
);
}
else
{
return
Promise
.
resolve
();
}
},
}),
]
}
>
<
InputNumber
min=
{
1
}
max=
{
100
}
value=
{
passRate
}
onChange=
{
(
value
)
=>
{
this
.
setState
(
{
formData
:
{
...
formData
,
passRate
:
value
,
},
<
InputNumber
min=
{
1
}
max=
{
100
}
value=
{
passRate
}
onChange=
{
(
value
)
=>
{
this
.
setState
(
{
formData
:
{
...
formData
,
passRate
:
parseInt
(
value
)
||
undefined
,
},
()
=>
this
.
setFormData
(
selectQuestionList
)
);
}
}
/>
</
Form
.
Item
>
{
" "
}
},
()
=>
this
.
setFormData
(
selectQuestionList
)
);
}
}
/
>
{
" "
}
%
<
span
className=
"score-info"
>
总分(
{
totalScore
}
)*及格线(
{
passRate
||
0
}
%)=及格分数(
{
passScore
}
)
总分(
{
Number
(
totalScore
)
||
0
}
)*及格线(
{
Number
(
passRate
)
||
0
}
%)=及格分数(
{
Number
(
passScore
)
||
0
}
)
</
span
>
</
div
>
</
Form
.
Item
>
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment