|
|
@@ -143,7 +143,7 @@
|
|
|
export default {
|
|
|
data() {
|
|
|
return {
|
|
|
- curnode:null,
|
|
|
+ curNode:null,
|
|
|
filterText:'',
|
|
|
data:[],
|
|
|
form:{},
|
|
|
@@ -158,18 +158,54 @@ export default {
|
|
|
}
|
|
|
},
|
|
|
methods: {
|
|
|
+ addNode(data,curnode,target){
|
|
|
+ let curid = curnode.id;
|
|
|
+ let curname = curnode.name;
|
|
|
+ data.forEach((item,i)=>{
|
|
|
+ if(item.id==curid&&item.name==curname){
|
|
|
+ const newChild = { id: target.id, name: target.name, children: [] };
|
|
|
+ if (!item.children) {
|
|
|
+ this.$set(item, 'children', []);
|
|
|
+ }
|
|
|
+ item.children.push(newChild)
|
|
|
+ }else{
|
|
|
+ this.addNode(item.children,curnode,target)
|
|
|
+ }
|
|
|
+ })
|
|
|
+ },
|
|
|
+ editNode(data,curnode,target){
|
|
|
+ let curid = curnode.id;
|
|
|
+ let curname = curnode.name;
|
|
|
+ data.forEach((item,i)=>{
|
|
|
+ if(item.id==curid&&item.name==curname){
|
|
|
+ const newChild = { id: target.id, name: target.name, children: [] };
|
|
|
+ // if (!item.children) {
|
|
|
+ // this.$set(item, 'children', []);
|
|
|
+ // }
|
|
|
+ // item.children.push(newChild)
|
|
|
+ this.$set(item,"name",target.name)
|
|
|
+ }else{
|
|
|
+ this.editNode(item.children,curnode,target)
|
|
|
+ }
|
|
|
+ })
|
|
|
+ },
|
|
|
getData(){
|
|
|
this.$api.getRiskpointList({name:this.filterText}).then(res=>{
|
|
|
this.data=res.data.data
|
|
|
})
|
|
|
},
|
|
|
edit(data){
|
|
|
+ this.curNode = data;
|
|
|
this.$api.getRiskpoint({id:data.id}).then(res=>{
|
|
|
let data=res.data.data;
|
|
|
this.form=data
|
|
|
})
|
|
|
},
|
|
|
append(data){
|
|
|
+ console.log(this.data,33333333333)
|
|
|
+ this.curNode = data;
|
|
|
+ // this.addNode(this.data,data,target)
|
|
|
+ console.log(data)
|
|
|
// this.show=1;
|
|
|
if(data.type == 'ent'){
|
|
|
this.form={
|
|
|
@@ -216,7 +252,9 @@ export default {
|
|
|
this.$api.updateRiskpoint(parm).then(res=>{
|
|
|
if(res.data.code==0){
|
|
|
this.$message({message: '修改成功!',type: 'success'});
|
|
|
- this.getData()
|
|
|
+ let newNode = {id:res.data.data,name:this.form.name,children:[]}
|
|
|
+ this.editNode(this.data,this.curNode,newNode)
|
|
|
+ // this.getData()
|
|
|
this.form={}
|
|
|
}else{
|
|
|
this.$message.error(res.data.message);
|
|
|
@@ -226,7 +264,9 @@ export default {
|
|
|
this.$api.saveRiskpoint(parm).then(res=>{
|
|
|
if(res.data.code==0){
|
|
|
this.$message({message: '添加成功!',type: 'success'});
|
|
|
- this.getData()
|
|
|
+ let newNode = {id:res.data.data,name:this.form.name,children:[]}
|
|
|
+ this.addNode(this.data,this.curNode,newNode)
|
|
|
+ // this.getData()
|
|
|
this.form={}
|
|
|
}else{
|
|
|
this.$message.error(res.data.message);
|