导入模型等联调

dev_2022-03-03
yujialong 3 years ago
parent 34299e9fa3
commit ae36804dee
  1. 6
      src/api/index.js
  2. 109
      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',
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`,
}

@ -16,6 +16,7 @@
@click="clearCode"
>清屏</el-button>
<el-button
v-if="modelIsShow"
class="btn"
type="warning"
@click="importModel"
@ -61,12 +62,14 @@
<!-- 导入模型 -->
<el-dialog title="请选择要导入的模型" :visible.sync="modelVisible" width="400px" :close-on-click-modal="false">
<el-tree
:data="modelData"
ref="tree"
@check-change="treeCheckChange"
show-checkbox
:check-strictly="true"
node-key="id">
: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'}">
</el-tree>
<span slot="footer" class="dialog-footer">
<el-button size="small" @click="typeVisible = false">取消</el-button>
@ -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: '', // inputexit
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函数里加上特定标识再通过接口传给后端去执行

@ -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里取

@ -29,6 +29,7 @@
:codeId.sync="item.codeId"
:answer.sync="item.answer"
:retResult.sync="item.retResult"
:modelIsShow.sync="modelIsShow"
@cache="leavePage"
></codemirror>
</el-tab-pane>
@ -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()

Loading…
Cancel
Save