导入模型等联调

dev_2022-03-03
yujialong 3 years ago
parent 34299e9fa3
commit ae36804dee
  1. 6
      src/api/index.js
  2. 99
      src/components/codemirror.vue
  3. 2
      src/config/index.js
  4. 9
      src/views/Home.vue

@ -8,5 +8,9 @@ export default {
getLastCache: 'python/python/getLastCache', getLastCache: 'python/python/getLastCache',
delCache: 'python/python/delCache', delCache: 'python/python/delCache',
getDetailById: 'occupationlab/assessment/getDetailById', 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`,
} }

@ -16,6 +16,7 @@
@click="clearCode" @click="clearCode"
>清屏</el-button> >清屏</el-button>
<el-button <el-button
v-if="modelIsShow"
class="btn" class="btn"
type="warning" type="warning"
@click="importModel" @click="importModel"
@ -63,10 +64,12 @@
<el-tree <el-tree
:data="modelData" :data="modelData"
ref="tree" ref="tree"
default-expand-all
@check-change="treeCheckChange" @check-change="treeCheckChange"
show-checkbox show-checkbox
:check-strictly="true" :check-strictly="true"
node-key="id"> node-key="id"
:props="{children: 'children', label: 'categoryName', isLeaf: 'leaf'}">
</el-tree> </el-tree>
<span slot="footer" class="dialog-footer"> <span slot="footer" class="dialog-footer">
<el-button size="small" @click="typeVisible = false">取消</el-button> <el-button size="small" @click="typeVisible = false">取消</el-button>
@ -124,7 +127,7 @@ import util from '@/util'
import config from '@/config' import config from '@/config'
const CANCEL_TOKEN = axios.CancelToken // input const CANCEL_TOKEN = axios.CancelToken // input
export default { export default {
props: ['judgmentId', 'code', 'codeId', 'projectId', 'retResult'], props: ['judgmentId', 'code', 'codeId', 'projectId', 'retResult', 'modelIsShow'],
data() { data() {
return { return {
token: util.getCookie('admin-token'), token: util.getCookie('admin-token'),
@ -172,57 +175,7 @@ export default {
sourceCode: '', // inputexit sourceCode: '', // inputexit
requestTimer: null, // requestTimer: null, //
modelVisible: false, modelVisible: false,
modelData: []
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: '华南区域'
}
]
}
]
}; };
}, },
components: { components: {
@ -263,6 +216,37 @@ export default {
// //
importModel() { importModel() {
this.modelVisible = true 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) { treeCheckChange(data, checked, indeterminate) {
@ -275,9 +259,12 @@ export default {
}, },
// //
submit() { submit() {
// this.$post(this.api.sourceModelClassification).then(res => { const id = this.$refs.tree.getCheckedKeys()
if (!id.length) return this.$message.error('请选择模型!')
// }).catch(res => {}) this.$post(`${this.api.referenceFindById}?id=${id[0]}`).then(res => {
// this.codeVal = ''
this.modelVisible = false
}).catch(res => {})
}, },
/** /**
* python代码里如果有input函数的话是做了单独的处理的原理是先把所有input函数都替换成exit函数再在exit函数里加上特定标识再通过接口传给后端去执行 * python代码里如果有input函数的话是做了单独的处理的原理是先把所有input函数都替换成exit函数再在exit函数里加上特定标识再通过接口传给后端去执行

@ -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') //是否是职站测试 const isBeta = process.env.NODE_ENV === 'development' || location.host.includes('39.108.250.202') //是否是职站测试
let host = location.origin + ':9000/' 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和名称 * python8个系统的id和名称
* id即systemId从cookie里取 * id即systemId从cookie里取

@ -29,6 +29,7 @@
:codeId.sync="item.codeId" :codeId.sync="item.codeId"
:answer.sync="item.answer" :answer.sync="item.answer"
:retResult.sync="item.retResult" :retResult.sync="item.retResult"
:modelIsShow.sync="modelIsShow"
@cache="leavePage" @cache="leavePage"
></codemirror> ></codemirror>
</el-tab-pane> </el-tab-pane>
@ -59,6 +60,7 @@ export default {
courseId: util.getCookie("courseId"), // id courseId: util.getCookie("courseId"), // id
assessmentId: util.getCookie("assessmentId"), // id assessmentId: util.getCookie("assessmentId"), // id
systemId: util.getCookie('systemId'), systemId: util.getCookie('systemId'),
modelIsShow: false, //
projectPermissions: 0, // (0 1 2) projectPermissions: 0, // (0 1 2)
language: 'Python', // language: 'Python', //
curTab: '', // curTab: '', //
@ -74,6 +76,7 @@ export default {
this.loadIns = Loading.service({ this.loadIns = Loading.service({
background: 'rgba(255, 255, 255, .1)' background: 'rgba(255, 255, 255, .1)'
}) })
this.getModelStatus()
this.autoLogout() this.autoLogout()
// //
window.onbeforeunload = () => { 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(){ autoLogout(){
let lastTime = new Date().getTime() let lastTime = new Date().getTime()

Loading…
Cancel
Save