|
|
@ -85,17 +85,26 @@ |
|
|
|
:visible.sync="modelVisible" |
|
|
|
:visible.sync="modelVisible" |
|
|
|
width="500px" |
|
|
|
width="500px" |
|
|
|
class="dialog" |
|
|
|
class="dialog" |
|
|
|
:close-on-click-modal="false"> |
|
|
|
:close-on-click-modal="false" |
|
|
|
|
|
|
|
v-loading="modelLoading"> |
|
|
|
<div class="model-wrap"> |
|
|
|
<div class="model-wrap"> |
|
|
|
<el-tree v-if="modelData.length" |
|
|
|
<el-tree v-if="schoolModels.length" |
|
|
|
:data="modelData" |
|
|
|
:data="schoolModels" |
|
|
|
v-loading="modelLoading" |
|
|
|
ref="schoolModel" |
|
|
|
ref="model" |
|
|
|
|
|
|
|
default-expand-all |
|
|
|
default-expand-all |
|
|
|
show-checkbox |
|
|
|
show-checkbox |
|
|
|
node-key="id" |
|
|
|
node-key="id" |
|
|
|
:props="{children: 'children', label: 'categoryName', isLeaf: 'leaf'}"> |
|
|
|
:props="{children: 'children', label: 'categoryName', isLeaf: 'leaf'}"> |
|
|
|
</el-tree> |
|
|
|
</el-tree> |
|
|
|
|
|
|
|
<el-tree v-if="systemModels.length" |
|
|
|
|
|
|
|
:data="systemModels" |
|
|
|
|
|
|
|
ref="systemModel" |
|
|
|
|
|
|
|
default-expand-all |
|
|
|
|
|
|
|
show-checkbox |
|
|
|
|
|
|
|
node-key="id" |
|
|
|
|
|
|
|
:props="{children: 'children', label: 'categoryName', isLeaf: 'leaf'}"> |
|
|
|
|
|
|
|
</el-tree> |
|
|
|
|
|
|
|
|
|
|
|
<div class="none" |
|
|
|
<div class="none" |
|
|
|
v-else>暂无可导入的模型</div> |
|
|
|
v-else>暂无可导入的模型</div> |
|
|
|
</div> |
|
|
|
</div> |
|
|
@ -124,7 +133,8 @@ export default { |
|
|
|
multipleSelection: [], |
|
|
|
multipleSelection: [], |
|
|
|
modelVisible: false, |
|
|
|
modelVisible: false, |
|
|
|
modelLoading: false, |
|
|
|
modelLoading: false, |
|
|
|
modelData: [], |
|
|
|
schoolModels: [], |
|
|
|
|
|
|
|
systemModels: [], |
|
|
|
submiting: false, |
|
|
|
submiting: false, |
|
|
|
timer: null |
|
|
|
timer: null |
|
|
|
}; |
|
|
|
}; |
|
|
@ -195,83 +205,77 @@ export default { |
|
|
|
this.getData() |
|
|
|
this.getData() |
|
|
|
}, |
|
|
|
}, |
|
|
|
// 导入模型 |
|
|
|
// 导入模型 |
|
|
|
add () { |
|
|
|
async add () { |
|
|
|
if (!this.$refs.tree.orgList.length) return this.$message.error('请先添加模型分类') |
|
|
|
if (!this.$refs.tree.orgList.length) return this.$message.error('请先添加模型分类') |
|
|
|
if (this.isTopLevel) return this.$message.error('请选择子分类进入导入模型') |
|
|
|
if (this.isTopLevel) return this.$message.error('请选择子分类进入导入模型') |
|
|
|
this.modelVisible = true |
|
|
|
this.modelVisible = true |
|
|
|
this.modelLoading = true |
|
|
|
this.modelLoading = true |
|
|
|
// 获取模型列表,用以跟源模型列表作比对,重复的不再显示 |
|
|
|
|
|
|
|
this.$post(this.api.getAllModelList, { |
|
|
|
|
|
|
|
founder: 1, |
|
|
|
|
|
|
|
pageNum: 1, |
|
|
|
|
|
|
|
pageSize: 10000, |
|
|
|
|
|
|
|
systemId: this.systemId, |
|
|
|
|
|
|
|
isOpen: 0 |
|
|
|
|
|
|
|
}).then(res => { |
|
|
|
|
|
|
|
const modelList = res.data.records |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// 本校分类及模型 |
|
|
|
// 本校分类模型跟系统内置分类模型的接口不一样,分开处理 |
|
|
|
// 查询源模型分类 |
|
|
|
// 查询源模型分类 |
|
|
|
this.$post(this.api.sourceModelClassification + '?founder=1').then(({ data }) => { |
|
|
|
let { data } = await this.$post(this.api.sourceModelClassification + '?founder=1') |
|
|
|
const promises = [] |
|
|
|
const promises = [] |
|
|
|
const addType = list => { |
|
|
|
const addType = (list, system = 0) => { |
|
|
|
list.map((e, i) => { |
|
|
|
list.map((e, i) => { |
|
|
|
// 用promise储存以添加完后更新数据 |
|
|
|
// 用promise储存以添加完后更新数据 |
|
|
|
promises.push(new Promise((resolve, reject) => { |
|
|
|
promises.push(new Promise(async (resolve, reject) => { |
|
|
|
// 获取源模型列表 |
|
|
|
try { |
|
|
|
this.$post(this.api.sysModelDemoList, { |
|
|
|
// 获取源模型列表 |
|
|
|
pageNum: 1, |
|
|
|
const res = await this.$post(this.api[system ? 'sortReadingModelByTeacherSideSystem' : 'InstitutionSourceModel'], { |
|
|
|
pageSize: 10000, |
|
|
|
pageNum: 1, |
|
|
|
categoryId: e.id, |
|
|
|
pageSize: 10000, |
|
|
|
founder: 1, |
|
|
|
categoryId: e.id, |
|
|
|
postStatus: 1, |
|
|
|
founder: system ? 0 : 1, |
|
|
|
isOpen: 0, |
|
|
|
postStatus: 1, |
|
|
|
ztOpen: 0 |
|
|
|
isOpen: 0, |
|
|
|
}).then(res => { |
|
|
|
ztOpen: 0 |
|
|
|
const { records } = res.data |
|
|
|
}) |
|
|
|
const modelChildren = [] |
|
|
|
const { records } = res.data |
|
|
|
// 判重,重复的模型不再显示,通过模型的copyId和源模型的id作比对 |
|
|
|
const modelChildren = [] |
|
|
|
records.map(n => { |
|
|
|
// 判重,重复的模型不再显示,通过模型的copyId和源模型的id作比对 |
|
|
|
if (!modelList.find(e => e.copyId === n.id)) { |
|
|
|
records.map(n => { |
|
|
|
n.categoryName = n.modelName |
|
|
|
n.categoryName = n.modelName |
|
|
|
modelChildren.push(n) |
|
|
|
modelChildren.push(n) |
|
|
|
} |
|
|
|
}) |
|
|
|
}) |
|
|
|
// 如果有未导入的模型,则添加到子级,否则设置为disabled |
|
|
|
// 如果有未导入的模型,则添加到子级,否则设置为disabled |
|
|
|
if (modelChildren.length) { |
|
|
|
if (modelChildren.length) { |
|
|
|
e.children = [...e.children, ...modelChildren] |
|
|
|
e.children = [...e.children, ...modelChildren] |
|
|
|
} else if (records.length) { |
|
|
|
} else if (records.length) { |
|
|
|
e.disabled = true |
|
|
|
e.disabled = true |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
resolve() |
|
|
|
|
|
|
|
}).catch(res => { |
|
|
|
|
|
|
|
reject() |
|
|
|
|
|
|
|
}) |
|
|
|
|
|
|
|
})) |
|
|
|
|
|
|
|
e.children && e.children.length && addType(e.children) |
|
|
|
|
|
|
|
}) |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
addType(data) |
|
|
|
|
|
|
|
// 筛选出disabled不为true的分类,因为没有模型的分类不需要展示 |
|
|
|
|
|
|
|
const handleType = list => { |
|
|
|
|
|
|
|
return list.filter((e, i) => { |
|
|
|
|
|
|
|
return !e.disabled |
|
|
|
|
|
|
|
}).map(e => { |
|
|
|
|
|
|
|
if (e.children) { |
|
|
|
|
|
|
|
e.children = handleType(e.children) |
|
|
|
|
|
|
|
} |
|
|
|
} |
|
|
|
return e |
|
|
|
resolve() |
|
|
|
}) |
|
|
|
} catch (error) { |
|
|
|
} |
|
|
|
reject() |
|
|
|
Promise.all(promises).then(_ => { |
|
|
|
} |
|
|
|
data = handleType(data) |
|
|
|
})) |
|
|
|
this.modelData = (data.length && data[0].children && data[0].children.length) ? data : [] |
|
|
|
e.children && e.children.length && addType(e.children, system) |
|
|
|
this.modelLoading = false |
|
|
|
}) |
|
|
|
}).catch(res => { }) |
|
|
|
} |
|
|
|
}).catch(res => { }) |
|
|
|
addType(data) |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// 系统内置模型 |
|
|
|
|
|
|
|
const res = await this.$post(`${this.api.builtInClassificationByNakadai}?systemId=${this.systemId}`) |
|
|
|
|
|
|
|
addType(res.data, 1) |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
Promise.all(promises).then(_ => { |
|
|
|
|
|
|
|
data = this.handleType(data) |
|
|
|
|
|
|
|
const systemData = this.handleType(res.data) |
|
|
|
|
|
|
|
this.schoolModels = (data.length && data[0].children && data[0].children.length) ? data : [] |
|
|
|
|
|
|
|
this.systemModels = (systemData.length && systemData[0].children && systemData[0].children.length) ? systemData : [] |
|
|
|
|
|
|
|
this.modelLoading = false |
|
|
|
}).catch(res => { }) |
|
|
|
}).catch(res => { }) |
|
|
|
}, |
|
|
|
}, |
|
|
|
// 把删除了的分类去除 |
|
|
|
// 筛选出disabled不为true的分类,因为没有模型的分类不需要展示 |
|
|
|
|
|
|
|
handleType (list) { |
|
|
|
|
|
|
|
return list.filter((e, i) => { |
|
|
|
|
|
|
|
return !e.disabled |
|
|
|
|
|
|
|
}).map(e => { |
|
|
|
|
|
|
|
if (e.children) { |
|
|
|
|
|
|
|
e.children = this.handleType(e.children) |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
return e |
|
|
|
|
|
|
|
}) |
|
|
|
|
|
|
|
}, |
|
|
|
|
|
|
|
|
|
|
|
// 查看模型 |
|
|
|
// 查看模型 |
|
|
|
show (row) { |
|
|
|
show (row) { |
|
|
@ -323,9 +327,10 @@ export default { |
|
|
|
submit () { |
|
|
|
submit () { |
|
|
|
if (this.submiting) return false |
|
|
|
if (this.submiting) return false |
|
|
|
const data = [] |
|
|
|
const data = [] |
|
|
|
const systemId = this.systemId |
|
|
|
const { systemId } = this |
|
|
|
if (this.$refs.model) { |
|
|
|
const { schoolModel, systemModel } = this.$refs |
|
|
|
const list = this.$refs.model.getCheckedNodes() // 获取选择的分类模型 |
|
|
|
if (schoolModel || systemModel) { |
|
|
|
|
|
|
|
const list = [...schoolModel.getCheckedNodes(), ...systemModel.getCheckedNodes()] // 获取选择的分类模型 |
|
|
|
const categoryId = this.$refs.tree.$refs.tree.getCurrentKey() // 获取当前分类 |
|
|
|
const categoryId = this.$refs.tree.$refs.tree.getCurrentKey() // 获取当前分类 |
|
|
|
if (!list.length) return this.$message.error('请选择模型') |
|
|
|
if (!list.length) return this.$message.error('请选择模型') |
|
|
|
this.submiting = true |
|
|
|
this.submiting = true |
|
|
@ -334,7 +339,7 @@ export default { |
|
|
|
e.categoryId && data.push({ |
|
|
|
e.categoryId && data.push({ |
|
|
|
systemId, |
|
|
|
systemId, |
|
|
|
categoryId, |
|
|
|
categoryId, |
|
|
|
copyId: e.id |
|
|
|
copyId: e.founder ? e.id : e.copyId // 系统模型取copyId,本校模型取id |
|
|
|
}) |
|
|
|
}) |
|
|
|
}) |
|
|
|
}) |
|
|
|
this.$post(this.api.saveReferenceDemo, data).then(res => { |
|
|
|
this.$post(this.api.saveReferenceDemo, data).then(res => { |
|
|
|