openf12
yujialong 2 years ago
parent ac2f86b339
commit c53b018596
  1. 15
      public/index.html
  2. 3
      src/api/index.js
  3. 239
      src/components/TestPanel.vue
  4. 295
      src/components/codemirror.vue
  5. 6
      src/config/index.js
  6. 977
      src/views/Data.vue
  7. 49
      src/views/Home.vue

@ -1,15 +1,20 @@
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="utf-8">
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<meta name="viewport" content="width=device-width,initial-scale=1.0">
<link rel="icon" href="<%= BASE_URL %>favicon.ico">
<meta charset="utf-8" />
<meta http-equiv="X-UA-Compatible" content="IE=edge" />
<meta name="viewport" content="width=device-width,initial-scale=1.0" />
<!-- <meta http-equiv="X-Frame-Options" content="deny" /> -->
<link rel="icon" href="<%= BASE_URL %>favicon.ico" />
<title><%= htmlWebpackPlugin.options.title %></title>
</head>
<body>
<noscript>
<strong>We're sorry but <%= htmlWebpackPlugin.options.title %> doesn't work properly without JavaScript enabled. Please enable it to continue.</strong>
<strong
>We're sorry but <%= htmlWebpackPlugin.options.title %> doesn't work
properly without JavaScript enabled. Please enable it to
continue.</strong
>
</noscript>
<div id="app"></div>
<!-- built files will be auto injected -->

