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