diff --git a/src/api/index.js b/src/api/index.js index 152c14d..53dc5c8 100644 --- a/src/api/index.js +++ b/src/api/index.js @@ -41,6 +41,6 @@ export default { detailsOfGoods: `nakadai/mall/detailsOfGoods`, importCode: `occupationlab/occupationlab/experimentalReport/importCode`, removeImport: `occupationlab/occupationlab/experimentalReport/removeImport`, - saveStartTime: `python/python/saveStartTime`, + getStartTime: `python/python/getStartTime`, getProductSystemTheme: `nakadai/mall/getProductSystemTheme`, } \ No newline at end of file diff --git a/src/components/TestPanel.vue b/src/components/TestPanel.vue index 0493950..ba6d02e 100644 --- a/src/components/TestPanel.vue +++ b/src/components/TestPanel.vue @@ -417,15 +417,8 @@ export default { 2 : 0 - let now - if (!this.projectPermissions) { - now = await this.getNow() - } else { - now = await this.getSumTime() // 考核、赛事获取第一次进入系统的时间,练习不需要 - if (!now) now = await this.getNow() - } + await this.getEntryTime() - this.entryTime = now if (this.assessmentId) { // 考核(考核才会从外面带进来assessmentId,练习是默认显示第一个项目,竞赛会带进来competitionId) this.getAssList() } else { // 练习 @@ -458,10 +451,13 @@ export default { permissions: this.projectPermissions // 练习/考核/竞赛 } return new Promise((resolve, reject) => { - this.$get(`${this.api.queryTestProject}`, data).then(res => { + this.$get(`${this.api.queryTestProject}`, data).then(async res => { const list = res.projects this.projectList = list - if (!this.projectPermissions && !this.projectId) this.projectId = list ? list[0].projectId : 0 // 默认取第一个项目 + if (!this.projectPermissions && !this.projectId) { + this.projectId = list ? list[0].projectId : 0 // 默认取第一个项目 + await this.getEntryTime() + } this.getProDetail().then(() => { resolve() }).catch(res => { @@ -526,13 +522,12 @@ export default { this.experimentHint = project.experimentHint this.hintOpen = project.founder ? !project.hintOpenBySchool : !project.hintOpen // 0显示,1不显示,系统跟老师的禁用字段不一样 this.$emit('tell', projectId, systemId, this.points) - // this.getSumTime() const isPrac = this.projectPermissions == 0 // 是否是练习 this.text = isPrac ? '已用' : '剩余' // 竞赛不需要 if (!this.competitionId) { const now = await this.getNow() - this.countVal = isPrac ? 0 : (new Date(this.endTime) - now) / 1000 // 如果是考核,取考核的结束时间减去当前时间去做倒计时,练习则直接给0做计时 + this.countVal = (isPrac ? now - this.entryTime : (new Date(this.endTime) - now)) / 1000 // 如果是考核,取考核的结束时间减去当前时间去做倒计时,练习则直接取当前时间减去上次进来的时间做计时 this.startCount() } resolve() @@ -558,6 +553,16 @@ export default { resolve(new Date(res.currentTime)) }) }, + // 获取进入时间 + getEntryTime () { + return new Promise(async (resolve, reject) => { + let now + if (this.projectId) now = await this.getSumTime() // 获取第一次进入系统的时间 + if (!now) now = await this.getNow() + this.entryTime = now + resolve() + }) + }, // 关闭父页面的loading,并置加载完成状态为true closeLoad () { this.$parent.loadIns.close() @@ -599,7 +604,7 @@ export default { }).catch(res => { }) }, // 获取上次缓存记录 - getCache (cache) { + async getCache (cache) { const pId = cache ? cache.projectId : '' const projectId = Number(pId || this.projectId) const cid = this.courseId @@ -743,13 +748,14 @@ export default { }).catch(res => { }) }, // 项目选择回调 - selectProject () { + async selectProject () { this.isSelected = true + await this.getEntryTime() + this.countVal = this.entryTime this.getProDetail().then(() => { this.getCache() }).catch(res => { }) this.setSubmit(false) - this.countVal = 0 this.grade = '00' this.pannelTab = 'first' this.clearReport() @@ -889,7 +895,7 @@ export default { if (this.isSubmit) return false const pointList = this.$parent.workbench const date = await this.getNow() - const entryTime = this.entryTime + const { entryTime } = this const timeSum = Math.ceil((date - entryTime) / 60000) // 计算实验用时(分钟),向上取整 const submitTime = util.formatDate('yyyy-MM-dd hh:mm:ss', date) const projectId = this.projectId @@ -913,7 +919,7 @@ export default { classId: this.classId ? this.classId : '', className: this.className ? this.className : '', curriculumId: this.courseId, - startTime: this.projectPermissions ? this.startTime : util.formatDate('yyyy-MM-dd hh:mm:ss', entryTime), // 开始时间(考核:直接从职站取考核的开始时间;练习:取页面进入的时间) + startTime: util.formatDate('yyyy-MM-dd hh:mm:ss', entryTime), // 取页面进入的时间 endTime: this.projectPermissions ? this.endTime : submitTime, // 结束时间(考核:直接从职站取考核的结束时间;练习:取提交时间) submitTime, // 提交时间,即当前时间(这3个时间都是传完整的日期时间格式) timeSum, diff --git a/src/components/codemirror.vue b/src/components/codemirror.vue index 7cdc891..626df5a 100644 --- a/src/components/codemirror.vue +++ b/src/components/codemirror.vue @@ -834,7 +834,7 @@ export default { }, // 导入代码 importCode (row) { - this.codeVal = row.runCode + this.codeVal += (this.codeVal ? '\n' : '') + row.runCode // 空两行插入 this.$nextTick(() => { const codemirror = this.$refs.codemirror.codemirror codemirror.focus() @@ -844,7 +844,7 @@ export default { }, // 导入代码 showSubmit () { - this.codeVal = this.curCode + this.codeVal += (this.codeVal ? '\n' : '') + this.curCode // 空两行插入 this.$nextTick(() => { const codemirror = this.$refs.codemirror.codemirror codemirror.focus() diff --git a/src/config/index.js b/src/config/index.js index 824c44e..ed4c1ad 100644 --- a/src/config/index.js +++ b/src/config/index.js @@ -14,7 +14,7 @@ let bankPath = `${location.origin}/banksystem` // 银行系统 // 121.37.12.51 | 192.168.31.151 if (isDev) { host = 'http://192.168.31.51:9000/' - // host = 'http://121.37.12.51:9000/' + host = 'http://121.37.12.51:9000/' // host = 'https://occupationlab.com/' bankPath = `http://${location.hostname}:8093` } else if (isPro) { diff --git a/src/main.js b/src/main.js index dbb60cf..a28531b 100644 --- a/src/main.js +++ b/src/main.js @@ -3,7 +3,6 @@ import App from "./App.vue"; import router from "./router"; import store from "./store"; import ElementUI from 'element-ui' -import util from '@/util' import '@/styles/index.scss'; import axios from 'axios' import config from '@/config' @@ -75,7 +74,7 @@ Vue.prototype.$put = put Vue.prototype.$config = config Vue.config.productionTip = false; -const curriculumName = util.getCookie('curriculumName') +const curriculumName = Cookie.get('admin-curriculumName') document.title = curriculumName ? decodeURIComponent(curriculumName) : 'python' router.beforeEach((to, from, next) => { next()