@ -21,6 +21,7 @@ export default {
getDetailById: 'occupationlab/occupationlab/assessment/getDetailById',
pageStuAssessment: 'occupationlab/occupationlab/assessment/pageStuAssessment',
modelClassList: `nakadai/nakadai/model/reference/modelClassList`,
studentModelList: `nakadai/nakadai/model/student/studentModelList`,
referenceDemoList: `nakadai/nakadai/model/reference/demo/referenceDemoList`,
referenceFindById: `nakadai/nakadai/model/reference/demo/findById`,
checkIsShowBySystemId: `nakadai/nakadai/model/reference/checkIsShowBySystemId`,
@ -34,4 +35,6 @@ export default {
exportLabReport: `occupationlab/occupationlab/achievement/exportLabReport`,
reportDetail: `occupationlab/occupationlab/achievement/reportDetail`,
getCompetition: `competition/competition/management/getCompetition`,
whetherCanPaste: `nakadai/nakadai/model/demo/whetherCanPaste`,
displayListOrNotByStudent: `nakadai/nakadai/model/demo/displayListOrNotByStudent`,
}

@ -1,29 +1,30 @@
<template>
<div :class="['panel', {active: pannelVisible}]" id="panel">
<el-container class="scrollbar" v-if="pannelVisible">
<el-header>
<div :class="['panel', {active: pannelVisible}]"
id="panel">
<el-container class="scrollbar"
v-if="pannelVisible">
<el-header id="header">
<div class="panel-header">
<div class="project">
<div class="inline-center">
<p>实训项目</p>
<el-tooltip effect="dark" content="点击右侧“下三角”按钮可切换实验项目" placement="bottom">
<i class="info el-icon-warning" style="margin-left: 10px"></i>
<el-tooltip effect="dark"
content="点击右侧“下三角”按钮可切换实验项目"
placement="bottom">
<i class="info el-icon-warning"
style="margin-left: 10px"></i>
</el-tooltip>
</div>
<el-select
v-model="projectId"
placeholder="请选择"
class="select"
:disabled="projectPermissions != 0"
@change="selectProject"
style="flex: 1"
>
<el-option
v-for="(item, i) in projectList"
:key="item.projectId"
:label="i + 1 + '. ' + item.projectName"
:value="item.projectId"
></el-option>
<el-select v-model="projectId"
placeholder="请选择"
class="select"
:disabled="projectPermissions != 0"
@change="selectProject"
style="flex: 1">
<el-option v-for="(item, i) in projectList"
:key="item.projectId"
:label="i + 1 + '. ' + item.projectName"
:value="item.projectId"></el-option>
</el-select>
</div>
<div class="item">
@ -35,16 +36,23 @@
<span>{{seconds}}</span>
</div>
</div>
<div v-if="!competitionId" class="item">
<div v-if="!competitionId"
class="item">
<div>
总得分
<span class="total-score">{{grade}}</span>
</div>
</div>
<div>
<el-button @click="toReport" v-if="isSubmit && !competitionId">查看实验报告</el-button>
<el-button class="reload" @click="reload" v-show="projectPermissions == 0">重新开始</el-button>
<el-button type="primary" class="submit btn" @click="confirmSubmit" :disabled="isSubmit || !projectList.length">提交</el-button>
<el-button @click="toReport"
v-if="isSubmit && !competitionId">查看实验报告</el-button>
<el-button class="reload"
@click="reload"
v-show="projectPermissions == 0">重新开始</el-button>
<el-button type="primary"
class="submit btn"
@click="confirmSubmit"
:disabled="isSubmit || !projectList.length">提交</el-button>
</div>
</div>
</el-header>
@ -56,7 +64,8 @@
<p>实验目标</p>
</div>
<div class="goal">
<div class="ql-editor" v-html="experimentTarget"></div>
<div class="ql-editor"
v-html="experimentTarget"></div>
</div>
</div>
<div class="aside-footer">
@ -67,30 +76,38 @@
<div>
<el-row>
<el-col :span="24">
<el-card shadow="never" :border="false">
<el-table :data="taskList" :stripe="true">
<el-card shadow="never"
:border="false">
<el-table :data="taskList"
:stripe="true">
<el-table-column type="index"></el-table-column>
<el-table-column prop="name" label="判分点" align="center"></el-table-column>
<el-table-column prop="score" label="分值" width="60" align="center"></el-table-column>
<el-table-column prop="name"
label="判分点"
align="center"></el-table-column>
<el-table-column prop="score"
label="分值"
width="60"
align="center"></el-table-column>
<template v-if="!competitionId">
<el-table-column label="结果" width="60" align="center">
<el-table-column label="结果"
width="60"
align="center">
<template slot-scope="scope">
<template v-if="isSubmit">
<template v-if="!competitionId">
<i
v-if="scope.row.finishedResult"
class="el-icon-check right"
></i>
<i
v-else
class="el-icon-close wrong"
></i>
<i v-if="scope.row.finishedResult"
class="el-icon-check right"></i>
<i v-else
class="el-icon-close wrong"></i>
</template>
<template v-else>-</template>
</template>
</template>
</el-table-column>
<el-table-column prop="score" label="得分" width="60" align="center">
<el-table-column prop="score"
label="得分"
width="60"
align="center">
<template slot-scope="scope">
<template v-if="isSubmit">{{ competitionId ? '-' : scope.row.examScore }}</template>
</template>
@ -104,23 +121,34 @@
</div>
</el-aside>
<el-main>
<el-tabs v-model="pannelTab" type="card">
<el-tab-pane label="项目背景" name="first">
<div class="ql-editor" v-html="experimentDescription"></div>
<el-tabs v-model="pannelTab"
type="card">
<el-tab-pane label="项目背景"
name="first">
<div class="ql-editor"
v-html="experimentDescription"></div>
</el-tab-pane>
<el-tab-pane label="实验要求" name="second">
<el-tab-pane label="实验要求"
name="second">
<el-collapse v-model="curReq">
<el-collapse-item v-for="item in points" :name="item.judgmentId" :key="item.judgmentId">
<el-collapse-item v-for="item in points"
:name="item.judgmentId"
:key="item.judgmentId">
<template slot="title">
<i class="el-icon-s-ticket"></i>
<div class="break-all des" v-html="item.name"></div>
<div class="break-all des"
v-html="item.name"></div>
</template>
<div class="ql-editor" v-html="item.experimentalRequirements"></div>
<div class="ql-editor"
v-html="item.experimentalRequirements"></div>
</el-collapse-item>
</el-collapse>
</el-tab-pane>
<el-tab-pane label="实验提示" name="fifth" v-if="hintOpen">
<div class="ql-editor" v-html="experimentHint"></div>
<el-tab-pane label="实验提示"
name="fifth"
v-if="hintOpen">
<div class="ql-editor"
v-html="experimentHint"></div>
</el-tab-pane>
</el-tabs>
</el-main>
@ -129,8 +157,14 @@
<div :class="['toggle-panel', {active: pannelVisible}]">
<div @click="togglePannel">
<img :src="require(`@/assets/images/system/${$config.defaultSystem}/left.png`)" alt class="c-p" v-if="pannelVisible" />
<img :src="require(`@/assets/images/system/${$config.defaultSystem}/right.png`)" alt class="c-p" v-if="!pannelVisible" />
<img :src="require(`@/assets/images/system/${$config.defaultSystem}/left.png`)"
alt
class="c-p"
v-if="pannelVisible" />
<img :src="require(`@/assets/images/system/${$config.defaultSystem}/right.png`)"
alt
class="c-p"
v-if="!pannelVisible" />
</div>
</div>
</div>
@ -145,7 +179,7 @@ import 'quill/dist/quill.core.css';
import 'quill/dist/quill.snow.css';
import 'quill/dist/quill.bubble.css';
export default {
data() {
data () {
return {
token: Cookie.get('admin-token'),
systemId: Cookie.get('admin-systemId') || 1,
@ -189,13 +223,13 @@ export default {
reportId: ''
};
},
mounted() {
mounted () {
// 210
this.projectPermissions = this.assessmentId ?
1 :
this.competitionId ?
2 :
0
0
if (this.assessmentId) { // assessmentIdcompetitionId)
this.getAssList()
} else { //
@ -208,7 +242,7 @@ export default {
} else {
this.getCache()
}
}).catch(res => {})
}).catch(res => { })
if (this.competitionId) {
clearInterval(this.statusTimer)
this.statusTimer = setInterval(_ => {
@ -220,14 +254,14 @@ export default {
},
methods: {
//
getList(){
getList () {
let data = {
systemId: this.systemId,
cId: this.courseId, // id
permissions: this.projectPermissions // //
}
return new Promise((resolve, reject) => {
this.$get(`${this.api.queryTestProject}`,data).then(res => {
this.$get(`${this.api.queryTestProject}`, data).then(res => {
const list = res.projects
this.projectList = list
if (!this.projectPermissions && !this.projectId) this.projectId = list ? list[0].projectId : 0 //
@ -242,7 +276,7 @@ export default {
})
},
//
getProDetail() {
getProDetail () {
const projectId = this.projectId
return new Promise((resolve, reject) => {
this.$get(this.api.getProjectDetail, {
@ -251,6 +285,7 @@ export default {
}).then(res => {
const points = res.projectJudgmentVos
const project = res.projectManage
const mg = res.projectManage
const curReq = []
//
if (project.systemId == 11) {
@ -264,8 +299,8 @@ export default {
points.map((e, i) => {
e.code = '' // code
e.codeId = '' // codeIdcodeId
e.answer = '' //
e.retResult = '' // (1 0)
e.answer = '' //
e.retResult = '' // (1 0)
curReq.push(e.judgmentId)
})
if (this.projectPermissions) {
@ -284,7 +319,7 @@ export default {
this.experimentTarget = project.experimentTarget
this.experimentDescription = project.experimentDescription
this.experimentHint = project.experimentHint
this.hintOpen = !res.projectManage.hintOpen // 01
this.hintOpen = mg.founder ? !mg.hintOpenBySchool : !mg.hintOpen // 01
this.$emit('tell', projectId, systemId, this.points)
const isPrac = this.projectPermissions == 0 //
this.text = isPrac ? '已用' : '剩余'
@ -300,12 +335,12 @@ export default {
})
},
// loadingtrue
closeLoad() {
closeLoad () {
this.$parent.loadIns.close()
this.$parent.loaded = true
},
//
getAssList(){
getAssList () {
this.$post(`${this.api.pageStuAssessment}`, {
pageNum: 1,
pageSize: 10000
@ -314,7 +349,7 @@ export default {
const assessmentId = this.assessmentId
let done = false
const classId = this.classId
// reportIdclassIdclassId
// reportIdclassIdclassId
if (list.find(e => e.assessmentId == assessmentId && e.reportId && e.classId == classId)) {
done = true
this.isSubmit = true
@ -328,16 +363,16 @@ export default {
if (!done) {
this.getList().then(() => {
this.getCache()
}).catch(res => {})
}).catch(res => { })
//
this.statusTimer = setInterval(_ => {
this.getAssStatus()
}, 1000)
}
}).catch(res => {})
}).catch(res => { })
},
//
getCache(cache) {
getCache (cache) {
const pId = cache ? cache.projectId : ''
const projectId = Number(pId || this.projectId)
const cid = this.courseId
@ -373,7 +408,7 @@ export default {
let hasCache = 0 //
points.map((e, i) => {
const judgmentId = e.judgmentId
promiseList.push(new Promise((resolve,reject) => {
promiseList.push(new Promise((resolve, reject) => {
this.$post(this.api.getLastCache, {
assessmentId: assessmentId ? Number(assessmentId) : '',
bcId: judgmentId,
@ -413,7 +448,7 @@ export default {
})
this.$emit('tell', projectId, this.curSystemId, this.points)
this.$emit('recoveryCode', newJudgmentId + '') // tab
}).catch(res => {})
}).catch(res => { })
} else {
this.points.map(e => {
const item = points.find(n => n.judgmentId === e.judgmentId)
@ -432,14 +467,14 @@ export default {
bcId: e.judgmentId,
projectId,
cid
}).then(res => {}).catch(() => {})
}).then(res => { }).catch(() => { })
})
})
})
}
},
//
getAssStatus() {
getAssStatus () {
//
this.isSubmit || this.$get(this.api.getDetailById, {
id: this.assessmentId
@ -453,10 +488,10 @@ export default {
})
this.submit()
}
}).catch(res => {})
}).catch(res => { })
},
//
getCompetitionStatus() {
getCompetitionStatus () {
//
this.isSubmit || this.$post(`${this.api.getCompetition}?competitionId=${this.competitionId}`).then(({ competition }) => {
const stages = competition.competitionStage
@ -475,14 +510,14 @@ export default {
this.counter((endTime - now) / 1000)
}
}
}).catch(res => {})
}).catch(res => { })
},
//
selectProject(){
selectProject () {
this.isSelected = true
this.getProDetail().then(() => {
this.getCache()
}).catch(res => {})
}).catch(res => { })
this.isSubmit = false
this.countVal = 0
this.grade = '00'
@ -491,11 +526,11 @@ export default {
newmain.$emit('isSubmit', this.isSubmit) //
},
//
toReport() {
toReport () {
this.$router.push(`/report?reportId=${this.reportId}`)
},
//
reload() {
reload () {
this.reloadCount()
this.grade = '00'
localStorage.removeItem('codeCache')
@ -514,10 +549,10 @@ export default {
this.startCount()
},
//
confirmSubmit() {
confirmSubmit () {
const pointList = this.$parent.workbench
let msg = '此操作将视为结束考试,是否继续?'
if(pointList.find(e => !e.codeId && e.code)) msg = '有代码没有运行,该代码将不得分,确定提交?'
if (pointList.find(e => !e.codeId && e.code)) msg = '有代码没有运行,该代码将不得分,确定提交?'
this.$confirm(msg, '提示', {
confirmButtonText: '确定',
cancelButtonText: '取消',
@ -534,14 +569,14 @@ export default {
}).then(({ codeId }) => {
this.$parent.workbench[0].codeId = codeId
this.submit()
}).catch(err => {})
}).catch(err => { })
} else {
this.submit()
}
}).catch(() => {})
}).catch(() => { })
},
//
submit() {
submit () {
if (this.isSubmit) return false
const pointList = this.$parent.workbench
const date = new Date()
@ -612,10 +647,10 @@ export default {
this.$parent.back()
}
})
}).catch(err => {})
}).catch(err => { })
},
//
editReport(reportId) {
editReport (reportId) {
const data = []
const ans = []
const promises = []
@ -647,20 +682,20 @@ export default {
this.$post(this.api.editExperimentalData, {
reportId,
data: JSON.stringify(data)
}).then(res => {}).catch(err => {})
}).then(res => { }).catch(err => { })
})
},
//
togglePannel() {
togglePannel () {
document.querySelector('#panel').style.left = 0
this.pannelVisible = !this.pannelVisible
},
//
timeFormat(param) {
timeFormat (param) {
return param < 10 ? '0' + param : param
},
//
reloadCount() {
reloadCount () {
clearInterval(this.counterTimer)
this.countVal = ''
this.day = '00'
@ -669,7 +704,7 @@ export default {
this.hour = '00'
},
//
counter(counterTime) {
counter (counterTime) {
let leave1 = counterTime % (24 * 3600) //
let leave2 = leave1 % 3600 //
let leave3 = leave2 % 60 //
@ -687,25 +722,24 @@ export default {
this.seconds = seconds
},
//
startCount() {
startCount () {
clearInterval(this.counterTimer)
this.counterTimer = setInterval(() => {
this.counter(this.projectPermissions ? this.countVal-- : this.countVal++)
}, 1000)
},
//
drag() {
drag () {
const el = document.querySelector('#panel')
let gap = 10 //
let parent = document.body
el.onmousedown = e => {
document.querySelector('#header').onmousedown = e => {
var x = e.clientX - el.offsetLeft
var y = e.clientY - el.offsetTop
var left = 0
var top = 0
var boxer = document.querySelector(".boxer")
document.onmousemove = function(eve) {
document.onmousemove = function (eve) {
left = eve.clientX - x
top = eve.clientY - y
//
@ -786,7 +820,7 @@ export default {
}
/deep/.des {
font-size: 16px;
font-family: "Microsoft YaHei";
font-family: 'Microsoft YaHei';
img {
max-width: 100%;
}
@ -836,8 +870,8 @@ export default {
color: #333;
background-color: #fff;
}
.el-aside /deep/[class*=" el-icon-"],
[class^="el-icon-"] {
.el-aside /deep/[class*=' el-icon-'],
[class^='el-icon-'] {
line-height: 40px;
font-size: 16px;
}
@ -856,10 +890,13 @@ export default {
&.system4 {
background-size: 100% 58px;
}
&.system5, &.system7, &.system9 {
&.system5,
&.system7,
&.system9 {
background-size: 100% 40px;
}
&.system8, &.system6 {
&.system8,
&.system6 {
background-size: 100% 61px;
}
&.system10 {
@ -902,7 +939,7 @@ export default {
}
/deep/.select {
.el-select__caret:before {
content: "\e78f";
content: '\e78f';
padding: 3px;
font-size: 16px;
color: #fff;
@ -971,7 +1008,7 @@ export default {
color: #bfbfbf;
cursor: pointer;
&:hover {
opacity: .9;
opacity: 0.9;
}
}
</style>

@ -1,83 +1,101 @@
<template>
<div class="code-wrap flex">
<div class="left">
<codemirror
v-model="codeVal"
:options="cmOption"
class="code-mirror"
@ready="ready"
ref="codemirror"
></codemirror>
<div v-if="isSubmit" class="code-mask"></div>
<codemirror v-model="codeVal"
:options="cmOption"
class="code-mirror"
@ready="ready"
ref="codemirror"></codemirror>
<div v-if="isSubmit"
class="code-mask"></div>
<div class="btns">
<span
class="el-icon-delete del"
@click="clearCode"
></span>
<el-button
v-if="modelIsShow"
class="btn"
type="warning"
@click="importModel"
>导入模型</el-button>
<el-button
class="run btn"
type="primary"
@click="runCode(false)"
:disabled="runEnable"
>运行</el-button>
<span class="el-icon-delete del"
@click="clearCode"></span>
<el-button v-if="modelIsShow"
class="btn"
type="warning"
@click="importModel">导入模型</el-button>
<el-button class="run btn"
type="primary"
@click="runCode(false)"
:disabled="runEnable">运行</el-button>
</div>
</div>
<div class="line"></div>
<div class="code-right answer">
<p :class="['text-wrapper', 'pic-num' + picSrcList.length]">{{ runResult }}</p>
<div :class="['pic-wrap', {wrong: isError === 0}]" v-if="picSrcList.length">
<div class="pic-item" v-for="(img, i) in picSrcList" :key="i">
<el-image
class="pic"
:src="img"
:preview-src-list="picSrcList">
<div :class="['pic-wrap', {wrong: isError === 0}]"
v-if="picSrcList.length">
<div class="pic-item"
v-for="(img, i) in picSrcList"
:key="i">
<el-image class="pic"
:src="img"
:preview-src-list="picSrcList">
</el-image>
<el-button class="download-btn btn" type="primary" size="mini" @click="downloadPic(i)">下载图片</el-button>
<a :ref="'picLink' + i" style="display: none;" download="运行结果.png" :href="img">下载图片</a>
<el-button class="download-btn btn"
type="primary"
size="mini"
@click="downloadPic(i)">下载图片</el-button>
<a :ref="'picLink' + i"
style="display: none;"
download="运行结果.png"
:href="img">下载图片</a>
</div>
</div>
<div class="result-right t-color" v-show="isError">
<img :src="require(`@/assets/images/system/${$config.defaultSystem}/yes.png`)" alt />运行成功
<el-button class="tips-btn" @click="exportResult">导出结果</el-button>
<div class="result-right t-color"
v-show="isError">
<img :src="require(`@/assets/images/system/${$config.defaultSystem}/yes.png`)"
alt />运行成功
<el-button class="tips-btn"
@click="exportResult">导出结果</el-button>
</div>
<div class="result-wrong" v-show="isError === 0">
<img src="@/assets/images/error.png" alt />
<div class="result-wrong"
v-show="isError === 0">
<img src="@/assets/images/error.png"
alt />
{{errLine}}行出现错误
<el-button class="tips-btn" @click="getTips" v-show="showTips">提示</el-button>
<el-dialog title="答案提示" center :close-on-click-modal="false" :visible.sync="tipsVisible">
<el-button class="tips-btn"
@click="getTips"
v-show="showTips">提示</el-button>
<el-dialog title="答案提示"
center
:close-on-click-modal="false"
:visible.sync="tipsVisible">
<el-tabs>
<el-tab-pane label="参考答案">
<div :class="['answer-wrap', {client: !fromManager}]" v-html="answer"></div>
<div :class="['answer-wrap', {client: !fromManager}]"
v-html="answer"></div>
</el-tab-pane>
</el-tabs>
</el-dialog>
</div>
</div>
<!-- 导入模型 -->
<el-dialog title="请选择要导入的模型" :visible.sync="modelVisible" width="400px" :close-on-click-modal="false">
<el-dialog title="请选择要导入的模型"
:visible.sync="modelVisible"
width="400px"
:close-on-click-modal="false">
<div class="model-wrap">
<el-tree
:data="modelData"
ref="tree"
default-expand-all
@check-change="treeCheckChange"
show-checkbox
:check-strictly="true"
node-key="id"
:props="{children: 'children', label: 'categoryName', isLeaf: 'leaf'}"
v-loading="modelLoading">
<el-tree :data="modelData"
ref="tree"
default-expand-all
@check-change="treeCheckChange"
show-checkbox
:check-strictly="true"
node-key="id"
:props="{children: 'children', label: 'categoryName', isLeaf: 'leaf'}"
v-loading="modelLoading">
</el-tree>
</div>
<span slot="footer" class="dialog-footer">
<el-button size="small" @click="modelVisible = false">取消</el-button>
<el-button size="small" type="primary" @click="submit">导入</el-button>
<span slot="footer"
class="dialog-footer">
<el-button size="small"
@click="modelVisible = false">取消</el-button>
<el-button size="small"
type="primary"
@click="submit">导入</el-button>
</span>
</el-dialog>
</div>
@ -133,7 +151,7 @@ import config from '@/config'
const CANCEL_TOKEN = axios.CancelToken // input
export default {
props: ['judgmentId', 'code', 'codeId', 'projectId', 'systemId', 'retResult', 'modelIsShow'],
data() {
data () {
return {
token: Cookie.get('admin-token'),
assessmentId: Cookie.get('admin-assessmentId'), // id
@ -189,11 +207,11 @@ export default {
codemirror
},
watch: {
codeVal(val) {
codeVal (val) {
this.$emit("update:code", val)
}
},
mounted() {
mounted () {
if (!this.assessmentId) this.showTips = true
//
newmain.$on("isSubmit", isSubmit => {
@ -204,16 +222,24 @@ export default {
methods: {
//
ready() {
ready () {
const code = this.$refs.codemirror.codemirror
code.setSize("auto", "calc(100vh - 167px)");
code.on('keypress', function() {
//
this.$post(`${this.api.whetherCanPaste}?systemId=${this.systemId}`).then(res => {
// ()
res.data == 'false' && !this.fromManager && code.on('beforeChange', (istance, change) => {
change.origin === 'paste' && change.cancel()
})
}).catch(err => { })
code.on('keypress', function () {
//
code.showHint()
});
},
//
clearCode() {
clearCode () {
this.codeVal = ''
this.isError = ''
this.runResult = ''
@ -222,46 +248,47 @@ export default {
this.$emit('update:retResult', '') //
},
//
importModel() {
importModel () {
this.modelLoading = true
this.modelVisible = true
//
this.$post(`${this.api.modelClassList}?systemId=${this.systemId}`).then(res => {
const { data } = res
this.$post(`${this.api.modelClassList}?systemId=${this.systemId}&founder=1`).then(({ data }) => {
const promises = []
const addType = list => {
list.map(e => {
e.disabled = true
// promise
promises.push(new Promise((resolve,reject) => {
this.$post(this.api.referenceDemoList, {
pageNum: 1,
pageSize: 10000,
categoryId: e.id
}).then(res => {
let { records } = res.data
records = records.filter(e => !e.isOpen) //
records.map(n => {
n.categoryName = n.modelName
})
e.children = [...e.children, ...records]
resolve()
}).catch(res => {
reject()
list.map(e => {
e.disabled = true
// promise
promises.push(new Promise((resolve, reject) => {
this.$post(this.api.studentModelList, {
categoryId: e.id,
pageNum: 1,
pageSize: 10000,
systemId: +this.systemId,
founder: 1
}).then(({ data }) => {
let { records } = data
records = records.filter(e => !e.isOpen) //
records.map(n => {
n.categoryName = n.modelName
})
}))
e.children && e.children.length && addType(e.children)
})
}
addType(data)
Promise.all(promises).then(_ => {
this.modelData = data
this.modelLoading = false
}).catch(res => {})
}).catch(res => {})
e.children = [...e.children, ...records]
resolve()
}).catch(res => {
reject()
})
}))
e.children && e.children.length && addType(e.children)
})
}
addType(data)
Promise.all(promises).then(_ => {
this.modelData = data
this.modelLoading = false
}).catch(res => { })
}).catch(res => { })
},
//
treeCheckChange(data, checked, indeterminate) {
treeCheckChange (data, checked, indeterminate) {
const checkKey = this.$refs.tree.getCheckedKeys()
//
if (checkKey.length > 1 && checked) {
@ -270,7 +297,7 @@ export default {
}
},
//
submit() {
submit () {
if (this.modelImporting) return false
const id = this.$refs.tree.getCheckedKeys()
if (!id.length) return this.$message.error('请选择模型!')
@ -286,7 +313,7 @@ export default {
this.modelImporting = false
}, 2000)
})
}).catch(res => {})
}).catch(res => { })
},
/**
* python代码里如果有input函数的话是做了单独的处理的原理是先把所有input函数都替换成exit函数再在exit函数里加上特定标识再通过接口传给后端去执行
@ -294,7 +321,7 @@ export default {
* 然后就可以通过这个返回的值来提示给用户让用户继续输入
* 下面这个函数就是递归执行这个input输入过程的函数
*/
confirmInput(msg){
confirmInput (msg) {
const receiveResult = msg.replace('validing:', '')
this.runResult += receiveResult
this.$prompt(receiveResult, '提示', {
@ -302,14 +329,14 @@ export default {
}).then(({ value }) => {
this.runResult += `${value}\n`
// exit
this.sourceCode = this.sourceCode.replace(`exit('validing:${receiveResult.replace(/[\r\n]*/g,'')}')`, _ => {
this.sourceCode = this.sourceCode.replace(`exit('validing:${receiveResult.replace(/[\r\n]*/g, '')}')`, _ => {
return `'${value}'`
})
this.sourceCode = this.sourceCode.replace(`exit("validing:${receiveResult.replace(/[\r\n]*/g,'')}")`, _ => {
this.sourceCode = this.sourceCode.replace(`exit("validing:${receiveResult.replace(/[\r\n]*/g, '')}")`, _ => {
return `'${value}'`
})
clearTimeout(this.requestTimer)
// AnswerTips
this.requestTimer = setTimeout(() => {
this.requestList.map(n => n('interrupt'))
@ -338,7 +365,7 @@ export default {
} else if (result.includes('validing:')) {
this.isError = 1
this.confirmInput(result)
} else if(data.retResult) {
} else if (data.retResult) {
this.isError = 1
this.runResult += result
}
@ -346,16 +373,16 @@ export default {
this.$emit('update:answer', this.runResult) //
this.$emit('update:retResult', data.retResult) //
}).catch(e => {
if(e && e.message == 'interrupt'){
if (e && e.message == 'interrupt') {
this.runCode(true)
this.requestList = []
}
})
}).catch(err => {})
}).catch(err => { })
},
//
runCode(isWhile) { // isWhiletruewhile
runCode (isWhile) { // isWhiletruewhile
if (!this.isSubmit) {
let code = this.codeVal
if (!code) {
@ -372,17 +399,17 @@ export default {
// input
if (inputTextReg.test(code)) {
code = code.replace(inputTextReg, val => {
return val.replace(/\\n/g,"")
return val.replace(/\\n/g, "")
})
this.codeVal = code
// inputexit"validing:"便
code = code.replace(inputFuncReg,val => {
code = code.replace(inputFuncReg, val => {
return `exit(${val[val.length - 1]}validing:`
})
this.sourceCode = code
if(!isWhile) this.runResult = ''
if (!isWhile) this.runResult = ''
this.$post(this.api.runPythonCode, {
code,
bcId,
@ -391,7 +418,7 @@ export default {
}).then(res => {
const data = res.code
const result = data.runResult
if(result.includes('File ')){
if (result.includes('File ')) {
if (isWhile) {
this.runResult += result
} else {
@ -399,7 +426,7 @@ export default {
}
this.errLine = parseInt(result.substring(result.indexOf('line') + 4, result.length))
this.isError = data.retResult
}else if(result.includes('validing:')){
} else if (result.includes('validing:')) {
this.isError = 1
this.confirmInput(result)
}
@ -439,7 +466,7 @@ export default {
let firtImg = ''
try {
imgList = eval(result)
} catch (error) {}
} catch (error) { }
if (imgList && imgList.length) firtImg = imgList[0]
//
if (photo) {
@ -453,8 +480,8 @@ export default {
* 这段是为要下载图片的项目案例写的后端会返回图片名称的数组前端负责循环这个数组然后下载下来
* 只有该系统有这段代码因为其他7个系统没有下载图片的项目后续如果加了直接把这段代码复制过去即可
*/
imgList.map((n,i) => {
util.downloadFile(`${i+1}.jpg`,n)
imgList.map((n, i) => {
util.downloadFile(`${i + 1}.jpg`, n)
})
this.isError = 0
this.runResult = '下载完成'
@ -481,26 +508,26 @@ export default {
}
},
//
downloadPic(i) {
downloadPic (i) {
this.$refs['picLink' + i][0].click()
},
//
exportResult() {
exportResult () {
var FileSaver = require('file-saver');
var blob = new Blob([this.runResult], {type: "text/plain;charset=utf-8"});
var blob = new Blob([this.runResult], { type: "text/plain;charset=utf-8" });
FileSaver.saveAs(blob, 'result.csv')
},
//
getTips() {
getTips () {
this.tipsVisible = true
this.$get(this.api.queryBcJudgmentByBcId, {
bcId: this.judgmentId
}).then(res => {
this.answer = res.experimentCode
}).catch(err => {})
}).catch(err => { })
},
//
dragSide() {
dragSide () {
const left = document.querySelector('.left')
const line = document.querySelector('.line')
const right = document.querySelector('.code-right')
@ -511,9 +538,9 @@ export default {
document.onmousemove = e => {
let x = e.clientX
//
if(x >= width * .1 && x <= width * .9) {
if (x >= width * .1 && x <= width * .9) {
line.style.left = x + 'px'
left.style.width = x +'px'
left.style.width = x + 'px'
right.style.width = document.querySelector('.code-wrap').clientWidth - (x + 5) + 'px'
}
}
@ -531,7 +558,7 @@ export default {
.code-wrap {
position: relative;
}
.left{
.left {
position: relative;
width: 60%;
}
@ -605,7 +632,7 @@ export default {
background-color: #f00;
cursor: pointer;
&:hover {
opacity: .9;
opacity: 0.9;
}
}
/deep/.CodeMirror-wrap pre.CodeMirror-line,
@ -693,7 +720,7 @@ export default {
margin: 0 auto 10px;
}
}
.code-mask{
.code-mask {
z-index: 2;
position: absolute;
top: 0;
@ -702,28 +729,28 @@ export default {
right: 0;
}
.btns {
z-index:99;
position:absolute;
right: 50px;
bottom:15px;
z-index: 99;
position: absolute;
right: 50px;
bottom: 15px;
display: flex;
}
.run{
width:100px;
color:#fff;
.run {
width: 100px;
color: #fff;
}
.download-btn{
color:#fff;
.download-btn {
color: #fff;
}
/deep/.answer-wrap{
/deep/.answer-wrap {
&.client {
user-select: none;
}
pre{
pre {
width: 100%;
white-space: pre-wrap;
}
img{
img {
max-width: 100%;
}
}

@ -10,9 +10,9 @@ let host = location.origin + '/'
let bankPath = `${location.origin}/banksystem` // 银行系统
// 121.37.12.51 | 192.168.31.151
if (isDev) {
// host = 'http://192.168.31.51:9000/'
// host = 'http://192.168.31.116:9000/'
host = 'http://121.37.12.51:9000/'
host = 'http://192.168.31.152:9000/'
// host = 'http://192.168.31.53:9000/'
// host = 'http://121.37.12.51:9000/'
// host = 'https://occupationlab.com/'
bankPath = `http://${location.hostname}:8093`
} else if (isPro) {

File diff suppressed because it is too large Load Diff

@ -17,9 +17,13 @@
<p v-if="$config.isHh"
style="font-size: 18px">{{$config.title}}</p>
<p>编程语言</p>
<el-input placeholder="请输入内容"
v-model="language"
:disabled="true"></el-input>
<el-select v-model="language"
@change="languageChange">
<el-option v-for="(item, i) in languages"
:key="i"
:label="item.name"
:value="item.id"></el-option>
</el-select>
</div>
<div class="inline-center">
<el-tooltip class="item"
@ -44,7 +48,8 @@
:key="item.judgmentId"
:label="item.name"
:value="item.judgmentId">
<codemirror :ref="'code' + i"
<codemirror v-if="!language"
:ref="'code' + i"
:key="codeKey"
:projectId.sync="projectId"
:systemId.sync="systemId"
@ -55,6 +60,16 @@
:retResult.sync="item.retResult"
:modelIsShow.sync="modelIsShow"
@cache="leavePage"></codemirror>
<!-- <img v-else
src="@/assets/images/vscode.png"
alt=""
width="100%"
height="700"> -->
<iframe v-else
class="vscode"
src="http://121.37.12.51:8088/?folder=/home/coder"
frameborder="0"
width="100%"></iframe>
</el-tab-pane>
</el-tabs>
</div>
@ -88,7 +103,17 @@ export default {
systemId: '',
modelIsShow: false, //
projectPermissions: 0, // (0 1 2)
language: 'Python', //
languages: [
{
id: 0,
name: 'Python'
},
{
id: 1,
name: 'Vscode'
},
],
language: 0, //
curTab: '', //
workbench: [], //
codeKey: 1 //
@ -143,9 +168,13 @@ export default {
},
//
getModelStatus (systemId) {
this.$post(`${this.api.checkIsShowBySystemId}?systemId=${systemId}`).then(res => {
this.modelIsShow = !res.isShow // 0 1
this.$post(`${this.api.displayListOrNotByStudent}?systemId=${systemId}`).then(res => {
this.modelIsShow = res.studentSideShowsTheStatus == 'true' ? true : false
}).catch(res => { })
},
//
languageChange (id) {
},
//
toData () {
@ -258,10 +287,14 @@ export default {
.el-input {
width: 200px;
}
.el-input.is-disabled .el-input__inner {
.el-input .el-input__inner {
border-radius: 30px;
}
}
.vscode {
height: calc(100vh - 186px);
}
.menu {
position: relative;
z-index: 1000;

Loading…
Cancel
Save