Skip to content

Commit

Permalink
fix:评分逻辑
Browse files Browse the repository at this point in the history
  • Loading branch information
NJUPTlay committed Mar 27, 2024
1 parent 4c13fbb commit 2bc1b0c
Show file tree
Hide file tree
Showing 5 changed files with 49 additions and 20 deletions.
2 changes: 1 addition & 1 deletion src/pages/home/index.scss
Original file line number Diff line number Diff line change
Expand Up @@ -245,7 +245,7 @@
}
.validate-img {
width: 60%;
height: 32px;
height: 33px;
border-radius: 0 5px 5px 0;
}
}
Expand Down
8 changes: 6 additions & 2 deletions src/pages/review/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -122,6 +122,9 @@ interface IJudgeReview {
// 身份为审批人员时表格内容
const JudgeReview: React.FC<IJudgeReview> = (props) => {
const { getPageNum, list, total, pageSize, loading } = props




// 表头内容
const columns: ColumnsType<DataListType> = [
Expand All @@ -140,8 +143,8 @@ const JudgeReview: React.FC<IJudgeReview> = (props) => {
title: '待审批数',
render(value, record, index) {
return (
<td className={list[index].totalNum === 0 ? 'tdnum nopoint' : 'tdnum redPoint'}>
{list[index].totalNum}
<td className={list[index].totalNum - list[index].completedNum === 0 ? 'tdnum nopoint' : 'tdnum redPoint'}>
{list[index].totalNum - list[index].completedNum}
</td>
)
},
Expand Down Expand Up @@ -225,6 +228,7 @@ const JudgeReview: React.FC<IJudgeReview> = (props) => {
// 身份为评审人员时表格内容
const ApproverReview: React.FC<IJudgeReview> = (props) => {
const { getPageNum, list, total, pageSize, loading } = props

// 表头内容
const columns: ColumnsType<DataListType> = [
{
Expand Down
4 changes: 3 additions & 1 deletion src/pages/reviewApprover/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -99,7 +99,9 @@ const ReviewApprover: React.FC = (props) => {
}
// 处理提交事件
const handleSubmit = () => {
if (score === null || score === undefined || score <= 0 || score <= 100) {
console.log(score);

if (score === null || score === undefined || score <= 0 || score > 100) {
setTimeout(() => {
notification.info({
message: 'x 提交失败',
Expand Down
4 changes: 3 additions & 1 deletion src/pages/reviewJudge/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -91,7 +91,9 @@ const ReviewJudge: React.FC = (props) => {
})
}
const handleSubmit = () => {
if (opinion !== '') {
console.log(isPass);

if (isPass || (!isPass && opinion !== '')) {
uploadWorkJudgeInfo(Number(id), isPass!, opinion!).then(() => {
// if (Number(id) === total) {
// setTimeout(() => {
Expand Down
51 changes: 36 additions & 15 deletions src/pages/reviewList/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ function ReviewList() {
navigate(`/review/list/${comId}/${current}`)
}

function resDataProcessing(res: any) {
function resDataProcessing(res: any, role: string) {
const result = res.data.data
if (result === null) {
setTimeout(() => {
Expand All @@ -47,25 +47,46 @@ function ReviewList() {
}, 100)
navigate('/review')
}
console.log(res.data.data);

const programList = res.data.data.list
console.log(programList);

let approveCount = 0
for (let i = 0; i < programList.length; i++) {
const isApprove = programList[i].score !== null || programList[i].score !== undefined
programList[i].isApprove = isApprove
if (isApprove) {
approveCount++
if (role === 'approver') {
let scoreCount = 0
let isScore;
for (let i = 0; i < programList.length; i++) {
programList[i]?.score ? isScore = true : isScore = false
// const isApprove = programList[i]?.score !== null || programList[i]?.score !== undefined
// console.log(isApprove);

programList[i].isApprove = isScore
if (isScore) {
scoreCount++
}
}
result.list[i].isPass = result.list[i].isPass === true ? '通过' : '未通过'

setIsApproveCount(scoreCount)
} else {
let passCount = 0
let _isPass;
for (let i = 0; i < programList.length; i++) {
console.log(programList);

programList[i]?.isPass ? _isPass = true : _isPass = false
programList[i].isPass = _isPass
if (_isPass) {
passCount++
}
result.list[i].isPass = result.list[i].isPass === true ? '通过' : '未通过'
console.log(programList[i].isApprove)
}
setIsApproveCount(passCount)
}
setIsApproveCount(approveCount)
setProgramList(programList)
setDataList(result)
localStorage.setItem('listTotal', res.data.data.total)
setLoading(false)

}

// 获取表格数据
Expand All @@ -82,13 +103,12 @@ function ReviewList() {
setIsEnd(currentTime > comDate.getTime())
if (userState === 'approver') {
getScoreWorkList(Number(comId), Number(page)).then((res) => {
resDataProcessing(res)
resDataProcessing(res, 'approver')
})
} else {
getJudgeWorkList(Number(comId), Number(page)).then((res) => {
console.log(res);

resDataProcessing(res);
resDataProcessing(res, 'judge');
// const result = res.data.data
// if (result === null) {
// setTimeout(() => {
Expand All @@ -112,6 +132,8 @@ function ReviewList() {

}, [pageNum])



const table = (
<ProgramList
loading={loading}
Expand Down Expand Up @@ -151,7 +173,6 @@ const ProgramList: React.FC<IProgramList> = (props: any) => {
// const [id, setId] = useState(0)
const navigate = useNavigate()


// 修改页面内容
const changePageNum = (current: number) => {
setCurrent(current)
Expand Down Expand Up @@ -183,7 +204,7 @@ const ProgramList: React.FC<IProgramList> = (props: any) => {
{
key: '5',
title: '状态',
dataIndex: 'isApprove',
dataIndex: role === 'approver' ? 'isApprove' : 'isJudge',
render: (data) => {
return <Space>
<Tag color={data ? "green" : "red"} key={data}>
Expand Down

0 comments on commit 2bc1b0c

Please sign in to comment.