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

update:调整

上级 b1068c8f
......@@ -644,7 +644,7 @@ import CodeListService from "@/codelist/codelist-service";
* @param {*} [arg={}]
* @memberof ${srfclassname('${ctrl.codeName}')}Base
*/
public load(opt: any = {}): void {
public async load(opt: any = {}): Promise<any> {
if(!this.fetchAction){
this.$Notice.error({ title: (this.$t('app.commonWords.wrong') as string), desc: '${view.getName()}' + (this.$t('app.list.notConfig.fetchAction') as string) });
return;
......@@ -663,17 +663,27 @@ import CodeListService from "@/codelist/codelist-service";
const parentdata: any = {};
this.$emit('beforeload', parentdata);
Object.assign(arg, parentdata);
let tempViewParams:any = parentdata.viewparams?parentdata.viewparams:{};
let tempViewParams:any = parentdata.viewparams ? parentdata.viewparams : {};
if(this.viewparams){
Object.assign(tempViewParams,JSON.parse(JSON.stringify(this.viewparams)));
}
Object.assign(arg,{viewparams:tempViewParams});
const post: Promise<any> = this.service.search(this.fetchAction, this.context?JSON.parse(JSON.stringify(this.context)):{}, arg, this.showBusyIndicator);
post.then((response: any) => {
Object.assign(arg, { viewparams: tempViewParams });
const tempContext: any = Util.deepCopy(this.context);
if (!(await this.handleCtrlEvents('onbeforeload', { data: arg }))) {
return false;
}
try {
const response: any = await this.service.search(this.fetchAction, tempContext, arg, this.showBusyIndicator);
if (!response || response.status !== 200) {
if (!(await this.handleCtrlEvents('onloaderror', { data: response && response.data ? response.data : arg }))) {
return;
}
if (response.data && response.data.message) {
this.$Notice.error({ title: (this.$t('app.commonWords.wrong') as string), desc: response.data.message });
}
return response;
}
if (!(await this.handleCtrlEvents('onloadsuccess', { data: response.data }))) {
return;
}
const data: any = response.data;
......@@ -710,12 +720,16 @@ import CodeListService from "@/codelist/codelist-service";
<#if ctrl.isEnableGroup?? && ctrl.isEnableGroup()>
this.group();
</#if>
}, (response: any) => {
return response;
} catch (response: any) {
if (!(await this.handleCtrlEvents('onloaderror', { data: response && response.data ? response.data : arg }))) {
return;
}
if (response && response.status === 401) {
return;
}
this.$Notice.error({ title: (this.$t('app.commonWords.wrong') as string), desc: response.data && response.data.message ? response.data.message : "" });
});
}
}
/**
......@@ -790,21 +804,28 @@ import CodeListService from "@/codelist/codelist-service";
dataInfo = dataInfo + '...' + ' 共' + datas.length + '条数据';
}
const removeData = () => {
const removeData = async () => {
let keys: any[] = [];
datas.forEach((data: any) => {
keys.push(data.srfkey);
});
let _removeAction = keys.length > 1 ? 'removeBatch' : this.removeAction ;
const context:any = JSON.parse(JSON.stringify(this.context));
const post: Promise<any> = this.service.delete(_removeAction,Object.assign(context,{ ${ctrl.getPSAppDataEntity().codeName?lower_case}: keys.join(';') }),Object.assign({ ${ctrl.getPSAppDataEntity().codeName?lower_case}: keys.join(';') },{viewparams:this.viewparams}), this.showBusyIndicator);
return new Promise((resolve: any, reject: any) => {
post.then((response: any) => {
if (!(await this.handleCtrlEvents('onbeforeremove', { data: this.items }))) {
return;
}
try {
const response: any = await this.service.delete(_removeAction,Object.assign(context,{ ${ctrl.getPSAppDataEntity().codeName?lower_case}: keys.join(';') }),Object.assign({ ${ctrl.getPSAppDataEntity().codeName?lower_case}: keys.join(';') },{viewparams:this.viewparams}), this.showBusyIndicator);
if (!response || response.status !== 200) {
if (!(await this.handleCtrlEvents('onremoveerror', { data: response && response.data ? response.data : arg }))) {
return;
}
this.$Notice.error({ title: '', desc: (this.$t('app.commonWords.delDataFail') as string) + ',' + response.info });
return;
} else {
}
this.$Notice.success({ title: '', desc: (this.$t('app.commonWords.deleteSuccess') as string) });
if (!(await this.handleCtrlEvents('onremovesuccess', { data: response.data }))) {
return;
}
//删除items中已删除的项
datas.forEach((data: any) => {
......@@ -820,8 +841,11 @@ import CodeListService from "@/codelist/codelist-service";
});
this.$emit('remove', null);
this.selections = [];
resolve(response);
}).catch((response: any) => {
return response;
} catch (response: any) {
if (!(await this.handleCtrlEvents('onremoveerror', { data: response && response.data ? response.data : arg }))) {
return;
}
if (response && response.status === 401) {
return;
}
......@@ -831,8 +855,7 @@ import CodeListService from "@/codelist/codelist-service";
return;
}
reject(response);
});
});
}
}
dataInfo = dataInfo.replace(/[null]/g, '').replace(/[undefined]/g, '').replace(/[ ]/g, '');
......@@ -859,6 +882,9 @@ import CodeListService from "@/codelist/codelist-service";
let successItems:any = [];
let errorItems:any = [];
let errorMessage:any = [];
if (!(await this.handleCtrlEvents('onbeforesave'))) {
return;
}
for (const item of _this.items) {
try {
if(Object.is(item.rowDataState, 'create')){
......@@ -891,8 +917,14 @@ import CodeListService from "@/codelist/codelist-service";
this.$emit('save', successItems);
this.refresh();
if(errorItems.length === 0){
if (!(await this.handleCtrlEvents('onsavesuccess', { data: successItems }))) {
return;
}
this.$Notice.success({ title: '', desc: (this.$t('app.commonWords.saveSuccess') as string) });
}else{
} else {
if (!(await this.handleCtrlEvents('onsaveerror', { data: successItems }))) {
return;
}
errorItems.forEach((item:any,index:number)=>{
this.$Notice.error({ title: (this.$t('app.commonWords.saveFailed') as string), desc: item.majorentityname+ (this.$t('app.commonWords.saveFailed') as string) + '!' });
console.error(errorMessage[index]);
......@@ -947,6 +979,10 @@ import CodeListService from "@/codelist/codelist-service";
*
*/
public selectchange() {
this.handleCtrlEvents('onselectionchange').then((res: boolean) => {
if (!res) {
return;
}
this.selections = [];
this.items.map((item: any) => {
if (item.isselected) {
......@@ -954,6 +990,7 @@ import CodeListService from "@/codelist/codelist-service";
}
});
this.$emit('selectionchange', this.selections);
})
}
/**
......
......@@ -303,9 +303,14 @@ import UIService from '@/uiservice/ui-service';
// 处理多选数据
if(!this.isSingleSelect){
let leafNodes = checkedState.checkedNodes.filter((item:any) => item.leaf);
this.selectedNodes = JSON.parse(JSON.stringify(leafNodes));
const selectedNodes = JSON.parse(JSON.stringify(leafNodes));
this.handleCtrlEvents('onselectionchange', { action: 'SelectionChange', data: selectedNodes }).then((res: boolean) => {
if (res) {
this.selectedNodes = selectedNodes;
this.$emit('selectionchange', this.selectedNodes);
}
})
}
}
/**
......@@ -323,7 +328,11 @@ import UIService from '@/uiservice/ui-service';
return;
}
// 只处理最底层子节点
if(this.isBranchAvailable || data.leaf){
if(this.isBranchAvailable || data.leaf) {
this.handleCtrlEvents('onselectionchange', { action: 'SelectionChange', data: data }).then((res: boolean) => {
if (!res) {
return;
}
this.currentselectedNode = JSON.parse(JSON.stringify(data));
// 单选直接替换
if(this.isSingleSelect){
......@@ -331,6 +340,7 @@ import UIService from '@/uiservice/ui-service';
this.$emit('selectionchange', this.selectedNodes);
}
// 多选用check方法
});
}
}
......@@ -514,12 +524,26 @@ import UIService from '@/uiservice/ui-service';
Object.assign(tempContext,{srfparentkey:curNode.data.srfparentkey});
Object.assign(tempViewParams,{srfparentkey:curNode.data.srfparentkey});
}
Object.assign(params,{viewparams:tempViewParams});
Object.assign(params,{ viewparams: tempViewParams });
this.handleCtrlEvents('onbeforeload', { data: node.data }).then((beforeLoadResult: boolean) => {
if (!beforeLoadResult) {
return;
}
this.service.getNodes(tempContext,params).then((response: any) => {
if (!response || response.status !== 200) {
this.handleCtrlEvents('onloaderror', { data: node.data }).then((loadErrorResult: boolean) => {
if (!loadErrorResult) {
return;
}
this.$Notice.error({ title: (this.$t('app.commonWords.wrong') as string), desc: response.info });
resolve([]);
return;
})
}
this.handleCtrlEvents('onloaderror', { data: node.data }).then((loadSuccessResult: boolean) => {
if (!loadSuccessResult) {
resolve([]);
return;
}
const _items = response.data;
this.formatExpanded(_items);
......@@ -532,13 +556,20 @@ import UIService from '@/uiservice/ui-service';
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,14 +628,27 @@ import UIService from '@/uiservice/ui-service';
*/
public refresh_node(curContext:any,arg: any = {}, parentnode: boolean): void {
const { srfnodeid: id } = arg;
Object.assign(arg,{viewparams:this.viewparams});
const get: Promise<any> = this.service.getNodes(JSON.parse(JSON.stringify(curContext)),arg);
Object.assign(arg, { viewparams: this.viewparams });
this.handleCtrlEvents('onbeforerefreshnode', { data: arg }).then((beforeRefreshRes: boolean) => {
if (!beforeRefreshRes) {
return;
}
const get: Promise<any> = this.service.getNodes(JSON.parse(JSON.stringify(curContext)), arg);
get.then((response: any) => {
if (!response || response.status !== 200) {
this.handleCtrlEvents('onrefreshnodeerror', { data: response && response.data ? response.data : {} }).then((errorRes: boolean) => {
if (!errorRes) {
return;
}
this.$Notice.error({ title: (this.$t('app.commonWords.wrong') as string), desc: response.info });
return;
})
}
const _items = [...response.data];
this.handleCtrlEvents('onrefreshnodesuccess', { data: _items }).then((successRes: boolean) => {
if (!successRes) {
return;
}
this.formatExpanded(_items);
const tree: any = this.$refs.${ctrl.name};
tree.updateKeyChildren(id, _items);
......@@ -613,12 +657,19 @@ import UIService from '@/uiservice/ui-service';
}
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 到此讨论。请谨慎行事。
先完成此消息的编辑!
想要评论请 注册