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