diff --git a/src/api/index.js b/src/api/index.js index ecf87fe..2f961d0 100644 --- a/src/api/index.js +++ b/src/api/index.js @@ -8,5 +8,9 @@ export default { getLastCache: 'python/python/getLastCache', delCache: 'python/python/delCache', getDetailById: 'occupationlab/assessment/getDetailById', - pageStuAssessment: 'occupationlab/assessment/pageStuAssessment' + pageStuAssessment: 'occupationlab/assessment/pageStuAssessment', + modelClassList: `nakadai/model/reference/modelClassList`, + referenceDemoList: `nakadai/model/reference/demo/referenceDemoList`, + referenceFindById: `nakadai/model/reference/demo/findById`, + checkIsShowBySystemId: `nakadai/model/reference/checkIsShowBySystemId`, } \ No newline at end of file diff --git a/src/components/codemirror.vue b/src/components/codemirror.vue index 2769906..4742648 100644 --- a/src/components/codemirror.vue +++ b/src/components/codemirror.vue @@ -16,6 +16,7 @@ @click="clearCode" >清屏 + :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'}"> 取消 @@ -124,7 +127,7 @@ import util from '@/util' import config from '@/config' const CANCEL_TOKEN = axios.CancelToken // 用于input中中断请求 export default { - props: ['judgmentId', 'code', 'codeId', 'projectId', 'retResult'], + props: ['judgmentId', 'code', 'codeId', 'projectId', 'retResult', 'modelIsShow'], data() { return { token: util.getCookie('admin-token'), @@ -172,57 +175,7 @@ export default { sourceCode: '', // 把input替换成exit函数后的代码 requestTimer: null, // 用于中断请求的定时器 modelVisible: false, - - modelData: [ - { - id: 1, - label: '品牌一', - children: [ - { - id: 4, - label: '华东区域', - children: [ - { - id: 9, - label: '上海' - }, - { - id: 10, - label: '昆山' - } - ] - } - ] - }, - { - id: 2, - label: '品牌二', - children: [ - { - id: 5, - label: '华东区域' - }, - { - id: 6, - label: '华南区域' - } - ] - }, - { - id: 3, - label: '品牌三', - children: [ - { - id: 7, - label: '华北区域' - }, - { - id: 8, - label: '华南区域' - } - ] - } - ] + modelData: [] }; }, components: { @@ -263,6 +216,37 @@ export default { // 导入模型 importModel() { this.modelVisible = true + // 查询源模型分类 + this.$post(`${this.api.modelClassList}?systemId=${this.systemId}`).then(res => { + const { data } = res + const promises = [] + const addType = list => { + list.map(e => { + // 用promise储存以添加完后更新数据 + promises.push(new Promise((resolve,reject) => { + this.$post(this.api.referenceDemoList, { + pageNum: 1, + pageSize: 10000, + categoryId: e.id + }).then(res => { + const { records } = res.data + records.map(n => { + n.categoryName = n.modelName + }) + 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 + }).catch(res => {}) + }).catch(res => {}) }, // 多选框选择回调 treeCheckChange(data, checked, indeterminate) { @@ -275,9 +259,12 @@ export default { }, // 导入模型提交 submit() { - // this.$post(this.api.sourceModelClassification).then(res => { - - // }).catch(res => {}) + const id = this.$refs.tree.getCheckedKeys() + if (!id.length) return this.$message.error('请选择模型!') + this.$post(`${this.api.referenceFindById}?id=${id[0]}`).then(res => { + // this.codeVal = '' + this.modelVisible = false + }).catch(res => {}) }, /** * python代码里如果有input函数的话,是做了单独的处理的,原理是先把所有input函数都替换成exit函数,再在exit函数里加上特定标识,再通过接口传给后端去执行 diff --git a/src/config/index.js b/src/config/index.js index e91769b..1c24bd4 100644 --- a/src/config/index.js +++ b/src/config/index.js @@ -4,7 +4,7 @@ const isHh = location.host.includes('10.196.131.73') //是否是河海版本 const isBeta = process.env.NODE_ENV === 'development' || location.host.includes('39.108.250.202') //是否是职站测试 let host = location.origin + ':9000/' -if (process.env.NODE_ENV === 'development') host = 'http://39.108.250.202:9000' +if (process.env.NODE_ENV === 'development') host = 'http://192.168.31.151:9000' /** * python8个系统的id和名称 * id即systemId,从cookie里取 diff --git a/src/views/Home.vue b/src/views/Home.vue index 8cd2b81..7fcb3d6 100644 --- a/src/views/Home.vue +++ b/src/views/Home.vue @@ -29,6 +29,7 @@ :codeId.sync="item.codeId" :answer.sync="item.answer" :retResult.sync="item.retResult" + :modelIsShow.sync="modelIsShow" @cache="leavePage" > @@ -59,6 +60,7 @@ export default { courseId: util.getCookie("courseId"), // 课程id assessmentId: util.getCookie("assessmentId"), // 考核id systemId: util.getCookie('systemId'), + modelIsShow: false, // 导入模型按钮是否显示 projectPermissions: 0, // 项目权限(0、练习 1、考核 2、竞赛) language: 'Python', // 编程语言 curTab: '', // 选中后绑定的对象 @@ -74,6 +76,7 @@ export default { this.loadIns = Loading.service({ background: 'rgba(255, 255, 255, .1)' }) + this.getModelStatus() this.autoLogout() // 绑定页面离开监听 window.onbeforeunload = () => { @@ -104,6 +107,12 @@ export default { }) } }, + // 获取导入模型按钮展示状态 + getModelStatus() { + this.$post(`${this.api.checkIsShowBySystemId}?systemId=${this.systemId}`).then(res => { + this.modelIsShow = !res.isShow // 0为展示 1为不展示 + }).catch(res => {}) + }, // 长时间未点击页面,就自动退出页面 autoLogout(){ let lastTime = new Date().getTime()