提交 1e1562b4 编写于 作者: Mosher's avatar Mosher

update:调整

上级 b1068c8f
...@@ -303,8 +303,13 @@ import UIService from '@/uiservice/ui-service'; ...@@ -303,8 +303,13 @@ import UIService from '@/uiservice/ui-service';
// 处理多选数据 // 处理多选数据
if(!this.isSingleSelect){ if(!this.isSingleSelect){
let leafNodes = checkedState.checkedNodes.filter((item:any) => item.leaf); let leafNodes = checkedState.checkedNodes.filter((item:any) => item.leaf);
this.selectedNodes = JSON.parse(JSON.stringify(leafNodes)); const selectedNodes = JSON.parse(JSON.stringify(leafNodes));
this.$emit('selectionchange', this.selectedNodes); this.handleCtrlEvents('onselectionchange', { action: 'SelectionChange', data: selectedNodes }).then((res: boolean) => {
if (res) {
this.selectedNodes = selectedNodes;
this.$emit('selectionchange', this.selectedNodes);
}
})
} }
} }
...@@ -323,14 +328,19 @@ import UIService from '@/uiservice/ui-service'; ...@@ -323,14 +328,19 @@ import UIService from '@/uiservice/ui-service';
return; return;
} }
// 只处理最底层子节点 // 只处理最底层子节点
if(this.isBranchAvailable || data.leaf){ if(this.isBranchAvailable || data.leaf) {
this.currentselectedNode = JSON.parse(JSON.stringify(data)); this.handleCtrlEvents('onselectionchange', { action: 'SelectionChange', data: data }).then((res: boolean) => {
// 单选直接替换 if (!res) {
if(this.isSingleSelect){ return;
this.selectedNodes = [this.currentselectedNode]; }
this.$emit('selectionchange', this.selectedNodes); this.currentselectedNode = JSON.parse(JSON.stringify(data));
} // 单选直接替换
// 多选用check方法 if(this.isSingleSelect){
this.selectedNodes = [this.currentselectedNode];
this.$emit('selectionchange', this.selectedNodes);
}
// 多选用check方法
});
} }
} }
...@@ -514,31 +524,52 @@ import UIService from '@/uiservice/ui-service'; ...@@ -514,31 +524,52 @@ import UIService from '@/uiservice/ui-service';
Object.assign(tempContext,{srfparentkey:curNode.data.srfparentkey}); Object.assign(tempContext,{srfparentkey:curNode.data.srfparentkey});
Object.assign(tempViewParams,{srfparentkey:curNode.data.srfparentkey}); Object.assign(tempViewParams,{srfparentkey:curNode.data.srfparentkey});
} }
Object.assign(params,{viewparams:tempViewParams}); Object.assign(params,{ viewparams: tempViewParams });
this.service.getNodes(tempContext,params).then((response: any) => { this.handleCtrlEvents('onbeforeload', { data: node.data }).then((beforeLoadResult: boolean) => {
if (!response || response.status !== 200) { if (!beforeLoadResult) {
this.$Notice.error({ title: (this.$t('app.commonWords.wrong') as string), desc: response.info });
resolve([]);
return; return;
} }
const _items = response.data; this.service.getNodes(tempContext,params).then((response: any) => {
this.formatExpanded(_items); if (!response || response.status !== 200) {
<#-- if (!node.level || node.level === 0) { this.handleCtrlEvents('onloaderror', { data: node.data }).then((loadErrorResult: boolean) => {
this.nodes = [..._items]; if (!loadErrorResult) {
} return;
this.nodes = response.data; --> }
resolve([..._items]); this.$Notice.error({ title: (this.$t('app.commonWords.wrong') as string), desc: response.info });
let isRoot = Object.is(node.level,0); resolve([]);
let isSelectedAll = node.checked; return;
this.setDefaultSelection(_items, isRoot, isSelectedAll); })
this.$emit("load", _items); }
}).catch((response: any) => { this.handleCtrlEvents('onloaderror', { data: node.data }).then((loadSuccessResult: boolean) => {
resolve([]); if (!loadSuccessResult) {
if (response && response.status === 401) { resolve([]);
return; return;
} }
this.$Notice.error({ title: (this.$t('app.commonWords.wrong') as string), desc: response.info }); const _items = response.data;
}); this.formatExpanded(_items);
<#-- if (!node.level || node.level === 0) {
this.nodes = [..._items];
}
this.nodes = response.data; -->
resolve([..._items]);
let isRoot = Object.is(node.level,0);
let isSelectedAll = node.checked;
this.setDefaultSelection(_items, isRoot, isSelectedAll);
this.$emit("load", _items);
});
}).catch((response: any) => {
this.handleCtrlEvents('onloaderror', { data: node.data }).then((loadErrorResult: boolean) => {
if (!loadErrorResult) {
return;
}
resolve([]);
if (response && response.status === 401) {
return;
}
this.$Notice.error({ title: (this.$t('app.commonWords.wrong') as string), desc: response.info });
});
});
})
} }
/** /**
...@@ -597,28 +628,48 @@ import UIService from '@/uiservice/ui-service'; ...@@ -597,28 +628,48 @@ import UIService from '@/uiservice/ui-service';
*/ */
public refresh_node(curContext:any,arg: any = {}, parentnode: boolean): void { public refresh_node(curContext:any,arg: any = {}, parentnode: boolean): void {
const { srfnodeid: id } = arg; const { srfnodeid: id } = arg;
Object.assign(arg,{viewparams:this.viewparams}); Object.assign(arg, { viewparams: this.viewparams });
const get: Promise<any> = this.service.getNodes(JSON.parse(JSON.stringify(curContext)),arg); this.handleCtrlEvents('onbeforerefreshnode', { data: arg }).then((beforeRefreshRes: boolean) => {
get.then((response: any) => { if (!beforeRefreshRes) {
if (!response || response.status !== 200) {
this.$Notice.error({ title: (this.$t('app.commonWords.wrong') as string), desc: response.info });
return; return;
} }
const _items = [...response.data]; const get: Promise<any> = this.service.getNodes(JSON.parse(JSON.stringify(curContext)), arg);
this.formatExpanded(_items); get.then((response: any) => {
const tree: any = this.$refs.${ctrl.name}; if (!response || response.status !== 200) {
tree.updateKeyChildren(id, _items); this.handleCtrlEvents('onrefreshnodeerror', { data: response && response.data ? response.data : {} }).then((errorRes: boolean) => {
if (parentnode) { if (!errorRes) {
this.currentselectedNode = {}; return;
} }
this.$forceUpdate(); this.$Notice.error({ title: (this.$t('app.commonWords.wrong') as string), desc: response.info });
this.setDefaultSelection(_items); return;
}).catch((response: any) => { })
if (response && response.status === 401) { }
return; const _items = [...response.data];
} this.handleCtrlEvents('onrefreshnodesuccess', { data: _items }).then((successRes: boolean) => {
this.$Notice.error({ title: (this.$t('app.commonWords.wrong') as string), desc: response.info }); if (!successRes) {
}); return;
}
this.formatExpanded(_items);
const tree: any = this.$refs.${ctrl.name};
tree.updateKeyChildren(id, _items);
if (parentnode) {
this.currentselectedNode = {};
}
this.$forceUpdate();
this.setDefaultSelection(_items);
})
}).catch((response: any) => {
this.handleCtrlEvents('onrefreshnodeerror', { data: response && response.data ? response.data : {} }).then((errorRes: boolean) => {
if (!errorRes) {
return;
}
if (response && response.status === 401) {
return;
}
this.$Notice.error({ title: (this.$t('app.commonWords.wrong') as string), desc: response.info });
})
});
})
} }
/** /**
......
Markdown 格式
0% or
您添加了 0 到此讨论。请谨慎行事。
先完成此消息的编辑!
想要评论请 注册