|
@@ -447,8 +447,6 @@ export default {
|
|
|
init() {
|
|
|
this.jm.view.minZoom = 0.1;
|
|
|
this.jm.view.maxZoom = 5;
|
|
|
- // this.jm.expand_all()
|
|
|
- // this.setColor()
|
|
|
// 重写编辑完成事件
|
|
|
this.jm.view.edit_node_end = () => {
|
|
|
const node = this.jm.view.get_editing_node();
|
|
@@ -473,117 +471,11 @@ export default {
|
|
|
const selectedNode = this.jm.get_selected_node();
|
|
|
if (selectedNode) {
|
|
|
if (selectedNode.children.length == 0) {
|
|
|
- // if (selectedNode.data.rowType == 1) {//查询产品
|
|
|
- // var queryParams = {
|
|
|
- // productCategoryId: selectedNode.data.ids,
|
|
|
- // };
|
|
|
- // this.$api.queryProducts(queryParams).then((res) => {
|
|
|
- // if (res.code == 200) {
|
|
|
- // this.jm.enable_edit();
|
|
|
- // res.data.list.forEach((item) => {
|
|
|
- // var data = {
|
|
|
- // expanded: false,
|
|
|
- // rowType: 2,
|
|
|
- // ids: item.id,
|
|
|
- // productName:item.productName,
|
|
|
- // children: [],
|
|
|
- // };
|
|
|
- // this.jm.toggle_node(selectedNode.id);
|
|
|
- // data.children = item.children ? item.children : [];
|
|
|
- // item.type = 2;
|
|
|
- // this.jm.add_node(
|
|
|
- // selectedNode.id,
|
|
|
- // "产品" + item.id,
|
|
|
- // this.getModelCardDom(item),
|
|
|
- // data
|
|
|
- // );
|
|
|
- // });
|
|
|
- // this.jm.disable_edit();
|
|
|
- // }
|
|
|
- // });
|
|
|
- // } else if (selectedNode.data.rowType == 2) {//查询产品架构
|
|
|
- // var queryParams = {
|
|
|
- // productId: selectedNode.data.ids,
|
|
|
- // structureId: 0,
|
|
|
- // };
|
|
|
- // this.$api.queryStructures(queryParams).then((res) => {
|
|
|
- // if (res.code == 200) {
|
|
|
- // this.jm.enable_edit();
|
|
|
-
|
|
|
- // res.data.children.forEach((item) => {
|
|
|
- // var data = {
|
|
|
- // expanded: false,
|
|
|
- // rowType: 3,
|
|
|
- // ids: item.id,
|
|
|
- // productId: selectedNode.data.ids,
|
|
|
- // productName:selectedNode.data.productName,
|
|
|
- // };
|
|
|
- // this.jm.toggle_node(selectedNode.id);
|
|
|
- // data.children = item.children ? item.children : [];
|
|
|
- // item.productName=selectedNode.data.productName,
|
|
|
- // item.type = 3;
|
|
|
- // this.jm.add_node(
|
|
|
- // selectedNode.id,
|
|
|
- // "架构" + item.id,
|
|
|
- // this.getModelCardDom(item),
|
|
|
- // data
|
|
|
- // );
|
|
|
- // // if(item.children&& item.children.length>0){
|
|
|
- // // this.deepChildren(item.id,item.children)
|
|
|
- // // }
|
|
|
- // });
|
|
|
-
|
|
|
- // this.jm.disable_edit();
|
|
|
- // }
|
|
|
- // });
|
|
|
- // } else {
|
|
|
- // if ((selectedNode.data.children&&selectedNode.data.children.length==0) ||( selectedNode.data.hasChildren && selectedNode.data.hasChildren.length==0)) {
|
|
|
- // return false;
|
|
|
- // }
|
|
|
- // var queryParams = {
|
|
|
- // structureId: selectedNode.data.ids,
|
|
|
- // productId: selectedNode.data.productId,
|
|
|
- // };
|
|
|
- // this.$api.queryStructures(queryParams).then((res) => {
|
|
|
- // if (res.code == 200) {
|
|
|
- // this.jm.enable_edit();
|
|
|
-
|
|
|
- // res.data.children.forEach((item) => {
|
|
|
- // var data = {
|
|
|
- // expanded: false,
|
|
|
- // rowType: 3,
|
|
|
- // ids: item.id,
|
|
|
- // productId: selectedNode.data.productId,
|
|
|
- // productName:selectedNode.data.productName,
|
|
|
- // };
|
|
|
- // this.jm.toggle_node(selectedNode.id);
|
|
|
- // data.children = item.children ? item.children : [];
|
|
|
- // item.productName=selectedNode.data.productName,
|
|
|
- // item.type = 3;
|
|
|
- // this.jm.add_node(
|
|
|
- // selectedNode.id,
|
|
|
- // "架构" + item.id,
|
|
|
- // this.getModelCardDom(item),
|
|
|
- // data
|
|
|
- // );
|
|
|
- // // if(item.children&& item.children.length>0){
|
|
|
- // // this.deepChildren(item.id,item.children)
|
|
|
- // // }
|
|
|
- // });
|
|
|
-
|
|
|
- // this.jm.disable_edit();
|
|
|
- // }
|
|
|
- // });
|
|
|
- // }
|
|
|
+
|
|
|
} else {
|
|
|
this.jm.toggle_node(selectedNode.id);
|
|
|
}
|
|
|
-
|
|
|
- // return selectedNode.id
|
|
|
}
|
|
|
- // else {
|
|
|
- // return null
|
|
|
- // }
|
|
|
},
|
|
|
|
|
|
// 拖拽
|
|
@@ -702,6 +594,7 @@ export default {
|
|
|
},
|
|
|
|
|
|
|
|
|
+ //获取当前数据
|
|
|
async getData() {
|
|
|
if (this.type == 1) {//产品类别
|
|
|
let params = {
|
|
@@ -743,8 +636,9 @@ export default {
|
|
|
async LoadData(currentData){
|
|
|
if(currentData.MindType == 1){//产品类别
|
|
|
var data1 = currentData
|
|
|
- //装载产品
|
|
|
- const [products] = await Promise.allSettled([this.initData(data1)])
|
|
|
+ //装载产品和架构
|
|
|
+ const [products,classificationNode] = await Promise.allSettled([this.initData(data1),this.initData(data1,2)])
|
|
|
+ //产品的装载
|
|
|
var productList = products.status =='fulfilled'?products.value:[]
|
|
|
if(productList.length>0){
|
|
|
data1.hasChildren = true
|
|
@@ -756,10 +650,25 @@ export default {
|
|
|
item.topic = this.getModelCardDom(item)
|
|
|
return item
|
|
|
})
|
|
|
+ }else{
|
|
|
+
|
|
|
}
|
|
|
+
|
|
|
+ // 产品类别架构的装载
|
|
|
+ var classificationNodes = classificationNode.status =='fulfilled'?classificationNode.value:[]
|
|
|
+ if(classificationNodes && classificationNodes.length){
|
|
|
+ data1.hasChildren = true
|
|
|
+ if(!data1.children){
|
|
|
+ data1.children = []
|
|
|
+ }
|
|
|
+ this.deepChildren(classificationNodes,data1)
|
|
|
+ data1.children.push(...classificationNodes)
|
|
|
+ }
|
|
|
+
|
|
|
+
|
|
|
data1.topic = this.getModelCardDom(data1)
|
|
|
|
|
|
- //装载架构
|
|
|
+ //判断产品类别是否有产品
|
|
|
var data2 = data1.children
|
|
|
if(!data2){
|
|
|
return
|
|
@@ -767,11 +676,20 @@ export default {
|
|
|
// 获取需要返回的架构数组以及funList
|
|
|
var treeList = [], funList = []
|
|
|
for(var i = 0;i<data2.length;i++){
|
|
|
+ if(data2[i].MindType!=2){
|
|
|
+ continue
|
|
|
+ }
|
|
|
treeList.push(`tree${i+1}`)
|
|
|
funList.push(this.initData(data2[i]))
|
|
|
}
|
|
|
+ if(treeList.length == 0){
|
|
|
+ return
|
|
|
+ }
|
|
|
treeList = await Promise.allSettled(funList)
|
|
|
for(var i = 0;i<data2.length;i++){
|
|
|
+ if(data2[i].MindType!=2){
|
|
|
+ continue
|
|
|
+ }
|
|
|
var trees = treeList[i].status =='fulfilled'?treeList[i].value:[]
|
|
|
if(trees.length>0){
|
|
|
data2[i].hasChildren = true
|
|
@@ -792,7 +710,7 @@ export default {
|
|
|
}
|
|
|
data1.topic = this.getModelCardDom(data1)
|
|
|
data1.children = trees
|
|
|
- }else if(currentData.MindType == 0){//全部
|
|
|
+ }else if(currentData.MindType == 0){//全部,有错误
|
|
|
var data1 = currentData
|
|
|
//装载产品类别
|
|
|
const [category] = await Promise.allSettled([this.initData(data1)])
|
|
@@ -859,19 +777,19 @@ export default {
|
|
|
}
|
|
|
},
|
|
|
//初始化JsMind数据
|
|
|
- async initData(currentData){
|
|
|
- if(currentData.MindType == 1){
|
|
|
+ async initData(currentData,type){
|
|
|
+ if(currentData.MindType == 1 && type!=2){//查询产品
|
|
|
let params = {
|
|
|
searchQuery:`category_id=${currentData.MindId}`,//检索条件
|
|
|
}
|
|
|
return await this.$api.queryProduct(params).then(response=> response.data.data)
|
|
|
- }else if(currentData.MindType == 2){//产品
|
|
|
+ }else if(currentData.MindType == 2 || type == 2){//查询产品架构
|
|
|
var params = {
|
|
|
type: currentData.MindType,
|
|
|
typeId: currentData.MindId
|
|
|
}
|
|
|
return await this.$api.queryTreeNodeTree(params).then(response=> response.data.data)
|
|
|
- }else if(currentData.MindType == 0){
|
|
|
+ }else if(currentData.MindType == 0){//查询产品类别
|
|
|
let params = {
|
|
|
searchQuery:'',//检索条件
|
|
|
}
|
|
@@ -879,72 +797,6 @@ export default {
|
|
|
}
|
|
|
|
|
|
},
|
|
|
- // //初始化JsMind数据
|
|
|
- // async initData(currentData){
|
|
|
- // if(currentData.MindType == 1){
|
|
|
- // let params = {
|
|
|
- // searchQuery:`product_id=${currentData.id}`,//检索条件
|
|
|
- // }
|
|
|
- // await this.$api.queryProduct(params).then(response=>{
|
|
|
- // if(response.code == 200){
|
|
|
- // if(response.data.data.length>0){
|
|
|
- // currentData.hasChildren = true
|
|
|
- // currentData.children = response.data.data.map(item=>{
|
|
|
- // item.MindId = `产品${item.id}`
|
|
|
- // item.MindType = 2
|
|
|
- // item.expanded = false
|
|
|
- // item.topic = this.getModelCardDom(item)
|
|
|
- // // this.jm.enable_edit();
|
|
|
- // // this.jm.update_node(item.MindId,this.getModelCardDom(item) )
|
|
|
- // // this.jm.disable_edit();
|
|
|
- // return item
|
|
|
- // })
|
|
|
-
|
|
|
-
|
|
|
- // }
|
|
|
- // }
|
|
|
- // })
|
|
|
- // }else if(currentData.MindType == 2){
|
|
|
- // var params = {
|
|
|
- // type: currentData.MindType,
|
|
|
- // typeId: currentData.id
|
|
|
- // }
|
|
|
- // await this.$api.queryTreeNodeTree(params).then(res => {
|
|
|
- // if (res.code == 200) {
|
|
|
- // var data = res.data.data
|
|
|
- // if(data.length>0){
|
|
|
- // currentData.hasChildren = true
|
|
|
- // var data = this.deepChildren(data,currentData)
|
|
|
- // }
|
|
|
- // currentData.children = data
|
|
|
- // }
|
|
|
- // })
|
|
|
- // }else if(currentData.MindType == 0){
|
|
|
- // let params = {
|
|
|
- // searchQuery:'',//检索条件
|
|
|
- // }
|
|
|
- // await this.$api.queryProductCategory(params).then(response=>{
|
|
|
- // if(response.code == 200){
|
|
|
- // if(response.data.data.length>0){
|
|
|
- // currentData.hasChildren = true
|
|
|
- // currentData.children = response.data.data.map(item=>{
|
|
|
- // item.MindId = `产品类别${item.id}`
|
|
|
- // item.MindType = 1
|
|
|
- // item.expanded = false
|
|
|
- // item.topic = this.getModelCardDom(item)
|
|
|
- // // this.jm.enable_edit();
|
|
|
- // // this.jm.update_node(item.MindId,this.getModelCardDom(item) )
|
|
|
- // // this.jm.disable_edit();
|
|
|
- // return item
|
|
|
- // })
|
|
|
-
|
|
|
- // }
|
|
|
- // }
|
|
|
- // })
|
|
|
- // }
|
|
|
-
|
|
|
- // },
|
|
|
-
|
|
|
//递归
|
|
|
deepChildren(data,currentData){
|
|
|
for(var i = 0;i<data.length;i++){
|
|
@@ -974,7 +826,6 @@ export default {
|
|
|
async mounted() {
|
|
|
window.check = this.check;
|
|
|
await this.getData()
|
|
|
- // await this.initData(this.currentData)
|
|
|
this.mind.data = this.currentData
|
|
|
this.jm = jsMind.show(this.options, this.mind);
|
|
|
|
|
@@ -984,7 +835,6 @@ export default {
|
|
|
// this.handleDrop(nextParentId, srcNode.id)
|
|
|
// }
|
|
|
this.editor = this.jm.view.e_editor;
|
|
|
- // this.init()
|
|
|
this.toggleStucture("side");
|
|
|
this.mouseWheel();
|
|
|
this.mouseDrag();
|