|
|
|
@ -9,11 +9,12 @@ |
|
|
|
|
<div v-if="isSubmit" |
|
|
|
|
class="code-mask"></div> |
|
|
|
|
<div class="btns"> |
|
|
|
|
<el-button class="btn" |
|
|
|
|
type="danger" |
|
|
|
|
@click="myCode">我的代码</el-button> |
|
|
|
|
<span class="el-icon-delete del" |
|
|
|
|
@click="clearCode"></span> |
|
|
|
|
<el-button v-if="isPrac" |
|
|
|
|
class="btn" |
|
|
|
|
type="danger" |
|
|
|
|
@click="myCode">我的代码</el-button> |
|
|
|
|
<el-button v-if="modelIsShow" |
|
|
|
|
class="btn" |
|
|
|
|
type="warning" |
|
|
|
@ -60,7 +61,7 @@ |
|
|
|
|
第{{errLine}}行出现错误 |
|
|
|
|
<el-button class="tips-btn" |
|
|
|
|
@click="getTips" |
|
|
|
|
v-show="showTips">提示</el-button> |
|
|
|
|
v-show="isPrac">提示</el-button> |
|
|
|
|
<el-dialog title="答案提示" |
|
|
|
|
center |
|
|
|
|
:close-on-click-modal="false" |
|
|
|
@ -136,13 +137,28 @@ |
|
|
|
|
|
|
|
|
|
<el-dialog title="我的代码" |
|
|
|
|
:visible.sync="codeVisible" |
|
|
|
|
width="1000px" |
|
|
|
|
width="1200px" |
|
|
|
|
:close-on-click-modal="false" |
|
|
|
|
custom-class="code-dia"> |
|
|
|
|
<div class="tool"> |
|
|
|
|
<el-input style="width: 250px" |
|
|
|
|
placeholder="请输入项目名称、判分点名称" |
|
|
|
|
v-model="keyword" |
|
|
|
|
suffix-icon="el-icon-search" |
|
|
|
|
clearable |
|
|
|
|
size="small"></el-input> |
|
|
|
|
<div class="action"> |
|
|
|
|
<el-button class="cus-btn" |
|
|
|
|
type="primary" |
|
|
|
|
size="small" |
|
|
|
|
@click="delAll">批量删除</el-button> |
|
|
|
|
</div> |
|
|
|
|
</div> |
|
|
|
|
<el-table :data="codeList" |
|
|
|
|
class="cus-table" |
|
|
|
|
ref="table" |
|
|
|
|
stripe |
|
|
|
|
max-height="400" |
|
|
|
|
header-align="center" |
|
|
|
|
@selection-change="handleSelectionChange"> |
|
|
|
|
<el-table-column type="selection" |
|
|
|
@ -152,31 +168,32 @@ |
|
|
|
|
label="序号" |
|
|
|
|
width="55" |
|
|
|
|
align="center"></el-table-column> |
|
|
|
|
<el-table-column prop="fileName" |
|
|
|
|
<el-table-column prop="judgmentName" |
|
|
|
|
label="判分点" |
|
|
|
|
min-width="250" |
|
|
|
|
align="center" |
|
|
|
|
show-overflow-tooltip></el-table-column> |
|
|
|
|
<el-table-column prop="projectName" |
|
|
|
|
label="项目名称" |
|
|
|
|
min-width="150" |
|
|
|
|
min-width="250" |
|
|
|
|
align="center" |
|
|
|
|
show-overflow-tooltip></el-table-column> |
|
|
|
|
<el-table-column prop="fileSize" |
|
|
|
|
label="判分点" |
|
|
|
|
min-width="150" |
|
|
|
|
align="center"></el-table-column> |
|
|
|
|
<el-table-column prop="createTime" |
|
|
|
|
<el-table-column prop="submitTime" |
|
|
|
|
label="提交时间" |
|
|
|
|
width="140" |
|
|
|
|
align="center"></el-table-column> |
|
|
|
|
<el-table-column prop="fileFormat" |
|
|
|
|
<el-table-column prop="score" |
|
|
|
|
label="是否得分" |
|
|
|
|
width="100" |
|
|
|
|
width="80" |
|
|
|
|
align="center"></el-table-column> |
|
|
|
|
<el-table-column width="200" |
|
|
|
|
<el-table-column width="190" |
|
|
|
|
label="操作" |
|
|
|
|
align="center"> |
|
|
|
|
<template slot-scope="scope"> |
|
|
|
|
<el-button type="text" |
|
|
|
|
@click="showCode(scope.row)">查看代码</el-button> |
|
|
|
|
<el-button type="text" |
|
|
|
|
@click="download(scope.row)">导入代码</el-button> |
|
|
|
|
@click="importCode(scope.row)">导入代码</el-button> |
|
|
|
|
<el-button type="text" |
|
|
|
|
@click="del(scope.row)">删除</el-button> |
|
|
|
|
</template> |
|
|
|
@ -199,16 +216,22 @@ |
|
|
|
|
|
|
|
|
|
<el-dialog title="查看代码" |
|
|
|
|
:visible.sync="showVisible" |
|
|
|
|
width="500px" |
|
|
|
|
width="700px" |
|
|
|
|
:close-on-click-modal="false" |
|
|
|
|
custom-class="code-dia"> |
|
|
|
|
<el-tabs v-model="showActive"> |
|
|
|
|
<el-tabs class="code-tab" |
|
|
|
|
v-model="showActive"> |
|
|
|
|
<el-tab-pane label="代码" |
|
|
|
|
name="code"> |
|
|
|
|
|
|
|
|
|
<codemirror class="code" |
|
|
|
|
v-model="curCode" |
|
|
|
|
:options="cmOptionDia"></codemirror> |
|
|
|
|
</el-tab-pane> |
|
|
|
|
<el-tab-pane label="结果" |
|
|
|
|
name="result"></el-tab-pane> |
|
|
|
|
name="result"> |
|
|
|
|
<div class="result" |
|
|
|
|
v-html="curResult"></div> |
|
|
|
|
</el-tab-pane> |
|
|
|
|
</el-tabs> |
|
|
|
|
<span slot="footer" |
|
|
|
|
class="dialog-footer"> |
|
|
|
@ -278,7 +301,8 @@ export default { |
|
|
|
|
competitionId: Cookie.get('admin-competitionId'), |
|
|
|
|
fromManager: Cookie.get('admin-fromManager'), // 是否是从教师端进入 |
|
|
|
|
courseId: Cookie.get('admin-courseId'), // 课程id |
|
|
|
|
showTips: false, // 显示隐藏提示按钮 |
|
|
|
|
mallId: Cookie.get('admin-mallId'), |
|
|
|
|
isPrac: false, // 练习 |
|
|
|
|
answer: '', // 正确答案 |
|
|
|
|
codeVal: this.code, |
|
|
|
|
runResult: '', // 运行结果 |
|
|
|
@ -314,6 +338,32 @@ export default { |
|
|
|
|
showCursorWhenSelecting: true, |
|
|
|
|
theme: "monokai" // 主题 |
|
|
|
|
}, |
|
|
|
|
cmOptionDia: { |
|
|
|
|
readOnly: true, |
|
|
|
|
scrollbarStyle: "native", |
|
|
|
|
tabSize: 2, // tab |
|
|
|
|
styleActiveLine: true, // 高亮选中行 |
|
|
|
|
lineNumbers: true, // 显示行号 |
|
|
|
|
styleSelectedText: true, |
|
|
|
|
line: true, |
|
|
|
|
foldGutter: true, // 块槽 |
|
|
|
|
gutters: ["CodeMirror-linenumbers", "CodeMirror-foldgutter"], |
|
|
|
|
highlightSelectionMatches: { showToken: /\w/, annotateScrollbar: true }, // 可以启用该选项来突出显示当前选中的内容的所有实例 |
|
|
|
|
mode: 'python', |
|
|
|
|
lineWrapping: true, //代码折叠 |
|
|
|
|
autoCloseTags: true,// 自动闭合标签 |
|
|
|
|
autoCloseBrackets: true,// 自动闭合括号 |
|
|
|
|
// hint.js options |
|
|
|
|
hintOptions: { |
|
|
|
|
// 当匹配只有一项的时候是否自动补全 |
|
|
|
|
completeSingle: false |
|
|
|
|
}, |
|
|
|
|
// 快捷键 可提供三种模式 sublime、emacs、vim |
|
|
|
|
keyMap: "sublime", |
|
|
|
|
matchBrackets: true, |
|
|
|
|
showCursorWhenSelecting: true, |
|
|
|
|
theme: "monokai" // 主题 |
|
|
|
|
}, |
|
|
|
|
inputTextReg: /^((?!#).*?(,|\s?|\(|\[|\{)+)?input(?!\w)\(['|"]([\s\S]+?)['|"]\)/m, // 匹配input() |
|
|
|
|
requestList: [], // 有input的情况下,保存每个axios的对象,用于中断请求 |
|
|
|
|
sourceCode: '', // 把input替换成exit函数后的代码 |
|
|
|
@ -342,9 +392,12 @@ export default { |
|
|
|
|
page: 1, |
|
|
|
|
pageSize: 10, |
|
|
|
|
total: 0, |
|
|
|
|
searchTimer: null, |
|
|
|
|
|
|
|
|
|
showVisible: false, |
|
|
|
|
showActive: 'code', |
|
|
|
|
curCode: '', |
|
|
|
|
curResult: '', |
|
|
|
|
}; |
|
|
|
|
}, |
|
|
|
|
components: { |
|
|
|
@ -353,10 +406,16 @@ export default { |
|
|
|
|
watch: { |
|
|
|
|
codeVal (val) { |
|
|
|
|
this.$emit("update:code", val) |
|
|
|
|
} |
|
|
|
|
}, |
|
|
|
|
keyword: function (val) { |
|
|
|
|
clearTimeout(this.searchTimer) |
|
|
|
|
this.searchTimer = setTimeout(() => { |
|
|
|
|
this.initData() |
|
|
|
|
}, 500) |
|
|
|
|
}, |
|
|
|
|
}, |
|
|
|
|
mounted () { |
|
|
|
|
if (!this.assessmentId && !this.competitionId) this.showTips = true |
|
|
|
|
if (!this.assessmentId && !this.competitionId) this.isPrac = true |
|
|
|
|
//兄弟组件传值 |
|
|
|
|
newmain.$on("isSubmit", isSubmit => { |
|
|
|
|
this.isSubmit = isSubmit |
|
|
|
@ -713,24 +772,36 @@ export default { |
|
|
|
|
}, |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// 获取我的代码 |
|
|
|
|
async getCodes () { |
|
|
|
|
const { page } = await this.$post(`${this.api.importCode}?mallId=${this.mallId}&curriculumId=${this.courseId}&projectId=${this.projectId}¤t=${this.page}&size=${this.pageSize}&projectName=${this.keyword}`) |
|
|
|
|
this.codeList = page.records |
|
|
|
|
this.total = page.total |
|
|
|
|
}, |
|
|
|
|
// 初始化列表 |
|
|
|
|
initData () { |
|
|
|
|
this.page = 1 |
|
|
|
|
this.getCodes() |
|
|
|
|
}, |
|
|
|
|
// 我的代码 |
|
|
|
|
myCode () { |
|
|
|
|
this.initData() |
|
|
|
|
this.codeVisible = true |
|
|
|
|
}, |
|
|
|
|
// 批量删除 |
|
|
|
|
delAll () { |
|
|
|
|
if (this.multipleSelection.length) { |
|
|
|
|
const newArr = this.multipleSelection |
|
|
|
|
const delList = newArr.map(item => { |
|
|
|
|
return `ids=${item.id}` |
|
|
|
|
const ids = newArr.map(e => { |
|
|
|
|
return `importId=${e.importId}` |
|
|
|
|
}) |
|
|
|
|
this.$confirm(`此批量删除操作不可逆,是否确认删除?`, '提示', { |
|
|
|
|
type: 'warning' |
|
|
|
|
}).then(() => { |
|
|
|
|
this.$post(`${this.api.batchDeletion}?${delList.join('&')}`).then(res => { |
|
|
|
|
this.$post(this.api.removeImport + '?' + ids.join('&')).then(res => { |
|
|
|
|
this.$refs.table.clearSelection() |
|
|
|
|
this.$message.success('删除成功') |
|
|
|
|
this.getData() |
|
|
|
|
this.getCodes() |
|
|
|
|
}).catch(res => { }) |
|
|
|
|
}).catch(() => { }) |
|
|
|
|
} else { |
|
|
|
@ -742,23 +813,45 @@ export default { |
|
|
|
|
this.$confirm('此删除操作不可逆,是否确认删除选中项?', '提示', { |
|
|
|
|
type: 'warning' |
|
|
|
|
}).then(() => { |
|
|
|
|
this.$post(`${this.api.batchDeletion}?ids=${row.id}`).then(res => { |
|
|
|
|
this.$post(this.api.removeImport + '?importId=' + row.importId).then(res => { |
|
|
|
|
this.$message.success('删除成功') |
|
|
|
|
this.getData() |
|
|
|
|
this.getCodes() |
|
|
|
|
}).catch(res => { }) |
|
|
|
|
}).catch(() => { }) |
|
|
|
|
}, |
|
|
|
|
handleCurrentChange (val) { |
|
|
|
|
this.page = val |
|
|
|
|
this.getData() |
|
|
|
|
this.getCodes() |
|
|
|
|
}, |
|
|
|
|
handleSelectionChange (val) { |
|
|
|
|
this.multipleSelection = val |
|
|
|
|
}, |
|
|
|
|
|
|
|
|
|
// 查看代码 |
|
|
|
|
showCode (row) { |
|
|
|
|
this.curCode = row.runCode |
|
|
|
|
this.curResult = row.runResults |
|
|
|
|
this.showVisible = true |
|
|
|
|
}, |
|
|
|
|
// 导入代码 |
|
|
|
|
importCode (row) { |
|
|
|
|
this.codeVal = row.runCode |
|
|
|
|
this.$nextTick(() => { |
|
|
|
|
const codemirror = this.$refs.codemirror.codemirror |
|
|
|
|
codemirror.focus() |
|
|
|
|
codemirror.setCursor(codemirror.lineCount(), 0) |
|
|
|
|
}) |
|
|
|
|
this.codeVisible = false |
|
|
|
|
}, |
|
|
|
|
// 导入代码 |
|
|
|
|
showSubmit () { |
|
|
|
|
|
|
|
|
|
this.codeVal = this.curCode |
|
|
|
|
this.$nextTick(() => { |
|
|
|
|
const codemirror = this.$refs.codemirror.codemirror |
|
|
|
|
codemirror.focus() |
|
|
|
|
codemirror.setCursor(codemirror.lineCount(), 0) |
|
|
|
|
}) |
|
|
|
|
this.showVisible = false |
|
|
|
|
this.codeVisible = false |
|
|
|
|
}, |
|
|
|
|
} |
|
|
|
|
}; |
|
|
|
@ -977,8 +1070,30 @@ export default { |
|
|
|
|
overflow: auto; |
|
|
|
|
} |
|
|
|
|
/deep/.code-dia { |
|
|
|
|
.el-dialog__header { |
|
|
|
|
padding: 0 20px; |
|
|
|
|
} |
|
|
|
|
.el-dialog__body { |
|
|
|
|
padding: 0 20px; |
|
|
|
|
} |
|
|
|
|
.code-tab { |
|
|
|
|
.el-tabs__item.is-active { |
|
|
|
|
color: #333 !important; |
|
|
|
|
background-color: transparent; |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
.tool { |
|
|
|
|
display: flex; |
|
|
|
|
justify-content: space-between; |
|
|
|
|
} |
|
|
|
|
.code { |
|
|
|
|
margin-top: 10px; |
|
|
|
|
} |
|
|
|
|
.result { |
|
|
|
|
font-size: 18px; |
|
|
|
|
white-space: pre-wrap; |
|
|
|
|
line-height: 50px; |
|
|
|
|
color: #333; |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
</style> |