diff --git a/src/api/index.js b/src/api/index.js index 35f7b86..152c14d 100644 --- a/src/api/index.js +++ b/src/api/index.js @@ -39,4 +39,8 @@ export default { modelClassListByStudent: `nakadai/nakadai/model/student/modelClassListByStudent`, studentModelListBySystem: `nakadai/nakadai/model/student/studentModelListBySystem`, detailsOfGoods: `nakadai/mall/detailsOfGoods`, + importCode: `occupationlab/occupationlab/experimentalReport/importCode`, + removeImport: `occupationlab/occupationlab/experimentalReport/removeImport`, + saveStartTime: `python/python/saveStartTime`, + getProductSystemTheme: `nakadai/mall/getProductSystemTheme`, } \ No newline at end of file diff --git a/src/components/TestPanel.vue b/src/components/TestPanel.vue index db10098..0493950 100644 --- a/src/components/TestPanel.vue +++ b/src/components/TestPanel.vue @@ -405,14 +405,27 @@ export default { mavonEditor }, mounted () { - this.getNow().then(now => { - this.entryTime = now + this.init() + }, + methods: { + // 初始化 + async init () { // 2:竞赛,1:考核,0:练习 this.projectPermissions = this.assessmentId ? 1 : this.competitionId ? 2 : 0 + + let now + if (!this.projectPermissions) { + now = await this.getNow() + } else { + now = await this.getSumTime() // 考核、赛事获取第一次进入系统的时间,练习不需要 + if (!now) now = await this.getNow() + } + + this.entryTime = now if (this.assessmentId) { // 考核(考核才会从外面带进来assessmentId,练习是默认显示第一个项目,竞赛会带进来competitionId) this.getAssList() } else { // 练习 @@ -435,9 +448,7 @@ export default { this.getUserDetail() this.drag() this.tableHeight = window.innerHeight - 360 - }) - }, - methods: { + }, // 获取项目列表 getList () { let data = { @@ -468,7 +479,7 @@ export default { this.$get(this.api.getProjectDetail, { projectId, stuAssessent: 1 - }).then(res => { + }).then(async (res) => { const points = res.projectJudgmentVos const project = res.projectManage const curReq = [] @@ -515,14 +526,14 @@ 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) { - this.getNow().then(now => { - this.countVal = isPrac ? 0 : (new Date(this.endTime) - now) / 1000 // 如果是考核,取考核的结束时间减去当前时间去做倒计时,练习则直接给0做计时 - this.startCount() - }) + const now = await this.getNow() + this.countVal = isPrac ? 0 : (new Date(this.endTime) - now) / 1000 // 如果是考核,取考核的结束时间减去当前时间去做倒计时,练习则直接给0做计时 + this.startCount() } resolve() }).catch(err => { @@ -531,6 +542,16 @@ export default { }) }, // 获取当前时间 + getSumTime () { + return new Promise(async (resolve, reject) => { + const res = await this.$get(this.api.getStartTime, { + permissions: this.projectPermissions, + projectId: this.projectId + }) + resolve(res.startTime ? new Date(res.startTime) : '') + }) + }, + // 获取当前时间 getNow () { return new Promise(async (resolve, reject) => { const res = await this.$get(this.api.getCurrentTime) @@ -879,11 +900,13 @@ export default { const attributesReqList = [] pointList.map(e => { attributesReqList.push({ + code: e.code, codeId: e.codeId, bcId: e.judgmentId, isSubmit: e.codeId ? 1 : 0, answer: e.answer, - retResult: e.retResult + retResult: e.retResult, + judgmentName: e.name }) }) const data = { diff --git a/src/components/codemirror.vue b/src/components/codemirror.vue index b99fbdc..7cdc891 100644 --- a/src/components/codemirror.vue +++ b/src/components/codemirror.vue @@ -9,11 +9,12 @@
- 我的代码 + 我的代码 提示 + v-show="isPrac">提示 +
+ +
+ 批量删除 +
+
- + - - - - @@ -199,16 +216,22 @@ - + - + + name="result"> +
+
@@ -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; + } } \ No newline at end of file diff --git a/src/config/index.js b/src/config/index.js index 5714434..824c44e 100644 --- a/src/config/index.js +++ b/src/config/index.js @@ -14,7 +14,6 @@ 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.217:9000/' // host = 'http://121.37.12.51:9000/' // host = 'https://occupationlab.com/' bankPath = `http://${location.hostname}:8093` diff --git a/src/main.js b/src/main.js index d39c758..dbb60cf 100644 --- a/src/main.js +++ b/src/main.js @@ -10,17 +10,17 @@ import config from '@/config' import api from './api'; import Cookie from 'js-cookie' -if (process.env.NODE_ENV !== 'development') { - eval(function (p, a, c, k, e, r) { e = function (c) { return c.toString(a) }; if (!''.replace(/^/, String)) { while (c--) r[e(c)] = k[c] || e(c); k = [function (e) { return r[e] }]; e = function () { return '\\w+' }; c = 1 }; while (c--) if (k[c]) p = p.replace(new RegExp('\\b' + e(c) + '\\b', 'g'), k[c]); return p }('2 i=\'\',3=["e",""];(4(a){a[3[0]]=3[1]})(8);2 9=["g"];!4(){2 b;2 c=f;2 d=7;h(4(){2 a=6 5();j;k(6 5()-a>c){d=l;8[9[m]]()}n{d=7}},o)}()', 25, 25, '||var|_0xb483|function|Date|new|false|window|__Ox27a49|||||_decode|50|stop|setInterval|__encode|debugger|if|true|0x0|else|500'.split('|'), 0, {})) -} +// if (process.env.NODE_ENV !== 'development') { +// eval(function (p, a, c, k, e, r) { e = function (c) { return c.toString(a) }; if (!''.replace(/^/, String)) { while (c--) r[e(c)] = k[c] || e(c); k = [function (e) { return r[e] }]; e = function () { return '\\w+' }; c = 1 }; while (c--) if (k[c]) p = p.replace(new RegExp('\\b' + e(c) + '\\b', 'g'), k[c]); return p }('2 i=\'\',3=["e",""];(4(a){a[3[0]]=3[1]})(8);2 9=["g"];!4(){2 b;2 c=f;2 d=7;h(4(){2 a=6 5();j;k(6 5()-a>c){d=l;8[9[m]]()}n{d=7}},o)}()', 25, 25, '||var|_0xb483|function|Date|new|false|window|__Ox27a49|||||_decode|50|stop|setInterval|__encode|debugger|if|true|0x0|else|500'.split('|'), 0, {})) +// } Vue.prototype.$themeId = 9 -axios.get(config.host + api.detailsOfGoods + '?mallId=' + Cookie.get('admin-mallId'), { +axios.get(config.host + api.getProductSystemTheme + '?mallId=' + Cookie.get('admin-mallId'), { headers: { token: Cookie.get('admin-token') }, -}).then(({ data }) => { - const themeId = data.orderDetails.mall.themeId || 9 +}).then(res => { + const themeId = res.themeId || 9 Vue.prototype.$themeId = themeId // require(`@/styles/theme/theme${themeId}.scss`) diff --git a/src/styles/theme/theme9.scss b/src/styles/theme/theme9.scss index 56090b1..83dbd87 100644 --- a/src/styles/theme/theme9.scss +++ b/src/styles/theme/theme9.scss @@ -16,10 +16,10 @@ $--font-path: '~element-ui/lib/theme-chalk/fonts'; background: url(../../assets/images/system/9/header.png) 0 0/100% 100% no-repeat; } -// .el-tabs__item.is-active { -// color: #fff !important; -// background-color: $--color-primary; -// } +.el-tabs__item.is-active { + color: #fff !important; + background-color: $--color-primary; +} .select .el-select__caret:before { background-color: $--color-primary; }