Skip to content
项目
群组
代码片段
帮助
当前项目
正在载入...
登录 / 注册
切换导航面板
S
saas-lab
项目
项目
详情
活动
周期分析
仓库
仓库
文件
提交
分支
标签
贡献者
图表
比较
统计图
议题
0
议题
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
CI / CD
CI / CD
流水线
作业
日程
统计图
Wiki
Wiki
代码片段
代码片段
成员
成员
折叠边栏
关闭边栏
活动
图像
聊天
创建新问题
作业
提交
问题看板
Open sidebar
EzijingWeb
saas-lab
Commits
87c3707c
提交
87c3707c
authored
3月 20, 2024
作者:
王鹏飞
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
chore: 新增理论考试规则在实验成绩规则
上级
7b162517
显示空白字符变更
内嵌
并排
正在显示
2 个修改的文件
包含
106 行增加
和
35 行删除
+106
-35
api.ts
src/modules/admin/lab/experiment/api.ts
+4
-0
GradeRulesDialog.vue
...ules/admin/lab/experiment/components/GradeRulesDialog.vue
+102
-35
没有找到文件。
src/modules/admin/lab/experiment/api.ts
浏览文件 @
87c3707c
...
@@ -167,3 +167,7 @@ export function updateExam(data: { experiment_id: string; exam_id: string }) {
...
@@ -167,3 +167,7 @@ export function updateExam(data: { experiment_id: string; exam_id: string }) {
export
function
deleteExam
(
data
:
{
id
:
string
})
{
export
function
deleteExam
(
data
:
{
id
:
string
})
{
return
httpRequest
.
post
(
'/api/resource/v1/backend/experiment/exam-delete'
,
data
)
return
httpRequest
.
post
(
'/api/resource/v1/backend/experiment/exam-delete'
,
data
)
}
}
// 获取实验下的所有理论考试
export
function
getScoreExamList
(
params
:
{
experiment_id
:
string
})
{
return
httpRequest
.
get
(
'/api/resource/v1/backend/experiment-score-rule/exams'
,
{
params
})
}
src/modules/admin/lab/experiment/components/GradeRulesDialog.vue
浏览文件 @
87c3707c
...
@@ -4,7 +4,7 @@ import type { ExperimentItem } from '../types'
...
@@ -4,7 +4,7 @@ import type { ExperimentItem } from '../types'
import
{
Plus
}
from
'@element-plus/icons-vue'
import
{
Plus
}
from
'@element-plus/icons-vue'
import
{
ElMessage
}
from
'element-plus'
import
{
ElMessage
}
from
'element-plus'
import
{
gradeRule
,
gradeRuleList
}
from
'@/utils/dictionary'
import
{
gradeRule
,
gradeRuleList
}
from
'@/utils/dictionary'
import
{
getExperimentGradeRule
,
updateExperimentGradeRule
}
from
'../api'
import
{
getExperimentGradeRule
,
updateExperimentGradeRule
,
getScoreExamList
}
from
'../api'
interface
Props
{
interface
Props
{
data
:
ExperimentItem
data
:
ExperimentItem
...
@@ -21,7 +21,9 @@ const formRef = $ref<FormInstance>()
...
@@ -21,7 +21,9 @@ const formRef = $ref<FormInstance>()
const
form
=
reactive
<
any
>
({
const
form
=
reactive
<
any
>
({
experiment_id
:
props
.
data
.
id
,
experiment_id
:
props
.
data
.
id
,
is_show
:
'1'
,
is_show
:
'1'
,
rule_list
:
[{
name
:
'实验报告'
,
type
:
1
,
percent
:
100
,
rule_mode
:
1
}]
// rule_list: [{ name: '实验报告', type: 1, percent: 100, rule_mode: 1 }],
rule_list
:
[],
exam_rules
:
[]
})
})
function
fetchInfo
()
{
function
fetchInfo
()
{
...
@@ -39,15 +41,31 @@ function fetchInfo() {
...
@@ -39,15 +41,31 @@ function fetchInfo() {
Object
.
assign
(
form
,
detail
,
{
rule_list
:
ruleList
})
Object
.
assign
(
form
,
detail
,
{
rule_list
:
ruleList
})
})
})
}
}
const
examList
=
ref
<
any
>
([])
async
function
fetchExamList
()
{
const
res
=
await
getScoreExamList
({
experiment_id
:
props
.
data
.
id
})
const
items
=
res
.
data
.
items
||
[]
examList
.
value
=
items
.
map
((
item
:
any
)
=>
{
return
{
...
item
,
...
item
.
exam_info
}
})
}
onMounted
(()
=>
{
onMounted
(()
=>
{
fetchInfo
()
fetchInfo
()
fetchExamList
()
})
})
// 合计
// 合计
const
total
=
$computed
(()
=>
{
const
total
=
$computed
(()
=>
{
return
form
.
rule_list
.
reduce
((
result
:
number
,
item
:
any
)
=>
{
const
examTotal
=
form
.
exam_rules
.
reduce
((
result
:
number
,
item
:
any
)
=>
{
return
result
+
(
item
.
percent
||
0
)
return
result
+
(
item
.
percent
||
0
)
},
0
)
},
0
)
return
(
form
.
rule_list
.
reduce
((
result
:
number
,
item
:
any
)
=>
{
return
result
+
(
item
.
percent
||
0
)
},
0
)
+
examTotal
)
})
})
// 添加
// 添加
...
@@ -60,10 +78,21 @@ function handleRemove(index: number) {
...
@@ -60,10 +78,21 @@ function handleRemove(index: number) {
}
}
// 提交
// 提交
function
handleSubmit
(
call
?:
any
)
{
function
handleSubmit
(
call
?:
any
)
{
for
(
let
i
=
0
;
i
<
form
.
exam_rules
.
length
;
i
++
)
{
const
item
=
form
.
exam_rules
[
i
]
if
(
!
item
.
exam_id
)
{
ElMessage
.
error
(
`理论考试第
${
i
+
1
}
行规则配置错误,请检查后重试`
)
return
}
if
(
!
item
.
percent
)
{
ElMessage
.
error
(
`理论考试权重不能为0!`
)
return
}
}
for
(
let
i
=
0
;
i
<
form
.
rule_list
.
length
;
i
++
)
{
for
(
let
i
=
0
;
i
<
form
.
rule_list
.
length
;
i
++
)
{
const
item
=
form
.
rule_list
[
i
]
const
item
=
form
.
rule_list
[
i
]
if
(
!
item
.
name
||
!
item
.
type
)
{
if
(
!
item
.
name
||
!
item
.
type
)
{
ElMessage
.
error
(
`第
${
i
+
1
}
行规则配置错误,请检查后重试`
)
ElMessage
.
error
(
`
实操考试
第
${
i
+
1
}
行规则配置错误,请检查后重试`
)
return
return
}
}
if
(
!
item
.
percent
)
{
if
(
!
item
.
percent
)
{
...
@@ -116,16 +145,22 @@ function handleTypeChange(row: any) {
...
@@ -116,16 +145,22 @@ function handleTypeChange(row: any) {
row
.
name
=
gradeRule
[
row
.
type
]
row
.
name
=
gradeRule
[
row
.
type
]
}
}
// 占比改变
// 占比改变
function
handlePercentChange
(
row
:
any
,
index
:
number
)
{
function
handlePercentChange
(
row
:
any
,
index
:
number
,
type
:
number
)
{
const
examTotal
=
form
.
exam_rules
.
reduce
((
result
:
number
,
item
:
any
,
i
:
number
)
=>
{
if
(
index
!==
i
||
type
!==
2
)
{
result
+=
item
.
percent
||
0
}
return
result
},
0
)
const
otherTotal
=
form
.
rule_list
.
reduce
((
result
:
number
,
item
:
any
,
i
:
number
)
=>
{
const
otherTotal
=
form
.
rule_list
.
reduce
((
result
:
number
,
item
:
any
,
i
:
number
)
=>
{
if
(
index
!==
i
)
{
if
(
index
!==
i
||
type
!==
1
)
{
result
+=
item
.
percent
||
0
result
+=
item
.
percent
||
0
}
}
return
result
return
result
},
0
)
},
0
)
// 最大可输入占比
// 最大可输入占比
nextTick
(()
=>
{
nextTick
(()
=>
{
row
.
percent
=
Math
.
min
(
100
-
otherTotal
,
row
.
percent
)
row
.
percent
=
Math
.
min
(
100
-
otherTotal
-
examTotal
,
row
.
percent
)
})
})
}
}
...
@@ -142,15 +177,27 @@ const handleEdit = function (type: number) {
...
@@ -142,15 +177,27 @@ const handleEdit = function (type: number) {
)
)
})
})
}
}
// 添加
function
handleAddExamRule
()
{
form
.
exam_rules
.
push
({
id
:
''
,
exam_id
:
''
,
percent
:
undefined
,
is_auto_scoring
:
1
})
}
// 删除
function
handleRemoveExamRule
(
index
:
number
)
{
form
.
exam_rules
.
splice
(
index
,
1
)
}
function
handleExamChange
(
id
:
string
,
row
:
any
)
{
const
exam
=
examList
.
value
.
find
((
item
:
any
)
=>
item
.
id
===
id
)
if
(
!
exam
)
return
row
.
id
=
exam
.
id
row
.
exam_id
=
exam
.
exam_id
}
</
script
>
</
script
>
<
template
>
<
template
>
<el-dialog
<el-dialog
title=
"编辑实验成绩规则"
:close-on-click-modal=
"false"
width=
"800px"
@
update:modelValue=
"value => $emit('update:modelValue', value)"
>
title=
"编辑实验成绩规则"
:close-on-click-modal=
"false"
width=
"800px"
@
update:modelValue=
"$emit('update:modelValue')"
>
<el-form
ref=
"formRef"
:model=
"form"
label-suffix=
":"
>
<el-form
ref=
"formRef"
:model=
"form"
label-suffix=
":"
>
<el-form-item
label=
"实验名称"
>
{{
data
?.
name
}}
</el-form-item>
<el-form-item
label=
"实验名称"
>
{{
data
?.
name
}}
</el-form-item>
<el-row>
<el-row>
...
@@ -166,30 +213,58 @@ const handleEdit = function (type: number) {
...
@@ -166,30 +213,58 @@ const handleEdit = function (type: number) {
<el-form-item
label=
"实验总成绩"
>
{{
data
?.
score
}}
</el-form-item>
<el-form-item
label=
"实验总成绩"
>
{{
data
?.
score
}}
</el-form-item>
</el-col>
</el-col>
</el-row>
</el-row>
<el-form-item
label=
"实验成绩规则"
></el-form-item>
<el-divider></el-divider>
<el-form-item>
<el-form-item>
<el-row
justify=
"space-between"
style=
"width: 100%"
>
<el-row
justify=
"space-between"
style=
"width: 100%"
>
<p>
实验成绩规则:
</p>
<p>
理论考试:
</p>
<el-button
type=
"primary"
:icon=
"Plus"
@
click=
"handleAddExamRule"
:disabled=
"form.exam_rules.length >= 1"
>
</el-button>
</el-row>
<el-table
:data=
"form.exam_rules"
row-key=
"id"
>
<el-table-column
prop=
"name"
width=
"170"
>
<template
#
default=
"
{ row }">
<el-select
:modelValue=
"row.id"
style=
"width: 100%"
@
change=
"data => handleExamChange(data, row)"
>
<el-option
v-for=
"item in examList"
:key=
"item.id"
:label=
"item.name"
:value=
"item.id"
></el-option>
</el-select>
</
template
>
</el-table-column>
<el-table-column
prop=
"percent"
align=
"center"
width=
"200"
>
<
template
#
default=
"{ row, $index }"
>
<el-input-number
v-model=
"row.percent"
:min=
"0"
@
change=
"handlePercentChange(row, $index, 2)"
/>
%
</
template
>
</el-table-column>
<el-table-column
prop=
"is_auto_scoring"
width=
"200"
>
<
template
#
default=
"{ row }"
>
<el-radio-group
v-model=
"row.is_auto_scoring"
size=
"small"
>
<el-radio
:label=
"1"
>
自动评分
</el-radio>
<!--
<el-radio
:label=
"2"
>
人工评分
</el-radio>
-->
</el-radio-group>
</
template
>
</el-table-column>
<el-table-column
width=
"90"
>
<
template
#
default=
"{ row }"
>
满分:
{{
100
||
rowScore
(
row
.
percent
)
}}
</
template
>
</el-table-column>
<el-table-column
align=
"right"
>
<
template
#
default=
"{ $index, row }"
>
<el-button
style=
"padding: 0"
text
type=
"primary"
@
click=
"handleRemoveExamRule($index)"
v-if=
"row.type !== 1"
>
删除
</el-button>
</
template
>
</el-table-column>
</el-table>
</el-form-item>
<el-form-item>
<el-row
justify=
"space-between"
style=
"width: 100%"
>
<p>
实操考试:
</p>
<el-button
type=
"primary"
:icon=
"Plus"
@
click=
"handleAdd"
></el-button>
<el-button
type=
"primary"
:icon=
"Plus"
@
click=
"handleAdd"
></el-button>
</el-row>
</el-row>
<el-table
:data=
"form.rule_list"
row-key=
"id"
>
<el-table
:data=
"form.rule_list"
row-key=
"id"
>
<el-table-column
prop=
"name"
width=
"170"
>
<el-table-column
prop=
"name"
width=
"170"
>
<
template
#
default=
"{ row }"
>
<
template
#
default=
"{ row }"
>
<el-input
v-model=
"row.name"
:maxlength=
"20"
style=
"width: 100%"
v-if=
"row.type === 5"
/>
<el-input
v-model=
"row.name"
:maxlength=
"20"
style=
"width: 100%"
v-if=
"row.type === 5"
/>
<el-select
<el-select
v-model=
"row.type"
:disabled=
"row.type === 1"
style=
"width: 100%"
@
change=
"handleTypeChange(row)"
v-else
>
v-model=
"row.type"
:disabled=
"row.type === 1"
style=
"width: 100%"
@
change=
"handleTypeChange(row)"
v-else
>
<el-option
v-for=
"item in currentRuleNames(row.type)"
:key=
"item.value"
v-bind=
"item"
></el-option>
<el-option
v-for=
"item in currentRuleNames(row.type)"
:key=
"item.value"
v-bind=
"item"
></el-option>
</el-select>
</el-select>
</
template
>
</
template
>
</el-table-column>
</el-table-column>
<el-table-column
prop=
"percent"
align=
"center"
width=
"200"
>
<el-table-column
prop=
"percent"
align=
"center"
width=
"200"
>
<
template
#
default=
"{ row, $index }"
>
<
template
#
default=
"{ row, $index }"
>
<el-input-number
v-model=
"row.percent"
:min=
"0"
@
change=
"handlePercentChange(row, $index, 1)"
/>
%
</
template
>
<el-input-number
v-model=
"row.percent"
:min=
"0"
@
change=
"handlePercentChange(row, $index)"
/>
%
</
template
>
</el-table-column>
</el-table-column>
<el-table-column
prop=
"rule_mode"
width=
"200"
>
<el-table-column
prop=
"rule_mode"
width=
"200"
>
<
template
#
default=
"{ row }"
>
<
template
#
default=
"{ row }"
>
...
@@ -207,18 +282,10 @@ const handleEdit = function (type: number) {
...
@@ -207,18 +282,10 @@ const handleEdit = function (type: number) {
<
template
#
default=
"{ $index, row }"
>
<
template
#
default=
"{ $index, row }"
>
<div
class=
"btn-box"
>
<div
class=
"btn-box"
>
<!-- || row.type === 8 -->
<!-- || row.type === 8 -->
<el-button
<el-button
:disabled=
"row.type === 1"
style=
"padding: 0"
text
type=
"primary"
@
click=
"handleEdit(row.type)"
v-if=
"row.type !== 1"
:disabled=
"row.type === 1"
style=
"padding: 0"
text
type=
"primary"
@
click=
"handleEdit(row.type)"
v-if=
"row.type !== 1"
>
编辑
</el-button
>
编辑
</el-button
>
>
<el-button
style=
"padding: 0"
text
type=
"primary"
@
click=
"handleRemove($index)"
v-if=
"row.type !== 1"
<el-button
style=
"padding: 0"
text
type=
"primary"
@
click=
"handleRemove($index)"
>
删除
</el-button>
>
删除
</el-button
>
</div>
</div>
</
template
>
</
template
>
</el-table-column>
</el-table-column>
...
@@ -238,7 +305,7 @@ const handleEdit = function (type: number) {
...
@@ -238,7 +305,7 @@ const handleEdit = function (type: number) {
<
style
lang=
"scss"
scoped
>
<
style
lang=
"scss"
scoped
>
.total
{
.total
{
width
:
100%
;
width
:
100%
;
padding
:
10px
20
0px
;
padding
:
10px
17
0px
;
box-sizing
:
border-box
;
box-sizing
:
border-box
;
p
{
p
{
margin-left
:
16px
;
margin-left
:
16px
;
...
...
编写
预览
Markdown
格式
0%
重试
或
添加新文件
添加附件
取消
您添加了
0
人
到此讨论。请谨慎行事。
请先完成此评论的编辑!
取消
请
注册
或者
登录
后发表评论