|
|
|
@ -71,7 +71,7 @@ |
|
|
|
|
> |
|
|
|
|
<el-table-column prop="id" type="index" label="序号" width="80"></el-table-column> |
|
|
|
|
<el-table-column label="编译器中正确答案" align="center"> |
|
|
|
|
<template slot-scope="scope"> |
|
|
|
|
<template slot-scope="scope" v-if="scope.row.isSubject"> |
|
|
|
|
<p class="p">字段一致性规则:用户编辑器中至少出现如下语句</p> |
|
|
|
|
<el-input |
|
|
|
|
type="textarea" |
|
|
|
@ -84,17 +84,22 @@ |
|
|
|
|
<el-table-column label=" " width="150"> |
|
|
|
|
<template slot-scope="scope"> |
|
|
|
|
<el-button |
|
|
|
|
circle |
|
|
|
|
type="primary" |
|
|
|
|
v-if="scope.row.isSubject" |
|
|
|
|
:disabled="isView || scope.row.isDisabled" |
|
|
|
|
type="primary" circle |
|
|
|
|
@click="changeResult(scope.row)" |
|
|
|
|
style="position: absolute; right: 55px" |
|
|
|
|
> |
|
|
|
|
{{ scope.row.withOr === 0 ? '且' : '或' }} |
|
|
|
|
{{ scope.row.resultOperation === 0 ? '且' : '或' }} |
|
|
|
|
</el-button> |
|
|
|
|
<el-button v-else type="primary" circle @click="changeRule(scope.row, scope.$index)"> |
|
|
|
|
{{ scope.row.ruleOperation === 0 ? "且" : "或" }} |
|
|
|
|
</el-button> |
|
|
|
|
</template> |
|
|
|
|
</el-table-column> |
|
|
|
|
<el-table-column label="终端中正确答案" align="center"> |
|
|
|
|
<template slot-scope="scope"> |
|
|
|
|
<template slot-scope="scope" v-if="scope.row.isSubject"> |
|
|
|
|
<p class="p">运行结果一致性规则:用户运行结果需要与下方代码运行结果一致</p> |
|
|
|
|
<el-input |
|
|
|
|
type="textarea" |
|
|
|
@ -105,7 +110,7 @@ |
|
|
|
|
</template> |
|
|
|
|
</el-table-column> |
|
|
|
|
<el-table-column label="操作" width="300" v-if="!isView"> |
|
|
|
|
<template slot-scope="scope"> |
|
|
|
|
<template slot-scope="scope" v-if="scope.row.isSubject"> |
|
|
|
|
<el-button v-show="scope.row.isDisabled" size="mini" type="text" @click="handleEdit(scope.row)">编辑</el-button> |
|
|
|
|
<el-button v-show="!scope.row.isDisabled" size="mini" type="text" @click="handleSave(scope.row)">保存</el-button> |
|
|
|
|
<el-button v-show="!scope.row.isDisabled" size="mini" type="text" @click="handleCancel(scope.row, scope.$index)">取消</el-button> |
|
|
|
@ -178,14 +183,15 @@ export default { |
|
|
|
|
bcJudgmentRuleList: judgmentRule |
|
|
|
|
} |
|
|
|
|
// 重新封装数据 |
|
|
|
|
judgmentRule.forEach((item, index) => { |
|
|
|
|
this.tableData.push({ |
|
|
|
|
...item, |
|
|
|
|
isSubject: true, |
|
|
|
|
isDisabled: true, |
|
|
|
|
isSave: true |
|
|
|
|
}); |
|
|
|
|
}) |
|
|
|
|
this.anewPosttingData(judgmentRule) |
|
|
|
|
// judgmentRule.forEach((item, index) => { |
|
|
|
|
// this.tableData.push({ |
|
|
|
|
// ...item, |
|
|
|
|
// isSubject: true, |
|
|
|
|
// isDisabled: true, |
|
|
|
|
// isSave: true |
|
|
|
|
// }); |
|
|
|
|
// }) |
|
|
|
|
} else { |
|
|
|
|
this.$message.warning(res.message); |
|
|
|
|
} |
|
|
|
@ -193,6 +199,49 @@ export default { |
|
|
|
|
console.log(err) |
|
|
|
|
}); |
|
|
|
|
}, |
|
|
|
|
// 重新封装数据 |
|
|
|
|
anewPosttingData(judgmentRule){ |
|
|
|
|
let length = judgmentRule.length; |
|
|
|
|
let tempArr = []; |
|
|
|
|
judgmentRule.forEach((item, index) => { |
|
|
|
|
let obj = { |
|
|
|
|
...item, |
|
|
|
|
isSubject: true, |
|
|
|
|
isDisabled: true, // 已禁用 |
|
|
|
|
isSave: true // 已保存 |
|
|
|
|
}; |
|
|
|
|
//题目类型(1选择 2判断 3填空 4问答 5指标结果) |
|
|
|
|
if (item.type == 1 || item.type == 2) { |
|
|
|
|
obj.subjectId = Number(item.emptyOne); |
|
|
|
|
obj.value1 = item.itemId; |
|
|
|
|
} else if (item.type == 3) { |
|
|
|
|
obj.subjectId = Number(item.emptyOne); |
|
|
|
|
obj.value1 = item.emptyTwo; |
|
|
|
|
} else if (item.type == 4) { |
|
|
|
|
// 需要提目id |
|
|
|
|
if (item.emptyOne === "无限制") { |
|
|
|
|
obj.value1 = item.emptyOne; |
|
|
|
|
obj.value2 = ""; |
|
|
|
|
} else { |
|
|
|
|
obj.value1 = item.emptyOne.substring(0, item.emptyOne.indexOf(",")); |
|
|
|
|
obj.value2 = item.emptyOne.substring(item.emptyOne.indexOf(",") + 1, item.emptyOne.length); |
|
|
|
|
} |
|
|
|
|
obj.value3 = item.emptyTwo; |
|
|
|
|
} else if (item.type == 5) { |
|
|
|
|
obj.subjectId = Number(item.emptyOne); |
|
|
|
|
obj.value2 = item.emptyTwo[0]; |
|
|
|
|
obj.value3 = item.emptyTwo.substring(1, item.emptyTwo.indexOf("~")); |
|
|
|
|
obj.value4 = item.emptyTwo.substring(item.emptyTwo.indexOf("~") + 1, item.emptyTwo.length - 1); |
|
|
|
|
obj.value5 = item.emptyTwo[item.emptyTwo.length - 1]; |
|
|
|
|
} |
|
|
|
|
tempArr.push(obj); |
|
|
|
|
if (length > 1 && index !== (length - 1)) { |
|
|
|
|
tempArr.push({ruleOperation: item.ruleOperation}); |
|
|
|
|
} |
|
|
|
|
this.tableData = tempArr; |
|
|
|
|
console.log(this.tableData) |
|
|
|
|
}); |
|
|
|
|
}, |
|
|
|
|
handleBlur() { // 新增/编辑判分点名称判重 |
|
|
|
|
if (this.formData.points.name) { |
|
|
|
|
let params = { |
|
|
|
@ -211,10 +260,6 @@ export default { |
|
|
|
|
} |
|
|
|
|
}, |
|
|
|
|
saveAll() { // 保存判分点 |
|
|
|
|
if (!this.formData.points.name) { |
|
|
|
|
this.$message.warning(`判分点名称不能为空`); |
|
|
|
|
return; |
|
|
|
|
} |
|
|
|
|
if (this.isNameRepeat) { |
|
|
|
|
this.$message.warning(`当前判分点名称已存在`); |
|
|
|
|
return; |
|
|
|
@ -223,88 +268,126 @@ export default { |
|
|
|
|
this.$message.warning(`实验要求不能为空`); |
|
|
|
|
return; |
|
|
|
|
} |
|
|
|
|
if (!this.formData.points.experimentCode) { |
|
|
|
|
this.$message.warning(`实验代码不能为空`); |
|
|
|
|
return; |
|
|
|
|
} |
|
|
|
|
if (!this.tableData.length) { |
|
|
|
|
this.$message.warning(`请添加判分规则`); |
|
|
|
|
return; |
|
|
|
|
} else { |
|
|
|
|
for (let i = 0; i < this.tableData.length; i++) { |
|
|
|
|
if (!this.tableData[i].required) { |
|
|
|
|
this.$message.warning(`第${i + 1}项,规则要求不能为空`); |
|
|
|
|
return; |
|
|
|
|
} else if (!this.tableData[i].result) { |
|
|
|
|
this.$message.warning(`第${i + 1}项,规则结果不能为空`); |
|
|
|
|
if ((this.tableData[i].isSubject && !this.tableData[i].required) && (this.tableData[i].isSubject && !this.tableData[i].result)) { |
|
|
|
|
this.$message.warning(`第${i + 1}项,规则与结果至少填写一个`); |
|
|
|
|
return; |
|
|
|
|
} else if (!this.tableData[i].isSave) { |
|
|
|
|
} else if (this.tableData[i].isSubject && !this.tableData[i].isSave) { |
|
|
|
|
this.$message.warning(`第${i + 1}项,未保存`); |
|
|
|
|
return; |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
let tempArr = []; |
|
|
|
|
this.tableData.forEach(i => { |
|
|
|
|
let obj = { |
|
|
|
|
id: i.id ? i.id : "", |
|
|
|
|
bcId: i.bcId, |
|
|
|
|
required: i.required, |
|
|
|
|
result: i.result, |
|
|
|
|
withOr: i.withOr |
|
|
|
|
}; |
|
|
|
|
tempArr.push(obj) |
|
|
|
|
}); |
|
|
|
|
this.formData.bcJudgmentRuleList = tempArr; |
|
|
|
|
if (this.isAdd) { // 新增判分点 |
|
|
|
|
this.$post(this.api.addBcJudgmentPoint, this.formData).then(res => { |
|
|
|
|
if (res.status === 200) { |
|
|
|
|
this.$message.success("新增判分点成功"); |
|
|
|
|
this.Back(); |
|
|
|
|
} else { |
|
|
|
|
this.$message.warning(res.message); |
|
|
|
|
if (this.formData.points.name || this.formData.points.experimentCode){ |
|
|
|
|
let tempArr = []; |
|
|
|
|
this.tableData.forEach(i => { |
|
|
|
|
if (i.isSubject) { |
|
|
|
|
let obj = { |
|
|
|
|
id: i.id ? i.id : "", |
|
|
|
|
bcId: i.bcId, |
|
|
|
|
required: i.required, |
|
|
|
|
result: i.result, |
|
|
|
|
resultOperation: i.resultOperation, |
|
|
|
|
ruleOperation: i.ruleOperation |
|
|
|
|
}; |
|
|
|
|
tempArr.push(obj) |
|
|
|
|
} |
|
|
|
|
}).catch(err => { |
|
|
|
|
console.log(err) |
|
|
|
|
}) |
|
|
|
|
} else if (this.isEdit) { // 编辑判分点 |
|
|
|
|
this.$post(this.api.updateBcJudgmentPoint, this.formData).then(res => { |
|
|
|
|
if (res.status === 200) { |
|
|
|
|
this.$message.success("更新判分点成功"); |
|
|
|
|
this.Back(); |
|
|
|
|
} else { |
|
|
|
|
this.$message.warning(res.message); |
|
|
|
|
} |
|
|
|
|
}).catch(err => { |
|
|
|
|
console.log(err) |
|
|
|
|
}) |
|
|
|
|
}); |
|
|
|
|
this.formData.bcJudgmentRuleList = tempArr; |
|
|
|
|
if (this.isAdd) { // 新增判分点 |
|
|
|
|
this.$post(this.api.addBcJudgmentPoint, this.formData).then(res => { |
|
|
|
|
if (res.status === 200) { |
|
|
|
|
this.$message.success("新增判分点成功"); |
|
|
|
|
this.Back(); |
|
|
|
|
} else { |
|
|
|
|
this.$message.warning(res.message); |
|
|
|
|
} |
|
|
|
|
}).catch(err => { |
|
|
|
|
console.log(err) |
|
|
|
|
}) |
|
|
|
|
} else if (this.isEdit) { // 编辑判分点 |
|
|
|
|
this.$post(this.api.updateBcJudgmentPoint, this.formData).then(res => { |
|
|
|
|
if (res.status === 200) { |
|
|
|
|
this.$message.success("更新判分点成功"); |
|
|
|
|
this.Back(); |
|
|
|
|
} else { |
|
|
|
|
this.$message.warning(res.message); |
|
|
|
|
} |
|
|
|
|
}).catch(err => { |
|
|
|
|
console.log(err) |
|
|
|
|
}) |
|
|
|
|
} |
|
|
|
|
}else{ |
|
|
|
|
this.$message.warning(`实验代码与判分点名称至少填写一个`); |
|
|
|
|
// if (!this.formData.points.name) { |
|
|
|
|
// this.$message.warning(`判分点名称不能为空`); |
|
|
|
|
// return; |
|
|
|
|
// } |
|
|
|
|
// if (!this.formData.points.experimentCode) { |
|
|
|
|
// |
|
|
|
|
// return; |
|
|
|
|
// } |
|
|
|
|
} |
|
|
|
|
}, |
|
|
|
|
addRule() { // 新增规则 |
|
|
|
|
this.isAddRule = true; |
|
|
|
|
this.tableData.push({ |
|
|
|
|
isDisabled: false, // 不禁用 |
|
|
|
|
isSave: false, // 未保存 |
|
|
|
|
bcId: this.bcId, |
|
|
|
|
required: "", |
|
|
|
|
result: "", |
|
|
|
|
withOr: 0 |
|
|
|
|
}); |
|
|
|
|
if(!this.isAddRule) { |
|
|
|
|
this.isAddRule = true; |
|
|
|
|
// this.tableData.length && this.tableData.push({ruleOperation: 0, indexNo: ""}); |
|
|
|
|
if (this.tableData.length > 0) { |
|
|
|
|
this.tableData.push({ |
|
|
|
|
ruleOperation: 0 |
|
|
|
|
}, { |
|
|
|
|
indexNo: this.tableData.length + 1, |
|
|
|
|
isSubject: true, |
|
|
|
|
isDisabled: false, // 不禁用 |
|
|
|
|
isSave: false, // 未保存 |
|
|
|
|
lcId: this.lcId, |
|
|
|
|
resultOperation: 0, |
|
|
|
|
ruleOperation: 0, |
|
|
|
|
operationIds: "", |
|
|
|
|
value1: "", |
|
|
|
|
value2: "", |
|
|
|
|
value3: "", |
|
|
|
|
value4: "", |
|
|
|
|
value5: "" |
|
|
|
|
}); |
|
|
|
|
} else { |
|
|
|
|
this.tableData.push({ |
|
|
|
|
indexNo: this.tableData.length + 1, |
|
|
|
|
isSubject: true, |
|
|
|
|
isDisabled: false, // 不禁用 |
|
|
|
|
isSave: false, // 未保存 |
|
|
|
|
lcId: this.lcId, |
|
|
|
|
resultOperation: 0, |
|
|
|
|
ruleOperation: 0, |
|
|
|
|
operationIds: "", |
|
|
|
|
value1: "", |
|
|
|
|
value2: "", |
|
|
|
|
value3: "", |
|
|
|
|
value4: "", |
|
|
|
|
value5: "" |
|
|
|
|
}); |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
}, |
|
|
|
|
changeResult(row) { // (左右)结果运算符(0:且 1:或 默认0) |
|
|
|
|
row.withOr = row.withOr === 0 ? 1 : 0; |
|
|
|
|
row.resultOperation = row.resultOperation === 0 ? 1 : 0; |
|
|
|
|
}, |
|
|
|
|
changeRule(row, index) { // (上下)规则运算符(0:且 1:或 默认0) |
|
|
|
|
row.ruleOperation = row.ruleOperation === 0 ? 1 : 0; |
|
|
|
|
this.tableData[index - 1].ruleOperation = row.ruleOperation; |
|
|
|
|
}, |
|
|
|
|
handleEdit(row) { // 处理编辑规则 |
|
|
|
|
this.tableDataCopy = deepCopy(this.tableData); // 深拷贝 |
|
|
|
|
row.isDisabled = false; |
|
|
|
|
}, |
|
|
|
|
handleSave(row) { // 处理保存规则 |
|
|
|
|
if (!row.required) { |
|
|
|
|
this.$message.warning(`规则要求不能为空`); |
|
|
|
|
return; |
|
|
|
|
} |
|
|
|
|
if (!row.result) { |
|
|
|
|
this.$message.warning(`规则结果不能为空`); |
|
|
|
|
if (!row.required && !row.result) { |
|
|
|
|
this.$message.warning(`规则与结果至少填写一个`); |
|
|
|
|
return; |
|
|
|
|
} |
|
|
|
|
row.isSave = true; |
|
|
|
@ -315,7 +398,8 @@ export default { |
|
|
|
|
if (row.isSave) { |
|
|
|
|
this.$set(this.tableData, index, this.tableDataCopy[index]); |
|
|
|
|
} else { |
|
|
|
|
this.tableData.splice(index, 1); |
|
|
|
|
this.tableData.splice(index-1, 2); |
|
|
|
|
// this.tableData.splice(index, 1); |
|
|
|
|
this.isAddRule = false; |
|
|
|
|
} |
|
|
|
|
}, |
|
|
|
@ -326,7 +410,12 @@ export default { |
|
|
|
|
type: "warning", |
|
|
|
|
center: true, |
|
|
|
|
}).then(() => { |
|
|
|
|
this.tableData.splice(index, 1); |
|
|
|
|
if (index+1 == this.tableData.length){ |
|
|
|
|
this.tableData.splice(index - 1, 2) |
|
|
|
|
}else{ |
|
|
|
|
this.tableData.splice(index,2); |
|
|
|
|
} |
|
|
|
|
this.itemkey = Math.random() |
|
|
|
|
this.isAddRule = false; |
|
|
|
|
}).catch(() => {}) |
|
|
|
|
}, |
|
|
|
|