From d9b4ec85b864faa3d4fc6a9ee545dd5340abd81f Mon Sep 17 00:00:00 2001 From: yujialong <479214531@qq.com> Date: Fri, 4 Mar 2022 17:07:07 +0800 Subject: [PATCH] =?UTF-8?q?=E6=BA=90=E6=A8=A1=E5=9E=8B=E5=A2=9E=E5=88=A0?= =?UTF-8?q?=E6=94=B9=E6=9F=A5?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/assets/img/yes.png | Bin 0 -> 395 bytes src/components/codemirror.vue | 44 +- src/utils/api.js | 7 + src/views/serve/addModel.vue | 58 ++- src/views/serve/backstage/index.vue | 11 +- src/views/serve/backstage/model.vue | 578 ++++------------------ src/views/serve/backstage/modelType.vue | 17 +- src/views/serve/backstage/sourceModel.vue | 220 ++------ src/views/serve/backstage/sourceType.vue | 17 +- 9 files changed, 245 insertions(+), 707 deletions(-) create mode 100644 src/assets/img/yes.png diff --git a/src/assets/img/yes.png b/src/assets/img/yes.png new file mode 100644 index 0000000000000000000000000000000000000000..6b9df117adeb511a6acc536b31f3c93b3fafae2b GIT binary patch literal 395 zcmV;60d)R}P)w;?Ke@*dyPw%Os?tNeAe`V*9gXW5P z6L71t+ zHh8uZL>8$}WdpH|tzM@~w7}+fJ?!DvIuPCwE8{NNl;cI7oeA zE
- + 运行成功
第{{errLine}}行出现错误 - 提示 - - - -
-
-
-
@@ -89,19 +81,17 @@ import "codemirror/theme/monokai.css"; import "codemirror/theme/base16-light.css"; import { Loading } from 'element-ui'; export default { - props: ['code', 'codeId', 'projectId', 'retResult'], + props: ['code', 'codeId', 'projectId', 'retResult', 'readOnly'], data() { return { - showTips: false, // 显示隐藏提示按钮 - answer: '', // 正确答案 codeVal: this.code, runResult: '', // 运行结果 isError: false, // 运行正确与否 errLine: '', // 错误代码的位置 - tipsVisible: false, // 答案提示弹框显示标识 picSrcList: [], loadIns: null, // loading实例 cmOption: { + readOnly: this.readOnly, scrollbarStyle: "native", tabSize: 2, // tab styleActiveLine: true, // 高亮选中行 @@ -139,7 +129,6 @@ export default { mounted() { }, - methods: { // 页面加载完后重置编辑框大小 ready() { @@ -159,22 +148,12 @@ export default { type: "warning" }) } else { - const bcId = this.judgmentId - const cid = this.courseId - const projectId = this.projectId this.loadIns = Loading.service({ background: 'transparent' }) - // 如果代码有savefig(python里的保存图片的方法),则要把savefig里的图片名字加上个时间戳,防止后台保存图片到服务器的时候图片名字重复导致覆盖 - code = code.replace(/\.savefig\(([\u4e00-\u9fa5\w]*?['"])/mg, str => { - return str + Date.now() - }) // 把代码传给后端,在后端运行Python代码 this.$post(this.api.runPythonCode, { - code, - bcId, - cid, - projectId + code }).then(res => { const data = res.code const photo = data.photoUrl @@ -183,9 +162,6 @@ export default { this.loadIns.close() this.picSrcList = [] if (photo) this.picSrcList = photo.split(',') - this.$emit('update:codeId', res.codeId) // 更新coddeId - this.$emit('update:answer', result) // 更新运行结果 - this.$emit('update:retResult', data.retResult) // 更新返回结果 let imgList = '' let firtImg = '' try { @@ -222,15 +198,6 @@ export default { // 下载图片 downloadPic(i) { this.$refs['picLink' + i][0].click() - }, - // 获取正式答案 - getTips() { - this.tipsVisible = true - this.$get(this.api.queryBcJudgmentByBcId, { - bcId: this.judgmentId - }).then(res => { - this.answer = res.experimentCode - }).catch(err => {}) } } }; @@ -322,8 +289,9 @@ export default { left: 20px; right: 20px; display: flex; + align-items: center; bottom: 10px; - padding: 0 10px; + padding: 5px 10px; img { width: 40px; height: 40px; diff --git a/src/utils/api.js b/src/utils/api.js index 37ed966..691bcfc 100644 --- a/src/utils/api.js +++ b/src/utils/api.js @@ -103,6 +103,13 @@ export default { categorySave: `${host}/nakadai/model/category/save`, sourceModelClassification: `${host}/nakadai/model/category/sourceModelClassification`, + bulkDisable: `${host}/nakadai/model/demo/bulkDisable`, + deleteSysModelDemo: `${host}/nakadai/model/demo/deleteSysModelDemo`, + modelFindById: `${host}/nakadai/model/demo/findById`, + saveSysModelDemo: `${host}/nakadai/model/demo/saveSysModelDemo`, + sysModelDemoList: `${host}/nakadai/model/demo/sysModelDemoList`, + updateSysModelDemo: `${host}/nakadai/model/demo/updateSysModelDemo`, + runPythonCode: `${host}/nakadai/model/demo/runPythonCode`, // 课程管理三级联查 courseDiscipline: `${host}/nakadai/nakadai/subject/courseDiscipline`, //课程学科类别 diff --git a/src/views/serve/addModel.vue b/src/views/serve/addModel.vue index 8575563..4d997df 100644 --- a/src/views/serve/addModel.vue +++ b/src/views/serve/addModel.vue @@ -5,19 +5,25 @@
返回 - + +
+
+ 发布 + 草稿
- 确定 - + @@ -31,20 +37,54 @@ export default { components:{ codemirror }, data() { return { - customerId : this.$route.query.id, + categoryId : Number(this.$route.query.categoryId), + id : Number(this.$route.query.id), + postStatus : Number(this.$route.query.postStatus), isDetail : Boolean(this.$route.query.show), form: { - - } + modelName: '', + modelDemo: '' + }, + codeKey: 1 }; }, mounted() { - + this.id && this.getData() }, methods: { + // 获取详情 + getData() { + this.$post(`${this.api.modelFindById}?id=${this.id}`).then(res => { + const { data } = res + this.form.modelName = data.modelName + this.form.modelDemo = data.modelDemo + this.codeKey++ + }).catch(res => {}) + }, // 保存 - submit(){ - + submit(postStatus){ + const { modelName, modelDemo } = this.form + const id = this.id + if (!modelName) return this.$message.error('请输入模型名称') + if (!modelDemo) return this.$message.error('请输入模型代码') + const data = { + categoryId: this.categoryId, + modelName, + modelDemo, + postStatus + } + if (id) { + data.id = id + this.$post(this.api.updateSysModelDemo, data).then(res => { + this.$message.success('编辑成功') + this.$router.back() + }).catch(res => {}) + } else { + this.$post(this.api.saveSysModelDemo, data).then(res => { + this.$message.success('新增成功') + this.$router.back() + }).catch(res => {}) + } }, } }; diff --git a/src/views/serve/backstage/index.vue b/src/views/serve/backstage/index.vue index ba05a4f..fdf1fa2 100644 --- a/src/views/serve/backstage/index.vue +++ b/src/views/serve/backstage/index.vue @@ -15,7 +15,7 @@ import sourceModel from "./sourceModel"; export default { data() { return { - active: "model", + active: this.$route.query.type || 'model', tabs: { model: "模型列表管理", sourceModel: "源模型管理" @@ -32,7 +32,14 @@ export default { created() {}, methods: { tabChange(index) { - this.active = index; + this.active = index + this.$router.push({ + path: 'backstage', + query: { + ...this.$route.query, + type: index + } + }) } } }; diff --git a/src/views/serve/backstage/model.vue b/src/views/serve/backstage/model.vue index 1ad4912..62400b2 100644 --- a/src/views/serve/backstage/model.vue +++ b/src/views/serve/backstage/model.vue @@ -1,7 +1,7 @@