|
|
|
@ -43,7 +43,8 @@ |
|
|
|
|
|
|
|
|
|
<el-dialog title="请选择需要导入的模型" :visible.sync="modelVisible" width="500px" class="dialog" :close-on-click-modal="false"> |
|
|
|
|
<div class="model-wrap"> |
|
|
|
|
<el-tree |
|
|
|
|
<el-tree |
|
|
|
|
v-if="modelData.length" |
|
|
|
|
:data="modelData" v-loading="modelLoading" |
|
|
|
|
ref="model" |
|
|
|
|
default-expand-all |
|
|
|
@ -51,6 +52,7 @@ |
|
|
|
|
node-key="id" |
|
|
|
|
:props="{children: 'children', label: 'categoryName', isLeaf: 'leaf'}"> |
|
|
|
|
</el-tree> |
|
|
|
|
<div class="none" v-else>暂无可导入的模型</div> |
|
|
|
|
</div> |
|
|
|
|
<span slot="footer" class="dialog-footer"> |
|
|
|
|
<el-button @click="modelVisible = false">取 消</el-button> |
|
|
|
@ -137,10 +139,10 @@ export default { |
|
|
|
|
|
|
|
|
|
// 查询源模型分类 |
|
|
|
|
this.$post(this.api.sourceModelClassification).then(res => { |
|
|
|
|
const { data } = res |
|
|
|
|
let { data } = res |
|
|
|
|
const promises = [] |
|
|
|
|
const addType = list => { |
|
|
|
|
list.map(e => { |
|
|
|
|
list.map((e, i) => { |
|
|
|
|
// 用promise储存以添加完后更新数据 |
|
|
|
|
promises.push(new Promise((resolve,reject) => { |
|
|
|
|
// 获取源模型列表 |
|
|
|
@ -158,7 +160,12 @@ export default { |
|
|
|
|
modelChildren.push(n) |
|
|
|
|
} |
|
|
|
|
}) |
|
|
|
|
e.children = [...e.children, ...modelChildren] |
|
|
|
|
// 如果有未导入的模型,则添加到子级,否则设置为disabled |
|
|
|
|
if (modelChildren.length) { |
|
|
|
|
e.children = [...e.children, ...modelChildren] |
|
|
|
|
} else { |
|
|
|
|
e.disabled = true |
|
|
|
|
} |
|
|
|
|
resolve() |
|
|
|
|
}).catch(res => { |
|
|
|
|
reject() |
|
|
|
@ -168,13 +175,27 @@ export default { |
|
|
|
|
}) |
|
|
|
|
} |
|
|
|
|
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 |
|
|
|
|
}) |
|
|
|
|
} |
|
|
|
|
Promise.all(promises).then(_ => { |
|
|
|
|
this.modelData = data |
|
|
|
|
this.modelLoading = false |
|
|
|
|
data = handleType(data) |
|
|
|
|
this.modelData = data |
|
|
|
|
this.modelLoading = false |
|
|
|
|
}).catch(res => {}) |
|
|
|
|
}).catch(res => {}) |
|
|
|
|
}).catch(res => {}) |
|
|
|
|
}, |
|
|
|
|
// 把删除了的分类去除 |
|
|
|
|
|
|
|
|
|
// 查看模型 |
|
|
|
|
show(row) { |
|
|
|
|
this.$router.push(`/addModel?categoryId=${this.$refs.tree.$refs.tree.getCurrentKey()}&id=${row.id}&show=1&model=1`) |
|
|
|
@ -219,27 +240,32 @@ export default { |
|
|
|
|
if (this.submiting) return false |
|
|
|
|
const data = [] |
|
|
|
|
const systemId = this.systemId |
|
|
|
|
const list = this.$refs.model.getCheckedNodes() // 获取选择的分类模型 |
|
|
|
|
const categoryId = this.$refs.tree.$refs.tree.getCurrentKey() // 获取当前分类 |
|
|
|
|
if (!list.length) return this.$message.error('请选择模型') |
|
|
|
|
this.submiting = true |
|
|
|
|
list.map(e => { |
|
|
|
|
// 有categoryId的才是模型,只导入模型,不导入分类 |
|
|
|
|
e.categoryId && data.push({ |
|
|
|
|
systemId, |
|
|
|
|
categoryId, |
|
|
|
|
copyId: e.id |
|
|
|
|
if (this.$refs.model) { |
|
|
|
|
const list = this.$refs.model.getCheckedNodes() // 获取选择的分类模型 |
|
|
|
|
const categoryId = this.$refs.tree.$refs.tree.getCurrentKey() // 获取当前分类 |
|
|
|
|
if (!list.length) return this.$message.error('请选择模型') |
|
|
|
|
this.submiting = true |
|
|
|
|
list.map(e => { |
|
|
|
|
// 有categoryId的才是模型,只导入模型,不导入分类 |
|
|
|
|
e.categoryId && data.push({ |
|
|
|
|
systemId, |
|
|
|
|
categoryId, |
|
|
|
|
copyId: e.id |
|
|
|
|
}) |
|
|
|
|
}) |
|
|
|
|
}) |
|
|
|
|
this.$post(this.api.saveReferenceDemo, data).then(res => { |
|
|
|
|
this.modelVisible = false |
|
|
|
|
this.initData() |
|
|
|
|
setTimeout(() => { |
|
|
|
|
this.submiting = false |
|
|
|
|
}, 2000) |
|
|
|
|
}).catch(res => { |
|
|
|
|
this.submiting = false |
|
|
|
|
}) |
|
|
|
|
this.$post(this.api.saveReferenceDemo, data).then(res => { |
|
|
|
|
this.modelVisible = false |
|
|
|
|
this.initData() |
|
|
|
|
setTimeout(() => { |
|
|
|
|
this.submiting = false |
|
|
|
|
}, 2000) |
|
|
|
|
}).catch(res => { |
|
|
|
|
this.submiting = false |
|
|
|
|
}) |
|
|
|
|
} else { |
|
|
|
|
this.submiting = false |
|
|
|
|
this.modelVisible = false |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
}; |
|
|
|
@ -266,5 +292,9 @@ export default { |
|
|
|
|
.model-wrap { |
|
|
|
|
max-height: 400px; |
|
|
|
|
overflow: auto; |
|
|
|
|
.none { |
|
|
|
|
text-align: center; |
|
|
|
|
color: #8b8b8b; |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
</style> |